From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z9aeq-0005X2-5l for qemu-devel@nongnu.org; Mon, 29 Jun 2015 11:07:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z9ael-00084R-En for qemu-devel@nongnu.org; Mon, 29 Jun 2015 11:07:40 -0400 Message-ID: <55915F26.6070202@redhat.com> Date: Mon, 29 Jun 2015 11:07:18 -0400 From: John Snow MIME-Version: 1.0 References: <1435018875-22527-1-git-send-email-jsnow@redhat.com> <1435018875-22527-15-git-send-email-jsnow@redhat.com> <20150626155949.GF31186@stefanha-thinkpad.redhat.com> <558D8C60.3040105@redhat.com> <20150629145115.GJ32151@stefanha-thinkpad.redhat.com> In-Reply-To: <20150629145115.GJ32151@stefanha-thinkpad.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 14/16] ahci: Do not map cmd_fis to generate response List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, Stefan Hajnoczi On 06/29/2015 10:51 AM, Stefan Hajnoczi wrote: > On Fri, Jun 26, 2015 at 01:31:12PM -0400, John Snow wrote: >> On 06/26/2015 11:59 AM, Stefan Hajnoczi wrote: >>> On Mon, Jun 22, 2015 at 08:21:13PM -0400, John Snow wrote: >>>> @@ -744,8 +722,8 @@ static void ahci_write_fis_pio(AHCIDevice >>>> *ad, uint16_t len) pio_fis[9] =3D s->hob_lcyl; pio_fis[10] =3D >>>> s->hob_hcyl; pio_fis[11] =3D 0; - pio_fis[12] =3D cmd_fis[12]; - >>>> pio_fis[13] =3D cmd_fis[13]; + pio_fis[12] =3D s->nsector & 0xFF;= =20 >>>> + pio_fis[13] =3D (s->nsector >> 8) & 0xFF; >>> >>> hw/ide/core.c decreases s->nsector until it reaches 0 and the >>> request ends. >>> >>> Will the values reported back to the guest be correct if we use=20 >>> s->nsector? >>> >> >> See the commit message for justification of this one. Ultimately, it >> doesn't matter what gets put in here (for data transfer commands) -- >> but getting RID of the cmd_fis mapping is a strong positive. >=20 > Getting rid of cmd_fis mapping is good. >=20 > Putting s->nsector into the undefined fields makes the code confusing. >=20 > It is clearer to zero the bytes with a comment saying the value does no= t > matter according to the spec. >=20 Well, it's not that it doesn't matter /ever/, it's more that for standard IO routines it doesn't matter. (See the normative output spec in ATA8-AC3 -- for most cases it's N/A, but for a handful of cases it carries a diagnostic signature.) What's really the case is that the FIS always dutifully copies out what the SATA registers are (or should be.) There are still a handful of commands that, if we choose to support them, copying the nsector register would be the "correct thing" to do, so I decided to copy that field here to serve as documentation and support future command additions. I would argue that if this field ever does the /wrong thing/, it would be a fix in the S/ATA layer, and not a change to the FIS generator here. I am inclined to leave it as-is, since for the current cases, nsector is going to empty to zero anyway. I believe the behavior presented here is correct. --js