From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bp5ct-0001XH-OI for qemu-devel@nongnu.org; Tue, 27 Sep 2016 23:33:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bp5cp-0002De-E5 for qemu-devel@nongnu.org; Tue, 27 Sep 2016 23:33:42 -0400 Date: Wed, 28 Sep 2016 13:05:23 +1000 From: David Gibson Message-ID: <20160928030523.GF18880@umbus> References: <1474899049-12506-1-git-send-email-lvivier@redhat.com> <1474899049-12506-5-git-send-email-lvivier@redhat.com> <20160927035313.GC30322@umbus.fritz.box> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="w3uUfsyyY1Pqa/ej" Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH 4/4] tests: enable ohci/uhci/xhci tests on PPC64 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laurent Vivier Cc: qemu-devel@nongnu.org, thuth@redhat.com, Greg Kurz , qemu-ppc@nongnu.org, Gerd Hoffmann , dgibson@redhat.com --w3uUfsyyY1Pqa/ej Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Sep 27, 2016 at 09:43:27AM +0200, Laurent Vivier wrote: >=20 >=20 > On 27/09/2016 05:53, David Gibson wrote: > > On Mon, Sep 26, 2016 at 04:10:49PM +0200, Laurent Vivier wrote: >=20 > >> void qusb_pci_init_one(QPCIBus *pcibus, struct qhc *hc, uint32_t devf= n, int bar) > >> { > >> hc->dev =3D qpci_device_find(pcibus, devfn); > >> @@ -31,6 +38,13 @@ void uhci_port_test(struct qhc *hc, int port, uint1= 6_t expect) > >> uint16_t value =3D qpci_io_readw(hc->dev, addr); > >> uint16_t mask =3D ~(UHCI_PORT_WRITE_CLEAR | UHCI_PORT_RSVD1); > >> =20 > >> + if (qtest_big_endian() && host_big_endian) { > >> + /* little endian device on big endian guest > >> + * must be swapped on big endian host > >> + */ > >> + value =3D bswap16(value); > >> + } > >> + > >=20 > > Hm.. should the qpci_io_*() helpers handle the endian conversion? >=20 > I'm really wondering how to manage correctly this case (I've the same > kind of issue with virtio). >=20 > The protocol between guest and test program reads/writes data using the > guest CPU endianess, so it works in the overall case. Oh.. That seems bogus; maybe we should change that. IIUC the protocol is transferring whole word values as strings. In which case we should be transferring whole word values - endianness should only come into play if we're associating bytes in the value with addresses. So using (poorly defined) guest endianness is a design error here - we should use "host endianness"; really "no endianness". > But in this case, > hcd-uhci is a little-endian device (.endianness =3D DEVICE_LITTLE_ENDIAN) > on a big endian machine, so I think in the linux driver we should have a > "le16_to_cpu()". But in our case we can't use "le16_to_cpu()" because > endianess of the host cpu is not the same has the one of the guest CPU. > Perhaps I should add a "target_le16_to_cpu()"? >=20 > Thanks, > Laurent >=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 --w3uUfsyyY1Pqa/ej Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJX6zNxAAoJEGw4ysog2bOSbSgQAN3p6n2q79vcfLRlF6qXEuCZ tt1nXgPD0p/AzPrArsYPYI0NPEO1vF5Vz/PoWp/YIJMRL/n+WjRbJzzNgwRPzZ73 //Gqk1g0Hc17cg6M8dK19YGEO+YDY8lmeIR5aal4/riW4nN9aZAxFMY8NeJOpgMt O+1+fFx4LJ97+Xe0GRIhAchPdfTThpaUPYocsHgs3X32zoAmSWXbfQOW6Y1wtJ2C JJEGfz4k+ieu1NL9nE23pIGOUPHytHpb5NXMzj6scs3984Jg3/5rFHoitLcEstbm hPkGBdkySpjth4QcrI7qHQUW+i/33AZT17V8J+jvOw3pIrtM10wwNUEyZ9qRYZV7 Qsm99fnRvMNe5gYmzySkZAUWyDALM+pli7IpVAkPM4tHreJGeUPL8dAuHuxjQVU6 Z4GzF9oqOQgkTzqLf4mrnbz/iF7+Ww3HTHJke3g9+u1DcRMcQ/4rMl9LfBoobJTT mUxFiHlkiSNfeY0EN9XU7STFLr4hbkQWjHPG715Hise/C6C+akDtNxUPwB2OArRp pN2s60TzjOru0iQq1TT2rpL5gexCJ3/qyC/VdJ5CmJiAtk47+FaLBa+xprfroUsf O9x2euAdPaMBLqeKQNFd1dI+BiA+gjdU6CDarAm5BfOKP6dwcWBN9fZvkf94ebij 9CjLdzjlfLTJsk4U8C7x =xEi7 -----END PGP SIGNATURE----- --w3uUfsyyY1Pqa/ej--