From patchwork Tue Oct 25 10:18:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10667 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp907913wru; Tue, 25 Oct 2022 02:52:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4cZbmZJENqd9JW4Ob/I1N5hFz0vrw6E10wAnIc6C8xdkCOKWKRTqt8iRiKc9+7jfySDwHH X-Received: by 2002:a63:5a41:0:b0:430:673e:1e13 with SMTP id k1-20020a635a41000000b00430673e1e13mr32604667pgm.435.1666691556313; Tue, 25 Oct 2022 02:52:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691556; cv=none; d=google.com; s=arc-20160816; b=MLM9nWlo1h4L/TLWoxu3EvaTAI0OKuTHMcZZxzK7LloX2TcDq8Q3jOerPh+L9YNme4 8M5vEEdHspMdjCPVaXpxomUysUknydLgTU3Fbs9dBk98ocQVcRRK7hKRggn5nMjBRY+A mVzNLq7kFAH/3koceP3zpfOwzdFVyPAGs0MbZIvUmZbGQyJ1dKpwiQg/ahuLkIiotE55 EECQnp44mugVAYaRmMmgLo98pH/8FS0a82Ptl8EWq6vnmFOoilH+S+bnYd2Z1ESbgPDX kCuePu0QFAz9vxBP4P0+9rjxInQ+W+ehcfA940kA+S4ZsrFWT20ka7TkMU4WQ9dGRtNQ 8yhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=5y7XN4x0t7BpaA//zSHoYzleoLUnpLPPlRp6n9PJsYQ=; b=gTHQExaT5hq7Bk9/mN40FFLf6hlA31Myr7A81RZ7tX0t6xXauPSlf1e/SlWu5ghOYx FaETdl0lgCUdZFsbqFYgkag2s18326mHTcRYFjjC3HfPtO6wgVfDEomtVEWc07oxR7Zn tmK0ba0Y+NUjYTaNQ5Zd4aLnhTVb0b6yaFGD+IwWn49QAWDOirdsJ9WOf5ADQ2GM3KWD HdsEz4N0AIbfeAsV+aLpKysyRZ9Ek2pjTOSq1EpOr4QuzCGGZfC/nK22aWpTZ5hprRHc 4JcHMeqzdad3kjJEFIe/fzQFX+xd76dEwK1iZFa4yBOGCQg/hTE3kQuP3V1if2+TX4RD AdUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mn17-20020a17090b189100b0020af2411705si2297145pjb.104.2022.10.25.02.52.20; Tue, 25 Oct 2022 02:52:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231743AbiJYJuZ (ORCPT + 99 others); Tue, 25 Oct 2022 05:50:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231523AbiJYJtU (ORCPT ); Tue, 25 Oct 2022 05:49:20 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8AC114D1CC; Tue, 25 Oct 2022 02:48:24 -0700 (PDT) Received: from frapeml500008.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRtF5LLwz67vyB; Tue, 25 Oct 2022 17:47:01 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by frapeml500008.china.huawei.com (7.182.85.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 25 Oct 2022 11:48:22 +0200 Received: from localhost.localdomain (10.69.192.58) by lhrpeml500003.china.huawei.com (7.191.162.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 25 Oct 2022 10:48:18 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 07/22] scsi: libsas: Notify LLDD expander found before calling sas_rphy_add() Date: Tue, 25 Oct 2022 18:18:01 +0800 Message-ID: <1666693096-180008-8-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1666693096-180008-1-git-send-email-john.garry@huawei.com> References: <1666693096-180008-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To lhrpeml500003.china.huawei.com (7.191.162.67) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747652765113006113?= X-GMAIL-MSGID: =?utf-8?q?1747652765113006113?= Ensure that we notify the LLDD of the expander being found before calling sas_rphy_add() as this function will require the LLDD be notified when we alloc a scsi device for an expander. Signed-off-by: John Garry --- drivers/scsi/libsas/sas_expander.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index 9e33014ec412..e7cb95683522 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c @@ -976,9 +976,12 @@ static struct domain_device *sas_ex_discover_expander( edev->level); sas_init_dev(child); + if (!sas_notify_lldd_dev_found(child)) + goto err_rphy_free; + sas_fill_in_rphy(child, rphy); if (!sas_rphy_add(rphy)) - goto err_rphy_free; + goto err_dev_gone; spin_lock_irq(&parent->port->dev_list_lock); list_add_tail(&child->dev_list_node, &parent->port->dev_list); @@ -995,6 +998,8 @@ static struct domain_device *sas_ex_discover_expander( list_del(&child->dev_list_node); spin_unlock_irq(&parent->port->dev_list_lock); sas_rphy_remove(rphy); +err_dev_gone: + sas_notify_lldd_dev_gone(child); err_rphy_free: sas_rphy_free(rphy); err_free_port: @@ -1575,32 +1580,22 @@ static int sas_discover_expander(struct domain_device *dev) { int res; - res = sas_notify_lldd_dev_found(dev); - if (res) - return res; - res = sas_ex_general(dev); if (res) - goto out_err; + return res; res = sas_ex_manuf_info(dev); if (res) - goto out_err; + return res; res = sas_expander_discover(dev); if (res) { pr_warn("expander %016llx discovery failed(0x%x)\n", SAS_ADDR(dev->sas_addr), res); - goto out_err; + return res; } sas_check_ex_subtractive_boundary(dev); - res = sas_check_parent_topology(dev); - if (res) - goto out_err; - return 0; -out_err: - sas_notify_lldd_dev_gone(dev); - return res; + return sas_check_parent_topology(dev); } static int sas_ex_level_discovery(struct asd_sas_port *port, const int level) @@ -1643,6 +1638,10 @@ int sas_discover_root_expander(struct domain_device *dev) int res; struct sas_expander_device *ex = rphy_to_expander_device(dev->rphy); + res = sas_notify_lldd_dev_found(dev); + if (res) + return res; + res = sas_rphy_add(dev->rphy); if (res) goto out_err; @@ -1659,6 +1658,7 @@ int sas_discover_root_expander(struct domain_device *dev) out_err2: sas_rphy_remove(dev->rphy); out_err: + sas_notify_lldd_dev_gone(dev); return res; }