All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Farman <farman@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	Cornelia Huck <cornelia.huck@de.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Alexander Graf <agraf@suse.de>,
	Eric Farman <farman@linux.vnet.ibm.com>
Subject: [Qemu-devel] [RFC PATCH v1 4/5] pc-bios/s390-ccw: Break up virtio-scsi read into multiples
Date: Wed, 26 Apr 2017 16:46:44 +0200	[thread overview]
Message-ID: <20170426144645.12476-5-farman@linux.vnet.ibm.com> (raw)
In-Reply-To: <20170426144645.12476-1-farman@linux.vnet.ibm.com>

A virtio-scsi request that goes through the host sd driver and
exceeds the maximum transfer size is automatically broken up
for us. But the equivalent request going to the sg driver
presumes that any length requirements have already been honored.
Let's use the max_sectors field from the device and break up
all virtio-scsi requests (both sd and sg) to avoid problem from
the host drivers.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
---
 pc-bios/s390-ccw/s390-ccw.h    |  4 ++++
 pc-bios/s390-ccw/virtio-scsi.c | 19 ++++++++++++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h
index ded67bc..e1f3751 100644
--- a/pc-bios/s390-ccw/s390-ccw.h
+++ b/pc-bios/s390-ccw/s390-ccw.h
@@ -42,6 +42,10 @@ typedef unsigned long long __u64;
 #ifndef NULL
 #define NULL    0
 #endif
+#ifndef MIN
+#define MIN(a, b) (((a) < (b)) ? (a) : (b));
+#endif
+
 
 #include "cio.h"
 #include "iplb.h"
diff --git a/pc-bios/s390-ccw/virtio-scsi.c b/pc-bios/s390-ccw/virtio-scsi.c
index 6d070e2..90a8cc8 100644
--- a/pc-bios/s390-ccw/virtio-scsi.c
+++ b/pc-bios/s390-ccw/virtio-scsi.c
@@ -254,12 +254,21 @@ static void virtio_scsi_locate_device(VDev *vdev)
 int virtio_scsi_read_many(VDev *vdev,
                           ulong sector, void *load_addr, int sec_num)
 {
+    int sector_count;
     int f = vdev->blk_factor;
-    unsigned int data_size = sec_num * virtio_get_block_size() * f;
-
-    if (!scsi_read_10(vdev, sector * f, sec_num * f, load_addr, data_size)) {
-        virtio_scsi_verify_response(&resp, "virtio-scsi:read_many");
-    }
+    unsigned int data_size;
+
+    do {
+        sector_count = MIN(sec_num, vdev->config.scsi.max_sectors);
+        data_size = sector_count * virtio_get_block_size() * f;
+        if (!scsi_read_10(vdev, sector * f, sector_count * f, load_addr,
+                          data_size)) {
+            virtio_scsi_verify_response(&resp, "virtio-scsi:read_many");
+        }
+        load_addr += data_size;
+        sector += sector_count;
+        sec_num -= sector_count;
+    } while (sec_num > 0);
 
     return 0;
 }
-- 
2.10.2

  parent reply	other threads:[~2017-04-26 14:47 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-26 14:46 [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX Eric Farman
2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 1/5] hw/scsi: Override the max_sectors value for virtio-scsi Eric Farman
2017-05-05  7:39   ` Paolo Bonzini
2017-05-05  7:50   ` Christian Borntraeger
2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 2/5] pc-bios/s390-ccw: Remove duplicate blk_factor adjustment Eric Farman
2017-05-05  7:10   ` Christian Borntraeger
2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 3/5] pc-bios/s390-ccw: Move SCSI block factor to outer read Eric Farman
2017-04-26 14:46 ` Eric Farman [this message]
2017-04-26 15:17   ` [Qemu-devel] [RFC PATCH v1 4/5] pc-bios/s390-ccw: Break up virtio-scsi read into multiples Eric Blake
2017-04-26 15:24     ` Eric Farman
2017-04-26 16:00       ` Eric Farman
2017-04-26 15:47     ` Cornelia Huck
2017-04-26 14:46 ` [Qemu-devel] [RFC PATCH v1 5/5] pc-bios/s390-ccw.img: rebuild image Eric Farman
2017-04-26 15:48 ` [Qemu-devel] [RFC PATCH v1 0/5] Enable virtio-scsi boot from /dev/sgX Christian Borntraeger
2017-04-26 16:13   ` Eric Farman
2017-05-05  7:41 ` Fam Zheng
2017-05-05 15:03   ` Eric Farman
2017-05-05 15:13     ` Paolo Bonzini
2017-05-05 16:12       ` Eric Farman
2017-05-06  8:24         ` Paolo Bonzini
2017-05-08  7:00           ` Christian Borntraeger
2017-05-08 15:00             ` Eric Farman

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=20170426144645.12476-5-farman@linux.vnet.ibm.com \
    --to=farman@linux.vnet.ibm.com \
    --cc=agraf@suse.de \
    --cc=borntraeger@de.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@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.