scsi: libsas: Move SMP task handlers to core
authorJohn Garry <john.garry@huawei.com>
Thu, 17 Feb 2022 15:42:34 +0000 (23:42 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Sat, 19 Feb 2022 20:59:34 +0000 (15:59 -0500)
Move the SMP task handlers to the core host code as they will be re-used
for executing internal abort and TMF tasks.

Link: https://lore.kernel.org/r/1645112566-115804-7-git-send-email-john.garry@huawei.com
Tested-by: Yihang Li <liyihang6@hisilicon.com>
Tested-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/libsas/sas_expander.c
drivers/scsi/libsas/sas_internal.h
drivers/scsi/libsas/sas_scsi_host.c

index 6abce9dfc17bd04df936c98ea8261560a92853f5..260e735d06fa4c5259e00dd497e28ff88b62e7d4 100644 (file)
@@ -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);
 
index acd515c018610d5fed1af48d1e3eee42d8242bc3..cd6aa723c3e1af4eeeb055f4122d0116dce31a4e 100644 (file)
@@ -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
index 387083a16a79e4b8de0b5ee7e2d1573e09398a61..40dcb4e8a747425ff2c969f3c6b8c9ee41cfd174 100644 (file)
@@ -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.