Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4353500pxb; Tue, 25 Jan 2022 08:37:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+NoIGZowKpHuORx6JEP1GpPlv7rcu/sxpGxL4+LpojQny2KfP6JNuHpM0FmLg1oyhwq36 X-Received: by 2002:a05:6402:26c4:: with SMTP id x4mr17376531edd.22.1643128656946; Tue, 25 Jan 2022 08:37:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643128656; cv=none; d=google.com; s=arc-20160816; b=EgGC5DKET6u0pFqMI1uyXIMrhr6NYeD5ATHwNvOz3td4QH4+JS3WlkcjxeqJX6citz DoyA09NHmhOpcY93XpRA+FVb2OnVaDWdtbZx9t3+TH9xpRK6boIJjE9kqavRgu5NWMfn NdSHahSkiLiON+KTnsh6IBhIQJtJ7baN9Ew+yLga24INADkwBnOEzk6ImN1ZySbBjewo xzoz4ullRp8lnSTc4oRcJJAP7zwcDRCZfcSct/5w3/lG8CUCqWQ6WKmiRvVdDdQsajg3 dVYS2cO6lwT9oxLXqjeIRUlWxxVIAnsbn2ZwOQQ+kDT5w4GnSFumihk/Yb/fVIDhW+5t 9Yig== 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=MzV0SUQ0Y7zeEuvygMEmjOQesEbyytvteYN1XPhf72k=; b=BlyekBT9F1aAcB4cxhk7+08gBHtI2o/BPMea0DJcb+cTXzNJknVSWD8SYdNFSHMafs f09TSdrdEy69S7yzOmTyQ47qw9vZM6WOeSwQ6Ps7gyjLue7eq7sBx2w+yWfXnzUyjv9F htEuEtptamG08YCBv6hhyk472HX8yvo679GVlK24qH5gQ/bbMkLaDBvbLEaLCUNwkMgC ZgbbdpkZwB5s1ZvwsS3xgtH9eLbgOkHMtX2KThaphbbDKkIfPhcapSsRKLsN7Qiw3x/+ fypAYC/agMSK7LqN7Z42XbQK/O7Ua3VkvZTH9cpwWwrSIdJU7PcEglWVfT8CEV3X5VLd igEg== 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 nb8si12085704ejc.464.2022.01.25.08.37.11; Tue, 25 Jan 2022 08:37:36 -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 S1383388AbiAYLpF (ORCPT + 99 others); Tue, 25 Jan 2022 06:45:05 -0500 Received: from frasgout.his.huawei.com ([185.176.79.56]:4504 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382511AbiAYLjV (ORCPT ); Tue, 25 Jan 2022 06:39:21 -0500 Received: from fraeml742-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4JjlCj6XJlz686my; Tue, 25 Jan 2022 19:35:45 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml742-chm.china.huawei.com (10.206.15.223) 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:39:10 +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:39:06 +0000 From: John Garry To: , , , , , CC: , , , , , , , , John Garry Subject: [PATCH 13/16] scsi: libsas: Add sas_lu_reset() Date: Tue, 25 Jan 2022 19:32:49 +0800 Message-ID: <1643110372-85470-14-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 Add a generic implementation of LU reset TMF handler, and use in LLDDs. Signed-off-by: John Garry --- 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(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 12919b063572..858f4b2aa211 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -1938,9 +1938,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); } diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index 5520c857598b..a7beca31d1e8 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c @@ -1066,6 +1066,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. diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c index 146005d2d75c..61bf4d1e8355 100644 --- a/drivers/scsi/mvsas/mv_sas.c +++ b/drivers/scsi/mvsas/mv_sas.c @@ -1384,13 +1384,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); diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index 3547e8538670..afea130807f2 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -1111,7 +1111,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); @@ -1126,8 +1125,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", diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index 710f93ddc5d4..12caf688806c 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -726,6 +726,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); -- 2.26.2