From patchwork Fri Jan 29 19:05:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 44017 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A6FC2B7D2A for ; Sat, 30 Jan 2010 06:15:20 +1100 (EST) Received: from localhost ([127.0.0.1]:39019 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NawHV-0006R8-JB for incoming@patchwork.ozlabs.org; Fri, 29 Jan 2010 14:13:25 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Naw9V-0002k9-EM for qemu-devel@nongnu.org; Fri, 29 Jan 2010 14:05:09 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Naw9Q-0002gN-Hn for qemu-devel@nongnu.org; Fri, 29 Jan 2010 14:05:08 -0500 Received: from [199.232.76.173] (port=41725 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Naw9Q-0002gG-7x for qemu-devel@nongnu.org; Fri, 29 Jan 2010 14:05:04 -0500 Received: from verein.lst.de ([213.95.11.210]:49400) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1Naw9P-0004DK-9n for qemu-devel@nongnu.org; Fri, 29 Jan 2010 14:05:03 -0500 Received: from verein.lst.de (localhost [127.0.0.1]) by verein.lst.de (8.12.3/8.12.3/Debian-7.1) with ESMTP id o0TJ51WY025409 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Fri, 29 Jan 2010 20:05:01 +0100 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-7.2) id o0TJ51ih025408; Fri, 29 Jan 2010 20:05:01 +0100 Date: Fri, 29 Jan 2010 20:05:01 +0100 From: Christoph Hellwig To: qemu-devel@nongnu.org Message-ID: <20100129190501.GB25287@lst.de> References: <20100129190417.GA25237@lst.de> Mime-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100129190417.GA25237@lst.de> User-Agent: Mutt/1.3.28i X-Spam-Score: 0 () X-Scanned-By: MIMEDefang 2.39 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: "Martin K. Petersen" Subject: [Qemu-devel] [PATCH 3/5] scsi: add topology support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Export the physical block size in the READ CAPACITY (16) command, and add the new block limits VPD page to export the minimum and optiomal I/O sizes. Note that we also need to bump the scsi revision level to SPC-2 as that is the minimum requirement by at least the Linux kernel to try READ CAPACITY (16) first and look at the block limits VPD page. Signed-off-by: Christoph Hellwig Index: qemu/hw/scsi-disk.c =================================================================== --- qemu.orig/hw/scsi-disk.c 2010-01-29 11:07:50.121003760 +0100 +++ qemu/hw/scsi-disk.c 2010-01-29 11:08:32.944025367 +0100 @@ -346,10 +346,11 @@ static int scsi_disk_emulate_inquiry(SCS case 0x00: /* Supported page codes, mandatory */ DPRINTF("Inquiry EVPD[Supported pages] " "buffer size %zd\n", req->cmd.xfer); - outbuf[buflen++] = 3; // number of pages + outbuf[buflen++] = 4; // number of pages outbuf[buflen++] = 0x00; // list of supported pages (this page) outbuf[buflen++] = 0x80; // unit serial number outbuf[buflen++] = 0x83; // device identification + outbuf[buflen++] = 0xb0; // block device characteristics break; case 0x80: /* Device serial number, optional */ @@ -391,6 +392,27 @@ static int scsi_disk_emulate_inquiry(SCS buflen += id_len; break; } + case 0xb0: /* block device characteristics */ + { + unsigned int min_io_size = bdrv_get_min_io_size(bdrv) >> 9; + unsigned int opt_io_size = bdrv_get_opt_io_size(bdrv) >> 9; + + /* required VPD size with unmap support */ + outbuf[3] = buflen = 0x3c; + + memset(outbuf + 4, 0, buflen - 4); + + /* optimal transfer length granularity */ + outbuf[6] = (min_io_size >> 8) & 0xff; + outbuf[7] = min_io_size & 0xff; + + /* optimal transfer length */ + outbuf[12] = (opt_io_size >> 24) & 0xff; + outbuf[13] = (opt_io_size >> 16) & 0xff; + outbuf[14] = (opt_io_size >> 8) & 0xff; + outbuf[15] = opt_io_size & 0xff; + break; + } default: BADF("Error: unsupported Inquiry (EVPD[%02X]) " "buffer size %zd\n", page_code, req->cmd.xfer); @@ -437,7 +459,7 @@ static int scsi_disk_emulate_inquiry(SCS memcpy(&outbuf[32], s->version ? s->version : QEMU_VERSION, 4); /* Identify device as SCSI-3 rev 1. Some later commands are also implemented. */ - outbuf[2] = 3; + outbuf[2] = 5; outbuf[3] = 2; /* Format 2 */ if (buflen > 36) { @@ -794,6 +816,8 @@ static int scsi_disk_emulate_command(SCS outbuf[9] = 0; outbuf[10] = s->cluster_size * 2; outbuf[11] = 0; + outbuf[12] = 0; + outbuf[13] = bdrv_get_physical_block_exp(bdrv); /* Protection, exponent and lowest lba field left blank. */ buflen = req->cmd.xfer; break;