Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp989721yba; Thu, 4 Apr 2019 01:53:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyouV+IamoghXfynUuDuVLhBpQtZumIHWZ8cjncKS4n0snYsnvMyunJPq2xTfXSwKk23ZHV X-Received: by 2002:a65:448b:: with SMTP id l11mr4593663pgq.185.1554367995066; Thu, 04 Apr 2019 01:53:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554367995; cv=none; d=google.com; s=arc-20160816; b=qWZZFEvaUs5usyw6JDNd+6niJwH+FwUqJ+ZwyMLFYcr6qMnAj60+j5g+T4XEUmHN+D NeGx/aOPMq/RjtCGuPnXLGys1DbTTpnWnOUVGa5yMEk60n/OXEzWlaV9O3KlYvXfiU+y DEkIPKlMpKuu6OA5CuOvAb4NKNyeyaUdHWfETIwi6Gk7LVWPRq7OUlY2L+Dc81qAn+oL VgRT1YL7y6K04TkOTdYWkDW+ZoPp2vE48fgB+sRsosoKcXSmrh27KylYmJ9RlUBmifIL PCGMCV6ZgO51siJF7jpwwCQyDSq9RagcFzIH9cSBPb1PhML4OZhI58sum3WlX+QkEpen iVvQ== 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=mN5mbQ5/x+SFQ9c8+vUsas9NZdOohv366CwdFl488pE=; b=YO7DbDAlNlzGL4+8+3QwRuatJ2iHS6xuN3BytsIkvMn84QyuV+xUt0YL0904SxhU/H VTMzw49VGbhR5UKmXtVnKqK4+CwbhvLuAcxtlP6H08nqwdfkRZUgumn/guP0tnR+Zxb2 TfBV1go3RO8WavCLZxF4j0c7K8xMV/StfZq0gKj5KnNDdeUWfDOH6ZtvUTe0H7OpV2uY Jc569sNH/HH/mfTfX0Rv+A+93qQVvacFio74uQlnJdXk8bK7WNVrbDeBPRaIPBUeuyTu fdpdoGyEOxxtd5c4JiFjj/W207RQoNTPeqkgl0VA59C4pVXaEasXoZFA9bn3riSKITun v9dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=acMRCA1u; 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 82si15949915pft.35.2019.04.04.01.52.59; Thu, 04 Apr 2019 01:53:15 -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=acMRCA1u; 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 S1728686AbfDDIun (ORCPT + 99 others); Thu, 4 Apr 2019 04:50:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:51922 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729145AbfDDIuk (ORCPT ); Thu, 4 Apr 2019 04:50:40 -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 DACB12171F; Thu, 4 Apr 2019 08:50:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554367840; bh=E9p4zyyY7UDgq5UAc6nkrN4z4MmFMVlpxCh1bV4xtrw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=acMRCA1ut54sD9ZmIfPXB0gs6rDYLH56cf3Qhl9pAtF2phbnKV6/djpR3jwl5UXNC tQuXBdKVKwLt/TIotzyvkstXhqOKJ8u1iQm1TwbGLfkSrMNemolmoYLP9PBUhEq80t rK3Y7oPmGyaNBzHkP/lSe71/ChR1sC+E63sXo7Rk= 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 4.9 16/91] scsi: hisi_sas: Set PHY linkrate when disconnected Date: Thu, 4 Apr 2019 10:47:00 +0200 Message-Id: <20190404084536.367992215@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084535.450029272@linuxfoundation.org> References: <20190404084535.450029272@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 4.9-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 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