Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5626293imu; Wed, 30 Jan 2019 00:26:15 -0800 (PST) X-Google-Smtp-Source: ALg8bN4taYprCGptIZtwfMwN7G2uzjHhljtBNb/tiAWxagc/miaJw8C6Srsl+aV14HmG2mC0K3qi X-Received: by 2002:a63:6a05:: with SMTP id f5mr26352584pgc.72.1548836775608; Wed, 30 Jan 2019 00:26:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548836775; cv=none; d=google.com; s=arc-20160816; b=MvYvcXMAp9dn7F1PPhMr8dpiyCiqf/0p9onQZ9IO84V4raYl9memYpkzSQESCAHa+p ykhgaK/LL1Ri+C1J62KexbTW3DHbZXAxnsv89Mdtm52G/k1QUTvS8S/3BY4XMb0T5FNN MSnSt+Ldrxkthc7XausY004myNBrKKe/OTdq9alCFtb3G/C8VUAe/5rMalK2neq/dVM4 hF2ZslZb9EUPnnLj0zeh9EztTW3hE9cfyizdIrwL1yyG1qlpokIc7zNwKiF57Hdrhs1V dkiIooGeJu3xuRCQ4YCXMvuDQklz8ASslbCJzJGB0TtuLaJsNZ1oKNh8wtHCFKGY+cXP BksQ== 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=uueRinBCiSZr7vl2DUW252Uv9KV9qLvs/m/wp0MltR0=; b=TFu2RIvduTED3tSpppkUkAKmu8GiDDmcLYrqUw7wv1HDulcfrF8nHcB1/wFNM4RkOw FzveakkdF03dDnjs3lrfWGUV1sImKBsziKXJJ16aB/4NhmSEPq7VF4CRukvmdnj1hoRF 5ofJULObKs3i1xfKEr3mHSFUtwjLb31JWBAQ/y5t2mqvE8BX8Zx4S3dlFxvf/GwgYbJ+ PRJGjzctp7qmVZg8QGSjQ+a+ki3bhuR+9RRbSTI3NZkVdYeZEoA18je+sEMmqhwp2iYv RWHbXf80Fdb3AECE1juFMHTKpi4V1FM5IoIyxRUh3pT8bLO8SecJ0rsoOBi1zIqcTeTh TWtg== 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 c30si763124pgn.52.2019.01.30.00.25.59; Wed, 30 Jan 2019 00:26:15 -0800 (PST) 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 S1730226AbfA3IZy (ORCPT + 99 others); Wed, 30 Jan 2019 03:25:54 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:2699 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725834AbfA3IZy (ORCPT ); Wed, 30 Jan 2019 03:25:54 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id C3DC751258FFD29DE41B; Wed, 30 Jan 2019 16:25:51 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.408.0; Wed, 30 Jan 2019 16:25:45 +0800 From: Jason Yan To: , CC: , , , , , , , , , , , , , Jason Yan , Ewan Milne , Tomas Henzl Subject: [PATCH v2 1/7] scsi: libsas: reset the negotiated_linkrate when phy is down Date: Wed, 30 Jan 2019 16:24:06 +0800 Message-ID: <20190130082412.9357-2-yanaijie@huawei.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20190130082412.9357-1-yanaijie@huawei.com> References: <20190130082412.9357-1-yanaijie@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.124.28] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the device is unplugged or disconnected, the negotiated_linkrate still can be seen from the userspace by sysfs. This makes people confused and leaks information of the device last used. So let's reset the negotiated_linkrate after the phy is down. Signed-off-by: Jason Yan CC: John Garry CC: Johannes Thumshirn CC: Ewan Milne CC: Christoph Hellwig CC: Tomas Henzl CC: Dan Williams CC: Hannes Reinecke --- drivers/scsi/libsas/sas_expander.c | 2 ++ include/scsi/libsas.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index 17eb4185f29d..7b0e6dcef6e6 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c @@ -1904,6 +1904,8 @@ static void sas_unregister_devs_sas_addr(struct domain_device *parent, &parent->port->sas_port_del_list); phy->port = NULL; } + if (phy->phy) + phy->phy->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN; } static int sas_discover_bfs_by_root_level(struct domain_device *root, diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index 3de3b10da19a..420156cea3ee 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -448,6 +448,9 @@ static inline void sas_phy_disconnected(struct asd_sas_phy *phy) { phy->oob_mode = OOB_NOT_CONNECTED; phy->linkrate = SAS_LINK_RATE_UNKNOWN; + + if (phy->phy) + phy->phy->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN; } static inline unsigned int to_sas_gpio_od(int device, int bit) -- 2.14.4