From: David Gibson <david@gibson.dropbear.id.au>
To: Laurent Vivier <lvivier@redhat.com>
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, qemu-ppc@nongnu.org,
agraf@suse.de, stefanha@redhat.com, mst@redhat.com,
aik@ozlabs.ru, mdroth@linux.vnet.ibm.com, groug@kaod.org,
thuth@redhat.com
Subject: Re: [Qemu-devel] [PATCHv2 04/11] libqos: Better handling of PCI legacy IO
Date: Thu, 20 Oct 2016 11:20:18 +1100 [thread overview]
Message-ID: <20161020002018.GM11140@umbus.fritz.box> (raw)
In-Reply-To: <5df3d45c-7875-fbf8-6c6b-cf1c7ab2dae6@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3601 bytes --]
On Wed, Oct 19, 2016 at 03:33:33PM +0200, Laurent Vivier wrote:
>
>
> On 19/10/2016 14:25, David Gibson wrote:
> > The usual model for PCI IO with libqos is to use qpci_iomap() to map a
> > specific BAR for a PCI device, then perform IOs within that BAR using
> > qpci_io_{read,write}*().
> >
> > However, certain devices also have legacy PCI IO. In this case, instead of
> > (or as well as) being accessed via PCI BARs, the device can be accessed
> > via certain well-known, fixed addresses in PCI IO space.
> >
> > Two existing tests use legacy PCI IO, and take different flawed approaches
> > to it:
> > * tco-test manually constructs a tco_io_base value instead of calling
> > qpci_iomap(), which assumes internal knowledge of the structure of
> > the value it shouldn't have
> > * ide-test uses direct in*() and out*() calls instead of using
> > qpci_io_*() accessors, meaning it's not portable to non-x86 machine
> > types.
> >
> > 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 <david@gibson.dropbear.id.au>
>
> This patch makes sense but it is not obvious (at least for me) why you
> are doing this if I don't read patch 11/11 before...
Probably doesn't help that I didn't finish rewriting the commit
message properly. I've removed no longer relevant stuff about
tco_test and putting some clarifying information about why this is
useful instead.
>
> Reviewed-by: Laurent Vivier <lvivier@redhat.com>
>
> > ---
> > tests/libqos/pci.c | 5 +++++
> > tests/libqos/pci.h | 1 +
> > 2 files changed, 6 insertions(+)
> >
> > diff --git a/tests/libqos/pci.c b/tests/libqos/pci.c
> > index bf1c532..98a2e56 100644
> > --- a/tests/libqos/pci.c
> > +++ b/tests/libqos/pci.c
> > @@ -350,6 +350,11 @@ void qpci_iounmap(QPCIDevice *dev, void *data)
> > /* FIXME */
> > }
> >
> > +void *qpci_legacy_iomap(QPCIDevice *dev, uint16_t addr)
> > +{
> > + return (void *)(uintptr_t)addr;
> > +}
> > +
> > void qpci_plug_device_test(const char *driver, const char *id,
> > uint8_t slot, const char *opts)
> > {
> > diff --git a/tests/libqos/pci.h b/tests/libqos/pci.h
> > index f6f916d..b6f855e 100644
> > --- a/tests/libqos/pci.h
> > +++ b/tests/libqos/pci.h
> > @@ -94,6 +94,7 @@ void qpci_io_writel(QPCIDevice *dev, void *data, uint32_t value);
> >
> > void *qpci_iomap(QPCIDevice *dev, int barno, uint64_t *sizeptr);
> > void qpci_iounmap(QPCIDevice *dev, void *data);
> > +void *qpci_legacy_iomap(QPCIDevice *dev, uint16_t addr);
> >
> > void qpci_plug_device_test(const char *driver, const char *id,
> > uint8_t slot, const char *opts);
> >
>
--
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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-10-20 3:08 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-19 12:25 [Qemu-devel] [PATCHv2 00/11] Cleanups to qtest PCI handling David Gibson
2016-10-19 12:25 ` [Qemu-devel] [PATCHv2 01/11] libqos: Give qvirtio_config_read*() consistent semantics David Gibson
2016-10-19 13:17 ` Laurent Vivier
2016-10-19 13:29 ` Greg Kurz
2016-10-19 12:25 ` [Qemu-devel] [PATCHv2 02/11] libqos: Handle PCI IO de-multiplexing in common code David Gibson
2016-10-19 13:20 ` Laurent Vivier
2016-10-19 14:45 ` Greg Kurz
2016-10-19 12:25 ` [Qemu-devel] [PATCHv2 03/11] libqos: Move BAR assignment to " David Gibson
2016-10-19 13:22 ` Laurent Vivier
2016-10-19 12:25 ` [Qemu-devel] [PATCHv2 04/11] libqos: Better handling of PCI legacy IO David Gibson
2016-10-19 13:33 ` Laurent Vivier
2016-10-20 0:20 ` David Gibson [this message]
2016-10-19 12:25 ` [Qemu-devel] [PATCHv2 05/11] tests: Adjust tco-test to use qpci_legacy_iomap() David Gibson
2016-10-19 13:35 ` Laurent Vivier
2016-10-19 12:25 ` [Qemu-devel] [PATCHv2 06/11] libqos: Add streaming accessors for PCI MMIO David Gibson
2016-10-19 12:25 ` [Qemu-devel] [PATCHv2 07/11] libqos: Implement mmio accessors in terms of mem{read, write} David Gibson
2016-10-19 13:38 ` Laurent Vivier
2016-10-19 12:25 ` [Qemu-devel] [PATCHv2 08/11] tests: Clean up IO handling in ide-test David Gibson
2016-10-19 14:43 ` Laurent Vivier
2016-10-19 14:51 ` Laurent Vivier
2016-10-20 3:24 ` David Gibson
2016-10-19 12:25 ` [Qemu-devel] [PATCHv2 09/11] libqos: Add 64-bit PCI IO accessors David Gibson
2016-10-19 14:16 ` Laurent Vivier
2016-10-19 12:25 ` [Qemu-devel] [PATCHv2 10/11] tests: Use qpci_mem{read, write} in ivshmem-test David Gibson
2016-10-19 14:20 ` Laurent Vivier
2016-10-19 12:25 ` [Qemu-devel] [PATCHv2 11/11] libqos: Change PCI accessors to take opaque BAR handle David Gibson
2016-10-19 14:35 ` Laurent Vivier
2016-10-20 3:34 ` David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161020002018.GM11140@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=agraf@suse.de \
--cc=aik@ozlabs.ru \
--cc=groug@kaod.org \
--cc=lvivier@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=stefanha@redhat.com \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).