Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2840113pxp; Tue, 22 Mar 2022 07:05:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7o/o/24vddb3WAAjyj7KdtcQbwbDFKulzZu/r8h0jXFZfdyafP8hBjxz6cR0jOuhdw4kS X-Received: by 2002:a4a:1ac7:0:b0:321:67b5:6569 with SMTP id 190-20020a4a1ac7000000b0032167b56569mr8426581oof.24.1647957921879; Tue, 22 Mar 2022 07:05:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647957921; cv=none; d=google.com; s=arc-20160816; b=YsC0XCrlEawmws4XXVb5ATsXp8Qk5VN5lbbI7pABHgmLefZrYgzfjsKeDXXO82gwO5 iIeiAyvEZIl5aoY5NaorU4NtTevq7hvDpmMMzAPa4vpYfdgVylxnHUKm3sMXs9ynV09t oJdzGTtDnQLcWUoYn/bJoxGck+H4vhqfiaDlt8kMoDEJycLyCz7TUSO2g97zTSMiCzfV 9dWRDN5aALRdVKDAf7C3f2PkyWXJWcBCCdg4i8YThF3AxxcMESK4OBF83Vit7B/B0dl6 W5cWn+u+Qecy4ILuxensdurHkiY0EkJae3fiuHjMd83pOUkWfYrxVwWA7lyk0MRJufCe 98UA== 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=ce52dF/moPPrhHw1VZBA/D0UBxz9aVmdHUoZeUrM+B8=; b=fNpBHoZU5TuvrQA9SDj9zDJNumZRQD/wowxYndrNE0gXa6t7n601Mugq9NQxhUGQ2L cYjLFSD5UYMwqRX5Ni5gTfL9mhgtxAitq+kjIrLleV8IvWgqr6xttBsZcwFZFyo+nl/P mmzr2h2+R7iGKJSbiSr00mF9bizwUHLvw54cdjIb00beJikVt+YYJ5ubuzYNVqfrNaot jq6TD99+nT8fvq8Fe6L4sX0tO8JLcVye1Sagu8h+7kC/fBCPthM3ZIai8zliyYC7X9uN RMrl4A7daZMDus+qMgqNR8iDP1rM0UHt0SqBBytSV2xHgWXTOcMYTJ/Kzpyrpj8OGW5y Px9g== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r14-20020a9d7cce000000b005cb2fc1382esi5465207otn.170.2022.03.22.07.05.07; Tue, 22 Mar 2022 07:05:21 -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 S233517AbiCVKsk (ORCPT + 99 others); Tue, 22 Mar 2022 06:48:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233504AbiCVKro (ORCPT ); Tue, 22 Mar 2022 06:47:44 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A799782D19; Tue, 22 Mar 2022 03:46:08 -0700 (PDT) Received: from fraeml742-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4KN7RL1hjGz67PTQ; Tue, 22 Mar 2022 18:45:02 +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.2375.24; Tue, 22 Mar 2022 11:46:06 +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, 22 Mar 2022 10:46:02 +0000 From: John Garry To: , , , , , , , CC: , , , , , , , John Garry Subject: [PATCH 07/11] scsi: libsas: Send internal abort commands through the block layer Date: Tue, 22 Mar 2022 18:39:41 +0800 Message-ID: <1647945585-197349-8-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1647945585-197349-1-git-send-email-john.garry@huawei.com> References: <1647945585-197349-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: dggems702-chm.china.huawei.com (10.3.19.179) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 Like what we did for SMP commands, send internal abort commands through the block layer. At this point no code in libsas relies on the sas_slow_task.timer; unfortunately we can't delete it as some LLDDs (pm8001) still rely on it - let's try to remove them in future. But we can delete the legacy timeout handler, sas_task_internal_timedout(). Signed-off-by: John Garry --- drivers/scsi/libsas/sas_scsi_host.c | 59 +++++++++++++++-------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index 04c6298d1340..f139977098c2 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c @@ -899,24 +899,6 @@ void sas_task_internal_done(struct sas_task *task) complete(&task->slow_task->completion); } -void sas_task_internal_timedout(struct timer_list *t) -{ - struct sas_task_slow *slow = from_timer(slow, t, timer); - struct sas_task *task = slow->task; - bool is_completed = true; - unsigned long flags; - - spin_lock_irqsave(&task->task_state_lock, flags); - if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) { - task->task_state_flags |= SAS_TASK_STATE_ABORTED; - is_completed = false; - } - spin_unlock_irqrestore(&task->task_state_lock, flags); - - if (!is_completed) - complete(&task->slow_task->completion); -} - #define TASK_TIMEOUT (20 * HZ) #define TASK_RETRY 3 @@ -979,35 +961,52 @@ static int sas_execute_internal_abort(struct domain_device *device, { struct sas_ha_struct *ha = device->port->ha; struct sas_internal *i = to_sas_internal(ha->core.shost->transportt); + struct Scsi_Host *shost = ha->core.shost; struct sas_task *task = NULL; int res, retry; + struct request_queue *request_queue; + struct request *rq; + + request_queue = sas_alloc_request_queue(shost); + if (IS_ERR(request_queue)) + return PTR_ERR(request_queue); for (retry = 0; retry < TASK_RETRY; retry++) { + struct scsi_cmnd *scmd; + task = sas_alloc_slow_task(GFP_KERNEL); - if (!task) - return -ENOMEM; + if (!task) { + res = -ENOMEM; + break; + } task->dev = device; task->task_proto = SAS_PROTOCOL_INTERNAL_ABORT; task->task_done = sas_task_internal_done; - task->slow_task->timer.function = sas_task_internal_timedout; - task->slow_task->timer.expires = jiffies + TASK_TIMEOUT; - add_timer(&task->slow_task->timer); task->abort_task.tag = tag; task->abort_task.type = type; task->abort_task.qid = qid; - res = i->dft->lldd_execute_task(task, GFP_KERNEL); - if (res) { - del_timer_sync(&task->slow_task->timer); - pr_err("Executing internal abort failed %016llx (%d)\n", - SAS_ADDR(device->sas_addr), res); + rq = scsi_alloc_request_hwq(request_queue, REQ_OP_DRV_IN, BLK_MQ_REQ_NOWAIT, qid); + if (!rq) { + res = PTR_ERR(rq); break; } + scmd = blk_mq_rq_to_pdu(rq); + scmd->submitter = SUBMITTED_BY_SCSI_CUSTOM_OPS; + ASSIGN_SAS_TASK(scmd, task); + + task->uldd_task = scmd; + + rq->timeout = TASK_TIMEOUT; + + blk_execute_rq_nowait(rq, true, NULL); + wait_for_completion(&task->slow_task->completion); res = TMF_RESP_FUNC_FAILED; + __blk_mq_end_request(rq, BLK_STS_OK); /* Even if the internal abort timed out, return direct. */ if (task->task_state_flags & SAS_TASK_STATE_ABORTED) { @@ -1042,7 +1041,11 @@ static int sas_execute_internal_abort(struct domain_device *device, task = NULL; } BUG_ON(retry == TASK_RETRY && task != NULL); + sas_free_task(task); + + blk_cleanup_queue(request_queue); + return res; } -- 2.26.2