From patchwork Tue Oct 25 10:18:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10681 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp908615wru; Tue, 25 Oct 2022 02:54:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7j5Su2FFSBirpGLEJNnnRCzOlIBeZIAfJGgtxphv0Kmf4UC5aLfO6qy2KT3rM3439IRXPO X-Received: by 2002:a17:903:244d:b0:183:afb6:e7ea with SMTP id l13-20020a170903244d00b00183afb6e7eamr37961300pls.31.1666691679924; Tue, 25 Oct 2022 02:54:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691679; cv=none; d=google.com; s=arc-20160816; b=wqqPWwp52n7Z246OVhgZpwLEVtmNmOQ0KHY+6KYcOnrva54wK/3hseYyXLhz0aWhNY biWoXwhmhGnmUuiTmBySXMHQTfnx66JqY08nbMRXL+tigj3/mk3GS98pnAu1z+I6Me97 uEnfln2bualZMa0NejSAD8ERFD1IpyqFnu8IlUV88xmfwI+6eufGmZYWmBh5R9WZoKYt ocVWGPOPIQSweYfQDHk2b67csNnVUirmBySm98l/4N7hxbzmrxpXz08cVNPFEFJaThDJ M1v5RJ/Iled/GG6gnFUKLzZHsTGkKbkCCWCZ2eOSaSFeAbjGIAJa1rJ/2+EgsnC5pgIa xDlg== 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=NxiUHFLjQWiDHeq4QmnSKAWCDch+NPvyPYItxJadCG8=; b=dZ6UMCc41eGRX9Tq3MLtyEtk6hcFRsiESdmPW+cWL/Q3FJiDTZuoTugg0zsigTgzY9 jxKsYZdPLqHrMVRcPstZtNjatY5P4tqCF81wxGyNFyXUdfiLjlef2++KOxwFIDv9ziI3 LpCetjAp+mFC/PCf/ocqa1+KyRU9WnUwDlDJ7L3LrsawW9jL29U7LNFXGKZfax6HlTY/ Kq12xpWCVWxwrSSlgp7O/zXACJIGhBn5VrrA73pSNR6uCPtUrh9+ndz0vBYcDdoKC1Jd AF0ReODNfF65S2wHdRQMsEmXs20Xjv/Mbcu5B6+pu10PJdblYhW73rhj9Aur1pD9Fpc8 51yQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d2-20020a170902cec200b00186abd10814si2829783plg.250.2022.10.25.02.54.26; Tue, 25 Oct 2022 02:54:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231463AbiJYJxn (ORCPT + 99 others); Tue, 25 Oct 2022 05:53:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232062AbiJYJwL (ORCPT ); Tue, 25 Oct 2022 05:52:11 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C17AF16F748; Tue, 25 Oct 2022 02:49:16 -0700 (PDT) Received: from fraeml745-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRvF5WDGz6HJXS; Tue, 25 Oct 2022 17:47:53 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) 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.2375.31; Tue, 25 Oct 2022 11:49:14 +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:10 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 19/22] scsi: libsas: Queue TMF commands as requests Date: Tue, 25 Oct 2022 18:18:13 +0800 Message-ID: <1666693096-180008-20-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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747652895084389439?= X-GMAIL-MSGID: =?utf-8?q?1747652895084389439?= Like what we did with SMP commands, send TMF commands through the block layer. In sas_task_abort() we must ensure to not confuse "TMF" for SATA with regular SATA command which comes from libata. Signed-off-by: John Garry --- drivers/scsi/libsas/sas_scsi_host.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index 2c734a87bb7c..e6ee8dd56a45 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c @@ -1067,13 +1067,17 @@ int sas_execute_tmf(struct domain_device *device, void *parameter, int res, retry; for (retry = 0; retry < TASK_RETRY; retry++) { - task = sas_alloc_slow_task(GFP_KERNEL); + struct request *rq; + + task = sas_alloc_slow_task_rq(device, GFP_KERNEL); if (!task) return -ENOMEM; - task->dev = device; task->task_proto = device->tproto; + rq = scsi_cmd_to_rq(task->uldd_task); + rq->timeout = TASK_TIMEOUT; + if (dev_is_sata(device)) { task->ata_task.device_control_reg_update = 1; if (force_phy_id >= 0) { @@ -1085,20 +1089,9 @@ int sas_execute_tmf(struct domain_device *device, void *parameter, memcpy(&task->ssp_task, parameter, para_len); } - task->task_done = sas_task_internal_done; task->tmf = tmf; - task->slow_task->timer.function = sas_task_internal_timedout; - task->slow_task->timer.expires = jiffies + TASK_TIMEOUT; - add_timer(&task->slow_task->timer); - - res = i->dft->lldd_execute_task(task, GFP_KERNEL); - if (res) { - del_timer_sync(&task->slow_task->timer); - pr_err("executing TMF task failed %016llx (%d)\n", - SAS_ADDR(device->sas_addr), res); - break; - } + blk_execute_rq_nowait(rq, true); wait_for_completion(&task->slow_task->completion); @@ -1270,7 +1263,7 @@ void sas_task_abort(struct sas_task *task) return; } - if (dev_is_sata(task->dev)) + if (dev_is_sata(task->dev) && !task->slow_task) sas_ata_task_abort(task); else blk_abort_request(scsi_cmd_to_rq(sc));