From patchwork Thu Feb 28 14:51:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 159378 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp731239jad; Thu, 28 Feb 2019 06:51:30 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia8tOOXLTOc8Gh8tpimxbYAUdsRrR/UMGLGjVOrwzKcC+8VczZTnbEmQjbVMYbJQrMRGsfF X-Received: by 2002:a63:fb16:: with SMTP id o22mr8617835pgh.209.1551365489967; Thu, 28 Feb 2019 06:51:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551365489; cv=none; d=google.com; s=arc-20160816; b=cAz8d1X5vFmrG1ilHLD2rAdyEPyJLH9GMgeUJiK8tEfBWAWplad0neyRYnDHpPXoSi D8QnpvFiaguNDChr92UQI8ZlWv8/nG1250mwRUV/qyYm36K4YzTxYSqdenOxFxXxpMYA pb/abY6o6V+wQaAFe7FTnmznrBc2XgMIJ6HkIQx1UGTcIC+cfWVkG61SYCy/GPkocPAK 4HaDuRGQnqx+v0GE87/BfHzxCBcbdPhffihs/3Qfab8CoJ+ZMgwOothJEMYd8o8PdKS6 KlprJ3D/wgNRR/MT0JtiBiEe5mQtmlYOLPBXBXJ3j4dNPdkmbSF4+Yygr9eelMa4+od/ tLHw== 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=g0tDfbeaJum1zDGu6d/0WING+fZP8XefnuAQTo6tshU=; b=vPEZN7zVOFKKphsDEVSKtzbJHx+w+Y31IvTv6KFIPyhs2XnH+sobcKi2AkK3zCChJ3 GtyIDsKdXe/SQ51UN/TjSzPp/TvSVoo4zVLQ9PtOCypRZlMxjYWkUCV2HCvgA5yG4TTg QWiPJFNHhLG+omrhNw5EmDkvpEIHCKHAXXLrQYtbro3wJ7NODV4kXW8MYEPDXMCBNDtj iJvve6lNXIG4G2w2LdPWzgOO+wgbRizc+PVKCWJU/jNL6TsRxHct1vczPQqQBMFyhTnf UAwHKWfyZEsLGeOrBHlEWVqxuIinYbpkOL7T73ClvayrI/Vdl+6BIMavvN7F8HDlL8Gq n/Hw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-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 v37si15667632plg.274.2019.02.28.06.51.29; Thu, 28 Feb 2019 06:51:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-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-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732592AbfB1Ov3 (ORCPT + 1 other); Thu, 28 Feb 2019 09:51:29 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:46372 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727779AbfB1Ov3 (ORCPT ); Thu, 28 Feb 2019 09:51:29 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id A8DD0B02891370821443; Thu, 28 Feb 2019 22:51:25 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.408.0; Thu, 28 Feb 2019 22:51:20 +0800 From: John Garry To: , CC: , , , John Garry Subject: [PATCH 4/6] scsi: hisi_sas: Set PHY linkrate when disconnected Date: Thu, 28 Feb 2019 22:51:00 +0800 Message-ID: <1551365462-128193-5-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1551365462-128193-1-git-send-email-john.garry@huawei.com> References: <1551365462-128193-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-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 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 --- drivers/scsi/hisi_sas/hisi_sas_main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index dd03dcbd3786..d8204bc3931b 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) \ @@ -2126,9 +2127,18 @@ static int hisi_sas_write_gpio(struct sas_ha_struct *sha, u8 reg_type, 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)