qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jens Freimann <jfrei@linux.vnet.ibm.com>
To: Christian Borntraeger <borntraeger@de.ibm.com>,
	Alexander Graf <agraf@suse.de>,
	Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: "Eugene (jno) Dvurechenski" <jno@linux.vnet.ibm.com>,
	Jens Freimann <jfrei@linux.vnet.ibm.com>,
	qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 1/7] pc-bios/s390-ccw: support all virtio block size
Date: Fri, 29 Aug 2014 11:01:36 +0200	[thread overview]
Message-ID: <1409302902-57391-2-git-send-email-jfrei@linux.vnet.ibm.com> (raw)
In-Reply-To: <1409302902-57391-1-git-send-email-jfrei@linux.vnet.ibm.com>

From: "Eugene (jno) Dvurechenski" <jno@linux.vnet.ibm.com>

The block size value may be given "as is" OR as a base value and
a shift count (exponent). So, we have to use calculation to get
the proper number in the code.

The main expression reads as
        (blk_cfg.blk_size << blk_cfg.physical_block_exp)

E.g., various combinations between blk_size=1/physical_block_exp=12
and blk_size=4096/physical_block_exp=0 are valid for 4K blocks.

Signed-off-by: Eugene (jno) Dvurechenski <jno@linux.vnet.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
---
 pc-bios/s390-ccw/virtio.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
index 31b23b0..04977e4 100644
--- a/pc-bios/s390-ccw/virtio.c
+++ b/pc-bios/s390-ccw/virtio.c
@@ -275,12 +275,14 @@ void virtio_assume_scsi(void)
 {
     guessed_disk_nature = true;
     blk_cfg.blk_size = 512;
+    blk_cfg.physical_block_exp = 0;
 }
 
 void virtio_assume_eckd(void)
 {
     guessed_disk_nature = true;
     blk_cfg.blk_size = 4096;
+    blk_cfg.physical_block_exp = 0;
 
     /* this must be here to calculate code segment position */
     blk_cfg.geometry.heads = 15;
@@ -290,31 +292,31 @@ void virtio_assume_eckd(void)
 bool virtio_disk_is_scsi(void)
 {
     if (guessed_disk_nature) {
-        return (blk_cfg.blk_size  == 512);
+        return (virtio_get_block_size()  == 512);
     }
     return (blk_cfg.geometry.heads == 255)
         && (blk_cfg.geometry.sectors == 63)
-        && (blk_cfg.blk_size  == 512);
+        && (virtio_get_block_size()  == 512);
 }
 
 bool virtio_disk_is_eckd(void)
 {
     if (guessed_disk_nature) {
-        return (blk_cfg.blk_size  == 4096);
+        return (virtio_get_block_size()  == 4096);
     }
     return (blk_cfg.geometry.heads == 15)
         && (blk_cfg.geometry.sectors == 12)
-        && (blk_cfg.blk_size  == 4096);
+        && (virtio_get_block_size()  == 4096);
 }
 
 bool virtio_ipl_disk_is_valid(void)
 {
-    return blk_cfg.blk_size && (virtio_disk_is_scsi() || virtio_disk_is_eckd());
+    return virtio_disk_is_scsi() || virtio_disk_is_eckd();
 }
 
 int virtio_get_block_size(void)
 {
-    return blk_cfg.blk_size;
+    return blk_cfg.blk_size << blk_cfg.physical_block_exp;
 }
 
 uint16_t virtio_get_cylinders(void)
-- 
1.8.5.5

  reply	other threads:[~2014-08-29  9:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-29  9:01 [Qemu-devel] [PATCH 0/7] s390-ccw.img: block size and DASD format support Jens Freimann
2014-08-29  9:01 ` Jens Freimann [this message]
2014-08-29  9:01 ` [Qemu-devel] [PATCH 2/7] pc-bios/s390-ccw: handle more ECKD DASD block sizes Jens Freimann
2014-08-29  9:01 ` [Qemu-devel] [PATCH 3/7] pc-bios/s390-ccw Improve ECKD informational message Jens Freimann
2014-08-29  9:01 ` [Qemu-devel] [PATCH 4/7] pc-bios/s390-ccw Really big EAV ECKD DASD handling Jens Freimann
2014-08-29  9:01 ` [Qemu-devel] [PATCH 5/7] pc-bios/s390-ccw: IPL from DASD with format variations Jens Freimann
2014-08-29  9:01 ` [Qemu-devel] [PATCH 6/7] pc-bios/s390-ccw: Do proper console setup Jens Freimann
2014-08-29  9:01 ` [Qemu-devel] [PATCH 7/7] pc-bios/s390-ccw.img binary update Jens Freimann
2014-08-29 10:10 ` [Qemu-devel] [PATCH 0/7] s390-ccw.img: block size and DASD format support Christian Borntraeger
2014-09-05 23:26   ` Alexander Graf

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=1409302902-57391-2-git-send-email-jfrei@linux.vnet.ibm.com \
    --to=jfrei@linux.vnet.ibm.com \
    --cc=agraf@suse.de \
    --cc=borntraeger@de.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=jno@linux.vnet.ibm.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 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).