hisi_sas/libsas: Some misc patches
Subsystems (3)
cover hisi_sas/libsas: Some misc patches
Hi Martin,
This is just some random patches which I have collected for the hisi_sas driver and libsas over the last cycle, described briefly as follows:
- Remove some duplication in slave_configure_v3_hw()
- Some DMA mapping API usage tidying
- v3 HW SATA completion error processing improvement
- For libsas, resume host when changing phy settings via sysfs - our test guys seem to find it useful.
Thanks in advance, John
John Garry (1):
scsi: hisi_sas: Call hisi_sas_slave_configure() from
slave_configure_v3_hw()
Xiang Chen (3):
scsi: hisi_sas: Remove unnecessary variable to hold DMA map elements
scsi: hisi_sas: Relocate DMA unmap of SMP task
scsi: libsas: Resume SAS host for phy reset or enable via sysfs
Xingui Yang (1):
scsi: hisi_sas: Modify v3 HW SATA completion error processing
drivers/scsi/hisi_sas/hisi_sas_main.c | 49 ++++++++++++-------------- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 2 -- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 2 -- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 16 +++++---- drivers/scsi/libsas/sas_init.c | 4 +++ 5 files changed, 36 insertions(+), 37 deletions(-)
Signature · 1 line
2.35.3
PATCH 1/5 scsi: hisi_sas: Call hisi_sas_slave_configure() from slave_configure_v3_hw()
There is duplicated code between slave_configure_v3_hw() and hisi_sas_slave_configure(), so call common function hisi_sas_slave_configure() from slave_configure_v3_hw().
--- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +1 -4
@@ -2778,16 +2778,13 @@ static DEVICE_ATTR_RW(intr_coal_count_v3_hw);static int slave_configure_v3_hw (struct scsi_device *sdev) {struct Scsi_Host *shost =dev_to_shost (&sdev->sdev_gendev); -struct domain_device *ddev =sdev_to_domain_dev (sdev);struct hisi_hba *hisi_hba =shost_priv (shost); +int ret =hisi_sas_slave_configure (sdev);struct device *dev = hisi_hba->dev; -int ret =sas_slave_configure (sdev);unsigned int max_sectors;if (ret)return ret; -if (!dev_is_sata (ddev)) -sas_change_queue_depth (sdev,64 );if (sdev->type ==TYPE_ENCLOSURE )return 0 ;
Signature · 1 line
2.35.3
PATCH 2/5 scsi: hisi_sas: Remove unnecessary variable to hold DMA map elements
In reply to John GarryFrom: Xiang Chen <[email protected]>
Use slot->n_elem to store the return value of dma_map_sg() for SSP and SMP IOs, and remove unnecessary variable n_elem_req.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 43 +++++++++++---------------- 1 file changed, 18 insertions(+), 25 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +18 -25
@@ -220,9 +220,10 @@ void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task,if (!sas_protocol_ata (task->task_proto)) {if (slot->n_elem) -dma_unmap_sg (dev, task->scatter, - task->num_scatter, - task->data_dir); +if (task->task_proto &SAS_PROTOCOL_SSP ) +dma_unmap_sg (dev, task->scatter, + task->num_scatter, + task->data_dir);if (slot->n_elem_dif) {struct sas_ssp_task *ssp_task = &task->ssp_task;struct scsi_cmnd *scsi_cmnd = ssp_task->cmd;
@@ -269,28 +270,23 @@ static void hisi_sas_task_prep_abort(struct hisi_hba *hisi_hba, }static void hisi_sas_dma_unmap (struct hisi_hba *hisi_hba, -struct sas_task *task,int n_elem, -int n_elem_req) +struct sas_task *task,int n_elem) {struct device *dev = hisi_hba->dev; -if (!sas_protocol_ata (task->task_proto)) { +if (!sas_protocol_ata (task->task_proto) && n_elem) {if (task->num_scatter) { -if (n_elem) -dma_unmap_sg (dev, task->scatter, - task->num_scatter, - task->data_dir); +dma_unmap_sg (dev, task->scatter, task->num_scatter, + task->data_dir); }else if (task->task_proto &SAS_PROTOCOL_SMP ) { -if (n_elem_req) -dma_unmap_sg (dev, &task->smp_task.smp_req, -1 ,DMA_TO_DEVICE ); +dma_unmap_sg (dev, &task->smp_task.smp_req, +1 ,DMA_TO_DEVICE ); } } }static int hisi_sas_dma_map (struct hisi_hba *hisi_hba, -struct sas_task *task,int *n_elem, -int *n_elem_req) +struct sas_task *task,int *n_elem) {struct device *dev = hisi_hba->dev;int rc;
@@ -308,9 +304,9 @@ static int hisi_sas_dma_map(struct hisi_hba *hisi_hba, goto prep_out; } }else if (task->task_proto &SAS_PROTOCOL_SMP ) { - *n_elem_req =dma_map_sg (dev, &task->smp_task.smp_req, -1 ,DMA_TO_DEVICE ); -if (!*n_elem_req) { + *n_elem =dma_map_sg (dev, &task->smp_task.smp_req, +1 ,DMA_TO_DEVICE ); +if (!*n_elem) { rc = -ENOMEM ; goto prep_out; }
@@ -332,8 +328,7 @@ static int hisi_sas_dma_map(struct hisi_hba *hisi_hba, err_out_dma_unmap:/* It would be better to call dma_unmap_sg() here, but it's messy */ -hisi_sas_dma_unmap (hisi_hba, task, *n_elem, - *n_elem_req); +hisi_sas_dma_unmap (hisi_hba, task, *n_elem); prep_out:return rc; }
@@ -457,7 +452,7 @@ void hisi_sas_task_deliver(struct hisi_hba *hisi_hba,static int hisi_sas_queue_command (struct sas_task *task,gfp_t gfp_flags) { -int n_elem =0 , n_elem_dif =0 , n_elem_req =0 ; +int n_elem =0 , n_elem_dif =0 ;struct domain_device *device = task->dev;struct asd_sas_port *sas_port = device->port;struct hisi_sas_device *sas_dev = device->lldd_dev;
@@ -568,8 +563,7 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags)return -EINVAL ; } - rc =hisi_sas_dma_map (hisi_hba, task, &n_elem, - &n_elem_req); + rc =hisi_sas_dma_map (hisi_hba, task, &n_elem);if (rc <0 ) goto prep_out;
@@ -605,8 +599,7 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags)if (!sas_protocol_ata (task->task_proto))hisi_sas_dif_dma_unmap (hisi_hba, task, n_elem_dif); err_out_dma_unmap: -hisi_sas_dma_unmap (hisi_hba, task, n_elem, - n_elem_req); +hisi_sas_dma_unmap (hisi_hba, task, n_elem); prep_out:dev_err (dev,"task exec: failed[%d]!\n" , rc);return rc;
Signature · 1 line
2.35.3
PATCH 3/5 scsi: hisi_sas: Relocate DMA unmap of SMP task
In reply to John GarryFrom: Xiang Chen <[email protected]>
Currently SMP tasks are DMA unmapped only when cq of SMP IO is returned normally. If the cq of SMP IO is returned with exception actually SMP tas is never unmapped. Relocate DMA unmap of SMP task to fix the issue.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 6 +++++- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 2 -- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 2 -- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 -- 4 files changed, 5 insertions(+), 7 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +5 -1
@@ -219,11 +219,15 @@ void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task, task->lldd_task =NULL ;if (!sas_protocol_ata (task->task_proto)) { -if (slot->n_elem) +if (slot->n_elem) {if (task->task_proto &SAS_PROTOCOL_SSP )dma_unmap_sg (dev, task->scatter, task->num_scatter, task->data_dir); +else +dma_unmap_sg (dev, &task->smp_task.smp_req, +1 ,DMA_TO_DEVICE ); + }if (slot->n_elem_dif) {struct sas_ssp_task *ssp_task = &task->ssp_task;struct scsi_cmnd *scsi_cmnd = ssp_task->cmd;
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +0 -2
@@ -1282,8 +1282,6 @@ static void slot_complete_v1_hw(struct hisi_hba *hisi_hba, ts->stat =SAS_SAM_STAT_GOOD ; -dma_unmap_sg (dev, &task->smp_task.smp_req,1 , -DMA_TO_DEVICE ); memcpy(to + sg_resp->offset, hisi_sas_status_buf_addr_mem(slot) + sizeof(struct hisi_sas_err_record),
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +0 -2
@@ -2428,8 +2428,6 @@ static void slot_complete_v2_hw(struct hisi_hba *hisi_hba, ts->stat =SAS_SAM_STAT_GOOD ; -dma_unmap_sg (dev, &task->smp_task.smp_req,1 , -DMA_TO_DEVICE ); memcpy(to + sg_resp->offset, hisi_sas_status_buf_addr_mem(slot) + sizeof(struct hisi_sas_err_record),
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +0 -2
@@ -2311,8 +2311,6 @@ static void slot_complete_v3_hw(struct hisi_hba *hisi_hba, ts->stat =SAS_SAM_STAT_GOOD ; -dma_unmap_sg (dev, &task->smp_task.smp_req,1 , -DMA_TO_DEVICE ); memcpy(to + sg_resp->offset, hisi_sas_status_buf_addr_mem(slot) + sizeof(struct hisi_sas_err_record),
Signature · 1 line
2.35.3
PATCH 4/5 scsi: hisi_sas: Modify v3 HW SATA completion error processing
In reply to John GarryFrom: Xingui Yang <[email protected]>
If the I/O completion response frame returned by the target device has been written to the host memory and the err bit in the status field of the received fis is 1, ts->stat should set to SAS_PROTO_RESPONSE, and this will let EH analyze and further determine cause of failure.
--- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +8 -1
@@ -481,6 +481,9 @@ struct hisi_sas_err_record_v3 {#define RX_DATA_LEN_UNDERFLOW_OFF 6#define RX_DATA_LEN_UNDERFLOW_MSK (1 << RX_DATA_LEN_UNDERFLOW_OFF) +#define RX_FIS_STATUS_ERR_OFF 0 +#define RX_FIS_STATUS_ERR_MSK (1 << RX_FIS_STATUS_ERR_OFF) +#define HISI_SAS_COMMAND_ENTRIES_V3_HW 4096#define HISI_SAS_MSI_COUNT_V3_HW 32
@@ -2161,6 +2164,7 @@ slot_err_v3_hw(struct hisi_hba *hisi_hba, struct sas_task *task,hisi_sas_status_buf_addr_mem (slot);u32 dma_rx_err_type =le32_to_cpu (record->dma_rx_err_type);u32 trans_tx_fail_type =le32_to_cpu (record->trans_tx_fail_type); +u16 sipc_rx_err_type =le16_to_cpu (record->sipc_rx_err_type);u32 dw3 =le32_to_cpu (complete_hdr->dw3);switch (task->task_proto) {
@@ -2188,7 +2192,10 @@ slot_err_v3_hw(struct hisi_hba *hisi_hba, struct sas_task *task,case SAS_PROTOCOL_SATA :case SAS_PROTOCOL_STP :case SAS_PROTOCOL_SATA |SAS_PROTOCOL_STP : -if (dma_rx_err_type &RX_DATA_LEN_UNDERFLOW_MSK ) { +if ((complete_hdr->dw0 &CMPLT_HDR_RSPNS_XFRD_MSK ) && + (sipc_rx_err_type &RX_FIS_STATUS_ERR_MSK )) { + ts->stat =SAS_PROTO_RESPONSE ; + }else if (dma_rx_err_type &RX_DATA_LEN_UNDERFLOW_MSK ) { ts->residual = trans_tx_fail_type; ts->stat =SAS_DATA_UNDERRUN ; }else if (dw3 &CMPLT_HDR_IO_IN_TARGET_MSK ) {
Signature · 1 line
2.35.3
PATCH 5/5 scsi: libsas: Resume SAS host for phy reset or enable via sysfs
In reply to John GarryFrom: Xiang Chen <[email protected]>
Currently if a phy reset or enable phy is issued via sysfs when controller is suspended, those operations will be ignored as SAS_HA_REGISTERED is cleared. If RPM is enabled then we may aggressively suspend automatically. In this case it may be difficult to enable or reset a phy via sysfs, so resume the host in these scenarios.
--- drivers/scsi/libsas/sas_init.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/scsi/libsas/sas_init.c +4 -0
@@ -531,6 +531,7 @@ static int queue_phy_reset(struct sas_phy *phy, int hard_reset)if (!d)return -ENOMEM ; +pm_runtime_get_sync (ha->dev);/* libsas workqueue coordinates ata-eh reset with discovery */ mutex_lock (&d->event_lock); d->reset_result =0 ;
@@ -544,6 +545,7 @@ static int queue_phy_reset(struct sas_phy *phy, int hard_reset)if (rc ==0 ) rc = d->reset_result;mutex_unlock (&d->event_lock); +pm_runtime_put_sync (ha->dev);return rc; }
@@ -558,6 +560,7 @@ static int queue_phy_enable(struct sas_phy *phy, int enable)if (!d)return -ENOMEM ; +pm_runtime_get_sync (ha->dev);/* libsas workqueue coordinates ata-eh reset with discovery */ mutex_lock (&d->event_lock); d->enable_result =0 ;
@@ -571,6 +574,7 @@ static int queue_phy_enable(struct sas_phy *phy, int enable)if (rc ==0 ) rc = d->enable_result;mutex_unlock (&d->event_lock); +pm_runtime_put_sync (ha->dev);return rc; }
Signature · 1 line
2.35.3
Martin K. Petersen
AppliedJohn,
Quoted 2 lines
This is just some random patches which I have collected for the
hisi_sasdriver and libsas over the last cycle, described briefly as follows:
Applied to 5.20/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Martin K. Petersen
AppliedQuoted 9 lines · John Garry
This is just some random patches which I have collected for the
hisi_sasdriver and libsas over the last cycle, described briefly as follows:
- Remove some duplication inslave_configure_v3_hw()
- Some DMA mapping API usage tidying
- v3 HW SATA completion error processing improvement
- For libsas, resume host when changing phy settings via sysfs - our test guys seem to find it useful.[...]
Applied to 5.20/scsi-queue, thanks!
[1/5] scsi: hisi_sas: Call hisi_sas_slave_configure() from slave_configure_v3_hw()
https://git.kernel.org/mkp/scsi/c/eed9f513bf7f [2/5] scsi: hisi_sas: Remove unnecessary variable to hold DMA map elements https://git.kernel.org/mkp/scsi/c/bc22f9c06c25 [3/5] scsi: hisi_sas: Relocate DMA unmap of SMP task https://git.kernel.org/mkp/scsi/c/f0902095a773 [4/5] scsi: hisi_sas: Modify v3 HW SATA completion error processing https://git.kernel.org/mkp/scsi/c/7e15334f5d25 [5/5] scsi: libsas: Resume SAS host for phy reset or enable via sysfs https://git.kernel.org/mkp/scsi/c/1e82e4627a79
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering