From nobody Wed Apr 8 12:34:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F44FC04A95 for ; Tue, 25 Oct 2022 09:53:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230428AbiJYJxZ (ORCPT ); Tue, 25 Oct 2022 05:53:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231946AbiJYJvj (ORCPT ); Tue, 25 Oct 2022 05:51:39 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E8F516CA5A; Tue, 25 Oct 2022 02:49:13 -0700 (PDT) Received: from frapeml100001.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRrj0JLXz686Kq; Tue, 25 Oct 2022 17:45:41 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by frapeml100001.china.huawei.com (7.182.85.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 25 Oct 2022 11:49:10 +0200 Received: from localhost.localdomain (10.69.192.58) by lhrpeml500003.china.huawei.com (7.191.162.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 25 Oct 2022 10:49:06 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 18/22] scsi: libsas: Queue SMP commands as requests Date: Tue, 25 Oct 2022 18:18:12 +0800 Message-ID: <1666693096-180008-19-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1666693096-180008-1-git-send-email-john.garry@huawei.com> References: <1666693096-180008-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To lhrpeml500003.china.huawei.com (7.191.162.67) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Send SMP commands through the block layer so that each command gets a unique tag associated. Function sas_task_complete_internal() is what the LLDD calls to signal that the CQ is complete and this calls into the SCSI midlayer. And then sas_blk_end_sync_rq() is called when the request completes. Signed-off-by: John Garry --- drivers/scsi/libsas/sas_expander.c | 23 ++++++++--------------- drivers/scsi/libsas/sas_init.c | 3 +++ drivers/scsi/libsas/sas_internal.h | 3 +++ drivers/scsi/libsas/sas_scsi_host.c | 16 ++++++++++++++++ 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_e= xpander.c index e7cb95683522..cc41127ea5cc 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c @@ -43,34 +43,27 @@ static int smp_execute_task_sg(struct domain_device *de= v, pm_runtime_get_sync(ha->dev); mutex_lock(&dev->ex_dev.cmd_mutex); for (retry =3D 0; retry < 3; retry++) { + struct request *rq; + if (test_bit(SAS_DEV_GONE, &dev->state)) { res =3D -ECOMM; break; } =20 - task =3D sas_alloc_slow_task(GFP_KERNEL); + task =3D sas_alloc_slow_task_rq(dev, GFP_KERNEL); if (!task) { res =3D -ENOMEM; break; } - task->dev =3D dev; + + rq =3D scsi_cmd_to_rq(task->uldd_task); + rq->timeout =3D SMP_TIMEOUT*HZ; + task->task_proto =3D dev->tproto; task->smp_task.smp_req =3D *req; task->smp_task.smp_resp =3D *resp; =20 - task->task_done =3D sas_task_internal_done; - - task->slow_task->timer.function =3D sas_task_internal_timedout; - task->slow_task->timer.expires =3D jiffies + SMP_TIMEOUT*HZ; - add_timer(&task->slow_task->timer); - - res =3D i->dft->lldd_execute_task(task, GFP_KERNEL); - - if (res) { - del_timer_sync(&task->slow_task->timer); - pr_notice("executing SMP task failed:%d\n", res); - break; - } + blk_execute_rq_nowait(rq, true); =20 wait_for_completion(&task->slow_task->completion); res =3D -ECOMM; diff --git a/drivers/scsi/libsas/sas_init.c b/drivers/scsi/libsas/sas_init.c index 90e63ff5e966..5f9e71a54799 100644 --- a/drivers/scsi/libsas/sas_init.c +++ b/drivers/scsi/libsas/sas_init.c @@ -84,6 +84,7 @@ struct sas_task *sas_alloc_slow_task_rq(struct domain_dev= ice *device, gfp_t flag return NULL; =20 task->dev =3D device; + task->task_done =3D sas_task_complete_internal; =20 rq =3D scsi_alloc_request(sdev->request_queue, REQ_OP_DRV_IN, BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT); @@ -95,6 +96,8 @@ struct sas_task *sas_alloc_slow_task_rq(struct domain_dev= ice *device, gfp_t flag scmd =3D blk_mq_rq_to_pdu(rq); =20 task->uldd_task =3D scmd; + + rq->end_io =3D sas_blk_end_sync_rq; rq->end_io_data =3D task; =20 return task; diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_i= nternal.h index f5ae4de382f7..9b58948c57c2 100644 --- a/drivers/scsi/libsas/sas_internal.h +++ b/drivers/scsi/libsas/sas_internal.h @@ -104,6 +104,9 @@ int sas_execute_tmf(struct domain_device *device, void = *parameter, int para_len, int force_phy_id, struct sas_tmf_task *tmf); =20 +void sas_task_complete_internal(struct sas_task *task); +enum rq_end_io_ret sas_blk_end_sync_rq(struct request *rq, blk_status_t er= ror); + #ifdef CONFIG_SCSI_SAS_HOST_SMP extern void sas_smp_host_handler(struct bsg_job *job, struct Scsi_Host *sh= ost); #else diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_= scsi_host.c index b7d1994a8f1b..2c734a87bb7c 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c @@ -913,6 +913,13 @@ void sas_task_internal_done(struct sas_task *task) complete(&task->slow_task->completion); } =20 +void sas_task_complete_internal(struct sas_task *task) +{ + struct scsi_cmnd *scmd =3D task->uldd_task; + + scsi_done(scmd); +} + void sas_task_internal_timedout(struct timer_list *t) { struct sas_task_slow *slow =3D from_timer(slow, t, timer); @@ -952,6 +959,15 @@ EXPORT_SYMBOL_GPL(sas_internal_timeout); #define TASK_TIMEOUT (20 * HZ) #define TASK_RETRY 3 =20 +enum rq_end_io_ret sas_blk_end_sync_rq(struct request *rq, blk_status_t er= ror) +{ + struct scsi_cmnd *scmd =3D blk_mq_rq_to_pdu(rq); + struct sas_task *task =3D TO_SAS_TASK(scmd); + complete(&task->slow_task->completion); + + return RQ_END_IO_NONE; +} + static int sas_execute_internal_abort(struct domain_device *device, enum sas_internal_abort type, u16 tag, unsigned int qid, void *data) --=20 2.35.3