All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 00/14] ZAC support
@ 2016-04-12  6:47 Hannes Reinecke
  2016-04-12  6:47 ` [PATCHv2 01/14] libata: do not attempt to retrieve sense code twice Hannes Reinecke
                   ` (13 more replies)
  0 siblings, 14 replies; 35+ messages in thread
From: Hannes Reinecke @ 2016-04-12  6:47 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke

Hi all,

here's a patchset implementing ZAC support for libata.

This is the second part of a larger patchset for ZAC/ZBC support;
it requires the scsi trace fixes queued for in mkp/4.7/scsi-queue and
the patchset 'libata: SATL update' I've posted earlier.
The full patchset can be found at:

git.kernel.org/hare/scsi-devel/h/zbc.v5

As usual, comments and reviews are welcome.

Changes to v1:
- Include reviews from upstream
- Add NCQ encapsulation for ZAC MANAGEMENT commands
- Update libata-trace to decode ZAC MANAGEMENT commands
- Minor fixes accumulated during testing

Hannes Reinecke (14):
  libata: do not attempt to retrieve sense code twice
  libsas: enable FPDMA SEND/RECEIVE
  libsas: Define ATA_CMD_NCQ_NON_DATA
  libata: Separate out ata_dev_config_ncq_send_recv()
  libata: NCQ Encapsulation for READ LOG DMA EXT
  libata: Check log page directory before accessing pages
  libata-trace: decode subcommands
  libata-scsi: Generate sense code for disabled devices
  libata: fixup ZAC device disabling
  libata: implement ZBC IN translation
  libata: Implement ZBC OUT translation
  libata: NCQ encapsulation for ZAC MANAGEMENT OUT
  libata: support device-managed ZAC devices
  libata: support host-aware and host-managed ZAC devices

 drivers/ata/libata-core.c              | 172 ++++++++++++++++---
 drivers/ata/libata-eh.c                |  36 +++-
 drivers/ata/libata-scsi.c              | 295 +++++++++++++++++++++++++++++++--
 drivers/ata/libata-trace.c             |  72 ++++++++
 drivers/ata/libata.h                   |   5 +-
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c |   3 +
 drivers/scsi/isci/request.c            |   5 +-
 drivers/scsi/libsas/sas_ata.c          |   7 +-
 drivers/scsi/mvsas/mv_sas.c            |   5 +-
 drivers/scsi/pm8001/pm8001_sas.c       |   5 +-
 include/linux/ata.h                    |  49 ++++++
 include/linux/libata.h                 |  27 ++-
 include/trace/events/libata.h          |  11 +-
 13 files changed, 642 insertions(+), 50 deletions(-)

-- 
1.8.5.6


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCHv2 01/14] libata: do not attempt to retrieve sense code twice
  2016-04-12  6:47 [PATCHv2 00/14] ZAC support Hannes Reinecke
@ 2016-04-12  6:47 ` Hannes Reinecke
  2016-04-12  6:47 ` [PATCHv2 02/14] libsas: enable FPDMA SEND/RECEIVE Hannes Reinecke
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 35+ messages in thread
From: Hannes Reinecke @ 2016-04-12  6:47 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke, Hannes Reinecke

Do not call ata_request_sense() if the sense code is already
present.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/ata/libata-eh.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 5b340ce..e816619 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -1660,7 +1660,7 @@ static void ata_eh_request_sense(struct ata_queued_cmd *qc,
 		return;
 	}
 
-	if (!cmd)
+	if (!cmd || qc->flags & ATA_QCFLAG_SENSE_VALID)
 		return;
 
 	if (!ata_id_sense_reporting_enabled(dev->id)) {
@@ -1849,7 +1849,7 @@ void ata_eh_analyze_ncq_error(struct ata_link *link)
 	memcpy(&qc->result_tf, &tf, sizeof(tf));
 	qc->result_tf.flags = ATA_TFLAG_ISADDR | ATA_TFLAG_LBA | ATA_TFLAG_LBA48;
 	qc->err_mask |= AC_ERR_DEV | AC_ERR_NCQ;
-	if (qc->result_tf.auxiliary) {
+	if ((qc->result_tf.command & ATA_SENSE) || qc->result_tf.auxiliary) {
 		char sense_key, asc, ascq;
 
 		sense_key = (qc->result_tf.auxiliary >> 16) & 0xff;
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCHv2 02/14] libsas: enable FPDMA SEND/RECEIVE
  2016-04-12  6:47 [PATCHv2 00/14] ZAC support Hannes Reinecke
  2016-04-12  6:47 ` [PATCHv2 01/14] libata: do not attempt to retrieve sense code twice Hannes Reinecke
@ 2016-04-12  6:47 ` Hannes Reinecke
  2016-04-12  7:10   ` kbuild test robot
                     ` (2 more replies)
  2016-04-12  6:47 ` [PATCHv2 03/14] libsas: Define ATA_CMD_NCQ_NON_DATA Hannes Reinecke
                   ` (11 subsequent siblings)
  13 siblings, 3 replies; 35+ messages in thread
From: Hannes Reinecke @ 2016-04-12  6:47 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke, Hannes Reinecke

Update libsas and dependent drivers to handle FPDMA
SEND/RECEIVE correctly.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 2 ++
 drivers/scsi/isci/request.c            | 4 +++-
 drivers/scsi/libsas/sas_ata.c          | 6 ++++--
 drivers/scsi/mvsas/mv_sas.c            | 4 +++-
 drivers/scsi/pm8001/pm8001_sas.c       | 4 +++-
 5 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index b733747..fc2e767 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -1573,6 +1573,8 @@ static u8 get_ata_protocol(u8 cmd, int direction)
 	switch (cmd) {
 	case ATA_CMD_FPDMA_WRITE:
 	case ATA_CMD_FPDMA_READ:
+	case ATA_CMD_FPMDA_RECV:
+	case ATA_CMD_FPDMA_SEND:
 	return SATA_PROTOCOL_FPDMA;
 
 	case ATA_CMD_ID_ATA:
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index cfd0084..29456e0 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -3169,7 +3169,9 @@ static enum sci_status isci_request_stp_request_construct(struct isci_request *i
 	status = sci_io_request_construct_basic_sata(ireq);
 
 	if (qc && (qc->tf.command == ATA_CMD_FPDMA_WRITE ||
-		   qc->tf.command == ATA_CMD_FPDMA_READ)) {
+		   qc->tf.command == ATA_CMD_FPDMA_READ ||
+		   qc->tf.command == ATA_CMD_FPDMA_RECV ||
+		   qc->tf.command == ATA_CMD_FPDMA_SEND)) {
 		fis->sector_count = qc->tag << 3;
 		ireq->tc->type.stp.ncq_tag = qc->tag;
 	}
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index 9c706d8..fe1cd26 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -205,7 +205,9 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc)
 	task->task_done = sas_ata_task_done;
 
 	if (qc->tf.command == ATA_CMD_FPDMA_WRITE ||
-	    qc->tf.command == ATA_CMD_FPDMA_READ) {
+	    qc->tf.command == ATA_CMD_FPDMA_READ ||
+	    qc->tf.command == ATA_CMD_FPDMA_RECV ||
+	    qc->tf.command == ATA_CMD_FPDMA_SEND) {
 		/* Need to zero out the tag libata assigned us */
 		qc->tf.nsect = 0;
 	}
@@ -548,7 +550,7 @@ static struct ata_port_operations sas_sata_ops = {
 
 static struct ata_port_info sata_port_info = {
 	.flags = ATA_FLAG_SATA | ATA_FLAG_PIO_DMA | ATA_FLAG_NCQ |
-		 ATA_FLAG_SAS_HOST,
+		 ATA_FLAG_SAS_HOST | ATA_FLAG_FPDMA_AUX,
 	.pio_mask = ATA_PIO4,
 	.mwdma_mask = ATA_MWDMA2,
 	.udma_mask = ATA_UDMA6,
diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c
index 83cd3ea..db37149 100644
--- a/drivers/scsi/mvsas/mv_sas.c
+++ b/drivers/scsi/mvsas/mv_sas.c
@@ -429,7 +429,9 @@ static u32 mvs_get_ncq_tag(struct sas_task *task, u32 *tag)
 
 	if (qc) {
 		if (qc->tf.command == ATA_CMD_FPDMA_WRITE ||
-			qc->tf.command == ATA_CMD_FPDMA_READ) {
+		    qc->tf.command == ATA_CMD_FPDMA_READ ||
+		    qc->tf.command == ATA_CMD_FPDMA_RECV ||
+		    qc->tf.command == ATA_CMD_FPDMA_SEND) {
 			*tag = qc->tag;
 			return 1;
 		}
diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
index 949198c..62abd98 100644
--- a/drivers/scsi/pm8001/pm8001_sas.c
+++ b/drivers/scsi/pm8001/pm8001_sas.c
@@ -280,7 +280,9 @@ u32 pm8001_get_ncq_tag(struct sas_task *task, u32 *tag)
 	struct ata_queued_cmd *qc = task->uldd_task;
 	if (qc) {
 		if (qc->tf.command == ATA_CMD_FPDMA_WRITE ||
-			qc->tf.command == ATA_CMD_FPDMA_READ) {
+		    qc->tf.command == ATA_CMD_FPDMA_READ ||
+		    qc->tf.command == ATA_CMD_FPDMA_RECV ||
+		    qc->tf.command == ATA_CMD_FPDMA_SEND) {
 			*tag = qc->tag;
 			return 1;
 		}
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCHv2 03/14] libsas: Define ATA_CMD_NCQ_NON_DATA
  2016-04-12  6:47 [PATCHv2 00/14] ZAC support Hannes Reinecke
  2016-04-12  6:47 ` [PATCHv2 01/14] libata: do not attempt to retrieve sense code twice Hannes Reinecke
  2016-04-12  6:47 ` [PATCHv2 02/14] libsas: enable FPDMA SEND/RECEIVE Hannes Reinecke
@ 2016-04-12  6:47 ` Hannes Reinecke
  2016-04-12 10:03   ` John Garry
  2016-04-12  6:47 ` [PATCHv2 04/14] libata: Separate out ata_dev_config_ncq_send_recv() Hannes Reinecke
                   ` (10 subsequent siblings)
  13 siblings, 1 reply; 35+ messages in thread
From: Hannes Reinecke @ 2016-04-12  6:47 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke, Hannes Reinecke

Define the NCQ NON DATA command and update libsas to handle it
correctly.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 1 +
 drivers/scsi/isci/request.c            | 3 ++-
 drivers/scsi/libsas/sas_ata.c          | 3 ++-
 drivers/scsi/mvsas/mv_sas.c            | 3 ++-
 drivers/scsi/pm8001/pm8001_sas.c       | 3 ++-
 include/linux/ata.h                    | 1 +
 include/trace/events/libata.h          | 1 +
 7 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index fc2e767..ebaf5ab 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -1575,6 +1575,7 @@ static u8 get_ata_protocol(u8 cmd, int direction)
 	case ATA_CMD_FPDMA_READ:
 	case ATA_CMD_FPMDA_RECV:
 	case ATA_CMD_FPDMA_SEND:
+	case ATA_CMD_NCQ_NON_DATA:
 	return SATA_PROTOCOL_FPDMA;
 
 	case ATA_CMD_ID_ATA:
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index 29456e0..b709d2b 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -3171,7 +3171,8 @@ static enum sci_status isci_request_stp_request_construct(struct isci_request *i
 	if (qc && (qc->tf.command == ATA_CMD_FPDMA_WRITE ||
 		   qc->tf.command == ATA_CMD_FPDMA_READ ||
 		   qc->tf.command == ATA_CMD_FPDMA_RECV ||
-		   qc->tf.command == ATA_CMD_FPDMA_SEND)) {
+		   qc->tf.command == ATA_CMD_FPDMA_SEND ||
+		   qc->tf.command == ATA_CMD_NCQ_NON_DATA)) {
 		fis->sector_count = qc->tag << 3;
 		ireq->tc->type.stp.ncq_tag = qc->tag;
 	}
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index fe1cd26..935c430 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -207,7 +207,8 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc)
 	if (qc->tf.command == ATA_CMD_FPDMA_WRITE ||
 	    qc->tf.command == ATA_CMD_FPDMA_READ ||
 	    qc->tf.command == ATA_CMD_FPDMA_RECV ||
-	    qc->tf.command == ATA_CMD_FPDMA_SEND) {
+	    qc->tf.command == ATA_CMD_FPDMA_SEND ||
+	    qc->tf.command == ATA_CMD_NCQ_NON_DATA) {
 		/* Need to zero out the tag libata assigned us */
 		qc->tf.nsect = 0;
 	}
diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c
index db37149..5b9fcff 100644
--- a/drivers/scsi/mvsas/mv_sas.c
+++ b/drivers/scsi/mvsas/mv_sas.c
@@ -431,7 +431,8 @@ static u32 mvs_get_ncq_tag(struct sas_task *task, u32 *tag)
 		if (qc->tf.command == ATA_CMD_FPDMA_WRITE ||
 		    qc->tf.command == ATA_CMD_FPDMA_READ ||
 		    qc->tf.command == ATA_CMD_FPDMA_RECV ||
-		    qc->tf.command == ATA_CMD_FPDMA_SEND) {
+		    qc->tf.command == ATA_CMD_FPDMA_SEND ||
+		    qc->tf.command == ATA_CMD_NCQ_NON_DATA) {
 			*tag = qc->tag;
 			return 1;
 		}
diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
index 62abd98..dc33dfa 100644
--- a/drivers/scsi/pm8001/pm8001_sas.c
+++ b/drivers/scsi/pm8001/pm8001_sas.c
@@ -282,7 +282,8 @@ u32 pm8001_get_ncq_tag(struct sas_task *task, u32 *tag)
 		if (qc->tf.command == ATA_CMD_FPDMA_WRITE ||
 		    qc->tf.command == ATA_CMD_FPDMA_READ ||
 		    qc->tf.command == ATA_CMD_FPDMA_RECV ||
-		    qc->tf.command == ATA_CMD_FPDMA_SEND) {
+		    qc->tf.command == ATA_CMD_FPDMA_SEND ||
+		    qc->tf.command == ATA_CMD_NCQ_NON_DATA) {
 			*tag = qc->tag;
 			return 1;
 		}
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 00aebc4..b84210a 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -243,6 +243,7 @@ enum {
 	ATA_CMD_WRITE_QUEUED_FUA_EXT = 0x3E,
 	ATA_CMD_FPDMA_READ	= 0x60,
 	ATA_CMD_FPDMA_WRITE	= 0x61,
+	ATA_CMD_NCQ_NON_DATA	= 0x63,
 	ATA_CMD_FPDMA_SEND	= 0x64,
 	ATA_CMD_FPDMA_RECV	= 0x65,
 	ATA_CMD_PIO_READ	= 0x20,
diff --git a/include/trace/events/libata.h b/include/trace/events/libata.h
index 8b0fbd9..0168603 100644
--- a/include/trace/events/libata.h
+++ b/include/trace/events/libata.h
@@ -39,6 +39,7 @@
 		 ata_opcode_name(ATA_CMD_WRITE_QUEUED_FUA_EXT), \
 		 ata_opcode_name(ATA_CMD_FPDMA_READ),		\
 		 ata_opcode_name(ATA_CMD_FPDMA_WRITE),		\
+		 ata_opcode_name(ATA_CMD_NCQ_NON_DATA),		\
 		 ata_opcode_name(ATA_CMD_FPDMA_SEND),		\
 		 ata_opcode_name(ATA_CMD_FPDMA_RECV),		\
 		 ata_opcode_name(ATA_CMD_PIO_READ),		\
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCHv2 04/14] libata: Separate out ata_dev_config_ncq_send_recv()
  2016-04-12  6:47 [PATCHv2 00/14] ZAC support Hannes Reinecke
                   ` (2 preceding siblings ...)
  2016-04-12  6:47 ` [PATCHv2 03/14] libsas: Define ATA_CMD_NCQ_NON_DATA Hannes Reinecke
@ 2016-04-12  6:47 ` Hannes Reinecke
  2016-04-12  6:47 ` [PATCHv2 05/14] libata: NCQ Encapsulation for READ LOG DMA EXT Hannes Reinecke
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 35+ messages in thread
From: Hannes Reinecke @ 2016-04-12  6:47 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke, Hannes Reinecke

Move NCQ SEND/RECEIVE checks into a separate function.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/ata/libata-core.c | 47 +++++++++++++++++++++++++++--------------------
 1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 7bdb2c4..fa74b57 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2079,6 +2079,31 @@ static inline u8 ata_dev_knobble(struct ata_device *dev)
 	return ((ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(dev->id)));
 }
 
+static void ata_dev_config_ncq_send_recv(struct ata_device *dev)
+{
+	struct ata_port *ap = dev->link->ap;
+	unsigned int err_mask;
+
+	err_mask = ata_read_log_page(dev, ATA_LOG_NCQ_SEND_RECV,
+				     0, ap->sector_buf, 1);
+	if (err_mask) {
+		ata_dev_dbg(dev,
+			    "failed to get NCQ Send/Recv Log Emask 0x%x\n",
+			    err_mask);
+	} else {
+		u8 *cmds = dev->ncq_send_recv_cmds;
+
+		dev->flags |= ATA_DFLAG_NCQ_SEND_RECV;
+		memcpy(cmds, ap->sector_buf, ATA_LOG_NCQ_SEND_RECV_SIZE);
+
+		if (dev->horkage & ATA_HORKAGE_NO_NCQ_TRIM) {
+			ata_dev_dbg(dev, "disabling queued TRIM support\n");
+			cmds[ATA_LOG_NCQ_SEND_RECV_DSM_OFFSET] &=
+				~ATA_LOG_NCQ_SEND_RECV_DSM_TRIM;
+		}
+	}
+}
+
 static int ata_dev_config_ncq(struct ata_device *dev,
 			       char *desc, size_t desc_sz)
 {
@@ -2124,26 +2149,8 @@ static int ata_dev_config_ncq(struct ata_device *dev,
 			ddepth, aa_desc);
 
 	if ((ap->flags & ATA_FLAG_FPDMA_AUX) &&
-	    ata_id_has_ncq_send_and_recv(dev->id)) {
-		err_mask = ata_read_log_page(dev, ATA_LOG_NCQ_SEND_RECV,
-					     0, ap->sector_buf, 1);
-		if (err_mask) {
-			ata_dev_dbg(dev,
-				    "failed to get NCQ Send/Recv Log Emask 0x%x\n",
-				    err_mask);
-		} else {
-			u8 *cmds = dev->ncq_send_recv_cmds;
-
-			dev->flags |= ATA_DFLAG_NCQ_SEND_RECV;
-			memcpy(cmds, ap->sector_buf, ATA_LOG_NCQ_SEND_RECV_SIZE);
-
-			if (dev->horkage & ATA_HORKAGE_NO_NCQ_TRIM) {
-				ata_dev_dbg(dev, "disabling queued TRIM support\n");
-				cmds[ATA_LOG_NCQ_SEND_RECV_DSM_OFFSET] &=
-					~ATA_LOG_NCQ_SEND_RECV_DSM_TRIM;
-			}
-		}
-	}
+	    ata_id_has_ncq_send_and_recv(dev->id))
+		ata_dev_config_ncq_send_recv(dev);
 
 	return 0;
 }
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCHv2 05/14] libata: NCQ Encapsulation for READ LOG DMA EXT
  2016-04-12  6:47 [PATCHv2 00/14] ZAC support Hannes Reinecke
                   ` (3 preceding siblings ...)
  2016-04-12  6:47 ` [PATCHv2 04/14] libata: Separate out ata_dev_config_ncq_send_recv() Hannes Reinecke
@ 2016-04-12  6:47 ` Hannes Reinecke
  2016-04-13 18:07   ` Tejun Heo
  2016-04-12  6:47 ` [PATCHv2 06/14] libata: Check log page directory before accessing pages Hannes Reinecke
                   ` (8 subsequent siblings)
  13 siblings, 1 reply; 35+ messages in thread
From: Hannes Reinecke @ 2016-04-12  6:47 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke, Hannes Reinecke

Recent devices can use NCQ encapsulation for READ LOG DMA EXT,
so we should be using it if available.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/ata/libata-core.c |  5 ++---
 drivers/ata/libata-eh.c   | 30 +++++++++++++++++++++++++-----
 drivers/ata/libata.h      |  5 +++--
 include/linux/ata.h       |  5 +++++
 include/linux/libata.h    |  7 +++++++
 5 files changed, 42 insertions(+), 10 deletions(-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index fa74b57..f48f152 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2085,7 +2085,7 @@ static void ata_dev_config_ncq_send_recv(struct ata_device *dev)
 	unsigned int err_mask;
 
 	err_mask = ata_read_log_page(dev, ATA_LOG_NCQ_SEND_RECV,
-				     0, ap->sector_buf, 1);
+				     0, ap->sector_buf, 1, true);
 	if (err_mask) {
 		ata_dev_dbg(dev,
 			    "failed to get NCQ Send/Recv Log Emask 0x%x\n",
@@ -2383,8 +2383,7 @@ int ata_dev_configure(struct ata_device *dev)
 			err_mask = ata_read_log_page(dev,
 						     ATA_LOG_SATA_ID_DEV_DATA,
 						     ATA_LOG_SATA_SETTINGS,
-						     sata_setting,
-						     1);
+						     sata_setting, 1, true);
 			if (err_mask)
 				ata_dev_dbg(dev,
 					    "failed to get Identify Device Data, Emask 0x%x\n",
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index e816619..dfe8fdc 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -1493,6 +1493,7 @@ static const char *ata_err_string(unsigned int err_mask)
  *	@page: page to read
  *	@buf: buffer to store read page
  *	@sectors: number of sectors to read
+ *	@fpdma: flag if fpdma should be used
  *
  *	Read log page using READ_LOG_EXT command.
  *
@@ -1503,7 +1504,8 @@ static const char *ata_err_string(unsigned int err_mask)
  *	0 on success, AC_ERR_* mask otherwise.
  */
 unsigned int ata_read_log_page(struct ata_device *dev, u8 log,
-			       u8 page, void *buf, unsigned int sectors)
+			       u8 page, void *buf, unsigned int sectors,
+			       bool fpdma)
 {
 	unsigned long ap_flags = dev->link->ap->flags;
 	struct ata_taskfile tf;
@@ -1521,25 +1523,43 @@ unsigned int ata_read_log_page(struct ata_device *dev, u8 log,
 
 retry:
 	ata_tf_init(dev, &tf);
-	if (dev->dma_mode && ata_id_has_read_log_dma_ext(dev->id) &&
+	if (fpdma && ata_ncq_enabled(dev) &&
+	    ata_fpdma_read_log_supported(dev)) {
+		tf.command = ATA_CMD_FPDMA_RECV;
+		tf.protocol = ATA_PROT_NCQ;
+		tf.hob_nsect = ATA_SUBCMD_FPDMA_RECV_RD_LOG_DMA_EXT & 0x1f;
+		tf.nsect = ATA_TAG_INTERNAL << 3;
+		tf.feature = sectors;
+		tf.hob_feature = sectors >> 8;
+		dma = true;
+	} else if (dev->dma_mode && ata_id_has_read_log_dma_ext(dev->id) &&
 	    !(dev->horkage & ATA_HORKAGE_NO_NCQ_LOG)) {
 		tf.command = ATA_CMD_READ_LOG_DMA_EXT;
 		tf.protocol = ATA_PROT_DMA;
+		tf.nsect = sectors;
+		tf.hob_nsect = sectors >> 8;
 		dma = true;
 	} else {
 		tf.command = ATA_CMD_READ_LOG_EXT;
 		tf.protocol = ATA_PROT_PIO;
+		tf.nsect = sectors;
+		tf.hob_nsect = sectors >> 8;
 		dma = false;
 	}
 	tf.lbal = log;
 	tf.lbam = page;
-	tf.nsect = sectors;
-	tf.hob_nsect = sectors >> 8;
 	tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_LBA48 | ATA_TFLAG_DEVICE;
 
 	err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE,
 				     buf, sectors * ATA_SECT_SIZE, 0);
 
+	if (err_mask && fpdma) {
+		ata_dev_warn(dev,
+			     "RECEIVE FPDMA failed, trying READ LOG_DMA EXT\n");
+		dev->ncq_send_recv_cmds[ATA_LOG_NCQ_SEND_RECV_RD_LOG_OFFSET] &=
+		    ~ATA_LOG_NCQ_SEND_RECV_RD_LOG_SUPPORTED;
+		goto retry;
+	}
 	if (err_mask && dma) {
 		dev->horkage |= ATA_HORKAGE_NO_NCQ_LOG;
 		ata_dev_warn(dev, "READ LOG DMA EXT failed, trying unqueued\n");
@@ -1573,7 +1593,7 @@ static int ata_eh_read_log_10h(struct ata_device *dev,
 	u8 csum;
 	int i;
 
-	err_mask = ata_read_log_page(dev, ATA_LOG_SATA_NCQ, 0, buf, 1);
+	err_mask = ata_read_log_page(dev, ATA_LOG_SATA_NCQ, 0, buf, 1, false);
 	if (err_mask)
 		return -EIO;
 
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 3b301a4..5732f98 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -169,8 +169,9 @@ extern void ata_eh_about_to_do(struct ata_link *link, struct ata_device *dev,
 			       unsigned int action);
 extern void ata_eh_done(struct ata_link *link, struct ata_device *dev,
 			unsigned int action);
-extern unsigned int ata_read_log_page(struct ata_device *dev, u8 log,
-				      u8 page, void *buf, unsigned int sectors);
+extern unsigned int ata_read_log_page(struct ata_device *dev, u8 log, u8 page,
+				      void *buf, unsigned int sectors,
+				      bool fpdma);
 extern void ata_eh_autopsy(struct ata_port *ap);
 const char *ata_get_cmd_descript(u8 command);
 extern void ata_eh_report(struct ata_port *ap);
diff --git a/include/linux/ata.h b/include/linux/ata.h
index b84210a..94ccde5 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -306,6 +306,9 @@ enum {
 	/* marked obsolete in the ATA/ATAPI-7 spec */
 	ATA_CMD_RESTORE		= 0x10,
 
+	/* Subcmds for ATA_CMD_FPDMA_RECV */
+	ATA_SUBCMD_FPDMA_RECV_RD_LOG_DMA_EXT = 0x01,
+
 	/* Subcmds for ATA_CMD_FPDMA_SEND */
 	ATA_SUBCMD_FPDMA_SEND_DSM            = 0x00,
 	ATA_SUBCMD_FPDMA_SEND_WR_LOG_DMA_EXT = 0x02,
@@ -329,7 +332,9 @@ enum {
 	ATA_LOG_NCQ_SEND_RECV_DSM_OFFSET	= 0x04,
 	ATA_LOG_NCQ_SEND_RECV_DSM_TRIM		= (1 << 0),
 	ATA_LOG_NCQ_SEND_RECV_RD_LOG_OFFSET	= 0x08,
+	ATA_LOG_NCQ_SEND_RECV_RD_LOG_SUPPORTED  = (1 << 0),
 	ATA_LOG_NCQ_SEND_RECV_WR_LOG_OFFSET	= 0x0C,
+	ATA_LOG_NCQ_SEND_RECV_WR_LOG_SUPPORTED  = (1 << 0),
 	ATA_LOG_NCQ_SEND_RECV_SIZE		= 0x10,
 
 	/* READ/WRITE LONG (obsolete) */
diff --git a/include/linux/libata.h b/include/linux/libata.h
index a418bca..09ddb5a 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -1642,6 +1642,13 @@ static inline bool ata_fpdma_dsm_supported(struct ata_device *dev)
 		 ATA_LOG_NCQ_SEND_RECV_DSM_TRIM);
 }
 
+static inline bool ata_fpdma_read_log_supported(struct ata_device *dev)
+{
+	return (dev->flags & ATA_DFLAG_NCQ_SEND_RECV) &&
+		(dev->ncq_send_recv_cmds[ATA_LOG_NCQ_SEND_RECV_RD_LOG_OFFSET] &
+		 ATA_LOG_NCQ_SEND_RECV_RD_LOG_SUPPORTED);
+}
+
 static inline void ata_qc_set_polling(struct ata_queued_cmd *qc)
 {
 	qc->tf.ctl |= ATA_NIEN;
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCHv2 06/14] libata: Check log page directory before accessing pages
  2016-04-12  6:47 [PATCHv2 00/14] ZAC support Hannes Reinecke
                   ` (4 preceding siblings ...)
  2016-04-12  6:47 ` [PATCHv2 05/14] libata: NCQ Encapsulation for READ LOG DMA EXT Hannes Reinecke
@ 2016-04-12  6:47 ` Hannes Reinecke
  2016-04-13 18:08   ` Tejun Heo
  2016-04-12  6:47 ` [PATCHv2 07/14] libata-trace: decode subcommands Hannes Reinecke
                   ` (7 subsequent siblings)
  13 siblings, 1 reply; 35+ messages in thread
From: Hannes Reinecke @ 2016-04-12  6:47 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke, Hannes Reinecke

When reading the NCQ Send/Recv log it might actually not
supported, thereby causing irritating messages
'READ LOG DMA EXT failed'.
Instead we should be reading the log directory first to
figure out if the log is actually supported before trying
to access it.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/ata/libata-core.c | 17 +++++++++++++++++
 include/linux/ata.h       |  1 +
 2 files changed, 18 insertions(+)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index f48f152..cfde6bc 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -66,6 +66,7 @@
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
 #include <asm/byteorder.h>
+#include <asm/unaligned.h>
 #include <linux/cdrom.h>
 #include <linux/ratelimit.h>
 #include <linux/pm_runtime.h>
@@ -2083,7 +2084,23 @@ static void ata_dev_config_ncq_send_recv(struct ata_device *dev)
 {
 	struct ata_port *ap = dev->link->ap;
 	unsigned int err_mask;
+	int log_index = ATA_LOG_NCQ_SEND_RECV * 2;
+	u16 log_pages;
 
+	err_mask = ata_read_log_page(dev, ATA_LOG_DIRECTORY,
+				     0, ap->sector_buf, 1, true);
+	if (err_mask) {
+		ata_dev_dbg(dev,
+			    "failed to get Log Directory Emask 0x%x\n",
+			    err_mask);
+		return;
+	}
+	log_pages = get_unaligned_le16(&ap->sector_buf[log_index]);
+	if (!log_pages) {
+		ata_dev_warn(dev,
+			     "NCQ Send/Recv Log not supported\n");
+		return;
+	}
 	err_mask = ata_read_log_page(dev, ATA_LOG_NCQ_SEND_RECV,
 				     0, ap->sector_buf, 1, true);
 	if (err_mask) {
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 94ccde5..b5be5e8 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -314,6 +314,7 @@ enum {
 	ATA_SUBCMD_FPDMA_SEND_WR_LOG_DMA_EXT = 0x02,
 
 	/* READ_LOG_EXT pages */
+	ATA_LOG_DIRECTORY	= 0x0,
 	ATA_LOG_SATA_NCQ	= 0x10,
 	ATA_LOG_NCQ_SEND_RECV	  = 0x13,
 	ATA_LOG_SATA_ID_DEV_DATA  = 0x30,
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCHv2 07/14] libata-trace: decode subcommands
  2016-04-12  6:47 [PATCHv2 00/14] ZAC support Hannes Reinecke
                   ` (5 preceding siblings ...)
  2016-04-12  6:47 ` [PATCHv2 06/14] libata: Check log page directory before accessing pages Hannes Reinecke
@ 2016-04-12  6:47 ` Hannes Reinecke
  2016-04-12  6:47 ` [PATCHv2 08/14] libata-scsi: Generate sense code for disabled devices Hannes Reinecke
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 35+ messages in thread
From: Hannes Reinecke @ 2016-04-12  6:47 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke, Hannes Reinecke

Some commands like FPDMA RECEIVE or NCQ NON DATA can encapsulate
other commands to NCQ transport. So decode the subcmds, too.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/ata/libata-trace.c    | 43 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/ata.h           | 17 +++++++++++++++++
 include/trace/events/libata.h |  8 +++++++-
 3 files changed, 67 insertions(+), 1 deletion(-)

diff --git a/drivers/ata/libata-trace.c b/drivers/ata/libata-trace.c
index fd30b8c..99ec1e8 100644
--- a/drivers/ata/libata-trace.c
+++ b/drivers/ata/libata-trace.c
@@ -149,3 +149,46 @@ libata_trace_parse_qc_flags(struct trace_seq *p, unsigned int qc_flags)
 
 	return ret;
 }
+
+const char *
+libata_trace_parse_subcmd(struct trace_seq *p, unsigned char cmd,
+			  unsigned char feature, unsigned char hob_nsect)
+{
+	const char *ret = trace_seq_buffer_ptr(p);
+
+	switch (cmd) {
+	case ATA_CMD_FPDMA_RECV:
+		switch (hob_nsect & 0x5f) {
+		case ATA_SUBCMD_FPDMA_RECV_RD_LOG_DMA_EXT:
+			trace_seq_printf(p, " READ_LOG_DMA_EXT");
+			break;
+		}
+		break;
+	case ATA_CMD_FPDMA_SEND:
+		switch (hob_nsect & 0x5f) {
+		case ATA_SUBCMD_FPDMA_SEND_WR_LOG_DMA_EXT:
+			trace_seq_printf(p, " WRITE_LOG_DMA_EXT");
+			break;
+		case ATA_SUBCMD_FPDMA_SEND_DSM:
+			trace_seq_printf(p, " DATASET_MANAGEMENT");
+			break;
+		}
+		break;
+	case ATA_CMD_NCQ_NON_DATA:
+		switch (feature) {
+		case ATA_SUBCMD_NCQ_NON_DATA_ABORT_QUEUE:
+			trace_seq_printf(p, " ABORT_QUEUE");
+			break;
+		case ATA_SUBCMD_NCQ_NON_DATA_SET_FEATURES:
+			trace_seq_printf(p, " SET_FEATURES");
+			break;
+		case ATA_SUBCMD_NCQ_NON_DATA_ZERO_EXT:
+			trace_seq_printf(p, " ZERO_EXT");
+			break;
+		}
+		break;
+	}
+	trace_seq_putc(p, 0);
+
+	return ret;
+}
diff --git a/include/linux/ata.h b/include/linux/ata.h
index b5be5e8..032bb22 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -313,6 +313,11 @@ enum {
 	ATA_SUBCMD_FPDMA_SEND_DSM            = 0x00,
 	ATA_SUBCMD_FPDMA_SEND_WR_LOG_DMA_EXT = 0x02,
 
+	/* Subcmds for ATA_CMD_NCQ_NON_DATA */
+	ATA_SUBCMD_NCQ_NON_DATA_ABORT_QUEUE  = 0x00,
+	ATA_SUBCMD_NCQ_NON_DATA_SET_FEATURES = 0x05,
+	ATA_SUBCMD_NCQ_NON_DATA_ZERO_EXT     = 0x06,
+
 	/* READ_LOG_EXT pages */
 	ATA_LOG_DIRECTORY	= 0x0,
 	ATA_LOG_SATA_NCQ	= 0x10,
@@ -338,6 +343,18 @@ enum {
 	ATA_LOG_NCQ_SEND_RECV_WR_LOG_SUPPORTED  = (1 << 0),
 	ATA_LOG_NCQ_SEND_RECV_SIZE		= 0x10,
 
+	/* NCQ Non-Data log */
+	ATA_LOG_NCQ_NON_DATA_SUBCMDS_OFFSET	= 0x00,
+	ATA_LOG_NCQ_NON_DATA_ABORT_OFFSET	= 0x00,
+	ATA_LOG_NCQ_NON_DATA_ABORT_NCQ		= (1 << 0),
+	ATA_LOG_NCQ_NON_DATA_ABORT_ALL		= (1 << 1),
+	ATA_LOG_NCQ_NON_DATA_ABORT_STREAMING	= (1 << 2),
+	ATA_LOG_NCQ_NON_DATA_ABORT_NON_STREAMING = (1 << 3),
+	ATA_LOG_NCQ_NON_DATA_ABORT_SELECTED	= (1 << 4),
+	ATA_LOG_NCQ_NON_DATA_ZAC_MGMT_OFFSET	= 0x1C,
+	ATA_LOG_NCQ_NON_DATA_ZAC_MGMT_OUT	= (1 << 0),
+	ATA_LOG_NCQ_NON_DATA_SIZE		= 0x40,
+
 	/* READ/WRITE LONG (obsolete) */
 	ATA_CMD_READ_LONG	= 0x22,
 	ATA_CMD_READ_LONG_ONCE	= 0x23,
diff --git a/include/trace/events/libata.h b/include/trace/events/libata.h
index 0168603..318c04b 100644
--- a/include/trace/events/libata.h
+++ b/include/trace/events/libata.h
@@ -140,6 +140,10 @@ const char *libata_trace_parse_eh_err_mask(struct trace_seq *, unsigned int);
 const char *libata_trace_parse_qc_flags(struct trace_seq *, unsigned int);
 #define __parse_qc_flags(f) libata_trace_parse_qc_flags(p, f)
 
+const char *libata_trace_parse_subcmd(struct trace_seq *, unsigned char,
+				      unsigned char, unsigned char);
+#define __parse_subcmd(c, f, h) libata_trace_parse_subcmd(p, c, f, h)
+
 TRACE_EVENT(ata_qc_issue,
 
 	TP_PROTO(struct ata_queued_cmd *qc),
@@ -186,11 +190,13 @@ TRACE_EVENT(ata_qc_issue,
 		__entry->hob_nsect	= qc->tf.hob_nsect;
 	),
 
-	TP_printk("ata_port=%u ata_dev=%u tag=%d proto=%s cmd=%s " \
+	TP_printk("ata_port=%u ata_dev=%u tag=%d proto=%s cmd=%s%s " \
 		  " tf=(%02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x)",
 		  __entry->ata_port, __entry->ata_dev, __entry->tag,
 		  show_protocol_name(__entry->proto),
 		  show_opcode_name(__entry->cmd),
+		  __parse_subcmd(__entry->cmd, __entry->feature,
+				 __entry->hob_nsect),
 		  __entry->cmd, __entry->feature, __entry->nsect,
 		  __entry->lbal, __entry->lbam, __entry->lbah,
 		  __entry->hob_feature, __entry->hob_nsect,
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCHv2 08/14] libata-scsi: Generate sense code for disabled devices
  2016-04-12  6:47 [PATCHv2 00/14] ZAC support Hannes Reinecke
                   ` (6 preceding siblings ...)
  2016-04-12  6:47 ` [PATCHv2 07/14] libata-trace: decode subcommands Hannes Reinecke
@ 2016-04-12  6:47 ` Hannes Reinecke
  2016-04-12  6:47 ` [PATCHv2 09/14] libata: fixup ZAC device disabling Hannes Reinecke
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 35+ messages in thread
From: Hannes Reinecke @ 2016-04-12  6:47 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke, Hannes Reinecke

If a device is disabled after error recovery it doesn't make
any sense to generate an ATA sense, but we should rather
return a generic sense code indicating the device is gone.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/ata/libata-scsi.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 8b61d63..6d78b4b 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -1126,6 +1126,12 @@ static void ata_gen_ata_sense(struct ata_queued_cmd *qc)
 
 	cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
 
+	if (ata_dev_disabled(dev)) {
+		/* Device disabled after error recovery */
+		/* LOGICAL UNIT NOT READY, HARD RESET REQUIRED */
+		ata_scsi_set_sense(dev, cmd, NOT_READY, 0x04, 0x21);
+		return;
+	}
 	/* Use ata_to_sense_error() to map status register bits
 	 * onto sense key, asc & ascq.
 	 */
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCHv2 09/14] libata: fixup ZAC device disabling
  2016-04-12  6:47 [PATCHv2 00/14] ZAC support Hannes Reinecke
                   ` (7 preceding siblings ...)
  2016-04-12  6:47 ` [PATCHv2 08/14] libata-scsi: Generate sense code for disabled devices Hannes Reinecke
@ 2016-04-12  6:47 ` Hannes Reinecke
  2016-04-13 18:09   ` Tejun Heo
  2016-04-12  6:47 ` [PATCHv2 10/14] libata: implement ZBC IN translation Hannes Reinecke
                   ` (4 subsequent siblings)
  13 siblings, 1 reply; 35+ messages in thread
From: Hannes Reinecke @ 2016-04-12  6:47 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke, Hannes Reinecke

libata device disabling is ... curious. So add the correct
definitions that we can disable ZAC devices properly.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 include/linux/libata.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/libata.h b/include/linux/libata.h
index 09ddb5a..92297cd 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -192,7 +192,8 @@ enum {
 	ATA_DEV_SEMB		= 7,	/* SEMB */
 	ATA_DEV_SEMB_UNSUP	= 8,	/* SEMB (unsupported) */
 	ATA_DEV_ZAC		= 9,	/* ZAC device */
-	ATA_DEV_NONE		= 10,	/* no device */
+	ATA_DEV_ZAC_UNSUP	= 10,	/* ZAC device (unsupported) */
+	ATA_DEV_NONE		= 11,	/* no device */
 
 	/* struct ata_link flags */
 	ATA_LFLAG_NO_HRST	= (1 << 1), /* avoid hardreset */
@@ -1524,7 +1525,8 @@ static inline unsigned int ata_class_enabled(unsigned int class)
 static inline unsigned int ata_class_disabled(unsigned int class)
 {
 	return class == ATA_DEV_ATA_UNSUP || class == ATA_DEV_ATAPI_UNSUP ||
-		class == ATA_DEV_PMP_UNSUP || class == ATA_DEV_SEMB_UNSUP;
+		class == ATA_DEV_PMP_UNSUP || class == ATA_DEV_SEMB_UNSUP ||
+		class == ATA_DEV_ZAC_UNSUP;
 }
 
 static inline unsigned int ata_class_absent(unsigned int class)
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCHv2 10/14] libata: implement ZBC IN translation
  2016-04-12  6:47 [PATCHv2 00/14] ZAC support Hannes Reinecke
                   ` (8 preceding siblings ...)
  2016-04-12  6:47 ` [PATCHv2 09/14] libata: fixup ZAC device disabling Hannes Reinecke
@ 2016-04-12  6:47 ` Hannes Reinecke
  2016-04-12  6:47 ` [PATCHv2 11/14] libata: Implement ZBC OUT translation Hannes Reinecke
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 35+ messages in thread
From: Hannes Reinecke @ 2016-04-12  6:47 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke

ZAC drives implement a 'ZAC Management In' command template,
which maps onto the ZBC IN command.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/ata/libata-eh.c       |   1 +
 drivers/ata/libata-scsi.c     | 157 ++++++++++++++++++++++++++++++++++++++++++
 drivers/ata/libata-trace.c    |  10 +++
 include/linux/ata.h           |   5 ++
 include/trace/events/libata.h |   1 +
 5 files changed, 174 insertions(+)

diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index dfe8fdc..4932ce5 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -2502,6 +2502,7 @@ const char *ata_get_cmd_descript(u8 command)
 		{ ATA_CMD_CFA_WRITE_MULT_NE,	"CFA WRITE MULTIPLE WITHOUT ERASE" },
 		{ ATA_CMD_REQ_SENSE_DATA,	"REQUEST SENSE DATA EXT" },
 		{ ATA_CMD_SANITIZE_DEVICE,	"SANITIZE DEVICE" },
+		{ ATA_CMD_ZAC_MGMT_IN,		"ZAC MANAGEMENT IN" },
 		{ ATA_CMD_READ_LONG,		"READ LONG (with retries)" },
 		{ ATA_CMD_READ_LONG_ONCE,	"READ LONG (without retries)" },
 		{ ATA_CMD_WRITE_LONG,		"WRITE LONG (with retries)" },
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 6d78b4b..3e402a8 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -3318,6 +3318,160 @@ invalid_opcode:
 }
 
 /**
+ *	ata_scsi_report_zones_complete - convert ATA output
+ *	@qc: command structure returning the data
+ *
+ *	Convert T-13 little-endian field representation into
+ *	T-10 big-endian field representation.
+ *	What a mess.
+ */
+static void ata_scsi_report_zones_complete(struct ata_queued_cmd *qc)
+{
+	struct scsi_cmnd *scmd = qc->scsicmd;
+	struct sg_mapping_iter miter;
+	unsigned long flags;
+	unsigned int bytes = 0;
+
+	sg_miter_start(&miter, scsi_sglist(scmd), scsi_sg_count(scmd),
+		       SG_MITER_TO_SG | SG_MITER_ATOMIC);
+
+	local_irq_save(flags);
+	while (sg_miter_next(&miter)) {
+		unsigned int offset = 0;
+
+		if (bytes == 0) {
+			char *hdr;
+			u32 list_length;
+			u64 max_lba, opt_lba;
+			u16 same;
+
+			/* Swizzle header */
+			hdr = miter.addr;
+			list_length = get_unaligned_le32(&hdr[0]);
+			same = get_unaligned_le16(&hdr[4]);
+			max_lba = get_unaligned_le64(&hdr[8]);
+			opt_lba = get_unaligned_le64(&hdr[16]);
+			put_unaligned_be32(list_length, &hdr[0]);
+			hdr[4] = same & 0xf;
+			put_unaligned_be64(max_lba, &hdr[8]);
+			put_unaligned_be64(opt_lba, &hdr[16]);
+			offset += 64;
+			bytes += 64;
+		}
+		while (offset < miter.length) {
+			char *rec;
+			u8 cond, type, non_seq, reset;
+			u64 size, start, wp;
+
+			/* Swizzle zone descriptor */
+			rec = miter.addr + offset;
+			type = rec[0] & 0xf;
+			cond = (rec[1] >> 4) & 0xf;
+			non_seq = (rec[1] & 2);
+			reset = (rec[1] & 1);
+			size = get_unaligned_le64(&rec[8]);
+			start = get_unaligned_le64(&rec[16]);
+			wp = get_unaligned_le64(&rec[24]);
+			rec[0] = type;
+			rec[1] = (cond << 4) | non_seq | reset;
+			put_unaligned_be64(size, &rec[8]);
+			put_unaligned_be64(start, &rec[16]);
+			put_unaligned_be64(wp, &rec[24]);
+			WARN_ON(offset + 64 > miter.length);
+			offset += 64;
+			bytes += 64;
+		}
+	}
+	sg_miter_stop(&miter);
+	local_irq_restore(flags);
+
+	ata_scsi_qc_complete(qc);
+}
+
+static unsigned int ata_scsi_zbc_in_xlat(struct ata_queued_cmd *qc)
+{
+	struct ata_taskfile *tf = &qc->tf;
+	struct scsi_cmnd *scmd = qc->scsicmd;
+	const u8 *cdb = scmd->cmnd;
+	u16 sect, fp = (u16)-1;
+	u8 sa, options, bp = 0xff;
+	u64 block;
+	u32 n_block;
+
+	if (unlikely(scmd->cmd_len < 16)) {
+		ata_dev_warn(qc->dev, "invalid cdb length %d\n",
+			     scmd->cmd_len);
+		fp = 15;
+		goto invalid_fld;
+	}
+	scsi_16_lba_len(cdb, &block, &n_block);
+	if (n_block != scsi_bufflen(scmd)) {
+		ata_dev_warn(qc->dev, "non-matching transfer count (%d/%d)\n",
+			     n_block, scsi_bufflen(scmd));
+		goto invalid_param_len;
+	}
+	sa = cdb[1] & 0x1f;
+	if (sa != ZI_REPORT_ZONES) {
+		ata_dev_warn(qc->dev, "invalid service action %d\n", sa);
+		fp = 1;
+		goto invalid_fld;
+	}
+	/*
+	 * ZAC allows only for transfers in 512 byte blocks,
+	 * and uses a 16 bit value for the transfer count.
+	 */
+	if ((n_block / 512) > 0xffff || n_block < 512 || (n_block % 512)) {
+		ata_dev_warn(qc->dev, "invalid transfer count %d\n", n_block);
+		goto invalid_param_len;
+	}
+	sect = n_block / 512;
+	options = cdb[14];
+
+	if (ata_ncq_enabled(qc->dev) &&
+	    (qc->dev->flags & ATA_DFLAG_NCQ_SEND_RECV)) {
+		tf->protocol = ATA_PROT_NCQ;
+		tf->command = ATA_CMD_FPDMA_RECV;
+		tf->hob_nsect = ATA_SUBCMD_FPDMA_RECV_ZAC_MGMT_IN & 0x1f;
+		tf->nsect = qc->tag << 3;
+		tf->feature = sect & 0xff;
+		tf->hob_feature = (sect >> 8) & 0xff;
+		tf->auxiliary = ATA_SUBCMD_ZAC_MGMT_IN_REPORT_ZONES;
+	} else {
+		tf->command = ATA_CMD_ZAC_MGMT_IN;
+		tf->feature = ATA_SUBCMD_ZAC_MGMT_IN_REPORT_ZONES;
+		tf->protocol = ATA_PROT_DMA;
+		tf->hob_feature = options;
+		tf->hob_nsect = (sect >> 8) & 0xff;
+		tf->nsect = sect & 0xff;
+	}
+	tf->device = ATA_LBA;
+	tf->lbah = (block >> 16) & 0xff;
+	tf->lbam = (block >> 8) & 0xff;
+	tf->lbal = block & 0xff;
+	tf->hob_lbah = (block >> 40) & 0xff;
+	tf->hob_lbam = (block >> 32) & 0xff;
+	tf->hob_lbal = (block >> 24) & 0xff;
+
+	tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_LBA48;
+	qc->flags |= ATA_QCFLAG_RESULT_TF;
+
+	ata_qc_set_pc_nbytes(qc);
+
+	qc->complete_fn = ata_scsi_report_zones_complete;
+
+	return 0;
+
+invalid_fld:
+	ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp);
+	return 1;
+
+invalid_param_len:
+	/* "Parameter list length error" */
+	ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0);
+	return 1;
+}
+
+/**
  *	ata_mselect_caching - Simulate MODE SELECT for caching info page
  *	@qc: Storage for translated ATA taskfile
  *	@buf: input buffer
@@ -3632,6 +3786,9 @@ static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd)
 		return ata_scsi_mode_select_xlat;
 		break;
 
+	case ZBC_IN:
+		return ata_scsi_zbc_in_xlat;
+
 	case START_STOP:
 		return ata_scsi_start_stop_xlat;
 	}
diff --git a/drivers/ata/libata-trace.c b/drivers/ata/libata-trace.c
index 99ec1e8..9caeabd 100644
--- a/drivers/ata/libata-trace.c
+++ b/drivers/ata/libata-trace.c
@@ -162,6 +162,9 @@ libata_trace_parse_subcmd(struct trace_seq *p, unsigned char cmd,
 		case ATA_SUBCMD_FPDMA_RECV_RD_LOG_DMA_EXT:
 			trace_seq_printf(p, " READ_LOG_DMA_EXT");
 			break;
+		case ATA_SUBCMD_FPDMA_RECV_ZAC_MGMT_IN:
+			trace_seq_printf(p, " ZAC_MGMT_IN");
+			break;
 		}
 		break;
 	case ATA_CMD_FPDMA_SEND:
@@ -187,6 +190,13 @@ libata_trace_parse_subcmd(struct trace_seq *p, unsigned char cmd,
 			break;
 		}
 		break;
+	case ATA_CMD_ZAC_MGMT_IN:
+		switch (feature) {
+		case ATA_SUBCMD_ZAC_MGMT_IN_REPORT_ZONES:
+			trace_seq_printf(p, " REPORT_ZONES");
+			break;
+		}
+		break;
 	}
 	trace_seq_putc(p, 0);
 
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 032bb22..2f01ba9 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -302,12 +302,14 @@ enum {
 	ATA_CMD_CFA_WRITE_MULT_NE = 0xCD,
 	ATA_CMD_REQ_SENSE_DATA  = 0x0B,
 	ATA_CMD_SANITIZE_DEVICE = 0xB4,
+	ATA_CMD_ZAC_MGMT_IN	= 0x4A,
 
 	/* marked obsolete in the ATA/ATAPI-7 spec */
 	ATA_CMD_RESTORE		= 0x10,
 
 	/* Subcmds for ATA_CMD_FPDMA_RECV */
 	ATA_SUBCMD_FPDMA_RECV_RD_LOG_DMA_EXT = 0x01,
+	ATA_SUBCMD_FPDMA_RECV_ZAC_MGMT_IN    = 0x02,
 
 	/* Subcmds for ATA_CMD_FPDMA_SEND */
 	ATA_SUBCMD_FPDMA_SEND_DSM            = 0x00,
@@ -318,6 +320,9 @@ enum {
 	ATA_SUBCMD_NCQ_NON_DATA_SET_FEATURES = 0x05,
 	ATA_SUBCMD_NCQ_NON_DATA_ZERO_EXT     = 0x06,
 
+	/* Subcmds for ATA_CMD_ZAC_MGMT_IN */
+	ATA_SUBCMD_ZAC_MGMT_IN_REPORT_ZONES = 0x00,
+
 	/* READ_LOG_EXT pages */
 	ATA_LOG_DIRECTORY	= 0x0,
 	ATA_LOG_SATA_NCQ	= 0x10,
diff --git a/include/trace/events/libata.h b/include/trace/events/libata.h
index 318c04b..b966417 100644
--- a/include/trace/events/libata.h
+++ b/include/trace/events/libata.h
@@ -98,6 +98,7 @@
 		 ata_opcode_name(ATA_CMD_CFA_WRITE_MULT_NE),	\
 		 ata_opcode_name(ATA_CMD_REQ_SENSE_DATA),	\
 		 ata_opcode_name(ATA_CMD_SANITIZE_DEVICE),	\
+		 ata_opcode_name(ATA_CMD_ZAC_MGMT_IN),		\
 		 ata_opcode_name(ATA_CMD_RESTORE),		\
 		 ata_opcode_name(ATA_CMD_READ_LONG),		\
 		 ata_opcode_name(ATA_CMD_READ_LONG_ONCE),	\
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCHv2 11/14] libata: Implement ZBC OUT translation
  2016-04-12  6:47 [PATCHv2 00/14] ZAC support Hannes Reinecke
                   ` (9 preceding siblings ...)
  2016-04-12  6:47 ` [PATCHv2 10/14] libata: implement ZBC IN translation Hannes Reinecke
@ 2016-04-12  6:47 ` Hannes Reinecke
  2016-04-12 18:54   ` Shaun Tancheff
  2016-04-12  6:47 ` [PATCHv2 12/14] libata: NCQ encapsulation for ZAC MANAGEMENT OUT Hannes Reinecke
                   ` (2 subsequent siblings)
  13 siblings, 1 reply; 35+ messages in thread
From: Hannes Reinecke @ 2016-04-12  6:47 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke

ZAC drives implement a 'ZAC Management Out' command template,
which maps onto the ZBC OUT command.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/ata/libata-eh.c       |  1 +
 drivers/ata/libata-scsi.c     | 67 +++++++++++++++++++++++++++++++++++++++++++
 drivers/ata/libata-trace.c    | 16 +++++++++++
 include/linux/ata.h           |  7 +++++
 include/trace/events/libata.h |  1 +
 5 files changed, 92 insertions(+)

diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 4932ce5..4c2bf7f 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -2503,6 +2503,7 @@ const char *ata_get_cmd_descript(u8 command)
 		{ ATA_CMD_REQ_SENSE_DATA,	"REQUEST SENSE DATA EXT" },
 		{ ATA_CMD_SANITIZE_DEVICE,	"SANITIZE DEVICE" },
 		{ ATA_CMD_ZAC_MGMT_IN,		"ZAC MANAGEMENT IN" },
+		{ ATA_CMD_ZAC_MGMT_OUT,		"ZAC MANAGEMENT OUT" },
 		{ ATA_CMD_READ_LONG,		"READ LONG (with retries)" },
 		{ ATA_CMD_READ_LONG_ONCE,	"READ LONG (without retries)" },
 		{ ATA_CMD_WRITE_LONG,		"WRITE LONG (with retries)" },
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 3e402a8..ef696a3 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -3471,6 +3471,70 @@ invalid_param_len:
 	return 1;
 }
 
+static unsigned int ata_scsi_zbc_out_xlat(struct ata_queued_cmd *qc)
+{
+	struct ata_taskfile *tf = &qc->tf;
+	struct scsi_cmnd *scmd = qc->scsicmd;
+	struct ata_device *dev = qc->dev;
+	const u8 *cdb = scmd->cmnd;
+	u8 reset_all, sa;
+	u64 block;
+	u32 n_block;
+	u16 fp = (u16)-1;
+
+	if (unlikely(scmd->cmd_len < 16)) {
+		fp = 15;
+		goto invalid_fld;
+	}
+
+	sa = cdb[1] & 0x1f;
+	if ((sa != ZO_CLOSE_ZONE) && (sa != ZO_FINISH_ZONE) &&
+	    (sa != ZO_OPEN_ZONE) && (sa != ZO_RESET_WRITE_POINTER)) {
+		fp = 1;
+		goto invalid_fld;
+	}
+
+	scsi_16_lba_len(cdb, &block, &n_block);
+	if (n_block) {
+		/*
+		 * ZAC MANAGEMENT OUT doesn't define any length
+		 */
+		goto invalid_param_len;
+	}
+	if (block > dev->n_sectors)
+		goto out_of_range;
+
+	reset_all = cdb[14] & 0x1;
+
+	tf->protocol = ATA_PROT_NODATA;
+	tf->command = ATA_CMD_ZAC_MGMT_OUT;
+	tf->feature = sa;
+	tf->hob_feature = reset_all & 0x1;
+
+	tf->lbah = (block >> 16) & 0xff;
+	tf->lbam = (block >> 8) & 0xff;
+	tf->lbal = block & 0xff;
+	tf->hob_lbah = (block >> 40) & 0xff;
+	tf->hob_lbam = (block >> 32) & 0xff;
+	tf->hob_lbal = (block >> 24) & 0xff;
+	tf->device = ATA_LBA;
+	tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_LBA48;
+
+	return 0;
+
+ invalid_fld:
+	ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff);
+	return 1;
+ out_of_range:
+	/* "Logical Block Address out of range" */
+	ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x21, 0x00);
+	return 1;
+invalid_param_len:
+	/* "Parameter list length error" */
+	ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0);
+	return 1;
+}
+
 /**
  *	ata_mselect_caching - Simulate MODE SELECT for caching info page
  *	@qc: Storage for translated ATA taskfile
@@ -3789,6 +3853,9 @@ static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd)
 	case ZBC_IN:
 		return ata_scsi_zbc_in_xlat;
 
+	case ZBC_OUT:
+		return ata_scsi_zbc_out_xlat;
+
 	case START_STOP:
 		return ata_scsi_start_stop_xlat;
 	}
diff --git a/drivers/ata/libata-trace.c b/drivers/ata/libata-trace.c
index 9caeabd..1111ba7 100644
--- a/drivers/ata/libata-trace.c
+++ b/drivers/ata/libata-trace.c
@@ -197,6 +197,22 @@ libata_trace_parse_subcmd(struct trace_seq *p, unsigned char cmd,
 			break;
 		}
 		break;
+	case ATA_CMD_ZAC_MGMT_OUT:
+		switch (feature) {
+		case ATA_SUBCMD_ZAC_MGMT_OUT_CLOSE_ZONE:
+			trace_seq_printf(p, " CLOSE_ZONE");
+			break;
+		case ATA_SUBCMD_ZAC_MGMT_OUT_FINISH_ZONE:
+			trace_seq_printf(p, " FINISH_ZONE");
+			break;
+		case ATA_SUBCMD_ZAC_MGMT_OUT_OPEN_ZONE:
+			trace_seq_printf(p, " OPEN_ZONE");
+			break;
+		case ATA_SUBCMD_ZAC_MGMT_OUT_RESET_WRITE_POINTER:
+			trace_seq_printf(p, " RESET_WRITE_POINTER");
+			break;
+		}
+		break;
 	}
 	trace_seq_putc(p, 0);
 
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 2f01ba9..e3bf9a3 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -303,6 +303,7 @@ enum {
 	ATA_CMD_REQ_SENSE_DATA  = 0x0B,
 	ATA_CMD_SANITIZE_DEVICE = 0xB4,
 	ATA_CMD_ZAC_MGMT_IN	= 0x4A,
+	ATA_CMD_ZAC_MGMT_OUT	= 0x9F,
 
 	/* marked obsolete in the ATA/ATAPI-7 spec */
 	ATA_CMD_RESTORE		= 0x10,
@@ -323,6 +324,12 @@ enum {
 	/* Subcmds for ATA_CMD_ZAC_MGMT_IN */
 	ATA_SUBCMD_ZAC_MGMT_IN_REPORT_ZONES = 0x00,
 
+	/* Subcmds for ATA_CMD_ZAC_MGMT_OUT */
+	ATA_SUBCMD_ZAC_MGMT_OUT_CLOSE_ZONE = 0x01,
+	ATA_SUBCMD_ZAC_MGMT_OUT_FINISH_ZONE = 0x02,
+	ATA_SUBCMD_ZAC_MGMT_OUT_OPEN_ZONE = 0x03,
+	ATA_SUBCMD_ZAC_MGMT_OUT_RESET_WRITE_POINTER = 0x04,
+
 	/* READ_LOG_EXT pages */
 	ATA_LOG_DIRECTORY	= 0x0,
 	ATA_LOG_SATA_NCQ	= 0x10,
diff --git a/include/trace/events/libata.h b/include/trace/events/libata.h
index b966417..3032edc 100644
--- a/include/trace/events/libata.h
+++ b/include/trace/events/libata.h
@@ -99,6 +99,7 @@
 		 ata_opcode_name(ATA_CMD_REQ_SENSE_DATA),	\
 		 ata_opcode_name(ATA_CMD_SANITIZE_DEVICE),	\
 		 ata_opcode_name(ATA_CMD_ZAC_MGMT_IN),		\
+		 ata_opcode_name(ATA_CMD_ZAC_MGMT_OUT),		\
 		 ata_opcode_name(ATA_CMD_RESTORE),		\
 		 ata_opcode_name(ATA_CMD_READ_LONG),		\
 		 ata_opcode_name(ATA_CMD_READ_LONG_ONCE),	\
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCHv2 12/14] libata: NCQ encapsulation for ZAC MANAGEMENT OUT
  2016-04-12  6:47 [PATCHv2 00/14] ZAC support Hannes Reinecke
                   ` (10 preceding siblings ...)
  2016-04-12  6:47 ` [PATCHv2 11/14] libata: Implement ZBC OUT translation Hannes Reinecke
@ 2016-04-12  6:47 ` Hannes Reinecke
  2016-04-12  6:47 ` [PATCHv2 13/14] libata: support device-managed ZAC devices Hannes Reinecke
  2016-04-12  6:47 ` [PATCHv2 14/14] libata: support host-aware and host-managed " Hannes Reinecke
  13 siblings, 0 replies; 35+ messages in thread
From: Hannes Reinecke @ 2016-04-12  6:47 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke, Hannes Reinecke

Add NCQ encapsulation for ZAC MANAGEMENT OUT and evaluate
NCQ Non-Data log pages to figure out if NCQ encapsulation
is supported.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/ata/libata-core.c  | 43 ++++++++++++++++++++++++++++++++++++++++---
 drivers/ata/libata-scsi.c  | 18 +++++++++++++-----
 drivers/ata/libata-trace.c |  3 +++
 include/linux/ata.h        |  7 +++++++
 include/linux/libata.h     |  7 +++++++
 5 files changed, 70 insertions(+), 8 deletions(-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index cfde6bc..4d2e965 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2121,6 +2121,40 @@ static void ata_dev_config_ncq_send_recv(struct ata_device *dev)
 	}
 }
 
+static void ata_dev_config_ncq_non_data(struct ata_device *dev)
+{
+	struct ata_port *ap = dev->link->ap;
+	unsigned int err_mask;
+	int log_index = ATA_LOG_NCQ_NON_DATA * 2;
+	u16 log_pages;
+
+	err_mask = ata_read_log_page(dev, ATA_LOG_DIRECTORY,
+				     0, ap->sector_buf, 1, true);
+	if (err_mask) {
+		ata_dev_dbg(dev,
+			    "failed to get Log Directory Emask 0x%x\n",
+			    err_mask);
+		return;
+	}
+	log_pages = get_unaligned_le16(&ap->sector_buf[log_index]);
+	if (!log_pages) {
+		ata_dev_warn(dev,
+			     "NCQ Send/Recv Log not supported\n");
+		return;
+	}
+	err_mask = ata_read_log_page(dev, ATA_LOG_NCQ_NON_DATA,
+				     0, ap->sector_buf, 1, true);
+	if (err_mask) {
+		ata_dev_dbg(dev,
+			    "failed to get NCQ Non-Data Log Emask 0x%x\n",
+			    err_mask);
+	} else {
+		u8 *cmds = dev->ncq_non_data_cmds;
+
+		memcpy(cmds, ap->sector_buf, ATA_LOG_NCQ_NON_DATA_SIZE);
+	}
+}
+
 static int ata_dev_config_ncq(struct ata_device *dev,
 			       char *desc, size_t desc_sz)
 {
@@ -2165,9 +2199,12 @@ static int ata_dev_config_ncq(struct ata_device *dev,
 		snprintf(desc, desc_sz, "NCQ (depth %d/%d)%s", hdepth,
 			ddepth, aa_desc);
 
-	if ((ap->flags & ATA_FLAG_FPDMA_AUX) &&
-	    ata_id_has_ncq_send_and_recv(dev->id))
-		ata_dev_config_ncq_send_recv(dev);
+	if ((ap->flags & ATA_FLAG_FPDMA_AUX)) {
+		if (ata_id_has_ncq_send_and_recv(dev->id))
+			ata_dev_config_ncq_send_recv(dev);
+		if (ata_id_has_ncq_non_data(dev->id))
+			ata_dev_config_ncq_non_data(dev);
+	}
 
 	return 0;
 }
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index ef696a3..5f1fc03 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -3506,11 +3506,19 @@ static unsigned int ata_scsi_zbc_out_xlat(struct ata_queued_cmd *qc)
 
 	reset_all = cdb[14] & 0x1;
 
-	tf->protocol = ATA_PROT_NODATA;
-	tf->command = ATA_CMD_ZAC_MGMT_OUT;
-	tf->feature = sa;
-	tf->hob_feature = reset_all & 0x1;
-
+	if (ata_ncq_enabled(qc->dev) &&
+	    ata_fpdma_zac_mgmt_out_supported(qc->dev)) {
+		tf->protocol = ATA_PROT_NCQ;
+		tf->command = ATA_CMD_NCQ_NON_DATA;
+		tf->hob_nsect = ATA_SUBCMD_NCQ_NON_DATA_ZAC_MGMT_OUT;
+		tf->nsect = qc->tag << 3;
+		tf->auxiliary = sa | (reset_all & 0x1) << 8;
+	} else {
+		tf->protocol = ATA_PROT_NODATA;
+		tf->command = ATA_CMD_ZAC_MGMT_OUT;
+		tf->feature = sa;
+		tf->hob_feature = reset_all & 0x1;
+	}
 	tf->lbah = (block >> 16) & 0xff;
 	tf->lbam = (block >> 8) & 0xff;
 	tf->lbal = block & 0xff;
diff --git a/drivers/ata/libata-trace.c b/drivers/ata/libata-trace.c
index 1111ba7..f8c550d 100644
--- a/drivers/ata/libata-trace.c
+++ b/drivers/ata/libata-trace.c
@@ -188,6 +188,9 @@ libata_trace_parse_subcmd(struct trace_seq *p, unsigned char cmd,
 		case ATA_SUBCMD_NCQ_NON_DATA_ZERO_EXT:
 			trace_seq_printf(p, " ZERO_EXT");
 			break;
+		case ATA_SUBCMD_NCQ_NON_DATA_ZAC_MGMT_OUT:
+			trace_seq_printf(p, " ZAC_MGMT_OUT");
+			break;
 		}
 		break;
 	case ATA_CMD_ZAC_MGMT_IN:
diff --git a/include/linux/ata.h b/include/linux/ata.h
index e3bf9a3..3fb2d7d 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -320,6 +320,7 @@ enum {
 	ATA_SUBCMD_NCQ_NON_DATA_ABORT_QUEUE  = 0x00,
 	ATA_SUBCMD_NCQ_NON_DATA_SET_FEATURES = 0x05,
 	ATA_SUBCMD_NCQ_NON_DATA_ZERO_EXT     = 0x06,
+	ATA_SUBCMD_NCQ_NON_DATA_ZAC_MGMT_OUT = 0x07,
 
 	/* Subcmds for ATA_CMD_ZAC_MGMT_IN */
 	ATA_SUBCMD_ZAC_MGMT_IN_REPORT_ZONES = 0x00,
@@ -333,6 +334,7 @@ enum {
 	/* READ_LOG_EXT pages */
 	ATA_LOG_DIRECTORY	= 0x0,
 	ATA_LOG_SATA_NCQ	= 0x10,
+	ATA_LOG_NCQ_NON_DATA	  = 0x12,
 	ATA_LOG_NCQ_SEND_RECV	  = 0x13,
 	ATA_LOG_SATA_ID_DEV_DATA  = 0x30,
 	ATA_LOG_SATA_SETTINGS	  = 0x08,
@@ -874,6 +876,11 @@ static inline bool ata_id_has_ncq_send_and_recv(const u16 *id)
 	return id[ATA_ID_SATA_CAPABILITY_2] & BIT(6);
 }
 
+static inline bool ata_id_has_ncq_non_data(const u16 *id)
+{
+	return id[ATA_ID_SATA_CAPABILITY_2] & BIT(5);
+}
+
 static inline bool ata_id_has_trim(const u16 *id)
 {
 	if (ata_id_major_version(id) >= 7 &&
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 92297cd..bb48eb7 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -729,6 +729,7 @@ struct ata_device {
 
 	/* NCQ send and receive log subcommand support */
 	u8			ncq_send_recv_cmds[ATA_LOG_NCQ_SEND_RECV_SIZE];
+	u8			ncq_non_data_cmds[ATA_LOG_NCQ_NON_DATA_SIZE];
 
 	/* error history */
 	int			spdn_cnt;
@@ -1651,6 +1652,12 @@ static inline bool ata_fpdma_read_log_supported(struct ata_device *dev)
 		 ATA_LOG_NCQ_SEND_RECV_RD_LOG_SUPPORTED);
 }
 
+static inline bool ata_fpdma_zac_mgmt_out_supported(struct ata_device *dev)
+{
+	return (dev->ncq_non_data_cmds[ATA_LOG_NCQ_NON_DATA_ZAC_MGMT_OFFSET] &
+		ATA_LOG_NCQ_NON_DATA_ZAC_MGMT_OUT);
+}
+
 static inline void ata_qc_set_polling(struct ata_queued_cmd *qc)
 {
 	qc->tf.ctl |= ATA_NIEN;
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCHv2 13/14] libata: support device-managed ZAC devices
  2016-04-12  6:47 [PATCHv2 00/14] ZAC support Hannes Reinecke
                   ` (11 preceding siblings ...)
  2016-04-12  6:47 ` [PATCHv2 12/14] libata: NCQ encapsulation for ZAC MANAGEMENT OUT Hannes Reinecke
@ 2016-04-12  6:47 ` Hannes Reinecke
  2016-04-13 20:50   ` Shaun Tancheff
  2016-04-12  6:47 ` [PATCHv2 14/14] libata: support host-aware and host-managed " Hannes Reinecke
  13 siblings, 1 reply; 35+ messages in thread
From: Hannes Reinecke @ 2016-04-12  6:47 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke

Device-managed ZAC devices just set the zoned capabilities field
in INQUIRY byte 69 (cf ACS-4). This corresponds to the 'zoned'
field in the block device characteristics VPD page.
As this is only defined in SPC-5/SBC-4 we also need to update
the supported SCSI version descriptor.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/ata/libata-scsi.c | 19 ++++++++++---------
 include/linux/ata.h       |  5 +++++
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 5f1fc03..a92fbe9 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2082,14 +2082,14 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)
 		0x00,
 		0xA0,	/* SAM-5 (no version claimed) */
 
-		0x04,
-		0xC0,	/* SBC-3 (no version claimed) */
+		0x06,
+		0x00,	/* SBC-4 (no version claimed) */
 
-		0x04,
-		0x60,	/* SPC-4 (no version claimed) */
+		0x05,
+		0xC0,	/* SPC-5 (no version claimed) */
 
 		0x60,
-		0x20,   /* ZBC (no version claimed) */
+		0x24,   /* ZBC r05 */
 	};
 
 	u8 hdr[] = {
@@ -2109,10 +2109,8 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)
 	    (args->dev->link->ap->pflags & ATA_PFLAG_EXTERNAL))
 		hdr[1] |= (1 << 7);
 
-	if (args->dev->class == ATA_DEV_ZAC) {
+	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);
@@ -2126,7 +2124,7 @@ 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);
 
-	if (args->dev->class == ATA_DEV_ZAC)
+	if (ata_id_zoned_cap(args->id) || args->dev->class == ATA_DEV_ZAC)
 		memcpy(rbuf + 58, versions_zbc, sizeof(versions_zbc));
 	else
 		memcpy(rbuf + 58, versions, sizeof(versions));
@@ -2322,12 +2320,15 @@ static unsigned int ata_scsiop_inq_b1(struct ata_scsi_args *args, u8 *rbuf)
 {
 	int form_factor = ata_id_form_factor(args->id);
 	int media_rotation_rate = ata_id_rotation_rate(args->id);
+	u8 zoned = ata_id_zoned_cap(args->id);
 
 	rbuf[1] = 0xb1;
 	rbuf[3] = 0x3c;
 	rbuf[4] = media_rotation_rate >> 8;
 	rbuf[5] = media_rotation_rate;
 	rbuf[7] = form_factor;
+	if (zoned)
+		rbuf[8] = (zoned << 4);
 
 	return 0;
 }
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 3fb2d7d..439be2a 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -932,6 +932,11 @@ static inline bool ata_id_is_ssd(const u16 *id)
 	return id[ATA_ID_ROT_SPEED] == 0x01;
 }
 
+static inline u8 ata_id_zoned_cap(const u16 *id)
+{
+	return (id[ATA_ID_ADDITIONAL_SUPP] & 0x3);
+}
+
 static inline bool ata_id_pio_need_iordy(const u16 *id, const u8 pio)
 {
 	/* CF spec. r4.1 Table 22 says no IORDY on PIO5 and PIO6. */
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCHv2 14/14] libata: support host-aware and host-managed ZAC devices
  2016-04-12  6:47 [PATCHv2 00/14] ZAC support Hannes Reinecke
                   ` (12 preceding siblings ...)
  2016-04-12  6:47 ` [PATCHv2 13/14] libata: support device-managed ZAC devices Hannes Reinecke
@ 2016-04-12  6:47 ` Hannes Reinecke
  13 siblings, 0 replies; 35+ messages in thread
From: Hannes Reinecke @ 2016-04-12  6:47 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke

Byte 69 bits 0:1 in the IDENTIFY DEVICE data indicate a
host-aware ZAC device.
Host-managed ZAC devices have their own individual signature,
and to not set the bits in the IDENTIFY DEVICE data.
And whenever we detect a ZAC-compatible device we should
be displaying the zoned block characteristics VPD page.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/ata/libata-core.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/ata/libata-scsi.c | 38 ++++++++++++++++++++++++--
 include/linux/ata.h       |  1 +
 include/linux/libata.h    |  7 +++++
 4 files changed, 112 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 4d2e965..e35c52a 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2227,6 +2227,73 @@ static void ata_dev_config_sense_reporting(struct ata_device *dev)
 	}
 }
 
+static void ata_dev_config_zac(struct ata_device *dev)
+{
+	struct ata_port *ap = dev->link->ap;
+	unsigned int err_mask;
+	u8 *identify_buf = ap->sector_buf;
+	int log_index = ATA_LOG_SATA_ID_DEV_DATA * 2;
+	u16 log_pages;
+
+	dev->zac_zones_optimal_open = (u32)-1;
+	dev->zac_zones_optimal_nonseq = (u32)-1;
+	dev->zac_zones_max_open = (u32)-1;
+
+	/*
+	 * Always set the 'ZAC' flag for Host-managed devices.
+	 */
+	if (dev->class == ATA_DEV_ZAC)
+		dev->flags |= ATA_DFLAG_ZAC;
+	else if (ata_id_zoned_cap(dev->id) == 0x01)
+		/*
+		 * Check for host-aware devices.
+		 */
+		dev->flags |= ATA_DFLAG_ZAC;
+
+	if (!(dev->flags & ATA_DFLAG_ZAC))
+		return;
+
+	/*
+	 * Read IDENTIFY DEVICE data log, page 9 (Zoned-device information)
+	 */
+	err_mask = ata_read_log_page(dev, ATA_LOG_DIRECTORY,
+				     0, ap->sector_buf, 1, true);
+	if (err_mask) {
+		ata_dev_info(dev,
+			     "failed to get Log Directory Emask 0x%x\n",
+			     err_mask);
+		return;
+	}
+	log_pages = get_unaligned_le16(&ap->sector_buf[log_index]);
+	if (log_pages <= ATA_LOG_ZONED_INFORMATION) {
+		ata_dev_warn(dev,
+			     "ATA Zoned Information Log not supported\n");
+		dev->zac_zones_optimal_open = U32_MAX;
+		dev->zac_zones_optimal_nonseq = U32_MAX;
+		dev->zac_zones_max_open = U32_MAX;
+		return;
+	}
+	err_mask = ata_read_log_page(dev, ATA_LOG_SATA_ID_DEV_DATA,
+				     ATA_LOG_ZONED_INFORMATION,
+				     identify_buf, 1, true);
+	if (!err_mask) {
+		u64 zoned_cap, opt_open, opt_nonseq, max_open;
+
+		zoned_cap = get_unaligned_le64(&identify_buf[8]);
+		if ((zoned_cap >> 63))
+			dev->zac_zoned_cap = (zoned_cap & 1);
+		opt_open = get_unaligned_le64(&identify_buf[24]);
+		if ((opt_open >> 63))
+			dev->zac_zones_optimal_open = (u32)opt_open;
+		opt_nonseq = get_unaligned_le64(&identify_buf[32]);
+		if ((opt_nonseq >> 63))
+			dev->zac_zones_optimal_nonseq = (u32)opt_nonseq;
+		max_open = get_unaligned_le64(&identify_buf[40]);
+		if ((max_open >> 63))
+			dev->zac_zones_max_open = (u32)max_open;
+	}
+}
+
 /**
  *	ata_dev_configure - Configure the specified ATA/ATAPI device
  *	@dev: Target device to configure
@@ -2449,6 +2516,7 @@ int ata_dev_configure(struct ata_device *dev)
 				}
 		}
 		ata_dev_config_sense_reporting(dev);
+		ata_dev_config_zac(dev);
 		dev->cdb_len = 16;
 	}
 
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index a92fbe9..432d064 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2144,6 +2144,7 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)
  */
 static unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf)
 {
+	int num_pages;
 	const u8 pages[] = {
 		0x00,	/* page 0x00, this page */
 		0x80,	/* page 0x80, unit serial no page */
@@ -2152,10 +2153,14 @@ static unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf)
 		0xb0,	/* page 0xb0, block limits page */
 		0xb1,	/* page 0xb1, block device characteristics page */
 		0xb2,	/* page 0xb2, thin provisioning page */
+		0xb6,	/* page 0xb6, zoned block device characteristics */
 	};
 
-	rbuf[3] = sizeof(pages);	/* number of supported VPD pages */
-	memcpy(rbuf + 4, pages, sizeof(pages));
+	num_pages = sizeof(pages);
+	if (!(args->dev->flags & ATA_DFLAG_ZAC))
+		num_pages--;
+	rbuf[3] = num_pages;	/* number of supported VPD pages */
+	memcpy(rbuf + 4, pages, num_pages);
 	return 0;
 }
 
@@ -2343,6 +2348,26 @@ static unsigned int ata_scsiop_inq_b2(struct ata_scsi_args *args, u8 *rbuf)
 	return 0;
 }
 
+static unsigned int ata_scsiop_inq_b6(struct ata_scsi_args *args, u8 *rbuf)
+{
+	/*
+	 * zbc-r05 SCSI Zoned Block device characteristics VPD page
+	 */
+	rbuf[1] = 0xb6;
+	rbuf[3] = 0x3C;
+
+	/*
+	 * URSWRZ bit is only meaningful for host-managed ZAC drives
+	 */
+	if (args->dev->zac_zoned_cap & 1)
+		rbuf[4] |= 1;
+	put_unaligned_be32(args->dev->zac_zones_optimal_open, &rbuf[8]);
+	put_unaligned_be32(args->dev->zac_zones_optimal_nonseq, &rbuf[12]);
+	put_unaligned_be32(args->dev->zac_zones_max_open, &rbuf[16]);
+
+	return 0;
+}
+
 /**
  *	ata_scsiop_noop - Command handler that simply returns success.
  *	@args: device IDENTIFY data / SCSI command of interest.
@@ -2661,6 +2686,9 @@ static unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf)
 				rbuf[14] |= 0x40; /* LBPRZ */
 			}
 		}
+		if (ata_id_zoned_cap(args->id) ||
+		    args->dev->class == ATA_DEV_ZAC)
+			rbuf[12] = (1 << 4); /* RC_BASIS */
 	}
 	return 0;
 }
@@ -4046,6 +4074,12 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)
 		case 0xb2:
 			ata_scsi_rbuf_fill(&args, ata_scsiop_inq_b2);
 			break;
+		case 0xb6:
+			if (dev->flags & ATA_DFLAG_ZAC) {
+				ata_scsi_rbuf_fill(&args, ata_scsiop_inq_b6);
+				break;
+			}
+			/* Fallthrough */
 		default:
 			ata_scsi_invalid_field(dev, cmd, 2);
 			break;
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 439be2a..d413443 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -338,6 +338,7 @@ enum {
 	ATA_LOG_NCQ_SEND_RECV	  = 0x13,
 	ATA_LOG_SATA_ID_DEV_DATA  = 0x30,
 	ATA_LOG_SATA_SETTINGS	  = 0x08,
+	ATA_LOG_ZONED_INFORMATION = 0x09,
 	ATA_LOG_DEVSLP_OFFSET	  = 0x30,
 	ATA_LOG_DEVSLP_SIZE	  = 0x08,
 	ATA_LOG_DEVSLP_MDAT	  = 0x00,
diff --git a/include/linux/libata.h b/include/linux/libata.h
index bb48eb7..1a23c6e 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -181,6 +181,7 @@ enum {
 	ATA_DFLAG_DEVSLP	= (1 << 27), /* device supports Device Sleep */
 	ATA_DFLAG_ACPI_DISABLED = (1 << 28), /* ACPI for the device is disabled */
 	ATA_DFLAG_D_SENSE	= (1 << 29), /* Descriptor sense requested */
+	ATA_DFLAG_ZAC		= (1 << 30), /* ZAC device */
 
 	ATA_DEV_UNKNOWN		= 0,	/* unknown device */
 	ATA_DEV_ATA		= 1,	/* ATA device */
@@ -731,6 +732,12 @@ struct ata_device {
 	u8			ncq_send_recv_cmds[ATA_LOG_NCQ_SEND_RECV_SIZE];
 	u8			ncq_non_data_cmds[ATA_LOG_NCQ_NON_DATA_SIZE];
 
+	/* ZAC zone configuration */
+	u32			zac_zoned_cap;
+	u32			zac_zones_optimal_open;
+	u32			zac_zones_optimal_nonseq;
+	u32			zac_zones_max_open;
+
 	/* error history */
 	int			spdn_cnt;
 	/* ering is CLEAR_END, read comment above CLEAR_END */
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* Re: [PATCHv2 02/14] libsas: enable FPDMA SEND/RECEIVE
  2016-04-12  6:47 ` [PATCHv2 02/14] libsas: enable FPDMA SEND/RECEIVE Hannes Reinecke
@ 2016-04-12  7:10   ` kbuild test robot
  2016-04-12  7:19   ` kbuild test robot
  2016-04-12  7:25   ` Hannes Reinecke
  2 siblings, 0 replies; 35+ messages in thread
From: kbuild test robot @ 2016-04-12  7:10 UTC (permalink / raw)
  Cc: kbuild-all, Tejun Heo, linux-ide, Martin K. Petersen,
	Christoph Hellwig, James Bottomley, Shaun Tancheff,
	Damien Le Moal, linux-scsi, Hannes Reinecke, Hannes Reinecke

[-- Attachment #1: Type: text/plain, Size: 1616 bytes --]

Hi Hannes,

[auto build test ERROR on tj-libata/for-next]
[also build test ERROR on next-20160412]
[cannot apply to v4.6-rc3]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Hannes-Reinecke/ZAC-support/20160412-145232
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tj/libata for-next
config: xtensa-allmodconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=xtensa 

All errors (new ones prefixed by >>):

   drivers/scsi/hisi_sas/hisi_sas_v2_hw.c: In function 'get_ata_protocol':
>> drivers/scsi/hisi_sas/hisi_sas_v2_hw.c:1576:7: error: 'ATA_CMD_FPMDA_RECV' undeclared (first use in this function)
     case ATA_CMD_FPMDA_RECV:
          ^
   drivers/scsi/hisi_sas/hisi_sas_v2_hw.c:1576:7: note: each undeclared identifier is reported only once for each function it appears in

vim +/ATA_CMD_FPMDA_RECV +1576 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c

  1570	
  1571	static u8 get_ata_protocol(u8 cmd, int direction)
  1572	{
  1573		switch (cmd) {
  1574		case ATA_CMD_FPDMA_WRITE:
  1575		case ATA_CMD_FPDMA_READ:
> 1576		case ATA_CMD_FPMDA_RECV:
  1577		case ATA_CMD_FPDMA_SEND:
  1578		return SATA_PROTOCOL_FPDMA;
  1579	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 44809 bytes --]

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCHv2 02/14] libsas: enable FPDMA SEND/RECEIVE
  2016-04-12  6:47 ` [PATCHv2 02/14] libsas: enable FPDMA SEND/RECEIVE Hannes Reinecke
  2016-04-12  7:10   ` kbuild test robot
@ 2016-04-12  7:19   ` kbuild test robot
  2016-04-12  7:25   ` Hannes Reinecke
  2 siblings, 0 replies; 35+ messages in thread
From: kbuild test robot @ 2016-04-12  7:19 UTC (permalink / raw)
  Cc: kbuild-all, Tejun Heo, linux-ide, Martin K. Petersen,
	Christoph Hellwig, James Bottomley, Shaun Tancheff,
	Damien Le Moal, linux-scsi, Hannes Reinecke, Hannes Reinecke

Hi Hannes,

[auto build test WARNING on tj-libata/for-next]
[also build test WARNING on next-20160412]
[cannot apply to v4.6-rc3]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Hannes-Reinecke/ZAC-support/20160412-145232
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tj/libata for-next
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

   include/linux/compiler.h:232:8: sparse: attribute 'no_sanitize_address': unknown attribute
   drivers/scsi/hisi_sas/hisi_sas_v2_hw.c:1576:14: sparse: undefined identifier 'ATA_CMD_FPMDA_RECV'
>> drivers/scsi/hisi_sas/hisi_sas_v2_hw.c:1576:14: sparse: incompatible types for 'case' statement
   drivers/scsi/hisi_sas/hisi_sas_v2_hw.c:1576:14: sparse: Expected constant expression in case statement
   drivers/scsi/hisi_sas/hisi_sas_v2_hw.c: In function 'get_ata_protocol':
   drivers/scsi/hisi_sas/hisi_sas_v2_hw.c:1576:7: error: 'ATA_CMD_FPMDA_RECV' undeclared (first use in this function)
     case ATA_CMD_FPMDA_RECV:
          ^
   drivers/scsi/hisi_sas/hisi_sas_v2_hw.c:1576:7: note: each undeclared identifier is reported only once for each function it appears in

vim +/case +1576 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c

  1560			sas_dev->running_req--;
  1561	
  1562		hisi_sas_slot_task_free(hisi_hba, task, slot);
  1563		sts = ts->stat;
  1564	
  1565		if (task->task_done)
  1566			task->task_done(task);
  1567	
  1568		return sts;
  1569	}
  1570	
  1571	static u8 get_ata_protocol(u8 cmd, int direction)
  1572	{
  1573		switch (cmd) {
  1574		case ATA_CMD_FPDMA_WRITE:
  1575		case ATA_CMD_FPDMA_READ:
> 1576		case ATA_CMD_FPMDA_RECV:
  1577		case ATA_CMD_FPDMA_SEND:
  1578		return SATA_PROTOCOL_FPDMA;
  1579	
  1580		case ATA_CMD_ID_ATA:
  1581		case ATA_CMD_PMP_READ:
  1582		case ATA_CMD_READ_LOG_EXT:
  1583		case ATA_CMD_PIO_READ:
  1584		case ATA_CMD_PIO_READ_EXT:

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCHv2 02/14] libsas: enable FPDMA SEND/RECEIVE
  2016-04-12  6:47 ` [PATCHv2 02/14] libsas: enable FPDMA SEND/RECEIVE Hannes Reinecke
  2016-04-12  7:10   ` kbuild test robot
  2016-04-12  7:19   ` kbuild test robot
@ 2016-04-12  7:25   ` Hannes Reinecke
  2 siblings, 0 replies; 35+ messages in thread
From: Hannes Reinecke @ 2016-04-12  7:25 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke

On 04/12/2016 08:47 AM, Hannes Reinecke wrote:
> Update libsas and dependent drivers to handle FPDMA
> SEND/RECEIVE correctly.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.com>
> ---
>  drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 2 ++
>  drivers/scsi/isci/request.c            | 4 +++-
>  drivers/scsi/libsas/sas_ata.c          | 6 ++++--
>  drivers/scsi/mvsas/mv_sas.c            | 4 +++-
>  drivers/scsi/pm8001/pm8001_sas.c       | 4 +++-
>  5 files changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
> index b733747..fc2e767 100644
> --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
> +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
> @@ -1573,6 +1573,8 @@ static u8 get_ata_protocol(u8 cmd, int direction)
>  	switch (cmd) {
>  	case ATA_CMD_FPDMA_WRITE:
>  	case ATA_CMD_FPDMA_READ:
> +	case ATA_CMD_FPMDA_RECV:
> +	case ATA_CMD_FPDMA_SEND:
>  	return SATA_PROTOCOL_FPDMA;
>  
>  	case ATA_CMD_ID_ATA:
Bah. Blasted typo; had it fixed up at one point, but now it crept in
again. Tejun, can you fix it up or should I resubmit this patch?

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCHv2 03/14] libsas: Define ATA_CMD_NCQ_NON_DATA
  2016-04-12  6:47 ` [PATCHv2 03/14] libsas: Define ATA_CMD_NCQ_NON_DATA Hannes Reinecke
@ 2016-04-12 10:03   ` John Garry
  2016-04-12 10:25     ` Hannes Reinecke
  0 siblings, 1 reply; 35+ messages in thread
From: John Garry @ 2016-04-12 10:03 UTC (permalink / raw)
  To: Hannes Reinecke, Tejun Heo
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke

On 12/04/2016 07:47, Hannes Reinecke wrote:
> Define the NCQ NON DATA command and update libsas to handle it
> correctly.
>
> Signed-off-by: Hannes Reinecke <hare@suse.com>
> ---
>   drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 1 +
>   drivers/scsi/isci/request.c            | 3 ++-
>   drivers/scsi/libsas/sas_ata.c          | 3 ++-
>   drivers/scsi/mvsas/mv_sas.c            | 3 ++-
>   drivers/scsi/pm8001/pm8001_sas.c       | 3 ++-
>   include/linux/ata.h                    | 1 +
>   include/trace/events/libata.h          | 1 +
>   7 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
> index fc2e767..ebaf5ab 100644
> --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
> +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
> @@ -1575,6 +1575,7 @@ static u8 get_ata_protocol(u8 cmd, int direction)
>   	case ATA_CMD_FPDMA_READ:
>   	case ATA_CMD_FPMDA_RECV:
>   	case ATA_CMD_FPDMA_SEND:
> +	case ATA_CMD_NCQ_NON_DATA:
>   	return SATA_PROTOCOL_FPDMA;
>

I'm going to double-check this. It may correspond to 
SATA_PROTOCOL_NONDATA, and not SATA_PROTOCOL_FPDMA.

Cheers,

>   	case ATA_CMD_ID_ATA:
> diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
> index 29456e0..b709d2b 100644
> --- a/drivers/scsi/isci/request.c
> +++ b/drivers/scsi/isci/request.c
> @@ -3171,7 +3171,8 @@ static enum sci_status isci_request_stp_request_construct(struct isci_request *i
>   	if (qc && (qc->tf.command == ATA_CMD_FPDMA_WRITE ||
>   		   qc->tf.command == ATA_CMD_FPDMA_READ ||
>   		   qc->tf.command == ATA_CMD_FPDMA_RECV ||
> -		   qc->tf.command == ATA_CMD_FPDMA_SEND)) {
> +		   qc->tf.command == ATA_CMD_FPDMA_SEND ||
> +		   qc->tf.command == ATA_CMD_NCQ_NON_DATA)) {
>   		fis->sector_count = qc->tag << 3;
>   		ireq->tc->type.stp.ncq_tag = qc->tag;
>   	}
> diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
> index fe1cd26..935c430 100644
> --- a/drivers/scsi/libsas/sas_ata.c
> +++ b/drivers/scsi/libsas/sas_ata.c
> @@ -207,7 +207,8 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc)
>   	if (qc->tf.command == ATA_CMD_FPDMA_WRITE ||
>   	    qc->tf.command == ATA_CMD_FPDMA_READ ||
>   	    qc->tf.command == ATA_CMD_FPDMA_RECV ||
> -	    qc->tf.command == ATA_CMD_FPDMA_SEND) {
> +	    qc->tf.command == ATA_CMD_FPDMA_SEND ||
> +	    qc->tf.command == ATA_CMD_NCQ_NON_DATA) {
>   		/* Need to zero out the tag libata assigned us */
>   		qc->tf.nsect = 0;
>   	}
> diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c
> index db37149..5b9fcff 100644
> --- a/drivers/scsi/mvsas/mv_sas.c
> +++ b/drivers/scsi/mvsas/mv_sas.c
> @@ -431,7 +431,8 @@ static u32 mvs_get_ncq_tag(struct sas_task *task, u32 *tag)
>   		if (qc->tf.command == ATA_CMD_FPDMA_WRITE ||
>   		    qc->tf.command == ATA_CMD_FPDMA_READ ||
>   		    qc->tf.command == ATA_CMD_FPDMA_RECV ||
> -		    qc->tf.command == ATA_CMD_FPDMA_SEND) {
> +		    qc->tf.command == ATA_CMD_FPDMA_SEND ||
> +		    qc->tf.command == ATA_CMD_NCQ_NON_DATA) {
>   			*tag = qc->tag;
>   			return 1;
>   		}
> diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
> index 62abd98..dc33dfa 100644
> --- a/drivers/scsi/pm8001/pm8001_sas.c
> +++ b/drivers/scsi/pm8001/pm8001_sas.c
> @@ -282,7 +282,8 @@ u32 pm8001_get_ncq_tag(struct sas_task *task, u32 *tag)
>   		if (qc->tf.command == ATA_CMD_FPDMA_WRITE ||
>   		    qc->tf.command == ATA_CMD_FPDMA_READ ||
>   		    qc->tf.command == ATA_CMD_FPDMA_RECV ||
> -		    qc->tf.command == ATA_CMD_FPDMA_SEND) {
> +		    qc->tf.command == ATA_CMD_FPDMA_SEND ||
> +		    qc->tf.command == ATA_CMD_NCQ_NON_DATA) {
>   			*tag = qc->tag;
>   			return 1;
>   		}
> diff --git a/include/linux/ata.h b/include/linux/ata.h
> index 00aebc4..b84210a 100644
> --- a/include/linux/ata.h
> +++ b/include/linux/ata.h
> @@ -243,6 +243,7 @@ enum {
>   	ATA_CMD_WRITE_QUEUED_FUA_EXT = 0x3E,
>   	ATA_CMD_FPDMA_READ	= 0x60,
>   	ATA_CMD_FPDMA_WRITE	= 0x61,
> +	ATA_CMD_NCQ_NON_DATA	= 0x63,
>   	ATA_CMD_FPDMA_SEND	= 0x64,
>   	ATA_CMD_FPDMA_RECV	= 0x65,
>   	ATA_CMD_PIO_READ	= 0x20,
> diff --git a/include/trace/events/libata.h b/include/trace/events/libata.h
> index 8b0fbd9..0168603 100644
> --- a/include/trace/events/libata.h
> +++ b/include/trace/events/libata.h
> @@ -39,6 +39,7 @@
>   		 ata_opcode_name(ATA_CMD_WRITE_QUEUED_FUA_EXT), \
>   		 ata_opcode_name(ATA_CMD_FPDMA_READ),		\
>   		 ata_opcode_name(ATA_CMD_FPDMA_WRITE),		\
> +		 ata_opcode_name(ATA_CMD_NCQ_NON_DATA),		\
>   		 ata_opcode_name(ATA_CMD_FPDMA_SEND),		\
>   		 ata_opcode_name(ATA_CMD_FPDMA_RECV),		\
>   		 ata_opcode_name(ATA_CMD_PIO_READ),		\
>



^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCHv2 03/14] libsas: Define ATA_CMD_NCQ_NON_DATA
  2016-04-12 10:03   ` John Garry
@ 2016-04-12 10:25     ` Hannes Reinecke
  2016-04-14  9:06       ` John Garry
  0 siblings, 1 reply; 35+ messages in thread
From: Hannes Reinecke @ 2016-04-12 10:25 UTC (permalink / raw)
  To: John Garry, Tejun Heo
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke

On 04/12/2016 12:03 PM, John Garry wrote:
> On 12/04/2016 07:47, Hannes Reinecke wrote:
>> Define the NCQ NON DATA command and update libsas to handle it
>> correctly.
>>
>> Signed-off-by: Hannes Reinecke <hare@suse.com>
>> ---
>>   drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 1 +
>>   drivers/scsi/isci/request.c            | 3 ++-
>>   drivers/scsi/libsas/sas_ata.c          | 3 ++-
>>   drivers/scsi/mvsas/mv_sas.c            | 3 ++-
>>   drivers/scsi/pm8001/pm8001_sas.c       | 3 ++-
>>   include/linux/ata.h                    | 1 +
>>   include/trace/events/libata.h          | 1 +
>>   7 files changed, 11 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
>> b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
>> index fc2e767..ebaf5ab 100644
>> --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
>> +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
>> @@ -1575,6 +1575,7 @@ static u8 get_ata_protocol(u8 cmd, int
>> direction)
>>       case ATA_CMD_FPDMA_READ:
>>       case ATA_CMD_FPMDA_RECV:
>>       case ATA_CMD_FPDMA_SEND:
>> +    case ATA_CMD_NCQ_NON_DATA:
>>       return SATA_PROTOCOL_FPDMA;
>>
> 
> I'm going to double-check this. It may correspond to
> SATA_PROTOCOL_NONDATA, and not SATA_PROTOCOL_FPDMA.
> 
Thanks. The spec is not exactly clear in that regard...

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCHv2 11/14] libata: Implement ZBC OUT translation
  2016-04-12  6:47 ` [PATCHv2 11/14] libata: Implement ZBC OUT translation Hannes Reinecke
@ 2016-04-12 18:54   ` Shaun Tancheff
  0 siblings, 0 replies; 35+ messages in thread
From: Shaun Tancheff @ 2016-04-12 18:54 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Tejun Heo, linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Damien Le Moal, linux-scsi

On Tue, Apr 12, 2016 at 1:47 PM, Hannes Reinecke <hare@suse.de> wrote:
> ZAC drives implement a 'ZAC Management Out' command template,
> which maps onto the ZBC OUT command.
>
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
>  drivers/ata/libata-eh.c       |  1 +
>  drivers/ata/libata-scsi.c     | 67 +++++++++++++++++++++++++++++++++++++++++++
>  drivers/ata/libata-trace.c    | 16 +++++++++++
>  include/linux/ata.h           |  7 +++++
>  include/trace/events/libata.h |  1 +
>  5 files changed, 92 insertions(+)
>
> diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
> index 4932ce5..4c2bf7f 100644
> --- a/drivers/ata/libata-eh.c
> +++ b/drivers/ata/libata-eh.c
> @@ -2503,6 +2503,7 @@ const char *ata_get_cmd_descript(u8 command)
>                 { ATA_CMD_REQ_SENSE_DATA,       "REQUEST SENSE DATA EXT" },
>                 { ATA_CMD_SANITIZE_DEVICE,      "SANITIZE DEVICE" },
>                 { ATA_CMD_ZAC_MGMT_IN,          "ZAC MANAGEMENT IN" },
> +               { ATA_CMD_ZAC_MGMT_OUT,         "ZAC MANAGEMENT OUT" },
>                 { ATA_CMD_READ_LONG,            "READ LONG (with retries)" },
>                 { ATA_CMD_READ_LONG_ONCE,       "READ LONG (without retries)" },
>                 { ATA_CMD_WRITE_LONG,           "WRITE LONG (with retries)" },
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index 3e402a8..ef696a3 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -3471,6 +3471,70 @@ invalid_param_len:
>         return 1;
>  }
>
> +static unsigned int ata_scsi_zbc_out_xlat(struct ata_queued_cmd *qc)
> +{
> +       struct ata_taskfile *tf = &qc->tf;
> +       struct scsi_cmnd *scmd = qc->scsicmd;
> +       struct ata_device *dev = qc->dev;
> +       const u8 *cdb = scmd->cmnd;
> +       u8 reset_all, sa;
> +       u64 block;
> +       u32 n_block;
> +       u16 fp = (u16)-1;
> +
> +       if (unlikely(scmd->cmd_len < 16)) {
> +               fp = 15;
> +               goto invalid_fld;
> +       }
> +
> +       sa = cdb[1] & 0x1f;
> +       if ((sa != ZO_CLOSE_ZONE) && (sa != ZO_FINISH_ZONE) &&
> +           (sa != ZO_OPEN_ZONE) && (sa != ZO_RESET_WRITE_POINTER)) {
> +               fp = 1;
> +               goto invalid_fld;
> +       }
> +
> +       scsi_16_lba_len(cdb, &block, &n_block);
> +       if (n_block) {
> +               /*
> +                * ZAC MANAGEMENT OUT doesn't define any length
> +                */
> +               goto invalid_param_len;
> +       }
> +       if (block > dev->n_sectors)
> +               goto out_of_range;
> +
> +       reset_all = cdb[14] & 0x1;
> +
> +       tf->protocol = ATA_PROT_NODATA;
> +       tf->command = ATA_CMD_ZAC_MGMT_OUT;
> +       tf->feature = sa;
> +       tf->hob_feature = reset_all & 0x1;
> +
> +       tf->lbah = (block >> 16) & 0xff;
> +       tf->lbam = (block >> 8) & 0xff;
> +       tf->lbal = block & 0xff;
> +       tf->hob_lbah = (block >> 40) & 0xff;
> +       tf->hob_lbam = (block >> 32) & 0xff;
> +       tf->hob_lbal = (block >> 24) & 0xff;
> +       tf->device = ATA_LBA;
> +       tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_LBA48;
> +
> +       return 0;
> +
> + invalid_fld:
> +       ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff);
> +       return 1;
> + out_of_range:
> +       /* "Logical Block Address out of range" */
> +       ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x21, 0x00);
> +       return 1;
> +invalid_param_len:
> +       /* "Parameter list length error" */
> +       ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0);
> +       return 1;
> +}
> +
>  /**
>   *     ata_mselect_caching - Simulate MODE SELECT for caching info page
>   *     @qc: Storage for translated ATA taskfile
> @@ -3789,6 +3853,9 @@ static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd)
>         case ZBC_IN:
>                 return ata_scsi_zbc_in_xlat;
>
> +       case ZBC_OUT:
> +               return ata_scsi_zbc_out_xlat;
> +
>         case START_STOP:
>                 return ata_scsi_start_stop_xlat;
>         }
> diff --git a/drivers/ata/libata-trace.c b/drivers/ata/libata-trace.c
> index 9caeabd..1111ba7 100644
> --- a/drivers/ata/libata-trace.c
> +++ b/drivers/ata/libata-trace.c
> @@ -197,6 +197,22 @@ libata_trace_parse_subcmd(struct trace_seq *p, unsigned char cmd,
>                         break;
>                 }
>                 break;
> +       case ATA_CMD_ZAC_MGMT_OUT:
> +               switch (feature) {
> +               case ATA_SUBCMD_ZAC_MGMT_OUT_CLOSE_ZONE:
> +                       trace_seq_printf(p, " CLOSE_ZONE");
> +                       break;
> +               case ATA_SUBCMD_ZAC_MGMT_OUT_FINISH_ZONE:
> +                       trace_seq_printf(p, " FINISH_ZONE");
> +                       break;
> +               case ATA_SUBCMD_ZAC_MGMT_OUT_OPEN_ZONE:
> +                       trace_seq_printf(p, " OPEN_ZONE");
> +                       break;
> +               case ATA_SUBCMD_ZAC_MGMT_OUT_RESET_WRITE_POINTER:
> +                       trace_seq_printf(p, " RESET_WRITE_POINTER");
> +                       break;
> +               }
> +               break;
>         }
>         trace_seq_putc(p, 0);
>
> diff --git a/include/linux/ata.h b/include/linux/ata.h
> index 2f01ba9..e3bf9a3 100644
> --- a/include/linux/ata.h
> +++ b/include/linux/ata.h
> @@ -303,6 +303,7 @@ enum {
>         ATA_CMD_REQ_SENSE_DATA  = 0x0B,
>         ATA_CMD_SANITIZE_DEVICE = 0xB4,
>         ATA_CMD_ZAC_MGMT_IN     = 0x4A,
> +       ATA_CMD_ZAC_MGMT_OUT    = 0x9F,
>
>         /* marked obsolete in the ATA/ATAPI-7 spec */
>         ATA_CMD_RESTORE         = 0x10,
> @@ -323,6 +324,12 @@ enum {
>         /* Subcmds for ATA_CMD_ZAC_MGMT_IN */
>         ATA_SUBCMD_ZAC_MGMT_IN_REPORT_ZONES = 0x00,
>
> +       /* Subcmds for ATA_CMD_ZAC_MGMT_OUT */
> +       ATA_SUBCMD_ZAC_MGMT_OUT_CLOSE_ZONE = 0x01,
> +       ATA_SUBCMD_ZAC_MGMT_OUT_FINISH_ZONE = 0x02,
> +       ATA_SUBCMD_ZAC_MGMT_OUT_OPEN_ZONE = 0x03,
> +       ATA_SUBCMD_ZAC_MGMT_OUT_RESET_WRITE_POINTER = 0x04,
> +
>         /* READ_LOG_EXT pages */
>         ATA_LOG_DIRECTORY       = 0x0,
>         ATA_LOG_SATA_NCQ        = 0x10,
> diff --git a/include/trace/events/libata.h b/include/trace/events/libata.h
> index b966417..3032edc 100644
> --- a/include/trace/events/libata.h
> +++ b/include/trace/events/libata.h
> @@ -99,6 +99,7 @@
>                  ata_opcode_name(ATA_CMD_REQ_SENSE_DATA),       \
>                  ata_opcode_name(ATA_CMD_SANITIZE_DEVICE),      \
>                  ata_opcode_name(ATA_CMD_ZAC_MGMT_IN),          \
> +                ata_opcode_name(ATA_CMD_ZAC_MGMT_OUT),         \
>                  ata_opcode_name(ATA_CMD_RESTORE),              \
>                  ata_opcode_name(ATA_CMD_READ_LONG),            \
>                  ata_opcode_name(ATA_CMD_READ_LONG_ONCE),       \
> --
> 1.8.5.6
>

Thanks for adding Open/Close/Finish.

Reviewed-by: Shaun Tancheff <shaun.tancheff@seagate.com>
Tested-by: Shaun Tancheff <shaun.tancheff@seagate.com>

-- 
Shaun Tancheff

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCHv2 05/14] libata: NCQ Encapsulation for READ LOG DMA EXT
  2016-04-12  6:47 ` [PATCHv2 05/14] libata: NCQ Encapsulation for READ LOG DMA EXT Hannes Reinecke
@ 2016-04-13 18:07   ` Tejun Heo
  2016-04-14  5:44     ` Hannes Reinecke
  0 siblings, 1 reply; 35+ messages in thread
From: Tejun Heo @ 2016-04-13 18:07 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke

On Tue, Apr 12, 2016 at 08:47:49AM +0200, Hannes Reinecke wrote:
> Recent devices can use NCQ encapsulation for READ LOG DMA EXT,
> so we should be using it if available.

Does this have any actual benefits than being new and shiny?  It's
being called from EH path where we know that no other commands are in
flight.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCHv2 06/14] libata: Check log page directory before accessing pages
  2016-04-12  6:47 ` [PATCHv2 06/14] libata: Check log page directory before accessing pages Hannes Reinecke
@ 2016-04-13 18:08   ` Tejun Heo
  2016-04-14  5:44     ` Hannes Reinecke
  0 siblings, 1 reply; 35+ messages in thread
From: Tejun Heo @ 2016-04-13 18:08 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke

On Tue, Apr 12, 2016 at 08:47:50AM +0200, Hannes Reinecke wrote:
> +	log_pages = get_unaligned_le16(&ap->sector_buf[log_index]);
> +	if (!log_pages) {
> +		ata_dev_warn(dev,
> +			     "NCQ Send/Recv Log not supported\n");

Shouldn't this be an info message?

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCHv2 09/14] libata: fixup ZAC device disabling
  2016-04-12  6:47 ` [PATCHv2 09/14] libata: fixup ZAC device disabling Hannes Reinecke
@ 2016-04-13 18:09   ` Tejun Heo
  2016-04-14  5:48     ` Hannes Reinecke
  0 siblings, 1 reply; 35+ messages in thread
From: Tejun Heo @ 2016-04-13 18:09 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke

On Tue, Apr 12, 2016 at 08:47:53AM +0200, Hannes Reinecke wrote:
> libata device disabling is ... curious. So add the correct
> definitions that we can disable ZAC devices properly.

Fold into an earlier patch?

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCHv2 13/14] libata: support device-managed ZAC devices
  2016-04-12  6:47 ` [PATCHv2 13/14] libata: support device-managed ZAC devices Hannes Reinecke
@ 2016-04-13 20:50   ` Shaun Tancheff
  0 siblings, 0 replies; 35+ messages in thread
From: Shaun Tancheff @ 2016-04-13 20:50 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Tejun Heo, linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Damien Le Moal, linux-scsi

On Tue, Apr 12, 2016 at 1:47 PM, Hannes Reinecke <hare@suse.de> wrote:
> Device-managed ZAC devices just set the zoned capabilities field
> in INQUIRY byte 69 (cf ACS-4). This corresponds to the 'zoned'
> field in the block device characteristics VPD page.
> As this is only defined in SPC-5/SBC-4 we also need to update
> the supported SCSI version descriptor.
>
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
>  drivers/ata/libata-scsi.c | 19 ++++++++++---------
>  include/linux/ata.h       |  5 +++++
>  2 files changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index 5f1fc03..a92fbe9 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -2082,14 +2082,14 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)
>                 0x00,
>                 0xA0,   /* SAM-5 (no version claimed) */
>
> -               0x04,
> -               0xC0,   /* SBC-3 (no version claimed) */
> +               0x06,
> +               0x00,   /* SBC-4 (no version claimed) */
>
> -               0x04,
> -               0x60,   /* SPC-4 (no version claimed) */
> +               0x05,
> +               0xC0,   /* SPC-5 (no version claimed) */
>
>                 0x60,
> -               0x20,   /* ZBC (no version claimed) */
> +               0x24,   /* ZBC r05 */
>         };
>
>         u8 hdr[] = {
> @@ -2109,10 +2109,8 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)
>             (args->dev->link->ap->pflags & ATA_PFLAG_EXTERNAL))
>                 hdr[1] |= (1 << 7);
>
> -       if (args->dev->class == ATA_DEV_ZAC) {
> +       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);
> @@ -2126,7 +2124,7 @@ 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);
>
> -       if (args->dev->class == ATA_DEV_ZAC)
> +       if (ata_id_zoned_cap(args->id) || args->dev->class == ATA_DEV_ZAC)
>                 memcpy(rbuf + 58, versions_zbc, sizeof(versions_zbc));
>         else
>                 memcpy(rbuf + 58, versions, sizeof(versions));
> @@ -2322,12 +2320,15 @@ static unsigned int ata_scsiop_inq_b1(struct ata_scsi_args *args, u8 *rbuf)
>  {
>         int form_factor = ata_id_form_factor(args->id);
>         int media_rotation_rate = ata_id_rotation_rate(args->id);
> +       u8 zoned = ata_id_zoned_cap(args->id);
>
>         rbuf[1] = 0xb1;
>         rbuf[3] = 0x3c;
>         rbuf[4] = media_rotation_rate >> 8;
>         rbuf[5] = media_rotation_rate;
>         rbuf[7] = form_factor;
> +       if (zoned)
> +               rbuf[8] = (zoned << 4);
>
>         return 0;
>  }
> diff --git a/include/linux/ata.h b/include/linux/ata.h
> index 3fb2d7d..439be2a 100644
> --- a/include/linux/ata.h
> +++ b/include/linux/ata.h
> @@ -932,6 +932,11 @@ static inline bool ata_id_is_ssd(const u16 *id)
>         return id[ATA_ID_ROT_SPEED] == 0x01;
>  }
>
> +static inline u8 ata_id_zoned_cap(const u16 *id)
> +{
> +       return (id[ATA_ID_ADDITIONAL_SUPP] & 0x3);
> +}
> +
>  static inline bool ata_id_pio_need_iordy(const u16 *id, const u8 pio)
>  {
>         /* CF spec. r4.1 Table 22 says no IORDY on PIO5 and PIO6. */
> --
> 1.8.5.6
>
This also covers Host aware zoned drives.

Reviewed-by: Shaun Tancheff <shaun.tancheff@seagate.com>
Tested-by: Shaun Tancheff <shaun.tancheff@seagate.com>

Regards,

Shaun Tancheff

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCHv2 05/14] libata: NCQ Encapsulation for READ LOG DMA EXT
  2016-04-13 18:07   ` Tejun Heo
@ 2016-04-14  5:44     ` Hannes Reinecke
  2016-04-14 15:43       ` Tejun Heo
  0 siblings, 1 reply; 35+ messages in thread
From: Hannes Reinecke @ 2016-04-14  5:44 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke

On 04/13/2016 08:07 PM, Tejun Heo wrote:
> On Tue, Apr 12, 2016 at 08:47:49AM +0200, Hannes Reinecke wrote:
>> Recent devices can use NCQ encapsulation for READ LOG DMA EXT,
>> so we should be using it if available.
> 
> Does this have any actual benefits than being new and shiny?  It's
> being called from EH path where we know that no other commands are in
> flight.
> 
Hehe. No, it isn't, if you look closely.
(Or make that: it _shouldn't_, and I've messed it up)
(That's what the 'fpdma' parameter is for)

The benefit is not so much for normal operations, but it'll give us
a performance improvements on SMR drives where we need to issue
READ LOG DMA EXT rather frequently. There we really want to have
them as NCQ commands.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCHv2 06/14] libata: Check log page directory before accessing pages
  2016-04-13 18:08   ` Tejun Heo
@ 2016-04-14  5:44     ` Hannes Reinecke
  0 siblings, 0 replies; 35+ messages in thread
From: Hannes Reinecke @ 2016-04-14  5:44 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke

On 04/13/2016 08:08 PM, Tejun Heo wrote:
> On Tue, Apr 12, 2016 at 08:47:50AM +0200, Hannes Reinecke wrote:
>> +	log_pages = get_unaligned_le16(&ap->sector_buf[log_index]);
>> +	if (!log_pages) {
>> +		ata_dev_warn(dev,
>> +			     "NCQ Send/Recv Log not supported\n");
> 
> Shouldn't this be an info message?
> 
Sure. Will be adjusting it.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCHv2 09/14] libata: fixup ZAC device disabling
  2016-04-13 18:09   ` Tejun Heo
@ 2016-04-14  5:48     ` Hannes Reinecke
  2016-04-14 15:43       ` Tejun Heo
  0 siblings, 1 reply; 35+ messages in thread
From: Hannes Reinecke @ 2016-04-14  5:48 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke

On 04/13/2016 08:09 PM, Tejun Heo wrote:
> On Tue, Apr 12, 2016 at 08:47:53AM +0200, Hannes Reinecke wrote:
>> libata device disabling is ... curious. So add the correct
>> definitions that we can disable ZAC devices properly.
> 
> Fold into an earlier patch?
> 
That earlier patch would be commit
9162c6579bf90b3f5ddb7e3a6c6fa946c1b4cbeb
("libata: Implement ATA_DEV_ZAC"), which got merged
in 2014 ...

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCHv2 03/14] libsas: Define ATA_CMD_NCQ_NON_DATA
  2016-04-12 10:25     ` Hannes Reinecke
@ 2016-04-14  9:06       ` John Garry
  2016-04-14  9:39         ` Hannes Reinecke
  0 siblings, 1 reply; 35+ messages in thread
From: John Garry @ 2016-04-14  9:06 UTC (permalink / raw)
  To: Hannes Reinecke, Tejun Heo
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke

On 12/04/2016 11:25, Hannes Reinecke wrote:
> On 04/12/2016 12:03 PM, John Garry wrote:
>> On 12/04/2016 07:47, Hannes Reinecke wrote:
>>> Define the NCQ NON DATA command and update libsas to handle it
>>> correctly.
>>>
>>> Signed-off-by: Hannes Reinecke <hare@suse.com>
>>> ---
>>>    drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 1 +
>>>    drivers/scsi/isci/request.c            | 3 ++-
>>>    drivers/scsi/libsas/sas_ata.c          | 3 ++-
>>>    drivers/scsi/mvsas/mv_sas.c            | 3 ++-
>>>    drivers/scsi/pm8001/pm8001_sas.c       | 3 ++-
>>>    include/linux/ata.h                    | 1 +
>>>    include/trace/events/libata.h          | 1 +
>>>    7 files changed, 11 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
>>> b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
>>> index fc2e767..ebaf5ab 100644
>>> --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
>>> +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
>>> @@ -1575,6 +1575,7 @@ static u8 get_ata_protocol(u8 cmd, int
>>> direction)
>>>        case ATA_CMD_FPDMA_READ:
>>>        case ATA_CMD_FPMDA_RECV:
>>>        case ATA_CMD_FPDMA_SEND:
>>> +    case ATA_CMD_NCQ_NON_DATA:
>>>        return SATA_PROTOCOL_FPDMA;
>>>
>>
>> I'm going to double-check this. It may correspond to
>> SATA_PROTOCOL_NONDATA, and not SATA_PROTOCOL_FPDMA.
>>

So I got confirmation that SATA_PROTOCOL_FPDMA is correct for this type 
of command and we do support it.

If we want to test is it ok just to take this patchset and the other 
advised prerequisite patchsets?

> Thanks. The spec is not exactly clear in that regard...
>
> Cheers,
>
> Hannes
>



^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCHv2 03/14] libsas: Define ATA_CMD_NCQ_NON_DATA
  2016-04-14  9:06       ` John Garry
@ 2016-04-14  9:39         ` Hannes Reinecke
  0 siblings, 0 replies; 35+ messages in thread
From: Hannes Reinecke @ 2016-04-14  9:39 UTC (permalink / raw)
  To: John Garry, Tejun Heo
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke

On 04/14/2016 11:06 AM, John Garry wrote:
> On 12/04/2016 11:25, Hannes Reinecke wrote:
>> On 04/12/2016 12:03 PM, John Garry wrote:
>>> On 12/04/2016 07:47, Hannes Reinecke wrote:
>>>> Define the NCQ NON DATA command and update libsas to handle it
>>>> correctly.
>>>>
>>>> Signed-off-by: Hannes Reinecke <hare@suse.com>
>>>> ---
>>>>    drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 1 +
>>>>    drivers/scsi/isci/request.c            | 3 ++-
>>>>    drivers/scsi/libsas/sas_ata.c          | 3 ++-
>>>>    drivers/scsi/mvsas/mv_sas.c            | 3 ++-
>>>>    drivers/scsi/pm8001/pm8001_sas.c       | 3 ++-
>>>>    include/linux/ata.h                    | 1 +
>>>>    include/trace/events/libata.h          | 1 +
>>>>    7 files changed, 11 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
>>>> b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
>>>> index fc2e767..ebaf5ab 100644
>>>> --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
>>>> +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
>>>> @@ -1575,6 +1575,7 @@ static u8 get_ata_protocol(u8 cmd, int
>>>> direction)
>>>>        case ATA_CMD_FPDMA_READ:
>>>>        case ATA_CMD_FPMDA_RECV:
>>>>        case ATA_CMD_FPDMA_SEND:
>>>> +    case ATA_CMD_NCQ_NON_DATA:
>>>>        return SATA_PROTOCOL_FPDMA;
>>>>
>>>
>>> I'm going to double-check this. It may correspond to
>>> SATA_PROTOCOL_NONDATA, and not SATA_PROTOCOL_FPDMA.
>>>
> 
> So I got confirmation that SATA_PROTOCOL_FPDMA is correct for this
> type of command and we do support it.
> 
> If we want to test is it ok just to take this patchset and the other
> advised prerequisite patchsets?
> 
Yes, that should be sufficient.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCHv2 05/14] libata: NCQ Encapsulation for READ LOG DMA EXT
  2016-04-14  5:44     ` Hannes Reinecke
@ 2016-04-14 15:43       ` Tejun Heo
  2016-04-14 15:59         ` Hannes Reinecke
  0 siblings, 1 reply; 35+ messages in thread
From: Tejun Heo @ 2016-04-14 15:43 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke

Hello, Hannes.

On Thu, Apr 14, 2016 at 07:44:19AM +0200, Hannes Reinecke wrote:
> Hehe. No, it isn't, if you look closely.
> (Or make that: it _shouldn't_, and I've messed it up)
> (That's what the 'fpdma' parameter is for)
> 
> The benefit is not so much for normal operations, but it'll give us
> a performance improvements on SMR drives where we need to issue
> READ LOG DMA EXT rather frequently. There we really want to have
> them as NCQ commands.

I'm still a bit confused.  Isn't it part of EH?  If so, the path is
never traveled with other commands in flight and thus whether a
command is NCQ or not doesn't make any difference.  The only thing
it'd do is making devices which advertise the capability but don't get
it quite right fail.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCHv2 09/14] libata: fixup ZAC device disabling
  2016-04-14  5:48     ` Hannes Reinecke
@ 2016-04-14 15:43       ` Tejun Heo
  0 siblings, 0 replies; 35+ messages in thread
From: Tejun Heo @ 2016-04-14 15:43 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi,
	Hannes Reinecke

On Thu, Apr 14, 2016 at 07:48:03AM +0200, Hannes Reinecke wrote:
> On 04/13/2016 08:09 PM, Tejun Heo wrote:
> > On Tue, Apr 12, 2016 at 08:47:53AM +0200, Hannes Reinecke wrote:
> >> libata device disabling is ... curious. So add the correct
> >> definitions that we can disable ZAC devices properly.
> > 
> > Fold into an earlier patch?
> > 
> That earlier patch would be commit
> 9162c6579bf90b3f5ddb7e3a6c6fa946c1b4cbeb
> ("libata: Implement ATA_DEV_ZAC"), which got merged
> in 2014 ...

Ah, right you are.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCHv2 05/14] libata: NCQ Encapsulation for READ LOG DMA EXT
  2016-04-14 15:43       ` Tejun Heo
@ 2016-04-14 15:59         ` Hannes Reinecke
  2016-04-14 16:07           ` Tejun Heo
  0 siblings, 1 reply; 35+ messages in thread
From: Hannes Reinecke @ 2016-04-14 15:59 UTC (permalink / raw)
  To: Tejun Heo, Hannes Reinecke
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi

On 04/14/2016 05:43 PM, Tejun Heo wrote:
> Hello, Hannes.
>
> On Thu, Apr 14, 2016 at 07:44:19AM +0200, Hannes Reinecke wrote:
>> Hehe. No, it isn't, if you look closely.
>> (Or make that: it _shouldn't_, and I've messed it up)
>> (That's what the 'fpdma' parameter is for)
>>
>> The benefit is not so much for normal operations, but it'll give us
>> a performance improvements on SMR drives where we need to issue
>> READ LOG DMA EXT rather frequently. There we really want to have
>> them as NCQ commands.
>
> I'm still a bit confused.  Isn't it part of EH?  If so, the path is
> never traveled with other commands in flight and thus whether a
> command is NCQ or not doesn't make any difference.  The only thing
> it'd do is making devices which advertise the capability but don't get
> it quite right fail.
>
For this patch, yes, you are right.
However, the ZAC enablement patches later on submit READ LOG EXT 
commands (for REPORT ZONES), and _they_ benefit from NCQ encapsulation.

Cheers,

Hannes


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCHv2 05/14] libata: NCQ Encapsulation for READ LOG DMA EXT
  2016-04-14 15:59         ` Hannes Reinecke
@ 2016-04-14 16:07           ` Tejun Heo
  2016-04-15 12:32             ` Hannes Reinecke
  0 siblings, 1 reply; 35+ messages in thread
From: Tejun Heo @ 2016-04-14 16:07 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Hannes Reinecke, linux-ide, Martin K. Petersen,
	Christoph Hellwig, James Bottomley, Shaun Tancheff,
	Damien Le Moal, linux-scsi

On Thu, Apr 14, 2016 at 05:59:48PM +0200, Hannes Reinecke wrote:
> For this patch, yes, you are right.
> However, the ZAC enablement patches later on submit READ LOG EXT commands
> (for REPORT ZONES), and _they_ benefit from NCQ encapsulation.

Umm... so, you can't use ata_exec_internal() outside of EH context.

-- 
tejun

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCHv2 05/14] libata: NCQ Encapsulation for READ LOG DMA EXT
  2016-04-14 16:07           ` Tejun Heo
@ 2016-04-15 12:32             ` Hannes Reinecke
  0 siblings, 0 replies; 35+ messages in thread
From: Hannes Reinecke @ 2016-04-15 12:32 UTC (permalink / raw)
  To: Tejun Heo, Hannes Reinecke
  Cc: linux-ide, Martin K. Petersen, Christoph Hellwig,
	James Bottomley, Shaun Tancheff, Damien Le Moal, linux-scsi

On 04/14/2016 06:07 PM, Tejun Heo wrote:
> On Thu, Apr 14, 2016 at 05:59:48PM +0200, Hannes Reinecke wrote:
>> For this patch, yes, you are right.
>> However, the ZAC enablement patches later on submit READ LOG EXT commands
>> (for REPORT ZONES), and _they_ benefit from NCQ encapsulation.
> 
> Umm... so, you can't use ata_exec_internal() outside of EH context.
> 
Right, I've checked the overall situation.
Yes, there is an NCQ encapsulation for READ LOG EXT, but indeed we
cannot sensibly use it from an EH context.
And the only other position where we would need it is during device
initialisation, which is hardly performance critical.

So I'll be dropping this patch from the next round of submissions
and will just keep the command definitions.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2016-04-15 12:32 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-12  6:47 [PATCHv2 00/14] ZAC support Hannes Reinecke
2016-04-12  6:47 ` [PATCHv2 01/14] libata: do not attempt to retrieve sense code twice Hannes Reinecke
2016-04-12  6:47 ` [PATCHv2 02/14] libsas: enable FPDMA SEND/RECEIVE Hannes Reinecke
2016-04-12  7:10   ` kbuild test robot
2016-04-12  7:19   ` kbuild test robot
2016-04-12  7:25   ` Hannes Reinecke
2016-04-12  6:47 ` [PATCHv2 03/14] libsas: Define ATA_CMD_NCQ_NON_DATA Hannes Reinecke
2016-04-12 10:03   ` John Garry
2016-04-12 10:25     ` Hannes Reinecke
2016-04-14  9:06       ` John Garry
2016-04-14  9:39         ` Hannes Reinecke
2016-04-12  6:47 ` [PATCHv2 04/14] libata: Separate out ata_dev_config_ncq_send_recv() Hannes Reinecke
2016-04-12  6:47 ` [PATCHv2 05/14] libata: NCQ Encapsulation for READ LOG DMA EXT Hannes Reinecke
2016-04-13 18:07   ` Tejun Heo
2016-04-14  5:44     ` Hannes Reinecke
2016-04-14 15:43       ` Tejun Heo
2016-04-14 15:59         ` Hannes Reinecke
2016-04-14 16:07           ` Tejun Heo
2016-04-15 12:32             ` Hannes Reinecke
2016-04-12  6:47 ` [PATCHv2 06/14] libata: Check log page directory before accessing pages Hannes Reinecke
2016-04-13 18:08   ` Tejun Heo
2016-04-14  5:44     ` Hannes Reinecke
2016-04-12  6:47 ` [PATCHv2 07/14] libata-trace: decode subcommands Hannes Reinecke
2016-04-12  6:47 ` [PATCHv2 08/14] libata-scsi: Generate sense code for disabled devices Hannes Reinecke
2016-04-12  6:47 ` [PATCHv2 09/14] libata: fixup ZAC device disabling Hannes Reinecke
2016-04-13 18:09   ` Tejun Heo
2016-04-14  5:48     ` Hannes Reinecke
2016-04-14 15:43       ` Tejun Heo
2016-04-12  6:47 ` [PATCHv2 10/14] libata: implement ZBC IN translation Hannes Reinecke
2016-04-12  6:47 ` [PATCHv2 11/14] libata: Implement ZBC OUT translation Hannes Reinecke
2016-04-12 18:54   ` Shaun Tancheff
2016-04-12  6:47 ` [PATCHv2 12/14] libata: NCQ encapsulation for ZAC MANAGEMENT OUT Hannes Reinecke
2016-04-12  6:47 ` [PATCHv2 13/14] libata: support device-managed ZAC devices Hannes Reinecke
2016-04-13 20:50   ` Shaun Tancheff
2016-04-12  6:47 ` [PATCHv2 14/14] libata: support host-aware and host-managed " Hannes Reinecke

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.