From patchwork Fri Apr 12 08:57:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 162096 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp364693jan; Fri, 12 Apr 2019 01:58:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyatsuanMiQUm/Yir+n+Zpek9FKE6A036WPj+LolNJhUMEbn/vQdRwoyw38nXfXQamd9Fzu X-Received: by 2002:a63:d713:: with SMTP id d19mr7737296pgg.145.1555059509774; Fri, 12 Apr 2019 01:58:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555059509; cv=none; d=google.com; s=arc-20160816; b=R0sao6BIJbMVYMJZ8ojFuMPNxvsy3fGploNVos71i4cBEPAf9ubvGN29z1jnCepHFJ Un6MIhfkFPy+bixfuOHojOkWKeykZDGBAr9jPHbisOhnBeZ6gDipo/OsZJfNA5oovEBQ gqBI/Bp6vALllmcQgMYmzd43D3aUKoJVIS3Km+DSHBfugFKeTDg8kLa1yB4yi0qvb1Cl 1ExvQXjGQYFbu5IwYH4pSLDw6DEYIXHouybaSqKnhLWSw2HrBIsT986JdmagIn/5Kua6 v92FZz6Sft8h5FO/T+RT9u2FPqJg1MkhMxFJqiGwGJ3miRXHY1dFV7JqRro4twcguYri W8eA== 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=2r70ILTNHMZfSrYuadec8IKhbET2cfPsrvP45I58g/s=; b=SsWiCVX9fIJg4kjFLFlq84hnoKF4qImZ4w94UA+tuMUaViPbiBuImWTg780Zyay8Kc v0tCH6jTcJbq9u+/g3g+aCmSK6OdXGfg1MhgcdLbN6qcCbs9f4Kdf/RlQqT7RI6S2n9i l8NQ/J8BCEGzqU4/Pg9oWdEEnRtPVSnEqqpBQy+xS1XZ5AXprUX9t5rnw706/vN9Ivmt VTIcRx6LtbsQeFKxUczuPuKXhQylR43+gv09yon/PUYl8FXYQ7RA4yXUUCU0IYslHwsw 1fhu5FCKvR0GZ5TcJNHDHX3i0NJV/cqOWTmQuFhFzPrcuHbpsjECB4b/k4yBwdszkY9h 6cog== ARC-Authentication-Results: i=1; mx.google.com; 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 gn11si36505252plb.205.2019.04.12.01.58.29; Fri, 12 Apr 2019 01:58:29 -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; 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 S1727361AbfDLI62 (ORCPT + 31 others); Fri, 12 Apr 2019 04:58:28 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:6732 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726731AbfDLI61 (ORCPT ); Fri, 12 Apr 2019 04:58:27 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id AFEB922D21713472FF63; Fri, 12 Apr 2019 16:58:24 +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; Fri, 12 Apr 2019 16:58:16 +0800 From: John Garry To: , CC: , , , , , , John Garry Subject: [PATCH 5/6] scsi: libsas: Do discovery on empty PHY to update PHY info Date: Fri, 12 Apr 2019 16:57:56 +0800 Message-ID: <1555059478-36224-6-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1555059478-36224-1-git-send-email-john.garry@huawei.com> References: <1555059478-36224-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When we discover the PHY is empty in sas_rediscover_dev(), the PHY information (like negotiated linkrate) is not updated. As such, for a user examining sysfs for that PHY, they would see incorrect values: root@(none)$ cd /sys/class/sas_phy/phy-0:0:20 root@(none)$ more negotiated_linkrate 3.0 Gbit root@(none)$ echo 0 > enable root@(none)$ more negotiated_linkrate 3.0 Gbit So fix this, simply discover the PHY again, even though we know it's empty; in the above example, this gives us: root@(none)$ more negotiated_linkrate Phy disabled We must do this after unregistering the device associated with the PHY (in sas_unregister_devs_sas_addr()). Signed-off-by: John Garry --- drivers/scsi/libsas/sas_expander.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.17.1 diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index 6f569a65d791..ad96bc843acc 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c @@ -2068,6 +2068,11 @@ static int sas_rediscover_dev(struct domain_device *dev, int phy_id, if ((SAS_ADDR(sas_addr) == 0) || (res == -ECOMM)) { phy->phy_state = PHY_EMPTY; sas_unregister_devs_sas_addr(dev, phy_id, last); + /* + * Even though the PHY is empty, for convenience we discover + * the PHY to update the PHY info, like negotiated linkrate. + */ + sas_ex_phy_discover(dev, phy_id); return res; } else if (SAS_ADDR(sas_addr) == SAS_ADDR(phy->attached_sas_addr) && dev_type_flutter(type, phy->attached_dev_type)) {