From patchwork Wed Dec 4 17:56:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 180838 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp949192ile; Wed, 4 Dec 2019 10:16:12 -0800 (PST) X-Google-Smtp-Source: APXvYqzEJjEgNbBjPnKE6Z69Rhtk8jGufds4P3zEQrvIqC2cJRPSsZCJ5zhdA549z8qYF/f7GX/M X-Received: by 2002:a05:6830:591:: with SMTP id c17mr3307931oth.226.1575483372169; Wed, 04 Dec 2019 10:16:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575483372; cv=none; d=google.com; s=arc-20160816; b=eXDYGePDDAdLYdE1C4LCGjwiQw50Wm/hVkuz9ls1K0dsWBMO+Sb19rux77tPU1n/Lj T/sT/TQRbgQ1q7GzjSKaRbhkLv6oal3S25InPzlUugO3SGb+e0mSKGnXmCpQ6JsBdq9V lRYoQXtYzkKpkIxnnKFGWVlHkxesLvcI8BqZVoqwHFLxdPZIOsxyRs77yzFuJ12o1ecv sUVbFSCDFDJseH0a3zIKrRxnSRNgQZAjQASNvuJoOorYScXu7Gj5qYZP2h4TMnCpMpgx m1zem2hEv1DmayM32XQ6cGMx5fF8904FGbSJD5G+GA7RRwq9vX3o8PJm/Em9n2ep9Ktx e+4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pXhJFdyC9Q3iFGXUDnxWfDp1jyJaJavq5YFFXEsv+nA=; b=FfL38d1xZAeQyilv6jf3Nw1esyq8sX3wYoM47drJoJj616BEY4zpfRq2/mMbF1D4Wu XoIdDRxcLGaSh49omwRDivZxWypIRpAbLf7ozy42qHqxd4Z0yErNB+SuzfxjTovHt/nA kqwVG1jb1Ln2Cpw4ruXorB05rroYrG0sUwtcn9oZIBE0HD4w7U+I9jn9++rNABb8cLG7 Rvr7FOT7g5ve3jJVbHZuRLH50oNImgFsw+5Dkp0S8jovyhOFOCWolaChyQOypnEQpsWZ JASVUx4dKPuvWVbs9AtKKz+dc/muzesjb7J/Tfao7LSBH6EzRexEDDor/+5vJD5H8gq7 JZVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=D+p+UrNC; 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 c12si3785527otn.7.2019.12.04.10.16.10; Wed, 04 Dec 2019 10:16:12 -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; dkim=pass header.i=@kernel.org header.s=default header.b=D+p+UrNC; 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 S1731703AbfLDSQG (ORCPT + 27 others); Wed, 4 Dec 2019 13:16:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:42752 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731753AbfLDSNf (ORCPT ); Wed, 4 Dec 2019 13:13:35 -0500 Received: from localhost (unknown [217.68.49.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4509320674; Wed, 4 Dec 2019 18:13:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575483214; bh=Oq84LTVSVC75WPxhcTGPrRuAJow9CRZ9cyQfe033SG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D+p+UrNCTgWJ2QcBtvTFluOkX0Tq1Of/q6/VJ5pQJ6otrZ5MDfhTGAMlUUSMJAUlQ 4ZHloam7fyfffNvqJux8bTLQRoUwSyGsi7kZmoE5iGlVxz3l42VFXuvv0ydWdlKJ4a 9rb99W/QXpm6/pyuLetfF4bNQfHh1jLbglKt6vjA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jian Luo , John Garry , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.9 100/125] scsi: libsas: Support SATA PHY connection rate unmatch fixing during discovery Date: Wed, 4 Dec 2019 18:56:45 +0100 Message-Id: <20191204175325.182554385@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191204175308.377746305@linuxfoundation.org> References: <20191204175308.377746305@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: John Garry [ Upstream commit cec9771d2e954650095aa37a6a97722c8194e7d2 ] +----------+ +----------+ | | | | | |--- 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 Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/libsas/sas_expander.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) -- 2.20.1 diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index d44f18f773c0f..b7e4493d3dc16 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c @@ -806,6 +806,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;