From patchwork Tue Oct 25 10:17:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10664 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp907374wru; Tue, 25 Oct 2022 02:51:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6nCuG+d2Xa+o27j6sob3b4NvOKiT0mI44KVucB+MwOTB3qn3QeNC6IJw1CHZzWQilvldLP X-Received: by 2002:a05:6402:a46:b0:461:ed76:cb56 with SMTP id bt6-20020a0564020a4600b00461ed76cb56mr6067824edb.264.1666691465469; Tue, 25 Oct 2022 02:51:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691465; cv=none; d=google.com; s=arc-20160816; b=Z5vrmIol/JiNsQy/+uRfmOSSwYpniiw7OSPFGp/cThwr9gFIK/jyFJRWP41T+1Dunx hPPLnxXyGiUCCrZTbRrgRXWJ23dMZi0yqNPdq8kRXEvs854zlSXxXoeJ/lerzOfphTzJ ke01JyHUMjWRK6ZHzvKe8siy+mjaWCjxxphy9bwvdz/33/uGd6jEz7jNl3xvnctDwatt NnJZJWn+KiQl8LmHark+jt1T7zDXaNRITslojeAM/vFg6/9QmXb2a0bRaH0OomSeVwBj mTTbJwrMP6CVZ0VHq2UaxY2LyGYRsylN9wrkjmUWTOMbgYZj8qEnvwba18HYTmWc/5wz rgAA== 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=i+6xc6vyImYhdJ+LENv/mkNCXJV0E6KkFR6KXHgG7bk=; b=AliPwmsk06kDPnGB9zrhFnraq/9rYglJGswUVEhEFNSORwO5gRrOLR35kAoMMpAvkO 4iXK30uxtRInwlfFkh99GbK7hQNBlafb0fNAmJfU9QdTFNRYWc7TXPTAPF2GL7qNGrso fn7DjN5IXdPihc02Fr6+xoQVBm288r4auUuPMLqFjf6gLfD9G4SiluNBInzsSN4F/4vA wfNLXvuEAbLEQi5m1qX/daMOqN6IGWg9zNhhiMapA36gFP4af5bEEmGBuJOyXLvahcId pW23Bwy5ej0jXHphPZz4sa2gnqhVQhGutGOB4nmF7ON1tgVIvBLjxqGYhkEnv7a7f5Qo Y2WQ== 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 g18-20020a056402181200b00461b93cfe9dsi2095596edy.55.2022.10.25.02.50.40; Tue, 25 Oct 2022 02:51:05 -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 S231640AbiJYJsN (ORCPT + 99 others); Tue, 25 Oct 2022 05:48:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230213AbiJYJsB (ORCPT ); Tue, 25 Oct 2022 05:48:01 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF17C118764; Tue, 25 Oct 2022 02:47:58 -0700 (PDT) Received: from fraeml708-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRsm01JJz6HJLh; Tue, 25 Oct 2022 17:46:36 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml708-chm.china.huawei.com (10.206.15.36) 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:47:57 +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:47:52 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 01/22] blk-mq: Don't get budget for reserved requests Date: Tue, 25 Oct 2022 18:17:55 +0800 Message-ID: <1666693096-180008-2-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?1747652670337761584?= X-GMAIL-MSGID: =?utf-8?q?1747652670337761584?= It should be possible to send reserved requests even when there is no budget, so don't request a budget in that case. This comes into play when we need to allocate a reserved request from the target device request queue for error handling for that same device. Signed-off-by: John Garry --- block/blk-mq.c | 4 +++- drivers/scsi/scsi_lib.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 260adeb2e455..d8baabb32ea4 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1955,11 +1955,13 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list, errors = queued = 0; do { struct blk_mq_queue_data bd; + bool need_budget; rq = list_first_entry(list, struct request, queuelist); WARN_ON_ONCE(hctx != rq->mq_hctx); - prep = blk_mq_prep_dispatch_rq(rq, !nr_budgets); + need_budget = !nr_budgets && !blk_mq_is_reserved_rq(rq); + prep = blk_mq_prep_dispatch_rq(rq, need_budget); if (prep != PREP_DISPATCH_OK) break; diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index fa96d3cfdfa3..39d4fd124375 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -298,7 +298,8 @@ void scsi_device_unbusy(struct scsi_device *sdev, struct scsi_cmnd *cmd) if (starget->can_queue > 0) atomic_dec(&starget->target_busy); - sbitmap_put(&sdev->budget_map, cmd->budget_token); + if (!blk_mq_is_reserved_rq(scsi_cmd_to_rq(cmd))) + sbitmap_put(&sdev->budget_map, cmd->budget_token); cmd->budget_token = -1; } From patchwork Tue Oct 25 10:17:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10671 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp908176wru; Tue, 25 Oct 2022 02:53:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Xn3Fyro97jMagIxWIdOPtKQEl9tZmS/l0fLZB4qOZ5ctz5TicZjfFhfXtTiLtSI3Bg6QJ X-Received: by 2002:aa7:c78e:0:b0:456:c524:90ec with SMTP id n14-20020aa7c78e000000b00456c52490ecmr35016643eds.192.1666691602082; Tue, 25 Oct 2022 02:53:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691602; cv=none; d=google.com; s=arc-20160816; b=HQuHrWA84+9LmLyUu6eiD3JP9Z+3z+HzGUKjBGaS7ut07mmDehdwjF4/kvlQu5Dag4 HdP+rfZW3gnp+eKcuTfxnfntl3KGA6KzOs08mTw2DKZjCyjwiZBY1AqQtG+yvr15l/Cz 2DDSUBIGBQrIGW/FM4IjdyOcGV3tkPXZxcLRqeJ3vklQyWMZ3xSwBeIQB7Y8pYvqwC23 Hny7XSj35eg6GEkHC1uuPRlMi1TqxFrnnB2MhiwuDGgYHrgnhEkoVSC/sb4xT+WP+xB+ PmhGLD0pJrIXPtlb9OXxeZo9WPzkqcqkartJ5aZt1ngk8u4pUKugO2dVWM1EbvjnUvOM GZPw== 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=89p/4Sxgc4CQxkP/odqAY1iHQPJkyP+KtH39Ey8Dy0Y=; b=YHipkAz+XSzNzmdOBzzUOoQo/1rHN52YEyHaLmtDQeFYlylBa84Nw2Y2Ijp9o8j4f5 OSHzBYEK1myEiZv6pZFSvOIqFZ9mMbK6HxPU+AOnx4DPZDPYGez+uUK/9AgMX/D6Tksm 2JDyRRqr9HoEW9/vGR6UkmmmnwBivIO3cF2qMyPG79KpELDa3i2suX0WP0WnYS/8OLRn l1BsNxja8+xmMouiCOj7IYgOBNzw6+LBoEQX1ETTm2Y+c0XOdup7sjMq9v+EtDwXEbWq L8TiyyTAtZtcZ/3SNYeadAF51rwYf4tFdpec6fY5JamDihuOuQpvEzgrM9uFqI2OlX10 pxhg== 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 a5-20020a170906368500b007a6843971c0si2270752ejc.190.2022.10.25.02.52.57; Tue, 25 Oct 2022 02:53:22 -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 S231878AbiJYJs0 (ORCPT + 99 others); Tue, 25 Oct 2022 05:48:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231379AbiJYJsG (ORCPT ); Tue, 25 Oct 2022 05:48:06 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F3D1110B0E; Tue, 25 Oct 2022 02:48:04 -0700 (PDT) Received: from fraeml705-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRqL71Xnz6893Q; Tue, 25 Oct 2022 17:44:30 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml705-chm.china.huawei.com (10.206.15.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.31; Tue, 25 Oct 2022 11:48:00 +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:47:57 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 02/22] scsi: core: Add scsi_get_dev() Date: Tue, 25 Oct 2022 18:17:56 +0800 Message-ID: <1666693096-180008-3-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?1747652813433808309?= X-GMAIL-MSGID: =?utf-8?q?1747652813433808309?= Add a function which allows us to alloc a sdev with configurable device parent, and channel:id:lun This is useful for separating adding a scsi device into separate alloc and scan steps Signed-off-by: John Garry --- drivers/scsi/scsi_scan.c | 25 +++++++++++++++++++++++++ include/scsi/scsi_host.h | 4 ++++ 2 files changed, 29 insertions(+) diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 5d27f5196de6..ad0a5902d1a0 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -1979,3 +1979,28 @@ void scsi_forget_host(struct Scsi_Host *shost) spin_unlock_irqrestore(shost->host_lock, flags); } +struct scsi_device *scsi_get_dev(struct device *parent, int channel, uint id, u64 lun) +{ + struct Scsi_Host *shost = dev_to_shost(parent); + struct scsi_device *sdev = NULL; + struct scsi_target *starget; + + mutex_lock(&shost->scan_mutex); + if (!scsi_host_scan_allowed(shost)) + goto out; + + starget = scsi_alloc_target(parent, channel, id); + if (!starget) + goto out; + + sdev = scsi_alloc_sdev(starget, lun, NULL); + if (sdev) + sdev->borken = 0; + else + scsi_target_reap(starget); + put_device(&starget->dev); + out: + mutex_unlock(&shost->scan_mutex); + return sdev; +} +EXPORT_SYMBOL(scsi_get_dev); diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index e71436183c0d..750ccf126377 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -787,6 +787,10 @@ void scsi_host_busy_iter(struct Scsi_Host *, struct class_container; + +extern struct scsi_device *scsi_get_dev(struct device *parent, int channel, + uint id, u64 lun); + /* * DIF defines the exchange of protection information between * initiator and SBC block device. From patchwork Tue Oct 25 10:17:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10663 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp907341wru; Tue, 25 Oct 2022 02:51:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4qgElAmJ4QMXGH6shrhJZy8+zS0jNir3/VbyQbEBb81bO/bYDb5PT4b6m65MQURMSnTn4/ X-Received: by 2002:a63:eb4a:0:b0:46f:63f:a892 with SMTP id b10-20020a63eb4a000000b0046f063fa892mr8805659pgk.33.1666691460138; Tue, 25 Oct 2022 02:51:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691460; cv=none; d=google.com; s=arc-20160816; b=pjEl834c4lqQ+f2PTyTFPtRGIpLjIt4V3g2+vOs9wiK3hTFHFGsZP9o1EhA8EF3Zoh Q4fgLRtmQAPKKlICZGDKPGwxnnx3LU3tLKtUVi2qElXfHB13Go/e6yKbza6a7HBtwJcx sRBCp62y1+NDi6Z/LaXaxwfGw4IK7vW/qagHc0cxST3814L7cRB1h4tgWqrjxEFV0+kY jyXXxOp0ASXkD1yCaJwjKh+qVOIFq06W54wk9SmzAcYW/MQ6fWGZCOl6bHfqgUb1Tkpt mrZEkDrn8WRLW9tfzq0O5mL4zSeO52i6Cywe6PGueE6PW8uwUHN51eA82FBusvdy6N2n Tnew== 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=qTQOiahHLDfY4mgkx9YMjHO7E5GBSJKU3yE+4wLsVqA=; b=Q9DA08k6wcxj5TTl67ViU3frRYaeNVAV54Qe+Jnzb5SAxWxo7TfEA8lTp0N/dUch4E S+7lKsmgbG9lWJDaMtdyFbZkKZltg1pl5Ks6cxzmBET4MMo9XCU3uKE/9tV0cofTI2Av ZX0i2Rqe3C81tFg6TZaEJQcyU+Bt973CSqMvEqRbygMaJyOnbMikCfaGWrxIwFJIiD+L rScRbTGFL7oHj8eUxf6Uhm5EGKi0064ZZAaVZ3r4TnG+CEdnPTsycNxza2iPE12+pX9f r694h4gu4RtJogElh/SBtubRmLg+pYhUHEf9JCAdTtV4sNSj2WS2xvxDGhox+yyufG+p m9Vg== 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 j6-20020a633c06000000b004404162e5e0si2527202pga.593.2022.10.25.02.50.46; Tue, 25 Oct 2022 02:51:00 -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 S231808AbiJYJsR (ORCPT + 99 others); Tue, 25 Oct 2022 05:48:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230360AbiJYJsI (ORCPT ); Tue, 25 Oct 2022 05:48:08 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73DCE4E625; Tue, 25 Oct 2022 02:48:07 -0700 (PDT) Received: from fraeml704-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRqR2sY4z689TS; Tue, 25 Oct 2022 17:44:35 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml704-chm.china.huawei.com (10.206.15.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.31; Tue, 25 Oct 2022 11:48:05 +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:48:01 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 03/22] scsi: core: Implement reserved command handling Date: Tue, 25 Oct 2022 18:17:57 +0800 Message-ID: <1666693096-180008-4-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?1747652664882457301?= X-GMAIL-MSGID: =?utf-8?q?1747652664882457301?= From: Hannes Reinecke Quite some drivers are using management commands internally, which typically use the same hardware tag pool (ie they are being allocated from the same hardware resources) as the 'normal' I/O commands. These commands are set aside before allocating the block-mq tag bitmap, so they'll never show up as busy in the tag map. The block-layer, OTOH, already has 'reserved_tags' to handle precisely this situation. So this patch adds a new field 'nr_reserved_cmds' to the SCSI host template to instruct the block layer to set aside a tag space for these management commands by using reserved tags. Signed-off-by: Hannes Reinecke #jpg: Set tag_set->queue_depth = shost->can_queue, and not = shost->can_queue + shost->nr_reserved_cmds; Signed-off-by: John Garry --- drivers/scsi/hosts.c | 3 +++ drivers/scsi/scsi_lib.c | 2 ++ include/scsi/scsi_host.h | 15 ++++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 12346e2297fd..db89afc37bc9 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -489,6 +489,9 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) if (sht->virt_boundary_mask) shost->virt_boundary_mask = sht->virt_boundary_mask; + if (sht->nr_reserved_cmds) + shost->nr_reserved_cmds = sht->nr_reserved_cmds; + device_initialize(&shost->shost_gendev); dev_set_name(&shost->shost_gendev, "host%d", shost->host_no); shost->shost_gendev.bus = &scsi_bus_type; diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 39d4fd124375..a8c4e7c037ae 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1978,6 +1978,8 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost) tag_set->nr_hw_queues = shost->nr_hw_queues ? : 1; tag_set->nr_maps = shost->nr_maps ? : 1; tag_set->queue_depth = shost->can_queue; + tag_set->reserved_tags = shost->nr_reserved_cmds; + tag_set->cmd_size = cmd_size; tag_set->numa_node = dev_to_node(shost->dma_dev); tag_set->flags = BLK_MQ_F_SHOULD_MERGE; diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 750ccf126377..91678c77398e 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -360,10 +360,17 @@ struct scsi_host_template { /* * This determines if we will use a non-interrupt driven * or an interrupt driven scheme. It is set to the maximum number - * of simultaneous commands a single hw queue in HBA will accept. + * of simultaneous commands a single hw queue in HBA will accept + * including reserved commands. */ int can_queue; + /* + * This determines how many commands the HBA will set aside + * for reserved commands. + */ + int nr_reserved_cmds; + /* * In many instances, especially where disconnect / reconnect are * supported, our host also has an ID on the SCSI bus. If this is @@ -611,6 +618,12 @@ struct Scsi_Host { */ unsigned nr_hw_queues; unsigned nr_maps; + + /* + * Number of reserved commands to allocate, if any. + */ + unsigned int nr_reserved_cmds; + unsigned active_mode:2; /* From patchwork Tue Oct 25 10:17:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10676 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp908383wru; Tue, 25 Oct 2022 02:53:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7PtQ/sHEBFcc/x/geJmf/uSy5/L+r1mKmL1ARdvdt3K3m2JPofEvlGjOpBTTHr5ZzhIAAA X-Received: by 2002:a17:907:1b24:b0:76d:7b9d:2f8b with SMTP id mp36-20020a1709071b2400b0076d7b9d2f8bmr30098434ejc.414.1666691636309; Tue, 25 Oct 2022 02:53:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691636; cv=none; d=google.com; s=arc-20160816; b=pYR378oA4oTOFVGTVlHdQ6EHE8RFSMwPi8iYL5deoTHwA/FetlKODH3qKZjxJdbONV ifWCMcPJ2tr6BK1+HHRxmoLbcr+0ZChnJ0cCinSKynwySKIA83SHbbU4MkRxPeEKOf6a HoV+Hr9z8V4C2rNGlxqW/YAVtrLbZ5x6Dna/hnQ0YV3cHeik6poHqLEviNsCSuTS3z5Z cP4ih/wmInA5wjtjR+7ntEQZfmOypUmlyPYhFoFDFjYNGp7AXDAriE2e8CMhp5Qw1+87 Vz2ZbisnK4odq9uT7V02bK/2lxtxsZXDkcfNmB+wlczTZ5eZ0Cre/drSSkAR9RB2CIyB ZC2A== 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=zGCRiTGdB5qFyzp4Koo7dAcNu4cplUZTfErz9HOBl4A=; b=B+Bj55Z1xVWUNJnvyy8E2jzzS0E9iOGzROGUB/TWw/6L5iHVxgNGBhN55d+vJAOY6Z CcmUAx/8PlO9781dDfQh5BpWOGXoKJwhXKGCUZuzhVE/gOkSPVjN+qhAagQH+wWm30C8 ODKpbzPbDJdqjhXkiQI9JTJ6Go9LzQpPbakfdkThvpk/b+So27VoxBh5vjeISCsV6VU6 AVB4/UunEzlAUmKiMAq074s8DAr319JZS8d/4Pc+iQeBT9w5SuXO/OHnPapuUhYbXNRX 1YdWnE094x+RCdNsavS5MRikWrLINQeR7EtLrCqpIKNkId4KILfu31HGUHNsW0Q55EHB JOwA== 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 x19-20020a05640226d300b0043dfc949d31si2687906edd.25.2022.10.25.02.53.32; Tue, 25 Oct 2022 02:53:56 -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 S230025AbiJYJsm (ORCPT + 99 others); Tue, 25 Oct 2022 05:48:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231614AbiJYJsN (ORCPT ); Tue, 25 Oct 2022 05:48:13 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03A91111B99; Tue, 25 Oct 2022 02:48:12 -0700 (PDT) Received: from fraeml703-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRqW5gcqz67xV0; Tue, 25 Oct 2022 17:44:39 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml703-chm.china.huawei.com (10.206.15.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.31; Tue, 25 Oct 2022 11:48:09 +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:48:05 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 04/22] scsi: core: Add support to send reserved commands Date: Tue, 25 Oct 2022 18:17:58 +0800 Message-ID: <1666693096-180008-5-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?1747652849357371853?= X-GMAIL-MSGID: =?utf-8?q?1747652849357371853?= Add a method to queue reserved commands. Signed-off-by: John Garry --- drivers/scsi/hosts.c | 6 ++++++ drivers/scsi/scsi_lib.c | 25 +++++++++++++++++++++++++ include/scsi/scsi_host.h | 1 + 3 files changed, 32 insertions(+) diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index db89afc37bc9..78968553089f 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -230,6 +230,12 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, goto fail; } + if (shost->nr_reserved_cmds && !sht->reserved_queuecommand) { + shost_printk(KERN_ERR, shost, + "nr_reserved_cmds set but no method to queue\n"); + goto fail; + } + /* Use min_t(int, ...) in case shost->can_queue exceeds SHRT_MAX */ shost->cmd_per_lun = min_t(int, shost->cmd_per_lun, shost->can_queue); diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index a8c4e7c037ae..08015c42c326 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1428,6 +1428,16 @@ static void scsi_complete(struct request *rq) struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq); enum scsi_disposition disposition; + if (blk_mq_is_reserved_rq(rq)) { + struct scsi_device *sdev = cmd->device; + + scsi_mq_uninit_cmd(cmd); + scsi_device_unbusy(sdev, cmd); + __blk_mq_end_request(rq, 0); + + return; + } + INIT_LIST_HEAD(&cmd->eh_entry); atomic_inc(&cmd->device->iodone_cnt); @@ -1718,6 +1728,21 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx, blk_status_t ret; int reason; + if (blk_mq_is_reserved_rq(req)) { + if (!(req->rq_flags & RQF_DONTPREP)) { + ret = scsi_prepare_cmd(req); + if (ret != BLK_STS_OK) + goto out_dec_host_busy; + + req->rq_flags |= RQF_DONTPREP; + } else { + clear_bit(SCMD_STATE_COMPLETE, &cmd->state); + } + blk_mq_start_request(req); + + return shost->hostt->reserved_queuecommand(shost, cmd); + } + WARN_ON_ONCE(cmd->budget_token < 0); /* diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 91678c77398e..a39f36aa0b0d 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -73,6 +73,7 @@ struct scsi_host_template { * STATUS: REQUIRED */ int (* queuecommand)(struct Scsi_Host *, struct scsi_cmnd *); + int (*reserved_queuecommand)(struct Scsi_Host *, struct scsi_cmnd *); /* * The commit_rqs function is used to trigger a hardware From patchwork Tue Oct 25 10:17:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10675 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp908308wru; Tue, 25 Oct 2022 02:53:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7YJzIdM9dq3GcOZvb69c5s+73rJHqeeZAonXvUD7otHboBTSRykHUROesdXTCh49ndMwJ3 X-Received: by 2002:a17:906:9746:b0:78e:11cc:3bb3 with SMTP id o6-20020a170906974600b0078e11cc3bb3mr31615861ejy.379.1666691623605; Tue, 25 Oct 2022 02:53:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691623; cv=none; d=google.com; s=arc-20160816; b=WVQNWnLi8tYZzKFZft0btl9lqXtPjV64N6g8/hS0AYm4kMnXQju0n+7lMx3P+gY2FQ g537ZaqfSHNHe+yCTTkSRy9bjB6zO/vYT/nCBeYGQolK/toVIL5c4sU7qobPUEAyO97m vf8Exvnongc41T4TFetgquPHe/eoJA4F12BXYP9OVnbtC3dbb2XrbuqsbI/QOyMOqbC2 xE3YaSlU7XPQ1XpRlpFqmNysbyuk/q4Bw+rEmFsonn6tzzjOnBbq51TOYYRBitEZ/atn JA4LIs4isCypsRi4T415+U24jjIYIetZNCFudV+PsOf/6C1tGxJytcTTKh5bQUNKhTbS 4rjw== 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=OUr431bKUimkIDJD3Q6qoJDpGGicDfDp11DDof8fh+E=; b=vuDOSnjC/MqbLhrDLlkFYRdCHHKuLcxQPkxN0bi9ds2ZcX9AUCJJLbwwd4wrP04Dec QE8zl1j4NR4Ep3kZWPp6wngLgxQJ82+7x6/Ojk9ktg652MhHZtT4cr/IWSdy7//voEuE l8JWNGOFCo7n78v/y/lAI8zxEgmjxoG916k4KuPL6C0fvFluOTW5WuuZsMlTnNAGcIEy oWMnlJ5/EcRVB5SFfs0nchuxuTiTvhWhxpBvI12I1f9Qe/B13utys6slGiwnyK9YKazu ++OOwDI8rVUAtuyj3sLm5RNvWNwPSRhsqJuQlGcGH9nbHu5Xo6OS0TrQ3DnOVEQZPskU FlvQ== 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 ht12-20020a170907608c00b0078dacbcaa7asi2440927ejc.992.2022.10.25.02.53.18; Tue, 25 Oct 2022 02:53:43 -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 S231792AbiJYJso (ORCPT + 99 others); Tue, 25 Oct 2022 05:48:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231805AbiJYJsR (ORCPT ); Tue, 25 Oct 2022 05:48:17 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CBA312B354; Tue, 25 Oct 2022 02:48:16 -0700 (PDT) Received: from fraeml702-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRqc0nS9z67XGR; Tue, 25 Oct 2022 17:44:44 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml702-chm.china.huawei.com (10.206.15.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.31; Tue, 25 Oct 2022 11:48: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:48:10 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 05/22] scsi: core: Add support for reserved command timeout handling Date: Tue, 25 Oct 2022 18:17:59 +0800 Message-ID: <1666693096-180008-6-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?1747652835799441461?= X-GMAIL-MSGID: =?utf-8?q?1747652835799441461?= Add support for reserved timeout handling. Any driver which specifies that it supports reserved tags must supply a handler. Signed-off-by: John Garry --- drivers/scsi/hosts.c | 15 +++++++++++---- drivers/scsi/scsi_error.c | 3 +++ include/scsi/scsi_host.h | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 78968553089f..52346085b3c1 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -230,10 +230,17 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, goto fail; } - if (shost->nr_reserved_cmds && !sht->reserved_queuecommand) { - shost_printk(KERN_ERR, shost, - "nr_reserved_cmds set but no method to queue\n"); - goto fail; + if (shost->nr_reserved_cmds) { + if (!sht->reserved_queuecommand) { + shost_printk(KERN_ERR, shost, + "nr_reserved_cmds set but no method to queue\n"); + goto fail; + } + if (!sht->reserved_timedout) { + shost_printk(KERN_ERR, shost, + "nr_reserved_cmds set but no method to handle timeouts\n"); + goto fail; + } } /* Use min_t(int, ...) in case shost->can_queue exceeds SHRT_MAX */ diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 6995c8979230..2f86a4284f29 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -338,6 +338,9 @@ enum blk_eh_timer_return scsi_timeout(struct request *req) if (host->eh_deadline != -1 && !host->last_reset) host->last_reset = jiffies; + if (blk_mq_is_reserved_rq(req)) + return host->hostt->reserved_timedout(scmd); + if (host->hostt->eh_timed_out) rtn = host->hostt->eh_timed_out(scmd); diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index a39f36aa0b0d..266c13e731de 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -74,6 +74,7 @@ struct scsi_host_template { */ int (* queuecommand)(struct Scsi_Host *, struct scsi_cmnd *); int (*reserved_queuecommand)(struct Scsi_Host *, struct scsi_cmnd *); + enum blk_eh_timer_return (*reserved_timedout)(struct scsi_cmnd *); /* * The commit_rqs function is used to trigger a hardware From patchwork Tue Oct 25 10:18:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10665 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp907656wru; Tue, 25 Oct 2022 02:51:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5QNPS8Th/s66DIjGOW0sewVFE2Gmyp7HzLsUjXXaMhz6Pa/5SYhIeiCn4abOUIBmajcIeg X-Received: by 2002:a17:907:3ea9:b0:78d:fdf0:88fe with SMTP id hs41-20020a1709073ea900b0078dfdf088femr32860433ejc.667.1666691512402; Tue, 25 Oct 2022 02:51:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691512; cv=none; d=google.com; s=arc-20160816; b=Ala9cdfnjJtoFH9p9PHy+2/8Wwwx183U4QaI2u+0hUxfEfPrUN1bN4wE8XuNNvdwrG xAW9m+GEhBpeeBbLzrI9/pQrT/KxkEyEkQTfa6jZpzMNTVgIp7P52DiKnXv1KrOxzz8H rilslBe29n9+qRoJeOBKcyma1hC4Hq0/q4OIRL+0aTVRdQXdnZhJsje7jeC1m8Hk6147 HynKx4Md0xtyRezRjEzHlLbDHT7FAMIUhq4VKtPByQwJcQ3V7SSA6jNTYSmEScZza0Nv 0r7v9xokxha31uTzDhPPHq1eYbue5BvRMY+ucEASEg7mkMfLtsmdV+MtyKmLbv51cSrt 6zew== 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=O16xvWrKFzhvh0L17SFR5/HZSvZr7N4IlJ/RNBEiZcs=; b=01ttwidL1aV+hmQkUnLO05uwJr6+hY8wDuFYAt8xf2eDqlILW8gEAHGSSVoe99EH4m es96lbtoZlNPzNsWHq4g/kvFSIiUMhMxpkbWZ/FRGjGJKEm0bIKsGNBbyDhA5jLgscZd T01dCQTx5GJ4+4YHdXbHB+ie+xx93o/ODDaLpfH2nCgrHwLCJwwfVJcfE8hU9vAKLTbs VESqDS+aOqxGAo6KgUoCpN7sX5ou5dcelDtNH736L+jzWMK1lE4xCFTO4SkWB9IZs8D0 hDZSvLGH8VFbdoB4omriUcUsSzMCLw1HlZ/ZJ2+WRf+qcO7dxM2662GgrjG311F2Mv5O 5NxQ== 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 b14-20020a056402084e00b0045d9ceae6d8si2813837edz.492.2022.10.25.02.51.28; Tue, 25 Oct 2022 02:51:52 -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 S229955AbiJYJuA (ORCPT + 99 others); Tue, 25 Oct 2022 05:50:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232005AbiJYJsg (ORCPT ); Tue, 25 Oct 2022 05:48:36 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E70A1136423; Tue, 25 Oct 2022 02:48:20 -0700 (PDT) Received: from fraeml701-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRsY5jf1z6H72c; Tue, 25 Oct 2022 17:46:25 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml701-chm.china.huawei.com (10.206.15.50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.31; Tue, 25 Oct 2022 11:48:18 +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:48:14 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 06/22] scsi: libsas: Improve sas_ex_discover_expander() error handling Date: Tue, 25 Oct 2022 18:18:00 +0800 Message-ID: <1666693096-180008-7-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?1747652719611881581?= X-GMAIL-MSGID: =?utf-8?q?1747652719611881581?= Errors in function sas_ex_discover_expander() are generally ignored, so add handling to gracefully handles errors in all cases. Signed-off-by: John Garry --- drivers/scsi/libsas/sas_expander.c | 50 ++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index 2907ca5d0ed4..9e33014ec412 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c @@ -919,7 +919,6 @@ static struct domain_device *sas_ex_discover_expander( struct sas_rphy *rphy; struct sas_expander_device *edev; struct asd_sas_port *port; - int res; if (phy->routing_attr == DIRECT_ROUTING) { pr_warn("ex %016llx:%02d:D <--> ex %016llx:0x%x is not allowed\n", @@ -933,9 +932,11 @@ static struct domain_device *sas_ex_discover_expander( return NULL; phy->port = sas_port_alloc(&parent->rphy->dev, phy_id); - /* FIXME: better error handling */ - BUG_ON(sas_port_add(phy->port) != 0); + if (!phy->port) + goto err_put_child; + if (!sas_port_add(phy->port)) + goto err_delete_port; switch (phy->attached_dev_type) { case SAS_EDGE_EXPANDER_DEVICE: @@ -948,8 +949,15 @@ static struct domain_device *sas_ex_discover_expander( break; default: rphy = NULL; /* shut gcc up */ - BUG(); + pr_warn("ex unhandled dev type %d %016llx:%02d:D <--> ex %016llx:%02d\n", + phy->attached_dev_type, + SAS_ADDR(parent->sas_addr), phy_id, + SAS_ADDR(phy->attached_sas_addr), + phy->attached_phy_id); } + if (!rphy) + goto err_free_port; + port = parent->port; child->rphy = rphy; get_device(&rphy->dev); @@ -967,26 +975,36 @@ static struct domain_device *sas_ex_discover_expander( parent->port->disc.max_level = max(parent->port->disc.max_level, edev->level); sas_init_dev(child); + sas_fill_in_rphy(child, rphy); - sas_rphy_add(rphy); + if (!sas_rphy_add(rphy)) + goto err_rphy_free; spin_lock_irq(&parent->port->dev_list_lock); list_add_tail(&child->dev_list_node, &parent->port->dev_list); spin_unlock_irq(&parent->port->dev_list_lock); - res = sas_discover_expander(child); - if (res) { - sas_rphy_delete(rphy); - spin_lock_irq(&parent->port->dev_list_lock); - list_del(&child->dev_list_node); - spin_unlock_irq(&parent->port->dev_list_lock); - sas_put_device(child); - sas_port_delete(phy->port); - phy->port = NULL; - return NULL; - } + if (!sas_discover_expander(child)) + goto err_rphy_remove; + list_add_tail(&child->siblings, &parent->ex_dev.children); return child; + +err_rphy_remove: + spin_lock_irq(&parent->port->dev_list_lock); + list_del(&child->dev_list_node); + spin_unlock_irq(&parent->port->dev_list_lock); + sas_rphy_remove(rphy); +err_rphy_free: + sas_rphy_free(rphy); +err_free_port: + sas_port_free(phy->port); +err_delete_port: + sas_port_delete(phy->port); + phy->port = NULL; +err_put_child: + sas_put_device(child); + return NULL; } static int sas_ex_discover_dev(struct domain_device *dev, int phy_id) From patchwork Tue Oct 25 10:18:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10667 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp907913wru; Tue, 25 Oct 2022 02:52:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4cZbmZJENqd9JW4Ob/I1N5hFz0vrw6E10wAnIc6C8xdkCOKWKRTqt8iRiKc9+7jfySDwHH X-Received: by 2002:a63:5a41:0:b0:430:673e:1e13 with SMTP id k1-20020a635a41000000b00430673e1e13mr32604667pgm.435.1666691556313; Tue, 25 Oct 2022 02:52:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691556; cv=none; d=google.com; s=arc-20160816; b=MLM9nWlo1h4L/TLWoxu3EvaTAI0OKuTHMcZZxzK7LloX2TcDq8Q3jOerPh+L9YNme4 8M5vEEdHspMdjCPVaXpxomUysUknydLgTU3Fbs9dBk98ocQVcRRK7hKRggn5nMjBRY+A mVzNLq7kFAH/3koceP3zpfOwzdFVyPAGs0MbZIvUmZbGQyJ1dKpwiQg/ahuLkIiotE55 EECQnp44mugVAYaRmMmgLo98pH/8FS0a82Ptl8EWq6vnmFOoilH+S+bnYd2Z1ESbgPDX kCuePu0QFAz9vxBP4P0+9rjxInQ+W+ehcfA940kA+S4ZsrFWT20ka7TkMU4WQ9dGRtNQ 8yhA== 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=5y7XN4x0t7BpaA//zSHoYzleoLUnpLPPlRp6n9PJsYQ=; b=gTHQExaT5hq7Bk9/mN40FFLf6hlA31Myr7A81RZ7tX0t6xXauPSlf1e/SlWu5ghOYx FaETdl0lgCUdZFsbqFYgkag2s18326mHTcRYFjjC3HfPtO6wgVfDEomtVEWc07oxR7Zn tmK0ba0Y+NUjYTaNQ5Zd4aLnhTVb0b6yaFGD+IwWn49QAWDOirdsJ9WOf5ADQ2GM3KWD HdsEz4N0AIbfeAsV+aLpKysyRZ9Ek2pjTOSq1EpOr4QuzCGGZfC/nK22aWpTZ5hprRHc 4JcHMeqzdad3kjJEFIe/fzQFX+xd76dEwK1iZFa4yBOGCQg/hTE3kQuP3V1if2+TX4RD AdUQ== 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 mn17-20020a17090b189100b0020af2411705si2297145pjb.104.2022.10.25.02.52.20; Tue, 25 Oct 2022 02:52:36 -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 S231743AbiJYJuZ (ORCPT + 99 others); Tue, 25 Oct 2022 05:50:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231523AbiJYJtU (ORCPT ); Tue, 25 Oct 2022 05:49:20 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8AC114D1CC; Tue, 25 Oct 2022 02:48:24 -0700 (PDT) Received: from frapeml500008.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRtF5LLwz67vyB; Tue, 25 Oct 2022 17:47:01 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by frapeml500008.china.huawei.com (7.182.85.71) 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:48:22 +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:48:18 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 07/22] scsi: libsas: Notify LLDD expander found before calling sas_rphy_add() Date: Tue, 25 Oct 2022 18:18:01 +0800 Message-ID: <1666693096-180008-8-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?1747652765113006113?= X-GMAIL-MSGID: =?utf-8?q?1747652765113006113?= Ensure that we notify the LLDD of the expander being found before calling sas_rphy_add() as this function will require the LLDD be notified when we alloc a scsi device for an expander. Signed-off-by: John Garry --- drivers/scsi/libsas/sas_expander.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index 9e33014ec412..e7cb95683522 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c @@ -976,9 +976,12 @@ static struct domain_device *sas_ex_discover_expander( edev->level); sas_init_dev(child); + if (!sas_notify_lldd_dev_found(child)) + goto err_rphy_free; + sas_fill_in_rphy(child, rphy); if (!sas_rphy_add(rphy)) - goto err_rphy_free; + goto err_dev_gone; spin_lock_irq(&parent->port->dev_list_lock); list_add_tail(&child->dev_list_node, &parent->port->dev_list); @@ -995,6 +998,8 @@ static struct domain_device *sas_ex_discover_expander( list_del(&child->dev_list_node); spin_unlock_irq(&parent->port->dev_list_lock); sas_rphy_remove(rphy); +err_dev_gone: + sas_notify_lldd_dev_gone(child); err_rphy_free: sas_rphy_free(rphy); err_free_port: @@ -1575,32 +1580,22 @@ static int sas_discover_expander(struct domain_device *dev) { int res; - res = sas_notify_lldd_dev_found(dev); - if (res) - return res; - res = sas_ex_general(dev); if (res) - goto out_err; + return res; res = sas_ex_manuf_info(dev); if (res) - goto out_err; + return res; res = sas_expander_discover(dev); if (res) { pr_warn("expander %016llx discovery failed(0x%x)\n", SAS_ADDR(dev->sas_addr), res); - goto out_err; + return res; } sas_check_ex_subtractive_boundary(dev); - res = sas_check_parent_topology(dev); - if (res) - goto out_err; - return 0; -out_err: - sas_notify_lldd_dev_gone(dev); - return res; + return sas_check_parent_topology(dev); } static int sas_ex_level_discovery(struct asd_sas_port *port, const int level) @@ -1643,6 +1638,10 @@ int sas_discover_root_expander(struct domain_device *dev) int res; struct sas_expander_device *ex = rphy_to_expander_device(dev->rphy); + res = sas_notify_lldd_dev_found(dev); + if (res) + return res; + res = sas_rphy_add(dev->rphy); if (res) goto out_err; @@ -1659,6 +1658,7 @@ int sas_discover_root_expander(struct domain_device *dev) out_err2: sas_rphy_remove(dev->rphy); out_err: + sas_notify_lldd_dev_gone(dev); return res; } From patchwork Tue Oct 25 10:18:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10666 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp907817wru; Tue, 25 Oct 2022 02:52:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6tVpxq2ySK9WUefn7aU58rk+G+dxcE20cykHTMn4o07YT76md1shn1yD+0x1LlNNCBFiLz X-Received: by 2002:a05:6402:190e:b0:45c:d10a:4c1a with SMTP id e14-20020a056402190e00b0045cd10a4c1amr35109453edz.345.1666691536068; Tue, 25 Oct 2022 02:52:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691536; cv=none; d=google.com; s=arc-20160816; b=cUu8CHI0nOF+2ChkFJF+kOPw5ChM0dnyjgsFVl8zmWbzAsIN5eQrp4435437C8HgyN 1ZtsM48rHI5NgA/sMOJ+BvCoqBoUWlSRVwLjXmjJu3+lIQooZbVJFJlBUqxAd16WZY3m hImmsG4TMZRj6EwbCHuUceSNQhiuhbK1QnQeMXvvniskpht0waQJHUZah3KtISZfyDLe 6k+CZC3UkFxmG+td00+FGt25gdo6yveZK4Vbtvu6uccPP4qWOZq19M+FYHch/bQZAmXj xijjSUkDFdZSdWoaVbezr7yumEw2Zo/WjY/5C1OIqbWM7v8udFTNKLFuKJ3x2JHkdPqH Fbiw== 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=xGPXYlqD8pXe6yDaFI0uF0Z/RpxJUHfZnbyqt50nP0U=; b=OkYVrpBnM4bMFGZDaeiCIPwCVkBEEm5S2dYM9AYkuHm79hYydQshIFJjVGcEOeG0Ko Fug4QEHMNsu3PnR4INZIzu+XMDzCDnhxzfmJNi7pvTU/VQzVvvoPCgrS3yvTGwnUd4yr oNOvto+gRH+IziKZr0p3/m5znXruyctkkPd24AclkYKEbeY5yj9O5QFgpdmx+z7LDj3E 1bIObqNP+56tVEZ5aGJBgrobZcSlqHWSr2gm79SYJD9hnOXz9lPrW7r40e2ZZLl2k2c2 vP1dgzS5rOLmLMUT9+uZuQm7+VH90hCH3LYlFE7ah2LvP68847NzPRepfDhXf9B6nU4G f9eA== 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 hs21-20020a1709073e9500b0073d81935416si1739189ejc.749.2022.10.25.02.51.52; Tue, 25 Oct 2022 02:52:16 -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 S231609AbiJYJud (ORCPT + 99 others); Tue, 25 Oct 2022 05:50:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231468AbiJYJtU (ORCPT ); Tue, 25 Oct 2022 05:49:20 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C39AC14D8D6; Tue, 25 Oct 2022 02:48:29 -0700 (PDT) Received: from frapeml500006.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRsk3Wldz688p7; Tue, 25 Oct 2022 17:46:34 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by frapeml500006.china.huawei.com (7.182.85.219) 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:48:27 +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:48:22 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 08/22] scsi: scsi_transport_sas: Alloc sdev for expander Date: Tue, 25 Oct 2022 18:18:02 +0800 Message-ID: <1666693096-180008-9-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?1747652744221802674?= X-GMAIL-MSGID: =?utf-8?q?1747652744221802674?= Allocate a scsi device for an expander for sending SMP commands on the expander sdev request queue. Use channel=1 to not conflict with scsi target devices. Signed-off-by: John Garry --- drivers/scsi/scsi_transport_sas.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c index 2f88c61216ee..da075dfc7cd0 100644 --- a/drivers/scsi/scsi_transport_sas.c +++ b/drivers/scsi/scsi_transport_sas.c @@ -1548,6 +1548,11 @@ int sas_rphy_add(struct sas_rphy *rphy) scsi_scan_target(&rphy->dev, 0, rphy->scsi_target_id, lun, SCSI_SCAN_INITIAL); + } else if (identify->device_type == SAS_EDGE_EXPANDER_DEVICE || + identify->device_type == SAS_FANOUT_EXPANDER_DEVICE) { + + if (!scsi_get_dev(&rphy->dev, 1, rphy->scsi_target_id, 0)) + return -ENODEV; } return 0; @@ -1627,6 +1632,7 @@ sas_rphy_remove(struct sas_rphy *rphy) case SAS_EDGE_EXPANDER_DEVICE: case SAS_FANOUT_EXPANDER_DEVICE: sas_remove_children(dev); + scsi_remove_target(dev); break; default: break; From patchwork Tue Oct 25 10:18:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10672 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp908260wru; Tue, 25 Oct 2022 02:53:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4TNseg7GRL301ikSYxdvs/snzjxtJIpV+F9ed5CjUAPFOR0y06iDBO7gYmSqrRcbiBvjHV X-Received: by 2002:a17:906:ef8c:b0:78d:4a00:7c7b with SMTP id ze12-20020a170906ef8c00b0078d4a007c7bmr32256215ejb.187.1666691615998; Tue, 25 Oct 2022 02:53:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691615; cv=none; d=google.com; s=arc-20160816; b=SUYM6vDnWuxs8YtZKBnyy+7ZxQLQLCVBUA+0y5i3zDFO2HFUMd/tjWW2ZHr5tLlZ4d EAgCSNKU1TRjYfR7hMBvbKREAXNd6EJRxDGgkzW2gb0o1VqS8CChd4JPxV+1ni/3aqVZ blIn0wmP9c1gGDDFM7xqyZ6s+XPybY1JhhDpRlwt02zqxgF2s0I7wF0YbWzdlwhR/Je+ LM3sz6zkT/XZWS2SUQ57BXWhELwAkI7eGnjm7VcK/YN8YSgJh4VOSNaXYLZ3b/WZw13E O1z6HFkzjO4RMaRwAw1lvVXacT74QvWa1pNvEg09hidrp342UAS4+QUNC+j8cF2TlsiJ ulqg== 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=oe7xEg89fDmuKxFGAK+VpOV5h7evGCmGFAKlmyNkn2g=; b=PaNdlPiY/IlegCNIRjziKXkTRK0eyVgTc9Dbw5s8NKeEdq1uX1RDkVYkYddYw2fxIO bDbOa3UqhCG1AIt8ekeJuWII3CJMzzhz+nxY5fDJ8vRKIjaQAkAG7W9WeH5Jx8BWDWoY DBClU7BD8KyZ04DqWta+xLJ05FTEIIlDU1D2RlsGxr8XcCkazlsm05ulV4O/OqqhUeoc mORD8LrVbxy7Yzwp6hJnRgUWjjqGmqZWBRBs0TVRKKqVacfpckJAhej/kqqMPy+VxM0r H/m+20wT80ncQaBuNxjSjSnfa6mo+CtjVHdhFNR2XRV26mV8dR6eHgxlSKh6Hhciod26 1kPg== 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 ly25-20020a170906af5900b0078da30cb4bfsi1696324ejb.428.2022.10.25.02.53.09; Tue, 25 Oct 2022 02:53:35 -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 S231165AbiJYJun (ORCPT + 99 others); Tue, 25 Oct 2022 05:50:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231806AbiJYJt5 (ORCPT ); Tue, 25 Oct 2022 05:49:57 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50A2615746D; Tue, 25 Oct 2022 02:48:33 -0700 (PDT) Received: from frapeml500005.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRtQ3D83z6HJMX; Tue, 25 Oct 2022 17:47:10 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by frapeml500005.china.huawei.com (7.182.85.13) 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:48:31 +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:48:27 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 09/22] scsi: libsas: Add sas_alloc_slow_task_rq() Date: Tue, 25 Oct 2022 18:18:03 +0800 Message-ID: <1666693096-180008-10-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?1747652827991497876?= X-GMAIL-MSGID: =?utf-8?q?1747652827991497876?= Add a function to add a slow task with a request associated. The next step will be to send tasks same as we do for other requests - through the block layer. Signed-off-by: John Garry --- drivers/scsi/libsas/sas_init.c | 51 ++++++++++++++++++++++++++++++ drivers/scsi/libsas/sas_internal.h | 1 + include/scsi/libsas.h | 2 +- 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/libsas/sas_init.c b/drivers/scsi/libsas/sas_init.c index f2c05ebeb72f..90e63ff5e966 100644 --- a/drivers/scsi/libsas/sas_init.c +++ b/drivers/scsi/libsas/sas_init.c @@ -56,9 +56,60 @@ struct sas_task *sas_alloc_slow_task(gfp_t flags) return task; } +struct sas_task *sas_alloc_slow_task_rq(struct domain_device *device, gfp_t flags) +{ + struct sas_ha_struct *sas_ha = device->port->ha; + struct Scsi_Host *shost = sas_ha->core.shost; + struct scsi_device *sdev, *found_sdev = NULL; + struct scsi_cmnd *scmd; + struct sas_task *task; + struct request *rq; + + shost_for_each_device(sdev, shost) { + struct scsi_target *starget = sdev->sdev_target; + + if (starget->hostdata == device) { + found_sdev = sdev; + break; + } + } + + if (!found_sdev) + return NULL; + + scsi_device_put(found_sdev); + + task = sas_alloc_slow_task(flags); + if (!task) + return NULL; + + task->dev = device; + + rq = scsi_alloc_request(sdev->request_queue, REQ_OP_DRV_IN, + BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT); + if (IS_ERR(rq)) { + sas_free_task(task); + return NULL; + } + + scmd = blk_mq_rq_to_pdu(rq); + + task->uldd_task = scmd; + rq->end_io_data = task; + + return task; +} + void sas_free_task(struct sas_task *task) { if (task) { + if (task->slow_task && task->uldd_task) { + struct scsi_cmnd *scmd = task->uldd_task; + struct request *rq = scsi_cmd_to_rq(scmd); + + BUG_ON(!blk_mq_is_reserved_rq(rq)); + blk_mq_free_request(rq); + } kfree(task->slow_task); kmem_cache_free(sas_task_cache, task); } diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h index 6cf190ade35e..f5ae4de382f7 100644 --- a/drivers/scsi/libsas/sas_internal.h +++ b/drivers/scsi/libsas/sas_internal.h @@ -54,6 +54,7 @@ void sas_free_event(struct asd_sas_event *event); struct sas_task *sas_alloc_task(gfp_t flags); struct sas_task *sas_alloc_slow_task(gfp_t flags); +struct sas_task *sas_alloc_slow_task_rq(struct domain_device *device, gfp_t flags); void sas_free_task(struct sas_task *task); int sas_register_ports(struct sas_ha_struct *sas_ha); diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index 1aee3d0ebbb2..4c4d8c91b1c1 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -648,7 +648,7 @@ static inline struct request *sas_task_find_rq(struct sas_task *task) { struct scsi_cmnd *scmd; - if (task->task_proto & SAS_PROTOCOL_STP_ALL) { + if (!task->slow_task && task->task_proto & SAS_PROTOCOL_STP_ALL) { struct ata_queued_cmd *qc = task->uldd_task; scmd = qc ? qc->scsicmd : NULL; From patchwork Tue Oct 25 10:18:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10668 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp907929wru; Tue, 25 Oct 2022 02:52:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7fSAuJT+Tb4CUBeaVITiVYuo2iu4WImSPJos9yHGa0lqd+uekIASB6sh1hmLy3weJXbVRs X-Received: by 2002:a17:903:22c1:b0:186:5f78:44c5 with SMTP id y1-20020a17090322c100b001865f7844c5mr28592673plg.16.1666691558044; Tue, 25 Oct 2022 02:52:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691558; cv=none; d=google.com; s=arc-20160816; b=MRrB6DktDHNcVEJ1kMqEZCv6wVW2Ph2yGEsi7dfinNhuYlmzpVz1myHjVynjytOdL3 fTh6LWI8mOC4OOBS+q9gduqw0NG0vg60t4yN3wfnG+iqZ77xuJGzIoMdtyxXlsjCE+BE +uQaze9zS+xmHaP4d3/jp8nYdiDgGYJqIroNC6PynjV2jluSaw1wBXGUyXsKFRWqKSRj Q/qwPOYPIcZ0Q9ZnDBgoHl6AaOLz7nMpgiFvFuQTb/XXx4/DnessoIPQ60SgJfVHsUwo 6s04Xi0MNfdX+ZouhgH7QV9HK3qRw1JGCPSrIIlUYu1skGf8kfVWJu58FlXetL6HfOzP oGEw== 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=u0SnvDZiTcUMeMdK3lbFnLs3t/zXgbvxVDmJB85UDY8=; b=s9AScLh1no6zThu+yrQh/CqQ+0ZFuiMBlm1zO/Lwo5Szy2pNCQhJ2VcJINs8hKNy4b LsF+uyl1LZWa5V4itNGxU415iFX7DnQDzDOaxYcVIyh/6BamZg1tDriYFQ6PZgILwadC XwEORaFcUXThVRRrlz8j1wNR2BflSwa1EO1rP3rI14OnzQTFxwfGylIzx0cX+CFi+3V8 7sdy1UHkiaLclgwl5YN/VsNuLsFfLJlT/ydO6mah7+jb++mjW/jVcLtPrWjsTOKLG+48 4xOebASEc4II/kOa5VLkyotTG0ECwACqyGjACWzvX77lPSsKSwpM+7kfytqDwxiAcBb7 VdmQ== 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 t3-20020a63b703000000b0045190ea3f14si2415754pgf.471.2022.10.25.02.52.23; Tue, 25 Oct 2022 02:52:38 -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 S231538AbiJYJvV (ORCPT + 99 others); Tue, 25 Oct 2022 05:51:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230463AbiJYJuQ (ORCPT ); Tue, 25 Oct 2022 05:50:16 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7D45110B0E; Tue, 25 Oct 2022 02:48:37 -0700 (PDT) Received: from frapeml500004.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRsv12brz67GTC; Tue, 25 Oct 2022 17:46:43 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by frapeml500004.china.huawei.com (7.182.85.22) 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:48:35 +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:48:31 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 10/22] scsi: libsas: Add sas_queuecommand_internal() Date: Tue, 25 Oct 2022 18:18:04 +0800 Message-ID: <1666693096-180008-11-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?1747652767009767395?= X-GMAIL-MSGID: =?utf-8?q?1747652767009767395?= Add a callback for scsi host template reserved_queuecommand callback, and plug it into libsas LLDDs. Signed-off-by: John Garry --- drivers/scsi/aic94xx/aic94xx_init.c | 1 + drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 1 + drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 1 + drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 1 + drivers/scsi/isci/init.c | 1 + drivers/scsi/libsas/sas_scsi_host.c | 13 +++++++++++++ drivers/scsi/mvsas/mv_init.c | 1 + drivers/scsi/pm8001/pm8001_init.c | 1 + include/scsi/libsas.h | 1 + 9 files changed, 21 insertions(+) diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c index 954d0c5ae2e2..e9d2ee5434c2 100644 --- a/drivers/scsi/aic94xx/aic94xx_init.c +++ b/drivers/scsi/aic94xx/aic94xx_init.c @@ -60,6 +60,7 @@ static struct scsi_host_template aic94xx_sht = { .compat_ioctl = sas_ioctl, #endif .track_queue_depth = 1, + .reserved_queuecommand = sas_queuecommand_internal, }; static int asd_map_memio(struct asd_ha_struct *asd_ha) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c index d643c5a49aa9..6cf660b1212e 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -1760,6 +1760,7 @@ static struct scsi_host_template sht_v1_hw = { #endif .shost_groups = host_v1_hw_groups, .host_reset = hisi_sas_host_reset, + .reserved_queuecommand = sas_queuecommand_internal, }; static const struct hisi_sas_hw hisi_sas_v1_hw = { diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index cded42f4ca44..d2bf23ad0833 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -3578,6 +3578,7 @@ static struct scsi_host_template sht_v2_hw = { .host_reset = hisi_sas_host_reset, .map_queues = map_queues_v2_hw, .host_tagset = 1, + .reserved_queuecommand = sas_queuecommand_internal, }; static const struct hisi_sas_hw hisi_sas_v2_hw = { diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 0c3fcb807806..ff56072c7a33 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -3245,6 +3245,7 @@ static struct scsi_host_template sht_v3_hw = { .tag_alloc_policy = BLK_TAG_ALLOC_RR, .host_reset = hisi_sas_host_reset, .host_tagset = 1, + .reserved_queuecommand = sas_queuecommand_internal, }; static const struct hisi_sas_hw hisi_sas_v3_hw = { diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c index e294d5d961eb..e970f4b77ed3 100644 --- a/drivers/scsi/isci/init.c +++ b/drivers/scsi/isci/init.c @@ -177,6 +177,7 @@ static struct scsi_host_template isci_sht = { #endif .shost_groups = isci_host_groups, .track_queue_depth = 1, + .reserved_queuecommand = sas_queuecommand_internal, }; static struct sas_domain_function_template isci_transport_ops = { diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index a36fa1c128a8..04e8c0575021 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c @@ -158,6 +158,19 @@ static struct sas_task *sas_create_task(struct scsi_cmnd *cmd, return task; } +int sas_queuecommand_internal(struct Scsi_Host *shost, struct scsi_cmnd *cmnd) +{ + struct sas_ha_struct *ha = SHOST_TO_SAS_HA(shost); + struct sas_internal *i = to_sas_internal(ha->core.shost->transportt); + struct request *rq = blk_mq_rq_from_pdu(cmnd); + struct sas_task *task = rq->end_io_data; + + ASSIGN_SAS_TASK(cmnd, task); + + return i->dft->lldd_execute_task(task, GFP_KERNEL); +} +EXPORT_SYMBOL_GPL(sas_queuecommand_internal); + int sas_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) { struct sas_internal *i = to_sas_internal(host->transportt); diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c index cfe84473a515..228ab00e180f 100644 --- a/drivers/scsi/mvsas/mv_init.c +++ b/drivers/scsi/mvsas/mv_init.c @@ -54,6 +54,7 @@ static struct scsi_host_template mvs_sht = { #endif .shost_groups = mvst_host_groups, .track_queue_depth = 1, + .reserved_queuecommand = sas_queuecommand_internal, }; static struct sas_domain_function_template mvs_transport_ops = { diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index a1df61205b20..1a12c3f97f53 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -123,6 +123,7 @@ static struct scsi_host_template pm8001_sht = { .track_queue_depth = 1, .cmd_per_lun = 32, .map_queues = pm8001_map_queues, + .reserved_queuecommand = sas_queuecommand_internal, }; /* diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index 4c4d8c91b1c1..64035f83c5bd 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -739,6 +739,7 @@ int sas_discover_sata(struct domain_device *); int sas_discover_end_dev(struct domain_device *); void sas_unregister_dev(struct asd_sas_port *port, struct domain_device *); +int sas_queuecommand_internal(struct Scsi_Host *shost, struct scsi_cmnd *cmnd); void sas_init_dev(struct domain_device *); From patchwork Tue Oct 25 10:18:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10674 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp908279wru; Tue, 25 Oct 2022 02:53:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4yt88/ItdsrBRikcd1t8tRHhzzxh+abQK/uhLeE82/R9sHZHSBywDvfD5tB6qyyxPPalHM X-Received: by 2002:a63:6bc5:0:b0:460:bd9a:64b8 with SMTP id g188-20020a636bc5000000b00460bd9a64b8mr32675472pgc.257.1666691618573; Tue, 25 Oct 2022 02:53:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691618; cv=none; d=google.com; s=arc-20160816; b=yNQHv1/d4lSK+mLHMgn7T54Yoz7zFcf3sHhDpEIgDBb1K3Pj7S5zAFJatzGrL8xmnp +4I/Nm02mVrMNGofYcPMtNd41wZTSQqRuysKTNkdnAjTgqxNErsZNhL2ri5q9/Doyjev ML1r+GZDSQdHqxHAozXGwpJUXaj+Kx5/teZK2hLUyuXJ0ID+cPncxfzxRH5KdWQZt3E0 O6FOznuQ7tB63B1W7SQvnQhqzAoKDtwQtrthM0rf1B1zV/hIX4d9NTy3uCNfWsnROll4 O3TqV2ndE2aBBgznTmirfeYg/Rg/QzVMpaYBh2CBzEzWDwfZniyTaqP7KyWaf3U6uJfv oynw== 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=pwieV/xKmvRenRPfkY50euGtprO7bkx2jG3zp92zcrM=; b=KbUfB0cslkyQeFLPlPXpljJ8uuIVEoTez7WK5BJoVkV+H16BA+6IvwNGy0NSKt6vdc 1bv1bGOrfh5S10/WJBRmiZRZpjfnIQu+FoW+uMyGkOAj1vhXwV7tpBD8sSQbkZABzvz4 gUCg0c/OZ2GZxkwaPzzFsTd0eJwDcQ9FVXncMpIRw2NHZiXYUEOk6ZAEfyMWI1ITzaF/ n93v/YQ3uJpDj2/hn0RndNBmfHkpbANt7cI4u8CXtS0vqR/u5TtrJSLKMkHYabEO8Bm6 dRXxd4YPo7sZ5hxFY3LWPxaofaVjOUtAq4PEBaH/0/Ty66EhKtffl1uissI/rpO6u+zC ocOQ== 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 oa9-20020a17090b1bc900b001fb706e96afsi14335513pjb.182.2022.10.25.02.53.24; Tue, 25 Oct 2022 02:53:38 -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 S232014AbiJYJvj (ORCPT + 99 others); Tue, 25 Oct 2022 05:51:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231374AbiJYJuW (ORCPT ); Tue, 25 Oct 2022 05:50:22 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFDCE15CB16; Tue, 25 Oct 2022 02:48:41 -0700 (PDT) Received: from frapeml500002.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRtb0Ng1z6HJG9; Tue, 25 Oct 2022 17:47:19 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by frapeml500002.china.huawei.com (7.182.85.205) 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:48:40 +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:48:35 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 11/22] scsi: libsas: Add sas_internal_timeout() Date: Tue, 25 Oct 2022 18:18:05 +0800 Message-ID: <1666693096-180008-12-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?1747652830512909193?= X-GMAIL-MSGID: =?utf-8?q?1747652830512909193?= Add sas_internal_timeout(), which is the timeout handler for reserved commands, and plug into the libsas LLDDs. Signed-off-by: John Garry --- drivers/scsi/aic94xx/aic94xx_init.c | 1 + drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 1 + drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 1 + drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 1 + drivers/scsi/isci/init.c | 1 + drivers/scsi/libsas/sas_scsi_host.c | 18 ++++++++++++++++++ drivers/scsi/mvsas/mv_init.c | 1 + drivers/scsi/pm8001/pm8001_init.c | 1 + include/scsi/libsas.h | 1 + 9 files changed, 26 insertions(+) diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c index e9d2ee5434c2..06c86d7a777a 100644 --- a/drivers/scsi/aic94xx/aic94xx_init.c +++ b/drivers/scsi/aic94xx/aic94xx_init.c @@ -61,6 +61,7 @@ static struct scsi_host_template aic94xx_sht = { #endif .track_queue_depth = 1, .reserved_queuecommand = sas_queuecommand_internal, + .reserved_timedout = sas_internal_timeout, }; static int asd_map_memio(struct asd_ha_struct *asd_ha) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c index 6cf660b1212e..9f71cc72cd80 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -1761,6 +1761,7 @@ static struct scsi_host_template sht_v1_hw = { .shost_groups = host_v1_hw_groups, .host_reset = hisi_sas_host_reset, .reserved_queuecommand = sas_queuecommand_internal, + .reserved_timedout = sas_internal_timeout, }; static const struct hisi_sas_hw hisi_sas_v1_hw = { diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index d2bf23ad0833..483a03ed6253 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -3579,6 +3579,7 @@ static struct scsi_host_template sht_v2_hw = { .map_queues = map_queues_v2_hw, .host_tagset = 1, .reserved_queuecommand = sas_queuecommand_internal, + .reserved_timedout = sas_internal_timeout, }; static const struct hisi_sas_hw hisi_sas_v2_hw = { diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index ff56072c7a33..02d96fba510f 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -3246,6 +3246,7 @@ static struct scsi_host_template sht_v3_hw = { .host_reset = hisi_sas_host_reset, .host_tagset = 1, .reserved_queuecommand = sas_queuecommand_internal, + .reserved_timedout = sas_internal_timeout, }; static const struct hisi_sas_hw hisi_sas_v3_hw = { diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c index e970f4b77ed3..9c7869bf6cde 100644 --- a/drivers/scsi/isci/init.c +++ b/drivers/scsi/isci/init.c @@ -178,6 +178,7 @@ static struct scsi_host_template isci_sht = { .shost_groups = isci_host_groups, .track_queue_depth = 1, .reserved_queuecommand = sas_queuecommand_internal, + .reserved_timedout = sas_internal_timeout, }; static struct sas_domain_function_template isci_transport_ops = { diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index 04e8c0575021..b7d1994a8f1b 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c @@ -930,6 +930,24 @@ void sas_task_internal_timedout(struct timer_list *t) if (!is_completed) complete(&task->slow_task->completion); } +enum blk_eh_timer_return sas_internal_timeout(struct scsi_cmnd *scmd) +{ + struct sas_task *task = TO_SAS_TASK(scmd); + 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); + return BLK_EH_DONE; +} +EXPORT_SYMBOL_GPL(sas_internal_timeout); #define TASK_TIMEOUT (20 * HZ) #define TASK_RETRY 3 diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c index 228ab00e180f..7fed0259e1f5 100644 --- a/drivers/scsi/mvsas/mv_init.c +++ b/drivers/scsi/mvsas/mv_init.c @@ -55,6 +55,7 @@ static struct scsi_host_template mvs_sht = { .shost_groups = mvst_host_groups, .track_queue_depth = 1, .reserved_queuecommand = sas_queuecommand_internal, + .reserved_timedout = sas_internal_timeout, }; static struct sas_domain_function_template mvs_transport_ops = { diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index 1a12c3f97f53..ce9509792bc0 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -124,6 +124,7 @@ static struct scsi_host_template pm8001_sht = { .cmd_per_lun = 32, .map_queues = pm8001_map_queues, .reserved_queuecommand = sas_queuecommand_internal, + .reserved_timedout = sas_internal_timeout, }; /* diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index 64035f83c5bd..f02156ccd376 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -711,6 +711,7 @@ int sas_set_phy_speed(struct sas_phy *phy, struct sas_phy_linkrates *rates); int sas_phy_reset(struct sas_phy *phy, int hard_reset); int sas_phy_enable(struct sas_phy *phy, int enable); extern int sas_queuecommand(struct Scsi_Host *, struct scsi_cmnd *); +extern enum blk_eh_timer_return sas_internal_timeout(struct scsi_cmnd *scmd); extern int sas_target_alloc(struct scsi_target *); extern int sas_slave_configure(struct scsi_device *); extern int sas_change_queue_depth(struct scsi_device *, int new_depth); From patchwork Tue Oct 25 10:18:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10669 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp908009wru; Tue, 25 Oct 2022 02:52:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7FG4vk/biNDxaPBnQj7wBkGhoGsmwMw5+q4qTcvobppZELK/2vtVIrBmZs6gt95ZAhYD3C X-Received: by 2002:a17:90b:3b49:b0:213:2adb:6181 with SMTP id ot9-20020a17090b3b4900b002132adb6181mr6654692pjb.56.1666691574518; Tue, 25 Oct 2022 02:52:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691574; cv=none; d=google.com; s=arc-20160816; b=EdLkohf7uzQvIxfVFhJ20tBH/rs1LRqUM2pO2mqBu8Fikrq51q6c74i5zMhk/WT9gR xEwmNgZ6IZUti80o3Raz1JpNXK6RgHZkBIu6tRILwaNXczKb1J1nFpHGZUAVwknwyy6u Qp59m2An0YUijEh/175VPt+BdASjMVJQQiR5YqrfpogjAzmJSOScmJzyHPPB8Uyd25ZU /o7efWqaMFjFC6qMf9/zdrzj/MsyVLkq5Hooa7Wuq2FMoH245HO6mNJiHH2E2ubAsOth e9YvShCkuN3hTdNtI0u06OtLwdSMOQWQ3pODt4eA8IhkZMXrS07lkMQ2RGyqSSBtcxuJ /7RQ== 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=PInqdFtMU5cmtL++aU+ecH2x1/c4gS/PFYDED3CYr6M=; b=JNDOcb+EuRUfqfzZZ84Xm3N3p7r48X6alMM4/RNTDOxp2t34URGZJPvdDQXyDN+TbI Vi+k+JB7wuNd2yrjOr3WyzA9LEFsxLoHJsfP367MLFuV9Sug2SjR27rBpaBnSh2c8IbP vjODFumh9Z5iBdk5AD5MZoBsodI+rETzrFgbMhteFQ0MAbwJh+Sww+bc55nL/O1eazr6 b4rB5mrWlGmuqWVxPkitYO15aZ9pQ15GFtTn23XZVvp9llXxxUn33xxtxDthFFCivSN6 NNx+PrPzY/0qS5TsnBpjFA4GLG0m1XmqFd4nFIiTcsIu6/elbDiDEosZWjLewq+cZvvT CvYg== 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 k4-20020a170902c40400b0017c59fa6b65si3104426plk.597.2022.10.25.02.52.38; Tue, 25 Oct 2022 02:52:54 -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 S231953AbiJYJvn (ORCPT + 99 others); Tue, 25 Oct 2022 05:51:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231940AbiJYJu0 (ORCPT ); Tue, 25 Oct 2022 05:50:26 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10B8115DB25; Tue, 25 Oct 2022 02:48:47 -0700 (PDT) Received: from frapeml100008.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRrB56Ppz67WVb; Tue, 25 Oct 2022 17:45:14 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by frapeml100008.china.huawei.com (7.182.85.131) 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:48:44 +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:48:40 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 12/22] scsi: core: Use SCSI_SCAN_RESCAN in __scsi_add_device() Date: Tue, 25 Oct 2022 18:18:06 +0800 Message-ID: <1666693096-180008-13-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?1747652784205642879?= X-GMAIL-MSGID: =?utf-8?q?1747652784205642879?= Instead of using hardcoded '1' as the __scsi_add_device() -> scsi_probe_and_add_lun() rescan arg, use proper macro SCSI_SCAN_RESCAN. Signed-off-by: John Garry Reviewed-by: Damien Le Moal --- drivers/scsi/scsi_scan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index ad0a5902d1a0..b795c138f2c1 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -1580,7 +1580,8 @@ struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel, scsi_complete_async_scans(); if (scsi_host_scan_allowed(shost) && scsi_autopm_get_host(shost) == 0) { - scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata); + scsi_probe_and_add_lun(starget, lun, NULL, &sdev, + SCSI_SCAN_RESCAN, hostdata); scsi_autopm_put_host(shost); } mutex_unlock(&shost->scan_mutex); From patchwork Tue Oct 25 10:18:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10670 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp908169wru; Tue, 25 Oct 2022 02:53:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4UXQuQgk20c1IbO15KsgEqOfW8eWupBdoUd3/XmLKj4pAUHdqpAJ3lThvnZaogOxGTOAGr X-Received: by 2002:a17:907:320a:b0:741:72ee:8f3 with SMTP id xg10-20020a170907320a00b0074172ee08f3mr31673390ejb.168.1666691601274; Tue, 25 Oct 2022 02:53:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691601; cv=none; d=google.com; s=arc-20160816; b=hgmtYAGfiuEyViPKaTfLrSik56dZ3SMjj/xO+S4Ev3OFHIVLFQE+dhkI6qXTT6bRAf Rtvi/LHf+DvQZuyaFEMe4HlZzIaV7rDv2TGHpju1nZTjDHkM6fNi87pCdxRPisPUqukH d+aNocAtCEpYRqvQhf5YN1x6cc/ERXmeB2K8JSpsTDWiyIvvccBOGrbZwGa0NM3kCVLK 6LjfClDM0xvRkkGaIKrjy2GX3oMj9n3VxRAcxjSg1L4TcFX383mo96C+nBE60ym9vqwb XIAdjTFJ4+I1DyrA7F/TLGp3+5s6ripB1U7WijSuqjSpyHQYSMEW752Tzxy3vkVDiBj5 vMzQ== 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=KkrS/liDtiJ5W3fLhhHJyvZfhHOs5ZDMmL0CHRprBqo=; b=igcZ4RVwtCxR3GcKAXw65SWOyPgCgyUihv2jcmwOUpGEGmzs1N16NvBHySqIY6uaW3 ywP5wW5TI4+mUaKFFP+qa+OL0/LTFtOGpZ0rKjcLoMmbPv2jgPSHohpeoLEUo/LvaYqT dBq3PyN71Uo55iN2tzV/27xf/FPH6/TTsU8C+Av/l/nshJQ/UO2cnNf4SaJW3DM6xEu9 BCQuA/i1LFFOujYqJz16xz7JKzQmlQlPAPZSR8OybwKumi+OWHVrpBkyVAyLJtSy4L9Y qY+f31cQhe3n3eX1Oo/vWvSt7VQoSGBkVz7pssuxgXVR6kEykwpyDEN4c2k7EH9BIu4s pugw== 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 hd14-20020a170907968e00b0078db719e54csi154787ejc.98.2022.10.25.02.52.57; Tue, 25 Oct 2022 02:53: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 S232050AbiJYJvv (ORCPT + 99 others); Tue, 25 Oct 2022 05:51:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231704AbiJYJui (ORCPT ); Tue, 25 Oct 2022 05:50:38 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4698015ECD4; Tue, 25 Oct 2022 02:48:51 -0700 (PDT) Received: from frapeml100006.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRrH0jvFz67bC8; Tue, 25 Oct 2022 17:45:19 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by frapeml100006.china.huawei.com (7.182.85.201) 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:48:49 +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:48:44 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 13/22] scsi: scsi_transport_sas: Allocate end device target id in the rphy alloc Date: Tue, 25 Oct 2022 18:18:07 +0800 Message-ID: <1666693096-180008-14-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?1747652812623833002?= X-GMAIL-MSGID: =?utf-8?q?1747652812623833002?= Currently the per-end device target id is allocated when adding the rphy, which is when we execute the scan of the target. However it will be useful to have the target id allocated earlier when allocating the rphy for the end device. For libata we want to move to a scheme of allocating the sdev early in the probe process and then later executing the scan (for that target). As such, users of would libata would require that the target id allocated earlier here (before the scan). Signed-off-by: John Garry --- drivers/scsi/scsi_transport_sas.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c index da075dfc7cd0..c03e88990264 100644 --- a/drivers/scsi/scsi_transport_sas.c +++ b/drivers/scsi/scsi_transport_sas.c @@ -1433,6 +1433,7 @@ static void sas_rphy_initialize(struct sas_rphy *rphy) struct sas_rphy *sas_end_device_alloc(struct sas_port *parent) { struct Scsi_Host *shost = dev_to_shost(&parent->dev); + struct sas_host_attrs *sas_host = to_sas_host_attrs(shost); struct sas_end_device *rdev; rdev = kzalloc(sizeof(*rdev), GFP_KERNEL); @@ -1455,6 +1456,10 @@ struct sas_rphy *sas_end_device_alloc(struct sas_port *parent) sas_rphy_initialize(&rdev->rphy); transport_setup_device(&rdev->rphy.dev); + mutex_lock(&sas_host->lock); + rdev->rphy.scsi_target_id = sas_host->next_target_id++; + mutex_unlock(&sas_host->lock); + return &rdev->rphy; } EXPORT_SYMBOL(sas_end_device_alloc); @@ -1500,6 +1505,17 @@ struct sas_rphy *sas_expander_alloc(struct sas_port *parent, } EXPORT_SYMBOL(sas_expander_alloc); +static bool sas_rphy_valid_tproto_end_device(struct sas_rphy *rphy) +{ + struct sas_identify *identify = &rphy->identify; + + if (identify->device_type != SAS_END_DEVICE) + return false; + + return (identify->target_port_protocols & + (SAS_PROTOCOL_SSP | SAS_PROTOCOL_STP | SAS_PROTOCOL_SATA)); +} + /** * sas_rphy_add - add a SAS remote PHY to the device hierarchy * @rphy: The remote PHY to be added @@ -1529,16 +1545,9 @@ int sas_rphy_add(struct sas_rphy *rphy) mutex_lock(&sas_host->lock); list_add_tail(&rphy->list, &sas_host->rphy_list); - if (identify->device_type == SAS_END_DEVICE && - (identify->target_port_protocols & - (SAS_PROTOCOL_SSP | SAS_PROTOCOL_STP | SAS_PROTOCOL_SATA))) - rphy->scsi_target_id = sas_host->next_target_id++; - else if (identify->device_type == SAS_END_DEVICE) - rphy->scsi_target_id = -1; mutex_unlock(&sas_host->lock); - if (identify->device_type == SAS_END_DEVICE && - rphy->scsi_target_id != -1) { + if (sas_rphy_valid_tproto_end_device(rphy)) { int lun; if (identify->target_port_protocols & SAS_PROTOCOL_SSP) @@ -1672,8 +1681,7 @@ static int sas_user_scan(struct Scsi_Host *shost, uint channel, mutex_lock(&sas_host->lock); list_for_each_entry(rphy, &sas_host->rphy_list, list) { - if (rphy->identify.device_type != SAS_END_DEVICE || - rphy->scsi_target_id == -1) + if (!sas_rphy_valid_tproto_end_device(rphy)) continue; if ((channel == SCAN_WILD_CARD || channel == 0) && From patchwork Tue Oct 25 10:18:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10673 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp908278wru; Tue, 25 Oct 2022 02:53:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7U2VDgxMni+bkSR6I/2h0fiVleIto+2Zjgl1D08W6cu28ROsN1udYjPDcYHyqApqFGzkAO X-Received: by 2002:a63:551b:0:b0:44b:7dcf:92ee with SMTP id j27-20020a63551b000000b0044b7dcf92eemr32779220pgb.610.1666691618581; Tue, 25 Oct 2022 02:53:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691618; cv=none; d=google.com; s=arc-20160816; b=F2Ua3Mu4alOaqrXkKlYAB69WgtYEh98gvfJtpvjVbw6zoAlvj+SHl0BAtgVwut8kop F1Yroxz8e3lt20Yt0Mqruct8t8jxOoV5bU1/ZIhBiIuiizXulqbzZuLLscg3P3viQoe3 aUjzz/rZsTvJ+tyOxfZFJm5ZRC3zY+r5ZcUB1AXtIGEf1ea8232kIYxnQ5RqLVkohSS0 lBIUVHdbJjSVUEjULIa6uDzn6kvEi6LJY1mjrkH+PI2stwkAx9gByWNbGJVw5IuLIpoE +avnUk2F/iQ8VucjVy3nfuc1hwOk7UuYYJuetOhzegp1PUj5o03loxZdQ3XY6N1LR2FV UgYQ== 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=CNrz55GuvaoJ9CBTsNOZ7M5z/EprRxB9os9jyOM2bVI=; b=kBQauBgq2rQ43AzMUA/syXWYjoMjhNSKJN34ntT6I1FvP86v8hZNF9Hkc6dCqGnhVZ 4HYtiKc0/nREfJIpQaQg2Msx6NR5rFsrLqtZbQnnDyJh3aslOz1fmy5r0ax1ZK6RzkWN 1lSev/tilid/BwOk0sZntZIUX7FncEFU4PnWeQO2kZtiB4bYmrTrp+W0XRtn3xGHiB/+ rrRjN42xrMoGkQ3khbPEOovmgfIKsRTjpH7mXsj9KfYqMPtW+gs29NYHAXCTbLhPmfBT EMHIPT/QCUD3XhmkCOd7XAuu9BK8GpHUiPmZBxkSeKNj5W6CK8OgywaE37cOHcBZlels 3fng== 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 j17-20020a635951000000b0044601bb2f90si2365379pgm.530.2022.10.25.02.53.24; Tue, 25 Oct 2022 02:53:38 -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 S231645AbiJYJwK (ORCPT + 99 others); Tue, 25 Oct 2022 05:52:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231463AbiJYJul (ORCPT ); Tue, 25 Oct 2022 05:50:41 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B4E615F900; Tue, 25 Oct 2022 02:48:55 -0700 (PDT) Received: from frapeml100005.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRtr3sltz67vyB; Tue, 25 Oct 2022 17:47:32 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by frapeml100005.china.huawei.com (7.182.85.132) 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:48:53 +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:48:49 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 14/22] ata: libata-scsi: Add ata_scsi_setup_sdev() Date: Tue, 25 Oct 2022 18:18:08 +0800 Message-ID: <1666693096-180008-15-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?1747652830659992540?= X-GMAIL-MSGID: =?utf-8?q?1747652830659992540?= Add a function to setup the sdev associated with an ata_device. Currently in libata to create the sdev we call __scsi_add_device() to create the sdev and execute the scan. However if we want to move to a 2-step process where we allocate the sdev early in the port probe, then we need a separate function just to allocate the sdev. We add a ata_port_operations callback .setup_scsi_device for when the driver needs a custom setup. This is essentially for libsas, which does not use the same options for sdev parent and id. Signed-off-by: John Garry --- drivers/ata/libata-scsi.c | 26 ++++++++++++++++++++++++++ drivers/ata/libata.h | 1 + include/linux/libata.h | 2 ++ 3 files changed, 29 insertions(+) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index e2ebb0b065e2..efdba852e363 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -4253,6 +4253,32 @@ static void ata_scsi_assign_ofnode(struct ata_device *dev, struct ata_port *ap) } #endif +int ata_scsi_setup_sdev(struct ata_device *dev) +{ + u64 lun = 0; + int channel = 0; + uint id = 0; + struct ata_link *link = dev->link; + struct ata_port *ap = link->ap; + struct Scsi_Host *shost = ap->scsi_host; + struct device *parent = &shost->shost_gendev; + struct scsi_device *sdev; + + if (ap->ops->setup_scsi_device) + return ap->ops->setup_scsi_device(dev); + + if (ata_is_host_link(link)) + id = dev->devno; + else + channel = link->pmp; + sdev = scsi_get_dev(parent, channel, id, lun); + if (!sdev) + return -ENODEV; + dev->sdev = sdev; + ata_scsi_assign_ofnode(dev, ap); + return 0; +} + void ata_scsi_scan_host(struct ata_port *ap, int sync) { int tries = 5; diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h index 2c5c8273af01..0c2df1e60768 100644 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h @@ -112,6 +112,7 @@ extern struct ata_device *ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev); extern int ata_scsi_add_hosts(struct ata_host *host, struct scsi_host_template *sht); +extern int ata_scsi_setup_sdev(struct ata_device *dev); extern void ata_scsi_scan_host(struct ata_port *ap, int sync); extern int ata_scsi_offline_dev(struct ata_device *dev); extern void ata_scsi_set_sense(struct ata_device *dev, diff --git a/include/linux/libata.h b/include/linux/libata.h index fe990176e6ee..827d5838cd23 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -968,6 +968,8 @@ struct ata_port_operations { void (*phy_reset)(struct ata_port *ap); void (*eng_timeout)(struct ata_port *ap); + int (*setup_scsi_device)(struct ata_device *dev); + /* * ->inherits must be the last field and all the preceding * fields must be pointers. From patchwork Tue Oct 25 10:18:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10677 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp908389wru; Tue, 25 Oct 2022 02:53:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7NXhn0ew3VSYdudScIH5He7SvaZRQ8WddcgNlAJOlTq9eEOtqGsX8vUrX8syKnNPooY6K1 X-Received: by 2002:a63:2b4b:0:b0:440:2963:5863 with SMTP id r72-20020a632b4b000000b0044029635863mr31232907pgr.28.1666691637050; Tue, 25 Oct 2022 02:53:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691637; cv=none; d=google.com; s=arc-20160816; b=ffji+nPwyDsSLQOVq025qV9zEfPZTNTPKIAWWdleykJlxFh36VBk4J61UohDHi++5v GCyVs0uy7wViVr/yS21EWFBcttMceBPaLiXr/uYWU6VkZVVI/+vC7wyu63FIiodvjblD Q8OwCoZIFqwxv+6JlkR5gJ/5KqqQyagdMc8SExurbpziEDWGYhLNBsSERuhFo/MknP+k dKlFj/kO7H/j/ifrxd4dXy/r5XWjd+9AJexvyCn3ZKfjmk7j+EGT3SDqKQJvVCPQnMqw 1D0SRGcQa+XGPlDLaru8G1EKezLQ4Pmy8MPzmA2FEa95rNwzXu2yd+0F+H3HfhQHULS+ tDSw== 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=f9M/pMK1HoIPqrf9mmuCPB+5Y5O7w0SxVlCVWFtLohE=; b=e3QuifgOoj1QP04d/7DFvhOazx+VRJn+wvBl80s9N3R7wkV0BzEywBoF5jqyZb8UqC zQZpbVp61MiHRiOQ5jw99sDnYJ9PkK71s30o2uZvILq9G7GtonGhG0N8Lg1rb/8cCcG0 qb6zHJ1uucr6rZbZtDB/QMDseO+V54I10fZ0/lt1KGydml/PWM3FBFmeQdW6Tcw9r5Q2 Ogfye21FYFOmQWwOKJB2k3Qro8T2nTFlMbDbMvBc9hRAhnH0lINvlLng7jJGcMEEmiWL uFcVPAg7VrM31RmhdYghtRYGycDdYjCFWp4fiT+PsuqTK6iK56xX5NT2Ur0p8XQRL16b XoAg== 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 h128-20020a625386000000b0053e3cf68da1si2555388pfb.74.2022.10.25.02.53.43; Tue, 25 Oct 2022 02:53:57 -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 S232089AbiJYJwZ (ORCPT + 99 others); Tue, 25 Oct 2022 05:52:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231688AbiJYJux (ORCPT ); Tue, 25 Oct 2022 05:50:53 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D606F134A83; Tue, 25 Oct 2022 02:48:59 -0700 (PDT) Received: from frapeml100004.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRtw68SCz689QR; Tue, 25 Oct 2022 17:47:36 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by frapeml100004.china.huawei.com (7.182.85.167) 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:48:57 +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:48:53 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 15/22] scsi: libsas: Add sas_ata_setup_device() Date: Tue, 25 Oct 2022 18:18:09 +0800 Message-ID: <1666693096-180008-16-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?1747652850176186342?= X-GMAIL-MSGID: =?utf-8?q?1747652850176186342?= Add a function which does a custom sdev alloc - essentially replicates what we do in sas_rphy_add() in terms of sdev parent and id. Signed-off-by: John Garry --- drivers/scsi/libsas/sas_ata.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index 78e6046fb55a..a46a2d345422 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c @@ -523,6 +523,25 @@ static int sas_ata_prereset(struct ata_link *link, unsigned long deadline) return res; } +static int sas_ata_setup_device(struct ata_device *dev) +{ + u64 lun = 0; + int channel = 0; + struct ata_link *link = dev->link; + struct ata_port *ap = link->ap; + struct scsi_device *sdev; + struct domain_device *ddev = ap->private_data; + struct sas_rphy *rphy = ddev->rphy; + struct device *parent = &rphy->dev; + uint id = rphy->scsi_target_id; + + sdev = scsi_get_dev(parent, channel, id, lun); + if (!sdev) + return -ENODEV; + dev->sdev = sdev; + return 0; +} + static struct ata_port_operations sas_sata_ops = { .prereset = sas_ata_prereset, .hardreset = sas_ata_hard_reset, @@ -537,6 +556,7 @@ static struct ata_port_operations sas_sata_ops = { .set_dmamode = sas_ata_set_dmamode, .sched_eh = sas_ata_sched_eh, .end_eh = sas_ata_end_eh, + .setup_scsi_device = sas_ata_setup_device, }; static struct ata_port_info sata_port_info = { From patchwork Tue Oct 25 10:18:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10678 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp908406wru; Tue, 25 Oct 2022 02:53:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5SiJk8ufR0PijQUItX448OshMXpJBEOI2ZXWskYXZ3lJ+YGk9ivjjrbLVh4dKOJ+sWRnSb X-Received: by 2002:a17:902:d492:b0:186:970f:57dd with SMTP id c18-20020a170902d49200b00186970f57ddmr14087678plg.86.1666691639593; Tue, 25 Oct 2022 02:53:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691639; cv=none; d=google.com; s=arc-20160816; b=qmoGRVRDL+N45v5CABu/FqpFf81YqvW96RQdrkECSYjvXnNLgGTiBKkB77yWiPEn6q 3zVsoJq8VUhwRmhmqyFbCJ0V08STefCLhRvrBPD/i56zVWUZ4Ff+FCqX5R8159J6VfsU Ak0KhCTU2JxmymMBSQzh03E5zZw0s9oyt4CxkYlG7FYsGiS03fVtYQacCm2MCVSfEO6r ZL+GprG4j3nnSYyhbLW7ZGsY1RMFk/uzoBFbtB0rwG+I4H6CBe54NIdFlIXPC02YcP3/ G9PBB1uBgvtdUPJnmnQ3JtLcOwA3mLI1ttjddZUiiYPBKEi4WCkA3mQ+J+jfOVkXYbwW l6jw== 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=VY/Bnbzw0OOUIHplAq19cwIFotvu/3gKjiPtTl7BtIw=; b=N8wss6hGH4RbQx/eueHb38c/92MGYIKHvLQr7bObRmAwxlukYnrVpd/34gxqNrG8PL HWZBM9WnA1t1uxvTtUpHWUe9iYA2NpjBZIS60iFp2CtXyfQVNl31y2FNz3cZADrKBEV0 nVFRxmx4BDMfYzBQdB6i9eeL1aNFKXY37fTH+ksXi3X3eJ5YcgECNEOh2o2cY4Fauhmi 0VIlqRQfl7tt93X0vp6S0qnohEDL4ENXPU+dAXS0bfAcAdvW6CL6fKS/Mf0+YATsMfS0 Er+4MN2+ae5dSlwbcoFmQl6OYLcaDzLRWBLrLVlv2Wz/UEjdV+jFGSoNu4kiOXj0L8lp 27Ew== 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 q24-20020a63e958000000b0046f1082320csi2465495pgj.742.2022.10.25.02.53.46; Tue, 25 Oct 2022 02:53:59 -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 S230499AbiJYJwa (ORCPT + 99 others); Tue, 25 Oct 2022 05:52:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231608AbiJYJu5 (ORCPT ); Tue, 25 Oct 2022 05:50:57 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E78AA16021D; Tue, 25 Oct 2022 02:49:03 -0700 (PDT) Received: from frapeml100003.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRtP2LpNz688Kc; Tue, 25 Oct 2022 17:47:09 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by frapeml100003.china.huawei.com (7.182.85.60) 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:02 +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:48:57 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 16/22] ata: libata-scsi: Allocate sdev early in port probe Date: Tue, 25 Oct 2022 18:18:10 +0800 Message-ID: <1666693096-180008-17-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?1747652852625799521?= X-GMAIL-MSGID: =?utf-8?q?1747652852625799521?= Currently the per-ata device sdev is allocated as part of the scsi target scan, which is after the ata port probe. However it is useful to have the sdev available in the port probe. As an example of an advantage, if the request queue is available in the probe (which it would be if the sdev is available), then it is possible to use a SCSI cmnd for ATA internal commands. The benefit of this is then we can put the ATA qc structure in the SCSI cmnd private data. It will also be useful if we want to send ATA internal commands as requests. Export scsi_target_reap() so that it can be used to put the extra reference we get when allocating the sdev. Signed-off-by: John Garry --- drivers/ata/libata-eh.c | 1 + drivers/ata/libata-scsi.c | 23 +++++++++-------------- drivers/scsi/scsi_scan.c | 1 + 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index 08e11bc312c2..1ed5b1b64792 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c @@ -3446,6 +3446,7 @@ static int ata_eh_schedule_probe(struct ata_device *dev) ata_eh_detach_dev(dev); ata_dev_init(dev); + ata_scsi_setup_sdev(dev); ehc->did_probe_mask |= (1 << dev->devno); ehc->i.action |= ATA_EH_RESET; ehc->saved_xfer_mode[dev->devno] = 0; diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index efdba852e363..476e0ef4bd29 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -1109,7 +1109,12 @@ int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev) if (dev->flags & ATA_DFLAG_TRUSTED) sdev->security_supported = 1; - dev->sdev = sdev; + /* + * Put extra reference which we get when allocating the starget + * initially + */ + scsi_target_reap(scsi_target(sdev)); + return 0; } @@ -4289,26 +4294,16 @@ void ata_scsi_scan_host(struct ata_port *ap, int sync) repeat: ata_for_each_link(link, ap, EDGE) { ata_for_each_dev(dev, link, ENABLED) { - struct scsi_device *sdev; + struct Scsi_Host *shost = ap->scsi_host; int channel = 0, id = 0; - if (dev->sdev) - continue; - if (ata_is_host_link(link)) id = dev->devno; else channel = link->pmp; - sdev = __scsi_add_device(ap->scsi_host, channel, id, 0, - NULL); - if (!IS_ERR(sdev)) { - dev->sdev = sdev; - ata_scsi_assign_ofnode(dev, ap); - scsi_device_put(sdev); - } else { - dev->sdev = NULL; - } + scsi_scan_target(&shost->shost_gendev, channel, id, + 0, SCSI_SCAN_INITIAL); } } diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index b795c138f2c1..da7bc14b030c 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -598,6 +598,7 @@ void scsi_target_reap(struct scsi_target *starget) BUG_ON(starget->state == STARGET_DEL); scsi_target_reap_ref_put(starget); } +EXPORT_SYMBOL_GPL(scsi_target_reap); /** * scsi_sanitize_inquiry_string - remove non-graphical chars from an From patchwork Tue Oct 25 10:18:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10679 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp908570wru; Tue, 25 Oct 2022 02:54:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Aqu4aVtk7OqrLnBl9eZ7LZIMA3wAxcdJ5m/FQD1bud+ksSTEdrP9eSMOgW/VKazZrNzuZ X-Received: by 2002:a17:902:d492:b0:186:970f:57dd with SMTP id c18-20020a170902d49200b00186970f57ddmr14089139plg.86.1666691669478; Tue, 25 Oct 2022 02:54:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691669; cv=none; d=google.com; s=arc-20160816; b=rmvQKKBtClNKUziAofLUssMHoIY6uUsbHnrMlGKVOnfjHcmP3i2lcamJtWKhJIRTZv kjA18vR+qZmAYjTWArK3W4U4wxa8OelCiARkSFUvCVepwoas4150KvaywUCK2wYia7ww BV3rSUfSh3b3JCHsiyqMTxnMj3atFV1K0JfJV7CJY6vZyLT63YeqBjuCc2IWmucdNJKG dEO9yMXhHpC4Ulo9k1S/QSVing+jkYioAL/bcW6DFGWyzwF1PvRaCTu+UpqwljNZ2lhl G6hrS4Yqzmt2Rb2CLlUzpiq+eHNY9dR4WDpMPE3YaQ6EIWhoyaOX6YLtcr6dTPN0YUgy ET4w== 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=79kat59oG8jCdTTiMHBQBTv0Gb4vgrO5nrjWDIFERcQ=; b=JVbWW8HSfpUqgI0cf2ov8RtFR+QlCvRn0RZu8VS9B19UiaRXXoTBk0kuc/PJ3Ux73w UXa257ADgSAaNSC/k0r0/dFpXG48YfwNb+lEqrD1OKZfUrA86Klh7jqEMziVN938PJQC TUIjW8r2GXaC5c+b/bHYQFmyjnEKq0Kruakww1UWIZ5D1blvJSqFDDYSWt/ZCjdYpejn 97k05NvDUkP6JPozmsy0nN61Uo8qyPXbviozmqn9xXwKt6Blnyml9CpPZ0nnC+8AUTUJ QQ5dSLBJdUiCpUdVQvQkl4DSLXyK8D42LWjtGNcE926SEbkBXqtDzAHpshPdmYksft58 rzbw== 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 t4-20020a170902e84400b0017f59ed2dfasi2875810plg.63.2022.10.25.02.54.15; Tue, 25 Oct 2022 02:54:29 -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 S232098AbiJYJwz (ORCPT + 99 others); Tue, 25 Oct 2022 05:52:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230259AbiJYJvU (ORCPT ); Tue, 25 Oct 2022 05:51:20 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D3C9164BC2; Tue, 25 Oct 2022 02:49:08 -0700 (PDT) Received: from frapeml100002.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRv53SC3z67yhg; Tue, 25 Oct 2022 17:47:45 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by frapeml100002.china.huawei.com (7.182.85.26) 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:06 +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:02 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 17/22] scsi: libsas drivers: Reserve tags Date: Tue, 25 Oct 2022 18:18:11 +0800 Message-ID: <1666693096-180008-18-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?1747652883862374519?= X-GMAIL-MSGID: =?utf-8?q?1747652883862374519?= Reserve 2x tags for libsas reserved tag handling, which should be enough. Continue to carve out a region of tags for driver internal management until each sas_task always has a request. Signed-off-by: John Garry --- drivers/scsi/aic94xx/aic94xx_init.c | 1 + drivers/scsi/hisi_sas/hisi_sas_main.c | 4 ++++ drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 1 + drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 1 + drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 5 +++++ drivers/scsi/isci/init.c | 1 + drivers/scsi/mvsas/mv_init.c | 5 +++++ drivers/scsi/pm8001/pm8001_init.c | 6 +++++- 8 files changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c index 06c86d7a777a..70b735cedeb3 100644 --- a/drivers/scsi/aic94xx/aic94xx_init.c +++ b/drivers/scsi/aic94xx/aic94xx_init.c @@ -62,6 +62,7 @@ static struct scsi_host_template aic94xx_sht = { .track_queue_depth = 1, .reserved_queuecommand = sas_queuecommand_internal, .reserved_timedout = sas_internal_timeout, + .nr_reserved_cmds = 2, }; static int asd_map_memio(struct asd_ha_struct *asd_ha) diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 54860d252466..fe2752d24fe8 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2442,6 +2442,10 @@ int hisi_sas_probe(struct platform_device *pdev, shost->can_queue = HISI_SAS_MAX_COMMANDS; shost->cmd_per_lun = HISI_SAS_MAX_COMMANDS; } else { + /* + * Intentionally use HISI_SAS_UNRESERVED_IPTT for .can_queue until + * every sas_task we're sent has a request associated. + */ shost->can_queue = HISI_SAS_UNRESERVED_IPTT; shost->cmd_per_lun = HISI_SAS_UNRESERVED_IPTT; } diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c index 9f71cc72cd80..438e8a963782 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -1762,6 +1762,7 @@ static struct scsi_host_template sht_v1_hw = { .host_reset = hisi_sas_host_reset, .reserved_queuecommand = sas_queuecommand_internal, .reserved_timedout = sas_internal_timeout, + .nr_reserved_cmds = 2, }; static const struct hisi_sas_hw hisi_sas_v1_hw = { diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index 483a03ed6253..b733eb18864c 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -3580,6 +3580,7 @@ static struct scsi_host_template sht_v2_hw = { .host_tagset = 1, .reserved_queuecommand = sas_queuecommand_internal, .reserved_timedout = sas_internal_timeout, + .nr_reserved_cmds = 2, }; static const struct hisi_sas_hw hisi_sas_v2_hw = { diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 02d96fba510f..d703af7985b0 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -3247,6 +3247,7 @@ static struct scsi_host_template sht_v3_hw = { .host_tagset = 1, .reserved_queuecommand = sas_queuecommand_internal, .reserved_timedout = sas_internal_timeout, + .nr_reserved_cmds = 2, }; static const struct hisi_sas_hw hisi_sas_v3_hw = { @@ -4859,6 +4860,10 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id) shost->max_lun = ~0; shost->max_channel = 1; shost->max_cmd_len = 16; + /* + * Intentionally use HISI_SAS_UNRESERVED_IPTT for .can_queue until + * every sas_task we're sent has a request associated. + */ shost->can_queue = HISI_SAS_UNRESERVED_IPTT; shost->cmd_per_lun = HISI_SAS_UNRESERVED_IPTT; diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c index 9c7869bf6cde..c07d89451bb6 100644 --- a/drivers/scsi/isci/init.c +++ b/drivers/scsi/isci/init.c @@ -179,6 +179,7 @@ static struct scsi_host_template isci_sht = { .track_queue_depth = 1, .reserved_queuecommand = sas_queuecommand_internal, .reserved_timedout = sas_internal_timeout, + .nr_reserved_cmds = 2, }; static struct sas_domain_function_template isci_transport_ops = { diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c index 7fed0259e1f5..07e6c5d6c46d 100644 --- a/drivers/scsi/mvsas/mv_init.c +++ b/drivers/scsi/mvsas/mv_init.c @@ -56,6 +56,7 @@ static struct scsi_host_template mvs_sht = { .track_queue_depth = 1, .reserved_queuecommand = sas_queuecommand_internal, .reserved_timedout = sas_internal_timeout, + .nr_reserved_cmds = 2, }; static struct sas_domain_function_template mvs_transport_ops = { @@ -470,6 +471,10 @@ static void mvs_post_sas_ha_init(struct Scsi_Host *shost, else can_queue = MVS_CHIP_SLOT_SZ; + /* + * Carve out MVS_RSVD_SLOTS slots internally until every sas_task we're sent + * has a request associated. + */ can_queue -= MVS_RSVD_SLOTS; shost->sg_tablesize = min_t(u16, SG_ALL, MVS_MAX_SG); diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index ce9509792bc0..e37e8898afaa 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -125,6 +125,7 @@ static struct scsi_host_template pm8001_sht = { .map_queues = pm8001_map_queues, .reserved_queuecommand = sas_queuecommand_internal, .reserved_timedout = sas_internal_timeout, + .nr_reserved_cmds = 2, }; /* @@ -1214,7 +1215,10 @@ static int pm8001_init_ccb_tag(struct pm8001_hba_info *pm8001_ha) max_out_io = pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_out_io; ccb_count = min_t(int, PM8001_MAX_CCB, max_out_io); - + /* + * Intentionally use ccb_count - PM8001_RESERVE_SLOT for .can_queue + * until every sas_task we're sent has a request associated. + */ shost->can_queue = ccb_count - PM8001_RESERVE_SLOT; pm8001_ha->rsvd_tags = bitmap_zalloc(PM8001_RESERVE_SLOT, GFP_KERNEL); From patchwork Tue Oct 25 10:18:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10680 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp908585wru; Tue, 25 Oct 2022 02:54:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5laMVpTAcJ+fjOTjnWiIp7+ggusCacb3rxBHD+mRwDOVUOcDaYTrCylZh+m58dKq+nf6Gm X-Received: by 2002:a17:90a:6045:b0:212:fe9a:5792 with SMTP id h5-20020a17090a604500b00212fe9a5792mr13486069pjm.178.1666691672463; Tue, 25 Oct 2022 02:54:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691672; cv=none; d=google.com; s=arc-20160816; b=Zsd8iy3VRtXYIdzNb5VqnjycMYtz4Lope4fu3Bp3cE34t9B4hGpKi8sO2NixAXnilQ u+Tpq1wQPoKzMSDYyTZ1Zr/swkFLUmYdu+U8f4oq0K5Axt0K4zjL3RFdKyVkx8QoTK+g 821z4XFDeuGXTgdzcepv2ysAgkxAfmRdKpuSdNXwuYkZ3TGu4mFudK9hU+uN4syKR+Iy hY2uiCeJE0QyQIreRfjY9qRnykd1dqQe4oJDRsPvfHHvGACbuvTo2/7XpJpGIoF+8Cxa mip/hiwJMIq3gMYOl2gbFIw8K8rkr4YRESgj1YxXT4UGTV5+t7olymPjbOCfaxzzWvgR uoXg== 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=Lo6zYqPhMQ07Vpmhe8dtf/zkjp5cO9c5LB7JbQ3L0G8=; b=JMRquwuwYd1kW+YtfpwazkYduxIac22k6QtLdctRPRhvd7/RDhHIIsGyYYWUIuncF7 uPQpbVvtdm/yaEVY2rLelP3MBO5N2c30MpnM3fTQINrxK+st3uNqmdS7PINSpZaCWN14 0ql80njUKq2SHPs7AHORWOi+SWknRN7P7znuXWukN3GqtldrHGC8c2ERCL6JvYQQu+JW W7nnHYRfYksWCQzfYaBfZW4tc0nu+gFJJF8yJLI8Lm3ov1hpQqQ3mE3bCUhi3GbEuH0y oVHQ219UmW7prxXu+RRDsHWnEXsQAJQyW5qR+YRLhbONvcLQmms3+bFBXU+aI4g4a1wR hwaQ== 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 p21-20020a631e55000000b00439ae523fd2si2635637pgm.289.2022.10.25.02.54.18; Tue, 25 Oct 2022 02:54:32 -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 S231591AbiJYJxX (ORCPT + 99 others); Tue, 25 Oct 2022 05:53:23 -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 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?1747652887225550063?= X-GMAIL-MSGID: =?utf-8?q?1747652887225550063?= 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_expander.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 *dev, pm_runtime_get_sync(ha->dev); mutex_lock(&dev->ex_dev.cmd_mutex); for (retry = 0; retry < 3; retry++) { + struct request *rq; + if (test_bit(SAS_DEV_GONE, &dev->state)) { res = -ECOMM; break; } - task = sas_alloc_slow_task(GFP_KERNEL); + task = sas_alloc_slow_task_rq(dev, GFP_KERNEL); if (!task) { res = -ENOMEM; break; } - task->dev = dev; + + rq = scsi_cmd_to_rq(task->uldd_task); + rq->timeout = SMP_TIMEOUT*HZ; + task->task_proto = dev->tproto; task->smp_task.smp_req = *req; task->smp_task.smp_resp = *resp; - task->task_done = sas_task_internal_done; - - task->slow_task->timer.function = sas_task_internal_timedout; - task->slow_task->timer.expires = jiffies + SMP_TIMEOUT*HZ; - 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_notice("executing SMP task failed:%d\n", res); - break; - } + blk_execute_rq_nowait(rq, true); wait_for_completion(&task->slow_task->completion); res = -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_device *device, gfp_t flag return NULL; task->dev = device; + task->task_done = sas_task_complete_internal; rq = 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_device *device, gfp_t flag scmd = blk_mq_rq_to_pdu(rq); task->uldd_task = scmd; + + rq->end_io = sas_blk_end_sync_rq; rq->end_io_data = task; return task; diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.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); +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 error); + #ifdef CONFIG_SCSI_SAS_HOST_SMP extern void sas_smp_host_handler(struct bsg_job *job, struct Scsi_Host *shost); #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); } +void sas_task_complete_internal(struct sas_task *task) +{ + struct scsi_cmnd *scmd = task->uldd_task; + + scsi_done(scmd); +} + void sas_task_internal_timedout(struct timer_list *t) { struct sas_task_slow *slow = from_timer(slow, t, timer); @@ -952,6 +959,15 @@ EXPORT_SYMBOL_GPL(sas_internal_timeout); #define TASK_TIMEOUT (20 * HZ) #define TASK_RETRY 3 +enum rq_end_io_ret sas_blk_end_sync_rq(struct request *rq, blk_status_t error) +{ + struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq); + struct sas_task *task = 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) 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)); From patchwork Tue Oct 25 10:18:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10682 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp909026wru; Tue, 25 Oct 2022 02:56:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM66t4uG2yTr72KhGMUchz2Jk+afCNe0nIAsx2VCTFt9vu1+nbmmQ0bINCKYcso/LFtFT5Jk X-Received: by 2002:a17:90a:29e4:b0:20a:f9d5:c10e with SMTP id h91-20020a17090a29e400b0020af9d5c10emr80732300pjd.132.1666691766236; Tue, 25 Oct 2022 02:56:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691766; cv=none; d=google.com; s=arc-20160816; b=VbTbFdrzTwiW0fI427ozEAWyJgd12wB2RsnDjgxRsuqW8opS++9WYLYgvq6mi34m+Y f86oafmWKzMIt0mReHajtClcNEpEnfmlTblU0G4nltr/I4sx3tBu1uhnroYuoGwdPx02 2iAl8PwaK1SPCEMI22nyRJixLr6OG2eXZnjBeg39syt9LMCBWCh/s3KVI2dlCq4kI8yV ejHnynldBjQKuwK8rKSFIO32dV+SLng7t8yO1EI2exGqomoQD86P6eVRMmIHAkEwJEkr PuX3XFYpu/PaWiRiP5U7SoBrwLH2jX1u0EMoK7+kYzVkKzCsq6EaaHW7JcH8NGHB4hy/ oT3Q== 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=OQc+3n3P39F/V/5qU2BlJusBFuohXs/jYChAQypY/po=; b=FjRQ0Y+y9s/MAzezIHI9tNXkyhn5HwSyMC5oCIDtx3SE2gzq1/uJ/fUKdXCZ0pl/4G BNK9hUdWkCf40HFZDc0BUI6Zz6V8RD0C9cpyde413YQFDtGj0tFOIn7bXy5blGH/1c/I 77AOH3C6zynqrS8rqbk5/F/p5fObJhc48AmTLsnN+ffdI1ml3zDzCz6jooo4Gn+FqA8Q SW9Z0TFm888ZqIr+mRttiAIWBTTm7scRV3HMIxET7BNFilm1MKCbRlAWddmyWtjc+Avz S8lTq18HWZU8s14GqzoqVbLIvrWwX4WKAmPUmh3LgK+r6OTJ1NnbskEc8BgvQeS58t8Q 4Vtg== 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 127-20020a621985000000b0056362152f8fsi2393660pfz.253.2022.10.25.02.55.52; Tue, 25 Oct 2022 02:56:06 -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 S231686AbiJYJyV (ORCPT + 99 others); Tue, 25 Oct 2022 05:54:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231608AbiJYJww (ORCPT ); Tue, 25 Oct 2022 05:52:52 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 158F0134A84; Tue, 25 Oct 2022 02:49:21 -0700 (PDT) Received: from fraeml744-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRvL0Zclz688yr; Tue, 25 Oct 2022 17:47:58 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml744-chm.china.huawei.com (10.206.15.225) 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:19 +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:14 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 20/22] scsi: core: Add scsi_alloc_request_hwq() Date: Tue, 25 Oct 2022 18:18:14 +0800 Message-ID: <1666693096-180008-21-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?1747652985356577137?= X-GMAIL-MSGID: =?utf-8?q?1747652985356577137?= Add a variant of scsi_alloc_request() which allocates a request for a specific hw queue. Signed-off-by: John Garry --- drivers/scsi/scsi_lib.c | 12 ++++++++++++ include/scsi/scsi_cmnd.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 08015c42c326..a622be13bc48 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1143,6 +1143,18 @@ struct request *scsi_alloc_request(struct request_queue *q, blk_opf_t opf, } EXPORT_SYMBOL_GPL(scsi_alloc_request); +struct request *scsi_alloc_request_hwq(struct request_queue *q, + unsigned int op, blk_mq_req_flags_t flags, unsigned int hwq) +{ + struct request *rq; + + rq = blk_mq_alloc_request_hctx(q, op, flags, hwq); + if (!IS_ERR(rq)) + scsi_initialize_rq(rq); + return rq; +} +EXPORT_SYMBOL_GPL(scsi_alloc_request_hwq); + /* * Only called when the request isn't completed by SCSI, and not freed by * SCSI diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index 7d3622db38ed..1fd98d1e9c73 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -389,4 +389,7 @@ extern void scsi_build_sense(struct scsi_cmnd *scmd, int desc, struct request *scsi_alloc_request(struct request_queue *q, blk_opf_t opf, blk_mq_req_flags_t flags); +struct request *scsi_alloc_request_hwq(struct request_queue *q, + unsigned int op, blk_mq_req_flags_t flags, unsigned int hwq); + #endif /* _SCSI_SCSI_CMND_H */ From patchwork Tue Oct 25 10:18:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10683 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp909101wru; Tue, 25 Oct 2022 02:56:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7qpQY+3+FksDHlDoKbQBTsorPdXfkMPy0RBqx1+D5cfh1Fgw7S1DUp8SMQ3Zvj4SG4pp3H X-Received: by 2002:a17:902:e811:b0:186:8a61:ea76 with SMTP id u17-20020a170902e81100b001868a61ea76mr16492830plg.10.1666691781103; Tue, 25 Oct 2022 02:56:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691781; cv=none; d=google.com; s=arc-20160816; b=vNdarTXbrhyugpCTvecx18KjoyEQRmDj2famfOn97AVboZGi25AWlHYF4N2VsbS9q9 fPu18O5sfHe35iGWpydb/oI3xtIP2Qlgb5w9Ssr9iP1lhcCNvuunbaPealuwOnNNth7B kw7y5j1qCEO74ungwfunPGx42QcExvaDYt/UmbPiIdmO0WJsd51CNKfrjRaEYeq9QZ/G YgRlR75O8Rd6TL6+tZvTaNFg0GOKCC8fildo5OlzpBqNsVe2UCo0+vTTVG41eEw7aZdk RkcABQDn062ACyd2yUJ6FBl5yttRdf2TtdlOZWBk5mzeXDgiZtV0/X6Tu20yYs/sGSdW 7Zfg== 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=tm1uWS3PmhkHPK9FQpBRxOv9e8jM4GYWcv+eCUn/HU8=; b=EzoXCffh2TbO+aBXEo3JmizfiuPVYbSrqN2n1EYt9rzks1yEGVTCspi7GQK0UNGNqu Hn+04t1nEGVH66xdZV09YM+kMXkG5TeGXDYNRRJ8mT9zRS7jpYn5axd1CezBgNN1fMpm ET+wJjjrUkfV40d9P8gTP3QZtRiSTXEMXWo2ae2jjPWvX7eGppnnk+lCsxWSop/s4iht 4VT1j/H1+c8gs3zqto6hsCSk5lZxrBaTf45iCfLNsPtgyoWkUiBmXNxdvmr3qGWh0DgJ 47JGHtefKZor/5AyRlJywHWCUwAd8iwsS7n32kRbXLhtEIcqhSiHwt6DW4QPi+aVDNMQ tH6Q== 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 jd21-20020a170903261500b0017532e01e57si2196427plb.200.2022.10.25.02.56.07; Tue, 25 Oct 2022 02:56: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 S231947AbiJYJy1 (ORCPT + 99 others); Tue, 25 Oct 2022 05:54:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232116AbiJYJw6 (ORCPT ); Tue, 25 Oct 2022 05:52:58 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EECDBC8F; Tue, 25 Oct 2022 02:49:25 -0700 (PDT) Received: from fraeml743-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRtp5tYhz688p7; Tue, 25 Oct 2022 17:47:30 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml743-chm.china.huawei.com (10.206.15.224) 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:23 +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:19 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 21/22] scsi: libsas: Queue internal abort commands as requests Date: Tue, 25 Oct 2022 18:18:15 +0800 Message-ID: <1666693096-180008-22-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?1747653001029257171?= X-GMAIL-MSGID: =?utf-8?q?1747653001029257171?= Like what we did for SMP commands, send internal abort commands through the block layer. At this point we can delete special handling in sas_task_abort() for SAS "internal" commands, as every slow task now has a request associated. Function sas_task_internal_timedout() is no longer referenced, so delete it. Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 36 +++++++++---------- drivers/scsi/libsas/sas_expander.c | 2 +- drivers/scsi/libsas/sas_init.c | 12 +++++-- drivers/scsi/libsas/sas_internal.h | 3 +- drivers/scsi/libsas/sas_scsi_host.c | 52 ++++++--------------------- include/scsi/libsas.h | 1 - 6 files changed, 38 insertions(+), 68 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index fe2752d24fe8..65475775c844 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -465,7 +465,7 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags) struct hisi_sas_port *port; struct hisi_hba *hisi_hba; struct hisi_sas_slot *slot; - struct request *rq = NULL; + struct request *rq; struct device *dev; int rc; @@ -485,6 +485,21 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags) hisi_hba = dev_to_hisi_hba(device); dev = hisi_hba->dev; + rq = sas_task_find_rq(task); + if (rq) { + unsigned int dq_index; + u32 blk_tag; + + blk_tag = blk_mq_unique_tag(rq); + dq_index = blk_mq_unique_tag_to_hwq(blk_tag); + dq = &hisi_hba->dq[dq_index]; + } else { + struct Scsi_Host *shost = hisi_hba->shost; + struct blk_mq_queue_map *qmap = &shost->tag_set.map[HCTX_TYPE_DEFAULT]; + int queue = qmap->mq_map[raw_smp_processor_id()]; + + dq = &hisi_hba->dq[queue]; + } switch (task->task_proto) { case SAS_PROTOCOL_SSP: @@ -519,22 +534,6 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags) return -ECOMM; } - - rq = sas_task_find_rq(task); - if (rq) { - unsigned int dq_index; - u32 blk_tag; - - blk_tag = blk_mq_unique_tag(rq); - dq_index = blk_mq_unique_tag_to_hwq(blk_tag); - dq = &hisi_hba->dq[dq_index]; - } else { - struct Scsi_Host *shost = hisi_hba->shost; - struct blk_mq_queue_map *qmap = &shost->tag_set.map[HCTX_TYPE_DEFAULT]; - int queue = qmap->mq_map[raw_smp_processor_id()]; - - dq = &hisi_hba->dq[queue]; - } break; case SAS_PROTOCOL_INTERNAL_ABORT: if (!hisi_hba->hw->prep_abort) @@ -543,13 +542,10 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags) if (test_bit(HISI_SAS_HW_FAULT_BIT, &hisi_hba->flags)) return -EIO; - hisi_hba = dev_to_hisi_hba(device); - if (unlikely(test_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags))) return -EINVAL; port = to_hisi_sas_port(sas_port); - dq = &hisi_hba->dq[task->abort_task.qid]; break; default: dev_err(hisi_hba->dev, "task prep: unknown/unsupported proto (0x%x)\n", diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index cc41127ea5cc..e852f1565fe7 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c @@ -50,7 +50,7 @@ static int smp_execute_task_sg(struct domain_device *dev, break; } - task = sas_alloc_slow_task_rq(dev, GFP_KERNEL); + task = sas_alloc_slow_task_rq(dev, GFP_KERNEL, -1U); if (!task) { res = -ENOMEM; break; diff --git a/drivers/scsi/libsas/sas_init.c b/drivers/scsi/libsas/sas_init.c index 5f9e71a54799..c3f602bd2c4c 100644 --- a/drivers/scsi/libsas/sas_init.c +++ b/drivers/scsi/libsas/sas_init.c @@ -56,7 +56,7 @@ struct sas_task *sas_alloc_slow_task(gfp_t flags) return task; } -struct sas_task *sas_alloc_slow_task_rq(struct domain_device *device, gfp_t flags) +struct sas_task *sas_alloc_slow_task_rq(struct domain_device *device, gfp_t flags, unsigned int qid) { struct sas_ha_struct *sas_ha = device->port->ha; struct Scsi_Host *shost = sas_ha->core.shost; @@ -86,8 +86,14 @@ struct sas_task *sas_alloc_slow_task_rq(struct domain_device *device, gfp_t flag task->dev = device; task->task_done = sas_task_complete_internal; - rq = scsi_alloc_request(sdev->request_queue, REQ_OP_DRV_IN, - BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT); + if (qid == -1U) { + rq = scsi_alloc_request(sdev->request_queue, REQ_OP_DRV_IN, + BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT); + } else { + rq = scsi_alloc_request_hwq(sdev->request_queue, REQ_OP_DRV_IN, + BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT, + qid); + } if (IS_ERR(rq)) { sas_free_task(task); return NULL; diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h index 9b58948c57c2..af4a4bf88830 100644 --- a/drivers/scsi/libsas/sas_internal.h +++ b/drivers/scsi/libsas/sas_internal.h @@ -54,7 +54,8 @@ void sas_free_event(struct asd_sas_event *event); struct sas_task *sas_alloc_task(gfp_t flags); struct sas_task *sas_alloc_slow_task(gfp_t flags); -struct sas_task *sas_alloc_slow_task_rq(struct domain_device *device, gfp_t flags); +struct sas_task *sas_alloc_slow_task_rq(struct domain_device *device, gfp_t flags, + unsigned int qid); void sas_free_task(struct sas_task *task); int sas_register_ports(struct sas_ha_struct *sas_ha); diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index e6ee8dd56a45..a93e019a7dbf 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c @@ -920,23 +920,6 @@ void sas_task_complete_internal(struct sas_task *task) scsi_done(scmd); } -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); -} enum blk_eh_timer_return sas_internal_timeout(struct scsi_cmnd *scmd) { struct sas_task *task = TO_SAS_TASK(scmd); @@ -978,28 +961,23 @@ static int sas_execute_internal_abort(struct domain_device *device, 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, qid); if (!task) return -ENOMEM; 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->task_done = sas_task_complete_internal; 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); - break; - } + rq = scsi_cmd_to_rq(task->uldd_task); + rq->timeout = TASK_TIMEOUT; + + blk_execute_rq_nowait(rq, true); wait_for_completion(&task->slow_task->completion); res = TMF_RESP_FUNC_FAILED; @@ -1069,7 +1047,7 @@ int sas_execute_tmf(struct domain_device *device, void *parameter, for (retry = 0; retry < TASK_RETRY; retry++) { struct request *rq; - task = sas_alloc_slow_task_rq(device, GFP_KERNEL); + task = sas_alloc_slow_task_rq(device, GFP_KERNEL, -1U); if (!task) return -ENOMEM; @@ -1251,17 +1229,7 @@ void sas_task_abort(struct sas_task *task) { struct scsi_cmnd *sc = task->uldd_task; - /* Escape for libsas internal commands */ - if (!sc) { - struct sas_task_slow *slow = task->slow_task; - - if (!slow) - return; - if (!del_timer(&slow->timer)) - return; - slow->timer.function(&slow->timer); - return; - } + WARN_ON_ONCE(!sc); if (dev_is_sata(task->dev) && !task->slow_task) sas_ata_task_abort(task); diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index f02156ccd376..60543d8b01d4 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -565,7 +565,6 @@ enum sas_internal_abort { struct sas_internal_abort_task { enum sas_internal_abort type; - unsigned int qid; u16 tag; }; From patchwork Tue Oct 25 10:18:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10684 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp909252wru; Tue, 25 Oct 2022 02:56:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5YgW/e0ydUZ1cBaWUR9pIxe0d+NVgE3l5VrJ4EgJAI9k3Gl53NMNkGQRq7GoZitK4AlM3O X-Received: by 2002:a17:903:1250:b0:185:40c6:3c2c with SMTP id u16-20020a170903125000b0018540c63c2cmr37931137plh.64.1666691809719; Tue, 25 Oct 2022 02:56:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691809; cv=none; d=google.com; s=arc-20160816; b=R2rC5X+mpby8i4QLFaPPzT4scjo+rZEvvdVehBI0MjUlpXR8Lf89nkMMhWk/NHxUm4 oRWBJermP63GVUXbbXp0cZiDDwW7PRLYoSCqwyHlR/RRhZYhkNGQwjSCvYIeZLG2nSwO iWvbZ8Hm03husDI8MGHjdc2Ph3jo16wlzb+v2PEn9VoIXCHUyaVyMJ2ICuBUdYQ8cTTj LY/Fldkbj7OmJYNWMgLQBkxqFoYbwPD24wgR8C2rYbyOAn6RiXsTmyye2dwW07Cs90e8 h+q7veQgSWRCmMfzL0hmOaUo196x3qptg6Z0Hy0Gneygv7hlvq3/W/d/fyh3wPxmgg0X dU0w== 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=qLvJR6rDDcu/zliNT57c1zK486HsvKtjff7AOTPoIEg=; b=eysw71GxLxrDrQbDaGuQcNkimj2ZfnMgGi+CvngO9ioklFIX9hVQy/QVAN7vRxWQ6F sRbprqBiP+/9LoIUXSaSmmP/fzM95nP3jhnthQt1ixu+t9bBEk09ufs2fNGvs5U7tu9i mmCQLOEJirqP0CkyCPtu0w5cUztfIak2y9I6+j2/4lXLPHxGVbPVdbOt05afADGQ1RBq yR8Hc17fqSYW+poFpBteOey4JisNllJ6myW9aITSAH3OJg8tqUEh8vLvSYE3PGrxKOQa Ro9PU1YaCTIyFt/t6Hg5EhL7BPbxPXR/e+o6BAD396Ui4QCtVZbIGQdgp52s1jIzshXf IHFg== 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 b15-20020a056a00114f00b0056bf15d0cbfsi2845122pfm.308.2022.10.25.02.56.36; Tue, 25 Oct 2022 02:56:49 -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 S231815AbiJYJyX (ORCPT + 99 others); Tue, 25 Oct 2022 05:54:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231167AbiJYJw6 (ORCPT ); Tue, 25 Oct 2022 05:52:58 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84C6214093; Tue, 25 Oct 2022 02:49:29 -0700 (PDT) Received: from fraeml742-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRtt6bPxz6H72c; Tue, 25 Oct 2022 17:47:34 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) 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.31; Tue, 25 Oct 2022 11:49:27 +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:23 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 22/22] scsi: libsas: Delete sas_task_slow.timer Date: Tue, 25 Oct 2022 18:18:16 +0800 Message-ID: <1666693096-180008-23-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?1747653031028559035?= X-GMAIL-MSGID: =?utf-8?q?1747653031028559035?= We now send every slow task through the block layer and use the timeout facility there, so delete sas_task_slow.timer . Signed-off-by: John Garry --- drivers/scsi/libsas/sas_init.c | 1 - drivers/scsi/libsas/sas_scsi_host.c | 1 - include/scsi/libsas.h | 3 --- 3 files changed, 5 deletions(-) diff --git a/drivers/scsi/libsas/sas_init.c b/drivers/scsi/libsas/sas_init.c index c3f602bd2c4c..8b0e72c447d0 100644 --- a/drivers/scsi/libsas/sas_init.c +++ b/drivers/scsi/libsas/sas_init.c @@ -50,7 +50,6 @@ struct sas_task *sas_alloc_slow_task(gfp_t flags) task->slow_task = slow; slow->task = task; - timer_setup(&slow->timer, NULL, 0); init_completion(&slow->completion); return task; diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index a93e019a7dbf..4fdd84868ac2 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c @@ -909,7 +909,6 @@ EXPORT_SYMBOL_GPL(sas_bios_param); void sas_task_internal_done(struct sas_task *task) { - del_timer(&task->slow_task->timer); complete(&task->slow_task->completion); } diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index 60543d8b01d4..f903be5895a9 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -9,8 +9,6 @@ #ifndef _LIBSAS_H_ #define _LIBSAS_H_ - -#include #include #include #include @@ -628,7 +626,6 @@ struct sas_task_slow { /* standard/extra infrastructure for slow path commands (SMP and * internal lldd commands */ - struct timer_list timer; struct completion completion; struct sas_task *task; };