Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp538143rwb; Thu, 22 Sep 2022 03:14:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4/Kk+J7TkN8JkBVbqCj0FYGfXumu6JRDMWxyv5rTfdLl+ZsiHaRvVvaTg843YElaiGiaJh X-Received: by 2002:a05:6a00:2409:b0:54e:a3ad:d32d with SMTP id z9-20020a056a00240900b0054ea3add32dmr2933928pfh.70.1663841674014; Thu, 22 Sep 2022 03:14:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663841674; cv=none; d=google.com; s=arc-20160816; b=lOvo/XgHbz9ZRpaFLzEdjrzbrjr+FcyMl0nGoMPigknjWuVkTCuS/6sIGM1hPnfOYS L9TFG6Sj0perwdRm3yOMycFW6LHXwv0HO7ujRbSEiN8xyIOYgMMlVW/nYqD6NU3fjnKa efxEPU/Ml5Agd5EkgB+mA4Y+FnOMJuND8jX9/B48B2CktdO+niGKqOHnMijwVGrlDFRh h62dVNKUiD5A0zC67mQwqUJnbR28EiJKZ2kG58EagQ3uZJ8RqcrUjZBPiMpcc5nladAw S40Im7WnBWD8G7XUErGRLkhZsGoyvuE9dxjGlMmJv1nZTaafXNEF3bWp7PodGhOH9RCQ vhdg== 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=Y+MeOneb1I1bOfKNvSxgM1SFXWwGcspH994hitKIA4Q=; b=Cs78hia/9oXV4co6rXeX7rC4R5PizSiRzwE1hODfSG6hC05lwSBnhwoH6Rh2HpJRPV 8n1XINgMuPtGYvSIgctrenzgi6pPN1hlBJN/VJYkpMjaFIWNEGi3GPwmaePOTgZFQaR3 xapvNgoEwm37ciE41gVS6oVXc61fDHAsJMGaYrClqjz1YdCgQ2k/ZrrFftWUtcJCGxCg JoSFBf3hReidxOs9aURlutG2uIx49l8Tdy5Pt+5UzMfVXGXFj8j17RQX3fGwfckg8U1F iKi2X8sSAv2v8TEvtHkuS3QR6k9KhvF/KrdNhV7AwPqcQdr9q4ErPSqqbH2yPSCfWURg 254Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g66-20020a636b45000000b0042b90c1d31dsi5492768pgc.829.2022.09.22.03.14.22; Thu, 22 Sep 2022 03:14:34 -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 S231341AbiIVJyD (ORCPT + 99 others); Thu, 22 Sep 2022 05:54:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231244AbiIVJxk (ORCPT ); Thu, 22 Sep 2022 05:53:40 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08F7BD58AD; Thu, 22 Sep 2022 02:53:29 -0700 (PDT) Received: from fraeml737-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MY9Xr4Hmnz67kTG; Thu, 22 Sep 2022 17:51:40 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml737-chm.china.huawei.com (10.206.15.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 22 Sep 2022 11:53: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; Thu, 22 Sep 2022 10:53:25 +0100 From: John Garry To: , , , CC: , , , , John Garry Subject: [PATCH v4 1/7] scsi: libsas: Add sas_ata_device_link_abort() Date: Thu, 22 Sep 2022 17:46:52 +0800 Message-ID: <1663840018-50161-2-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1663840018-50161-1-git-send-email-john.garry@huawei.com> References: <1663840018-50161-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To 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 Similar to how AHCI handles NCQ errors in ahci_error_intr() -> ata_port_abort() -> ata_do_link_abort(), add an NCQ error handler for LLDDs to call to initiate a link abort. This will mark all outstanding QCs as failed and kick-off EH. Note: A "force reset" argument is added for drivers which require the ATA error handling to always reset the device. A driver may require this feature for when SATA device per-SCSI cmnd resources are only released during reset for ATA EH. As such, we need an option to force reset to be done, regardless of what any EH autopsy decides. Suggested-by: Damien Le Moal Signed-off-by: John Garry Tested-by: Damien Le Moal --- drivers/scsi/libsas/sas_ata.c | 12 ++++++++++++ include/scsi/sas_ata.h | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index d35c9296f738..bdffb6852dcf 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c @@ -861,6 +861,18 @@ void sas_ata_wait_eh(struct domain_device *dev) ata_port_wait_eh(ap); } +void sas_ata_device_link_abort(struct domain_device *device, bool force_reset) +{ + struct ata_port *ap = device->sata_dev.ap; + struct ata_link *link = &ap->link; + + link->eh_info.err_mask |= AC_ERR_DEV; + if (force_reset) + link->eh_info.action |= ATA_EH_RESET; + ata_link_abort(link); +} +EXPORT_SYMBOL_GPL(sas_ata_device_link_abort); + int sas_execute_ata_cmd(struct domain_device *device, u8 *fis, int force_phy_id) { struct sas_tmf_task tmf_task = {}; diff --git a/include/scsi/sas_ata.h b/include/scsi/sas_ata.h index a1df4f9d57a3..e47f0aec0722 100644 --- a/include/scsi/sas_ata.h +++ b/include/scsi/sas_ata.h @@ -32,6 +32,7 @@ void sas_probe_sata(struct asd_sas_port *port); void sas_suspend_sata(struct asd_sas_port *port); void sas_resume_sata(struct asd_sas_port *port); void sas_ata_end_eh(struct ata_port *ap); +void sas_ata_device_link_abort(struct domain_device *dev, bool force_reset); int sas_execute_ata_cmd(struct domain_device *device, u8 *fis, int force_phy_id); int sas_ata_wait_after_reset(struct domain_device *dev, unsigned long deadline); @@ -87,6 +88,11 @@ static inline void sas_ata_end_eh(struct ata_port *ap) { } +static inline void sas_ata_device_link_abort(struct domain_device *dev, + bool force_reset) +{ +} + static inline int sas_execute_ata_cmd(struct domain_device *device, u8 *fis, int force_phy_id) { -- 2.35.3