hisi_sas misc fixes and minor optimisations
Subsystems (2)
cover hisi_sas misc fixes and minor optimisations
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(-)
Signature · 1 line
1.9.1
PATCH 1/15 hisi_sas: save completion queue read pointer
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.
--- 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(-)
drivers/scsi/hisi_sas/hisi_sas.h +1 -0
@@ -94,6 +94,7 @@ struct hisi_sas_port {struct hisi_sas_cq {struct hisi_hba *hisi_hba; +int rd_point;int id; };
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +2 -4
@@ -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 ;
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +2 -3
@@ -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 ; }
Signature · 1 line
1.9.1
Re: [PATCH 01/15] hisi_sas: save completion queue read pointer
Quoted 6 lines · 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.
Quoted 7 lines
Signed-off-by John Garry <[email protected]>--- 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(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
PATCH 2/15 hisi_sas: save delivery queue write pointer
In reply to John GarryOptimise by saving an avoidable read in theget_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.
--- 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(-)
drivers/scsi/hisi_sas/hisi_sas.h +7 -0
@@ -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 ];
drivers/scsi/hisi_sas/hisi_sas_main.c +5 -0
@@ -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,
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +7 -5
@@ -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,
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +6 -3
@@ -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,
Signature · 1 line
1.9.1
Re: [PATCH 02/15] hisi_sas: save delivery queue write pointer
Quoted 7 lines · John Garry
Optimise by saving an avoidable read in the
get_free_slotfunction.
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
tostart_deliveryfunction.
Quoted 8 lines
Signed-off-by John Garry <[email protected]>--- 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(-)
Cheers,
Cheers
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
PATCH 3/15 hisi_sas: keep CHL_INT2 masked for v2 HW
In reply to John GarryNone of the CHL_INT2 interrupts are serviced
in the channel irq ISR, so leave the interrupt
source masked.
The interrupt mask is initially set ininit_reg_v2_hw().
--- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +0 -6
@@ -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 ); }
Signature · 1 line
1.9.1
Re: [PATCH 03/15] hisi_sas: keep CHL_INT2 masked for v2 HW
Quoted 21 lines · John Garry
None of the
CHL_INT2interrupts are serviced
in the channel irq ISR, so leave the interrupt
source masked.
The interrupt mask is initially set ininit_reg_v2_hw().Signed-off-by John Garry <[email protected]>--- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 6 ------ 1 file changed, 6 deletions(-)drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +0
-1@@ -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;
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c static void start_phys_v2_hw(unsigned long data) · line 972
Quoted 10 lines
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +0
-5struct 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 ); }
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
PATCH 4/15 hisi_sas: only zero slot memory when reused
In reply to John GarryCurrently 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.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +1 -1
@@ -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);
Signature · 1 line
1.9.1
Re: [PATCH 04/15] hisi_sas: only zero slot memory when reused
Quoted 16 lines · 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 <[email protected]>--- drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/hisi_sas/hisi_sas_main.c +0
-0
drivers/scsi/hisi_sas/hisi_sas_main.c void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task, · line 103
Quoted 8 lines
drivers/scsi/hisi_sas/hisi_sas_main.c +1
-1@@ -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);
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
PATCH 5/15 hisi_sas: use safe BITS_PER_BYTE for slot tag size calculation
In reply to John GarryThe memory calculation for the tags bitmap should use BITS_PER_BYTE macro instead of coincidental same value of sizeof(unsigned long).
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +1 -1
@@ -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;
Signature · 1 line
1.9.1
Re: [PATCH 05/15] hisi_sas: use safe BITS_PER_BYTE for slot tag size calculation
Quoted 14 lines · John Garry
The memory calculation for the tags bitmap should use
BITS_PER_BYTEmacro instead of coincidental same value of sizeof(unsigned long).Signed-off-by John Garry <[email protected]>--- drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/hisi_sas/hisi_sas_main.c +0
-0
drivers/scsi/hisi_sas/hisi_sas_main.c static int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost) · line 1315
Quoted 8 lines
drivers/scsi/hisi_sas/hisi_sas_main.c +1
-1@@ -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;
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
PATCH 6/15 hisi_sas: disable dlvry queues once at reset for v2 hw
In reply to John GarryThe Delivery queue enable register should only be written to once at reset for v2 hw.
--- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +1 -3
@@ -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++) {
Signature · 1 line
1.9.1
Re: [PATCH 06/15] hisi_sas: disable dlvry queues once at reset for v2 hw
Quoted 14 lines · John Garry
The Delivery queue enable register should only be written to once at reset for v2 hw.
Signed-off-by John Garry <[email protected]>--- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +0
-0
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c static int reset_hw_v2_hw(struct hisi_hba *hisi_hba) · line 691
Quoted 10 lines
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +1
-3@@ -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++) {
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
PATCH 7/15 hisi_sas: fix phy8 linkrate calculation in phy_up_v2_hw()
In reply to John GarryIn 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.
--- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 3 --- 1 file changed, 3 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +0 -3
@@ -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 );
Signature · 1 line
1.9.1
Re: [PATCH 07/15] hisi_sas: fix phy8 linkrate calculation in phy_up_v2_hw()
Quoted 16 lines · John Garry
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 <[email protected]>Signed-off-by Xiang Chen <[email protected]>--- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 3 --- 1 file changed, 3 deletions(-)drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +0
-0
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c static int phy_up_v2_hw(int phy_no, struct hisi_hba *hisi_hba) · line 1881
Quoted 9 lines
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +0
-3@@ -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 );
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
PATCH 8/15 hisi_sas: fix a potential warning for sata disk ejection
In reply to John GarryIf 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.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +6 -20
@@ -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)) {
Signature · 1 line
1.9.1
Re: [PATCH 08/15] hisi_sas: fix a potential warning for sata disk ejection
Quoted 27 lines · John Garry
If
hisi_sas_task_prep()fails for a SATA device due to PHY down, we return a failure to libata and also calltask_done(), which will causeata_qc_complete()to be called twice:
- first call fromhisi_sas_task_prep(), which will clear flagATA_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
Quoted 9 lines
The issue is resolved by simply returning a failure status code to the upper layer.
Signed-off-by Xiang Chen <[email protected]>Signed-off-by John Garry <[email protected]>--- drivers/scsi/hisi_sas/hisi_sas_main.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
PATCH 9/15 hisi_sas: set dma mask before allocate DMA memory
In reply to John GarryThe 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.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +6 -7
@@ -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 );
Signature · 1 line
1.9.1
Re: [PATCH 09/15] hisi_sas: set dma mask before allocate DMA memory
Quoted 6 lines · John Garry
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.
Quoted 6 lines
Signed-off-by Xiang Chen <[email protected]>Signed-off-by John Garry <[email protected]>--- drivers/scsi/hisi_sas/hisi_sas_main.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
PATCH 10/15 hisi_sas: fix HBA SAS addr endianness for v2 hw
In reply to John GarryThe 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).
--- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +4 -4
@@ -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 ])); }
Signature · 1 line
1.9.1
Re: [PATCH 10/15] hisi_sas: fix HBA SAS addr endianness for v2 hw
Quoted 30 lines · John Garry
The endianness for the SAS address in the
TX_ID_DWORDregisters is set incorrectly.
We see errors like this in the boot log:[ 7.583284] sas: target proto 0x0 at 50000d1108e7923f:0x1f not handledThis 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 <[email protected]>Signed-off-by Xiang Chen <[email protected]>--- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +1
-2@@ -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 ]);
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c static void config_id_frame_v2_hw(struct hisi_hba *hisi_hba, int phy_no) · line 574
Quoted 10 lines
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +3
-2+ __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 ])); }
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
PATCH 11/15 hisi_sas: fix HBA SAS addr endianness for v1 hw
In reply to John GarryThe 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).
--- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +4 -4
@@ -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 ])); }
Signature · 1 line
1.9.1
Re: [PATCH 11/15] hisi_sas: fix HBA SAS addr endianness for v1 hw
Quoted 31 lines · John Garry
The endianness for the SAS address in the
TX_ID_DWORDregisters 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 handledThis 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 <[email protected]>Signed-off-by Xiang Chen <[email protected]>--- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +1
-2@@ -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 ]);
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c static void config_id_frame_v1_hw(struct hisi_hba *hisi_hba, int phy_no) · line 502
Quoted 10 lines
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +3
-2+ __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 ])); }
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
PATCH 12/15 hisi_sas: remove init_id_frame_v2_hw()
In reply to John GarryFunction 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.
--- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 10 ---------- 1 file changed, 10 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +0 -10
@@ -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 ; }
Signature · 1 line
1.9.1
Re: [PATCH 12/15] hisi_sas: remove init_id_frame_v2_hw()
Quoted 10 lines · John Garry
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 callsconfig_id_frame_v2_hw().We will keep the call to
config_id_frame_v2_hw()instart_phy_v2_hw()since it will be used for PHY reset functions.
Quoted 6 lines
Signed-off-by John Garry <[email protected]>Signed-off-by Xiang Chen <[email protected]>--- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 10 ---------- 1 file changed, 10 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
PATCH 13/15 hisi_sas: remove init_id_frame_v1_hw()
In reply to John GarryFunction 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.
--- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 10 ---------- 1 file changed, 10 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +0 -10
@@ -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 ; }
Signature · 1 line
1.9.1
Re: [PATCH 13/15] hisi_sas: remove init_id_frame_v1_hw()
Quoted 10 lines · John Garry
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 callsconfig_id_frame_v1_hw().We will keep the call to
config_id_frame_v1_hw()instart_phy_v1_hw()since it will be used for PHY reset functions.
Quoted 6 lines
Signed-off-by John Garry <[email protected]>Signed-off-by Xiang Chen <[email protected]>--- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 10 ---------- 1 file changed, 10 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
PATCH 14/15 hisi_sas: add missing SATA pending device type to v2 hw
In reply to John GarryIn 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.
--- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +1 -0
@@ -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
Signature · 1 line
1.9.1
Re: [PATCH 14/15] hisi_sas: add missing SATA pending device type to v2 hw
Quoted 18 lines · John Garry
In
setup_itct_v2_hw(), SATA device typeSAS_SATA_PENDINGis missing, so add it.Note: The HiSi SAS controller does not support SATA PM,
so do not handleSAS_SATA_PM_PORTorSAS_SATA_PM.Signed-off-by John Garry <[email protected]>Signed-off-by Xiang Chen <[email protected]>--- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 1 + 1 file changed, 1 insertion(+)drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +0
-0
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c static void setup_itct_v2_hw(struct hisi_hba *hisi_hba, · line 600
Quoted 7 lines
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +1
-0@@ -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
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
PATCH 15/15 hisi_sas: send three identify before phy up
In reply to John GarryWhen 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.
--- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +16 -4
@@ -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 );
Signature · 1 line
1.9.1
Re: [PATCH 15/15] hisi_sas: send three identify before phy up
Quoted 10 lines · John Garry
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.
Quoted 6 lines
Signed-off-by NengLong Zhao <[email protected]>Signed-off-by John Garry <[email protected]>--- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
Martin K. Petersen
AppliedQuoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"John" == John Garry <[email protected]> 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.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering