Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5595916img; Wed, 27 Mar 2019 11:21:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxkEZbAYT7+dzlke7F7wNDFGL29jVxj0aq1stDLgL7ykQbCfc1UG1j66e/+nDsfYsUMo7c X-Received: by 2002:a65:414a:: with SMTP id x10mr21583140pgp.237.1553710910674; Wed, 27 Mar 2019 11:21:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553710910; cv=none; d=google.com; s=arc-20160816; b=yoz4kiK6ra8SNxx7dCsJWrJLull5/U9v8m3fIn5N3Ta8970puOK16CzH6HUaChMsOV 1GApqwa5Icb1fwhxaGKtQSlL5U66x0K4tZjIW9iPn1z3+eiDh1C037Z6GC+5qyvI8rDV 51M73j2d5MiBrIOwKdcUHT7IXEgoPTYWjnyIt2TcAHnTVxHoRsRD86YhOlPFKzaslwS+ hf+K9e9Auxq660UbXG4gwSv+Zdwdp59pFayEO+nO2Dtjk9lw6Y2trcC6hlo8C7lJPdI/ 7PxVeUgXRRwKcQ+/HVhjUMB7ZkHVaAPhNcgAVkLqeRGtJ60FEUPWLJ7F1G70gw4atNZ9 pIZQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iARmybzdCMr6gOIoxfP6Szky89ETt7uwYg8iIwodw1A=; b=ir89X0poNucqTXuwv6/QgrFHOcAbkdOFLYOT+DgAuqrrX191n+waAekvI6vpNQ7WWD mBeV5MJ+dwwVlkbF/joFmmywqk9zEfZkf6CjOfeZlbyWTu6+061iO5hFt2fq6Dm9JJ9Y Xv7wJTArdDOmf04DPwOxJtVEcDxxTUt7Oq3WM0gnGqdQFOpiaL1t6kmf1zmMWUjLV3q9 ZMs47LKzzpa5nf/evY7T7GhaU8BhLkfxM/EhthTcPPnih+j8pZ96R0nNZEYbUCFsGfVh VYjlQs1kQpXFeWRjHCXaRcLYgOWDHwPoyJYIwBmrIgihkZ4er+yNbx2BSP95qwUnFz+Z +Cbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WoqRzRA0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v21si18707103pff.44.2019.03.27.11.21.35; Wed, 27 Mar 2019 11:21:50 -0700 (PDT) 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=WoqRzRA0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391040AbfC0SVD (ORCPT + 99 others); Wed, 27 Mar 2019 14:21:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:38652 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391055AbfC0SU4 (ORCPT ); Wed, 27 Mar 2019 14:20:56 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 089412177E; Wed, 27 Mar 2019 18:20:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710855; bh=MKWLuuAZsmOExOOCjpwUIYglaDYe4yMjxfDfPuAvdDI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WoqRzRA0l/VXD85M6nsiZdpIIXzW9Y+x60H5s/fif+C2LwAeDhMkSaRZ/1YiAz4Gf iZwfpfRKqf01Qn2LsoSaJyxOlsHiLY6YYav1s7GkpTmWyWkeeQV0cLQSSPyGlxuF2R cLWbbyFnmNkItS4POfZCnrivQWP8b8p3EQi5CKY0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: John Garry , "Martin K . Petersen" , Sasha Levin , linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 09/87] scsi: hisi_sas: Set PHY linkrate when disconnected Date: Wed, 27 Mar 2019 14:19:22 -0400 Message-Id: <20190327182040.17444-9-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327182040.17444-1-sashal@kernel.org> References: <20190327182040.17444-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: John Garry [ Upstream commit efdcad62e7b8a02fcccc5ccca57806dce1482ac8 ] When the PHY comes down, we currently do not set the negotiated linkrate: root@(none)$ pwd /sys/class/sas_phy/phy-0:0 root@(none)$ more enable 1 root@(none)$ more negotiated_linkrate 12.0 Gbit root@(none)$ echo 0 > enable root@(none)$ more negotiated_linkrate 12.0 Gbit root@(none)$ This patch fixes the driver code to set it properly when the PHY comes down. If the PHY had been enabled, then set unknown; otherwise, flag as disabled. The logical place to set the negotiated linkrate for this scenario is PHY down routine, which is called from the PHY down ISR. However, it is not possible to know if the PHY comes down due to PHY disable or loss of link, as sas_phy.enabled member is not set until after the transport disable routine is complete, which races with the PHY down ISR. As an imperfect solution, use sas_phy_data.enable as the flag to know if the PHY is down due to disable. It's imperfect, as sas_phy_data is internal to libsas. I can't see another way without adding a new field to hisi_sas_phy and managing it, or changing SCSI SAS transport. Signed-off-by: John Garry Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/hisi_sas/hisi_sas_main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 2f872f784e10..5252dd5d3f4b 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -10,6 +10,7 @@ */ #include "hisi_sas.h" +#include "../libsas/sas_internal.h" #define DRV_NAME "hisi_sas" #define DEV_IS_GONE(dev) \ @@ -1128,9 +1129,18 @@ static void hisi_sas_port_deformed(struct asd_sas_phy *sas_phy) static void hisi_sas_phy_disconnected(struct hisi_sas_phy *phy) { + struct asd_sas_phy *sas_phy = &phy->sas_phy; + struct sas_phy *sphy = sas_phy->phy; + struct sas_phy_data *d = sphy->hostdata; + phy->phy_attached = 0; phy->phy_type = 0; phy->port = NULL; + + if (d->enable) + sphy->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN; + else + sphy->negotiated_linkrate = SAS_PHY_DISABLED; } void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy) -- 2.19.1