Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp547947rwb; Tue, 27 Sep 2022 00:53:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Thtu3COzs6NagifP1bPqAhrWUyLTp7XABGiGZg7xjl1uJuMKy2KaXTj2HBE2x4tTQ0uJC X-Received: by 2002:a17:902:c952:b0:176:bb2c:5459 with SMTP id i18-20020a170902c95200b00176bb2c5459mr24964997pla.165.1664265194567; Tue, 27 Sep 2022 00:53:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664265194; cv=none; d=google.com; s=arc-20160816; b=jMs6y/Ui9/ifEJYYBZGjKzRr0W4wLCGFkfm2lB+U0wmye2OUSHy0Ytx6hocAAusm/J uu0qMfdCEjdPXM64MfxC3O1np97QrvaUSo1YLcSAEuyZCYbqvkh5N0Uu5U33p1u2s1Rd 8L+dubq1gj1ylU6O1jsGO1bPzMFWqv30beRdJT8LzelHye9oF1PEOGiRIzUe53tYXUkb lXREd6Y+cZLvBYbt0oAK+YujFz/O5DO9RwywvTzYLG0UnuGu2m5uPKLYlwbu2pnBH/RA QpwwE5O8VmJ4KbNm/8BZ8Io2t4lfifgfQ163teVZJ1x6fx5KlIJWvC/fHJxcJm460ctO PxAg== 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=4MkOTaO8eJVTDLwbeodt/EhXb0fAHr+SAPY76YBT3FA=; b=J75vqFl9ZnDjtC++4IMaOp5P6cRM8zoDLu1gtaPLEBYzrmDj4Ev43COPsJTk5FVVzC KIiRtQZ38hiAFdz30gZsLazXpHp6hrwN9C88PwhdORTW5dNkUqbk/4jDZXhIhCMlihTN 5odRuTiYydQECnTdNJngL985JLw5lws05nHBZGGWvs3aNFNx5U8DClH3N1GNn6JDUmOd QJNtm0dfpBvF0H8ClgnBglvlxyXDJxdlPOnFv64XTWzMDKfNQq3uaKuiy1QGzi6olQPx VUpkprinsX9TjezRae5kowhNRd1rDbIao+/blMRiMVCLvC8wj0zOLiarzWpYai/4B8qv OWHA== 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 c12-20020a63da0c000000b0043adff6d43dsi1186785pgh.583.2022.09.27.00.53.03; Tue, 27 Sep 2022 00:53:14 -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 S229670AbiI0HLm (ORCPT + 99 others); Tue, 27 Sep 2022 03:11:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229942AbiI0HLg (ORCPT ); Tue, 27 Sep 2022 03:11:36 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C02B1A6C56; Tue, 27 Sep 2022 00:11:34 -0700 (PDT) Received: from fraeml707-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Mc9jQ55htz67L9G; Tue, 27 Sep 2022 15:09:30 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml707-chm.china.huawei.com (10.206.15.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 27 Sep 2022 09:11:32 +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, 27 Sep 2022 08:11:29 +0100 From: John Garry To: , , , CC: , , , , , "John Garry" Subject: [PATCH v5 1/7] scsi: libsas: Add sas_ata_device_link_abort() Date: Tue, 27 Sep 2022 15:04:52 +0800 Message-ID: <1664262298-239952-2-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1664262298-239952-1-git-send-email-john.garry@huawei.com> References: <1664262298-239952-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To 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 Reviewed-by: Jason Yan --- 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