All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-devel@nongnu.org, David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [Qemu-devel] [PATCH] scsi-generic: Remove bogus double complete
Date: Tue, 03 May 2011 14:14:06 +0200	[thread overview]
Message-ID: <4DBFF18E.3000602@redhat.com> (raw)
In-Reply-To: <4D9B2060.3060000@redhat.com>

On 04/05/2011 04:00 PM, Kevin Wolf wrote:
> I have a hard time each time I try to understand this SCSI stuff without
> reading a lot of code and specs. What I would have expected is this:
>
> if (len == 0) {
>      scsi_command_complete(r, 0);
> } else {
>      r->req.bus->complete(r->req.bus, SCSI_REASON_DATA, r->req.tag, len);
> }
>
> This would fix the problem that both functions are called, but still use
> SCSI_REASON_DONE if no data is transferred. This is similar to what
> scsi-disk seems to be doing. However, if you can explain to me why your
> version is more correct, I'll gladly take it.

I agree with Kevin that his version seems more correct.  The purpose of 
the code is to trigger a phase mismatch for the lsi controller, and that 
would probably not happen with your version.  s->current->dma_len would 
never go down to 0 if it were really a short transfer:

     s->current->dma_len -= count;
     if (s->current->dma_len == 0) {
         s->current->dma_buf = NULL;
         if (out) {
             /* Write the data.  */
             dev->info->write_data(dev, s->current->tag);
         } else {
             /* Request any remaining data.  */
             dev->info->read_data(dev, s->current->tag);
         }
     } else {
         s->current->dma_buf += count;
         lsi_resume_script(s);
     }

so the SCRIPTS would deadlock, waiting for the full transfer to happen, 
and the SCSI_REASON_DONE callback would never be sent.

Even with spapr_vscsi, however, what would happen is that the 
SCSI_REASON_DATA does nothing except calling sdev->info->read_data (i.e. 
scsi_read_data) again.  This would then call scsi_command_complete and 
send the SCSI_REASON_DONE callback.  So for spapr_vscsi there should be 
no difference between the two cases.

I'll include Kevin's patch into my upcoming SCSI series.

Paolo

      reply	other threads:[~2011-05-03 12:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-05  5:07 [Qemu-devel] [PATCH] scsi-generic: Remove bogus double complete David Gibson
2011-04-05 14:00 ` Kevin Wolf
2011-05-03 12:14   ` Paolo Bonzini [this message]

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=4DBFF18E.3000602@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.