From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJgM6-0007qY-Ph for qemu-devel@nongnu.org; Fri, 06 Feb 2015 05:41:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YJgLq-0002z8-4h for qemu-devel@nongnu.org; Fri, 06 Feb 2015 05:41:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57661) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJgLp-0002yl-RM for qemu-devel@nongnu.org; Fri, 06 Feb 2015 05:41:29 -0500 Date: Fri, 6 Feb 2015 10:41:24 +0000 From: Stefan Hajnoczi Message-ID: <20150206104124.GC28079@stefanha-thinkpad.redhat.com> References: <1422999999-25868-1-git-send-email-jsnow@redhat.com> <1422999999-25868-11-git-send-email-jsnow@redhat.com> <20150205132927.GA19277@stefanha-thinkpad.redhat.com> <54D39804.2040503@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="FsscpQKzF/jJk6ya" Content-Disposition: inline In-Reply-To: <54D39804.2040503@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2 10/19] qtest/ahci: add ahci_write_fis List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow Cc: famz@redhat.com, mst@redhat.com, Stefan Hajnoczi , qemu-devel@nongnu.org, armbru@redhat.com, pbonzini@redhat.com --FsscpQKzF/jJk6ya Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Feb 05, 2015 at 11:19:16AM -0500, John Snow wrote: >=20 >=20 > On 02/05/2015 08:29 AM, Stefan Hajnoczi wrote: > >On Tue, Feb 03, 2015 at 04:46:30PM -0500, John Snow wrote: > >>Similar to ahci_set_command_header, add a helper that takes an > >>in-memory representation of a command FIS and writes it to guest > >>memory, handling endianness as-needed. > >> > >>Signed-off-by: John Snow > >>--- > >> tests/ahci-test.c | 2 +- > >> tests/libqos/ahci.c | 10 ++++++++++ > >> tests/libqos/ahci.h | 1 + > >> 3 files changed, 12 insertions(+), 1 deletion(-) > >> > >>diff --git a/tests/ahci-test.c b/tests/ahci-test.c > >>index 211274e..658956d 100644 > >>--- a/tests/ahci-test.c > >>+++ b/tests/ahci-test.c > >>@@ -728,7 +728,7 @@ static void ahci_test_identify(AHCIQState *ahci) > >> g_assert_cmphex(ahci_px_rreg(ahci, i, AHCI_PX_IS), =3D=3D, 0); > >> > >> /* Commit the Command FIS to the Command Table */ > >>- memwrite(table, &fis, sizeof(fis)); > >>+ ahci_write_fis(ahci, &fis, table); > >> > >> /* Commit the PRD entry to the Command Table */ > >> memwrite(table + 0x80, &prd, sizeof(prd)); > >>diff --git a/tests/libqos/ahci.c b/tests/libqos/ahci.c > >>index ec72627..7336781 100644 > >>--- a/tests/libqos/ahci.c > >>+++ b/tests/libqos/ahci.c > >>@@ -464,6 +464,16 @@ void ahci_destroy_command(AHCIQState *ahci, uint8_= t px, uint8_t cx) > >> ahci->port[px].prdtl[cx] =3D 0; > >> } > >> > >>+void ahci_write_fis(AHCIQState *ahci, RegH2DFIS *fis, uint64_t addr) > >>+{ > >>+ RegH2DFIS tmp =3D *fis; > >>+ > >>+ /* All other FIS fields are 8 bit and do not need to be flipped. */ > >>+ tmp.count =3D cpu_to_le16(tmp.count); > >>+ > >>+ memwrite(addr, &tmp, sizeof(tmp)); > >>+} > > > >This patch looks wrong because tmp.count is byteswapped now but not > >before. It actually works because the value is 0 so we never bothered > >to assign it explicitly. > > > >I do wonder about the 'aux' field in the FIS struct. It's uint32_t. > >Although the tests never access it, should that field be byteswapped? > > > >Stefan > > >=20 > The Aux field(s) is/are used for some NCQ subcommands, and the formatting > varies per-command, so it's not (at the moment) possible to byte swap it > automatically ahead of time. >=20 > So the answer is "sometimes, maybe, but we're not using it right now." >=20 > Also, yes, count /was/ wrong before. It's right now :) since the IDENTIFY > test as it currently stands is very literal and script-ish, there was no > need to swap the bits there before. The DMA test requires this, though. >=20 > If you'd like, I can add a comment or a note that the AUX fields are > currently ignored. We discussed the aux field on IRC. Since its structure depends on the command, it would be more appropraite to make it uint8_t aux[4] and perhaps introduce a union if we actually start using that field. That way it's clear that this is not a uint32_t that needs byteswapping. Stefan --FsscpQKzF/jJk6ya Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJU1JpUAAoJEJykq7OBq3PIJggH+gP9V9sTdMHyTJUEZOa6S2ke wClFGnn3gZ9evlLUEA64nr0ar8zagE77RPuPzDmg7bn05JVgONvehEkxNgDR1Ehn gPtwb17yNI2WBP6j+gqOmazfPjf3Bvs3hqnX08p3L95cv1YCmSMtv63c9x9YcSvk 7bFq/dKu2sMWScywuWQrRVBtk1E+7KXJmLlfksRw/Y0LbV424PhoaJNwKlPKII+N zmYtZq+GFpicYJYDAUvkhapvag9EUIXoVyEiLQhgDheisU+SVF1p8EePU+YIeK4N G+sJGnQDEoZtUUyjHWMHLqGdGLW4FmwKmlvJlGHdTCATPbJ7PfT/1YpkSuueYU0= =f7yD -----END PGP SIGNATURE----- --FsscpQKzF/jJk6ya--