From patchwork Fri Jan 4 16:01:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 154785 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp762389ljp; Fri, 4 Jan 2019 08:01:36 -0800 (PST) X-Google-Smtp-Source: ALg8bN5GzU+j+KCFxYmuq+PLc/lQ3zjhLoL8kOzI3tNw8/f5fDkjK58Nhv+3LaJZg8Mr/2VcwezG X-Received: by 2002:a17:902:b592:: with SMTP id a18mr45992221pls.293.1546617696600; Fri, 04 Jan 2019 08:01:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546617696; cv=none; d=google.com; s=arc-20160816; b=rgZW1a95zD/YStgPOcJx1qUxE2BP0ER9N+kGGk8loHIptKtF8dFUqI8eE/IxNiE7Qb Ky3k1Q66ihubOgyKRRjU+cixtVwNzxEd8aVePrxsGA0l8mRpAxkKdsfiui7gZDLMNu6f frrqACVW0inPhiXHUdeLF2uRZNsQT49uMQiZqclwWhKF94IV7I1g5eYRx6EA0pW533qg 2f5O8zPHX/XjRCN3gqccBRVaTmZJCeHz4hRLiKgZj11fav1/ieasQqRhJZ/k3NxAEDWi iqVQ/0JLL6S/RZu/8PXKeQSpY/GwElr5wPtuQRWMC8dnO9GUpeAKyE3xwFabWprhS4aI X+Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=U+Bk5nnyHOaUf6B936rt1YeaFe87xFTiGsbqoU848kI=; b=BW+sj675DTAOAFZQAS+TCntn6gwvcjMcK/k03bmYMiNEuVkL7PeBIEtyJD4eXO732G DtaMIcny6y/hfYTdZ0v2f0U2fjrBExz+C8RLqfjDChPp66ynNrrWOtBsdOO+9F6F33RV 3f7rRPbGv97Ag/U3Jo1O7P1giVVflC4cjXIC8tblm5XzoC+67dhWFUtFXscUCjQCFSdT HSy4MU14PMIO0rYEFVaWj7Wt29YN7cTyHXrpFadivTEH77xBJJVqVj1zwddwATM/Ih01 +M5+cu86ERw08iGTd5t57aXKO7fwHGHaOUUBz3DrPddwQfBsRL1z+ur52nVX2Nmz8Yag p+xw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gn20si52945551plb.98.2019.01.04.08.01.36; Fri, 04 Jan 2019 08:01:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728459AbfADQBe (ORCPT + 31 others); Fri, 4 Jan 2019 11:01:34 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:35488 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727192AbfADQBc (ORCPT ); Fri, 4 Jan 2019 11:01:32 -0500 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 694635C97288D; Sat, 5 Jan 2019 00:01:28 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.408.0; Sat, 5 Jan 2019 00:00:26 +0800 From: John Garry To: , CC: , , , , John Garry Subject: [PATCH 3/3] scsi: libsas: Support SATA PHY connection rate unmatch fixing during discovery Date: Sat, 5 Jan 2019 00:01:28 +0800 Message-ID: <1546617688-240623-4-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1546617688-240623-1-git-send-email-john.garry@huawei.com> References: <1546617688-240623-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +----------+ +----------+ | | | | | |--- 3.0 G ---| |--- 6.0 G --- SAS disk | | | | | |--- 3.0 G ---| |--- 6.0 G --- SAS disk |initiator | | | | device |--- 3.0 G ---| Expander |--- 6.0 G --- SAS disk | | | | | |--- 3.0 G ---| |--- 6.0 G --- SATA disk -->failed to connect | | | | | | | |--- 6.0 G --- SATA disk -->failed to connect | | | | +----------+ +----------+ According to Serial Attached SCSI - 1.1 (SAS-1.1): If an expander PHY attached to a SATA PHY is using a physical link rate greater than the maximum connection rate supported by the pathway from an STP initiator port, a management application client should use the SMP PHY CONTROL function (see 10.4.3.10) to set the PROGRAMMED MAXIMUM PHYSICAL LINK RATE field of the expander PHY to the maximum connection rate supported by the pathway from that STP initiator port. Currently libsas does not support checking if this condition occurs, nor rectifying when it does. Such a condition is not at all common, however it has been seen on some pre-silicon environments where the initiator PHY only supports a 1.5 Gbit maximum linkrate, mated with 12G expander PHYs and 3/6G SATA phy. This patch adds support for checking and rectifying this condition during initial device discovery only. We do support checking min pathway connection rate during revalidation phase, when new devices can be detected in the topology. However we do not support in the case of the the user reprogramming PHY linkrates, such that min pathway condition is not met/maintained. A note on root port PHY rates: The libsas root port PHY rates calculation is broken. Libsas sets the rates (min, max, and current linkrate) of a root port to the same linkrate of the first PHY member of that same port. In doing so, it assumes that all other PHYs which subsequently join the port to have the same negotiated linkrate, when they could actually be different. In practice this doesn't happen, as initiator and expander PHYs are normally initialised with consistent min/max linkrates. This has not caused an issue so far, so leave alone for now. Tested-by: Jian Luo Signed-off-by: John Garry --- drivers/scsi/libsas/sas_expander.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) -- 1.9.1 diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index 8817b8e..83e3715 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c @@ -824,6 +824,26 @@ static struct domain_device *sas_ex_discover_end_dev( #ifdef CONFIG_SCSI_SAS_ATA if ((phy->attached_tproto & SAS_PROTOCOL_STP) || phy->attached_sata_dev) { + if (child->linkrate > parent->min_linkrate) { + struct sas_phy_linkrates rates = { + .maximum_linkrate = parent->min_linkrate, + .minimum_linkrate = parent->min_linkrate, + }; + int ret; + + pr_notice("ex %016llx phy%02d SATA device linkrate > min pathway connection rate, attempting to lower device linkrate\n", + SAS_ADDR(child->sas_addr), phy_id); + ret = sas_smp_phy_control(parent, phy_id, + PHY_FUNC_LINK_RESET, &rates); + if (ret) { + pr_err("ex %016llx phy%02d SATA device could not set linkrate (%d)\n", + SAS_ADDR(child->sas_addr), phy_id, ret); + goto out_free; + } + pr_notice("ex %016llx phy%02d SATA device set linkrate successfully\n", + SAS_ADDR(child->sas_addr), phy_id); + child->linkrate = child->min_linkrate; + } res = sas_get_ata_info(child, phy); if (res) goto out_free;