Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp19242ybm; Mon, 20 May 2019 11:05:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZRY0dXXH1hynmmhI6UqLkfghUCTPK/w2UcFORJR9bC0fQ0mZDK1iOBjTZE69riP0xdWTP X-Received: by 2002:a62:5103:: with SMTP id f3mr83706585pfb.146.1558375558752; Mon, 20 May 2019 11:05:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558375558; cv=none; d=google.com; s=arc-20160816; b=Kb2Lj5MV7h1pJvimAk1NGRqt+9uDJ6Voqb//fPMgjihBJvAKXLkT7ApsHdSg0pyy9K zsRcyEDL4NAWZmtHF8uidHe3pcFqbdotQJui2cdY6oP1W9bbi1VIx75Pxe8Z4LfZDVe2 lxrdn2lST8BLtk5OPcvMU+zE4u5rHn/ytlYtdK04ayGgSPwOUosgL8OtxyEWt2b50iDb CW0NecpbdafSafANAPwMAW9F41UARNh0CQVe1pSNVE/Py7Z7ni6YHupWtoQwWzQlq3Bw /oMl/OYYljfcpkT2o+JRS9AbjYLyFdgUBQHEinAJVc88XdYTEgUlrEqyC2yWGwp2BlfJ 1LWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=TjXKIzHCnnt+4lcFZdxfcCFVKRFSuc/2IewHsrLBwl8=; b=TIBV3NXKzRf8EOYqyAIZWVLlVREwawR5dtatY1oE2F8iPYckXm2uLJJlzuTG/CJ0Xw L05brKWpsZoaNwSdTzzHJjFA7Vy22Pm10mUMoZEvIcHsXUX6r0P39OKuJXnPpmx0oOP2 2RXa2DWd/1n72gbVNYpwSETtkHSuizT2+D2SBj+b6Leu2Xat7PBZCs1htAj+SzlhsDAb PABNMfsuR6QzB9PAATgfA0jbSRtJGq0blxGlIJkwtjcIkO0somKb/hX8mxCJ3FFvb6KE TJY9iOBh8zrn7bmb6/9li8a0pvbQtYgT6JBZnSRO8To0sdRdQhgtLTFdcgeqvaaGhzi4 mS1g== 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 d66si20160443pfa.201.2019.05.20.11.05.43; Mon, 20 May 2019 11:05:58 -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 S2388687AbfETNsV (ORCPT + 99 others); Mon, 20 May 2019 09:48:21 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8224 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726169AbfETNsV (ORCPT ); Mon, 20 May 2019 09:48:21 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 9F584F835939B5E97F30; Mon, 20 May 2019 21:48:17 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.439.0; Mon, 20 May 2019 21:48:10 +0800 From: Jason Yan To: , CC: , , , , , , , , , , , Jason Yan Subject: [PATCH v2] scsi: libsas: no need to join wide port again in sas_ex_discover_dev() Date: Mon, 20 May 2019 22:06:00 +0800 Message-ID: <20190520140600.22861-1-yanaijie@huawei.com> X-Mailer: git-send-email 2.17.2 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 Since we are processing events synchronously now, the second call of sas_ex_join_wide_port() in sas_ex_discover_dev() is not needed. There will be no races with other works in disco workqueue. So remove the second sas_ex_join_wide_port(). I did not change the return value of 'res' to error when discover failed because we need to continue to discover other phys if one phy discover failed. So let's keep that logic as before and just add a debug log to detect the failure. And directly return if second fanout expander attatched to the parent expander because it has nothing to do after the phy is disabled. Signed-off-by: Jason Yan --- v2: Directly return in the "second fanout expander" case and change the log level to notice. drivers/scsi/libsas/sas_expander.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index 83f2fd70ce76..a148be23ca09 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c @@ -1104,7 +1104,7 @@ static int sas_ex_discover_dev(struct domain_device *dev, int phy_id) SAS_ADDR(dev->sas_addr), phy_id); sas_ex_disable_phy(dev, phy_id); - break; + return res; } else memcpy(dev->port->disc.fanout_sas_addr, ex_phy->attached_sas_addr, SAS_ADDR_SIZE); @@ -1116,27 +1116,9 @@ static int sas_ex_discover_dev(struct domain_device *dev, int phy_id) break; } - if (child) { - int i; - - for (i = 0; i < ex->num_phys; i++) { - if (ex->ex_phy[i].phy_state == PHY_VACANT || - ex->ex_phy[i].phy_state == PHY_NOT_PRESENT) - continue; - /* - * Due to races, the phy might not get added to the - * wide port, so we add the phy to the wide port here. - */ - if (SAS_ADDR(ex->ex_phy[i].attached_sas_addr) == - SAS_ADDR(child->sas_addr)) { - ex->ex_phy[i].phy_state= PHY_DEVICE_DISCOVERED; - if (sas_ex_join_wide_port(dev, i)) - pr_debug("Attaching ex phy%02d to wide port %016llx\n", - i, SAS_ADDR(ex->ex_phy[i].attached_sas_addr)); - } - } - } - + if (!child) + pr_notice("ex %016llx phy%02d failed to discover\n", + SAS_ADDR(dev->sas_addr), phy_id); return res; } -- 2.17.2