All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/15] hisi_sas misc fixes and minor optimisations
@ 2016-09-06 15:36 ` John Garry
  0 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry

This patchset introdcues some minor bug fixes and
optimisations for v1+v2 hw.

No new functional features are introduced in this patchset.

John Garry (15):
  hisi_sas: save completion queue read pointer
  hisi_sas: save delivery queue write pointer
  hisi_sas: keep CHL_INT2 masked for v2 HW
  hisi_sas: only zero slot memory when reused
  hisi_sas: use safe BITS_PER_BYTE for slot tag size calculation
  hisi_sas: disable dlvry queues once at reset for v2 hw
  hisi_sas: fix phy8 linkrate calculation in phy_up_v2_hw()
  hisi_sas: fix a potential warning for sata disk ejection
  hisi_sas: set dma mask before allocate DMA memory
  hisi_sas: fix HBA SAS addr endianness for v2 hw
  hisi_sas: fix HBA SAS addr endianness for v1 hw
  hisi_sas: remove init_id_frame_v2_hw()
  hisi_sas: remove init_id_frame_v1_hw()
  hisi_sas: add missing SATA pending device type to v2 hw
  hisi_sas: send three identify before PHY up

 drivers/scsi/hisi_sas/hisi_sas.h       |  8 +++++
 drivers/scsi/hisi_sas/hisi_sas_main.c  | 48 ++++++++++---------------
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 36 +++++++------------
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 66 ++++++++++++++++------------------
 4 files changed, 70 insertions(+), 88 deletions(-)

-- 
1.9.1

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

* [PATCH 00/15] hisi_sas misc fixes and minor optimisations
@ 2016-09-06 15:36 ` John Garry
  0 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry

This patchset introdcues some minor bug fixes and
optimisations for v1+v2 hw.

No new functional features are introduced in this patchset.

John Garry (15):
  hisi_sas: save completion queue read pointer
  hisi_sas: save delivery queue write pointer
  hisi_sas: keep CHL_INT2 masked for v2 HW
  hisi_sas: only zero slot memory when reused
  hisi_sas: use safe BITS_PER_BYTE for slot tag size calculation
  hisi_sas: disable dlvry queues once at reset for v2 hw
  hisi_sas: fix phy8 linkrate calculation in phy_up_v2_hw()
  hisi_sas: fix a potential warning for sata disk ejection
  hisi_sas: set dma mask before allocate DMA memory
  hisi_sas: fix HBA SAS addr endianness for v2 hw
  hisi_sas: fix HBA SAS addr endianness for v1 hw
  hisi_sas: remove init_id_frame_v2_hw()
  hisi_sas: remove init_id_frame_v1_hw()
  hisi_sas: add missing SATA pending device type to v2 hw
  hisi_sas: send three identify before PHY up

 drivers/scsi/hisi_sas/hisi_sas.h       |  8 +++++
 drivers/scsi/hisi_sas/hisi_sas_main.c  | 48 ++++++++++---------------
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 36 +++++++------------
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 66 ++++++++++++++++------------------
 4 files changed, 70 insertions(+), 88 deletions(-)

-- 
1.9.1

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

* [PATCH 01/15] hisi_sas: save completion queue read pointer
  2016-09-06 15:36 ` John Garry
@ 2016-09-06 15:36   ` John Garry
  -1 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry

Optimise by saving an avoidable read in the cq
interrupt.
The queue read pointer will only be updated
by software, so don't bother re-reading
what was already written in the previous interrupt.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/hisi_sas/hisi_sas.h       | 1 +
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 6 ++----
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 5 ++---
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index ca55ec2..9410335 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -94,6 +94,7 @@ struct hisi_sas_port {
 
 struct hisi_sas_cq {
 	struct hisi_hba *hisi_hba;
+	int	rd_point;
 	int	id;
 };
 
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
index 1abbc2e..3b31b20 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
@@ -1565,14 +1565,11 @@ static irqreturn_t cq_interrupt_v1_hw(int irq, void *p)
 	struct hisi_sas_complete_v1_hdr *complete_queue =
 			(struct hisi_sas_complete_v1_hdr *)
 			hisi_hba->complete_hdr[queue];
-	u32 irq_value, rd_point, wr_point;
+	u32 irq_value, rd_point = cq->rd_point, wr_point;
 
 	irq_value = hisi_sas_read32(hisi_hba, OQ_INT_SRC);
 
 	hisi_sas_write32(hisi_hba, OQ_INT_SRC, 1 << queue);
-
-	rd_point = hisi_sas_read32(hisi_hba,
-			COMPL_Q_0_RD_PTR + (0x14 * queue));
 	wr_point = hisi_sas_read32(hisi_hba,
 			COMPL_Q_0_WR_PTR + (0x14 * queue));
 
@@ -1600,6 +1597,7 @@ static irqreturn_t cq_interrupt_v1_hw(int irq, void *p)
 	}
 
 	/* update rd_point */
+	cq->rd_point = rd_point;
 	hisi_sas_write32(hisi_hba, COMPL_Q_0_RD_PTR + (0x14 * queue), rd_point);
 
 	return IRQ_HANDLED;
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index bf9b693..11006c9 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -2049,7 +2049,7 @@ static irqreturn_t cq_interrupt_v2_hw(int irq_no, void *p)
 	struct hisi_sas_slot *slot;
 	struct hisi_sas_itct *itct;
 	struct hisi_sas_complete_v2_hdr *complete_queue;
-	u32 irq_value, rd_point, wr_point, dev_id;
+	u32 irq_value, rd_point = cq->rd_point, wr_point, dev_id;
 	int queue = cq->id;
 
 	complete_queue = hisi_hba->complete_hdr[queue];
@@ -2057,8 +2057,6 @@ static irqreturn_t cq_interrupt_v2_hw(int irq_no, void *p)
 
 	hisi_sas_write32(hisi_hba, OQ_INT_SRC, 1 << queue);
 
-	rd_point = hisi_sas_read32(hisi_hba, COMPL_Q_0_RD_PTR +
-				   (0x14 * queue));
 	wr_point = hisi_sas_read32(hisi_hba, COMPL_Q_0_WR_PTR +
 				   (0x14 * queue));
 
@@ -2106,6 +2104,7 @@ static irqreturn_t cq_interrupt_v2_hw(int irq_no, void *p)
 	}
 
 	/* update rd_point */
+	cq->rd_point = rd_point;
 	hisi_sas_write32(hisi_hba, COMPL_Q_0_RD_PTR + (0x14 * queue), rd_point);
 	return IRQ_HANDLED;
 }
-- 
1.9.1

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

* [PATCH 01/15] hisi_sas: save completion queue read pointer
@ 2016-09-06 15:36   ` John Garry
  0 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry

Optimise by saving an avoidable read in the cq
interrupt.
The queue read pointer will only be updated
by software, so don't bother re-reading
what was already written in the previous interrupt.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/hisi_sas/hisi_sas.h       | 1 +
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 6 ++----
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 5 ++---
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index ca55ec2..9410335 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -94,6 +94,7 @@ struct hisi_sas_port {
 
 struct hisi_sas_cq {
 	struct hisi_hba *hisi_hba;
+	int	rd_point;
 	int	id;
 };
 
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
index 1abbc2e..3b31b20 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
@@ -1565,14 +1565,11 @@ static irqreturn_t cq_interrupt_v1_hw(int irq, void *p)
 	struct hisi_sas_complete_v1_hdr *complete_queue =
 			(struct hisi_sas_complete_v1_hdr *)
 			hisi_hba->complete_hdr[queue];
-	u32 irq_value, rd_point, wr_point;
+	u32 irq_value, rd_point = cq->rd_point, wr_point;
 
 	irq_value = hisi_sas_read32(hisi_hba, OQ_INT_SRC);
 
 	hisi_sas_write32(hisi_hba, OQ_INT_SRC, 1 << queue);
-
-	rd_point = hisi_sas_read32(hisi_hba,
-			COMPL_Q_0_RD_PTR + (0x14 * queue));
 	wr_point = hisi_sas_read32(hisi_hba,
 			COMPL_Q_0_WR_PTR + (0x14 * queue));
 
@@ -1600,6 +1597,7 @@ static irqreturn_t cq_interrupt_v1_hw(int irq, void *p)
 	}
 
 	/* update rd_point */
+	cq->rd_point = rd_point;
 	hisi_sas_write32(hisi_hba, COMPL_Q_0_RD_PTR + (0x14 * queue), rd_point);
 
 	return IRQ_HANDLED;
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index bf9b693..11006c9 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -2049,7 +2049,7 @@ static irqreturn_t cq_interrupt_v2_hw(int irq_no, void *p)
 	struct hisi_sas_slot *slot;
 	struct hisi_sas_itct *itct;
 	struct hisi_sas_complete_v2_hdr *complete_queue;
-	u32 irq_value, rd_point, wr_point, dev_id;
+	u32 irq_value, rd_point = cq->rd_point, wr_point, dev_id;
 	int queue = cq->id;
 
 	complete_queue = hisi_hba->complete_hdr[queue];
@@ -2057,8 +2057,6 @@ static irqreturn_t cq_interrupt_v2_hw(int irq_no, void *p)
 
 	hisi_sas_write32(hisi_hba, OQ_INT_SRC, 1 << queue);
 
-	rd_point = hisi_sas_read32(hisi_hba, COMPL_Q_0_RD_PTR +
-				   (0x14 * queue));
 	wr_point = hisi_sas_read32(hisi_hba, COMPL_Q_0_WR_PTR +
 				   (0x14 * queue));
 
@@ -2106,6 +2104,7 @@ static irqreturn_t cq_interrupt_v2_hw(int irq_no, void *p)
 	}
 
 	/* update rd_point */
+	cq->rd_point = rd_point;
 	hisi_sas_write32(hisi_hba, COMPL_Q_0_RD_PTR + (0x14 * queue), rd_point);
 	return IRQ_HANDLED;
 }
-- 
1.9.1

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

* [PATCH 02/15] hisi_sas: save delivery queue write pointer
  2016-09-06 15:36 ` John Garry
@ 2016-09-06 15:36   ` John Garry
  -1 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry

Optimise by saving an avoidable read in the
get_free_slot function.
The delivery queue write pointer will only be
updated by software, so don't bother re-reading
what was already written in the previous call
to start_delivery function.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/hisi_sas/hisi_sas.h       |  7 +++++++
 drivers/scsi/hisi_sas/hisi_sas_main.c  |  5 +++++
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 12 +++++++-----
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c |  9 ++++++---
 4 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index 9410335..72c9852 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -98,6 +98,12 @@ struct hisi_sas_cq {
 	int	id;
 };
 
+struct hisi_sas_dq {
+	struct hisi_hba *hisi_hba;
+	int	wr_point;
+	int	id;
+};
+
 struct hisi_sas_device {
 	enum sas_device_type	dev_type;
 	struct hisi_hba		*hisi_hba;
@@ -194,6 +200,7 @@ struct hisi_hba {
 	struct Scsi_Host *shost;
 
 	struct hisi_sas_cq cq[HISI_SAS_MAX_QUEUES];
+	struct hisi_sas_dq dq[HISI_SAS_MAX_QUEUES];
 	struct hisi_sas_phy phy[HISI_SAS_MAX_PHYS];
 	struct hisi_sas_port port[HISI_SAS_MAX_PHYS];
 
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 85c73d3..5d56576 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -1239,11 +1239,16 @@ static int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost)
 
 	for (i = 0; i < hisi_hba->queue_count; i++) {
 		struct hisi_sas_cq *cq = &hisi_hba->cq[i];
+		struct hisi_sas_dq *dq = &hisi_hba->dq[i];
 
 		/* Completion queue structure */
 		cq->id = i;
 		cq->hisi_hba = hisi_hba;
 
+		/* Delivery queue structure */
+		dq->id = i;
+		dq->hisi_hba = hisi_hba;
+
 		/* Delivery queue */
 		s = sizeof(struct hisi_sas_cmd_hdr) * HISI_SAS_QUEUE_SLOTS;
 		hisi_hba->cmd_hdr[i] = dma_alloc_coherent(dev, s,
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
index 3b31b20..b537464 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
@@ -875,12 +875,13 @@ static int get_wideport_bitmap_v1_hw(struct hisi_hba *hisi_hba, int port_id)
 static int get_free_slot_v1_hw(struct hisi_hba *hisi_hba, int *q, int *s)
 {
 	struct device *dev = &hisi_hba->pdev->dev;
+	struct hisi_sas_dq *dq;
 	u32 r, w;
 	int queue = hisi_hba->queue;
 
 	while (1) {
-		w = hisi_sas_read32_relaxed(hisi_hba,
-				    DLVRY_Q_0_WR_PTR + (queue * 0x14));
+		dq = &hisi_hba->dq[queue];
+		w = dq->wr_point;
 		r = hisi_sas_read32_relaxed(hisi_hba,
 				    DLVRY_Q_0_RD_PTR + (queue * 0x14));
 		if (r == (w+1) % HISI_SAS_QUEUE_SLOTS) {
@@ -903,10 +904,11 @@ static void start_delivery_v1_hw(struct hisi_hba *hisi_hba)
 {
 	int dlvry_queue = hisi_hba->slot_prep->dlvry_queue;
 	int dlvry_queue_slot = hisi_hba->slot_prep->dlvry_queue_slot;
+	struct hisi_sas_dq *dq = &hisi_hba->dq[dlvry_queue];
 
-	hisi_sas_write32(hisi_hba,
-			 DLVRY_Q_0_WR_PTR + (dlvry_queue * 0x14),
-			 ++dlvry_queue_slot % HISI_SAS_QUEUE_SLOTS);
+	dq->wr_point = ++dlvry_queue_slot % HISI_SAS_QUEUE_SLOTS;
+	hisi_sas_write32(hisi_hba, DLVRY_Q_0_WR_PTR + (dlvry_queue * 0x14),
+			 dq->wr_point);
 }
 
 static int prep_prd_sge_v1_hw(struct hisi_hba *hisi_hba,
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index 11006c9..e0c124b 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -1023,12 +1023,13 @@ static int get_wideport_bitmap_v2_hw(struct hisi_hba *hisi_hba, int port_id)
 static int get_free_slot_v2_hw(struct hisi_hba *hisi_hba, int *q, int *s)
 {
 	struct device *dev = &hisi_hba->pdev->dev;
+	struct hisi_sas_dq *dq;
 	u32 r, w;
 	int queue = hisi_hba->queue;
 
 	while (1) {
-		w = hisi_sas_read32_relaxed(hisi_hba,
-					    DLVRY_Q_0_WR_PTR + (queue * 0x14));
+		dq = &hisi_hba->dq[queue];
+		w = dq->wr_point;
 		r = hisi_sas_read32_relaxed(hisi_hba,
 					    DLVRY_Q_0_RD_PTR + (queue * 0x14));
 		if (r == (w+1) % HISI_SAS_QUEUE_SLOTS) {
@@ -1051,9 +1052,11 @@ static void start_delivery_v2_hw(struct hisi_hba *hisi_hba)
 {
 	int dlvry_queue = hisi_hba->slot_prep->dlvry_queue;
 	int dlvry_queue_slot = hisi_hba->slot_prep->dlvry_queue_slot;
+	struct hisi_sas_dq *dq = &hisi_hba->dq[dlvry_queue];
 
+	dq->wr_point = ++dlvry_queue_slot % HISI_SAS_QUEUE_SLOTS;
 	hisi_sas_write32(hisi_hba, DLVRY_Q_0_WR_PTR + (dlvry_queue * 0x14),
-			 ++dlvry_queue_slot % HISI_SAS_QUEUE_SLOTS);
+			 dq->wr_point);
 }
 
 static int prep_prd_sge_v2_hw(struct hisi_hba *hisi_hba,
-- 
1.9.1

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

* [PATCH 02/15] hisi_sas: save delivery queue write pointer
@ 2016-09-06 15:36   ` John Garry
  0 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry

Optimise by saving an avoidable read in the
get_free_slot function.
The delivery queue write pointer will only be
updated by software, so don't bother re-reading
what was already written in the previous call
to start_delivery function.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/hisi_sas/hisi_sas.h       |  7 +++++++
 drivers/scsi/hisi_sas/hisi_sas_main.c  |  5 +++++
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 12 +++++++-----
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c |  9 ++++++---
 4 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index 9410335..72c9852 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -98,6 +98,12 @@ struct hisi_sas_cq {
 	int	id;
 };
 
+struct hisi_sas_dq {
+	struct hisi_hba *hisi_hba;
+	int	wr_point;
+	int	id;
+};
+
 struct hisi_sas_device {
 	enum sas_device_type	dev_type;
 	struct hisi_hba		*hisi_hba;
@@ -194,6 +200,7 @@ struct hisi_hba {
 	struct Scsi_Host *shost;
 
 	struct hisi_sas_cq cq[HISI_SAS_MAX_QUEUES];
+	struct hisi_sas_dq dq[HISI_SAS_MAX_QUEUES];
 	struct hisi_sas_phy phy[HISI_SAS_MAX_PHYS];
 	struct hisi_sas_port port[HISI_SAS_MAX_PHYS];
 
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 85c73d3..5d56576 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -1239,11 +1239,16 @@ static int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost)
 
 	for (i = 0; i < hisi_hba->queue_count; i++) {
 		struct hisi_sas_cq *cq = &hisi_hba->cq[i];
+		struct hisi_sas_dq *dq = &hisi_hba->dq[i];
 
 		/* Completion queue structure */
 		cq->id = i;
 		cq->hisi_hba = hisi_hba;
 
+		/* Delivery queue structure */
+		dq->id = i;
+		dq->hisi_hba = hisi_hba;
+
 		/* Delivery queue */
 		s = sizeof(struct hisi_sas_cmd_hdr) * HISI_SAS_QUEUE_SLOTS;
 		hisi_hba->cmd_hdr[i] = dma_alloc_coherent(dev, s,
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
index 3b31b20..b537464 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
@@ -875,12 +875,13 @@ static int get_wideport_bitmap_v1_hw(struct hisi_hba *hisi_hba, int port_id)
 static int get_free_slot_v1_hw(struct hisi_hba *hisi_hba, int *q, int *s)
 {
 	struct device *dev = &hisi_hba->pdev->dev;
+	struct hisi_sas_dq *dq;
 	u32 r, w;
 	int queue = hisi_hba->queue;
 
 	while (1) {
-		w = hisi_sas_read32_relaxed(hisi_hba,
-				    DLVRY_Q_0_WR_PTR + (queue * 0x14));
+		dq = &hisi_hba->dq[queue];
+		w = dq->wr_point;
 		r = hisi_sas_read32_relaxed(hisi_hba,
 				    DLVRY_Q_0_RD_PTR + (queue * 0x14));
 		if (r == (w+1) % HISI_SAS_QUEUE_SLOTS) {
@@ -903,10 +904,11 @@ static void start_delivery_v1_hw(struct hisi_hba *hisi_hba)
 {
 	int dlvry_queue = hisi_hba->slot_prep->dlvry_queue;
 	int dlvry_queue_slot = hisi_hba->slot_prep->dlvry_queue_slot;
+	struct hisi_sas_dq *dq = &hisi_hba->dq[dlvry_queue];
 
-	hisi_sas_write32(hisi_hba,
-			 DLVRY_Q_0_WR_PTR + (dlvry_queue * 0x14),
-			 ++dlvry_queue_slot % HISI_SAS_QUEUE_SLOTS);
+	dq->wr_point = ++dlvry_queue_slot % HISI_SAS_QUEUE_SLOTS;
+	hisi_sas_write32(hisi_hba, DLVRY_Q_0_WR_PTR + (dlvry_queue * 0x14),
+			 dq->wr_point);
 }
 
 static int prep_prd_sge_v1_hw(struct hisi_hba *hisi_hba,
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index 11006c9..e0c124b 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -1023,12 +1023,13 @@ static int get_wideport_bitmap_v2_hw(struct hisi_hba *hisi_hba, int port_id)
 static int get_free_slot_v2_hw(struct hisi_hba *hisi_hba, int *q, int *s)
 {
 	struct device *dev = &hisi_hba->pdev->dev;
+	struct hisi_sas_dq *dq;
 	u32 r, w;
 	int queue = hisi_hba->queue;
 
 	while (1) {
-		w = hisi_sas_read32_relaxed(hisi_hba,
-					    DLVRY_Q_0_WR_PTR + (queue * 0x14));
+		dq = &hisi_hba->dq[queue];
+		w = dq->wr_point;
 		r = hisi_sas_read32_relaxed(hisi_hba,
 					    DLVRY_Q_0_RD_PTR + (queue * 0x14));
 		if (r == (w+1) % HISI_SAS_QUEUE_SLOTS) {
@@ -1051,9 +1052,11 @@ static void start_delivery_v2_hw(struct hisi_hba *hisi_hba)
 {
 	int dlvry_queue = hisi_hba->slot_prep->dlvry_queue;
 	int dlvry_queue_slot = hisi_hba->slot_prep->dlvry_queue_slot;
+	struct hisi_sas_dq *dq = &hisi_hba->dq[dlvry_queue];
 
+	dq->wr_point = ++dlvry_queue_slot % HISI_SAS_QUEUE_SLOTS;
 	hisi_sas_write32(hisi_hba, DLVRY_Q_0_WR_PTR + (dlvry_queue * 0x14),
-			 ++dlvry_queue_slot % HISI_SAS_QUEUE_SLOTS);
+			 dq->wr_point);
 }
 
 static int prep_prd_sge_v2_hw(struct hisi_hba *hisi_hba,
-- 
1.9.1


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

* [PATCH 03/15] hisi_sas: keep CHL_INT2 masked for v2 HW
  2016-09-06 15:36 ` John Garry
@ 2016-09-06 15:36   ` John Garry
  -1 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry

None of the CHL_INT2 interrupts are serviced
in the channel irq ISR, so leave the interrupt
source masked.
The interrupt mask is initially set in
init_reg_v2_hw().

Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index e0c124b..25e7c58 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -965,14 +965,8 @@ static void start_phys_v2_hw(unsigned long data)
 
 static void phys_init_v2_hw(struct hisi_hba *hisi_hba)
 {
-	int i;
 	struct timer_list *timer = &hisi_hba->timer;
 
-	for (i = 0; i < hisi_hba->n_phy; i++) {
-		hisi_sas_phy_write32(hisi_hba, i, CHL_INT2_MSK, 0x6a);
-		hisi_sas_phy_read32(hisi_hba, i, CHL_INT2_MSK);
-	}
-
 	setup_timer(timer, start_phys_v2_hw, (unsigned long)hisi_hba);
 	mod_timer(timer, jiffies + HZ);
 }
-- 
1.9.1

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

* [PATCH 03/15] hisi_sas: keep CHL_INT2 masked for v2 HW
@ 2016-09-06 15:36   ` John Garry
  0 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry

None of the CHL_INT2 interrupts are serviced
in the channel irq ISR, so leave the interrupt
source masked.
The interrupt mask is initially set in
init_reg_v2_hw().

Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index e0c124b..25e7c58 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -965,14 +965,8 @@ static void start_phys_v2_hw(unsigned long data)
 
 static void phys_init_v2_hw(struct hisi_hba *hisi_hba)
 {
-	int i;
 	struct timer_list *timer = &hisi_hba->timer;
 
-	for (i = 0; i < hisi_hba->n_phy; i++) {
-		hisi_sas_phy_write32(hisi_hba, i, CHL_INT2_MSK, 0x6a);
-		hisi_sas_phy_read32(hisi_hba, i, CHL_INT2_MSK);
-	}
-
 	setup_timer(timer, start_phys_v2_hw, (unsigned long)hisi_hba);
 	mod_timer(timer, jiffies + HZ);
 }
-- 
1.9.1

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

* [PATCH 04/15] hisi_sas: only zero slot memory when reused
  2016-09-06 15:36 ` John Garry
@ 2016-09-06 15:36   ` John Garry
  -1 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry

Currently the slot memory is zeroed when it is
freed and also when it is reused, like in
hisi_sas_task_prep(). Optimise by avoiding the
redundant zeroing in the free.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 5d56576..0e48751 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -97,7 +97,7 @@ void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task,
 	slot->task = NULL;
 	slot->port = NULL;
 	hisi_sas_slot_index_free(hisi_hba, slot->idx);
-	memset(slot, 0, sizeof(*slot));
+	/* slot memory is fully zeroed when it is reused */
 }
 EXPORT_SYMBOL_GPL(hisi_sas_slot_task_free);
 
-- 
1.9.1

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

* [PATCH 04/15] hisi_sas: only zero slot memory when reused
@ 2016-09-06 15:36   ` John Garry
  0 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry

Currently the slot memory is zeroed when it is
freed and also when it is reused, like in
hisi_sas_task_prep(). Optimise by avoiding the
redundant zeroing in the free.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 5d56576..0e48751 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -97,7 +97,7 @@ void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task,
 	slot->task = NULL;
 	slot->port = NULL;
 	hisi_sas_slot_index_free(hisi_hba, slot->idx);
-	memset(slot, 0, sizeof(*slot));
+	/* slot memory is fully zeroed when it is reused */
 }
 EXPORT_SYMBOL_GPL(hisi_sas_slot_task_free);
 
-- 
1.9.1

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

* [PATCH 05/15] hisi_sas: use safe BITS_PER_BYTE for slot tag size calculation
  2016-09-06 15:36 ` John Garry
@ 2016-09-06 15:36   ` John Garry
  -1 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry

The memory calculation for the tags bitmap should use BITS_PER_BYTE
macro instead of coincidental same value of sizeof(unsigned long).

Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 0e48751..dcb17a3 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -1309,7 +1309,7 @@ static int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost)
 	memset(hisi_hba->breakpoint, 0, s);
 
 	hisi_hba->slot_index_count = max_command_entries;
-	s = hisi_hba->slot_index_count / sizeof(unsigned long);
+	s = hisi_hba->slot_index_count / BITS_PER_BYTE;
 	hisi_hba->slot_index_tags = devm_kzalloc(dev, s, GFP_KERNEL);
 	if (!hisi_hba->slot_index_tags)
 		goto err_out;
-- 
1.9.1

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

* [PATCH 05/15] hisi_sas: use safe BITS_PER_BYTE for slot tag size calculation
@ 2016-09-06 15:36   ` John Garry
  0 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry

The memory calculation for the tags bitmap should use BITS_PER_BYTE
macro instead of coincidental same value of sizeof(unsigned long).

Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 0e48751..dcb17a3 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -1309,7 +1309,7 @@ static int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost)
 	memset(hisi_hba->breakpoint, 0, s);
 
 	hisi_hba->slot_index_count = max_command_entries;
-	s = hisi_hba->slot_index_count / sizeof(unsigned long);
+	s = hisi_hba->slot_index_count / BITS_PER_BYTE;
 	hisi_hba->slot_index_tags = devm_kzalloc(dev, s, GFP_KERNEL);
 	if (!hisi_hba->slot_index_tags)
 		goto err_out;
-- 
1.9.1

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

* [PATCH 06/15] hisi_sas: disable dlvry queues once at reset for v2 hw
  2016-09-06 15:36 ` John Garry
@ 2016-09-06 15:36   ` John Garry
  -1 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry

The Delivery queue enable register should only be written
to once at reset for v2 hw.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index 25e7c58..aca2b80 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -685,9 +685,7 @@ static int reset_hw_v2_hw(struct hisi_hba *hisi_hba)
 	else
 		reset_val = 0x7ffff;
 
-	/* Disable all of the DQ */
-	for (i = 0; i < HISI_SAS_MAX_QUEUES; i++)
-		hisi_sas_write32(hisi_hba, DLVRY_QUEUE_ENABLE, 0);
+	hisi_sas_write32(hisi_hba, DLVRY_QUEUE_ENABLE, 0);
 
 	/* Disable all of the PHYs */
 	for (i = 0; i < hisi_hba->n_phy; i++) {
-- 
1.9.1

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

* [PATCH 06/15] hisi_sas: disable dlvry queues once at reset for v2 hw
@ 2016-09-06 15:36   ` John Garry
  0 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry

The Delivery queue enable register should only be written
to once at reset for v2 hw.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index 25e7c58..aca2b80 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -685,9 +685,7 @@ static int reset_hw_v2_hw(struct hisi_hba *hisi_hba)
 	else
 		reset_val = 0x7ffff;
 
-	/* Disable all of the DQ */
-	for (i = 0; i < HISI_SAS_MAX_QUEUES; i++)
-		hisi_sas_write32(hisi_hba, DLVRY_QUEUE_ENABLE, 0);
+	hisi_sas_write32(hisi_hba, DLVRY_QUEUE_ENABLE, 0);
 
 	/* Disable all of the PHYs */
 	for (i = 0; i < hisi_hba->n_phy; i++) {
-- 
1.9.1

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

* [PATCH 07/15] hisi_sas: fix phy8 linkrate calculation in phy_up_v2_hw()
  2016-09-06 15:36 ` John Garry
@ 2016-09-06 15:36   ` John Garry
  -1 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry, Xiang Chen

In function phy_up_v2_hw(), we needlessly recalculate the
phy linkrate for all phys, and the calculation is incorrect
for phy8, so remove this code.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index aca2b80..ae44443 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -1876,9 +1876,6 @@ static int phy_up_v2_hw(int phy_no, struct hisi_hba *hisi_hba)
 		frame_rcvd[i] = __swab32(idaf);
 	}
 
-	/* Get the linkrates */
-	link_rate = hisi_sas_read32(hisi_hba, PHY_CONN_RATE);
-	link_rate = (link_rate >> (phy_no * 4)) & 0xf;
 	sas_phy->linkrate = link_rate;
 	hard_phy_linkrate = hisi_sas_phy_read32(hisi_hba, phy_no,
 						HARD_PHY_LINKRATE);
-- 
1.9.1

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

* [PATCH 07/15] hisi_sas: fix phy8 linkrate calculation in phy_up_v2_hw()
@ 2016-09-06 15:36   ` John Garry
  0 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry, Xiang Chen

In function phy_up_v2_hw(), we needlessly recalculate the
phy linkrate for all phys, and the calculation is incorrect
for phy8, so remove this code.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index aca2b80..ae44443 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -1876,9 +1876,6 @@ static int phy_up_v2_hw(int phy_no, struct hisi_hba *hisi_hba)
 		frame_rcvd[i] = __swab32(idaf);
 	}
 
-	/* Get the linkrates */
-	link_rate = hisi_sas_read32(hisi_hba, PHY_CONN_RATE);
-	link_rate = (link_rate >> (phy_no * 4)) & 0xf;
 	sas_phy->linkrate = link_rate;
 	hard_phy_linkrate = hisi_sas_phy_read32(hisi_hba, phy_no,
 						HARD_PHY_LINKRATE);
-- 
1.9.1


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

* [PATCH 08/15] hisi_sas: fix a potential warning for sata disk ejection
  2016-09-06 15:36 ` John Garry
@ 2016-09-06 15:36   ` John Garry
  -1 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry, Xiang Chen

If hisi_sas_task_prep() fails for a SATA device due to PHY
down, we return a failure to libata and also call task_done(),
which will cause ata_qc_complete() to be called twice:
- first call from hisi_sas_task_prep(), which will clear flag
  ATA_QCFLAG_ACTIVE
- ata_qc_complete() called from libata
The warning call trace is as follows:

[  117.070206] [<ffff0000084f59b0>] __ata_qc_complete+0xf4/0x11c
[  117.070208] [<ffff0000084f5b58>] ata_qc_complete+0x180/0x200
[  117.070210] [<ffff0000084f5dd0>] ata_qc_issue+0x110/0x354
[  117.070212] [<ffff0000084f6254>] ata_exec_internal_sg+0x240/0x4d0
[  117.070214] [<ffff0000084f6544>] ata_exec_internal+0x60/0xa0
[  117.070217] [<ffff000008501580>] ata_read_log_page+0x188/0x1b4
[  117.070218] [<ffff0000085017dc>] ata_eh_analyze_ncq_error+0xa8/0x274
[  117.070220] [<ffff000008501a3c>] ata_eh_link_autopsy+0x94/0x8c8
[  117.070222] [<ffff0000085022a4>] ata_eh_autopsy+0x34/0xe8
[  117.070223] [<ffff00000850540c>] ata_do_eh+0x28/0xc0
[  117.070225] [<ffff0000085054e0>] ata_std_error_handler+0x3c/0x84
[  117.070227] [<ffff000008505140>] ata_scsi_port_error_handler+0x480/0x674
[  117.070230] [<ffff0000084e3020>] async_sas_ata_eh+0x44/0x78
[  117.070231] [<ffff0000080d6b8c>] async_run_entry_fn+0x40/0x104
[  117.070234] [<ffff0000080ce518>] process_one_work+0x128/0x2f0
[  117.070235] [<ffff0000080ce738>] worker_thread+0x58/0x434
[  117.070237] [<ffff0000080d416c>] kthread+0xd4/0xe8
[  117.070240] [<ffff000008084e10>] ret_from_fork+0x10/0x40

The issue is resolved by simply returning a failure status
code to the upper layer.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/hisi_sas/hisi_sas_main.c | 26 ++++++--------------------
 1 file changed, 6 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index dcb17a3..d58e223 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -205,26 +205,12 @@ static int hisi_sas_task_prep(struct sas_task *task, struct hisi_hba *hisi_hba,
 	}
 	port = device->port->lldd_port;
 	if (port && !port->port_attached) {
-		if (sas_protocol_ata(task->task_proto)) {
-			struct task_status_struct *ts = &task->task_status;
-
-			dev_info(dev,
-				 "task prep: SATA/STP port%d not attach device\n",
-				 device->port->id);
-			ts->resp = SAS_TASK_COMPLETE;
-			ts->stat = SAS_PHY_DOWN;
-			task->task_done(task);
-		} else {
-			struct task_status_struct *ts = &task->task_status;
-
-			dev_info(dev,
-				 "task prep: SAS port%d does not attach device\n",
-				 device->port->id);
-			ts->resp = SAS_TASK_UNDELIVERED;
-			ts->stat = SAS_PHY_DOWN;
-			task->task_done(task);
-		}
-		return 0;
+		dev_info(dev, "task prep: %s port%d not attach device\n",
+			 (sas_protocol_ata(task->task_proto)) ?
+			 "SATA/STP" : "SAS",
+			 device->port->id);
+
+		return SAS_PHY_DOWN;
 	}
 
 	if (!sas_protocol_ata(task->task_proto)) {
-- 
1.9.1

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

* [PATCH 08/15] hisi_sas: fix a potential warning for sata disk ejection
@ 2016-09-06 15:36   ` John Garry
  0 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry, Xiang Chen

If hisi_sas_task_prep() fails for a SATA device due to PHY
down, we return a failure to libata and also call task_done(),
which will cause ata_qc_complete() to be called twice:
- first call from hisi_sas_task_prep(), which will clear flag
  ATA_QCFLAG_ACTIVE
- ata_qc_complete() called from libata
The warning call trace is as follows:

[  117.070206] [<ffff0000084f59b0>] __ata_qc_complete+0xf4/0x11c
[  117.070208] [<ffff0000084f5b58>] ata_qc_complete+0x180/0x200
[  117.070210] [<ffff0000084f5dd0>] ata_qc_issue+0x110/0x354
[  117.070212] [<ffff0000084f6254>] ata_exec_internal_sg+0x240/0x4d0
[  117.070214] [<ffff0000084f6544>] ata_exec_internal+0x60/0xa0
[  117.070217] [<ffff000008501580>] ata_read_log_page+0x188/0x1b4
[  117.070218] [<ffff0000085017dc>] ata_eh_analyze_ncq_error+0xa8/0x274
[  117.070220] [<ffff000008501a3c>] ata_eh_link_autopsy+0x94/0x8c8
[  117.070222] [<ffff0000085022a4>] ata_eh_autopsy+0x34/0xe8
[  117.070223] [<ffff00000850540c>] ata_do_eh+0x28/0xc0
[  117.070225] [<ffff0000085054e0>] ata_std_error_handler+0x3c/0x84
[  117.070227] [<ffff000008505140>] ata_scsi_port_error_handler+0x480/0x674
[  117.070230] [<ffff0000084e3020>] async_sas_ata_eh+0x44/0x78
[  117.070231] [<ffff0000080d6b8c>] async_run_entry_fn+0x40/0x104
[  117.070234] [<ffff0000080ce518>] process_one_work+0x128/0x2f0
[  117.070235] [<ffff0000080ce738>] worker_thread+0x58/0x434
[  117.070237] [<ffff0000080d416c>] kthread+0xd4/0xe8
[  117.070240] [<ffff000008084e10>] ret_from_fork+0x10/0x40

The issue is resolved by simply returning a failure status
code to the upper layer.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/hisi_sas/hisi_sas_main.c | 26 ++++++--------------------
 1 file changed, 6 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index dcb17a3..d58e223 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -205,26 +205,12 @@ static int hisi_sas_task_prep(struct sas_task *task, struct hisi_hba *hisi_hba,
 	}
 	port = device->port->lldd_port;
 	if (port && !port->port_attached) {
-		if (sas_protocol_ata(task->task_proto)) {
-			struct task_status_struct *ts = &task->task_status;
-
-			dev_info(dev,
-				 "task prep: SATA/STP port%d not attach device\n",
-				 device->port->id);
-			ts->resp = SAS_TASK_COMPLETE;
-			ts->stat = SAS_PHY_DOWN;
-			task->task_done(task);
-		} else {
-			struct task_status_struct *ts = &task->task_status;
-
-			dev_info(dev,
-				 "task prep: SAS port%d does not attach device\n",
-				 device->port->id);
-			ts->resp = SAS_TASK_UNDELIVERED;
-			ts->stat = SAS_PHY_DOWN;
-			task->task_done(task);
-		}
-		return 0;
+		dev_info(dev, "task prep: %s port%d not attach device\n",
+			 (sas_protocol_ata(task->task_proto)) ?
+			 "SATA/STP" : "SAS",
+			 device->port->id);
+
+		return SAS_PHY_DOWN;
 	}
 
 	if (!sas_protocol_ata(task->task_proto)) {
-- 
1.9.1


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

* [PATCH 09/15] hisi_sas: set dma mask before allocate DMA memory
  2016-09-06 15:36 ` John Garry
@ 2016-09-06 15:36   ` John Garry
  -1 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry, Xiang Chen

The device DMA mask was being set after the bulk of the
DMA allocations in the driver init, so potentially
DMA allocates fail.
To resolve, relocate before allocating the DMA memory when
initialising the driver.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/hisi_sas/hisi_sas_main.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index d58e223..2f872f7 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -1439,6 +1439,12 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
 				     &hisi_hba->queue_count))
 		goto err_out;
 
+	if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)) &&
+	    dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32))) {
+		dev_err(dev, "No usable DMA addressing method\n");
+		goto err_out;
+	}
+
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	hisi_hba->regs = devm_ioremap_resource(dev, res);
 	if (IS_ERR(hisi_hba->regs))
@@ -1486,13 +1492,6 @@ int hisi_sas_probe(struct platform_device *pdev,
 	hisi_hba = shost_priv(shost);
 	platform_set_drvdata(pdev, sha);
 
-	if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)) &&
-	    dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32))) {
-		dev_err(dev, "No usable DMA addressing method\n");
-		rc = -EIO;
-		goto err_out_ha;
-	}
-
 	phy_nr = port_nr = hisi_hba->n_phy;
 
 	arr_phy = devm_kcalloc(dev, phy_nr, sizeof(void *), GFP_KERNEL);
-- 
1.9.1

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

* [PATCH 09/15] hisi_sas: set dma mask before allocate DMA memory
@ 2016-09-06 15:36   ` John Garry
  0 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry, Xiang Chen

The device DMA mask was being set after the bulk of the
DMA allocations in the driver init, so potentially
DMA allocates fail.
To resolve, relocate before allocating the DMA memory when
initialising the driver.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/hisi_sas/hisi_sas_main.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index d58e223..2f872f7 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -1439,6 +1439,12 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
 				     &hisi_hba->queue_count))
 		goto err_out;
 
+	if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)) &&
+	    dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32))) {
+		dev_err(dev, "No usable DMA addressing method\n");
+		goto err_out;
+	}
+
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	hisi_hba->regs = devm_ioremap_resource(dev, res);
 	if (IS_ERR(hisi_hba->regs))
@@ -1486,13 +1492,6 @@ int hisi_sas_probe(struct platform_device *pdev,
 	hisi_hba = shost_priv(shost);
 	platform_set_drvdata(pdev, sha);
 
-	if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)) &&
-	    dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32))) {
-		dev_err(dev, "No usable DMA addressing method\n");
-		rc = -EIO;
-		goto err_out_ha;
-	}
-
 	phy_nr = port_nr = hisi_hba->n_phy;
 
 	arr_phy = devm_kcalloc(dev, phy_nr, sizeof(void *), GFP_KERNEL);
-- 
1.9.1


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

* [PATCH 10/15] hisi_sas: fix HBA SAS addr endianness for v2 hw
  2016-09-06 15:36 ` John Garry
@ 2016-09-06 15:36   ` John Garry
  -1 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry, Xiang Chen

The endianness for the SAS address in the TX_ID_DWORD
registers is set incorrectly.
We see errors like this in the boot log:
[    7.583284] sas: target proto 0x0 at 50000d1108e7923f:0x1f not handled

This is due to the host SAS addr not matching the PHY SAS
addr in the expander host-attached phy discovery responses.

To fix, we byte swap the SAS addr from BE to LE (which is
the endianness of the SAS controller).

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 8 ++++----
 1 file changed, 4 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 ae44443..ce84211 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -562,13 +562,13 @@ static void config_id_frame_v2_hw(struct hisi_hba *hisi_hba, int phy_no)
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD0,
 			__swab32(identify_buffer[0]));
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD1,
-			identify_buffer[2]);
+			__swab32(identify_buffer[1]));
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD2,
-			identify_buffer[1]);
+			__swab32(identify_buffer[2]));
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD3,
-			identify_buffer[4]);
+			__swab32(identify_buffer[3]));
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD4,
-			identify_buffer[3]);
+			__swab32(identify_buffer[4]));
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD5,
 			__swab32(identify_buffer[5]));
 }
-- 
1.9.1

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

* [PATCH 10/15] hisi_sas: fix HBA SAS addr endianness for v2 hw
@ 2016-09-06 15:36   ` John Garry
  0 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry, Xiang Chen

The endianness for the SAS address in the TX_ID_DWORD
registers is set incorrectly.
We see errors like this in the boot log:
[    7.583284] sas: target proto 0x0 at 50000d1108e7923f:0x1f not handled

This is due to the host SAS addr not matching the PHY SAS
addr in the expander host-attached phy discovery responses.

To fix, we byte swap the SAS addr from BE to LE (which is
the endianness of the SAS controller).

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 8 ++++----
 1 file changed, 4 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 ae44443..ce84211 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -562,13 +562,13 @@ static void config_id_frame_v2_hw(struct hisi_hba *hisi_hba, int phy_no)
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD0,
 			__swab32(identify_buffer[0]));
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD1,
-			identify_buffer[2]);
+			__swab32(identify_buffer[1]));
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD2,
-			identify_buffer[1]);
+			__swab32(identify_buffer[2]));
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD3,
-			identify_buffer[4]);
+			__swab32(identify_buffer[3]));
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD4,
-			identify_buffer[3]);
+			__swab32(identify_buffer[4]));
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD5,
 			__swab32(identify_buffer[5]));
 }
-- 
1.9.1

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

* [PATCH 11/15] hisi_sas: fix HBA SAS addr endianness for v1 hw
  2016-09-06 15:36 ` John Garry
@ 2016-09-06 15:36   ` John Garry
  -1 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry, Xiang Chen

The endianness for the SAS address in the TX_ID_DWORD
registers is set incorrectly.
We see errors like this in the boot log for v2 hw (which would
have the same issue as v1 hw):
[    7.583284] sas: target proto 0x0 at 50000d1108e7923f:0x1f not handled

This is due to the host SAS addr not matching the PHY SAS
addr in the expander host-attached phy discovery responses.

To fix, we byte swap the SAS addr from BE to LE (which is
the endianness of the SAS controller).

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
---
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
index b537464..c030df0 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
@@ -490,13 +490,13 @@ static void config_id_frame_v1_hw(struct hisi_hba *hisi_hba, int phy_no)
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD0,
 			__swab32(identify_buffer[0]));
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD1,
-			identify_buffer[2]);
+			__swab32(identify_buffer[1]));
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD2,
-			identify_buffer[1]);
+			__swab32(identify_buffer[2]));
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD3,
-			identify_buffer[4]);
+			__swab32(identify_buffer[3]));
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD4,
-			identify_buffer[3]);
+			__swab32(identify_buffer[4]));
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD5,
 			__swab32(identify_buffer[5]));
 }
-- 
1.9.1

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

* [PATCH 11/15] hisi_sas: fix HBA SAS addr endianness for v1 hw
@ 2016-09-06 15:36   ` John Garry
  0 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry, Xiang Chen

The endianness for the SAS address in the TX_ID_DWORD
registers is set incorrectly.
We see errors like this in the boot log for v2 hw (which would
have the same issue as v1 hw):
[    7.583284] sas: target proto 0x0 at 50000d1108e7923f:0x1f not handled

This is due to the host SAS addr not matching the PHY SAS
addr in the expander host-attached phy discovery responses.

To fix, we byte swap the SAS addr from BE to LE (which is
the endianness of the SAS controller).

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
---
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
index b537464..c030df0 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
@@ -490,13 +490,13 @@ static void config_id_frame_v1_hw(struct hisi_hba *hisi_hba, int phy_no)
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD0,
 			__swab32(identify_buffer[0]));
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD1,
-			identify_buffer[2]);
+			__swab32(identify_buffer[1]));
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD2,
-			identify_buffer[1]);
+			__swab32(identify_buffer[2]));
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD3,
-			identify_buffer[4]);
+			__swab32(identify_buffer[3]));
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD4,
-			identify_buffer[3]);
+			__swab32(identify_buffer[4]));
 	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD5,
 			__swab32(identify_buffer[5]));
 }
-- 
1.9.1


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

* [PATCH 12/15] hisi_sas: remove init_id_frame_v2_hw()
  2016-09-06 15:36 ` John Garry
@ 2016-09-06 15:36   ` John Garry
  -1 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry, Xiang Chen

Function config_id_frame_v2_hw() is called twice for
each PHY during initialisation, which is unneeded.

So remove init_id_frame_v2_hw(), which only calls
config_id_frame_v2_hw().

We will keep the call to config_id_frame_v2_hw()
in start_phy_v2_hw() since it will be used for
PHY reset functions.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index ce84211..5925b93 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -573,14 +573,6 @@ static void config_id_frame_v2_hw(struct hisi_hba *hisi_hba, int phy_no)
 			__swab32(identify_buffer[5]));
 }
 
-static void init_id_frame_v2_hw(struct hisi_hba *hisi_hba)
-{
-	int i;
-
-	for (i = 0; i < hisi_hba->n_phy; i++)
-		config_id_frame_v2_hw(hisi_hba, i);
-}
-
 static void setup_itct_v2_hw(struct hisi_hba *hisi_hba,
 			     struct hisi_sas_device *sas_dev)
 {
@@ -912,8 +904,6 @@ static int hw_init_v2_hw(struct hisi_hba *hisi_hba)
 	msleep(100);
 	init_reg_v2_hw(hisi_hba);
 
-	init_id_frame_v2_hw(hisi_hba);
-
 	return 0;
 }
 
-- 
1.9.1

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

* [PATCH 12/15] hisi_sas: remove init_id_frame_v2_hw()
@ 2016-09-06 15:36   ` John Garry
  0 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry, Xiang Chen

Function config_id_frame_v2_hw() is called twice for
each PHY during initialisation, which is unneeded.

So remove init_id_frame_v2_hw(), which only calls
config_id_frame_v2_hw().

We will keep the call to config_id_frame_v2_hw()
in start_phy_v2_hw() since it will be used for
PHY reset functions.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index ce84211..5925b93 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -573,14 +573,6 @@ static void config_id_frame_v2_hw(struct hisi_hba *hisi_hba, int phy_no)
 			__swab32(identify_buffer[5]));
 }
 
-static void init_id_frame_v2_hw(struct hisi_hba *hisi_hba)
-{
-	int i;
-
-	for (i = 0; i < hisi_hba->n_phy; i++)
-		config_id_frame_v2_hw(hisi_hba, i);
-}
-
 static void setup_itct_v2_hw(struct hisi_hba *hisi_hba,
 			     struct hisi_sas_device *sas_dev)
 {
@@ -912,8 +904,6 @@ static int hw_init_v2_hw(struct hisi_hba *hisi_hba)
 	msleep(100);
 	init_reg_v2_hw(hisi_hba);
 
-	init_id_frame_v2_hw(hisi_hba);
-
 	return 0;
 }
 
-- 
1.9.1

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

* [PATCH 13/15] hisi_sas: remove init_id_frame_v1_hw()
  2016-09-06 15:36 ` John Garry
@ 2016-09-06 15:36   ` John Garry
  -1 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry, Xiang Chen

Function config_id_frame_v1_hw() is called twice for
each PHY during initialisation, which is unneeded.

So remove init_id_frame_v1_hw(), which only calls
config_id_frame_v1_hw().

We will keep the call to config_id_frame_v1_hw()
in start_phy_v1_hw() since it will be used for
PHY reset functions.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
---
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
index c030df0..c0ac49d 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
@@ -501,14 +501,6 @@ static void config_id_frame_v1_hw(struct hisi_hba *hisi_hba, int phy_no)
 			__swab32(identify_buffer[5]));
 }
 
-static void init_id_frame_v1_hw(struct hisi_hba *hisi_hba)
-{
-	int i;
-
-	for (i = 0; i < hisi_hba->n_phy; i++)
-		config_id_frame_v1_hw(hisi_hba, i);
-}
-
 static void setup_itct_v1_hw(struct hisi_hba *hisi_hba,
 			     struct hisi_sas_device *sas_dev)
 {
@@ -774,8 +766,6 @@ static int hw_init_v1_hw(struct hisi_hba *hisi_hba)
 	msleep(100);
 	init_reg_v1_hw(hisi_hba);
 
-	init_id_frame_v1_hw(hisi_hba);
-
 	return 0;
 }
 
-- 
1.9.1

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

* [PATCH 13/15] hisi_sas: remove init_id_frame_v1_hw()
@ 2016-09-06 15:36   ` John Garry
  0 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry, Xiang Chen

Function config_id_frame_v1_hw() is called twice for
each PHY during initialisation, which is unneeded.

So remove init_id_frame_v1_hw(), which only calls
config_id_frame_v1_hw().

We will keep the call to config_id_frame_v1_hw()
in start_phy_v1_hw() since it will be used for
PHY reset functions.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
---
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
index c030df0..c0ac49d 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
@@ -501,14 +501,6 @@ static void config_id_frame_v1_hw(struct hisi_hba *hisi_hba, int phy_no)
 			__swab32(identify_buffer[5]));
 }
 
-static void init_id_frame_v1_hw(struct hisi_hba *hisi_hba)
-{
-	int i;
-
-	for (i = 0; i < hisi_hba->n_phy; i++)
-		config_id_frame_v1_hw(hisi_hba, i);
-}
-
 static void setup_itct_v1_hw(struct hisi_hba *hisi_hba,
 			     struct hisi_sas_device *sas_dev)
 {
@@ -774,8 +766,6 @@ static int hw_init_v1_hw(struct hisi_hba *hisi_hba)
 	msleep(100);
 	init_reg_v1_hw(hisi_hba);
 
-	init_id_frame_v1_hw(hisi_hba);
-
 	return 0;
 }
 
-- 
1.9.1

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

* [PATCH 14/15] hisi_sas: add missing SATA pending device type to v2 hw
  2016-09-06 15:36 ` John Garry
@ 2016-09-06 15:36   ` John Garry
  -1 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry, Xiang Chen

In setup_itct_v2_hw(), SATA device type SAS_SATA_PENDING
is missing, so add it.

Note: The HiSi SAS controller does not support SATA PM,
      so do not handle SAS_SATA_PM_PORT or SAS_SATA_PM.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index 5925b93..735ebff 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -594,6 +594,7 @@ static void setup_itct_v2_hw(struct hisi_hba *hisi_hba,
 		qw0 = HISI_SAS_DEV_TYPE_SSP << ITCT_HDR_DEV_TYPE_OFF;
 		break;
 	case SAS_SATA_DEV:
+	case SAS_SATA_PENDING:
 		if (parent_dev && DEV_IS_EXPANDER(parent_dev->dev_type))
 			qw0 = HISI_SAS_DEV_TYPE_STP << ITCT_HDR_DEV_TYPE_OFF;
 		else
-- 
1.9.1

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

* [PATCH 14/15] hisi_sas: add missing SATA pending device type to v2 hw
@ 2016-09-06 15:36   ` John Garry
  0 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry, Xiang Chen

In setup_itct_v2_hw(), SATA device type SAS_SATA_PENDING
is missing, so add it.

Note: The HiSi SAS controller does not support SATA PM,
      so do not handle SAS_SATA_PM_PORT or SAS_SATA_PM.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index 5925b93..735ebff 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -594,6 +594,7 @@ static void setup_itct_v2_hw(struct hisi_hba *hisi_hba,
 		qw0 = HISI_SAS_DEV_TYPE_SSP << ITCT_HDR_DEV_TYPE_OFF;
 		break;
 	case SAS_SATA_DEV:
+	case SAS_SATA_PENDING:
 		if (parent_dev && DEV_IS_EXPANDER(parent_dev->dev_type))
 			qw0 = HISI_SAS_DEV_TYPE_STP << ITCT_HDR_DEV_TYPE_OFF;
 		else
-- 
1.9.1

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

* [PATCH 15/15] hisi_sas: send three identify before phy up
  2016-09-06 15:36 ` John Garry
@ 2016-09-06 15:36   ` John Garry
  -1 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry, NengLong Zhao

When the v2 hw is attached with many disks through
an expander, there may be OOB reset resulting in a PHY
going down after the speed is negotiated (very low
probability).

This issue is resolved by modifying the link control
registers to send three identify frames before the PHY
is ready (according to 6.10.3.3.2 in SAS 3.0 spec) and
close ready when the PHY is down.

Signed-off-by: NengLong Zhao <zhaonenglong@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 20 ++++++++++++++++----
 1 file changed, 16 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 735ebff..9825a3f 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -117,6 +117,8 @@
 #define SL_CONTROL			(PORT_BASE + 0x94)
 #define SL_CONTROL_NOTIFY_EN_OFF	0
 #define SL_CONTROL_NOTIFY_EN_MSK	(0x1 << SL_CONTROL_NOTIFY_EN_OFF)
+#define SL_CONTROL_CTA_OFF		17
+#define SL_CONTROL_CTA_MSK		(0x1 << SL_CONTROL_CTA_OFF)
 #define TX_ID_DWORD0			(PORT_BASE + 0x9c)
 #define TX_ID_DWORD1			(PORT_BASE + 0xa0)
 #define TX_ID_DWORD2			(PORT_BASE + 0xa4)
@@ -124,6 +126,9 @@
 #define TX_ID_DWORD4			(PORT_BASE + 0xaC)
 #define TX_ID_DWORD5			(PORT_BASE + 0xb0)
 #define TX_ID_DWORD6			(PORT_BASE + 0xb4)
+#define TXID_AUTO			(PORT_BASE + 0xb8)
+#define TXID_AUTO_CT3_OFF		1
+#define TXID_AUTO_CT3_MSK		(0x1 << TXID_AUTO_CT3_OFF)
 #define RX_IDAF_DWORD0			(PORT_BASE + 0xc4)
 #define RX_IDAF_DWORD1			(PORT_BASE + 0xc8)
 #define RX_IDAF_DWORD2			(PORT_BASE + 0xcc)
@@ -814,6 +819,8 @@ static void init_reg_v2_hw(struct hisi_hba *hisi_hba)
 		hisi_sas_phy_write32(hisi_hba, i, PROG_PHY_LINK_RATE, 0x855);
 		hisi_sas_phy_write32(hisi_hba, i, SAS_PHY_CTRL, 0x30b9908);
 		hisi_sas_phy_write32(hisi_hba, i, SL_TOUT_CFG, 0x7d7d7d7d);
+		hisi_sas_phy_write32(hisi_hba, i, SL_CONTROL, 0x0);
+		hisi_sas_phy_write32(hisi_hba, i, TXID_AUTO, 0x2);
 		hisi_sas_phy_write32(hisi_hba, i, DONE_RECEIVED_TIME, 0x10);
 		hisi_sas_phy_write32(hisi_hba, i, CHL_INT0, 0xffffffff);
 		hisi_sas_phy_write32(hisi_hba, i, CHL_INT1, 0xffffffff);
@@ -1901,16 +1908,21 @@ end:
 static int phy_down_v2_hw(int phy_no, struct hisi_hba *hisi_hba)
 {
 	int res = 0;
-	u32 phy_cfg, phy_state;
+	u32 phy_state, sl_ctrl, txid_auto;
 
 	hisi_sas_phy_write32(hisi_hba, phy_no, PHYCTRL_NOT_RDY_MSK, 1);
 
-	phy_cfg = hisi_sas_phy_read32(hisi_hba, phy_no, PHY_CFG);
-
 	phy_state = hisi_sas_read32(hisi_hba, PHY_STATE);
-
 	hisi_sas_phy_down(hisi_hba, phy_no, (phy_state & 1 << phy_no) ? 1 : 0);
 
+	sl_ctrl = hisi_sas_phy_read32(hisi_hba, phy_no, SL_CONTROL);
+	hisi_sas_phy_write32(hisi_hba, phy_no, SL_CONTROL,
+			     sl_ctrl & ~SL_CONTROL_CTA_MSK);
+
+	txid_auto = hisi_sas_phy_read32(hisi_hba, phy_no, TXID_AUTO);
+	hisi_sas_phy_write32(hisi_hba, phy_no, TXID_AUTO,
+			     txid_auto | TXID_AUTO_CT3_MSK);
+
 	hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0, CHL_INT0_NOT_RDY_MSK);
 	hisi_sas_phy_write32(hisi_hba, phy_no, PHYCTRL_NOT_RDY_MSK, 0);
 
-- 
1.9.1

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

* [PATCH 15/15] hisi_sas: send three identify before phy up
@ 2016-09-06 15:36   ` John Garry
  0 siblings, 0 replies; 49+ messages in thread
From: John Garry @ 2016-09-06 15:36 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, John Garry, NengLong Zhao

When the v2 hw is attached with many disks through
an expander, there may be OOB reset resulting in a PHY
going down after the speed is negotiated (very low
probability).

This issue is resolved by modifying the link control
registers to send three identify frames before the PHY
is ready (according to 6.10.3.3.2 in SAS 3.0 spec) and
close ready when the PHY is down.

Signed-off-by: NengLong Zhao <zhaonenglong@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 20 ++++++++++++++++----
 1 file changed, 16 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 735ebff..9825a3f 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -117,6 +117,8 @@
 #define SL_CONTROL			(PORT_BASE + 0x94)
 #define SL_CONTROL_NOTIFY_EN_OFF	0
 #define SL_CONTROL_NOTIFY_EN_MSK	(0x1 << SL_CONTROL_NOTIFY_EN_OFF)
+#define SL_CONTROL_CTA_OFF		17
+#define SL_CONTROL_CTA_MSK		(0x1 << SL_CONTROL_CTA_OFF)
 #define TX_ID_DWORD0			(PORT_BASE + 0x9c)
 #define TX_ID_DWORD1			(PORT_BASE + 0xa0)
 #define TX_ID_DWORD2			(PORT_BASE + 0xa4)
@@ -124,6 +126,9 @@
 #define TX_ID_DWORD4			(PORT_BASE + 0xaC)
 #define TX_ID_DWORD5			(PORT_BASE + 0xb0)
 #define TX_ID_DWORD6			(PORT_BASE + 0xb4)
+#define TXID_AUTO			(PORT_BASE + 0xb8)
+#define TXID_AUTO_CT3_OFF		1
+#define TXID_AUTO_CT3_MSK		(0x1 << TXID_AUTO_CT3_OFF)
 #define RX_IDAF_DWORD0			(PORT_BASE + 0xc4)
 #define RX_IDAF_DWORD1			(PORT_BASE + 0xc8)
 #define RX_IDAF_DWORD2			(PORT_BASE + 0xcc)
@@ -814,6 +819,8 @@ static void init_reg_v2_hw(struct hisi_hba *hisi_hba)
 		hisi_sas_phy_write32(hisi_hba, i, PROG_PHY_LINK_RATE, 0x855);
 		hisi_sas_phy_write32(hisi_hba, i, SAS_PHY_CTRL, 0x30b9908);
 		hisi_sas_phy_write32(hisi_hba, i, SL_TOUT_CFG, 0x7d7d7d7d);
+		hisi_sas_phy_write32(hisi_hba, i, SL_CONTROL, 0x0);
+		hisi_sas_phy_write32(hisi_hba, i, TXID_AUTO, 0x2);
 		hisi_sas_phy_write32(hisi_hba, i, DONE_RECEIVED_TIME, 0x10);
 		hisi_sas_phy_write32(hisi_hba, i, CHL_INT0, 0xffffffff);
 		hisi_sas_phy_write32(hisi_hba, i, CHL_INT1, 0xffffffff);
@@ -1901,16 +1908,21 @@ end:
 static int phy_down_v2_hw(int phy_no, struct hisi_hba *hisi_hba)
 {
 	int res = 0;
-	u32 phy_cfg, phy_state;
+	u32 phy_state, sl_ctrl, txid_auto;
 
 	hisi_sas_phy_write32(hisi_hba, phy_no, PHYCTRL_NOT_RDY_MSK, 1);
 
-	phy_cfg = hisi_sas_phy_read32(hisi_hba, phy_no, PHY_CFG);
-
 	phy_state = hisi_sas_read32(hisi_hba, PHY_STATE);
-
 	hisi_sas_phy_down(hisi_hba, phy_no, (phy_state & 1 << phy_no) ? 1 : 0);
 
+	sl_ctrl = hisi_sas_phy_read32(hisi_hba, phy_no, SL_CONTROL);
+	hisi_sas_phy_write32(hisi_hba, phy_no, SL_CONTROL,
+			     sl_ctrl & ~SL_CONTROL_CTA_MSK);
+
+	txid_auto = hisi_sas_phy_read32(hisi_hba, phy_no, TXID_AUTO);
+	hisi_sas_phy_write32(hisi_hba, phy_no, TXID_AUTO,
+			     txid_auto | TXID_AUTO_CT3_MSK);
+
 	hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0, CHL_INT0_NOT_RDY_MSK);
 	hisi_sas_phy_write32(hisi_hba, phy_no, PHYCTRL_NOT_RDY_MSK, 0);
 
-- 
1.9.1

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

* Re: [PATCH 01/15] hisi_sas: save completion queue read pointer
  2016-09-06 15:36   ` John Garry
  (?)
@ 2016-09-14 11:46   ` Hannes Reinecke
  -1 siblings, 0 replies; 49+ messages in thread
From: Hannes Reinecke @ 2016-09-14 11:46 UTC (permalink / raw)
  To: John Garry, jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi, linux-kernel

On 09/06/2016 05:36 PM, John Garry wrote:
> Optimise by saving an avoidable read in the cq
> interrupt.
> The queue read pointer will only be updated
> by software, so don't bother re-reading
> what was already written in the previous interrupt.
> 
> Signed-off-by: John Garry <john.garry@huawei.com>
> ---
>  drivers/scsi/hisi_sas/hisi_sas.h       | 1 +
>  drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 6 ++----
>  drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 5 ++---
>  3 files changed, 5 insertions(+), 7 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

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

* Re: [PATCH 02/15] hisi_sas: save delivery queue write pointer
  2016-09-06 15:36   ` John Garry
  (?)
@ 2016-09-14 11:47   ` Hannes Reinecke
  -1 siblings, 0 replies; 49+ messages in thread
From: Hannes Reinecke @ 2016-09-14 11:47 UTC (permalink / raw)
  To: John Garry, jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi, linux-kernel

On 09/06/2016 05:36 PM, John Garry wrote:
> Optimise by saving an avoidable read in the
> get_free_slot function.
> The delivery queue write pointer will only be
> updated by software, so don't bother re-reading
> what was already written in the previous call
> to start_delivery function.
> 
> Signed-off-by: John Garry <john.garry@huawei.com>
> ---
>  drivers/scsi/hisi_sas/hisi_sas.h       |  7 +++++++
>  drivers/scsi/hisi_sas/hisi_sas_main.c  |  5 +++++
>  drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 12 +++++++-----
>  drivers/scsi/hisi_sas/hisi_sas_v2_hw.c |  9 ++++++---
>  4 files changed, 25 insertions(+), 8 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Cheers
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

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

* Re: [PATCH 03/15] hisi_sas: keep CHL_INT2 masked for v2 HW
  2016-09-06 15:36   ` John Garry
  (?)
@ 2016-09-14 11:48   ` Hannes Reinecke
  -1 siblings, 0 replies; 49+ messages in thread
From: Hannes Reinecke @ 2016-09-14 11:48 UTC (permalink / raw)
  To: John Garry, jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi, linux-kernel

On 09/06/2016 05:36 PM, John Garry wrote:
> None of the CHL_INT2 interrupts are serviced
> in the channel irq ISR, so leave the interrupt
> source masked.
> The interrupt mask is initially set in
> init_reg_v2_hw().
> 
> Signed-off-by: John Garry <john.garry@huawei.com>
> ---
>  drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
> index e0c124b..25e7c58 100644
> --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
> +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
> @@ -965,14 +965,8 @@ static void start_phys_v2_hw(unsigned long data)
>  
>  static void phys_init_v2_hw(struct hisi_hba *hisi_hba)
>  {
> -	int i;
>  	struct timer_list *timer = &hisi_hba->timer;
>  
> -	for (i = 0; i < hisi_hba->n_phy; i++) {
> -		hisi_sas_phy_write32(hisi_hba, i, CHL_INT2_MSK, 0x6a);
> -		hisi_sas_phy_read32(hisi_hba, i, CHL_INT2_MSK);
> -	}
> -
>  	setup_timer(timer, start_phys_v2_hw, (unsigned long)hisi_hba);
>  	mod_timer(timer, jiffies + HZ);
>  }
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

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

* Re: [PATCH 04/15] hisi_sas: only zero slot memory when reused
  2016-09-06 15:36   ` John Garry
  (?)
@ 2016-09-14 12:45   ` Hannes Reinecke
  -1 siblings, 0 replies; 49+ messages in thread
From: Hannes Reinecke @ 2016-09-14 12:45 UTC (permalink / raw)
  To: John Garry, jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi, linux-kernel

On 09/06/2016 05:36 PM, John Garry wrote:
> Currently the slot memory is zeroed when it is
> freed and also when it is reused, like in
> hisi_sas_task_prep(). Optimise by avoiding the
> redundant zeroing in the free.
> 
> Signed-off-by: John Garry <john.garry@huawei.com>
> ---
>  drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
> index 5d56576..0e48751 100644
> --- a/drivers/scsi/hisi_sas/hisi_sas_main.c
> +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
> @@ -97,7 +97,7 @@ void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task,
>  	slot->task = NULL;
>  	slot->port = NULL;
>  	hisi_sas_slot_index_free(hisi_hba, slot->idx);
> -	memset(slot, 0, sizeof(*slot));
> +	/* slot memory is fully zeroed when it is reused */
>  }
>  EXPORT_SYMBOL_GPL(hisi_sas_slot_task_free);
>  
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

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

* Re: [PATCH 05/15] hisi_sas: use safe BITS_PER_BYTE for slot tag size calculation
  2016-09-06 15:36   ` John Garry
  (?)
@ 2016-09-14 12:46   ` Hannes Reinecke
  -1 siblings, 0 replies; 49+ messages in thread
From: Hannes Reinecke @ 2016-09-14 12:46 UTC (permalink / raw)
  To: John Garry, jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi, linux-kernel

On 09/06/2016 05:36 PM, John Garry wrote:
> The memory calculation for the tags bitmap should use BITS_PER_BYTE
> macro instead of coincidental same value of sizeof(unsigned long).
> 
> Signed-off-by: John Garry <john.garry@huawei.com>
> ---
>  drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
> index 0e48751..dcb17a3 100644
> --- a/drivers/scsi/hisi_sas/hisi_sas_main.c
> +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
> @@ -1309,7 +1309,7 @@ static int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost)
>  	memset(hisi_hba->breakpoint, 0, s);
>  
>  	hisi_hba->slot_index_count = max_command_entries;
> -	s = hisi_hba->slot_index_count / sizeof(unsigned long);
> +	s = hisi_hba->slot_index_count / BITS_PER_BYTE;
>  	hisi_hba->slot_index_tags = devm_kzalloc(dev, s, GFP_KERNEL);
>  	if (!hisi_hba->slot_index_tags)
>  		goto err_out;
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

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

* Re: [PATCH 06/15] hisi_sas: disable dlvry queues once at reset for v2 hw
  2016-09-06 15:36   ` John Garry
  (?)
@ 2016-09-14 12:46   ` Hannes Reinecke
  -1 siblings, 0 replies; 49+ messages in thread
From: Hannes Reinecke @ 2016-09-14 12:46 UTC (permalink / raw)
  To: John Garry, jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi, linux-kernel

On 09/06/2016 05:36 PM, John Garry wrote:
> The Delivery queue enable register should only be written
> to once at reset for v2 hw.
> 
> Signed-off-by: John Garry <john.garry@huawei.com>
> ---
>  drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
> index 25e7c58..aca2b80 100644
> --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
> +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
> @@ -685,9 +685,7 @@ static int reset_hw_v2_hw(struct hisi_hba *hisi_hba)
>  	else
>  		reset_val = 0x7ffff;
>  
> -	/* Disable all of the DQ */
> -	for (i = 0; i < HISI_SAS_MAX_QUEUES; i++)
> -		hisi_sas_write32(hisi_hba, DLVRY_QUEUE_ENABLE, 0);
> +	hisi_sas_write32(hisi_hba, DLVRY_QUEUE_ENABLE, 0);
>  
>  	/* Disable all of the PHYs */
>  	for (i = 0; i < hisi_hba->n_phy; i++) {
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

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

* Re: [PATCH 07/15] hisi_sas: fix phy8 linkrate calculation in phy_up_v2_hw()
  2016-09-06 15:36   ` John Garry
  (?)
@ 2016-09-14 12:47   ` Hannes Reinecke
  -1 siblings, 0 replies; 49+ messages in thread
From: Hannes Reinecke @ 2016-09-14 12:47 UTC (permalink / raw)
  To: John Garry, jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, Xiang Chen

On 09/06/2016 05:36 PM, John Garry wrote:
> In function phy_up_v2_hw(), we needlessly recalculate the
> phy linkrate for all phys, and the calculation is incorrect
> for phy8, so remove this code.
> 
> Signed-off-by: John Garry <john.garry@huawei.com>
> Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
> ---
>  drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
> index aca2b80..ae44443 100644
> --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
> +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
> @@ -1876,9 +1876,6 @@ static int phy_up_v2_hw(int phy_no, struct hisi_hba *hisi_hba)
>  		frame_rcvd[i] = __swab32(idaf);
>  	}
>  
> -	/* Get the linkrates */
> -	link_rate = hisi_sas_read32(hisi_hba, PHY_CONN_RATE);
> -	link_rate = (link_rate >> (phy_no * 4)) & 0xf;
>  	sas_phy->linkrate = link_rate;
>  	hard_phy_linkrate = hisi_sas_phy_read32(hisi_hba, phy_no,
>  						HARD_PHY_LINKRATE);
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

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

* Re: [PATCH 08/15] hisi_sas: fix a potential warning for sata disk ejection
  2016-09-06 15:36   ` John Garry
  (?)
@ 2016-09-14 12:48   ` Hannes Reinecke
  -1 siblings, 0 replies; 49+ messages in thread
From: Hannes Reinecke @ 2016-09-14 12:48 UTC (permalink / raw)
  To: John Garry, jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, Xiang Chen

On 09/06/2016 05:36 PM, John Garry wrote:
> If hisi_sas_task_prep() fails for a SATA device due to PHY
> down, we return a failure to libata and also call task_done(),
> which will cause ata_qc_complete() to be called twice:
> - first call from hisi_sas_task_prep(), which will clear flag
>   ATA_QCFLAG_ACTIVE
> - ata_qc_complete() called from libata
> The warning call trace is as follows:
> 
> [  117.070206] [<ffff0000084f59b0>] __ata_qc_complete+0xf4/0x11c
> [  117.070208] [<ffff0000084f5b58>] ata_qc_complete+0x180/0x200
> [  117.070210] [<ffff0000084f5dd0>] ata_qc_issue+0x110/0x354
> [  117.070212] [<ffff0000084f6254>] ata_exec_internal_sg+0x240/0x4d0
> [  117.070214] [<ffff0000084f6544>] ata_exec_internal+0x60/0xa0
> [  117.070217] [<ffff000008501580>] ata_read_log_page+0x188/0x1b4
> [  117.070218] [<ffff0000085017dc>] ata_eh_analyze_ncq_error+0xa8/0x274
> [  117.070220] [<ffff000008501a3c>] ata_eh_link_autopsy+0x94/0x8c8
> [  117.070222] [<ffff0000085022a4>] ata_eh_autopsy+0x34/0xe8
> [  117.070223] [<ffff00000850540c>] ata_do_eh+0x28/0xc0
> [  117.070225] [<ffff0000085054e0>] ata_std_error_handler+0x3c/0x84
> [  117.070227] [<ffff000008505140>] ata_scsi_port_error_handler+0x480/0x674
> [  117.070230] [<ffff0000084e3020>] async_sas_ata_eh+0x44/0x78
> [  117.070231] [<ffff0000080d6b8c>] async_run_entry_fn+0x40/0x104
> [  117.070234] [<ffff0000080ce518>] process_one_work+0x128/0x2f0
> [  117.070235] [<ffff0000080ce738>] worker_thread+0x58/0x434
> [  117.070237] [<ffff0000080d416c>] kthread+0xd4/0xe8
> [  117.070240] [<ffff000008084e10>] ret_from_fork+0x10/0x40
> 
> The issue is resolved by simply returning a failure status
> code to the upper layer.
> 
> Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
> Signed-off-by: John Garry <john.garry@huawei.com>
> ---
>  drivers/scsi/hisi_sas/hisi_sas_main.c | 26 ++++++--------------------
>  1 file changed, 6 insertions(+), 20 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

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

* Re: [PATCH 09/15] hisi_sas: set dma mask before allocate DMA memory
  2016-09-06 15:36   ` John Garry
  (?)
@ 2016-09-14 12:48   ` Hannes Reinecke
  -1 siblings, 0 replies; 49+ messages in thread
From: Hannes Reinecke @ 2016-09-14 12:48 UTC (permalink / raw)
  To: John Garry, jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, Xiang Chen

On 09/06/2016 05:36 PM, John Garry wrote:
> The device DMA mask was being set after the bulk of the
> DMA allocations in the driver init, so potentially
> DMA allocates fail.
> To resolve, relocate before allocating the DMA memory when
> initialising the driver.
> 
> Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
> Signed-off-by: John Garry <john.garry@huawei.com>
> ---
>  drivers/scsi/hisi_sas/hisi_sas_main.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

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

* Re: [PATCH 10/15] hisi_sas: fix HBA SAS addr endianness for v2 hw
  2016-09-06 15:36   ` John Garry
  (?)
@ 2016-09-14 12:49   ` Hannes Reinecke
  -1 siblings, 0 replies; 49+ messages in thread
From: Hannes Reinecke @ 2016-09-14 12:49 UTC (permalink / raw)
  To: John Garry, jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, Xiang Chen

On 09/06/2016 05:36 PM, John Garry wrote:
> The endianness for the SAS address in the TX_ID_DWORD
> registers is set incorrectly.
> We see errors like this in the boot log:
> [    7.583284] sas: target proto 0x0 at 50000d1108e7923f:0x1f not handled
> 
> This is due to the host SAS addr not matching the PHY SAS
> addr in the expander host-attached phy discovery responses.
> 
> To fix, we byte swap the SAS addr from BE to LE (which is
> the endianness of the SAS controller).
> 
> Signed-off-by: John Garry <john.garry@huawei.com>
> Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
> ---
>  drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 8 ++++----
>  1 file changed, 4 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 ae44443..ce84211 100644
> --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
> +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
> @@ -562,13 +562,13 @@ static void config_id_frame_v2_hw(struct hisi_hba *hisi_hba, int phy_no)
>  	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD0,
>  			__swab32(identify_buffer[0]));
>  	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD1,
> -			identify_buffer[2]);
> +			__swab32(identify_buffer[1]));
>  	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD2,
> -			identify_buffer[1]);
> +			__swab32(identify_buffer[2]));
>  	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD3,
> -			identify_buffer[4]);
> +			__swab32(identify_buffer[3]));
>  	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD4,
> -			identify_buffer[3]);
> +			__swab32(identify_buffer[4]));
>  	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD5,
>  			__swab32(identify_buffer[5]));
>  }
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

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

* Re: [PATCH 11/15] hisi_sas: fix HBA SAS addr endianness for v1 hw
  2016-09-06 15:36   ` John Garry
  (?)
@ 2016-09-14 12:49   ` Hannes Reinecke
  -1 siblings, 0 replies; 49+ messages in thread
From: Hannes Reinecke @ 2016-09-14 12:49 UTC (permalink / raw)
  To: John Garry, jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, Xiang Chen

On 09/06/2016 05:36 PM, John Garry wrote:
> The endianness for the SAS address in the TX_ID_DWORD
> registers is set incorrectly.
> We see errors like this in the boot log for v2 hw (which would
> have the same issue as v1 hw):
> [    7.583284] sas: target proto 0x0 at 50000d1108e7923f:0x1f not handled
> 
> This is due to the host SAS addr not matching the PHY SAS
> addr in the expander host-attached phy discovery responses.
> 
> To fix, we byte swap the SAS addr from BE to LE (which is
> the endianness of the SAS controller).
> 
> Signed-off-by: John Garry <john.garry@huawei.com>
> Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
> ---
>  drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
> index b537464..c030df0 100644
> --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
> +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
> @@ -490,13 +490,13 @@ static void config_id_frame_v1_hw(struct hisi_hba *hisi_hba, int phy_no)
>  	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD0,
>  			__swab32(identify_buffer[0]));
>  	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD1,
> -			identify_buffer[2]);
> +			__swab32(identify_buffer[1]));
>  	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD2,
> -			identify_buffer[1]);
> +			__swab32(identify_buffer[2]));
>  	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD3,
> -			identify_buffer[4]);
> +			__swab32(identify_buffer[3]));
>  	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD4,
> -			identify_buffer[3]);
> +			__swab32(identify_buffer[4]));
>  	hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD5,
>  			__swab32(identify_buffer[5]));
>  }
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

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

* Re: [PATCH 12/15] hisi_sas: remove init_id_frame_v2_hw()
  2016-09-06 15:36   ` John Garry
  (?)
@ 2016-09-14 12:50   ` Hannes Reinecke
  -1 siblings, 0 replies; 49+ messages in thread
From: Hannes Reinecke @ 2016-09-14 12:50 UTC (permalink / raw)
  To: John Garry, jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, Xiang Chen

On 09/06/2016 05:36 PM, John Garry wrote:
> Function config_id_frame_v2_hw() is called twice for
> each PHY during initialisation, which is unneeded.
> 
> So remove init_id_frame_v2_hw(), which only calls
> config_id_frame_v2_hw().
> 
> We will keep the call to config_id_frame_v2_hw()
> in start_phy_v2_hw() since it will be used for
> PHY reset functions.
> 
> Signed-off-by: John Garry <john.garry@huawei.com>
> Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
> ---
>  drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 10 ----------
>  1 file changed, 10 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

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

* Re: [PATCH 13/15] hisi_sas: remove init_id_frame_v1_hw()
  2016-09-06 15:36   ` John Garry
  (?)
@ 2016-09-14 12:50   ` Hannes Reinecke
  -1 siblings, 0 replies; 49+ messages in thread
From: Hannes Reinecke @ 2016-09-14 12:50 UTC (permalink / raw)
  To: John Garry, jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, Xiang Chen

On 09/06/2016 05:36 PM, John Garry wrote:
> Function config_id_frame_v1_hw() is called twice for
> each PHY during initialisation, which is unneeded.
> 
> So remove init_id_frame_v1_hw(), which only calls
> config_id_frame_v1_hw().
> 
> We will keep the call to config_id_frame_v1_hw()
> in start_phy_v1_hw() since it will be used for
> PHY reset functions.
> 
> Signed-off-by: John Garry <john.garry@huawei.com>
> Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
> ---
>  drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 10 ----------
>  1 file changed, 10 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

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

* Re: [PATCH 14/15] hisi_sas: add missing SATA pending device type to v2 hw
  2016-09-06 15:36   ` John Garry
  (?)
@ 2016-09-14 12:51   ` Hannes Reinecke
  -1 siblings, 0 replies; 49+ messages in thread
From: Hannes Reinecke @ 2016-09-14 12:51 UTC (permalink / raw)
  To: John Garry, jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, Xiang Chen

On 09/06/2016 05:36 PM, John Garry wrote:
> In setup_itct_v2_hw(), SATA device type SAS_SATA_PENDING
> is missing, so add it.
> 
> Note: The HiSi SAS controller does not support SATA PM,
>       so do not handle SAS_SATA_PM_PORT or SAS_SATA_PM.
> 
> Signed-off-by: John Garry <john.garry@huawei.com>
> Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
> ---
>  drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
> index 5925b93..735ebff 100644
> --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
> +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
> @@ -594,6 +594,7 @@ static void setup_itct_v2_hw(struct hisi_hba *hisi_hba,
>  		qw0 = HISI_SAS_DEV_TYPE_SSP << ITCT_HDR_DEV_TYPE_OFF;
>  		break;
>  	case SAS_SATA_DEV:
> +	case SAS_SATA_PENDING:
>  		if (parent_dev && DEV_IS_EXPANDER(parent_dev->dev_type))
>  			qw0 = HISI_SAS_DEV_TYPE_STP << ITCT_HDR_DEV_TYPE_OFF;
>  		else
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

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

* Re: [PATCH 15/15] hisi_sas: send three identify before phy up
  2016-09-06 15:36   ` John Garry
  (?)
@ 2016-09-14 12:52   ` Hannes Reinecke
  -1 siblings, 0 replies; 49+ messages in thread
From: Hannes Reinecke @ 2016-09-14 12:52 UTC (permalink / raw)
  To: John Garry, jejb, martin.petersen
  Cc: linuxarm, zhangfei.gao, xuwei5, john.garry2, linux-scsi,
	linux-kernel, NengLong Zhao

On 09/06/2016 05:36 PM, John Garry wrote:
> When the v2 hw is attached with many disks through
> an expander, there may be OOB reset resulting in a PHY
> going down after the speed is negotiated (very low
> probability).
> 
> This issue is resolved by modifying the link control
> registers to send three identify frames before the PHY
> is ready (according to 6.10.3.3.2 in SAS 3.0 spec) and
> close ready when the PHY is down.
> 
> Signed-off-by: NengLong Zhao <zhaonenglong@hisilicon.com>
> Signed-off-by: John Garry <john.garry@huawei.com>
> ---
>  drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

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

* Re: [PATCH 00/15] hisi_sas misc fixes and minor optimisations
  2016-09-06 15:36 ` John Garry
@ 2016-09-14 16:54   ` Martin K. Petersen
  -1 siblings, 0 replies; 49+ messages in thread
From: Martin K. Petersen @ 2016-09-14 16:54 UTC (permalink / raw)
  To: John Garry
  Cc: jejb, martin.petersen, linuxarm, zhangfei.gao, xuwei5,
	john.garry2, linux-scsi, linux-kernel

>>>>> "John" == John Garry <john.garry@huawei.com> writes:

John> This patchset introdcues some minor bug fixes and optimisations
John> for v1+v2 hw.

John> No new functional features are introduced in this patchset.

Applied to 4.9/scsi-queue.

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH 00/15] hisi_sas misc fixes and minor optimisations
@ 2016-09-14 16:54   ` Martin K. Petersen
  0 siblings, 0 replies; 49+ messages in thread
From: Martin K. Petersen @ 2016-09-14 16:54 UTC (permalink / raw)
  To: John Garry
  Cc: jejb, martin.petersen, linuxarm, zhangfei.gao, xuwei5,
	john.garry2, linux-scsi, linux-kernel

>>>>> "John" == John Garry <john.garry@huawei.com> writes:

John> This patchset introdcues some minor bug fixes and optimisations
John> for v1+v2 hw.

John> No new functional features are introduced in this patchset.

Applied to 4.9/scsi-queue.

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2016-09-14 16:55 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-06 15:36 [PATCH 00/15] hisi_sas misc fixes and minor optimisations John Garry
2016-09-06 15:36 ` John Garry
2016-09-06 15:36 ` [PATCH 01/15] hisi_sas: save completion queue read pointer John Garry
2016-09-06 15:36   ` John Garry
2016-09-14 11:46   ` Hannes Reinecke
2016-09-06 15:36 ` [PATCH 02/15] hisi_sas: save delivery queue write pointer John Garry
2016-09-06 15:36   ` John Garry
2016-09-14 11:47   ` Hannes Reinecke
2016-09-06 15:36 ` [PATCH 03/15] hisi_sas: keep CHL_INT2 masked for v2 HW John Garry
2016-09-06 15:36   ` John Garry
2016-09-14 11:48   ` Hannes Reinecke
2016-09-06 15:36 ` [PATCH 04/15] hisi_sas: only zero slot memory when reused John Garry
2016-09-06 15:36   ` John Garry
2016-09-14 12:45   ` Hannes Reinecke
2016-09-06 15:36 ` [PATCH 05/15] hisi_sas: use safe BITS_PER_BYTE for slot tag size calculation John Garry
2016-09-06 15:36   ` John Garry
2016-09-14 12:46   ` Hannes Reinecke
2016-09-06 15:36 ` [PATCH 06/15] hisi_sas: disable dlvry queues once at reset for v2 hw John Garry
2016-09-06 15:36   ` John Garry
2016-09-14 12:46   ` Hannes Reinecke
2016-09-06 15:36 ` [PATCH 07/15] hisi_sas: fix phy8 linkrate calculation in phy_up_v2_hw() John Garry
2016-09-06 15:36   ` John Garry
2016-09-14 12:47   ` Hannes Reinecke
2016-09-06 15:36 ` [PATCH 08/15] hisi_sas: fix a potential warning for sata disk ejection John Garry
2016-09-06 15:36   ` John Garry
2016-09-14 12:48   ` Hannes Reinecke
2016-09-06 15:36 ` [PATCH 09/15] hisi_sas: set dma mask before allocate DMA memory John Garry
2016-09-06 15:36   ` John Garry
2016-09-14 12:48   ` Hannes Reinecke
2016-09-06 15:36 ` [PATCH 10/15] hisi_sas: fix HBA SAS addr endianness for v2 hw John Garry
2016-09-06 15:36   ` John Garry
2016-09-14 12:49   ` Hannes Reinecke
2016-09-06 15:36 ` [PATCH 11/15] hisi_sas: fix HBA SAS addr endianness for v1 hw John Garry
2016-09-06 15:36   ` John Garry
2016-09-14 12:49   ` Hannes Reinecke
2016-09-06 15:36 ` [PATCH 12/15] hisi_sas: remove init_id_frame_v2_hw() John Garry
2016-09-06 15:36   ` John Garry
2016-09-14 12:50   ` Hannes Reinecke
2016-09-06 15:36 ` [PATCH 13/15] hisi_sas: remove init_id_frame_v1_hw() John Garry
2016-09-06 15:36   ` John Garry
2016-09-14 12:50   ` Hannes Reinecke
2016-09-06 15:36 ` [PATCH 14/15] hisi_sas: add missing SATA pending device type to v2 hw John Garry
2016-09-06 15:36   ` John Garry
2016-09-14 12:51   ` Hannes Reinecke
2016-09-06 15:36 ` [PATCH 15/15] hisi_sas: send three identify before phy up John Garry
2016-09-06 15:36   ` John Garry
2016-09-14 12:52   ` Hannes Reinecke
2016-09-14 16:54 ` [PATCH 00/15] hisi_sas misc fixes and minor optimisations Martin K. Petersen
2016-09-14 16:54   ` Martin K. Petersen

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.