scsi: libsas and users: Factor out LLDD TMF code
Subsystems (6)
v2 cover scsi: libsas and users: Factor out LLDD TMF code
The LLDD TMF code is almost identical between hisi_sas, pm8001, and mvsas drivers.
This series factors out that code into libsas, thus reducing much duplication and giving a net reduction of ~350 LoC.
There are some subtle differences between the core TMF handler and each of the LLDDs old implementation, so any review and testing is appreciated.
Some other minor patches are thrown in:
- Delete unused macro in hisi_sas driver
- Delete unused libsas callback
- Delete unused SAS_SG_ERR
- Add enum for response frame datapres field
- Handle unrecognised errors in sas_scsi_find_task()
I have another follow-up series to factor out the internal abort code, which is common to hisi_sas and pm8001 drivers.
Based on mkp-scsi 5.18 staging queue at commit ac2beb4e3bd7
Differences to v1:
- Add Reviewed-by and Tested-by tags (Thanks!)
- Add SAS_SG_ERR patch
- Add sas_scsi_find_task() patch
- Use switch statement in sas_ssp_task_response()
- Add DATAPRES enum in sas.h
- Reword "Add struct sas_tmf_task" patch
- Don't print TMF code in sas_execute_tmf()
- Rebase
John Garry (18):
scsi: libsas: Handle non-TMF codes in sas_scsi_find_task()
scsi: libsas: Use enum for response frame DATAPRES field
scsi: libsas: Delete lldd_clear_aca callback
scsi: libsas: Delete SAS_SG_ERR
scsi: hisi_sas: Delete unused I_T_NEXUS_RESET_PHYUP_TIMEOUT
scsi: libsas: Move SMP task handlers to core
scsi: libsas: Add struct sas_tmf_task
scsi: libsas: Add sas_task.tmf
scsi: libsas: Add sas_execute_tmf()
scsi: libsas: Add sas_execute_ssp_tmf()
scsi: libsas: Add TMF handler exec complete callback
scsi: libsas: Add TMF handler aborted callback
scsi: libsas: Add sas_abort_task_set()
scsi: libsas: Add sas_clear_task_set()
scsi: libsas: Add sas_lu_reset()
scsi: libsas: Add sas_query_task()
scsi: libsas: Add sas_abort_task()
scsi: libsas: Add sas_execute_ata_cmd()
Documentation/scsi/libsas.rst | 2 - drivers/scsi/aic94xx/aic94xx.h | 1 - drivers/scsi/aic94xx/aic94xx_init.c | 1 - drivers/scsi/aic94xx/aic94xx_tmf.c | 11 +- drivers/scsi/hisi_sas/hisi_sas.h | 9 +- drivers/scsi/hisi_sas/hisi_sas_main.c | 227 ++++-------------------- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 2 +- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 9 +- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 +- drivers/scsi/isci/init.c | 1 - drivers/scsi/isci/request.c | 7 +- drivers/scsi/isci/task.c | 18 -- drivers/scsi/isci/task.h | 4 - drivers/scsi/libsas/sas_ata.c | 10 +- drivers/scsi/libsas/sas_expander.c | 24 +-- drivers/scsi/libsas/sas_internal.h | 6 + drivers/scsi/libsas/sas_scsi_host.c | 229 ++++++++++++++++++++++++- drivers/scsi/libsas/sas_task.c | 14 +- drivers/scsi/mvsas/mv_defs.h | 5 - drivers/scsi/mvsas/mv_init.c | 5 +- drivers/scsi/mvsas/mv_sas.c | 179 +------------------ drivers/scsi/mvsas/mv_sas.h | 3 - drivers/scsi/pm8001/pm8001_hwi.c | 4 +- drivers/scsi/pm8001/pm8001_init.c | 5 +- drivers/scsi/pm8001/pm8001_sas.c | 194 ++++----------------- drivers/scsi/pm8001/pm8001_sas.h | 14 +- include/scsi/libsas.h | 24 ++- include/scsi/sas.h | 7 + 28 files changed, 377 insertions(+), 640 deletions(-)
Signature · 1 line
2.26.2
PATCH v2 1/18 scsi: libsas: Handle non-TMF codes in sas_scsi_find_task()
LLDD TMF callbacks may return linux or other error codes instead of TMF codes. This may cause problems in sas_scsi_find_task() -> .lldd_query_task(), as only TMF codes are handled there. As such, we may not return a task_disposition type from sas_scsi_find_task(). Function sas_eh_handle_sas_errors() only handles that type, and will only progress error handling for those recognised types.
Return TASK_ABORT_FAILED upon exit on the assumption that the command may still be alive and error handling should be escalated.
--- drivers/scsi/libsas/sas_scsi_host.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/scsi/libsas/sas_scsi_host.c +4 -2
@@ -316,11 +316,13 @@ static enum task_disposition sas_scsi_find_task(struct sas_task *task)pr_notice ("%s: task 0x%p failed to abort\n" , __func__, task);return TASK_ABORT_FAILED ; +default : +pr_notice ("%s: task 0x%p result code %d not handled\n" , + __func__, task, res); } - } } -return res; +return TASK_ABORT_FAILED ; }static int sas_recover_lu (struct domain_device *dev,struct scsi_cmnd *cmd)
Signature · 1 line
2.26.2
PATCH v2 2/18 scsi: libsas: Use enum for response frame DATAPRES field
In reply to John GarryAs defined in table 126 of the SAS spec 1.1, use an enum for the DATAPRES field, which makes reading the code easier.
Also change sas_ssp_task_response() to use a switch statement, which is more suitable (than if-else), as suggested by Christoph.
--- drivers/scsi/aic94xx/aic94xx_tmf.c | 2 +- drivers/scsi/isci/request.c | 7 ++++--- drivers/scsi/libsas/sas_task.c | 14 +++++++++----- drivers/scsi/mvsas/mv_sas.c | 2 +- include/scsi/sas.h | 7 +++++++ 5 files changed, 22 insertions(+), 10 deletions(-)
drivers/scsi/aic94xx/aic94xx_tmf.c +1 -1
@@ -287,7 +287,7 @@ static int asd_get_tmf_resp_tasklet(struct asd_ascb *ascb, fh = edb->vaddr +16 ; ru = edb->vaddr +16 +sizeof (*fh); res = ru->status; -if (ru->datapres ==1 )/* Response data present */ +if (ru->datapres ==SAS_DATAPRES_RESPONSE_DATA ) res = ru->resp_data[3 ];#if 0 ascb->tag = fh->tag;
drivers/scsi/isci/request.c +4 -3
@@ -1047,7 +1047,8 @@ request_started_state_tc_event(struct isci_request *ireq, resp_iu = &ireq->ssp.rsp; datapres = resp_iu->datapres; -if (datapres ==1 || datapres ==2 ) { +if (datapres ==SAS_DATAPRES_RESPONSE_DATA || + datapres ==SAS_DATAPRES_SENSE_DATA ) { ireq->scu_status =SCU_TASK_DONE_CHECK_RESPONSE ; ireq->sci_status =SCI_FAILURE_IO_RESPONSE_VALID ; }else {
@@ -1730,8 +1731,8 @@ sci_io_request_frame_handler(struct isci_request *ireq, resp_iu = &ireq->ssp.rsp; -if (resp_iu->datapres ==0x01 || - resp_iu->datapres ==0x02 ) { +if (resp_iu->datapres ==SAS_DATAPRES_RESPONSE_DATA || + resp_iu->datapres ==SAS_DATAPRES_SENSE_DATA ) { ireq->scu_status =SCU_TASK_DONE_CHECK_RESPONSE ; ireq->sci_status =SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR ; }else {
drivers/scsi/libsas/sas_task.c +9 -5
@@ -15,11 +15,14 @@ void sas_ssp_task_response(struct device *dev, struct sas_task *task, tstat->resp =SAS_TASK_COMPLETE ; -if (iu->datapres ==0 ) +switch (iu->datapres) { +case SAS_DATAPRES_NO_DATA : tstat->stat = iu->status; -else if (iu->datapres ==1 ) +break ; +case SAS_DATAPRES_RESPONSE_DATA : tstat->stat = iu->resp_data[3 ]; -else if (iu->datapres ==2 ) { +break ; +case SAS_DATAPRES_SENSE_DATA : tstat->stat =SAS_SAM_STAT_CHECK_CONDITION ; tstat->buf_valid_size = min_t(int, SAS_STATUS_BUF_SIZE,
@@ -29,10 +32,11 @@ void sas_ssp_task_response(struct device *dev, struct sas_task *task,if (iu->status !=SAM_STAT_CHECK_CONDITION )dev_warn (dev,"dev %016llx sent sense data, but stat(0x%x) is not CHECK CONDITION\n" ,SAS_ADDR (task->dev->sas_addr), iu->status); - } -else +break ; +default :/* when datapres contains corrupt/unknown value... */ tstat->stat =SAS_SAM_STAT_CHECK_CONDITION ; + } }EXPORT_SYMBOL_GPL (sas_ssp_task_response);
drivers/scsi/mvsas/mv_sas.c +1 -1
@@ -1638,7 +1638,7 @@ static void mvs_set_sense(u8 *buffer, int len, int d_sense,static void mvs_fill_ssp_resp_iu (struct ssp_response_iu *iu,u8 key,u8 asc,u8 asc_q) { - iu->datapres =2 ; + iu->datapres =SAS_DATAPRES_SENSE_DATA ; iu->response_data_len =0 ; iu->sense_data_len =17 ; iu->status =02 ;
include/scsi/sas.h +7 -0
@@ -191,6 +191,13 @@ enum sas_gpio_reg_type { SAS_GPIO_REG_TX_GP = 4, }; +/* Response frame DATAPRES field */ +enum { +SAS_DATAPRES_NO_DATA =0 , +SAS_DATAPRES_RESPONSE_DATA =1 , +SAS_DATAPRES_SENSE_DATA =2 , +}; +struct dev_to_host_fis {u8 fis_type;/* 0x34 */ u8 flags;
Signature · 1 line
2.26.2
PATCH v2 3/18 scsi: libsas: Delete lldd_clear_aca callback
In reply to John GarryThis callback is never called, so remove support.
--- Documentation/scsi/libsas.rst | 2 -- drivers/scsi/aic94xx/aic94xx.h | 1 - drivers/scsi/aic94xx/aic94xx_init.c | 1 - drivers/scsi/aic94xx/aic94xx_tmf.c | 9 --------- drivers/scsi/hisi_sas/hisi_sas_main.c | 12 ------------ drivers/scsi/isci/init.c | 1 - drivers/scsi/isci/task.c | 18 ------------------ drivers/scsi/isci/task.h | 4 ---- drivers/scsi/mvsas/mv_init.c | 1 - drivers/scsi/mvsas/mv_sas.c | 11 ----------- drivers/scsi/mvsas/mv_sas.h | 1 - drivers/scsi/pm8001/pm8001_init.c | 1 - drivers/scsi/pm8001/pm8001_sas.c | 8 -------- drivers/scsi/pm8001/pm8001_sas.h | 1 - include/scsi/libsas.h | 1 - 15 files changed, 72 deletions(-)
Documentation/scsi/libsas.rst +0 -2
@@ -207,7 +207,6 @@ Management Functions (TMFs) described in SAM:: /* Task Management Functions. Must be called from process context. */ int (*lldd_abort_task)(struct sas_task *); int (*lldd_abort_task_set)(struct domain_device *, u8 *lun); - int (*lldd_clear_aca)(struct domain_device *, u8 *lun); int (*lldd_clear_task_set)(struct domain_device *, u8 *lun); int (*lldd_I_T_nexus_reset)(struct domain_device *); int (*lldd_lu_reset)(struct domain_device *, u8 *lun);
@@ -262,7 +261,6 @@ can look like this (called last thing from probe()) my_ha->sas_ha.lldd_abort_task = my_abort_task; my_ha->sas_ha.lldd_abort_task_set = my_abort_task_set; - my_ha->sas_ha.lldd_clear_aca = my_clear_aca; my_ha->sas_ha.lldd_clear_task_set = my_clear_task_set; my_ha->sas_ha.lldd_I_T_nexus_reset= NULL; (2) my_ha->sas_ha.lldd_lu_reset = my_lu_reset;
drivers/scsi/aic94xx/aic94xx.h +0 -1
@@ -60,7 +60,6 @@ void asd_set_dmamode(struct domain_device *dev);/* ---------- TMFs ---------- */ int asd_abort_task (struct sas_task *);int asd_abort_task_set (struct domain_device *,u8 *lun); -int asd_clear_aca (struct domain_device *,u8 *lun);int asd_clear_task_set (struct domain_device *,u8 *lun);int asd_lu_reset (struct domain_device *,u8 *lun);int asd_I_T_nexus_reset (struct domain_device *dev);
drivers/scsi/aic94xx/aic94xx_init.c +0 -1
@@ -960,7 +960,6 @@ static struct sas_domain_function_template aic94xx_transport_functions = { .lldd_abort_task = asd_abort_task, .lldd_abort_task_set = asd_abort_task_set, - .lldd_clear_aca = asd_clear_aca, .lldd_clear_task_set = asd_clear_task_set, .lldd_I_T_nexus_reset = asd_I_T_nexus_reset, .lldd_lu_reset = asd_lu_reset,
drivers/scsi/aic94xx/aic94xx_tmf.c +0 -9
@@ -644,15 +644,6 @@ int asd_abort_task_set(struct domain_device *dev, u8 *lun)return res; } -int asd_clear_aca (struct domain_device *dev,u8 *lun) -{ -int res =asd_initiate_ssp_tmf (dev, lun,TMF_CLEAR_ACA ,0 ); - -if (res ==TMF_RESP_FUNC_COMPLETE ) -asd_clear_nexus_I_T_L (dev, lun); -return res; -} -int asd_clear_task_set (struct domain_device *dev,u8 *lun) {int res =asd_initiate_ssp_tmf (dev, lun,TMF_CLEAR_TASK_SET ,0 );
drivers/scsi/hisi_sas/hisi_sas_main.c +0 -12
@@ -1793,17 +1793,6 @@ static int hisi_sas_abort_task_set(struct domain_device *device, u8 *lun)return rc; } -static int hisi_sas_clear_aca (struct domain_device *device,u8 *lun) -{ -struct hisi_sas_tmf_task tmf_task; -int rc; - - tmf_task.tmf =TMF_CLEAR_ACA ; - rc =hisi_sas_debug_issue_ssp_tmf (device, lun, &tmf_task); - -return rc; -} -#define I_T_NEXUS_RESET_PHYUP_TIMEOUT (2 * HZ)static int hisi_sas_debug_I_T_nexus_reset (struct domain_device *device)
@@ -2333,7 +2322,6 @@ static struct sas_domain_function_template hisi_sas_transport_ops = { .lldd_control_phy = hisi_sas_control_phy, .lldd_abort_task = hisi_sas_abort_task, .lldd_abort_task_set = hisi_sas_abort_task_set, - .lldd_clear_aca = hisi_sas_clear_aca, .lldd_I_T_nexus_reset = hisi_sas_I_T_nexus_reset, .lldd_lu_reset = hisi_sas_lu_reset, .lldd_query_task = hisi_sas_query_task,
drivers/scsi/isci/init.c +0 -1
@@ -193,7 +193,6 @@ static struct sas_domain_function_template isci_transport_ops = {/* Task Management Functions. Must be called from process context. */ .lldd_abort_task = isci_task_abort_task, .lldd_abort_task_set = isci_task_abort_task_set, - .lldd_clear_aca = isci_task_clear_aca, .lldd_clear_task_set = isci_task_clear_task_set, .lldd_I_T_nexus_reset = isci_task_I_T_nexus_reset, .lldd_lu_reset = isci_task_lu_reset,
drivers/scsi/isci/task.c +0 -18
@@ -620,24 +620,6 @@ int isci_task_abort_task_set( } -/** -* isci_task_clear_aca() - This function is one of the SAS Domain Template -* functions. This is one of the Task Management functoins called by libsas. -* @d_device: This parameter specifies the domain device associated with this -* request. -* @lun: This parameter specifies the lun associated with this request. -* -* status, zero indicates success. -*/ -int isci_task_clear_aca ( -struct domain_device *d_device, -u8 *lun) -{ -return TMF_RESP_FUNC_FAILED ; -} - - -/** * isci_task_clear_task_set() - This function is one of the SAS Domain Template * functions. This is one of the Task Management functoins called by libsas.
drivers/scsi/isci/task.h +0 -4
@@ -140,10 +140,6 @@ int isci_task_abort_task_set(struct domain_device *d_device, u8 *lun); -int isci_task_clear_aca ( -struct domain_device *d_device, -u8 *lun); -int isci_task_clear_task_set (struct domain_device *d_device,u8 *lun);
drivers/scsi/mvsas/mv_init.c +0 -1
@@ -64,7 +64,6 @@ static struct sas_domain_function_template mvs_transport_ops = { .lldd_abort_task = mvs_abort_task, .lldd_abort_task_set = mvs_abort_task_set, - .lldd_clear_aca = mvs_clear_aca, .lldd_clear_task_set = mvs_clear_task_set, .lldd_I_T_nexus_reset = mvs_I_T_nexus_reset, .lldd_lu_reset = mvs_lu_reset,
drivers/scsi/mvsas/mv_sas.c +0 -11
@@ -1550,17 +1550,6 @@ int mvs_abort_task_set(struct domain_device *dev, u8 *lun)return rc; } -int mvs_clear_aca (struct domain_device *dev,u8 *lun) -{ -int rc =TMF_RESP_FUNC_FAILED ; -struct mvs_tmf_task tmf_task; - - tmf_task.tmf =TMF_CLEAR_ACA ; - rc =mvs_debug_issue_ssp_tmf (dev, lun, &tmf_task); - -return rc; -} -int mvs_clear_task_set (struct domain_device *dev,u8 *lun) {int rc =TMF_RESP_FUNC_FAILED ;
drivers/scsi/mvsas/mv_sas.h +0 -1
@@ -441,7 +441,6 @@ int mvs_scan_finished(struct Scsi_Host *shost, unsigned long time);int mvs_queue_command (struct sas_task *task,gfp_t gfp_flags);int mvs_abort_task (struct sas_task *task);int mvs_abort_task_set (struct domain_device *dev,u8 *lun); -int mvs_clear_aca (struct domain_device *dev,u8 *lun);int mvs_clear_task_set (struct domain_device *dev,u8 * lun);void mvs_port_formed (struct asd_sas_phy *sas_phy);void mvs_port_deformed (struct asd_sas_phy *sas_phy);
drivers/scsi/pm8001/pm8001_init.c +0 -1
@@ -123,7 +123,6 @@ static struct sas_domain_function_template pm8001_transport_ops = { .lldd_abort_task = pm8001_abort_task, .lldd_abort_task_set = pm8001_abort_task_set, - .lldd_clear_aca = pm8001_clear_aca, .lldd_clear_task_set = pm8001_clear_task_set, .lldd_I_T_nexus_reset = pm8001_I_T_nexus_reset, .lldd_lu_reset = pm8001_lu_reset,
drivers/scsi/pm8001/pm8001_sas.c +0 -8
@@ -1358,14 +1358,6 @@ int pm8001_abort_task_set(struct domain_device *dev, u8 *lun)return pm8001_issue_ssp_tmf (dev, lun, &tmf_task); } -int pm8001_clear_aca (struct domain_device *dev,u8 *lun) -{ -struct pm8001_tmf_task tmf_task; - - tmf_task.tmf =TMF_CLEAR_ACA ; -return pm8001_issue_ssp_tmf (dev, lun, &tmf_task); -} -int pm8001_clear_task_set (struct domain_device *dev,u8 *lun) {struct pm8001_tmf_task tmf_task;
drivers/scsi/pm8001/pm8001_sas.h +0 -1
@@ -649,7 +649,6 @@ int pm8001_scan_finished(struct Scsi_Host *shost, unsigned long time);int pm8001_queue_command (struct sas_task *task,gfp_t gfp_flags);int pm8001_abort_task (struct sas_task *task);int pm8001_abort_task_set (struct domain_device *dev,u8 *lun); -int pm8001_clear_aca (struct domain_device *dev,u8 *lun);int pm8001_clear_task_set (struct domain_device *dev,u8 *lun);int pm8001_dev_found (struct domain_device *dev);void pm8001_dev_gone (struct domain_device *dev);
include/scsi/libsas.h +0 -1
@@ -636,7 +636,6 @@ struct sas_domain_function_template {/* Task Management Functions. Must be called from process context. */ int (*lldd_abort_task)(struct sas_task *);int (*lldd_abort_task_set)(struct domain_device *,u8 *lun); -int (*lldd_clear_aca)(struct domain_device *,u8 *lun);int (*lldd_clear_task_set)(struct domain_device *,u8 *lun);int (*lldd_I_T_nexus_reset)(struct domain_device *);int (*lldd_ata_check_ready)(struct domain_device *);
Signature · 1 line
2.26.2
PATCH v2 4/18 scsi: libsas: Delete SAS_SG_ERR
In reply to John GarryNo LLDD sets exec status as SAS_SG_ERR, so remove support.
--- drivers/scsi/libsas/sas_ata.c | 2 -- drivers/scsi/libsas/sas_scsi_host.c | 3 --- include/scsi/libsas.h | 1 - 3 files changed, 6 deletions(-)
drivers/scsi/libsas/sas_ata.c +0 -2
@@ -52,8 +52,6 @@ static enum ata_completion_errors sas_to_ata_err(struct task_status_struct *ts)case SAS_DATA_OVERRUN :case SAS_QUEUE_FULL :case SAS_DEVICE_UNKNOWN : -case SAS_SG_ERR : -return AC_ERR_INVALID ;case SAS_OPEN_TO :case SAS_OPEN_REJECT : pr_warn("%s: Saw error %d. What to do?\n",
drivers/scsi/libsas/sas_scsi_host.c +0 -3
@@ -67,9 +67,6 @@ static void sas_end_task(struct scsi_cmnd *sc, struct sas_task *task)case SAS_DEVICE_UNKNOWN : hs =DID_BAD_TARGET ;break ; -case SAS_SG_ERR : - hs =DID_PARITY ; -break ;case SAS_OPEN_REJECT :if (ts->open_rej_reason ==SAS_OREJ_RSVD_RETRY ) hs =DID_SOFT_ERROR ;/* retry */
include/scsi/libsas.h +0 -1
@@ -492,7 +492,6 @@ enum exec_status {SAS_INTERRUPTED ,SAS_QUEUE_FULL ,SAS_DEVICE_UNKNOWN , -SAS_SG_ERR ,SAS_OPEN_REJECT ,SAS_OPEN_TO , SAS_PROTO_RESPONSE,
Signature · 1 line
2.26.2
PATCH v2 5/18 scsi: hisi_sas: Delete unused I_T_NEXUS_RESET_PHYUP_TIMEOUT
In reply to John GarryThere is no user, so delete it.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 2 -- 1 file changed, 2 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +0 -2
@@ -1793,8 +1793,6 @@ static int hisi_sas_abort_task_set(struct domain_device *device, u8 *lun)return rc; } -#define I_T_NEXUS_RESET_PHYUP_TIMEOUT (2 * HZ) -static int hisi_sas_debug_I_T_nexus_reset (struct domain_device *device) {struct sas_phy *local_phy =sas_get_local_phy (device);
Signature · 1 line
2.26.2
PATCH v2 6/18 scsi: libsas: Move SMP task handlers to core
In reply to John GarryMove the SMP task handlers to the core host code as they will be re-used for executing internal abort and TMF tasks.
--- drivers/scsi/libsas/sas_expander.c | 24 ++---------------------- drivers/scsi/libsas/sas_internal.h | 3 +++ drivers/scsi/libsas/sas_scsi_host.c | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 22 deletions(-)
drivers/scsi/libsas/sas_expander.c +2 -22
@@ -28,26 +28,6 @@ static int sas_disable_routing(struct domain_device *dev, u8 *sas_addr);/* ---------- SMP task management ---------- */ -static void smp_task_timedout (struct timer_list *t) -{ -struct sas_task_slow *slow =from_timer (slow, t, timer); -struct sas_task *task = slow->task; -unsigned long flags; - -spin_lock_irqsave (&task->task_state_lock, flags); -if (!(task->task_state_flags &SAS_TASK_STATE_DONE )) { - task->task_state_flags |=SAS_TASK_STATE_ABORTED ; -complete (&task->slow_task->completion); - } -spin_unlock_irqrestore (&task->task_state_lock, flags); -} - -static void smp_task_done (struct sas_task *task) -{ -del_timer (&task->slow_task->timer); -complete (&task->slow_task->completion); -} -/* Give it some long enough timeout. In seconds. */ #define SMP_TIMEOUT 10
@@ -78,9 +58,9 @@ static int smp_execute_task_sg(struct domain_device *dev, task->smp_task.smp_req = *req; task->smp_task.smp_resp = *resp; - task->task_done = smp_task_done; + task->task_done = sas_task_internal_done; - task->slow_task->timer.function = smp_task_timedout; + task->slow_task->timer.function = sas_task_internal_timedout; task->slow_task->timer.expires = jiffies +SMP_TIMEOUT *HZ ;add_timer (&task->slow_task->timer);
drivers/scsi/libsas/sas_internal.h +3 -0
@@ -95,6 +95,9 @@ void sas_destruct_devices(struct asd_sas_port *port);extern const work_func_t sas_phy_event_fns[PHY_NUM_EVENTS ];extern const work_func_t sas_port_event_fns[PORT_NUM_EVENTS ]; +void sas_task_internal_done (struct sas_task *task); +void sas_task_internal_timedout (struct timer_list *t); +#ifdef CONFIG_SCSI_SAS_HOST_SMP extern void sas_smp_host_handler (struct bsg_job *job,struct Scsi_Host *shost);#else
drivers/scsi/libsas/sas_scsi_host.c +24 -0
@@ -893,6 +893,30 @@ int sas_bios_param(struct scsi_device *scsi_dev, }EXPORT_SYMBOL_GPL (sas_bios_param); +void sas_task_internal_done (struct sas_task *task) +{ +del_timer (&task->slow_task->timer); +complete (&task->slow_task->completion); +} + +void sas_task_internal_timedout (struct timer_list *t) +{ +struct sas_task_slow *slow =from_timer (slow, t, timer); +struct sas_task *task = slow->task; +bool is_completed = true; +unsigned long flags; + +spin_lock_irqsave (&task->task_state_lock, flags); +if (!(task->task_state_flags &SAS_TASK_STATE_DONE )) { + task->task_state_flags |=SAS_TASK_STATE_ABORTED ; + is_completed = false; + } +spin_unlock_irqrestore (&task->task_state_lock, flags); + +if (!is_completed) +complete (&task->slow_task->completion); +} +/* * Tell an upper layer that it needs to initiate an abort for a given task. * This should only ever be called by an LLDD.
Signature · 1 line
2.26.2
PATCH v2 7/18 scsi: libsas: Add struct sas_tmf_task
In reply to John GarrySome of the LLDDs which use libsas have their own definition of a struct to hold TMF info, so add a common struct for libsas.
Also add an interim force phy id field for hisi_sas driver, which will be removed once the STP "TMF" code is factored out.
Even though some LLDDs (pm8001) use a u32 for the tag, u16 will be adequate, as that named driver only uses tags in range [0, 1024).
--- drivers/scsi/hisi_sas/hisi_sas.h | 9 +-------- drivers/scsi/hisi_sas/hisi_sas_main.c | 22 +++++++++++----------- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 2 +- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 4 ++-- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 +- drivers/scsi/mvsas/mv_defs.h | 5 ----- drivers/scsi/mvsas/mv_sas.c | 20 ++++++++++---------- drivers/scsi/pm8001/pm8001_hwi.c | 4 ++-- drivers/scsi/pm8001/pm8001_sas.c | 18 +++++++++--------- drivers/scsi/pm8001/pm8001_sas.h | 10 +++------- include/scsi/libsas.h | 9 +++++++++ 11 files changed, 49 insertions(+), 56 deletions(-)
drivers/scsi/hisi_sas/hisi_sas.h +1 -8
@@ -234,13 +234,6 @@ struct hisi_sas_device {spinlock_t lock;/* For protecting slots */ }; -struct hisi_sas_tmf_task { -int force_phy; -int phy_id; -u8 tmf; -u16 tag_of_task_to_be_managed; -}; -struct hisi_sas_slot {struct list_head entry;struct list_head delivery;
@@ -259,7 +252,7 @@ struct hisi_sas_slot {dma_addr_t cmd_hdr_dma;struct timer_list internal_abort_timer;bool is_internal; -struct hisi_sas_tmf_task *tmf; +struct sas_tmf_task *tmf;/* Do not reorder/change members after here */ void *buf;dma_addr_t buf_dma;
drivers/scsi/hisi_sas/hisi_sas_main.c +11 -11
@@ -11,7 +11,7 @@ ((!dev) || (dev->dev_type == SAS_PHY_UNUSED))static int hisi_sas_debug_issue_ssp_tmf (struct domain_device *device, -u8 *lun,struct hisi_sas_tmf_task *tmf); +u8 *lun,struct sas_tmf_task *tmf); static int hisi_sas_internal_task_abort(struct hisi_hba *hisi_hba, struct domain_device *device,
@@ -464,7 +464,7 @@ void hisi_sas_task_deliver(struct hisi_hba *hisi_hba, }static int hisi_sas_task_exec (struct sas_task *task,gfp_t gfp_flags, -struct hisi_sas_tmf_task *tmf) +struct sas_tmf_task *tmf) {int n_elem =0 , n_elem_dif =0 , n_elem_req =0 ;struct domain_device *device = task->dev;
@@ -672,7 +672,7 @@ static int hisi_sas_init_device(struct domain_device *device) {int rc =TMF_RESP_FUNC_COMPLETE ;struct scsi_lun lun; -struct hisi_sas_tmf_task tmf_task; +struct sas_tmf_task tmf_task;int retry =HISI_SAS_DISK_RECOVER_CNT ;struct hisi_hba *hisi_hba =dev_to_hisi_hba (device);struct device *dev = hisi_hba->dev;
@@ -1236,7 +1236,7 @@ static void hisi_sas_tmf_timedout(struct timer_list *t)#define INTERNAL_ABORT_TIMEOUT (6 * HZ)static int hisi_sas_exec_internal_tmf_task (struct domain_device *device,void *parameter,u32 para_len, -struct hisi_sas_tmf_task *tmf) +struct sas_tmf_task *tmf) {struct hisi_sas_device *sas_dev = device->lldd_dev;struct hisi_hba *hisi_hba = sas_dev->hisi_hba;
@@ -1371,7 +1371,7 @@ static int hisi_sas_softreset_ata_disk(struct domain_device *device)struct hisi_hba *hisi_hba =dev_to_hisi_hba (device);struct device *dev = hisi_hba->dev;int s =sizeof (struct host_to_dev_fis ); -struct hisi_sas_tmf_task tmf = {}; +struct sas_tmf_task tmf = {};ata_for_each_link (link, ap,EDGE ) {int pmp =sata_srst_pmp (link);
@@ -1405,7 +1405,7 @@ static int hisi_sas_softreset_ata_disk(struct domain_device *device) }static int hisi_sas_debug_issue_ssp_tmf (struct domain_device *device, -u8 *lun,struct hisi_sas_tmf_task *tmf) +u8 *lun,struct sas_tmf_task *tmf) {struct sas_ssp_task ssp_task;
@@ -1512,7 +1512,7 @@ static void hisi_sas_send_ata_reset_each_phy(struct hisi_hba *hisi_hba,struct asd_sas_port *sas_port, struct domain_device *device) { - struct hisi_sas_tmf_task tmf_task = { .force_phy = 1 }; + struct sas_tmf_task tmf_task = { .force_phy = 1 };struct ata_port *ap = device->sata_dev.ap;struct device *dev = hisi_hba->dev;int s =sizeof (struct host_to_dev_fis );
@@ -1664,7 +1664,7 @@ static int hisi_sas_controller_reset(struct hisi_hba *hisi_hba)static int hisi_sas_abort_task (struct sas_task *task) {struct scsi_lun lun; -struct hisi_sas_tmf_task tmf_task; +struct sas_tmf_task tmf_task;struct domain_device *device = task->dev;struct hisi_sas_device *sas_dev = device->lldd_dev;struct hisi_hba *hisi_hba;
@@ -1773,7 +1773,7 @@ static int hisi_sas_abort_task_set(struct domain_device *device, u8 *lun) {struct hisi_hba *hisi_hba =dev_to_hisi_hba (device);struct device *dev = hisi_hba->dev; -struct hisi_sas_tmf_task tmf_task; +struct sas_tmf_task tmf_task;int rc; rc = hisi_sas_internal_task_abort(hisi_hba, device,
@@ -1924,7 +1924,7 @@ static int hisi_sas_lu_reset(struct domain_device *device, u8 *lun)hisi_sas_release_task (hisi_hba, device);sas_put_local_phy (phy); }else { -struct hisi_sas_tmf_task tmf_task = { .tmf =TMF_LU_RESET }; +struct sas_tmf_task tmf_task = { .tmf =TMF_LU_RESET }; rc =hisi_sas_debug_issue_ssp_tmf (device, lun, &tmf_task);if (rc ==TMF_RESP_FUNC_COMPLETE )
@@ -1982,7 +1982,7 @@ static int hisi_sas_clear_nexus_ha(struct sas_ha_struct *sas_ha)static int hisi_sas_query_task (struct sas_task *task) {struct scsi_lun lun; -struct hisi_sas_tmf_task tmf_task; +struct sas_tmf_task tmf_task;int rc =TMF_RESP_FUNC_FAILED ;if (task->lldd_task && task->task_proto &SAS_PROTOCOL_SSP ) {
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +1 -1
@@ -958,7 +958,7 @@ static void prep_ssp_v1_hw(struct hisi_hba *hisi_hba,struct hisi_sas_port *port = slot->port;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; +struct sas_tmf_task *tmf = slot->tmf;int has_data =0 , priority = !!tmf;u8 *buf_cmd, fburst =0 ;u32 dw1, dw2;
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +2 -2
@@ -1742,7 +1742,7 @@ static void prep_ssp_v2_hw(struct hisi_hba *hisi_hba,struct hisi_sas_port *port = slot->port;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; +struct sas_tmf_task *tmf = slot->tmf;int has_data =0 , priority = !!tmf;u8 *buf_cmd;u32 dw1 =0 , dw2 =0 ;
@@ -2491,7 +2491,7 @@ static void prep_ata_v2_hw(struct hisi_hba *hisi_hba,struct hisi_sas_cmd_hdr *hdr = slot->cmd_hdr;struct asd_sas_port *sas_port = device->port;struct hisi_sas_port *port =to_hisi_sas_port (sas_port); -struct hisi_sas_tmf_task *tmf = slot->tmf; +struct sas_tmf_task *tmf = slot->tmf;u8 *buf_cmd;int has_data =0 , hdr_tag =0 ;u32 dw0, dw1 =0 , dw2 =0 ;
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +1 -1
@@ -1219,7 +1219,7 @@ static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba,struct hisi_sas_port *port = slot->port;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; +struct sas_tmf_task *tmf = slot->tmf;int has_data =0 , priority = !!tmf;unsigned char prot_op;u8 *buf_cmd;
drivers/scsi/mvsas/mv_defs.h +0 -5
@@ -486,9 +486,4 @@ enum datapres_field { SENSE_DATA = 2, }; -/* define task management IU */ -struct mvs_tmf_task { -u8 tmf; -u16 tag_of_task_to_be_managed; -};#endif
drivers/scsi/mvsas/mv_sas.c +10 -10
@@ -556,7 +556,7 @@ static int mvs_task_prep_ata(struct mvs_info *mvi,static int mvs_task_prep_ssp (struct mvs_info *mvi,struct mvs_task_exec_info *tei,int is_tmf, -struct mvs_tmf_task *tmf) +struct sas_tmf_task *tmf) {struct sas_task *task = tei->task;struct mvs_cmd_hdr *hdr = tei->hdr;
@@ -696,7 +696,7 @@ static int mvs_task_prep_ssp(struct mvs_info *mvi,#define DEV_IS_GONE (mvi_dev) ((!mvi_dev || (mvi_dev->dev_type == SAS_PHY_UNUSED)))static int mvs_task_prep (struct sas_task *task,struct mvs_info *mvi,int is_tmf, -struct mvs_tmf_task *tmf,int *pass) +struct sas_tmf_task *tmf,int *pass) {struct domain_device *dev = task->dev;struct mvs_device *mvi_dev = dev->lldd_dev;
@@ -839,7 +839,7 @@ static int mvs_task_prep(struct sas_task *task, struct mvs_info *mvi, int is_tmfstatic int mvs_task_exec (struct sas_task *task,gfp_t gfp_flags,struct completion *completion,int is_tmf, -struct mvs_tmf_task *tmf) +struct sas_tmf_task *tmf) {struct mvs_info *mvi =NULL ;u32 rc =0 ;
@@ -1277,7 +1277,7 @@ static void mvs_tmf_timedout(struct timer_list *t)#define MVS_TASK_TIMEOUT 20static int mvs_exec_internal_tmf_task (struct domain_device *dev, -void *parameter,u32 para_len,struct mvs_tmf_task *tmf) +void *parameter,u32 para_len,struct sas_tmf_task *tmf) {int res, retry;struct sas_task *task =NULL ;
@@ -1352,7 +1352,7 @@ static int mvs_exec_internal_tmf_task(struct domain_device *dev, }static int mvs_debug_issue_ssp_tmf (struct domain_device *dev, -u8 *lun,struct mvs_tmf_task *tmf) +u8 *lun,struct sas_tmf_task *tmf) {struct sas_ssp_task ssp_task;if (!(dev->tproto &SAS_PROTOCOL_SSP ))
@@ -1384,7 +1384,7 @@ int mvs_lu_reset(struct domain_device *dev, u8 *lun) {unsigned long flags;int rc =TMF_RESP_FUNC_FAILED ; -struct mvs_tmf_task tmf_task; +struct sas_tmf_task tmf_task;struct mvs_device * mvi_dev = dev->lldd_dev;struct mvs_info *mvi = mvi_dev->mvi_info;
@@ -1428,7 +1428,7 @@ int mvs_query_task(struct sas_task *task) {u32 tag;struct scsi_lun lun; -struct mvs_tmf_task tmf_task; +struct sas_tmf_task tmf_task;int rc =TMF_RESP_FUNC_FAILED ;if (task->lldd_task && task->task_proto &SAS_PROTOCOL_SSP ) {
@@ -1465,7 +1465,7 @@ int mvs_query_task(struct sas_task *task)int mvs_abort_task (struct sas_task *task) {struct scsi_lun lun; -struct mvs_tmf_task tmf_task; +struct sas_tmf_task tmf_task;struct domain_device *dev = task->dev;struct mvs_device *mvi_dev = (struct mvs_device *)dev->lldd_dev;struct mvs_info *mvi;
@@ -1542,7 +1542,7 @@ int mvs_abort_task(struct sas_task *task)int mvs_abort_task_set (struct domain_device *dev,u8 *lun) {int rc; -struct mvs_tmf_task tmf_task; +struct sas_tmf_task tmf_task; tmf_task.tmf =TMF_ABORT_TASK_SET ; rc =mvs_debug_issue_ssp_tmf (dev, lun, &tmf_task);
@@ -1553,7 +1553,7 @@ int mvs_abort_task_set(struct domain_device *dev, u8 *lun)int mvs_clear_task_set (struct domain_device *dev,u8 *lun) {int rc =TMF_RESP_FUNC_FAILED ; -struct mvs_tmf_task tmf_task; +struct sas_tmf_task tmf_task; tmf_task.tmf =TMF_CLEAR_TASK_SET ; rc =mvs_debug_issue_ssp_tmf (dev, lun, &tmf_task);
drivers/scsi/pm8001/pm8001_hwi.c +2 -2
@@ -4602,7 +4602,7 @@ int pm8001_chip_abort_task(struct pm8001_hba_info *pm8001_ha,* @tmf: task management function. */ int pm8001_chip_ssp_tm_req (struct pm8001_hba_info *pm8001_ha, -struct pm8001_ccb_info *ccb,struct pm8001_tmf_task *tmf) +struct pm8001_ccb_info *ccb,struct sas_tmf_task *tmf) {struct sas_task *task = ccb->task;struct domain_device *dev = task->dev;
@@ -4614,7 +4614,7 @@ int pm8001_chip_ssp_tm_req(struct pm8001_hba_info *pm8001_ha,memset (&sspTMCmd,0 ,sizeof (sspTMCmd)); sspTMCmd.device_id =cpu_to_le32 (pm8001_dev->device_id); - sspTMCmd.relate_tag =cpu_to_le32 (tmf->tag_of_task_to_be_managed); + sspTMCmd.relate_tag =cpu_to_le32 ((u32 )tmf->tag_of_task_to_be_managed); sspTMCmd.tmf =cpu_to_le32 (tmf->tmf);memcpy (sspTMCmd.lun, task->ssp_task.LUN,8 ); sspTMCmd.tag =cpu_to_le32 (ccb->ccb_tag);
drivers/scsi/pm8001/pm8001_sas.c +9 -9
@@ -336,7 +336,7 @@ static int pm8001_task_prep_ata(struct pm8001_hba_info *pm8001_ha,* @tmf: the task management IU */ static int pm8001_task_prep_ssp_tm (struct pm8001_hba_info *pm8001_ha, -struct pm8001_ccb_info *ccb,struct pm8001_tmf_task *tmf) +struct pm8001_ccb_info *ccb,struct sas_tmf_task *tmf) {return PM8001_CHIP_DISP ->ssp_tm_req (pm8001_ha, ccb, tmf); }
@@ -379,7 +379,7 @@ static int sas_find_local_port_id(struct domain_device *dev)* @tmf: the task management IU */ static int pm8001_task_exec (struct sas_task *task, -gfp_t gfp_flags,int is_tmf,struct pm8001_tmf_task *tmf) +gfp_t gfp_flags,int is_tmf,struct sas_tmf_task *tmf) {struct domain_device *dev = task->dev;struct pm8001_hba_info *pm8001_ha;
@@ -728,7 +728,7 @@ static void pm8001_tmf_timedout(struct timer_list *t)* this function, note it is also with the task execute interface. */ static int pm8001_exec_internal_tmf_task (struct domain_device *dev, -void *parameter,u32 para_len,struct pm8001_tmf_task *tmf) +void *parameter,u32 para_len,struct sas_tmf_task *tmf) {int res, retry;struct sas_task *task =NULL ;
@@ -919,7 +919,7 @@ void pm8001_dev_gone(struct domain_device *dev) }static int pm8001_issue_ssp_tmf (struct domain_device *dev, -u8 *lun,struct pm8001_tmf_task *tmf) +u8 *lun,struct sas_tmf_task *tmf) {struct sas_ssp_task ssp_task;if (!(dev->tproto &SAS_PROTOCOL_SSP ))
@@ -1120,7 +1120,7 @@ int pm8001_I_T_nexus_event_handler(struct domain_device *dev)int pm8001_lu_reset (struct domain_device *dev,u8 *lun) {int rc =TMF_RESP_FUNC_FAILED ; -struct pm8001_tmf_task tmf_task; +struct sas_tmf_task tmf_task;struct pm8001_device *pm8001_dev = dev->lldd_dev;struct pm8001_hba_info *pm8001_ha =pm8001_find_ha_by_dev (dev);DECLARE_COMPLETION_ONSTACK (completion_setstate);
@@ -1149,7 +1149,7 @@ int pm8001_query_task(struct sas_task *task) {u32 tag =0xdeadbeef ;struct scsi_lun lun; -struct pm8001_tmf_task tmf_task; +struct sas_tmf_task tmf_task;int rc =TMF_RESP_FUNC_FAILED ;if (unlikely (!task || !task->lldd_task || !task->dev))return rc;
@@ -1198,7 +1198,7 @@ int pm8001_abort_task(struct sas_task *task)struct pm8001_hba_info *pm8001_ha;struct scsi_lun lun;struct pm8001_device *pm8001_dev; -struct pm8001_tmf_task tmf_task; +struct sas_tmf_task tmf_task;int rc =TMF_RESP_FUNC_FAILED , ret;u32 phy_id, port_id;struct sas_task_slow slow_task;
@@ -1352,7 +1352,7 @@ int pm8001_abort_task(struct sas_task *task)int pm8001_abort_task_set (struct domain_device *dev,u8 *lun) { -struct pm8001_tmf_task tmf_task; +struct sas_tmf_task tmf_task; tmf_task.tmf =TMF_ABORT_TASK_SET ;return pm8001_issue_ssp_tmf (dev, lun, &tmf_task);
@@ -1360,7 +1360,7 @@ int pm8001_abort_task_set(struct domain_device *dev, u8 *lun)int pm8001_clear_task_set (struct domain_device *dev,u8 *lun) { -struct pm8001_tmf_task tmf_task; +struct sas_tmf_task tmf_task;struct pm8001_device *pm8001_dev = dev->lldd_dev;struct pm8001_hba_info *pm8001_ha =pm8001_find_ha_by_dev (dev);
drivers/scsi/pm8001/pm8001_sas.h +3 -7
@@ -99,11 +99,7 @@ extern const struct pm8001_dispatch pm8001_80xx_dispatch;struct pm8001_hba_info ;struct pm8001_ccb_info ;struct pm8001_device ; -/* define task management IU */ -struct pm8001_tmf_task { -u8 tmf; -u32 tag_of_task_to_be_managed; -}; +struct pm8001_ioctl_payload {u32 signature;u16 major_function;
@@ -203,7 +199,7 @@ struct pm8001_dispatch { struct pm8001_device *pm8001_dev, u8 flag, u32 task_tag, u32 cmd_tag);int (*ssp_tm_req)(struct pm8001_hba_info *pm8001_ha, -struct pm8001_ccb_info *ccb,struct pm8001_tmf_task *tmf); +struct pm8001_ccb_info *ccb,struct sas_tmf_task *tmf);int (*get_nvmd_req)(struct pm8001_hba_info *pm8001_ha,void *payload);int (*set_nvmd_req)(struct pm8001_hba_info *pm8001_ha,void *payload); int (*fw_flash_update_req)(struct pm8001_hba_info *pm8001_ha,
@@ -687,7 +683,7 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha, void *payload);int pm8001_chip_get_nvmd_req (struct pm8001_hba_info *pm8001_ha,void *payload);int pm8001_chip_ssp_tm_req (struct pm8001_hba_info *pm8001_ha,struct pm8001_ccb_info *ccb, -struct pm8001_tmf_task *tmf); +struct sas_tmf_task *tmf);int pm8001_chip_abort_task (struct pm8001_hba_info *pm8001_ha,struct pm8001_device *pm8001_dev,u8 flag,u32 task_tag,u32 cmd_tag);
include/scsi/libsas.h +9 -0
@@ -576,6 +576,15 @@ struct sas_ssp_task {struct scsi_cmnd *cmd; }; +struct sas_tmf_task { +u8 tmf; +u16 tag_of_task_to_be_managed; + +/* Temp */ +int force_phy; +int phy_id; +}; +struct sas_task {struct domain_device *dev;
Signature · 1 line
2.26.2
PATCH v2 8/18 scsi: libsas: Add sas_task.tmf
In reply to John GarryAdd a pointer to a sas_tmf_task to the sas_task struct, as this will be used when the common LLDD TMF code is factored out.
Also set it for the LLDDs to store per-sas_task TMF info.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 16 ++++++--------- drivers/scsi/mvsas/mv_sas.c | 15 ++++++-------- drivers/scsi/pm8001/pm8001_sas.c | 28 ++++++++++----------------- include/scsi/libsas.h | 1 + 4 files changed, 23 insertions(+), 37 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +6 -10
@@ -463,8 +463,7 @@ void hisi_sas_task_deliver(struct hisi_hba *hisi_hba,spin_unlock (&dq->lock); } -static int hisi_sas_task_exec (struct sas_task *task,gfp_t gfp_flags, -struct sas_tmf_task *tmf) +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 ;struct domain_device *device = task->dev;
@@ -575,8 +574,8 @@ static int hisi_sas_task_exec(struct sas_task *task, gfp_t gfp_flags, slot->task = task; slot->port = port; - slot->tmf = tmf; - slot->is_internal = tmf; + slot->tmf = task->tmf; + slot->is_internal = task->tmf;/* protect task_prep and start_delivery sequence */ hisi_sas_task_deliver (hisi_hba, slot, dq, sas_dev,NULL );
@@ -1106,11 +1105,6 @@ static void hisi_sas_dev_gone(struct domain_device *device)up (&hisi_hba->sem); } -static int hisi_sas_queue_command (struct sas_task *task,gfp_t gfp_flags) -{ -return hisi_sas_task_exec (task, gfp_flags,NULL ); -} -static int hisi_sas_phy_set_linkrate (struct hisi_hba *hisi_hba,int phy_no,struct sas_phy_linkrates *r) {
@@ -1264,7 +1258,9 @@ static int hisi_sas_exec_internal_tmf_task(struct domain_device *device, task->slow_task->timer.expires = jiffies +TASK_TIMEOUT ;add_timer (&task->slow_task->timer); - res =hisi_sas_task_exec (task,GFP_KERNEL , tmf); + task->tmf = tmf; + + res =hisi_sas_queue_command (task,GFP_KERNEL );if (res) {del_timer_sync (&task->slow_task->timer); dev_err(dev, "abort tmf: executing internal task failed: %d\n",
drivers/scsi/mvsas/mv_sas.c +6 -9
@@ -837,14 +837,14 @@ static int mvs_task_prep(struct sas_task *task, struct mvs_info *mvi, int is_tmfreturn rc; } -static int mvs_task_exec (struct sas_task *task,gfp_t gfp_flags, -struct completion *completion,int is_tmf, -struct sas_tmf_task *tmf) +int mvs_queue_command (struct sas_task *task,gfp_t gfp_flags) {struct mvs_info *mvi =NULL ;u32 rc =0 ;u32 pass =0 ;unsigned long flags =0 ; +struct sas_tmf_task *tmf = task->tmf; +int is_tmf = !!task->tmf; mvi = ((struct mvs_device *)task->dev->lldd_dev)->mvi_info;
@@ -861,11 +861,6 @@ static int mvs_task_exec(struct sas_task *task, gfp_t gfp_flags,return rc; } -int mvs_queue_command (struct sas_task *task,gfp_t gfp_flags) -{ -return mvs_task_exec (task, gfp_flags,NULL ,0 ,NULL ); -} -static void mvs_slot_free (struct mvs_info *mvi,u32 rx_desc) {u32 slot_idx = rx_desc &RXQ_SLOT_MASK ;
@@ -1297,7 +1292,9 @@ static int mvs_exec_internal_tmf_task(struct domain_device *dev, task->slow_task->timer.expires = jiffies +MVS_TASK_TIMEOUT *HZ ;add_timer (&task->slow_task->timer); - res =mvs_task_exec (task,GFP_KERNEL ,NULL ,1 , tmf); + task->tmf = tmf; + + res =mvs_queue_command (task,GFP_KERNEL );if (res) {del_timer (&task->slow_task->timer);
drivers/scsi/pm8001/pm8001_sas.c +10 -18
@@ -371,15 +371,14 @@ static int sas_find_local_port_id(struct domain_device *dev)#define DEV_IS_GONE (pm8001_dev) \ ((!pm8001_dev || (pm8001_dev->dev_type == SAS_PHY_UNUSED))) +/** -* pm8001_task_exec - queue the task(ssp, smp && ata) to the hardware. +* pm8001_queue_command - register for upper layer used, all IO commands sent +* to HBA are from this interface. * @task: the task to be execute. -* @gfp_flags: gfp_flags. -* @is_tmf: if it is task management task. -* @tmf: the task management IU +* @gfp_flags: gfp_flags */ -static int pm8001_task_exec (struct sas_task *task, -gfp_t gfp_flags,int is_tmf,struct sas_tmf_task *tmf) +int pm8001_queue_command (struct sas_task *task,gfp_t gfp_flags) {struct domain_device *dev = task->dev;struct pm8001_hba_info *pm8001_ha;
@@ -390,6 +389,8 @@ static int pm8001_task_exec(struct sas_task *task,u32 tag =0xdeadbeef , rc =0 , n_elem =0 ;unsigned long flags =0 ;enum sas_protocol task_proto = t->task_proto; +struct sas_tmf_task *tmf = task->tmf; +int is_tmf = !!task->tmf;if (!dev->port) {struct task_status_struct *tsm = &t->task_status;
@@ -504,17 +505,6 @@ static int pm8001_task_exec(struct sas_task *task,return rc; } -/** -* pm8001_queue_command - register for upper layer used, all IO commands sent -* to HBA are from this interface. -* @task: the task to be execute. -* @gfp_flags: gfp_flags -*/ -int pm8001_queue_command (struct sas_task *task,gfp_t gfp_flags) -{ -return pm8001_task_exec (task, gfp_flags,0 ,NULL ); -} -/** * pm8001_ccb_task_free - free the sg for ssp and smp command, free the ccb. * @pm8001_ha: our hba card information
@@ -749,7 +739,9 @@ static int pm8001_exec_internal_tmf_task(struct domain_device *dev, task->slow_task->timer.expires = jiffies +PM8001_TASK_TIMEOUT *HZ ;add_timer (&task->slow_task->timer); - res =pm8001_task_exec (task,GFP_KERNEL ,1 , tmf); + task->tmf = tmf; + + res =pm8001_queue_command (task,GFP_KERNEL );if (res) {del_timer (&task->slow_task->timer);
include/scsi/libsas.h +1 -0
@@ -610,6 +610,7 @@ struct sas_task {void *lldd_task;/* for use by LLDDs */ void *uldd_task;struct sas_task_slow *slow_task; +struct sas_tmf_task *tmf; };struct sas_task_slow {
Signature · 1 line
2.26.2
PATCH v2 9/18 scsi: libsas: Add sas_execute_tmf()
In reply to John GarryDrivers using libsas have to issue their own TMFs, and the code to do this is duplicated between drivers.
Add a common function to handle TMFs. This will be also used for sending ATA commands, but use name "tmf" as the purpose is similar between SCSI and ATA in the usage.
The force_phy_id argument will be used for a hisi_sas HW bug workaround.
We check the sas task status stat field against TMF codes, as according to the SAS v1.1 spec 9.2.2.5.3, if response_data is in datapres, then the response code should be a TMF code - see table 128.
--- drivers/scsi/libsas/sas_internal.h | 3 + drivers/scsi/libsas/sas_scsi_host.c | 105 ++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+)
drivers/scsi/libsas/sas_internal.h +3 -0
@@ -97,6 +97,9 @@ extern const work_func_t sas_port_event_fns[PORT_NUM_EVENTS];void sas_task_internal_done (struct sas_task *task);void sas_task_internal_timedout (struct timer_list *t); +int sas_execute_tmf (struct domain_device *device,void *parameter, +int para_len,int force_phy_id, +struct sas_tmf_task *tmf);#ifdef CONFIG_SCSI_SAS_HOST_SMP extern void sas_smp_host_handler (struct bsg_job *job,struct Scsi_Host *shost);
drivers/scsi/libsas/sas_scsi_host.c +105 -0
111 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH v2 10/18 scsi: libsas: Add sas_execute_ssp_tmf()
In reply to John GarryAdd a function to issue an SSP TMF.
Add a temp prototype to keep make W=1 happy.
--- drivers/scsi/libsas/sas_scsi_host.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/scsi/libsas/sas_scsi_host.c +18 -0
@@ -937,6 +937,9 @@ int sas_execute_tmf(struct domain_device *device, void *parameter, task->dev = device; task->task_proto = device->tproto; +if (!dev_is_sata (device)) +memcpy (&task->ssp_task, parameter, para_len); + task->task_done = sas_task_internal_done; task->tmf = tmf;
@@ -1022,6 +1025,21 @@ int sas_execute_tmf(struct domain_device *device, void *parameter,return res; } +int sas_execute_ssp_tmf (struct domain_device *device,u8 *lun, +struct sas_tmf_task *tmf); +int sas_execute_ssp_tmf (struct domain_device *device,u8 *lun, +struct sas_tmf_task *tmf) +{ +struct sas_ssp_task ssp_task; + +if (!(device->tproto &SAS_PROTOCOL_SSP )) +return TMF_RESP_FUNC_ESUPP ; + +memcpy (ssp_task.LUN, lun,8 ); + +return sas_execute_tmf (device, &ssp_task,sizeof (ssp_task),-1 , tmf); +} +/* * Tell an upper layer that it needs to initiate an abort for a given task. * This should only ever be called by an LLDD.
Signature · 1 line
2.26.2
PATCH v2 11/18 scsi: libsas: Add TMF handler exec complete callback
In reply to John GarryThe pm8001 TMF handler has some special processing when the TMF completes, so add a callback and fill it in for the pm8001 driver.
--- drivers/scsi/libsas/sas_scsi_host.c | 3 +++ drivers/scsi/pm8001/pm8001_init.c | 1 + drivers/scsi/pm8001/pm8001_sas.c | 14 ++++++++++++++ drivers/scsi/pm8001/pm8001_sas.h | 1 + include/scsi/libsas.h | 3 +++ 5 files changed, 22 insertions(+)
drivers/scsi/libsas/sas_scsi_host.c +3 -0
@@ -957,6 +957,9 @@ int sas_execute_tmf(struct domain_device *device, void *parameter,wait_for_completion (&task->slow_task->completion); +if (i->dft->lldd_tmf_exec_complete) + i->dft->lldd_tmf_exec_complete (device); + res =TMF_RESP_FUNC_FAILED ;if ((task->task_state_flags &SAS_TASK_STATE_ABORTED )) {
drivers/scsi/pm8001/pm8001_init.c +1 -0
@@ -128,6 +128,7 @@ static struct sas_domain_function_template pm8001_transport_ops = { .lldd_lu_reset = pm8001_lu_reset, .lldd_query_task = pm8001_query_task, .lldd_port_formed = pm8001_port_formed, + .lldd_tmf_exec_complete = pm8001_setds_completion, };/**
drivers/scsi/pm8001/pm8001_sas.c +14 -0
@@ -1376,3 +1376,17 @@ void pm8001_port_formed(struct asd_sas_phy *sas_phy) } sas_port->lldd_port = port; } + +void pm8001_setds_completion (struct domain_device *dev) +{ +struct pm8001_hba_info *pm8001_ha =pm8001_find_ha_by_dev (dev); +struct pm8001_device *pm8001_dev = dev->lldd_dev; +DECLARE_COMPLETION_ONSTACK (completion_setstate); + +if (pm8001_ha->chip_id != chip_8001) { + pm8001_dev->setds_completion = &completion_setstate; +PM8001_CHIP_DISP ->set_dev_state_req (pm8001_ha, + pm8001_dev,DS_OPERATIONAL ); +wait_for_completion (&completion_setstate); + } +}
drivers/scsi/pm8001/pm8001_sas.h +1 -0
@@ -742,6 +742,7 @@ pm8001_ccb_task_free_done(struct pm8001_hba_info *pm8001_ha,smp_mb ();/*in order to force CPU ordering*/ task->task_done(task); } +void pm8001_setds_completion (struct domain_device *dev);#endif
include/scsi/libsas.h +3 -0
@@ -652,6 +652,9 @@ struct sas_domain_function_template {int (*lldd_lu_reset)(struct domain_device *,u8 *lun);int (*lldd_query_task)(struct sas_task *); +/* Special TMF callbacks */ +void (*lldd_tmf_exec_complete)(struct domain_device *dev); +/* Port and Adapter management */ int (*lldd_clear_nexus_port)(struct asd_sas_port *);int (*lldd_clear_nexus_ha)(struct sas_ha_struct *);
Signature · 1 line
2.26.2
PATCH v2 12/18 scsi: libsas: Add TMF handler aborted callback
In reply to John GarryThe hisi_sas and pm8001 TMF handlers have some special processing for when the TMF is aborted, so add a callback and fill it in for those drivers.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 20 ++++++++++++++++++++ drivers/scsi/libsas/sas_scsi_host.c | 2 ++ drivers/scsi/pm8001/pm8001_init.c | 1 + drivers/scsi/pm8001/pm8001_sas.c | 8 ++++++++ drivers/scsi/pm8001/pm8001_sas.h | 1 + include/scsi/libsas.h | 1 + 6 files changed, 33 insertions(+)
drivers/scsi/hisi_sas/hisi_sas_main.c +20 -0
@@ -666,6 +666,25 @@ static struct hisi_sas_device *hisi_sas_alloc_dev(struct domain_device *device)return sas_dev; } +static void hisi_sas_tmf_aborted (struct sas_task *task) +{ +struct hisi_sas_slot *slot = task->lldd_task; +struct domain_device *device = task->dev; +struct hisi_sas_device *sas_dev = device->lldd_dev; +struct hisi_hba *hisi_hba = sas_dev->hisi_hba; + +if (slot) { +struct hisi_sas_cq *cq = + &hisi_hba->cq[slot->dlvry_queue]; +/* +* sync irq to avoid free'ing task +* before using task in IO completion +*/ +synchronize_irq (cq->irq_no); + slot->task =NULL ; + } +} +#define HISI_SAS_DISK_RECOVER_CNT 3static int hisi_sas_init_device (struct domain_device *device) {
@@ -2322,6 +2341,7 @@ static struct sas_domain_function_template hisi_sas_transport_ops = { .lldd_clear_nexus_ha = hisi_sas_clear_nexus_ha, .lldd_port_formed = hisi_sas_port_formed, .lldd_write_gpio = hisi_sas_write_gpio, + .lldd_tmf_aborted = hisi_sas_tmf_aborted, };void hisi_sas_init_mem (struct hisi_hba *hisi_hba)
drivers/scsi/libsas/sas_scsi_host.c +2 -0
@@ -966,6 +966,8 @@ int sas_execute_tmf(struct domain_device *device, void *parameter,if (!(task->task_state_flags &SAS_TASK_STATE_DONE )) {pr_err ("TMF task timeout for %016llx and not done\n" ,SAS_ADDR (device->sas_addr)); +if (i->dft->lldd_tmf_aborted) + i->dft->lldd_tmf_aborted (task);break ; } pr_warn("TMF task timeout for %016llx and done\n",
drivers/scsi/pm8001/pm8001_init.c +1 -0
@@ -129,6 +129,7 @@ static struct sas_domain_function_template pm8001_transport_ops = { .lldd_query_task = pm8001_query_task, .lldd_port_formed = pm8001_port_formed, .lldd_tmf_exec_complete = pm8001_setds_completion, + .lldd_tmf_aborted = pm8001_tmf_aborted, };/**
drivers/scsi/pm8001/pm8001_sas.c +8 -0
@@ -1390,3 +1390,11 @@ void pm8001_setds_completion(struct domain_device *dev)wait_for_completion (&completion_setstate); } } + +void pm8001_tmf_aborted (struct sas_task *task) +{ +struct pm8001_ccb_info *ccb = task->lldd_task; + +if (ccb) + ccb->task =NULL ; +}
drivers/scsi/pm8001/pm8001_sas.h +1 -0
@@ -743,6 +743,7 @@ pm8001_ccb_task_free_done(struct pm8001_hba_info *pm8001_ha, task->task_done(task); }void pm8001_setds_completion (struct domain_device *dev); +void pm8001_tmf_aborted (struct sas_task *task);#endif
include/scsi/libsas.h +1 -0
@@ -654,6 +654,7 @@ struct sas_domain_function_template {/* Special TMF callbacks */ void (*lldd_tmf_exec_complete)(struct domain_device *dev); +void (*lldd_tmf_aborted)(struct sas_task *task);/* Port and Adapter management */ int (*lldd_clear_nexus_port)(struct asd_sas_port *);
Signature · 1 line
2.26.2
PATCH v2 13/18 scsi: libsas: Add sas_abort_task_set()
In reply to John GarryAdd a generic implementation of abort task set TMF handler, and use in LLDDs.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 5 +---- drivers/scsi/libsas/sas_scsi_host.c | 16 ++++++++++++---- drivers/scsi/mvsas/mv_init.c | 2 +- drivers/scsi/mvsas/mv_sas.c | 11 ----------- drivers/scsi/mvsas/mv_sas.h | 1 - drivers/scsi/pm8001/pm8001_init.c | 2 +- drivers/scsi/pm8001/pm8001_sas.c | 8 -------- drivers/scsi/pm8001/pm8001_sas.h | 1 - include/scsi/libsas.h | 2 ++ 9 files changed, 17 insertions(+), 31 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +1 -4
@@ -1788,7 +1788,6 @@ static int hisi_sas_abort_task_set(struct domain_device *device, u8 *lun) {struct hisi_hba *hisi_hba =dev_to_hisi_hba (device);struct device *dev = hisi_hba->dev; -struct sas_tmf_task tmf_task;int rc; rc = hisi_sas_internal_task_abort(hisi_hba, device,
@@ -1799,9 +1798,7 @@ static int hisi_sas_abort_task_set(struct domain_device *device, u8 *lun) }hisi_sas_dereg_device (hisi_hba, device); - tmf_task.tmf =TMF_ABORT_TASK_SET ; - rc =hisi_sas_debug_issue_ssp_tmf (device, lun, &tmf_task); - + rc =sas_abort_task_set (device, lun);if (rc ==TMF_RESP_FUNC_COMPLETE )hisi_sas_release_task (hisi_hba, device);
drivers/scsi/libsas/sas_scsi_host.c +12 -4
@@ -1030,10 +1030,8 @@ int sas_execute_tmf(struct domain_device *device, void *parameter,return res; } -int sas_execute_ssp_tmf (struct domain_device *device,u8 *lun, -struct sas_tmf_task *tmf); -int sas_execute_ssp_tmf (struct domain_device *device,u8 *lun, -struct sas_tmf_task *tmf) +static int sas_execute_ssp_tmf (struct domain_device *device,u8 *lun, +struct sas_tmf_task *tmf) {struct sas_ssp_task ssp_task;
@@ -1045,6 +1043,16 @@ int sas_execute_ssp_tmf(struct domain_device *device, u8 *lun,return sas_execute_tmf (device, &ssp_task,sizeof (ssp_task),-1 , tmf); } +int sas_abort_task_set (struct domain_device *dev,u8 *lun) +{ +struct sas_tmf_task tmf_task = { + .tmf =TMF_ABORT_TASK_SET , + }; + +return sas_execute_ssp_tmf (dev, lun, &tmf_task); +} +EXPORT_SYMBOL_GPL (sas_abort_task_set); +/* * Tell an upper layer that it needs to initiate an abort for a given task. * This should only ever be called by an LLDD.
drivers/scsi/mvsas/mv_init.c +1 -1
@@ -63,7 +63,7 @@ static struct sas_domain_function_template mvs_transport_ops = { .lldd_control_phy = mvs_phy_control, .lldd_abort_task = mvs_abort_task, - .lldd_abort_task_set = mvs_abort_task_set, + .lldd_abort_task_set = sas_abort_task_set, .lldd_clear_task_set = mvs_clear_task_set, .lldd_I_T_nexus_reset = mvs_I_T_nexus_reset, .lldd_lu_reset = mvs_lu_reset,
drivers/scsi/mvsas/mv_sas.c +0 -11
@@ -1536,17 +1536,6 @@ int mvs_abort_task(struct sas_task *task)return rc; } -int mvs_abort_task_set (struct domain_device *dev,u8 *lun) -{ -int rc; -struct sas_tmf_task tmf_task; - - tmf_task.tmf =TMF_ABORT_TASK_SET ; - rc =mvs_debug_issue_ssp_tmf (dev, lun, &tmf_task); - -return rc; -} -int mvs_clear_task_set (struct domain_device *dev,u8 *lun) {int rc =TMF_RESP_FUNC_FAILED ;
drivers/scsi/mvsas/mv_sas.h +0 -1
@@ -440,7 +440,6 @@ void mvs_scan_start(struct Scsi_Host *shost);int mvs_scan_finished (struct Scsi_Host *shost,unsigned long time);int mvs_queue_command (struct sas_task *task,gfp_t gfp_flags);int mvs_abort_task (struct sas_task *task); -int mvs_abort_task_set (struct domain_device *dev,u8 *lun);int mvs_clear_task_set (struct domain_device *dev,u8 * lun);void mvs_port_formed (struct asd_sas_phy *sas_phy);void mvs_port_deformed (struct asd_sas_phy *sas_phy);
drivers/scsi/pm8001/pm8001_init.c +1 -1
@@ -122,7 +122,7 @@ static struct sas_domain_function_template pm8001_transport_ops = { .lldd_control_phy = pm8001_phy_control, .lldd_abort_task = pm8001_abort_task, - .lldd_abort_task_set = pm8001_abort_task_set, + .lldd_abort_task_set = sas_abort_task_set, .lldd_clear_task_set = pm8001_clear_task_set, .lldd_I_T_nexus_reset = pm8001_I_T_nexus_reset, .lldd_lu_reset = pm8001_lu_reset,
drivers/scsi/pm8001/pm8001_sas.c +0 -8
@@ -1342,14 +1342,6 @@ int pm8001_abort_task(struct sas_task *task)return rc; } -int pm8001_abort_task_set (struct domain_device *dev,u8 *lun) -{ -struct sas_tmf_task tmf_task; - - tmf_task.tmf =TMF_ABORT_TASK_SET ; -return pm8001_issue_ssp_tmf (dev, lun, &tmf_task); -} -int pm8001_clear_task_set (struct domain_device *dev,u8 *lun) {struct sas_tmf_task tmf_task;
drivers/scsi/pm8001/pm8001_sas.h +0 -1
@@ -644,7 +644,6 @@ void pm8001_scan_start(struct Scsi_Host *shost);int pm8001_scan_finished (struct Scsi_Host *shost,unsigned long time);int pm8001_queue_command (struct sas_task *task,gfp_t gfp_flags);int pm8001_abort_task (struct sas_task *task); -int pm8001_abort_task_set (struct domain_device *dev,u8 *lun);int pm8001_clear_task_set (struct domain_device *dev,u8 *lun);int pm8001_dev_found (struct domain_device *dev);void pm8001_dev_gone (struct domain_device *dev);
include/scsi/libsas.h +2 -0
@@ -722,6 +722,8 @@ struct sas_phy *sas_get_local_phy(struct domain_device *dev);int sas_request_addr (struct Scsi_Host *shost,u8 *addr); +int sas_abort_task_set (struct domain_device *dev,u8 *lun); +int sas_notify_port_event (struct asd_sas_phy *phy,enum port_event event,gfp_t gfp_flags); int sas_notify_phy_event(struct asd_sas_phy *phy, enum phy_event event,
Signature · 1 line
2.26.2
PATCH v2 14/18 scsi: libsas: Add sas_clear_task_set()
In reply to John GarryAdd a generic implementation of clear task set TMF handler, and use in LLDDs.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 5 +---- drivers/scsi/libsas/sas_scsi_host.c | 10 ++++++++++ drivers/scsi/mvsas/mv_init.c | 2 +- drivers/scsi/mvsas/mv_sas.c | 11 ----------- drivers/scsi/mvsas/mv_sas.h | 1 - drivers/scsi/pm8001/pm8001_sas.c | 4 +--- include/scsi/libsas.h | 1 + 7 files changed, 14 insertions(+), 20 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +1 -4
@@ -690,7 +690,6 @@ static int hisi_sas_init_device(struct domain_device *device) {int rc =TMF_RESP_FUNC_COMPLETE ;struct scsi_lun lun; -struct sas_tmf_task tmf_task;int retry =HISI_SAS_DISK_RECOVER_CNT ;struct hisi_hba *hisi_hba =dev_to_hisi_hba (device);struct device *dev = hisi_hba->dev;
@@ -700,10 +699,8 @@ static int hisi_sas_init_device(struct domain_device *device)case SAS_END_DEVICE :int_to_scsilun (0 , &lun); - tmf_task.tmf =TMF_CLEAR_TASK_SET ;while (retry-- >0 ) { - rc =hisi_sas_debug_issue_ssp_tmf (device, lun.scsi_lun, - &tmf_task); + rc =sas_clear_task_set (device, lun.scsi_lun);if (rc ==TMF_RESP_FUNC_COMPLETE ) {hisi_sas_release_task (hisi_hba, device);break ;
drivers/scsi/libsas/sas_scsi_host.c +10 -0
@@ -1053,6 +1053,16 @@ int sas_abort_task_set(struct domain_device *dev, u8 *lun) }EXPORT_SYMBOL_GPL (sas_abort_task_set); +int sas_clear_task_set (struct domain_device *dev,u8 *lun) +{ +struct sas_tmf_task tmf_task = { + .tmf =TMF_CLEAR_TASK_SET , + }; + +return sas_execute_ssp_tmf (dev, lun, &tmf_task); +} +EXPORT_SYMBOL_GPL (sas_clear_task_set); +/* * Tell an upper layer that it needs to initiate an abort for a given task. * This should only ever be called by an LLDD.
drivers/scsi/mvsas/mv_init.c +1 -1
@@ -64,7 +64,7 @@ static struct sas_domain_function_template mvs_transport_ops = { .lldd_abort_task = mvs_abort_task, .lldd_abort_task_set = sas_abort_task_set, - .lldd_clear_task_set = mvs_clear_task_set, + .lldd_clear_task_set = sas_clear_task_set, .lldd_I_T_nexus_reset = mvs_I_T_nexus_reset, .lldd_lu_reset = mvs_lu_reset, .lldd_query_task = mvs_query_task,
drivers/scsi/mvsas/mv_sas.c +0 -11
@@ -1536,17 +1536,6 @@ int mvs_abort_task(struct sas_task *task)return rc; } -int mvs_clear_task_set (struct domain_device *dev,u8 *lun) -{ -int rc =TMF_RESP_FUNC_FAILED ; -struct sas_tmf_task tmf_task; - - tmf_task.tmf =TMF_CLEAR_TASK_SET ; - rc =mvs_debug_issue_ssp_tmf (dev, lun, &tmf_task); - -return rc; -} -static int mvs_sata_done (struct mvs_info *mvi,struct sas_task *task,u32 slot_idx,int err) {
drivers/scsi/mvsas/mv_sas.h +0 -1
@@ -440,7 +440,6 @@ void mvs_scan_start(struct Scsi_Host *shost);int mvs_scan_finished (struct Scsi_Host *shost,unsigned long time);int mvs_queue_command (struct sas_task *task,gfp_t gfp_flags);int mvs_abort_task (struct sas_task *task); -int mvs_clear_task_set (struct domain_device *dev,u8 * lun);void mvs_port_formed (struct asd_sas_phy *sas_phy);void mvs_port_deformed (struct asd_sas_phy *sas_phy);int mvs_dev_found (struct domain_device *dev);
drivers/scsi/pm8001/pm8001_sas.c +1 -3
@@ -1344,14 +1344,12 @@ int pm8001_abort_task(struct sas_task *task)int pm8001_clear_task_set (struct domain_device *dev,u8 *lun) { -struct sas_tmf_task tmf_task;struct pm8001_device *pm8001_dev = dev->lldd_dev;struct pm8001_hba_info *pm8001_ha =pm8001_find_ha_by_dev (dev);pm8001_dbg (pm8001_ha,EH ,"I_T_L_Q clear task set[%x]\n" , pm8001_dev->device_id); - tmf_task.tmf =TMF_CLEAR_TASK_SET ; -return pm8001_issue_ssp_tmf (dev, lun, &tmf_task); +return sas_clear_task_set (dev, lun); }void pm8001_port_formed (struct asd_sas_phy *sas_phy)
include/scsi/libsas.h +1 -0
@@ -723,6 +723,7 @@ struct sas_phy *sas_get_local_phy(struct domain_device *dev);int sas_request_addr (struct Scsi_Host *shost,u8 *addr);int sas_abort_task_set (struct domain_device *dev,u8 *lun); +int sas_clear_task_set (struct domain_device *dev,u8 *lun);int sas_notify_port_event (struct asd_sas_phy *phy,enum port_event event,gfp_t gfp_flags);
Signature · 1 line
2.26.2
PATCH v2 15/18 scsi: libsas: Add sas_lu_reset()
In reply to John GarryAdd a generic implementation of LU reset TMF handler, and use in LLDDs.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 4 +--- drivers/scsi/libsas/sas_scsi_host.c | 10 ++++++++++ drivers/scsi/mvsas/mv_sas.c | 4 +--- drivers/scsi/pm8001/pm8001_sas.c | 4 +--- include/scsi/libsas.h | 1 + 5 files changed, 14 insertions(+), 9 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +1 -3
@@ -1933,9 +1933,7 @@ static int hisi_sas_lu_reset(struct domain_device *device, u8 *lun)hisi_sas_release_task (hisi_hba, device);sas_put_local_phy (phy); }else { -struct sas_tmf_task tmf_task = { .tmf =TMF_LU_RESET }; - - rc =hisi_sas_debug_issue_ssp_tmf (device, lun, &tmf_task); + rc =sas_lu_reset (device, lun);if (rc ==TMF_RESP_FUNC_COMPLETE )hisi_sas_release_task (hisi_hba, device); }
drivers/scsi/libsas/sas_scsi_host.c +10 -0
@@ -1063,6 +1063,16 @@ int sas_clear_task_set(struct domain_device *dev, u8 *lun) }EXPORT_SYMBOL_GPL (sas_clear_task_set); +int sas_lu_reset (struct domain_device *dev,u8 *lun) +{ +struct sas_tmf_task tmf_task = { + .tmf =TMF_LU_RESET , + }; + +return sas_execute_ssp_tmf (dev, lun, &tmf_task); +} +EXPORT_SYMBOL_GPL (sas_lu_reset); +/* * Tell an upper layer that it needs to initiate an abort for a given task. * This should only ever be called by an LLDD.
drivers/scsi/mvsas/mv_sas.c +1 -3
@@ -1381,13 +1381,11 @@ int mvs_lu_reset(struct domain_device *dev, u8 *lun) {unsigned long flags;int rc =TMF_RESP_FUNC_FAILED ; -struct sas_tmf_task tmf_task;struct mvs_device * mvi_dev = dev->lldd_dev;struct mvs_info *mvi = mvi_dev->mvi_info; - tmf_task.tmf =TMF_LU_RESET ; mvi_dev->dev_status =MVS_DEV_EH ; - rc =mvs_debug_issue_ssp_tmf (dev, lun, &tmf_task); + rc =sas_lu_reset (dev, lun);if (rc ==TMF_RESP_FUNC_COMPLETE ) {spin_lock_irqsave (&mvi->lock, flags);mvs_release_task (mvi, dev);
drivers/scsi/pm8001/pm8001_sas.c +1 -3
@@ -1112,7 +1112,6 @@ int pm8001_I_T_nexus_event_handler(struct domain_device *dev)int pm8001_lu_reset (struct domain_device *dev,u8 *lun) {int rc =TMF_RESP_FUNC_FAILED ; -struct sas_tmf_task tmf_task;struct pm8001_device *pm8001_dev = dev->lldd_dev;struct pm8001_hba_info *pm8001_ha =pm8001_find_ha_by_dev (dev);DECLARE_COMPLETION_ONSTACK (completion_setstate);
@@ -1127,8 +1126,7 @@ int pm8001_lu_reset(struct domain_device *dev, u8 *lun) pm8001_dev, DS_OPERATIONAL);wait_for_completion (&completion_setstate); }else { - tmf_task.tmf =TMF_LU_RESET ; - rc =pm8001_issue_ssp_tmf (dev, lun, &tmf_task); + rc =sas_lu_reset (dev, lun); }/* If failed, fall-through I_T_Nexus reset */ pm8001_dbg(pm8001_ha, EH, "for device[%x]:rc=%d\n",
include/scsi/libsas.h +1 -0
@@ -724,6 +724,7 @@ int sas_request_addr(struct Scsi_Host *shost, u8 *addr);int sas_abort_task_set (struct domain_device *dev,u8 *lun);int sas_clear_task_set (struct domain_device *dev,u8 *lun); +int sas_lu_reset (struct domain_device *dev,u8 *lun);int sas_notify_port_event (struct asd_sas_phy *phy,enum port_event event,gfp_t gfp_flags);
Signature · 1 line
2.26.2
PATCH v2 16/18 scsi: libsas: Add sas_query_task()
In reply to John GarryAdd a generic implementation of query task TMF handler, and use in LLDDs.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 12 +----------- drivers/scsi/libsas/sas_scsi_host.c | 16 ++++++++++++++++ drivers/scsi/mvsas/mv_sas.c | 9 +-------- drivers/scsi/pm8001/pm8001_sas.c | 7 +------ include/scsi/libsas.h | 1 + 5 files changed, 20 insertions(+), 25 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +1 -11
@@ -1988,23 +1988,13 @@ static int hisi_sas_clear_nexus_ha(struct sas_ha_struct *sas_ha)static int hisi_sas_query_task (struct sas_task *task) { -struct scsi_lun lun; -struct sas_tmf_task tmf_task;int rc =TMF_RESP_FUNC_FAILED ;if (task->lldd_task && task->task_proto &SAS_PROTOCOL_SSP ) { -struct scsi_cmnd *cmnd = task->uldd_task; -struct domain_device *device = task->dev;struct hisi_sas_slot *slot = task->lldd_task;u32 tag = slot->idx; -int_to_scsilun (cmnd->device->lun, &lun); - tmf_task.tmf =TMF_QUERY_TASK ; - tmf_task.tag_of_task_to_be_managed = tag; - - rc =hisi_sas_debug_issue_ssp_tmf (device, - lun.scsi_lun, - &tmf_task); + rc =sas_query_task (task, tag);switch (rc) {/* The task is still in Lun, release it then */ case TMF_RESP_FUNC_SUCC :
drivers/scsi/libsas/sas_scsi_host.c +16 -0
@@ -1073,6 +1073,22 @@ int sas_lu_reset(struct domain_device *dev, u8 *lun) }EXPORT_SYMBOL_GPL (sas_lu_reset); +int sas_query_task (struct sas_task *task,u16 tag) +{ +struct sas_tmf_task tmf_task = { + .tmf =TMF_QUERY_TASK , + .tag_of_task_to_be_managed = tag, + }; +struct scsi_cmnd *cmnd = task->uldd_task; +struct domain_device *dev = task->dev; +struct scsi_lun lun; + +int_to_scsilun (cmnd->device->lun, &lun); + +return sas_execute_ssp_tmf (dev, lun.scsi_lun, &tmf_task); +} +EXPORT_SYMBOL_GPL (sas_query_task); +/* * Tell an upper layer that it needs to initiate an abort for a given task. * This should only ever be called by an LLDD.
drivers/scsi/mvsas/mv_sas.c +1 -8
@@ -1422,27 +1422,20 @@ int mvs_I_T_nexus_reset(struct domain_device *dev)int mvs_query_task (struct sas_task *task) {u32 tag; -struct scsi_lun lun; -struct sas_tmf_task tmf_task;int rc =TMF_RESP_FUNC_FAILED ;if (task->lldd_task && task->task_proto &SAS_PROTOCOL_SSP ) { -struct scsi_cmnd * cmnd = (struct scsi_cmnd *)task->uldd_task;struct domain_device *dev = task->dev;struct mvs_device *mvi_dev = (struct mvs_device *)dev->lldd_dev;struct mvs_info *mvi = mvi_dev->mvi_info; -int_to_scsilun (cmnd->device->lun, &lun); rc =mvs_find_tag (mvi, task, &tag);if (rc ==0 ) { rc =TMF_RESP_FUNC_FAILED ;return rc; } - tmf_task.tmf =TMF_QUERY_TASK ; - tmf_task.tag_of_task_to_be_managed =cpu_to_le16 (tag); - - rc =mvs_debug_issue_ssp_tmf (dev, lun.scsi_lun, &tmf_task); + rc =sas_query_task (task, tag);switch (rc) {/* The task is still in Lun, release it then */ case TMF_RESP_FUNC_SUCC :
drivers/scsi/pm8001/pm8001_sas.c +1 -6
@@ -1138,8 +1138,6 @@ int pm8001_lu_reset(struct domain_device *dev, u8 *lun)int pm8001_query_task (struct sas_task *task) {u32 tag =0xdeadbeef ; -struct scsi_lun lun; -struct sas_tmf_task tmf_task;int rc =TMF_RESP_FUNC_FAILED ;if (unlikely (!task || !task->lldd_task || !task->dev))return rc;
@@ -1150,17 +1148,14 @@ int pm8001_query_task(struct sas_task *task)struct pm8001_hba_info *pm8001_ha =pm8001_find_ha_by_dev (dev); -int_to_scsilun (cmnd->device->lun, &lun); rc =pm8001_find_tag (task, &tag);if (rc ==0 ) { rc =TMF_RESP_FUNC_FAILED ;return rc; }pm8001_dbg (pm8001_ha,EH ,"Query:[%16ph]\n" , cmnd->cmnd); - tmf_task.tmf =TMF_QUERY_TASK ; - tmf_task.tag_of_task_to_be_managed = tag; - rc =pm8001_issue_ssp_tmf (dev, lun.scsi_lun, &tmf_task); + rc =sas_query_task (task, tag);switch (rc) {/* The task is still in Lun, release it then */ case TMF_RESP_FUNC_SUCC :
include/scsi/libsas.h +1 -0
@@ -725,6 +725,7 @@ int sas_request_addr(struct Scsi_Host *shost, u8 *addr);int sas_abort_task_set (struct domain_device *dev,u8 *lun);int sas_clear_task_set (struct domain_device *dev,u8 *lun);int sas_lu_reset (struct domain_device *dev,u8 *lun); +int sas_query_task (struct sas_task *task,u16 tag);int sas_notify_port_event (struct asd_sas_phy *phy,enum port_event event,gfp_t gfp_flags);
Signature · 1 line
2.26.2
PATCH v2 17/18 scsi: libsas: Add sas_abort_task()
In reply to John GarryAdd a generic implementation of abort task TMF handler, and use in LLDDs.
With that, some LLDDs custom TMF functions can now be deleted.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 27 +----- drivers/scsi/libsas/sas_scsi_host.c | 16 ++++ drivers/scsi/mvsas/mv_sas.c | 118 +------------------------- drivers/scsi/pm8001/pm8001_sas.c | 117 +------------------------ include/scsi/libsas.h | 1 + 5 files changed, 20 insertions(+), 259 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +1 -26
@@ -10,8 +10,6 @@#define DEV_IS_GONE (dev) \ ((!dev) || (dev->dev_type == SAS_PHY_UNUSED)) -static int hisi_sas_debug_issue_ssp_tmf (struct domain_device *device, -u8 *lun,struct sas_tmf_task *tmf); static int hisi_sas_internal_task_abort(struct hisi_hba *hisi_hba, struct domain_device *device,
@@ -1416,20 +1414,6 @@ static int hisi_sas_softreset_ata_disk(struct domain_device *device)return rc; } -static int hisi_sas_debug_issue_ssp_tmf (struct domain_device *device, -u8 *lun,struct sas_tmf_task *tmf) -{ -struct sas_ssp_task ssp_task; - -if (!(device->tproto &SAS_PROTOCOL_SSP )) -return TMF_RESP_FUNC_ESUPP ; - -memcpy (ssp_task.LUN, lun,8 ); - -return hisi_sas_exec_internal_tmf_task (device, &ssp_task, -sizeof (ssp_task), tmf); -} -static void hisi_sas_refresh_port_id (struct hisi_hba *hisi_hba) {u32 state = hisi_hba->hw->get_phys_state (hisi_hba);
@@ -1675,8 +1659,6 @@ static int hisi_sas_controller_reset(struct hisi_hba *hisi_hba)static int hisi_sas_abort_task (struct sas_task *task) { -struct scsi_lun lun; -struct sas_tmf_task tmf_task;struct domain_device *device = task->dev;struct hisi_sas_device *sas_dev = device->lldd_dev;struct hisi_hba *hisi_hba;
@@ -1711,18 +1693,11 @@ static int hisi_sas_abort_task(struct sas_task *task)spin_unlock_irqrestore (&task->task_state_lock, flags);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;u16 tag = slot->idx;int rc2; -int_to_scsilun (cmnd->device->lun, &lun); - tmf_task.tmf =TMF_ABORT_TASK ; - tmf_task.tag_of_task_to_be_managed = tag; - - rc =hisi_sas_debug_issue_ssp_tmf (task->dev, lun.scsi_lun, - &tmf_task); - + rc =sas_abort_task (task, tag); rc2 =hisi_sas_internal_task_abort (hisi_hba, device,HISI_SAS_INT_ABT_CMD , tag, false);
drivers/scsi/libsas/sas_scsi_host.c +16 -0
@@ -1089,6 +1089,22 @@ int sas_query_task(struct sas_task *task, u16 tag) }EXPORT_SYMBOL_GPL (sas_query_task); +int sas_abort_task (struct sas_task *task,u16 tag) +{ +struct sas_tmf_task tmf_task = { + .tmf =TMF_ABORT_TASK , + .tag_of_task_to_be_managed = tag, + }; +struct scsi_cmnd *cmnd = task->uldd_task; +struct domain_device *dev = task->dev; +struct scsi_lun lun; + +int_to_scsilun (cmnd->device->lun, &lun); + +return sas_execute_ssp_tmf (dev, lun.scsi_lun, &tmf_task); +} +EXPORT_SYMBOL_GPL (sas_abort_task); +/* * Tell an upper layer that it needs to initiate an abort for a given task. * This should only ever be called by an LLDD.
drivers/scsi/mvsas/mv_sas.c +1 -117
142 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_sas.c +1 -116
142 lines not on this page · raw message
include/scsi/libsas.h +1 -0
@@ -726,6 +726,7 @@ int sas_abort_task_set(struct domain_device *dev, u8 *lun);int sas_clear_task_set (struct domain_device *dev,u8 *lun);int sas_lu_reset (struct domain_device *dev,u8 *lun);int sas_query_task (struct sas_task *task,u16 tag); +int sas_abort_task (struct sas_task *task,u16 tag);int sas_notify_port_event (struct asd_sas_phy *phy,enum port_event event,gfp_t gfp_flags);
Signature · 1 line
2.26.2
PATCH v2 18/18 scsi: libsas: Add sas_execute_ata_cmd()
In reply to John GarryAdd a function to execute an ATA command using the TMF code, and use in the hisi_sas driver. That driver needs to be able to issue the command on a specific phy, so add an interface for that.
With that, hisi_sas_exec_internal_tmf_task() may be deleted.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 130 +------------------------ drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 5 +- drivers/scsi/libsas/sas_ata.c | 8 ++ drivers/scsi/libsas/sas_scsi_host.c | 10 +- include/scsi/libsas.h | 10 +- 5 files changed, 29 insertions(+), 134 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +3 -127
@@ -1239,124 +1239,7 @@ static void hisi_sas_tmf_timedout(struct timer_list *t)complete (&task->slow_task->completion); } -#define TASK_TIMEOUT (20 * HZ) -#define TASK_RETRY 3#define INTERNAL_ABORT_TIMEOUT (6 * HZ) -static int hisi_sas_exec_internal_tmf_task (struct domain_device *device, -void *parameter,u32 para_len, -struct sas_tmf_task *tmf) -{ -struct hisi_sas_device *sas_dev = device->lldd_dev; -struct hisi_hba *hisi_hba = sas_dev->hisi_hba; -struct device *dev = hisi_hba->dev; -struct sas_task *task; -int res, retry; - -for (retry =0 ; retry <TASK_RETRY ; retry++) { - task =sas_alloc_slow_task (GFP_KERNEL ); -if (!task) -return -ENOMEM ; - - task->dev = device; - task->task_proto = device->tproto; - -if (dev_is_sata (device)) { - task->ata_task.device_control_reg_update =1 ; -memcpy (&task->ata_task.fis, parameter, para_len); - }else { -memcpy (&task->ssp_task, parameter, para_len); - } - task->task_done = hisi_sas_task_done; - - task->slow_task->timer.function = hisi_sas_tmf_timedout; - task->slow_task->timer.expires = jiffies +TASK_TIMEOUT ; -add_timer (&task->slow_task->timer); - - task->tmf = tmf; - - res =hisi_sas_queue_command (task,GFP_KERNEL ); -if (res) { -del_timer_sync (&task->slow_task->timer); -dev_err (dev,"abort tmf: executing internal task failed: %d\n" , - res); - goto ex_err; - } - -wait_for_completion (&task->slow_task->completion); - res =TMF_RESP_FUNC_FAILED ; -/* Even TMF timed out, return direct. */ -if ((task->task_state_flags &SAS_TASK_STATE_ABORTED )) { -if (!(task->task_state_flags &SAS_TASK_STATE_DONE )) { -struct hisi_sas_slot *slot = task->lldd_task; - -dev_err (dev,"abort tmf: TMF task timeout and not done\n" ); -if (slot) { -struct hisi_sas_cq *cq = - &hisi_hba->cq[slot->dlvry_queue]; -/* -* sync irq to avoid free'ing task -* before using task in IO completion -*/ -synchronize_irq (cq->irq_no); - slot->task =NULL ; - } - - goto ex_err; - }else -dev_err (dev,"abort tmf: TMF task timeout\n" ); - } - -if (task->task_status.resp ==SAS_TASK_COMPLETE && - task->task_status.stat ==TMF_RESP_FUNC_COMPLETE ) { - res =TMF_RESP_FUNC_COMPLETE ; -break ; - } - -if (task->task_status.resp ==SAS_TASK_COMPLETE && - task->task_status.stat ==TMF_RESP_FUNC_SUCC ) { - res =TMF_RESP_FUNC_SUCC ; -break ; - } - -if (task->task_status.resp ==SAS_TASK_COMPLETE && - task->task_status.stat ==SAS_DATA_UNDERRUN ) { -/* no error, but return the number of bytes of -* underrun -*/ -dev_warn (dev,"abort tmf: task to dev %016llx resp: 0x%x sts 0x%x underrun\n" , -SAS_ADDR (device->sas_addr), - task->task_status.resp, - task->task_status.stat); - res = task->task_status.residual; -break ; - } - -if (task->task_status.resp ==SAS_TASK_COMPLETE && - task->task_status.stat ==SAS_DATA_OVERRUN ) { -dev_warn (dev,"abort tmf: blocked task error\n" ); - res = -EMSGSIZE ; -break ; - } - -if (task->task_status.resp ==SAS_TASK_COMPLETE && - task->task_status.stat ==SAS_OPEN_REJECT ) { -dev_warn (dev,"abort tmf: open reject failed\n" ); - res = -EIO ; - }else { -dev_warn (dev,"abort tmf: task to dev %016llx resp: 0x%x status 0x%x\n" , -SAS_ADDR (device->sas_addr), - task->task_status.resp, - task->task_status.stat); - } -sas_free_task (task); - task =NULL ; - } -ex_err: -if (retry ==TASK_RETRY ) -dev_warn (dev,"abort tmf: executing internal task failed!\n" ); -sas_free_task (task); -return res; -}static void hisi_sas_fill_ata_reset_cmd (struct ata_device *dev,bool reset,int pmp,u8 *fis)
@@ -1380,14 +1263,12 @@ static int hisi_sas_softreset_ata_disk(struct domain_device *device)int rc =TMF_RESP_FUNC_FAILED ;struct hisi_hba *hisi_hba =dev_to_hisi_hba (device);struct device *dev = hisi_hba->dev; -int s =sizeof (struct host_to_dev_fis ); -struct sas_tmf_task tmf = {};ata_for_each_link (link, ap,EDGE ) {int pmp =sata_srst_pmp (link);hisi_sas_fill_ata_reset_cmd (link->device,1 , pmp, fis); - rc =hisi_sas_exec_internal_tmf_task (device, fis, s, &tmf); + rc =sas_execute_ata_cmd (device, fis,-1 );if (rc !=TMF_RESP_FUNC_COMPLETE )break ; }
@@ -1397,8 +1278,7 @@ static int hisi_sas_softreset_ata_disk(struct domain_device *device)int pmp =sata_srst_pmp (link);hisi_sas_fill_ata_reset_cmd (link->device,0 , pmp, fis); - rc =hisi_sas_exec_internal_tmf_task (device, fis, - s, &tmf); + rc =sas_execute_ata_cmd (device, fis,-1 );if (rc !=TMF_RESP_FUNC_COMPLETE )dev_err (dev,"ata disk %016llx de-reset failed\n" ,SAS_ADDR (device->sas_addr));
@@ -1508,10 +1388,8 @@ static void hisi_sas_send_ata_reset_each_phy(struct hisi_hba *hisi_hba,struct asd_sas_port *sas_port, struct domain_device *device) { - struct sas_tmf_task tmf_task = { .force_phy = 1 }; struct ata_port *ap = device->sata_dev.ap;struct device *dev = hisi_hba->dev; -int s =sizeof (struct host_to_dev_fis );int rc =TMF_RESP_FUNC_FAILED ;struct ata_link *link;u8 fis[20 ] = {0 };
@@ -1524,10 +1402,8 @@ static void hisi_sas_send_ata_reset_each_phy(struct hisi_hba *hisi_hba,ata_for_each_link (link, ap,EDGE ) {int pmp =sata_srst_pmp (link); - tmf_task.phy_id = i;hisi_sas_fill_ata_reset_cmd (link->device,1 , pmp, fis); - rc =hisi_sas_exec_internal_tmf_task (device, fis, s, - &tmf_task); + rc =sas_execute_ata_cmd (device, fis, i);if (rc !=TMF_RESP_FUNC_COMPLETE ) {dev_err (dev,"phy%d ata reset failed rc=%d\n" , i, rc);
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +3 -2
@@ -2491,6 +2491,7 @@ static void prep_ata_v2_hw(struct hisi_hba *hisi_hba,struct hisi_sas_cmd_hdr *hdr = slot->cmd_hdr;struct asd_sas_port *sas_port = device->port;struct hisi_sas_port *port =to_hisi_sas_port (sas_port); +struct sas_ata_task *ata_task = &task->ata_task;struct sas_tmf_task *tmf = slot->tmf;u8 *buf_cmd;int has_data =0 , hdr_tag =0 ;
@@ -2504,9 +2505,9 @@ static void prep_ata_v2_hw(struct hisi_hba *hisi_hba,else dw0 |=4 <<CMD_HDR_CMD_OFF ; -if (tmf && tmf->force_phy) { +if (tmf && ata_task->force_phy) { dw0 |=CMD_HDR_FORCE_PHY_MSK ; - dw0 |= (1 << tmf->phy_id) <<CMD_HDR_PHY_ID_OFF ; + dw0 |= (1 << ata_task->force_phy_id) <<CMD_HDR_PHY_ID_OFF ; } hdr->dw0 =cpu_to_le32 (dw0);
drivers/scsi/libsas/sas_ata.c +8 -0
@@ -852,3 +852,11 @@ void sas_ata_wait_eh(struct domain_device *dev) ap = dev->sata_dev.ap;ata_port_wait_eh (ap); } + +int sas_execute_ata_cmd (struct domain_device *device,u8 *fis,int force_phy_id) +{ +struct sas_tmf_task tmf_task = {}; +return sas_execute_tmf (device, fis,sizeof (struct host_to_dev_fis ), + force_phy_id, &tmf_task); +} +EXPORT_SYMBOL_GPL (sas_execute_ata_cmd);
drivers/scsi/libsas/sas_scsi_host.c +9 -1
@@ -937,8 +937,16 @@ int sas_execute_tmf(struct domain_device *device, void *parameter, task->dev = device; task->task_proto = device->tproto; -if (!dev_is_sata (device)) +if (dev_is_sata (device)) { + task->ata_task.device_control_reg_update =1 ; +if (force_phy_id >=0 ) { + task->ata_task.force_phy = true; + task->ata_task.force_phy_id = force_phy_id; + } +memcpy (&task->ata_task.fis, parameter, para_len); + }else {memcpy (&task->ssp_task, parameter, para_len); + } task->task_done = sas_task_internal_done; task->tmf = tmf;
include/scsi/libsas.h +6 -4
@@ -552,6 +552,9 @@ struct sas_ata_task { u8 stp_affil_pol:1; u8 device_control_reg_update:1; + +bool force_phy; +int force_phy_id; };struct sas_smp_task {
@@ -579,10 +582,6 @@ struct sas_ssp_task {struct sas_tmf_task {u8 tmf;u16 tag_of_task_to_be_managed; - -/* Temp */ -int force_phy; -int phy_id; };struct sas_task {
@@ -727,10 +726,13 @@ int sas_clear_task_set(struct domain_device *dev, u8 *lun);int sas_lu_reset (struct domain_device *dev,u8 *lun);int sas_query_task (struct sas_task *task,u16 tag);int sas_abort_task (struct sas_task *task,u16 tag); +int sas_execute_ata_cmd (struct domain_device *device,u8 *fis, +int force_phy_id);int sas_notify_port_event (struct asd_sas_phy *phy,enum port_event event,gfp_t gfp_flags);int sas_notify_phy_event (struct asd_sas_phy *phy,enum phy_event event,gfp_t gfp_flags); +#endif /* _SASLIB_H_ */
Signature · 1 line
2.26.2
Quoted 16 lines · John Garry
The LLDD TMF code is almost identical between
hisi_sas, pm8001, and mvsas drivers.This series factors out that code into libsas, thus reducing much duplication and giving a net reduction of ~350 LoC.
There are some subtle differences between the core TMF handler and each of the LLDDs old implementation, so any review and testing is appreciated.
Some other minor patches are thrown in:
- Delete unused macro inhisi_sasdriver
- Delete unused libsas callback
- Delete unusedSAS_SG_ERR
- Add enum for response frame datapres field
- Handle unrecognised errors insas_scsi_find_task()
Quoted 4 lines
I have another follow-up series to factor out the internal abort code, which is common to
hisi_sasand pm8001 drivers.Based on mkp-scsi 5.18 staging queue at commit
ac2beb4e3bd7
I tested this series with my pm8001 v5 series on top. Everything looks good, no problems detected with both SAS and SATA drives tests. So feel free to add:
Martin,
This series and my pm8001 series have a conflict. When applying the pm8001 patches on top of these libsas changes, patch 28 has a fairly easy to resolve conflict. Let me know if you want me to send a v6 rebased on top of this.
Thanks !
Signature · 2 lines
Damien Le Moal Western Digital Research
Damien,
Quoted 4 lines
This series and my pm8001 series have a conflict. When applying the pm8001 patches on top of these libsas changes, patch 28 has a fairly easy to resolve conflict. Let me know if you want me to send a v6 rebased on top of this.
I'll fix it up.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Damien,
Quoted 4 lines
This series and my pm8001 series have a conflict. When applying the pm8001 patches on top of these libsas changes, patch 28 has a fairly easy to resolve conflict. Let me know if you want me to send a v6 rebased on top of this.
"fairly easy to resolve", huh? Sure, if you manually rework the entire patch.
Please send me an updated version of #28. The rest of the series is fine...
Thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Quoted 10 lines · Martin K. Petersen
Damien,
Quoted 4 lines
This series and my pm8001 series have a conflict. When applying the pm8001 patches on top of these libsas changes, patch 28 has a fairly easy to resolve conflict. Let me know if you want me to send a v6 rebased on top of this.
"fairly easy to resolve", huh? Sure, if you manually rework the entire patch.
Sorry about that. It is easy to resolve once you have been staring at the code for days :) Sending v6 for patch 28.
Quoted 6 lines
Please send me an updated version of #28. The rest of the series is fine...
Thanks!
Signature · 2 lines
Damien Le Moal Western Digital Research
Quoted 11 lines · Martin K. Petersen
Damien,
Quoted 4 lines
This series and my pm8001 series have a conflict. When applying the pm8001 patches on top of these libsas changes, patch 28 has a fairly easy to resolve conflict. Let me know if you want me to send a v6 rebased on top of this.
"fairly easy to resolve", huh? Sure, if you manually rework the entire patch.
Please send me an updated version of #28. The rest of the series is fine...
Thanks Martin and Damien. I'll mention potential conflicts in my cover letters in future to help co-ordinate things better.
John
Martin K. Petersen
AppliedJohn,
Quoted 5 lines
The LLDD TMF code is almost identical between
hisi_sas, pm8001, and mvsas drivers.This series factors out that code into libsas, thus reducing much duplication and giving a net reduction of ~350 LoC.
Applied to 5.18/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Quoted 10 lines · Martin K. Petersen
John,
Quoted 5 lines
The LLDD TMF code is almost identical between
hisi_sas, pm8001, and mvsas drivers.This series factors out that code into libsas, thus reducing much duplication and giving a net reduction of ~350 LoC.
Applied to 5.18/scsi-staging, thanks!
Did you push this ? I do not see John series in the branch...
Signature · 2 lines
Damien Le Moal Western Digital Research
Damien,
Quoted 3 lines
Quoted 1 line
Applied to 5.18/scsi-staging, thanks!
Did you push this ? I do not see John series in the branch...
It's there now.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Quoted 9 lines · Martin K. Petersen
Damien,
Quoted 3 lines
Quoted 1 line
Applied to 5.18/scsi-staging, thanks!
Did you push this ? I do not see John series in the branch...
It's there now.
Got it. Thanks !
Signature · 2 lines
Damien Le Moal Western Digital Research