Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2962020imm; Mon, 28 May 2018 21:02:47 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKr4zhADdyF67e6rFVx0GXL5YVPm6Tpq2DmdUWJvR5qGtAUyLPf/jzjQq68n8TRJKAIXv6B X-Received: by 2002:a17:902:d716:: with SMTP id w22-v6mr207163ply.98.1527566567723; Mon, 28 May 2018 21:02:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527566567; cv=none; d=google.com; s=arc-20160816; b=hK6tiyZgILOqSPl52y+ahXunk1ju31ZeLPIFJLU9fItSJm2vOgs1KeRN4L6805/K4Z 9uEZALYXMIqcLE2f0FExHGi75xMBvm40QJ4q+FLFYgUb/W5o3Dq5oWkBJeckxoFZeqXB /YG+AZa5Ajx2iteIH04D9rvdEJImDoAG96PeL8/h6M8nQAtk6TBEKFoPuDFT3nhlIaUC HEu6CUu8Oe80G/XksOwPNk9uPiMV/wnFsGknzuhSHMm1LqrUrJATd5M0x4WifHtp/CpB WjseJiQcDzgQEdo37aND9cHf3VeepL67TbCb7SmZ4KA7x4Kp8kWGh8fRy4GSSzrL5O0v D6Ew== 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:arc-authentication-results; bh=gPpUrX5vpm2Oh0ZBVtUFTc991IhlKo7OiXLpcObEIxw=; b=KvTQQbALJtz65mevrMdTRUqAQHTUE5HKBw0fVjb+nwkn70i2aT5AzmKpDuG1FePtm6 nA8RBWRDrmtZUvUHr8CE73+YsIVC9vDcsO3a20wyGMkI7Sz5rixybqLtOGZ5+wkdWGYx 31nOZU4C/OqtUrij0imAN65dOXOvj4dhND8rf1aBBpYtR3xplqCdq6pP3zWC/tgwH5D1 6CGradN6geOkXIBJH1h1FkB6opVdTjLF+xnomREc37O9m6Yl5Qc5RxWtcIVKzq5e/o8p vL6VGpwd6UckVInmp16JLcppxQ45zebE5hVmsODygF/mLE34vvmazzw+Cv9Q3SvCL3yh nAmA== 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 bi1-v6si2391684plb.126.2018.05.28.21.02.33; Mon, 28 May 2018 21:02:47 -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 S1756035AbeE2COV (ORCPT + 99 others); Mon, 28 May 2018 22:14:21 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:51314 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1756001AbeE2COQ (ORCPT ); Mon, 28 May 2018 22:14:16 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id A0BB4E8DF3360; Tue, 29 May 2018 10:14:12 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.382.0; Tue, 29 May 2018 10:14:03 +0800 From: Jason Yan To: , CC: , , , , , , , , , , , , , Jason Yan , Ewan Milne , Tomas Henzl Subject: [PATCH 4/8] scsi: libsas: trigger a new revalidation to discover the device Date: Tue, 29 May 2018 10:23:05 +0800 Message-ID: <20180529022309.21071-5-yanaijie@huawei.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180529022309.21071-1-yanaijie@huawei.com> References: <20180529022309.21071-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 Now if a new device replaced a old device, the sas address will change. We unregister the old device and discover the new device in one revalidation process. But after we deferred the sas_port_delete(), the sas port is not deleted when we registering the new port and device. This will make the sysfs complain of creating duplicate filename. Fix this by doing the replacement in two steps. The first revalidation only delete the old device and trigger a new revalidation. The second revalidation discover the new device. Signed-off-by: Jason Yan CC: chenxiang 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 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index 629c580d906b..25ad9ef54e6c 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c @@ -2013,6 +2013,8 @@ static int sas_rediscover_dev(struct domain_device *dev, int phy_id, bool last) { struct expander_device *ex = &dev->ex_dev; struct ex_phy *phy = &ex->ex_phy[phy_id]; + struct asd_sas_port *port = dev->port; + struct asd_sas_phy *sas_phy; enum sas_device_type type = SAS_PHY_UNUSED; u8 sas_addr[8]; int res; @@ -2060,7 +2062,14 @@ static int sas_rediscover_dev(struct domain_device *dev, int phy_id, bool last) SAS_ADDR(phy->attached_sas_addr)); sas_unregister_devs_sas_addr(dev, phy_id, last); - return sas_discover_new(dev, phy_id); + /* force the next revalidation find this phy and bring it up */ + phy->phy_change_count = -1; + ex->ex_change_count = -1; + sas_phy = container_of(port->phy_list.next, struct asd_sas_phy, + port_phy_el); + port->ha->notify_port_event(sas_phy, PORTE_BROADCAST_RCVD); + + return 0; } /** -- 2.13.6