qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 4/8] tests: Better handle legacy IO addresses in


From: David Gibson
Subject: Re: [Qemu-devel] [PATCH 4/8] tests: Better handle legacy IO addresses in tco-test
Date: Wed, 19 Oct 2016 14:09:51 +1100
User-agent: Mutt/1.7.0 (2016-08-17)

On Tue, Oct 18, 2016 at 05:14:04PM +0200, Laurent Vivier wrote:
> 
> 
> On 18/10/2016 12:52, David Gibson wrote:
> > tco_test uses the libqos PCI code to access the device.  This makes perfect
> > sense for the PCI config space accesses.  However for IO, rather than the
> > usual PCI approach of mapping a PCI BAR, then accessing that, it instead
> > uses the legacy approach of fixed, known addresses in PCI IO space.
> > 
> > That doesn't work very well with the qpci_io_{read,write} functions because
> > we never use qpci_iomap() and so have to make assumptions about the
> > internal encoding of the address tokens iomap() returns.
> > 
> > This patch avoids that, by directly using the bus's pio_{read,write}
> > callbacks, which are defined to take addresses within the PCI IO space.
> > 
> > Signed-off-by: David Gibson <address@hidden>
> > ---
> >  tests/tco-test.c | 87 
> > ++++++++++++++++++++++++++++----------------------------
> >  1 file changed, 44 insertions(+), 43 deletions(-)
> > 
> > diff --git a/tests/tco-test.c b/tests/tco-test.c
> > index 0d201b1..e668630 100644
> > --- a/tests/tco-test.c
> > +++ b/tests/tco-test.c
> > @@ -40,13 +40,13 @@ enum {
> >  typedef struct {
> >      const char *args;
> >      bool noreboot;
> > +    QPCIBus *bus;
> >      QPCIDevice *dev;
> > -    void *tco_io_base;
> > +    uint16_t tco_io_base;
> >  } TestData;
> >  
> >  static void test_init(TestData *d)
> >  {
> > -    QPCIBus *bus;
> >      QTestState *qs;
> >      char *s;
> >  
> > @@ -57,8 +57,8 @@ static void test_init(TestData *d)
> >      qtest_irq_intercept_in(qs, "ioapic");
> >      g_free(s);
> >  
> > -    bus = qpci_init_pc(NULL);
> > -    d->dev = qpci_device_find(bus, QPCI_DEVFN(0x1f, 0x00));
> > +    d->bus = qpci_init_pc(NULL);
> 
> You can use qtest_pc_boot() now.

I could, but that's not really in scope for this patch.

> > +    d->dev = qpci_device_find(d->bus, QPCI_DEVFN(0x1f, 0x00));
> >      g_assert(d->dev != NULL);
> >  
> >      qpci_device_enable(d->dev);
> > @@ -70,42 +70,42 @@ static void test_init(TestData *d)
> >      /* set Root Complex BAR */
> >      qpci_config_writel(d->dev, ICH9_LPC_RCBA, RCBA_BASE_ADDR | 0x1);
> >  
> > -    d->tco_io_base = (void *)((uintptr_t)PM_IO_BASE_ADDR + 0x60);
> > +    d->tco_io_base = PM_IO_BASE_ADDR + 0x60;
> 
> Why don't you use QPCIBar in TestData to store the address?
> And you can call qpci_io_XXX() with it.

As noted in your later patch, QPCIBar hasn't been introduced at this
stage of the series.  Further, storing the address in there would
require the testcase to understand the QPCIBar's internal structure,
which is exactly what I'm trying to avoid.

Now, it's quite likely that the ICH9 device here has the same
registers aliased in a PIO bar, which we could map in the normal way.
However, if we did that, we wouldn't be testing quite the same thing -
we'd be testing availability of the registers via the BAR address,
rather than via the fixed legacy address.

-- 
David Gibson                    | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
                                | _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]