Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp929702iob; Wed, 4 May 2022 10:53:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRXrwPua5tqD095d+Sznvh+AwX5dYgLm6W/4NQW2Oc5ubIuN7n9g2NfAFfMs2xTSJGI3Vv X-Received: by 2002:a17:90a:730b:b0:1d9:7fc0:47c5 with SMTP id m11-20020a17090a730b00b001d97fc047c5mr760787pjk.60.1651686809823; Wed, 04 May 2022 10:53:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651686809; cv=none; d=google.com; s=arc-20160816; b=NL6gyPaLkYz4xXj3Qj4e+rr+DH7RRVUG+9yJDZ+cjrl2aLyuZKvKVI51WYQG0bTRSm Xoowdqyvn6FNWYVjbArzvfLLED6R5xDZs1vTM9SVubqv68QFySTmskozutp7kwxFC1zM uB4rxk3remiLdZ9Y48yOfqyIYIaRaGlqJNxkDm7STbUhVZtBNkUvi01iNvKYL5HAgy8+ V4fg6siWlVzBOTsPLTH+gefvHLPEkvCtb3cWTOIPtgbTsxQnORoPAEjMkVVrBgwiyHMP TnVo+DFTdna+i+zUpGn7hl4NjApZ3o5eXnepJGVAp6MSOLSHiW7sdx3q1t0DVzIqm74g 7LbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=7HFHf4H6BqchalrRsFSaOiF5MajsEXQSmhrKvpdLbKA=; b=eA+ZzxOz21WzMVFUqpM9bMkjaWBIsJbLTxoCYpQp3uTBkFa22HxLefJjEQzP0HkY4Y vj5HGildnpStrDbTHfAShDFsTBMrXtiCYa34H4avJHBbGawBM0RSsSP5OFHrE9fTStI7 b108YmWewfEP86xWUMm0i5GBXkPNDMLFOokmLk5/VxiZeeDk/M1k+bBKPzH8dYncZCqp o9Ir1gxtpW407A9+T/us7cpCiMstmjChZaNRUFM3ViuwCuz1VD380nPrHtpmem25qh4z fMPOODhbEq8iaT0yFc4f6+FUxdc4JNBIJCUyduQEp57asURwrScsykaqdQQaKsDGy0Py pv0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=mail header.b=LMiWvfyr; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t63-20020a638142000000b0039e2b6aacbdsi19083804pgd.475.2022.05.04.10.53.14; Wed, 04 May 2022 10:53:29 -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; dkim=pass header.i=@baikalelectronics.ru header.s=mail header.b=LMiWvfyr; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242831AbiECV1J (ORCPT + 99 others); Tue, 3 May 2022 17:27:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242779AbiECV1D (ORCPT ); Tue, 3 May 2022 17:27:03 -0400 Received: from mail.baikalelectronics.ru (mail.baikalelectronics.com [87.245.175.226]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 61F3A41627; Tue, 3 May 2022 14:23:27 -0700 (PDT) Received: from mail.baikalelectronics.ru (unknown [192.168.51.25]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 0929616D1; Wed, 4 May 2022 00:24:00 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.baikalelectronics.ru 0929616D1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baikalelectronics.ru; s=mail; t=1651613040; bh=7HFHf4H6BqchalrRsFSaOiF5MajsEXQSmhrKvpdLbKA=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=LMiWvfyrl3fc3bZAjEGczclR1fSYLQelohqyjK7ydhOVZcFM4Lh5qCByoR2BY251A JiJw+TTdx/Fe3k9gmAXK/rz2CIZGBWzMkqLh9aDgV+pmvm1Y3awUTW+jlXRKRGva1J QdE5dUzTkW7XwGa6s7cyjhxplKJVPTe4nYkuVET0= Received: from localhost (192.168.53.207) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 4 May 2022 00:23:26 +0300 From: Serge Semin To: Jingoo Han , Gustavo Pimentel , Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Frank Li , Manivannan Sadhasivam , , Subject: [PATCH v2 01/13] PCI: dwc: Stop link in the host init error and de-initialization Date: Wed, 4 May 2022 00:22:48 +0300 Message-ID: <20220503212300.30105-2-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20220503212300.30105-1-Sergey.Semin@baikalelectronics.ru> References: <20220503212300.30105-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 It's logically correct to undo everything what was done in case of an error is discovered or in the corresponding cleanup counterpart. Otherwise the host controller will be left in an undetermined state. Seeing the link is set up in the Host-initialization method it will be right to de-activate it there in the cleanup-on-error block and stop the link in the antagonistic routine - dw_pcie_host_deinit(). The link de-activation is a platform-specific thing and is supposed to be implemented in the framework of the dw_pcie_ops.stop_link() operation. Fixes: 886a9c134755 ("PCI: dwc: Move link handling into common code") Signed-off-by: Serge Semin Reviewed-by: Manivannan Sadhasivam --- .../pci/controller/dwc/pcie-designware-host.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index 2fa86f32d964..7403b1709726 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -420,8 +420,14 @@ int dw_pcie_host_init(struct pcie_port *pp) bridge->sysdata = pp; ret = pci_host_probe(bridge); - if (!ret) - return 0; + if (ret) + goto err_stop_link; + + return 0; + +err_stop_link: + if (pci->ops && pci->ops->stop_link) + pci->ops->stop_link(pci); err_free_msi: if (pp->has_msi_ctrl) @@ -432,8 +438,14 @@ EXPORT_SYMBOL_GPL(dw_pcie_host_init); void dw_pcie_host_deinit(struct pcie_port *pp) { + struct dw_pcie *pci = to_dw_pcie_from_pp(pp); + pci_stop_root_bus(pp->bridge->bus); pci_remove_root_bus(pp->bridge->bus); + + if (pci->ops && pci->ops->stop_link) + pci->ops->stop_link(pci); + if (pp->has_msi_ctrl) dw_pcie_free_msi(pp); } -- 2.35.1