From: Shmulik Ladkani <shmulik.ladkani@gmail.com>
To: Matt Wang <wwentao@vmware.com>,
Vishal Bhakta <vbhakta@vmware.com>,
Dmitry Fleytman <dmitry.fleytman@gmail.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
linux-scsi@vger.kernel.org,
VMware PV-Drivers <pv-drivers@vmware.com>,
qemu-devel@nongnu.org, linux-kernel@vger.kernel.org,
Paolo Bonzini <pbonzini@redhat.com>
Subject: [BUG] scsi: vmw_pvscsi: Boot hangs during scsi under qemu, post commit e662502b3a78
Date: Tue, 24 Aug 2021 12:00:28 +0300 [thread overview]
Message-ID: <20210824120028.30d9c071@blondie> (raw)
Hi,
Commit e662502b3a78 ("scsi: vmw_pvscsi: Set correct residual data length"),
and its backports to stable trees, makes kernel hang during boot, when
ran as a VM under qemu with following parameters:
-drive file=$DISKFILE,if=none,id=sda
-device pvscsi
-device scsi-hd,bus=scsi.0,drive=sda
Diving deeper, commit e662502b3a78
@@ -585,7 +585,13 @@ static void pvscsi_complete_request(struct pvscsi_adapter *adapter,
case BTSTAT_SUCCESS:
+ /*
+ * Commands like INQUIRY may transfer less data than
+ * requested by the initiator via bufflen. Set residual
+ * count to make upper layer aware of the actual amount
+ * of data returned.
+ */
+ scsi_set_resid(cmd, scsi_bufflen(cmd) - e->dataLen);
assumes 'e->dataLen' is properly armed with actual num of bytes
transferred; alas qemu's hw/scsi/vmw_pvscsi.c never arms the 'dataLen'
field of the completion descriptor (kept zero).
As a result, the residual count is set as the *entire* 'scsi_bufflen' of a
good transfer, which makes upper scsi layers repeatedly ignore this
valid transfer.
Not properly arming 'dataLen' seems as an oversight in qemu, which needs
to be fixed.
However, since kernels with commit e662502b3a78 (and backports) now fail
to boot under qemu's "-device pvscsi", a suggested workaround is to set
the residual count *only* if 'e->dataLen' is armed, e.g:
@@ -588,7 +588,8 @@ static void pvscsi_complete_request(struct pvscsi_adapter *adapter,
* count to make upper layer aware of the actual amount
* of data returned.
*/
- scsi_set_resid(cmd, scsi_bufflen(cmd) - e->dataLen);
+ if (e->dataLen)
+ scsi_set_resid(cmd, scsi_bufflen(cmd) - e->dataLen);
in order to make kernels boot on old qemu binaries.
Best,
Shmulik
reply other threads:[~2021-08-24 9:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210824120028.30d9c071@blondie \
--to=shmulik.ladkani@gmail.com \
--cc=dmitry.fleytman@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=pbonzini@redhat.com \
--cc=pv-drivers@vmware.com \
--cc=qemu-devel@nongnu.org \
--cc=vbhakta@vmware.com \
--cc=wwentao@vmware.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).