Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4353234pxb; Tue, 25 Jan 2022 08:37:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJw90WuG/SJGh8TLhB4WCAvqqgThloYbBOex3rBRHA4rphjRv+93t6ixWk38oRv+/Ke9MEP5 X-Received: by 2002:a50:da8f:: with SMTP id q15mr21558103edj.0.1643128638360; Tue, 25 Jan 2022 08:37:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643128638; cv=none; d=google.com; s=arc-20160816; b=p+Lt/PzJkpaLSxr7E2tf8bCiYhGAny4HSQW+ejNMSueQyT3WFhQmeNxwUe2woHGQ7B LnhCp947gIB/4ZQX9vTWdK+DqAq0gGdsmolIfYvv5oO1Ls9VBBP/dUgzOeSIUPfQbj1G 2rC4lzjV+QAFEfQ8CQTf8LyxiDirZvJAFpWKwBFhUg/Tew04vlfqzZ8M+gYBTGRtA4d5 bsdbQk7Sh5sILVt0kyX5FBn5ef6s27BK10ustA+SsqrsiZzjrnT4PJIQKQrh/rNCjkqt AoJ2xnplrkRnr3DlGY71CwAq3Ad7ZZ3ji28mzbSM+70oByS1Feb1I/tU9dXP/n8hzEXN v4iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=lJMZsYE+M5SvnKv2rV2U1E0jwfSGwTxKjxvQIJiBjIM=; b=Tu7grxnhjN3DbDcb8jvwMARvaz1V5v5t/mjI9UXKFW3mfRN+mFoqiWOa2yUy1EwPpp FibU4lKjFoJw6Yahtvg1soDSHQJsoJOp+TWTd5/VVUvL4106613JJdqTOh4vptObCIN3 dPI3HSQtg1PFMkqR4CdY3wtrgcN8XWqTxrfJ60qZEHHYAC/VxqqbaemKhql0oQZJy5R+ e50ma001+G86S3PcIN0ouUbxVDugPkOZ54JBQASRBPmZsgiegAfFpHsqRGEA60ChY4Cp GazxaSKg2j0bB3b+UQYdla65FE9tPVtjKVzea8OUddKaR+laGihT3NHRHuAr48wpJ9mp tDzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c11si11664913edx.610.2022.01.25.08.36.51; Tue, 25 Jan 2022 08:37:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381971AbiAYLoo (ORCPT + 99 others); Tue, 25 Jan 2022 06:44:44 -0500 Received: from frasgout.his.huawei.com ([185.176.79.56]:4502 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382409AbiAYLjJ (ORCPT ); Tue, 25 Jan 2022 06:39:09 -0500 Received: from fraeml745-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4JjlBX12p1z687WJ; Tue, 25 Jan 2022 19:34:44 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml745-chm.china.huawei.com (10.206.15.226) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Tue, 25 Jan 2022 12:38:59 +0100 Received: from localhost.localdomain (10.69.192.58) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Tue, 25 Jan 2022 11:38:55 +0000 From: John Garry To: , , , , , CC: , , , , , , , , John Garry Subject: [PATCH 10/16] scsi: libsas: Add TMF handler aborted callback Date: Tue, 25 Jan 2022 19:32:46 +0800 Message-ID: <1643110372-85470-11-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1643110372-85470-1-git-send-email-john.garry@huawei.com> References: <1643110372-85470-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The hisi_sas TMF handler has some special processing when the TMF is aborted, so add a callback and fill it in for the hisi_sas driver. Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 20 ++++++++++++++++++++ drivers/scsi/libsas/sas_scsi_host.c | 2 ++ include/scsi/libsas.h | 1 + 3 files changed, 23 insertions(+) diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 4f146aa50423..a2c03cb6414f 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -671,6 +671,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 3 static int hisi_sas_init_device(struct domain_device *device) { @@ -2327,6 +2346,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) diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index 79a0a90cb359..956b4387c1b8 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c @@ -969,6 +969,8 @@ int sas_execute_tmf(struct domain_device *device, void *parameter, if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) { pr_err("TMF (%d) task timeout for %016llx and not done\n", tmf->tmf, SAS_ADDR(device->sas_addr)); + if (i->dft->lldd_tmf_aborted) + i->dft->lldd_tmf_aborted(task); break; } pr_warn("TMF (%d) task timeout for %016llx and done\n", diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index 9c2e58cbadc5..1e5ecfb2f36e 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -656,6 +656,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 *); -- 2.26.2