From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49080) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bx3ia-0003eW-Mw for qemu-devel@nongnu.org; Wed, 19 Oct 2016 23:08:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bx3iX-0002rR-Mm for qemu-devel@nongnu.org; Wed, 19 Oct 2016 23:08:32 -0400 Date: Thu, 20 Oct 2016 11:20:18 +1100 From: David Gibson Message-ID: <20161020002018.GM11140@umbus.fritz.box> References: <1476879941-14360-1-git-send-email-david@gibson.dropbear.id.au> <1476879941-14360-5-git-send-email-david@gibson.dropbear.id.au> <5df3d45c-7875-fbf8-6c6b-cf1c7ab2dae6@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="sMkrXc3gAYLRVOjR" Content-Disposition: inline In-Reply-To: <5df3d45c-7875-fbf8-6c6b-cf1c7ab2dae6@redhat.com> Subject: Re: [Qemu-devel] [PATCHv2 04/11] libqos: Better handling of PCI legacy IO List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laurent Vivier 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 --sMkrXc3gAYLRVOjR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Oct 19, 2016 at 03:33:33PM +0200, Laurent Vivier wrote: >=20 >=20 > 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}*(). > >=20 > > However, certain devices also have legacy PCI IO. In this case, instea= d 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. > >=20 > > Two existing tests use legacy PCI IO, and take different flawed approac= hes > > to it: > > * tco-test manually constructs a tco_io_base value instead of calli= ng > > 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 machi= ne > > types. > >=20 > > tco_test uses the libqos PCI code to access the device. This makes per= fect > > sense for the PCI config space accesses. However for IO, rather than t= he > > 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. > >=20 > > That doesn't work very well with the qpci_io_{read,write} functions bec= ause > > we never use qpci_iomap() and so have to make assumptions about the > > internal encoding of the address tokens iomap() returns. > >=20 > > 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. > >=20 > > Signed-off-by: David Gibson >=20 > 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. >=20 > Reviewed-by: Laurent Vivier >=20 > > --- > > tests/libqos/pci.c | 5 +++++ > > tests/libqos/pci.h | 1 + > > 2 files changed, 6 insertions(+) > >=20 > > 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 */ > > } > > =20 > > +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, uint= 32_t value); > > =20 > > 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); > > =20 > > void qpci_plug_device_test(const char *driver, const char *id, > > uint8_t slot, const char *opts); > >=20 >=20 --=20 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 --sMkrXc3gAYLRVOjR Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYCA2/AAoJEGw4ysog2bOStAMQAMmgpWYK6Weio9bRMA7c7jmR IAYJ8tFg1OFdqamwUVED4vP8ALeGkfuNyBQTUFt1J7TEqB4Wuj1q1y5xX1Vr3j6c Hudp9dANJLoCVqPg+o1Qe82D1D9J5fUzG3pG857lphcleD9eXv1C080z09UjM40W MdExL3/8o78oW3fWGjTOU6Qu7Ni0PYBeQWUC6NARWeLCTSxA6lU+cY7UaCF6VJh1 o6cEJ4eWc0FIyZ7wmBRdSDXhsht2vCmIf3pxA3zamz5AC96f2nTKNKBRjMGK4chr +4XR07gFc6xUEMwnUT4jS9PlvJ3U2QdhAMo0hDJ6O7HA+3KpcmosU4H3RPz3ssUA CDIS9CBN14eiNjirzF2pmVowJerReLZSkiTTsHCI7CbySD/XbRh7cj8Y7EiawJ94 /UbkmR28hLTqhBygeMuA14epo5U6ngabstTutNsPxQvvkHauoFzhVYNUVwMDRbFz 2H/bCzsiFulX6uDduqUDfps4V/rAfNIuXs1TYfsQab2n2EmzitQjlt6vzqUWTlPh SwMQMbn6cnYDbSSgeT1SgsvY3G4Kq5Fkjs4x+f5FkT4zdMsF7fXGofWwrgBtFeCY mDntVTA84ShMngXHpr1exR+Y096CYPeOV9GEe3f8YDrel20pEUrsYeTh5srJDp6b 6pSAe5GttktMD7kGEhqi =QZ0d -----END PGP SIGNATURE----- --sMkrXc3gAYLRVOjR--