Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: libsas: Move SMP task handlers to core

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>

authored by

John Garry and committed by
Martin K. Petersen
4aef43b2 da19eaba

+29 -22
+2 -22
drivers/scsi/libsas/sas_expander.c
··· 28 28 29 29 /* ---------- SMP task management ---------- */ 30 30 31 - static void smp_task_timedout(struct timer_list *t) 32 - { 33 - struct sas_task_slow *slow = from_timer(slow, t, timer); 34 - struct sas_task *task = slow->task; 35 - unsigned long flags; 36 - 37 - spin_lock_irqsave(&task->task_state_lock, flags); 38 - if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) { 39 - task->task_state_flags |= SAS_TASK_STATE_ABORTED; 40 - complete(&task->slow_task->completion); 41 - } 42 - spin_unlock_irqrestore(&task->task_state_lock, flags); 43 - } 44 - 45 - static void smp_task_done(struct sas_task *task) 46 - { 47 - del_timer(&task->slow_task->timer); 48 - complete(&task->slow_task->completion); 49 - } 50 - 51 31 /* Give it some long enough timeout. In seconds. */ 52 32 #define SMP_TIMEOUT 10 53 33 ··· 58 78 task->smp_task.smp_req = *req; 59 79 task->smp_task.smp_resp = *resp; 60 80 61 - task->task_done = smp_task_done; 81 + task->task_done = sas_task_internal_done; 62 82 63 - task->slow_task->timer.function = smp_task_timedout; 83 + task->slow_task->timer.function = sas_task_internal_timedout; 64 84 task->slow_task->timer.expires = jiffies + SMP_TIMEOUT*HZ; 65 85 add_timer(&task->slow_task->timer); 66 86
+3
drivers/scsi/libsas/sas_internal.h
··· 95 95 extern const work_func_t sas_phy_event_fns[PHY_NUM_EVENTS]; 96 96 extern const work_func_t sas_port_event_fns[PORT_NUM_EVENTS]; 97 97 98 + void sas_task_internal_done(struct sas_task *task); 99 + void sas_task_internal_timedout(struct timer_list *t); 100 + 98 101 #ifdef CONFIG_SCSI_SAS_HOST_SMP 99 102 extern void sas_smp_host_handler(struct bsg_job *job, struct Scsi_Host *shost); 100 103 #else
+24
drivers/scsi/libsas/sas_scsi_host.c
··· 893 893 } 894 894 EXPORT_SYMBOL_GPL(sas_bios_param); 895 895 896 + void sas_task_internal_done(struct sas_task *task) 897 + { 898 + del_timer(&task->slow_task->timer); 899 + complete(&task->slow_task->completion); 900 + } 901 + 902 + void sas_task_internal_timedout(struct timer_list *t) 903 + { 904 + struct sas_task_slow *slow = from_timer(slow, t, timer); 905 + struct sas_task *task = slow->task; 906 + bool is_completed = true; 907 + unsigned long flags; 908 + 909 + spin_lock_irqsave(&task->task_state_lock, flags); 910 + if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) { 911 + task->task_state_flags |= SAS_TASK_STATE_ABORTED; 912 + is_completed = false; 913 + } 914 + spin_unlock_irqrestore(&task->task_state_lock, flags); 915 + 916 + if (!is_completed) 917 + complete(&task->slow_task->completion); 918 + } 919 + 896 920 /* 897 921 * Tell an upper layer that it needs to initiate an abort for a given task. 898 922 * This should only ever be called by an LLDD.