Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1020933yba; Thu, 4 Apr 2019 02:35:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxi9hE5FPZDe3wAqSMkXeX9bJShD1wSqEULjH67vLVl+UbsxeWMUFkGEtH13nfg6k3QaX+V X-Received: by 2002:a63:29c8:: with SMTP id p191mr4815180pgp.197.1554370559172; Thu, 04 Apr 2019 02:35:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554370559; cv=none; d=google.com; s=arc-20160816; b=TgQWgYuCESEQAUQFc6x6fPq5oJXsxyypvuUJNN6j9KxPcK7jVGulghYZX1oi3X0ebo PrBldMU3lN9qRywV7TU2OMuFP4w9yzcBvQKjBOwoa4LU68Op8RTICeBBTOTEfvPmBUJ3 9/a8/D/NvQNQMssJ1ibubzXCUGkHgSR/E35rQ8z/69Bmkfr/e/aBVwzHNF3rQO8LV8+s wRXgbztzfeh8jeVMkfjLsNCB+0Wxy+OTUhiM+IPvY53d4XR8BDTlblsyP3rhh07JeEdl D9QklSERCynQup6sMLhGI5qTcUiz2uZ4JEvkrhACsXj9//YWSGn7uE8vyCYsxEwA4sdJ Dy1A== 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=w8/JrVWEJWTULsR8GmmXJ3EUwSJu/utC5AAyPOgNFSM=; b=PoDiIqVG0+LgySwyS4D9ARvobpISw4ui5Eg+xp3DxN50cVFqyTk+urb4oE29k7AoI+ bHmBWq7YnTQ8rF4s4QPzt5FKzb6rKM8icwUqV0TVOfv66LC8YULen2aDJAjVWjTt7Oib xFJ5KpivsAAoI5RzytBNE8e7kja9zarHq1W12blikYlDxefGdGXuT4oEezV9Cb2i8UEE u/eVKBAJn7yuGuBpPIyX6FVGjN801GypGjiB48f8o+jsMO+Hj8tZ1At8w01mbv1+f5Tx 20z+EKUmaT81hRNJpNsr09nvfwC3NYWljPjBwsO60qXCtonpC7qdX55xV3yqSSlw1WEU K3xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YCCwmnL3; 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 cm17si17185826plb.139.2019.04.04.02.35.43; Thu, 04 Apr 2019 02:35:59 -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=YCCwmnL3; 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 S1732843AbfDDJdW (ORCPT + 99 others); Thu, 4 Apr 2019 05:33:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:47318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732429AbfDDJIQ (ORCPT ); Thu, 4 Apr 2019 05:08:16 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 2702C218FE; Thu, 4 Apr 2019 09:08:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368895; bh=iTkadlmVPSaaQcSS9pkXLvzqAvXkQ5rej7hrT4aCC6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YCCwmnL3S0n9rmlCH4FXGpmB/R4kg7B+R8SFXULefwfJsYZ5LUEtoMtJsyrwrdIcR QReh5EFMuNEd5oIrXoyNZwHByjUnEX4eqYwOOg/SNr9l6VlFA3R8ippu20pTzvEje5 qkPEcp8emCWPb17em9efBZxwxdBqpOyVJHYux1C0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John Garry , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.0 021/246] scsi: hisi_sas: Set PHY linkrate when disconnected Date: Thu, 4 Apr 2019 10:45:21 +0200 Message-Id: <20190404084619.888493629@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084619.236418459@linuxfoundation.org> References: <20190404084619.236418459@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 5.0-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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 bc17fa0d8375..88ae415e907a 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) \ @@ -1972,9 +1973,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) -- 2.19.1