diff mbox

[3/4] libata-scsi: Update SATL for ZAC drives

Message ID 1406645117-53088-4-git-send-email-hare@suse.de
State Not Applicable
Delegated to: David Miller
Headers show

Commit Message

Hannes Reinecke July 29, 2014, 2:45 p.m. UTC
ZAC (zoned-access command) drives translate into ZBC (Zoned block
command) device type for SCSI. So implement the correct mappings
into libata-scsi and update the SCSI command set versions.

Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/ata/libata-scsi.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

Comments

Christoph Hellwig July 29, 2014, 5:12 p.m. UTC | #1
On Tue, Jul 29, 2014 at 04:45:16PM +0200, Hannes Reinecke wrote:
> ZAC (zoned-access command) drives translate into ZBC (Zoned block
> command) device type for SCSI. So implement the correct mappings
> into libata-scsi and update the SCSI command set versions.

This seems to both set the periphal type to ZBC and set the
HAW_ZBC bit, which is invalid for the version of ZBC spec I've seen.

Doesn't ZAC also destinguish between host aware and host managed device
like ZBC does?

--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Hannes Reinecke July 30, 2014, 6:18 a.m. UTC | #2
On 07/29/2014 07:12 PM, Christoph Hellwig wrote:
> On Tue, Jul 29, 2014 at 04:45:16PM +0200, Hannes Reinecke wrote:
>> ZAC (zoned-access command) drives translate into ZBC (Zoned block
>> command) device type for SCSI. So implement the correct mappings
>> into libata-scsi and update the SCSI command set versions.
>
> This seems to both set the periphal type to ZBC and set the
> HAW_ZBC bit, which is invalid for the version of ZBC spec I've seen.
>
D'oh. You are correct, one should read the doc properly.

> Doesn't ZAC also destinguish between host aware and host managed device
> like ZBC does?
>
Not as such. The spec I have only differentiates between CMR 
(conventional media recording) and SMR (shingled media recording) 
zones. And every SMR zone is a sequential write required zone.
So the host aware device type with sequential write preferred zones 
is not supported.

I'll be sending an updated patch with the correct bits set.

Cheers,

Hannes
diff mbox

Patch

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index bea6e7f..500b721 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -1969,6 +1969,7 @@  static void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
 static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)
 {
 	const u8 versions[] = {
+		0x00,
 		0x60,	/* SAM-3 (no version claimed) */
 
 		0x03,
@@ -1977,6 +1978,20 @@  static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)
 		0x02,
 		0x60	/* SPC-3 (no version claimed) */
 	};
+	const u8 versions_zbc[] = {
+		0x00,
+		0xA0,	/* SAM-5 (no version claimed) */
+
+		0x04,
+		0xC0,	/* SBC-3 (no version claimed) */
+
+		0x04,
+		0x60,	/* SPC-4 (no version claimed) */
+
+		0x60,
+		0x20,   /* ZBC (no version claimed) */
+	};
+
 	u8 hdr[] = {
 		TYPE_DISK,
 		0,
@@ -1991,6 +2006,11 @@  static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)
 	if (ata_id_removeable(args->id))
 		hdr[1] |= (1 << 7);
 
+	if (args->dev->class == ATA_DEV_ZAC) {
+		hdr[0] = TYPE_ZBC;
+		hdr[2] = 0x6; /* ZBC is defined in SPC-4 */
+	}
+
 	memcpy(rbuf, hdr, sizeof(hdr));
 	memcpy(&rbuf[8], "ATA     ", 8);
 	ata_id_string(args->id, &rbuf[16], ATA_ID_PROD, 16);
@@ -2003,7 +2023,10 @@  static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)
 	if (rbuf[32] == 0 || rbuf[32] == ' ')
 		memcpy(&rbuf[32], "n/a ", 4);
 
-	memcpy(rbuf + 59, versions, sizeof(versions));
+	if (args->dev->class == ATA_DEV_ZAC)
+		memcpy(rbuf + 58, versions_zbc, sizeof(versions_zbc));
+	else
+		memcpy(rbuf + 58, versions, sizeof(versions));
 
 	return 0;
 }
@@ -2202,7 +2225,9 @@  static unsigned int ata_scsiop_inq_b1(struct ata_scsi_args *args, u8 *rbuf)
 	rbuf[4] = media_rotation_rate >> 8;
 	rbuf[5] = media_rotation_rate;
 	rbuf[7] = form_factor;
-
+	if (args->dev->class == ATA_DEV_ZAC)
+		/* SBC-4 HAW_ZBC bit */
+		rbuf[8] |= 0x10;
 	return 0;
 }