From patchwork Fri Nov 18 08:37:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Zhan X-Patchwork-Id: 22191 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp69852wrr; Fri, 18 Nov 2022 00:45:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf4JKIvV7pDvyLittsm0rUhB3f5yDGpws0/1VtDsatIra6Okato2G3Ov2SFYbzH4RMdpgdaE X-Received: by 2002:a65:681a:0:b0:43c:7da:e64b with SMTP id l26-20020a65681a000000b0043c07dae64bmr5897407pgt.231.1668761150761; Fri, 18 Nov 2022 00:45:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668761150; cv=none; d=google.com; s=arc-20160816; b=rdlQnfVtOTv+BR36s7w1xBhtyT7DcXW6z8RtwCMbkCKxvZpuhM82SIkzCt9cSvRUdo iFhp4ru+mpH8Uoxuu+CDqIKyad4oa/PqaVm50yNmmdQINThkmEXhJegtLcOHlEteLa/m o8PP5Ol1MKxqUOBai7hsScerQPDnwMBGx5ZWaPBJJarCe0jR2d70J5v8iWb1LuJJ8bpf U30pIGEH30GSP8bbzU6k7COHf1ZW7bAPDKvpVL98GUcVfA7K69zaNl2KmBr4C0ft+tv1 BaFFp/WY2Qw/rTOwf4p9zbWnw2tb4j/H+T/2fNKQGt74AhtIEGMaK/6FL4lHW0tD+vge JuCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=fzpz+RoSBhBHF/ImZjV4E27vSYHp+8gJCIlt6t4Vcuw=; b=cBYDI5huq7kDpyulklBh2g/XoxoADRpe2jcjijO19pyyK2won7hDKnE0uScE5DGHOt zBeCgwIqjd/l8yMXwb4h+qHOP4VDbnS9ZNo+PUO1HNtJ4CtZ4NYak5ZjP7e6FabQ47M9 k8CyL4cRgBlj5lQZpvZzAujam7bl1Ppq7oUkHCLqNI3kHyL4skXT+Tttstk2fRTk4fI4 HcYUThF/8TC6kqw2LuEyxvu0WgUEu/tF3flmuGR4ZG5ZhZ9laerSWr16CYADvpyj5oS0 B31+SVe2NHVsRW0NFAPUbzypnz6ucgNFpqYwR2zgZRVVLNuMWq39t3uIXev3EB5+oxtA RCTw== 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=hisilicon.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rj4-20020a17090b3e8400b001ed40b70436si3390428pjb.155.2022.11.18.00.45.37; Fri, 18 Nov 2022 00:45:50 -0800 (PST) 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=hisilicon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241483AbiKRIim (ORCPT + 99 others); Fri, 18 Nov 2022 03:38:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235238AbiKRIi2 (ORCPT ); Fri, 18 Nov 2022 03:38:28 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1B526324; Fri, 18 Nov 2022 00:38:26 -0800 (PST) Received: from dggpeml500021.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4ND97b06YGzqSYh; Fri, 18 Nov 2022 16:34:35 +0800 (CST) Received: from dggpeml500019.china.huawei.com (7.185.36.137) by dggpeml500021.china.huawei.com (7.185.36.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 18 Nov 2022 16:38:19 +0800 Received: from localhost.localdomain (10.67.165.2) by dggpeml500019.china.huawei.com (7.185.36.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 18 Nov 2022 16:38:18 +0800 From: Jie Zhan To: , CC: , , , , , , , , , , , , Subject: [PATCH for-next 3/5] scsi: libsas: Add smp_ata_check_ready_type() Date: Fri, 18 Nov 2022 16:37:12 +0800 Message-ID: <20221118083714.4034612-4-zhanjie9@hisilicon.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20221118083714.4034612-1-zhanjie9@hisilicon.com> References: <20221118083714.4034612-1-zhanjie9@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500019.china.huawei.com (7.185.36.137) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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?1749822892483674582?= X-GMAIL-MSGID: =?utf-8?q?1749822892483674582?= Create function smp_ata_check_ready_type() for lldds to wait for SATA devices to come up after a link reset. Signed-off-by: Jie Zhan --- drivers/scsi/libsas/sas_ata.c | 25 +++++++++++++++++++++++++ drivers/scsi/libsas/sas_expander.c | 4 ++-- drivers/scsi/libsas/sas_internal.h | 2 ++ include/scsi/sas_ata.h | 6 ++++++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index 78e6046fb55a..4b65cd79150f 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c @@ -287,6 +287,31 @@ static int sas_ata_clear_pending(struct domain_device *dev, struct ex_phy *phy) return 1; } +int smp_ata_check_ready_type(struct ata_link *link) +{ + struct domain_device *dev = link->ap->private_data; + struct sas_phy *phy = sas_get_local_phy(dev); + struct domain_device *ex_dev = dev->parent; + enum sas_device_type type = SAS_PHY_UNUSED; + u8 sas_addr[SAS_ADDR_SIZE]; + int res; + + res = sas_get_phy_attached_dev(ex_dev, phy->number, sas_addr, &type); + sas_put_local_phy(phy); + if (res) + return res; + + switch (type) { + case SAS_SATA_PENDING: + return 0; + case SAS_END_DEVICE: + return 1; + default: + return -ENODEV; + } +} +EXPORT_SYMBOL_GPL(smp_ata_check_ready_type); + static int smp_ata_check_ready(struct ata_link *link) { int res; diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index 2907ca5d0ed4..a04cad620e93 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c @@ -1688,8 +1688,8 @@ static int sas_get_phy_change_count(struct domain_device *dev, return res; } -static int sas_get_phy_attached_dev(struct domain_device *dev, int phy_id, - u8 *sas_addr, enum sas_device_type *type) +int sas_get_phy_attached_dev(struct domain_device *dev, int phy_id, + u8 *sas_addr, enum sas_device_type *type) { int res; struct smp_disc_resp *disc_resp; diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h index 6cf190ade35e..6f593fa69b58 100644 --- a/drivers/scsi/libsas/sas_internal.h +++ b/drivers/scsi/libsas/sas_internal.h @@ -88,6 +88,8 @@ struct domain_device *sas_ex_to_ata(struct domain_device *ex_dev, int phy_id); int sas_ex_phy_discover(struct domain_device *dev, int single); int sas_get_report_phy_sata(struct domain_device *dev, int phy_id, struct smp_rps_resp *rps_resp); +int sas_get_phy_attached_dev(struct domain_device *dev, int phy_id, + u8 *sas_addr, enum sas_device_type *type); int sas_try_ata_reset(struct asd_sas_phy *phy); void sas_hae_reset(struct work_struct *work); diff --git a/include/scsi/sas_ata.h b/include/scsi/sas_ata.h index e47f0aec0722..e7d466df8157 100644 --- a/include/scsi/sas_ata.h +++ b/include/scsi/sas_ata.h @@ -36,6 +36,7 @@ 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); +int smp_ata_check_ready_type(struct ata_link *link); #else @@ -104,6 +105,11 @@ static inline int sas_ata_wait_after_reset(struct domain_device *dev, { return -ETIMEDOUT; } + +static inline int smp_ata_check_ready_type(struct ata_link *link) +{ + return 0; +} #endif #endif /* _SAS_ATA_H_ */