[v3,3/3] scsi: hisi_sas: Implement lldd_device_task_abort()

Message ID 20221221092514.4091-4-yangxingui@huawei.com
State New
Headers
Series Directly kick-off EH when device removed with active IO |

Commit Message

yangxingui Dec. 21, 2022, 9:25 a.m. UTC
  Implement lldd_device_task_abort() to abort active io for device.

Signed-off-by: Xingui Yang <yangxingui@huawei.com>
---
 drivers/scsi/hisi_sas/hisi_sas_main.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
  

Patch

diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 41ba22f6c7f0..647479e54b62 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -1839,6 +1839,24 @@  static int hisi_sas_clear_nexus_ha(struct sas_ha_struct *sas_ha)
 	return TMF_RESP_FUNC_COMPLETE;
 }
 
+static int hisi_sas_device_task_abort(struct domain_device *dev)
+{
+	struct hisi_sas_device *sas_dev = dev->lldd_dev;
+	struct hisi_sas_slot *slot, *slot2;
+	struct sas_task *task;
+
+	spin_lock(&sas_dev->lock);
+	list_for_each_entry_safe(slot, slot2, &sas_dev->list, entry) {
+		task = slot->task;
+		if (unlikely(!task || !task->lldd_task || !task->dev))
+			continue;
+		sas_task_abort(task);
+	}
+	spin_unlock(&sas_dev->lock);
+
+	return 0;
+}
+
 static int hisi_sas_query_task(struct sas_task *task)
 {
 	int rc = TMF_RESP_FUNC_FAILED;
@@ -2029,6 +2047,7 @@  static struct sas_domain_function_template hisi_sas_transport_ops = {
 	.lldd_abort_task_set	= hisi_sas_abort_task_set,
 	.lldd_I_T_nexus_reset	= hisi_sas_I_T_nexus_reset,
 	.lldd_lu_reset		= hisi_sas_lu_reset,
+	.lldd_device_task_abort = hisi_sas_device_task_abort,
 	.lldd_query_task	= hisi_sas_query_task,
 	.lldd_clear_nexus_ha	= hisi_sas_clear_nexus_ha,
 	.lldd_port_formed	= hisi_sas_port_formed,