Skip to contentSkip to conversation

Initial SMR drive support

PATCH Superseded Hannes Reinecke 2 participants 11 messages Jun 2, 2014 – Jun 14, 2014

Subsystems (5)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Initial SMR drive support

Hi all,

this is a first stab at implementing SMR support. The powers that be decided to call the ATA implementation 'ZAC' (zoned access commands), and the SCSI implementation 'ZBC' (zoned block commands).

This is just basic enablement to get ZAC and ZBC drives detected as such. None of the specific commands like 'report zones' or 'reset write pointer' have been implemented yet. Reasoning here is that the format of the 'report zones' command is still not finalized. Currently the formats for the ZAC log page and the ZBZ 'report zones' command are not identical, so one would need some translation logic here. But I was given to understand that both should be made identical for the final standard.

Hannes Reinecke (3):
libata: consolidate ata_dev_classify()
libata: Implement ATA_DEV_ZAC
scsi: Implement 'ZBC' device type

 drivers/ata/libahci.c               | 11 +++----
 drivers/ata/libata-core.c           | 34 +++++++++++++-------
 drivers/ata/libata-eh.c             |  7 +++--
 drivers/ata/libata-scsi.c           | 13 ++++++--
 drivers/ata/libata-sff.c            |  2 +-
 drivers/ata/libata-transport.c      |  1 +
 drivers/ata/sata_fsl.c              | 11 +++----
 drivers/ata/sata_inic162x.c         |  2 +-
 drivers/ata/sata_sil24.c            |  2 +-
 drivers/scsi/aic94xx/aic94xx_task.c | 10 +++---
 drivers/scsi/isci/request.c         |  4 +--
 drivers/scsi/libsas/sas_ata.c       | 63 +++++--------------------------------
 drivers/scsi/mvsas/mv_sas.c         |  4 +--
 drivers/scsi/pm8001/pm8001_hwi.c    |  2 +-
 drivers/scsi/pm8001/pm80xx_hwi.c    |  2 +-
 drivers/scsi/scsi.c                 |  2 ++
 drivers/scsi/scsi_scan.c            |  1 +
 drivers/scsi/sd.c                   | 16 ++++++----
 include/linux/libata.h              |  8 +++--
 include/scsi/libsas.h               |  2 +-
 include/scsi/scsi.h                 |  1 +
 21 files changed, 90 insertions(+), 108 deletions(-)
Signature · 1 line
1.7.12.4
#1 lore raw

PATCH 1/3 libata: consolidate ata_dev_classify()

ata_dev_classify() just uses the 'lbah' and 'lbam' fields from the taskfile, so we can as well use those as arguments and rip out the custom code from sas_ata.

---
 drivers/ata/libahci.c               | 11 +++----
 drivers/ata/libata-core.c           | 14 +++++----
 drivers/ata/libata-sff.c            |  2 +-
 drivers/ata/sata_fsl.c              | 11 +++----
 drivers/ata/sata_inic162x.c         |  2 +-
 drivers/ata/sata_sil24.c            |  2 +-
 drivers/scsi/aic94xx/aic94xx_task.c | 10 +++---
 drivers/scsi/isci/request.c         |  4 +--
 drivers/scsi/libsas/sas_ata.c       | 63 +++++--------------------------------
 drivers/scsi/mvsas/mv_sas.c         |  4 +--
 drivers/scsi/pm8001/pm8001_hwi.c    |  2 +-
 drivers/scsi/pm8001/pm80xx_hwi.c    |  2 +-
 include/linux/libata.h              |  2 +-
 include/scsi/libsas.h               |  2 +-
 14 files changed, 42 insertions(+), 89 deletions(-)
drivers/ata/libahci.c +5 -6
index 6bd4f66..1851d85 100644
@@ -1173,16 +1173,15 @@ static void ahci_dev_config(struct ata_device *dev)
 unsigned int ahci_dev_classify(struct ata_port *ap)
 {
 	void __iomem *port_mmio = ahci_port_base(ap);
-	struct ata_taskfile tf;
+	u8 lbah, lbam, lbal;
 	u32 tmp;
 
 	tmp = readl(port_mmio + PORT_SIG);
-	tf.lbah		= (tmp >> 24)	& 0xff;
-	tf.lbam		= (tmp >> 16)	& 0xff;
-	tf.lbal		= (tmp >> 8)	& 0xff;
-	tf.nsect	= (tmp)		& 0xff;
+	lbah		= (tmp >> 24)	& 0xff;
+	lbam		= (tmp >> 16)	& 0xff;
+	lbal		= (tmp >> 8)	& 0xff;
 
-	return ata_dev_classify(&tf);
+	return ata_dev_classify(lbah, lbam, lbal);
 }
 EXPORT_SYMBOL_GPL(ahci_dev_classify);
 
drivers/ata/libata-core.c +8 -6
index 943cc8b..40ea074 100644
@@ -1032,7 +1032,9 @@ const char *sata_spd_string(unsigned int spd)
 
 /**
  *	ata_dev_classify - determine device type based on ATA-spec signature
- *	@tf: ATA taskfile register set for device to be identified
+ *	@lbah: LBA high byte (LBA bits 23:16)
+ *	@lbam: LBA mid byte (LBA bits 15:8)
+ *	@lbal: LBA low byte (LBA bits 7:0)
  *
  *	Determine from taskfile register contents whether a device is
  *	ATA or ATAPI, as per "Signature and persistence" section
@@ -1045,7 +1047,7 @@ const char *sata_spd_string(unsigned int spd)
  *	Device type, %ATA_DEV_ATA, %ATA_DEV_ATAPI, %ATA_DEV_PMP or
  *	%ATA_DEV_UNKNOWN the event of failure.
  */
-unsigned int ata_dev_classify(const struct ata_taskfile *tf)
+unsigned int ata_dev_classify(u8 lbah, u8 lbam, u8 lbal)
 {
 	/* Apple's open source Darwin code hints that some devices only
 	 * put a proper signature into the LBA mid/high registers,
@@ -1068,22 +1070,22 @@ unsigned int ata_dev_classify(const struct ata_taskfile *tf)
 	 * SEMB signature.  This is worked around in
 	 * ata_dev_read_id().
 	 */
-	if ((tf->lbam == 0) && (tf->lbah == 0)) {
+	if ((lbam == 0) && (lbah == 0)) {
 		DPRINTK("found ATA device by sig\n");
 		return ATA_DEV_ATA;
 	}
 
-	if ((tf->lbam == 0x14) && (tf->lbah == 0xeb)) {
+	if ((lbam == 0x14) && (lbah == 0xeb)) {
 		DPRINTK("found ATAPI device by sig\n");
 		return ATA_DEV_ATAPI;
 	}
 
-	if ((tf->lbam == 0x69) && (tf->lbah == 0x96)) {
+	if ((lbam == 0x69) && (lbah == 0x96)) {
 		DPRINTK("found PMP device by sig\n");
 		return ATA_DEV_PMP;
 	}
 
-	if ((tf->lbam == 0x3c) && (tf->lbah == 0xc3)) {
+	if ((lbam == 0x3c) && (lbah == 0xc3)) {
 		DPRINTK("found SEMB device by sig (could be ATA device)\n");
 		return ATA_DEV_SEMB;
 	}
drivers/ata/libata-sff.c +1 -1
index b603720..46e1872 100644
@@ -1903,7 +1903,7 @@ unsigned int ata_sff_dev_classify(struct ata_device *dev, int present,
 		return ATA_DEV_NONE;
 
 	/* determine if device is ATA or ATAPI */
-	class = ata_dev_classify(&tf);
+	class = ata_dev_classify(tf.lbah, tf.lbam, tf.lbal);
 
 	if (class == ATA_DEV_UNKNOWN) {
 		/* If the device failed diagnostic, it's likely to
drivers/ata/sata_fsl.c +5 -6
index fb0b40a..1ba929a 100644
@@ -821,8 +821,8 @@ static unsigned int sata_fsl_dev_classify(struct ata_port *ap)
 {
 	struct sata_fsl_host_priv *host_priv = ap->host->private_data;
 	void __iomem *hcr_base = host_priv->hcr_base;
-	struct ata_taskfile tf;
 	u32 temp;
+	u8 lbah, lbam, lbal;
 
 	temp = ioread32(hcr_base + SIGNATURE);
 
@@ -830,12 +830,11 @@ static unsigned int sata_fsl_dev_classify(struct ata_port *ap)
 	VPRINTK("HStatus = 0x%x\n", ioread32(hcr_base + HSTATUS));
 	VPRINTK("HControl = 0x%x\n", ioread32(hcr_base + HCONTROL));
 
-	tf.lbah = (temp >> 24) & 0xff;
-	tf.lbam = (temp >> 16) & 0xff;
-	tf.lbal = (temp >> 8) & 0xff;
-	tf.nsect = temp & 0xff;
+	lbah = (temp >> 24) & 0xff;
+	lbam = (temp >> 16) & 0xff;
+	lbal = (temp >>  8) & 0xff;
 
-	return ata_dev_classify(&tf);
+	return ata_dev_classify(lbah, lbam, lbal);
 }
 
 static int sata_fsl_hardreset(struct ata_link *link, unsigned int *class,
drivers/ata/sata_inic162x.c +1 -1
index 5c54d95..caa399c 100644
@@ -649,7 +649,7 @@ static int inic_hardreset(struct ata_link *link, unsigned int *class,
 		}
 
 		inic_tf_read(ap, &tf);
-		*class = ata_dev_classify(&tf);
+		*class = ata_dev_classify(tf. lbah, tf.lbam, tf.lbal);
 	}
 
 	return 0;
drivers/ata/sata_sil24.c +1 -1
index aa1051b..1ca9c05 100644
@@ -684,7 +684,7 @@ static int sil24_softreset(struct ata_link *link, unsigned int *class,
 	}
 
 	sil24_read_tf(ap, 0, &tf);
-	*class = ata_dev_classify(&tf);
+	*class = ata_dev_classify(tf.lbah, tf.lbam, tf.lbal);
 
 	DPRINTK("EXIT, class=%u\n", *class);
 	return 0;
drivers/scsi/aic94xx/aic94xx_task.c +5 -5
index 59b86e2..7abbe42 100644
@@ -373,10 +373,10 @@ static int asd_build_ata_ascb(struct asd_ascb *ascb, struct sas_task *task,
 
 	if (unlikely(task->ata_task.device_control_reg_update))
 		scb->header.opcode = CONTROL_ATA_DEV;
-	else if (dev->sata_dev.command_set == ATA_COMMAND_SET)
-		scb->header.opcode = INITIATE_ATA_TASK;
-	else
+	else if (dev->sata_dev.class == ATA_DEV_ATAPI)
 		scb->header.opcode = INITIATE_ATAPI_TASK;
+	else
+		scb->header.opcode = INITIATE_ATA_TASK;
 
 	scb->ata_task.proto_conn_rate = (1 << 5); /* STP */
 	if (dev->port->oob_mode == SAS_OOB_MODE)
@@ -387,7 +387,7 @@ static int asd_build_ata_ascb(struct asd_ascb *ascb, struct sas_task *task,
 	if (likely(!task->ata_task.device_control_reg_update))
 		scb->ata_task.fis.flags |= 0x80; /* C=1: update ATA cmd reg */
 	scb->ata_task.fis.flags &= 0xF0; /* PM_PORT field shall be 0 */
-	if (dev->sata_dev.command_set == ATAPI_COMMAND_SET)
+	if (dev->sata_dev.class == ATA_DEV_ATAPI)
 		memcpy(scb->ata_task.atapi_packet, task->ata_task.atapi_packet,
 		       16);
 	scb->ata_task.sister_scb = cpu_to_le16(0xFFFF);
@@ -399,7 +399,7 @@ static int asd_build_ata_ascb(struct asd_ascb *ascb, struct sas_task *task,
 		if (task->ata_task.dma_xfer)
 			flags |= DATA_XFER_MODE_DMA;
 		if (task->ata_task.use_ncq &&
-		    dev->sata_dev.command_set != ATAPI_COMMAND_SET)
+		    dev->sata_dev.class != ATA_DEV_ATAPI)
 			flags |= ATA_Q_TYPE_NCQ;
 		flags |= data_dir_flags[task->data_dir];
 		scb->ata_task.ata_flags = flags;
drivers/scsi/isci/request.c +2 -2
index 56e3809..cfd0084 100644
@@ -694,7 +694,7 @@ sci_io_request_construct_sata(struct isci_request *ireq,
 	}
 
 	/* ATAPI */
-	if (dev->sata_dev.command_set == ATAPI_COMMAND_SET &&
+	if (dev->sata_dev.class == ATA_DEV_ATAPI &&
 	    task->ata_task.fis.command == ATA_CMD_PACKET) {
 		sci_atapi_construct(ireq);
 		return SCI_SUCCESS;
@@ -2980,7 +2980,7 @@ static void sci_request_started_state_enter(struct sci_base_state_machine *sm)
 		state = SCI_REQ_SMP_WAIT_RESP;
 	} else if (task && sas_protocol_ata(task->task_proto) &&
 		   !task->ata_task.use_ncq) {
-		if (dev->sata_dev.command_set == ATAPI_COMMAND_SET &&
+		if (dev->sata_dev.class == ATA_DEV_ATAPI &&
 			task->ata_task.fis.command == ATA_CMD_PACKET) {
 			state = SCI_REQ_ATAPI_WAIT_H2D;
 		} else if (task->data_dir == DMA_NONE) {
drivers/scsi/libsas/sas_ata.c +8 -55

105 lines not on this page · raw message

drivers/scsi/mvsas/mv_sas.c +2 -2
index 6c1f223..44625b8 100644
@@ -479,7 +479,7 @@ static int mvs_task_prep_ata(struct mvs_info *mvi,
 
 	if (task->ata_task.use_ncq)
 		flags |= MCH_FPDMA;
-	if (dev->sata_dev.command_set == ATAPI_COMMAND_SET) {
+	if (dev->sata_dev.class == ATA_DEV_ATAPI) {
 		if (task->ata_task.fis.command != ATA_CMD_ID_ATAPI)
 			flags |= MCH_ATAPI;
 	}
@@ -546,7 +546,7 @@ static int mvs_task_prep_ata(struct mvs_info *mvi,
 		task->ata_task.fis.flags |= 0x80; /* C=1: update ATA cmd reg */
 	/* fill in command FIS and ATAPI CDB */
 	memcpy(buf_cmd, &task->ata_task.fis, sizeof(struct host_to_dev_fis));
-	if (dev->sata_dev.command_set == ATAPI_COMMAND_SET)
+	if (dev->sata_dev.class == ATA_DEV_ATAPI)
 		memcpy(buf_cmd + STP_ATAPI_CMD,
 			task->ata_task.atapi_packet, 16);
 
drivers/scsi/pm8001/pm8001_hwi.c +1 -1
index a97be01..70f9b45 100644
@@ -4356,7 +4356,7 @@ static int pm8001_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
 			PM8001_IO_DBG(pm8001_ha, pm8001_printk("PIO\n"));
 		}
 		if (task->ata_task.use_ncq &&
-			dev->sata_dev.command_set != ATAPI_COMMAND_SET) {
+			dev->sata_dev.class != ATA_DEV_ATAPI) {
 			ATAP = 0x07; /* FPDMA */
 			PM8001_IO_DBG(pm8001_ha, pm8001_printk("FPDMA\n"));
 		}
drivers/scsi/pm8001/pm80xx_hwi.c +1 -1
index d70587f..b1f47f7 100644
@@ -4059,7 +4059,7 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
 			PM8001_IO_DBG(pm8001_ha, pm8001_printk("PIO\n"));
 		}
 		if (task->ata_task.use_ncq &&
-			dev->sata_dev.command_set != ATAPI_COMMAND_SET) {
+		    dev->sata_dev.class != ATA_DEV_ATAPI) {
 			ATAP = 0x07; /* FPDMA */
 			PM8001_IO_DBG(pm8001_ha, pm8001_printk("FPDMA\n"));
 		}
include/linux/libata.h +1 -1
index 5ab4e3a..3412aee 100644
@@ -1172,7 +1172,7 @@ extern int ata_std_qc_defer(struct ata_queued_cmd *qc);
 extern void ata_noop_qc_prep(struct ata_queued_cmd *qc);
 extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
 		 unsigned int n_elem);
-extern unsigned int ata_dev_classify(const struct ata_taskfile *tf);
+extern unsigned int ata_dev_classify(u8 lbah, u8 lbam, u8 lbal);
 extern void ata_dev_disable(struct ata_device *adev);
 extern void ata_id_string(const u16 *id, unsigned char *s,
 			  unsigned int ofs, unsigned int len);
include/scsi/libsas.h +1 -1
index ef7872c..32f88a4 100644
@@ -169,7 +169,7 @@ enum ata_command_set {
 #define ATA_RESP_FIS_SIZE 24
 
 struct sata_device {
-        enum   ata_command_set command_set;
+	unsigned int class;
         struct smp_resp        rps_resp; /* report_phy_sata_resp */
         u8     port_no;        /* port number, if this is a PM (Port) */
 
Signature · 1 line
1.7.12.4
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] libata: consolidate ata_dev_classify()

Quoted 3 lines · Hannes Reinecke

ata_dev_classify() just uses the 'lbah' and 'lbam' fields from the taskfile, so we can as well use those as arguments and rip out the custom code from sas_ata.

There is no reason why SAS couldn't set up a taskfile structure either, but this looks cleaner to me anyway, so:

But you really need to run libata changes past the linux-ide list and not just the scsi list.

#3 lore raw

PATCH 2/3 libata: Implement ATA_DEV_ZAC

In reply to Hannes Reinecke

Add new ATA device type for ZAC devices.

---
 drivers/ata/libata-core.c      | 20 ++++++++++++++------
 drivers/ata/libata-eh.c        |  7 +++++--
 drivers/ata/libata-scsi.c      |  5 +++--
 drivers/ata/libata-transport.c |  1 +
 include/linux/libata.h         |  6 ++++--
 5 files changed, 27 insertions(+), 12 deletions(-)
drivers/ata/libata-core.c +14 -6
index 40ea074..9270de1 100644
@@ -1044,8 +1044,8 @@ const char *sata_spd_string(unsigned int spd)
  *	None.
  *
  *	RETURNS:
- *	Device type, %ATA_DEV_ATA, %ATA_DEV_ATAPI, %ATA_DEV_PMP or
- *	%ATA_DEV_UNKNOWN the event of failure.
+ *	Device type, %ATA_DEV_ATA, %ATA_DEV_ATAPI, %ATA_DEV_PMP,
+ *	%ATA_DEV_ZAC, or %ATA_DEV_UNKNOWN the event of failure.
  */
 unsigned int ata_dev_classify(u8 lbah, u8 lbam, u8 lbal)
 {
@@ -1090,6 +1090,11 @@ unsigned int ata_dev_classify(u8 lbah, u8 lbam, u8 lbal)
 		return ATA_DEV_SEMB;
 	}
 
+	if ((lbam == 0xcd) && (lbah == 0xab)) {
+		DPRINTK("found ZAC device by sig\n");
+		return ATA_DEV_ZAC;
+	}
+
 	DPRINTK("unknown device\n");
 	return ATA_DEV_UNKNOWN;
 }
@@ -1330,7 +1335,7 @@ static int ata_hpa_resize(struct ata_device *dev)
 	int rc;
 
 	/* do we need to do it? */
-	if (dev->class != ATA_DEV_ATA ||
+	if ((dev->class != ATA_DEV_ATA && dev->class != ATA_DEV_ZAC) ||
 	    !ata_id_has_lba(dev->id) || !ata_id_hpa_enabled(dev->id) ||
 	    (dev->horkage & ATA_HORKAGE_BROKEN_HPA))
 		return 0;
@@ -1890,6 +1895,7 @@ retry:
 	case ATA_DEV_SEMB:
 		class = ATA_DEV_ATA;	/* some hard drives report SEMB sig */
 	case ATA_DEV_ATA:
+	case ATA_DEV_ZAC:
 		tf.command = ATA_CMD_ID_ATA;
 		break;
 	case ATA_DEV_ATAPI:
@@ -1981,7 +1987,7 @@ retry:
 	rc = -EINVAL;
 	reason = "device reports invalid type";
 
-	if (class == ATA_DEV_ATA) {
+	if (class == ATA_DEV_ATA || class == ATA_DEV_ZAC) {
 		if (!ata_id_is_ata(id) && !ata_id_is_cfa(id))
 			goto err_out;
 		if (ap->host->flags & ATA_HOST_IGNORE_ATA &&
@@ -2016,7 +2022,8 @@ retry:
 			goto retry;
 	}
 
-	if ((flags & ATA_READID_POSTRESET) && class == ATA_DEV_ATA) {
+	if ((flags & ATA_READID_POSTRESET) &&
+	    (class == ATA_DEV_ATA || class == ATA_DEV_ZAC)) {
 		/*
 		 * The exact sequence expected by certain pre-ATA4 drives is:
 		 * SRST RESET
@@ -2281,7 +2288,7 @@ int ata_dev_configure(struct ata_device *dev)
 			sizeof(modelbuf));
 
 	/* ATA-specific feature tests */
-	if (dev->class == ATA_DEV_ATA) {
+	if (dev->class == ATA_DEV_ATA || dev->class == ATA_DEV_ZAC) {
 		if (ata_id_is_cfa(id)) {
 			/* CPRM may make this media unusable */
 			if (id[ATA_ID_CFA_KEY_MGMT] & 1)
@@ -4034,6 +4041,7 @@ int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,
 	if (ata_class_enabled(new_class) &&
 	    new_class != ATA_DEV_ATA &&
 	    new_class != ATA_DEV_ATAPI &&
+	    new_class != ATA_DEV_ZAC &&
 	    new_class != ATA_DEV_SEMB) {
 		ata_dev_info(dev, "class mismatch %u != %u\n",
 			     dev->class, new_class);
drivers/ata/libata-eh.c +5 -2
index 6760fc4..f620c4a 100644
@@ -1809,6 +1809,7 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc,
 
 	switch (qc->dev->class) {
 	case ATA_DEV_ATA:
+	case ATA_DEV_ZAC:
 		if (err & ATA_ICRC)
 			qc->err_mask |= AC_ERR_ATA_BUS;
 		if (err & ATA_UNC)
@@ -3791,7 +3792,8 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
 				struct ata_eh_context *ehc = &link->eh_context;
 				unsigned long tmp;
 
-				if (dev->class != ATA_DEV_ATA)
+				if (dev->class != ATA_DEV_ATA &&
+				    dev->class != ATA_DEV_ZAC)
 					continue;
 				if (!(ehc->i.dev_action[dev->devno] &
 				      ATA_EH_PARK))
@@ -3872,7 +3874,8 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
 
 		/* retry flush if necessary */
 		ata_for_each_dev(dev, link, ALL) {
-			if (dev->class != ATA_DEV_ATA)
+			if (dev->class != ATA_DEV_ATA &&
+			    dev->class != ATA_DEV_ZAC)
 				continue;
 			rc = ata_eh_maybe_retry_flush(dev);
 			if (rc)
drivers/ata/libata-scsi.c +3 -2
index ef8567d..24be16d 100644
@@ -235,7 +235,8 @@ static ssize_t ata_scsi_park_store(struct device *device,
 		rc = -ENODEV;
 		goto unlock;
 	}
-	if (dev->class != ATA_DEV_ATA) {
+	if (dev->class != ATA_DEV_ATA &&
+	    dev->class != ATA_DEV_ZAC) {
 		rc = -EOPNOTSUPP;
 		goto unlock;
 	}
@@ -3408,7 +3409,7 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd,
 	ata_xlat_func_t xlat_func;
 	int rc = 0;
 
-	if (dev->class == ATA_DEV_ATA) {
+	if (dev->class == ATA_DEV_ATA || dev->class == ATA_DEV_ZAC) {
 		if (unlikely(!scmd->cmd_len || scmd->cmd_len > dev->cdb_len))
 			goto bad_cdb_len;
 
drivers/ata/libata-transport.c +1 -0
index e37413228..3227b7c 100644
@@ -143,6 +143,7 @@ static struct {
 	{ ATA_DEV_PMP_UNSUP,		"pmp" },
 	{ ATA_DEV_SEMB,			"semb" },
 	{ ATA_DEV_SEMB_UNSUP,		"semb" },
+	{ ATA_DEV_ZAC,			"zac" },
 	{ ATA_DEV_NONE,			"none" }
 };
 ata_bitfield_name_search(class, ata_class_names)
include/linux/libata.h +4 -2
index 3412aee..37f482b 100644
@@ -191,7 +191,8 @@ enum {
 	ATA_DEV_PMP_UNSUP	= 6,	/* SATA port multiplier (unsupported) */
 	ATA_DEV_SEMB		= 7,	/* SEMB */
 	ATA_DEV_SEMB_UNSUP	= 8,	/* SEMB (unsupported) */
-	ATA_DEV_NONE		= 9,	/* no device */
+	ATA_DEV_ZAC		= 9,	/* ZAC device */
+	ATA_DEV_NONE		= 10,	/* no device */
 
 	/* struct ata_link flags */
 	ATA_LFLAG_NO_HRST	= (1 << 1), /* avoid hardreset */
@@ -1490,7 +1491,8 @@ static inline unsigned int ata_tag_internal(unsigned int tag)
 static inline unsigned int ata_class_enabled(unsigned int class)
 {
 	return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI ||
-		class == ATA_DEV_PMP || class == ATA_DEV_SEMB;
+		class == ATA_DEV_PMP || class == ATA_DEV_SEMB ||
+		class == ATA_DEV_ZAC;
 }
 
 static inline unsigned int ata_class_disabled(unsigned int class)
Signature · 1 line
1.7.12.4
#4 lore raw

Re: [PATCH 2/3] libata: Implement ATA_DEV_ZAC

This also need to be run past the libata maintainers and the linux-ide list..

drivers/ata/libata-core.c unsigned int ata_dev_classify(u8 lbah, u8 lbam, u8 lbal) · line 1093

Quoted 1 line
drivers/ata/libata-core.c +1 -0
+	if ((lbam == 0xcd) && (lbah == 0xab)) {

The inner braces here aren't needed.

#5 lore raw

Re: [PATCH 2/3] libata: Implement ATA_DEV_ZAC

Quoted 7 lines · Christoph Hellwig

This also need to be run past the libata maintainers and the linux-ide list..

drivers/ata/libata-core.c unsigned int ata_dev_classify(u8 lbah, u8 lbam, u8 lbal) · line 1093

Quoted 1 line
drivers/ata/libata-core.c +1 -0
+	if ((lbam == 0xcd) && (lbah == 0xab)) {

The inner braces here aren't needed.

True, but that's the coding style within that function.
There are several conditions with every of them following the same style.

Cheers,

Hannes

Signature · 8 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#6 lore raw

PATCH 3/3 scsi: Implement 'ZBC' device type

In reply to Hannes Reinecke

ZBC (zoned block command aka 'SMR drives') devices will have a new device type 0x14 assigned by T10. So add the necessary mappings to sd.c and make it an alias for ATA ZAC devices.

---
 drivers/ata/libata-scsi.c |  8 +++++++-
 drivers/scsi/scsi.c       |  2 ++
 drivers/scsi/scsi_scan.c  |  1 +
 drivers/scsi/sd.c         | 16 ++++++++++------
 include/scsi/scsi.h       |  1 +
 5 files changed, 21 insertions(+), 7 deletions(-)
drivers/ata/libata-scsi.c +7 -1
index 24be16d..49b0844 100644
@@ -1991,6 +1991,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);
@@ -2198,7 +2203,8 @@ 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)
+		rbuf[8] |= 0x10;
 	return 0;
 }
 
drivers/scsi/scsi.c +2 -0
index 88d46fe..d47db90 100644
@@ -124,6 +124,8 @@ static const char *const scsi_device_types[] = {
 	"Bridge controller",
 	"Object storage   ",
 	"Automation/Drive ",
+	"Security Manager ",
+	"Direct-Access-ZBC",
 };
 
 /**
drivers/scsi/scsi_scan.c +1 -0
index e02b3aa..0788213 100644
@@ -819,6 +819,7 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
 	case TYPE_COMM:
 	case TYPE_RAID:
 	case TYPE_OSD:
+	case TYPE_ZBC:
 		sdev->writeable = 1;
 		break;
 	case TYPE_ROM:
drivers/scsi/sd.c +10 -6
index 321faf6..e147a78 100644
@@ -91,6 +91,7 @@ MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK15_MAJOR);
 MODULE_ALIAS_SCSI_DEVICE(TYPE_DISK);
 MODULE_ALIAS_SCSI_DEVICE(TYPE_MOD);
 MODULE_ALIAS_SCSI_DEVICE(TYPE_RBC);
+MODULE_ALIAS_SCSI_DEVICE(TYPE_ZBC);
 
 #if !defined(CONFIG_DEBUG_BLOCK_EXT_DEVT)
 #define SD_MINORS	16
@@ -148,7 +149,7 @@ cache_type_store(struct device *dev, struct device_attribute *attr,
 	static const char temp[] = "temporary ";
 	int len;
 
-	if (sdp->type != TYPE_DISK)
+	if (sdp->type != TYPE_DISK && sdp->type != TYPE_ZBC)
 		/* no cache control on RBC devices; theoretically they
 		 * can do it, but there's probably so many exceptions
 		 * it's not worth the risk */
@@ -245,7 +246,7 @@ allow_restart_store(struct device *dev, struct device_attribute *attr,
 	if (!capable(CAP_SYS_ADMIN))
 		return -EACCES;
 
-	if (sdp->type != TYPE_DISK)
+	if (sdp->type != TYPE_DISK && sdp->type != TYPE_ZBC)
 		return -EINVAL;
 
 	sdp->allow_restart = simple_strtoul(buf, NULL, 10);
@@ -375,7 +376,7 @@ provisioning_mode_store(struct device *dev, struct device_attribute *attr,
 	if (!capable(CAP_SYS_ADMIN))
 		return -EACCES;
 
-	if (sdp->type != TYPE_DISK)
+	if (sdp->type != TYPE_DISK && sdp->type != TYPE_ZBC)
 		return -EINVAL;
 
 	if (!strncmp(buf, lbp_mode[SD_LBP_UNMAP], 20))
@@ -442,7 +443,7 @@ max_write_same_blocks_store(struct device *dev, struct device_attribute *attr,
 	if (!capable(CAP_SYS_ADMIN))
 		return -EACCES;
 
-	if (sdp->type != TYPE_DISK)
+	if (sdp->type != TYPE_DISK && sdp->type != TYPE_ZBC)
 		return -EINVAL;
 
 	err = kstrtoul(buf, 10, &max);
@@ -2497,7 +2498,7 @@ static void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer)
 	struct scsi_mode_data data;
 	struct scsi_sense_hdr sshdr;
 
-	if (sdp->type != TYPE_DISK)
+	if (sdp->type != TYPE_DISK && sdp->type != TYPE_ZBC)
 		return;
 
 	if (sdkp->protection_type == 0)
@@ -2914,7 +2915,10 @@ static int sd_probe(struct device *dev)
 	int error;
 
 	error = -ENODEV;
-	if (sdp->type != TYPE_DISK && sdp->type != TYPE_MOD && sdp->type != TYPE_RBC)
+	if (sdp->type != TYPE_DISK &&
+	    sdp->type != TYPE_MOD &&
+	    sdp->type != TYPE_RBC &&
+	    sdp->type != TYPE_ZBC)
 		goto out;
 
 	SCSI_LOG_HLQUEUE(3, sdev_printk(KERN_INFO, sdp,
include/scsi/scsi.h +1 -0
index 0a4edfe..e668eed 100644
@@ -332,6 +332,7 @@ static inline int scsi_status_is_good(int status)
 #define TYPE_ENCLOSURE      0x0d    /* Enclosure Services Device */
 #define TYPE_RBC	    0x0e
 #define TYPE_OSD            0x11
+#define TYPE_ZBC            0x14    /* Zoned block device */
 #define TYPE_NO_LUN         0x7f
 
 /* SCSI protocols; these are taken from SPC-3 section 7.5 */
Signature · 1 line
1.7.12.4
#7 lore raw

Re: [PATCH 3/3] scsi: Implement 'ZBC' device type

Quoted 3 lines · Hannes Reinecke

ZBC (zoned block command aka 'SMR drives') devices will have a new device type 0x14 assigned by T10. So add the necessary mappings to sd.c and make it an alias for ATA ZAC devices.

The libata changes should defintively be a separate one, the sd changes probably as well.

But I'm uneasy with adding anything like this for now, for one the specs aren't even anywhere close to done, and second attaching ZBC devices in general doesn't sound like a very smart idea, we really need a strategy for the sequential required zones first.

#8 lore raw

Re: [PATCH 3/3] scsi: Implement 'ZBC' device type

Quoted 5 lines · Christoph Hellwig
Quoted 3 lines · Hannes Reinecke

ZBC (zoned block command aka 'SMR drives') devices will have a new device type 0x14 assigned by T10. So add the necessary mappings to sd.c and make it an alias for ATA ZAC devices.

Quoted 8 lines

The libata changes should defintively be a separate one, the sd changes probably as well.

But I'm uneasy with adding anything like this for now, for one the specs aren't even anywhere close to done, and second attaching ZBC devices in general doesn't sound like a very smart idea, we really need a strategy for the sequential required zones first.

In theory, yes.

In practice, however, ZAC drives will show up a normal ATA devices without that patch. Which is leading to even more trouble. So with this patch we're at least signalling to the user that something odd might happen.

Cheers,

Hannes

Signature · 8 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#9 lore raw

Re: [PATCH 3/3] scsi: Implement 'ZBC' device type

Quoted 11 lines · Hannes Reinecke
Quoted 5 lines

But I'm uneasy with adding anything like this for now, for one the specs aren't even anywhere close to done, and second attaching ZBC devices in general doesn't sound like a very smart idea, we really need a strategy for the sequential required zones first.

In theory, yes.

In practice, however, ZAC drives will show up a normal ATA devices without that patch. Which is leading to even more trouble. So with this patch we're at least signalling to the user that something odd might happen.

So how about we drop the sd.c changes so that no ULD gets attached, and keep the rest with the review comments addressed? That way we don't accidentally attach a ZBC/ZAC disk, but do get proper diagnostics and can even use SG_IO with the experimental ZBC or ZAC commands.

#10 lore raw

Re: [PATCH 3/3] scsi: Implement 'ZBC' device type

In reply to Hannes Reinecke

drivers/scsi/scsi_scan.c static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, · line 825

Quoted 12 lines
drivers/scsi/scsi_scan.c +1 -0
index e02b3aa..0788213 100644
@@ -819,6 +819,7 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
 	case TYPE_COMM:
 	case TYPE_RAID:
 	case TYPE_OSD:
+	case TYPE_ZBC:
 		sdev->writeable = 1;
 		break;
 	case TYPE_ROM:

sdev->writeable is only used in the sd and sr drivers, so we should just remove it from the scsi_device structure and track it internally to get rid of this layering violation.