hisi_sas: Misc fixes and other more minor patches
Subsystems (2)
cover hisi_sas: Misc fixes and other more minor patches
This series includes a misc assortment of fixes found during testing.
Also includes is some debugfs tidy-up and a patch missed from original upstreaming.
John Garry (5):
scsi: hisi_sas: No need to check return value of debugfs_create
functions
scsi: hisi_sas: Fix type casting and missing static qualifier in
debugfs code
scsi: hisi_sas: Some misc tidy-up
scsi: hisi_sas: Fix to only call scsi_get_prot_op() for non-NULL
scsi_cmnd
scsi: hisi_sas: Add missing seq_printf() call in
hisi_sas_show_row_32()
Luo Jiaxing (3):
scsi: hisi_sas: Add debugfs ITCT file and add file operations
scsi: hisi_sas: Reject setting programmed minimum linkrate > 1.5G
scsi: hisi_sas: Correct memory allocation size for DQ debugfs
Xiang Chen (4):
scsi: hisi_sas: send primitive NOTIFY to SSP situation only
scsi: hisi_sas: shutdown axi bus to avoid exception CQ returned
scsi: hisi_sas: remove the check of sas_dev status in
hisi_sas_I_T_nexus_reset()
scsi: hisi_sas: Remove unused parameter of function hisi_sas_alloc()
Xiaofei Tan (1):
scsi: hisi_sas: Fix losing directly attached disk when hot-plug
drivers/scsi/hisi_sas/hisi_sas.h | 19 ++-- drivers/scsi/hisi_sas/hisi_sas_main.c | 199 ++++++++++++++++++++------------- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 4 +- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 13 ++- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 48 +++++--- 5 files changed, 179 insertions(+), 104 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/13 scsi: hisi_sas: No need to check return value of debugfs_create functions
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.
--- drivers/scsi/hisi_sas/hisi_sas.h | 1 + drivers/scsi/hisi_sas/hisi_sas_main.c | 53 +++++++++++------------------------ 2 files changed, 17 insertions(+), 37 deletions(-)
drivers/scsi/hisi_sas/hisi_sas.h +1 -0
@@ -368,6 +368,7 @@ struct hisi_hba {struct dentry *debugfs_dir;struct dentry *debugfs_dump_dentry; +bool debugfs_snapshot; };/* Generic HW DMA host memory structures */
drivers/scsi/hisi_sas/hisi_sas_main.c +16 -37
102 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 2/13 scsi: hisi_sas: Fix type casting and missing static qualifier in debugfs code
In reply to John GarrySparse can detect some type casting issues in the debugfs code, so fix it up.
Also a missing static qualifier is added to hisi_sas_debugfs_to_reg_name().
--- drivers/scsi/hisi_sas/hisi_sas.h | 4 ++-- drivers/scsi/hisi_sas/hisi_sas_main.c | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-)
drivers/scsi/hisi_sas/hisi_sas.h +2 -2
@@ -359,8 +359,8 @@ struct hisi_hba {u32 intr_coal_count;/* Interrupt count to coalesce */ /* debugfs memories */ -void *debugfs_global_reg; -void *debugfs_port_reg[HISI_SAS_MAX_PHYS ]; +u32 *debugfs_global_reg; +u32 *debugfs_port_reg[HISI_SAS_MAX_PHYS ];void *debugfs_complete_hdr[HISI_SAS_MAX_QUEUES ];struct hisi_sas_cmd_hdr *debugfs_cmd_hdr[HISI_SAS_MAX_QUEUES ];struct hisi_sas_iost *debugfs_iost;
drivers/scsi/hisi_sas/hisi_sas_main.c +11 -10
@@ -2547,7 +2547,7 @@ static void hisi_sas_debugfs_snapshot_iost_reg(struct hisi_hba *hisi_hba) } } -const char * +static const char *hisi_sas_debugfs_to_reg_name (int off,int base_off,const struct hisi_sas_debugfs_reg_lu *lu) {
@@ -2574,10 +2574,10 @@ static void hisi_sas_debugfs_print_reg(u32 *regs_val, const void *ptr,if (name)seq_printf (s,"0x%08x 0x%08x %s\n" , off, -le32_to_cpu (regs_val[i]), name); + regs_val[i], name);else seq_printf (s,"0x%08x 0x%08x\n" , off, -le32_to_cpu (regs_val[i])); + regs_val[i]); } }
@@ -2587,7 +2587,7 @@ static int hisi_sas_debugfs_global_show(struct seq_file *s, void *p)const struct hisi_sas_hw *hw = hisi_hba->hw;const struct hisi_sas_debugfs_reg *reg_global = hw->debugfs_reg_global; -hisi_sas_debugfs_print_reg ((u32 *)hisi_hba->debugfs_global_reg, +hisi_sas_debugfs_print_reg (hisi_hba->debugfs_global_reg, reg_global, s);return 0 ;
@@ -2634,7 +2634,7 @@ static int hisi_sas_debugfs_port_open(struct inode *inode, struct file *filp) };static int hisi_sas_show_row_64 (struct seq_file *s,int index, -int sz,u64 *ptr) +int sz,__le64 *ptr) {int i;
@@ -2652,7 +2652,7 @@ static int hisi_sas_show_row_64(struct seq_file *s, int index, }static int hisi_sas_show_row_32 (struct seq_file *s,int index, -int sz,u32 *ptr) +int sz,__le32 *ptr) {int i;
@@ -2672,7 +2672,7 @@ static int hisi_sas_cq_show_slot(struct seq_file *s, int slot, void *cq_ptr)struct hisi_sas_cq *cq = cq_ptr;struct hisi_hba *hisi_hba = cq->hisi_hba;void *complete_queue = hisi_hba->debugfs_complete_hdr[cq->id]; -void *complete_hdr = complete_queue + +__le32 *complete_hdr = complete_queue + (hisi_hba->hw->complete_hdr_size * slot); return hisi_sas_show_row_32(s, slot,
@@ -2711,8 +2711,8 @@ static int hisi_sas_dq_show_slot(struct seq_file *s, int slot, void *dq_ptr)struct hisi_sas_dq *dq = dq_ptr;struct hisi_hba *hisi_hba = dq->hisi_hba;void *cmd_queue = hisi_hba->debugfs_cmd_hdr[dq->id]; -void *cmd_hdr = cmd_queue + - hisi_hba->hw->complete_hdr_size * slot; +__le32 *cmd_hdr = cmd_queue + +sizeof (struct hisi_sas_cmd_hdr ) * slot;return hisi_sas_show_row_32 (s, slot,sizeof (struct hisi_sas_cmd_hdr ), cmd_hdr);
@@ -2748,10 +2748,11 @@ static int hisi_sas_debugfs_iost_show(struct seq_file *s, void *p)struct hisi_hba *hisi_hba = s->private;struct hisi_sas_iost *debugfs_iost = hisi_hba->debugfs_iost;int i, ret, max_command_entries = hisi_hba->hw->max_command_entries; +__le64 *iost = &debugfs_iost->qw0;for (i =0 ; i < max_command_entries; i++, debugfs_iost++) { ret =hisi_sas_show_row_64 (s, i,sizeof (*debugfs_iost), - (u64 *)debugfs_iost); + iost);if (ret)return ret; }
Signature · 1 line
1.9.1
PATCH 3/13 scsi: hisi_sas: Add debugfs ITCT file and add file operations
In reply to John GarryFrom: Luo Jiaxing <[email protected]>
This patch create debugfs file for ITCT and add file operations.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
drivers/scsi/hisi_sas/hisi_sas_main.c +33 -0
@@ -2773,6 +2773,36 @@ static int hisi_sas_debugfs_iost_open(struct inode *inode, struct file *filp) .owner = THIS_MODULE, }; +static int hisi_sas_debugfs_itct_show (struct seq_file *s,void *p) +{ +int i, ret; +struct hisi_hba *hisi_hba = s->private; +struct hisi_sas_itct *debugfs_itct = hisi_hba->debugfs_itct; +__le64 *itct = &debugfs_itct->qw0; + +for (i =0 ; i <HISI_SAS_MAX_ITCT_ENTRIES ; i++, debugfs_itct++) { + ret =hisi_sas_show_row_64 (s, i,sizeof (*debugfs_itct), + itct); +if (ret) +return ret; + } + +return 0 ; +} + +static int hisi_sas_debugfs_itct_open (struct inode *inode,struct file *filp) +{ +return single_open (filp, hisi_sas_debugfs_itct_show, inode->i_private); +} + +static const struct file_operations hisi_sas_debugfs_itct_fops = { + .open = hisi_sas_debugfs_itct_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .owner =THIS_MODULE , +}; +static void hisi_sas_debugfs_create_files (struct hisi_hba *hisi_hba) {struct dentry *dump_dentry;
@@ -2819,6 +2849,9 @@ static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba)debugfs_create_file ("iost" ,0400 , dump_dentry, hisi_hba, &hisi_sas_debugfs_iost_fops); +debugfs_create_file ("itct" ,0400 , dump_dentry, hisi_hba, + &hisi_sas_debugfs_itct_fops); +return ; }
Signature · 1 line
1.9.1
PATCH 4/13 scsi: hisi_sas: send primitive NOTIFY to SSP situation only
In reply to John GarryFrom: Xiang Chen <[email protected]>
Send primitive NOTIFY to SSP situation only, or it causes underflow issue when sending IO. And also rename hisi_sas_hw.sl_notify() to hisi_sas_hw. sl_notify_ssp().
--- drivers/scsi/hisi_sas/hisi_sas.h | 2 +- drivers/scsi/hisi_sas/hisi_sas_main.c | 3 ++- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 4 ++-- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 4 ++-- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-)
drivers/scsi/hisi_sas/hisi_sas.h +1 -1
@@ -246,7 +246,7 @@ struct hisi_sas_hw {int (*slot_index_alloc)(struct hisi_hba *hisi_hba,struct domain_device *device);struct hisi_sas_device *(*alloc_dev)(struct domain_device *device); -void (*sl_notify)(struct hisi_hba *hisi_hba,int phy_no); +void (*sl_notify_ssp)(struct hisi_hba *hisi_hba,int phy_no);int (*get_free_slot)(struct hisi_hba *hisi_hba,struct hisi_sas_dq *dq);void (*start_delivery)(struct hisi_sas_dq *dq); void (*prep_ssp)(struct hisi_hba *hisi_hba,
drivers/scsi/hisi_sas/hisi_sas_main.c +2 -1
@@ -778,7 +778,8 @@ static void hisi_sas_phyup_work(struct work_struct *work)struct asd_sas_phy *sas_phy = &phy->sas_phy;int phy_no = sas_phy->id; - hisi_hba->hw->sl_notify (hisi_hba, phy_no);/* This requires a sleep */ +if (phy->identify.target_port_protocols ==SAS_PROTOCOL_SSP ) + hisi_hba->hw->sl_notify_ssp (hisi_hba, phy_no);hisi_sas_bytes_dmaed (hisi_hba, phy_no); }
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +2 -2
@@ -835,7 +835,7 @@ static void phys_init_v1_hw(struct hisi_hba *hisi_hba)mod_timer (timer, jiffies +HZ ); } -static void sl_notify_v1_hw (struct hisi_hba *hisi_hba,int phy_no) +static void sl_notify_ssp_v1_hw (struct hisi_hba *hisi_hba,int phy_no) {u32 sl_control;
@@ -1826,7 +1826,7 @@ static int hisi_sas_v1_init(struct hisi_hba *hisi_hba)static const struct hisi_sas_hw hisi_sas_v1_hw = { .hw_init = hisi_sas_v1_init, .setup_itct = setup_itct_v1_hw, - .sl_notify = sl_notify_v1_hw, + .sl_notify_ssp = sl_notify_ssp_v1_hw, .clear_itct = clear_itct_v1_hw, .prep_smp = prep_smp_v1_hw, .prep_ssp = prep_ssp_v1_hw,
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +2 -2
@@ -1589,7 +1589,7 @@ static void phys_init_v2_hw(struct hisi_hba *hisi_hba) } } -static void sl_notify_v2_hw (struct hisi_hba *hisi_hba,int phy_no) +static void sl_notify_ssp_v2_hw (struct hisi_hba *hisi_hba,int phy_no) {u32 sl_control;
@@ -3625,7 +3625,7 @@ static void debugfs_snapshot_restore_v2_hw(struct hisi_hba *hisi_hba) .setup_itct = setup_itct_v2_hw, .slot_index_alloc = slot_index_alloc_quirk_v2_hw, .alloc_dev = alloc_dev_quirk_v2_hw, - .sl_notify = sl_notify_v2_hw, + .sl_notify_ssp = sl_notify_ssp_v2_hw, .get_wideport_bitmap = get_wideport_bitmap_v2_hw, .clear_itct = clear_itct_v2_hw, .free_device = free_device_v2_hw,
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +2 -2
@@ -870,7 +870,7 @@ static void phys_init_v3_hw(struct hisi_hba *hisi_hba) } } -static void sl_notify_v3_hw (struct hisi_hba *hisi_hba,int phy_no) +static void sl_notify_ssp_v3_hw (struct hisi_hba *hisi_hba,int phy_no) {u32 sl_control;
@@ -2520,7 +2520,7 @@ static void debugfs_snapshot_restore_v3_hw(struct hisi_hba *hisi_hba) .get_wideport_bitmap = get_wideport_bitmap_v3_hw, .complete_hdr_size = sizeof(struct hisi_sas_complete_v3_hdr), .clear_itct = clear_itct_v3_hw, - .sl_notify = sl_notify_v3_hw, + .sl_notify_ssp = sl_notify_ssp_v3_hw, .prep_ssp = prep_ssp_v3_hw, .prep_smp = prep_smp_v3_hw, .prep_stp = prep_ata_v3_hw,
Signature · 1 line
1.9.1
PATCH 5/13 scsi: hisi_sas: shutdown axi bus to avoid exception CQ returned
In reply to John GarryFrom: Xiang Chen <[email protected]>
When injecting 2 bit ECC error, it will cause fatal AXI interrupts. Before the recovery of SAS controller reset, the internal of SAS controller is in error. If CQ interrupts return at the time, actually it is exception CQ interrupt, and it may cause resource release in disorder.
To avoid the exception situation, shutdown AXI bus after fatal AXI interrupt. In SAS controller reset, it will restart AXI bus. For later version of v3 hw, hardware will shutdown AXI bus for this situation, so just fix current ver of v3 hw.
--- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +12 -0
@@ -1646,6 +1646,7 @@ static irqreturn_t fatal_axi_int_v3_hw(int irq_no, void *p)u32 irq_value, irq_msk;struct hisi_hba *hisi_hba = p;struct device *dev = hisi_hba->dev; +struct pci_dev *pdev = hisi_hba->pci_dev;int i; irq_msk =hisi_sas_read32 (hisi_hba,ENT_INT_SRC_MSK3 );
@@ -1677,6 +1678,17 @@ static irqreturn_t fatal_axi_int_v3_hw(int irq_no, void *p) error->msg, irq_value);queue_work (hisi_hba->wq, &hisi_hba->rst_work); } + +if (pdev->revision <0x21 ) { +u32 reg_val; + + reg_val =hisi_sas_read32 (hisi_hba, +AXI_MASTER_CFG_BASE + +AM_CTRL_GLOBAL ); + reg_val |=AM_CTRL_SHUTDOWN_REQ_MSK ; +hisi_sas_write32 (hisi_hba,AXI_MASTER_CFG_BASE + +AM_CTRL_GLOBAL , reg_val); + } }if (irq_value &BIT (ENT_INT_SRC3_ITC_INT_OFF )) {
Signature · 1 line
1.9.1
PATCH 6/13 scsi: hisi_sas: remove the check of sas_dev status in hisi_sas_I_T_nexus_reset()
In reply to John GarryFrom: Xiang Chen <[email protected]>
When issing a hardreset to a SATA device when running IO, it is possible that abnormal CQs of the device are returned. Then enter error handle, it doesn't enter function hisi_sas_abort_task() as there is no timeout IO, and it doesn't set device as HISI_SAS_DEV_EH. So when hardreset by libata later, it actually doesn't issue hardreset as there is a check to judge whether device is in error.
For this situation, actually need to hardreset the device to recover. So remove the check of sas_dev status in hisi_sas_I_T_nexus_reset().
Before we add the check to avoid the endless loop of reset for directly-attached SATA device at probe time, actually we flutter it for it, so it is not necessary to add the check now.
--- drivers/scsi/hisi_sas/hisi_sas.h | 6 ------ drivers/scsi/hisi_sas/hisi_sas_main.c | 9 --------- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 1 - 3 files changed, 16 deletions(-)
drivers/scsi/hisi_sas/hisi_sas.h +0 -6
@@ -83,11 +83,6 @@ enum { PORT_TYPE_SATA = (1U << 0), }; -enum dev_status { -HISI_SAS_DEV_NORMAL , -HISI_SAS_DEV_EH , -}; -enum {HISI_SAS_INT_ABT_CMD =0 ,HISI_SAS_INT_ABT_DEV =1 ,
@@ -188,7 +183,6 @@ struct hisi_sas_device {enum sas_device_type dev_type;int device_id;int sata_idx; -u8 dev_status; };struct hisi_sas_tmf_task {
drivers/scsi/hisi_sas/hisi_sas_main.c +0 -9
@@ -626,7 +626,6 @@ static struct hisi_sas_device *hisi_sas_alloc_dev(struct domain_device *device) hisi_hba->devices[i].device_id = i; sas_dev = &hisi_hba->devices[i]; - sas_dev->dev_status =HISI_SAS_DEV_NORMAL ; sas_dev->dev_type = device->dev_type; sas_dev->hisi_hba = hisi_hba; sas_dev->sas_device = device;
@@ -1495,7 +1494,6 @@ static int hisi_sas_abort_task(struct sas_task *task) task->task_state_flags |=SAS_TASK_STATE_ABORTED ;spin_unlock_irqrestore (&task->task_state_lock, flags); - sas_dev->dev_status =HISI_SAS_DEV_EH ;if (task->lldd_task && task->task_proto &SAS_PROTOCOL_SSP ) {struct scsi_cmnd *cmnd = task->uldd_task;struct hisi_sas_slot *slot = task->lldd_task;
@@ -1639,15 +1637,10 @@ static int hisi_sas_debug_I_T_nexus_reset(struct domain_device *device)static int hisi_sas_I_T_nexus_reset (struct domain_device *device) { -struct hisi_sas_device *sas_dev = device->lldd_dev;struct hisi_hba *hisi_hba =dev_to_hisi_hba (device);struct device *dev = hisi_hba->dev;int rc =TMF_RESP_FUNC_FAILED ; -if (sas_dev->dev_status !=HISI_SAS_DEV_EH ) -return TMF_RESP_FUNC_FAILED ; - sas_dev->dev_status =HISI_SAS_DEV_NORMAL ; - rc =hisi_sas_internal_task_abort (hisi_hba, device,HISI_SAS_INT_ABT_DEV ,0 );if (rc <0 ) {
@@ -1671,7 +1664,6 @@ static int hisi_sas_lu_reset(struct domain_device *device, u8 *lun)struct device *dev = hisi_hba->dev;int rc =TMF_RESP_FUNC_FAILED ; - sas_dev->dev_status =HISI_SAS_DEV_EH ;if (dev_is_sata (device)) {struct sas_phy *phy;
@@ -2100,7 +2092,6 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost)for (i =0 ; i <HISI_SAS_MAX_DEVICES ; i++) { hisi_hba->devices[i].dev_type =SAS_PHY_UNUSED ; hisi_hba->devices[i].device_id = i; - hisi_hba->devices[i].dev_status =HISI_SAS_DEV_NORMAL ; }for (i =0 ; i < hisi_hba->queue_count; i++) {
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +0 -1
@@ -868,7 +868,6 @@ hisi_sas_device *alloc_dev_quirk_v2_hw(struct domain_device *device) hisi_hba->devices[i].device_id = i; sas_dev = &hisi_hba->devices[i]; - sas_dev->dev_status =HISI_SAS_DEV_NORMAL ; sas_dev->dev_type = device->dev_type; sas_dev->hisi_hba = hisi_hba; sas_dev->sas_device = device;
Signature · 1 line
1.9.1
PATCH 7/13 scsi: hisi_sas: Remove unused parameter of function hisi_sas_alloc()
In reply to John GarryFrom: Xiang Chen <[email protected]>
Actually in function hisi_sas_alloc(), parameter shost is not used, so remove it.
--- drivers/scsi/hisi_sas/hisi_sas.h | 2 +- drivers/scsi/hisi_sas/hisi_sas_main.c | 4 ++-- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/scsi/hisi_sas/hisi_sas.h +1 -1
@@ -497,7 +497,7 @@ struct hisi_sas_slot_buf_table {extern struct dentry *hisi_sas_debugfs_dir;extern void hisi_sas_stop_phys (struct hisi_hba *hisi_hba); -extern int hisi_sas_alloc (struct hisi_hba *hisi_hba,struct Scsi_Host *shost); +extern int hisi_sas_alloc (struct hisi_hba *hisi_hba);extern void hisi_sas_free (struct hisi_hba *hisi_hba);extern u8 hisi_sas_get_ata_protocol (struct host_to_dev_fis *fis,int direction);
drivers/scsi/hisi_sas/hisi_sas_main.c +2 -2
@@ -2074,7 +2074,7 @@ void hisi_sas_init_mem(struct hisi_hba *hisi_hba) }EXPORT_SYMBOL_GPL (hisi_sas_init_mem); -int hisi_sas_alloc (struct hisi_hba *hisi_hba,struct Scsi_Host *shost) +int hisi_sas_alloc (struct hisi_hba *hisi_hba) {struct device *dev = hisi_hba->dev;int i, j, s, max_command_entries = hisi_hba->hw->max_command_entries;
@@ -2358,7 +2358,7 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev, goto err_out; } -if (hisi_sas_alloc (hisi_hba, shost)) { +if (hisi_sas_alloc (hisi_hba)) {hisi_sas_free (hisi_hba); goto err_out; }
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +1 -1
@@ -2591,7 +2591,7 @@ static void debugfs_snapshot_restore_v3_hw(struct hisi_hba *hisi_hba)if (hisi_sas_get_fw_info (hisi_hba) <0 ) goto err_out; -if (hisi_sas_alloc (hisi_hba, shost)) { +if (hisi_sas_alloc (hisi_hba)) {hisi_sas_free (hisi_hba); goto err_out; }
Signature · 1 line
1.9.1
PATCH 8/13 scsi: hisi_sas: Reject setting programmed minimum linkrate > 1.5G
In reply to John GarryFrom: Luo Jiaxing <[email protected]>
The SAS controller cannot support a programmed minimum linkrate of
Quoted 1 line
1.5G (it will always negotiate to 1.5G at least), so just reject it.
This solves a strange situation where the PHY negotiated linkrate may be less than the programmed minimum linkrate.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +8 -4
@@ -946,7 +946,7 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags)return hisi_sas_task_exec (task, gfp_flags,0 ,NULL ); } -static void hisi_sas_phy_set_linkrate (struct hisi_hba *hisi_hba,int phy_no, +static int hisi_sas_phy_set_linkrate (struct hisi_hba *hisi_hba,int phy_no,struct sas_phy_linkrates *r) {struct sas_phy_linkrates _r;
@@ -955,6 +955,9 @@ static void hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no,struct asd_sas_phy *sas_phy = &phy->sas_phy;enum sas_linkrate min, max; +if (r->minimum_linkrate >SAS_LINK_RATE_1_5_GBPS ) +return -EINVAL ; +if (r->maximum_linkrate ==SAS_LINK_RATE_UNKNOWN ) { max = sas_phy->phy->maximum_linkrate; min = r->minimum_linkrate;
@@ -962,7 +965,7 @@ static void hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no, max = r->maximum_linkrate; min = sas_phy->phy->minimum_linkrate; }else -return ; +return -EINVAL ; _r.maximum_linkrate = max; _r.minimum_linkrate = min;
@@ -974,6 +977,8 @@ static void hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no,msleep (100 ); hisi_hba->hw->phy_set_linkrate (hisi_hba, phy_no, &_r); hisi_hba->hw->phy_start (hisi_hba, phy_no); + +return 0 ; } static int hisi_sas_control_phy(struct asd_sas_phy *sas_phy, enum phy_func func,
@@ -999,8 +1004,7 @@ static int hisi_sas_control_phy(struct asd_sas_phy *sas_phy, enum phy_func func,break ;case PHY_FUNC_SET_LINK_RATE : -hisi_sas_phy_set_linkrate (hisi_hba, phy_no, funcdata); -break ; +return hisi_sas_phy_set_linkrate (hisi_hba, phy_no, funcdata);case PHY_FUNC_GET_EVENTS :if (hisi_hba->hw->get_events) { hisi_hba->hw->get_events (hisi_hba, phy_no);
Signature · 1 line
1.9.1
PATCH 9/13 scsi: hisi_sas: Fix losing directly attached disk when hot-plug
In reply to John GarryFrom: Xiaofei Tan <[email protected]>
Hot-plugging SAS wire of direct hard disk backplane may cause disk lost. We have done this test with several types of SATA disk from different venders, and only two models from Seagate has this problem, ST4000NM0035-1V4107 and ST3000VM002-1ET166.
The root cause is that the disk doesn't send D2H frame after OOB finished. SAS controller will issue phyup interrupt only when D2H frame is received, otherwise, will be waiting there all the time.
When this issue happen, we can find the disk again with link reset. To fix this issue, we setup an timer after OOB finished. If the PHY is not up in 20s, do link reset. Notes: the 20s is an experience value.
--- drivers/scsi/hisi_sas/hisi_sas.h | 4 ++++ drivers/scsi/hisi_sas/hisi_sas_main.c | 26 ++++++++++++++++++++++++++ drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 8 ++++++++ drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 27 ++++++++++++++++++--------- 4 files changed, 56 insertions(+), 9 deletions(-)
drivers/scsi/hisi_sas/hisi_sas.h +4 -0
@@ -76,6 +76,8 @@#define HISI_SAS_PROT_MASK (HISI_SAS_DIF_PROT_MASK) +#define HISI_SAS_WAIT_PHYUP_TIMEOUT 20 +struct hisi_hba ;enum {
@@ -141,6 +143,7 @@ struct hisi_sas_phy {struct asd_sas_phy sas_phy;struct sas_identify identify;struct completion *reset_completion; +struct timer_list timer;spinlock_t lock;u64 port_id;/* from hw */ u64 frame_rcvd_size;
@@ -522,6 +525,7 @@ extern void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba,extern void hisi_sas_rst_work_handler (struct work_struct *work);extern void hisi_sas_sync_rst_work_handler (struct work_struct *work);extern void hisi_sas_kill_tasklets (struct hisi_hba *hisi_hba); +extern void hisi_sas_phy_oob_ready (struct hisi_hba *hisi_hba,int phy_no);extern bool hisi_sas_notify_phy_event (struct hisi_sas_phy *phy,enum hisi_sas_phy_event event);extern void hisi_sas_release_tasks (struct hisi_hba *hisi_hba);
drivers/scsi/hisi_sas/hisi_sas_main.c +26 -0
@@ -808,6 +808,30 @@ bool hisi_sas_notify_phy_event(struct hisi_sas_phy *phy, }EXPORT_SYMBOL_GPL (hisi_sas_notify_phy_event); +static void hisi_sas_wait_phyup_timedout (struct timer_list *t) +{ +struct hisi_sas_phy *phy =from_timer (phy, t, timer); +struct hisi_hba *hisi_hba = phy->hisi_hba; +struct device *dev = hisi_hba->dev; +int phy_no = phy->sas_phy.id; + +dev_warn (dev,"phy%d wait phyup timeout, issuing link reset\n" , phy_no); +hisi_sas_notify_phy_event (phy,HISI_PHYE_LINK_RESET ); +} + +void hisi_sas_phy_oob_ready (struct hisi_hba *hisi_hba,int phy_no) +{ +struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no]; +struct device *dev = hisi_hba->dev; + +if (!timer_pending (&phy->timer)) { +dev_dbg (dev,"phy%d OOB ready\n" , phy_no); + phy->timer.expires = jiffies +HISI_SAS_WAIT_PHYUP_TIMEOUT *HZ ; +add_timer (&phy->timer); + } +} +EXPORT_SYMBOL_GPL (hisi_sas_phy_oob_ready); +static void hisi_sas_phy_init (struct hisi_hba *hisi_hba,int phy_no) {struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];
@@ -836,6 +860,8 @@ static void hisi_sas_phy_init(struct hisi_hba *hisi_hba, int phy_no)INIT_WORK (&phy->works[i], hisi_sas_phye_fns[i]);spin_lock_init (&phy->lock); + +timer_setup (&phy->timer, hisi_sas_wait_phyup_timedout,0 ); }static void hisi_sas_port_notify_formed (struct asd_sas_phy *sas_phy)
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +8 -0
@@ -2676,6 +2676,8 @@ static int phy_up_v2_hw(int phy_no, struct hisi_hba *hisi_hba)if (is_sata_phy_v2_hw (hisi_hba, phy_no)) goto end; +del_timer (&phy->timer); +if (phy_no ==8 ) {u32 port_state =hisi_sas_read32 (hisi_hba,PORT_STATE );
@@ -2755,6 +2757,7 @@ static int phy_down_v2_hw(int phy_no, struct hisi_hba *hisi_hba)struct hisi_sas_port *port = phy->port;struct device *dev = hisi_hba->dev; +del_timer (&phy->timer);hisi_sas_phy_write32 (hisi_hba, phy_no,PHYCTRL_NOT_RDY_MSK ,1 ); phy_state =hisi_sas_read32 (hisi_hba,PHY_STATE );
@@ -2943,6 +2946,9 @@ static irqreturn_t int_chnl_int_v2_hw(int irq_no, void *p)if (irq_value0 &CHL_INT0_SL_RX_BCST_ACK_MSK )phy_bcast_v2_hw (phy_no, hisi_hba); +if (irq_value0 &CHL_INT0_PHY_RDY_MSK ) +hisi_sas_phy_oob_ready (hisi_hba, phy_no); +hisi_sas_phy_write32 (hisi_hba, phy_no,CHL_INT0 , irq_value0 & (~CHL_INT0_HOTPLUG_TOUT_MSK)
@@ -3226,6 +3232,8 @@ static irqreturn_t sata_int_v2_hw(int irq_no, void *p)unsigned long flags;int phy_no, offset; +del_timer (&phy->timer); + phy_no = sas_phy->id; initial_fis = &hisi_hba->initial_fis[phy_no]; fis = &initial_fis->fis;
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +18 -9
@@ -1290,6 +1290,7 @@ static irqreturn_t phy_up_v3_hw(int phy_no, struct hisi_hba *hisi_hba)struct device *dev = hisi_hba->dev;unsigned long flags; +del_timer (&phy->timer);hisi_sas_phy_write32 (hisi_hba, phy_no,PHYCTRL_PHY_ENA_MSK ,1 ); port_id =hisi_sas_read32 (hisi_hba,PHY_PORT_NUM_MA );
@@ -1383,9 +1384,11 @@ static irqreturn_t phy_up_v3_hw(int phy_no, struct hisi_hba *hisi_hba)static irqreturn_t phy_down_v3_hw (int phy_no,struct hisi_hba *hisi_hba) { +struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];u32 phy_state, sl_ctrl, txid_auto;struct device *dev = hisi_hba->dev; +del_timer (&phy->timer);hisi_sas_phy_write32 (hisi_hba, phy_no,PHYCTRL_NOT_RDY_MSK ,1 ); phy_state =hisi_sas_read32 (hisi_hba,PHY_STATE );
@@ -1554,6 +1557,19 @@ static void handle_chl_int2_v3_hw(struct hisi_hba *hisi_hba, int phy_no)hisi_sas_phy_write32 (hisi_hba, phy_no,CHL_INT2 , irq_value); } +static void handle_chl_int0_v3_hw (struct hisi_hba *hisi_hba,int phy_no) +{ +u32 irq_value0 =hisi_sas_phy_read32 (hisi_hba, phy_no,CHL_INT0 ); + +if (irq_value0 &CHL_INT0_PHY_RDY_MSK ) +hisi_sas_phy_oob_ready (hisi_hba, phy_no); + +hisi_sas_phy_write32 (hisi_hba, phy_no,CHL_INT0 , + irq_value0 & (~CHL_INT0_SL_RX_BCST_ACK_MSK ) + & (~CHL_INT0_SL_PHY_ENABLE_MSK ) + & (~CHL_INT0_NOT_RDY_MSK )); +} +static irqreturn_t int_chnl_int_v3_hw (int irq_no,void *p) {struct hisi_hba *hisi_hba = p;
@@ -1564,8 +1580,8 @@ static irqreturn_t int_chnl_int_v3_hw(int irq_no, void *p) &0xeeeeeeee ;while (irq_msk) { -u32 irq_value0 =hisi_sas_phy_read32 (hisi_hba, phy_no, -CHL_INT0 ); +if (irq_msk & (2 << (phy_no *4 ))) +handle_chl_int0_v3_hw (hisi_hba, phy_no);if (irq_msk & (4 << (phy_no *4 )))handle_chl_int1_v3_hw (hisi_hba, phy_no);
@@ -1573,13 +1589,6 @@ static irqreturn_t int_chnl_int_v3_hw(int irq_no, void *p)if (irq_msk & (8 << (phy_no *4 )))handle_chl_int2_v3_hw (hisi_hba, phy_no); -if (irq_msk & (2 << (phy_no *4 )) && irq_value0) { -hisi_sas_phy_write32 (hisi_hba, phy_no, -CHL_INT0 , irq_value0 - & (~CHL_INT0_SL_RX_BCST_ACK_MSK ) - & (~CHL_INT0_SL_PHY_ENABLE_MSK ) - & (~CHL_INT0_NOT_RDY_MSK )); - } irq_msk &= ~(0xe << (phy_no *4 )); phy_no++; }
Signature · 1 line
1.9.1
PATCH 10/13 scsi: hisi_sas: Correct memory allocation size for DQ debugfs
In reply to John GarryFrom: Luo Jiaxing <[email protected]>
Some sizes we allocate for debugfs structure is incorrect, so fix them.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +2 -2
@@ -2502,7 +2502,7 @@ static void hisi_sas_debugfs_snapshot_cq_reg(struct hisi_hba *hisi_hba)static void hisi_sas_debugfs_snapshot_dq_reg (struct hisi_hba *hisi_hba) { -int queue_entry_size = hisi_hba->hw->complete_hdr_size; +int queue_entry_size =sizeof (struct hisi_sas_cmd_hdr );int i;for (i =0 ; i < hisi_hba->queue_count; i++)
@@ -2945,7 +2945,7 @@ void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba) }/* Alloc buffer for dq */ - sz = hisi_hba->hw->complete_hdr_size *HISI_SAS_QUEUE_SLOTS ; + sz =sizeof (struct hisi_sas_cmd_hdr ) *HISI_SAS_QUEUE_SLOTS ;for (d =0 ; d < hisi_hba->queue_count; d++) { hisi_hba->debugfs_cmd_hdr[d] =devm_kmalloc (dev, sz,GFP_KERNEL );
Signature · 1 line
1.9.1
PATCH 11/13 scsi: hisi_sas: Some misc tidy-up
In reply to John GarrySparse detected some problems in the driver, so tidy them up.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +22 -11
@@ -2075,14 +2075,18 @@ void hisi_sas_kill_tasklets(struct hisi_hba *hisi_hba)void hisi_sas_init_mem (struct hisi_hba *hisi_hba) { -int i, s, max_command_entries = hisi_hba->hw->max_command_entries; +int i, s, j, max_command_entries = hisi_hba->hw->max_command_entries; +struct hisi_sas_breakpoint *sata_breakpoint = hisi_hba->sata_breakpoint;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]; +struct hisi_sas_cmd_hdr *cmd_hdr = hisi_hba->cmd_hdr[i]; + + s =sizeof (struct hisi_sas_cmd_hdr ); +for (j =0 ; j <HISI_SAS_QUEUE_SLOTS ; j++) +memset (&cmd_hdr[j],0 , s); - s =sizeof (struct hisi_sas_cmd_hdr ) *HISI_SAS_QUEUE_SLOTS ; -memset (hisi_hba->cmd_hdr[i],0 , s); dq->wr_point =0 ; s = hisi_hba->hw->complete_hdr_size *HISI_SAS_QUEUE_SLOTS ;
@@ -2099,8 +2103,9 @@ void hisi_sas_init_mem(struct hisi_hba *hisi_hba) s = max_command_entries *sizeof (struct hisi_sas_breakpoint );memset (hisi_hba->breakpoint,0 , s); - s =HISI_SAS_MAX_ITCT_ENTRIES *sizeof (struct hisi_sas_sata_breakpoint ); -memset (hisi_hba->sata_breakpoint,0 , s); + s =sizeof (struct hisi_sas_sata_breakpoint ); +for (j =0 ; j <HISI_SAS_MAX_ITCT_ENTRIES ; j++) +memset (&sata_breakpoint[j],0 , s); }EXPORT_SYMBOL_GPL (hisi_sas_init_mem);
@@ -2157,10 +2162,9 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba) s =HISI_SAS_MAX_ITCT_ENTRIES *sizeof (struct hisi_sas_itct ); hisi_hba->itct =dmam_alloc_coherent (dev, s, &hisi_hba->itct_dma, -GFP_KERNEL ); +GFP_KERNEL | __GFP_ZERO);if (!hisi_hba->itct) goto err_out; -memset (hisi_hba->itct,0 , s); hisi_hba->slot_info = devm_kcalloc(dev, max_command_entries, sizeof(struct hisi_sas_slot),
@@ -2505,10 +2509,17 @@ static void hisi_sas_debugfs_snapshot_dq_reg(struct hisi_hba *hisi_hba)int queue_entry_size =sizeof (struct hisi_sas_cmd_hdr );int i; -for (i =0 ; i < hisi_hba->queue_count; i++) -memcpy (hisi_hba->debugfs_cmd_hdr[i], - hisi_hba->cmd_hdr[i], -HISI_SAS_QUEUE_SLOTS * queue_entry_size); +for (i =0 ; i < hisi_hba->queue_count; i++) { +struct hisi_sas_cmd_hdr *debugfs_cmd_hdr, *cmd_hdr; +int j; + + debugfs_cmd_hdr = hisi_hba->debugfs_cmd_hdr[i]; + cmd_hdr = hisi_hba->cmd_hdr[i]; + +for (j =0 ; j <HISI_SAS_QUEUE_SLOTS ; j++) +memcpy (&debugfs_cmd_hdr[j], &cmd_hdr[j], + queue_entry_size); + } }static void hisi_sas_debugfs_snapshot_port_reg (struct hisi_hba *hisi_hba)
Signature · 1 line
1.9.1
PATCH 12/13 scsi: hisi_sas: Fix to only call scsi_get_prot_op() for non-NULL scsi_cmnd
In reply to John GarryA NULL-pointer dereference was introduced for TMF SSP commands from the upstreaming reworking.
Fix this by relocating the scsi_get_prot_op() callsite.
--- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +2 -1
@@ -1035,8 +1035,8 @@ static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba,struct sas_ssp_task *ssp_task = &task->ssp_task;struct scsi_cmnd *scsi_cmnd = ssp_task->cmd;struct hisi_sas_tmf_task *tmf = slot->tmf; -unsigned char prot_op =scsi_get_prot_op (scsi_cmnd);int has_data =0 , priority = !!tmf; +unsigned char prot_op;u8 *buf_cmd;u32 dw1 =0 , dw2 =0 , len =0 ;
@@ -1051,6 +1051,7 @@ static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba, dw1 |=2 <<CMD_HDR_FRAME_TYPE_OFF ; dw1 |=DIR_NO_DATA <<CMD_HDR_DIR_OFF ; }else { + prot_op =scsi_get_prot_op (scsi_cmnd); dw1 |=1 <<CMD_HDR_FRAME_TYPE_OFF ;switch (scsi_cmnd->sc_data_direction) {case DMA_TO_DEVICE :
Signature · 1 line
1.9.1
PATCH 13/13 scsi: hisi_sas: Add missing seq_printf() call in hisi_sas_show_row_32()
In reply to John GarryThis call must have been missed when I reworked the debugfs feature for upstreaming, so add it back.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/hisi_sas/hisi_sas_main.c +1 -0
@@ -2692,6 +2692,7 @@ static int hisi_sas_show_row_32(struct seq_file *s, int index,/* completion header size not fixed per HW version */ seq_printf (s,"index %04d:\n\t" , index);for (i =1 ; i <= sz /4 ; i++, ptr++) { +seq_printf (s," 0x%08x" ,le32_to_cpu (*ptr));if (!(i %4 ))seq_puts (s,"\n\t" ); }
Signature · 1 line
1.9.1
Martin K. Petersen
AppliedJohn,
Quoted 4 lines
This series includes a misc assortment of fixes found during testing.
Also includes is some debugfs tidy-up and a patch missed from original upstreaming.
Applied to 5.1/scsi-queue, thanks.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering