From: John Snow <jsnow@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
Stefan Hajnoczi <stefanha@gmail.com>
Cc: kwolf@redhat.com, mst@redhat.com, armbru@redhat.com,
stefanha@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 0/6] AHCI Device Fixes
Date: Tue, 28 Oct 2014 21:28:26 -0400 [thread overview]
Message-ID: <545042BA.4040800@redhat.com> (raw)
In-Reply-To: <54503475.6050500@redhat.com>
On 10/28/2014 08:27 PM, Paolo Bonzini wrote:
>
>>> Yeah, I was wondering if any commands could have <512 bytes response...
>>> I sort of convinced myself that the answer was no for ATA commands, but
>>> stupidly forgot about packet (SCSI) commands. Their results are
>>> obviously shorter than 512 bytes.
>>
>> Are you referencing the sglist underflow patch? (#5 instead of #3)
>
> Hmm, yeah.
>
>> There were cases in the code already where we /assumed/ that having any bytes
>> implied we had at least a sector's worth.
>
> Even for ATAPI?
>
> If there are valid cases for
>> the sglist to have less than a sector's worth (SCSI) then I'll need to
>> touch that again as well and update all the assumptions in the IDE code
>> to look for numbytes instead of numsectors.
>
> cmd_inquiry can return 36 bytes. That can be both PIO and DMA. SeaBIOS
> only uses the DMA variant for AHCI.
>
> Paolo
>
OK. So the sglist underflow patch recognizes that functions in the DMA
loop check to see if the "prepare buf" calls succeed or not by checking
their return code, which was previously generated by something like:
return (size != 0);
Which I updated to be:
return (size / 512) != 0;
This was adjusted in two functions:
ahci_dma_prepare_buf
bmdma_prepare_buf
which are both usually accessed via the .prepare_buf member for IDE DMA OPS.
bmdma_prepare_buf is never accessed outside of this callback. AHCI's
prepare buf is called only once, in ahci_start_transfer, which is the
PIO pathway (so it includes the PACKET transfer mechanisms.) In
ahci_start_transfer, we don't actually even check the return code, so we
don't fail commands like cmd_inquiry, so this will succeed.
The only call to prepare_buf is otherwise in ide_dma_cb, which does not
include PIO or PACKET pathways, so this command should always return
full sectors.
So the code as-written does not actually prevent non-ATA commands from
working as intended, however, it is a little messy because somebody
might misunderstand what the return code from .prepare_buf really even
means.
Here's what I propose:
(1) Update the prepare_buf callback (including the AHCI and BMDMA
implementations) to return, simply, the number of bytes prepared. For
AHCI, the largest this can ever be is something like
(2) Update uses of the callback or implementations to use this number
directly to determine if the call succeeded, failed, or "succeeded
enough" for our purposes.
(3) We can reserve the return code of -1 to imply catastrophic failure.
In the meantime:
Patches 1, 2, and 6 are fine and should be merged. I have also fixed
patch 3, but I can submit that by itself a little later.
Patch 4 and 5 work best together but have the confusion documented
above, and I can do better.
next prev parent reply other threads:[~2014-10-29 1:28 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-01 22:55 [Qemu-devel] [PATCH 0/6] AHCI Device Fixes John Snow
2014-10-01 22:55 ` [Qemu-devel] [PATCH 1/6] ahci: Correct PIO/D2H FIS responses John Snow
2014-10-27 9:32 ` Markus Armbruster
2014-10-27 15:43 ` John Snow
2014-10-27 15:59 ` Markus Armbruster
2014-10-01 22:55 ` [Qemu-devel] [PATCH 2/6] ahci: Update byte count after DMA completion John Snow
2014-10-01 22:55 ` [Qemu-devel] [PATCH 3/6] ide: repair PIO transfers for cases where nsector > 1 John Snow
2014-10-01 22:55 ` [Qemu-devel] [PATCH 4/6] ahci: unify sglist preparation John Snow
2014-10-01 22:55 ` [Qemu-devel] [PATCH 5/6] ide: Correct handling of malformed/short PRDTs John Snow
2014-10-27 10:06 ` Paolo Bonzini
2014-10-27 18:30 ` John Snow
2014-10-01 22:55 ` [Qemu-devel] [PATCH 6/6] ahci: Fix SDB FIS Construction John Snow
2014-10-16 9:36 ` [Qemu-devel] [PATCH 0/6] AHCI Device Fixes John Snow
2014-10-25 20:03 ` Michael S. Tsirkin
2014-10-27 10:07 ` Paolo Bonzini
2014-10-28 13:51 ` Stefan Hajnoczi
2014-10-28 23:54 ` John Snow
2014-10-29 0:03 ` Paolo Bonzini
2014-10-29 0:06 ` John Snow
2014-10-29 0:27 ` Paolo Bonzini
2014-10-29 1:28 ` John Snow [this message]
2014-10-29 8:58 ` Paolo Bonzini
2014-10-30 10:52 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=545042BA.4040800@redhat.com \
--to=jsnow@redhat.com \
--cc=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).