From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58873) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOR7v-0001d0-1v for qemu-devel@nongnu.org; Mon, 01 Sep 2014 08:54:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XOR7g-00055b-9x for qemu-devel@nongnu.org; Mon, 01 Sep 2014 08:54:31 -0400 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:48663) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOR7f-00054z-U7 for qemu-devel@nongnu.org; Mon, 01 Sep 2014 08:54:16 -0400 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 1 Sep 2014 13:54:15 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 3D39317D8067 for ; Mon, 1 Sep 2014 13:56:09 +0100 (BST) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id s81CsCc341877608 for ; Mon, 1 Sep 2014 12:54:12 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s81Cs9CV002604 for ; Mon, 1 Sep 2014 06:54:11 -0600 From: Christian Borntraeger Date: Mon, 1 Sep 2014 14:54:16 +0200 Message-Id: <1409576070-55803-6-git-send-email-borntraeger@de.ibm.com> In-Reply-To: <1409576070-55803-1-git-send-email-borntraeger@de.ibm.com> References: <1409576070-55803-1-git-send-email-borntraeger@de.ibm.com> Subject: [Qemu-devel] [PULL 05/19] pc-bios/s390-ccw: support all virtio block size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu-devel , Alexander Graf , Christian Borntraeger , Jens Freimann , Anthony Liguori , Cornelia Huck , "Eugene (jno) Dvurechenski" , Richard Henderson From: "Eugene (jno) Dvurechenski" 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 Acked-by: Christian Borntraeger Reviewed-by: David Hildenbrand Signed-off-by: Jens Freimann Signed-off-by: Christian Borntraeger --- 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.4.2