From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bxpjU-0005lJ-2z for qemu-devel@nongnu.org; Sat, 22 Oct 2016 02:24:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bxpjQ-0005EQ-66 for qemu-devel@nongnu.org; Sat, 22 Oct 2016 02:24:40 -0400 Date: Sat, 22 Oct 2016 15:50:11 +1100 From: David Gibson Message-ID: <20161022045011.GA19629@umbus.fritz.box> References: <1477012792-3326-1-git-send-email-david@gibson.dropbear.id.au> <1477012792-3326-5-git-send-email-david@gibson.dropbear.id.au> <20161021120506.659ad412@bahia> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="envbJBWh7q8WU6mo" Content-Disposition: inline In-Reply-To: <20161021120506.659ad412@bahia> Subject: Re: [Qemu-devel] [PATCHv4 04/11] libqos: Better handling of PCI legacy IO List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Greg Kurz Cc: aik@ozlabs.ru, pbonzini@redhat.com, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, lvivier@redhat.com, agraf@suse.de, stefanha@redhat.com, mst@redhat.com, mdroth@linux.vnet.ibm.com, thuth@redhat.com --envbJBWh7q8WU6mo Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Oct 21, 2016 at 12:05:06PM +0200, Greg Kurz wrote: > On Fri, 21 Oct 2016 12:19:45 +1100 > David Gibson wrote: >=20 > > 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 > > This patch implements a new qpci_iomap_legacy() interface which gets a > > handle in the same format as qpci_iomap() but refers to a region in > > the legacy PIO space. For a device which has the same registers > > available both in a BAR and in legacy space (quite common), this > > allows the same test code to test both options with just a different > > iomap() at the beginning. > >=20 > > Signed-off-by: David Gibson > > Reviewed-by: Laurent Vivier > > --- > > 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; > > +} > > + >=20 > Since both tco-test and ide-test are hardcoded for x86 machine types, is > it right for this implementation to sit in common PCI code instead of > the PC specific one ? Those tests are x86 specific for now. tco-test is of some ICH9 internal device so it probably always will be. But it's absolutely possible to have a legacy IDE controller on another platform. Even if those specific tests don't happen, it's likely someone will want to test some sort of legacy device on another platform at some point. [Even though the "legacy" in question is old PCs, it's not uncommon to see these devices on other platforms - a PC-style southbridge chip including an ISA bridge and legacy devices is a cheap way of getting a bunch of useful gadgets on your board, so it's pretty common on many archs] > > 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 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 --envbJBWh7q8WU6mo Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYCvAAAAoJEGw4ysog2bOSq/gQAMlms9VPTVv370qVQdognZck nbkdeY8SH7ihgALu5eNj/uvaeguG3nBQT2KMkjupt6FQ8c/NnvnOkj5XAMbBtJMu XbWBC+SmLfhj1KHsfY4vTnrfzGgOyacuQwlhmOGYvgwWT9UAbhohwJBfPmGsfKtA cgzWTsbHYP8a3NIIRXaa0B5APN532weMdh5rs0s7PBzqstv/ydoVg3V4Xd2zYuYt QBJlr6WuNNjbf9T5Gkpka3/EzArM8sxR/WqTUjvD1kLvKnjt9NH7yrQtFYWC6tJ1 SmUyI6Tb9pATwwzIgOueOguGxfIcAY2m9A0sNCHgsCHeEXgYHNFsDwVGHHh4eTEQ r8fl7CZOQwIhea5yJOsyR9g7y89B2P4INFIJjGFti8LaSleooM8CkHtmwLjS9C3R VnfAuYddixs2+1D923dx3ToGov8BUSRFgWgaIfVPGJH2BCW7Ruand1LHZSXmec0K +mHqJLJWSQ9m1LUly97j79pILHYeEP+W64m2KL1Gd4IndTxaSmdgCGuQk4bKeFxp 1I5m+AjZLSHlPRTIJS8KD5RLsIDs57qWKO0rCt3GmodLLfDmWkn2yVXvUfjF3cBy v13eCvYlussGG6mjPi7dR62MOavhuHA5g+YLO5LJ6qC2p2GuOvCJYYQ8EyJTkpSO Cb34xzTh6HH+wwaBy75+ =umNF -----END PGP SIGNATURE----- --envbJBWh7q8WU6mo--