Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp5631062pxb; Mon, 28 Mar 2022 15:13:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzASbQcS9aGbXE7ILQOUbFojOp7Q+73CuUanbSZEG6vhHw8uJmo4KwuF0sQXvnbjtG1L2g5 X-Received: by 2002:a05:6808:1386:b0:2d9:a01a:488a with SMTP id c6-20020a056808138600b002d9a01a488amr714787oiw.213.1648505604437; Mon, 28 Mar 2022 15:13:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648505604; cv=none; d=google.com; s=arc-20160816; b=WKovBOcte/LS10lVOaGS57W/SLvoKU/ZzyDaw39A9VCNkcwuGuKe8Q5aBUKuQm3qyf WS2x/8wr/viSq+MJz7mPe8HqZU04DYdz8vU8WHvvatUP1lZaUAQgY8H3PbYMcIpNXnof 8SDIMJlkhENL/okjNyjFlpfGlJYudQF44ZvGfgI02oxBQ08nnHkYu9NXCLOL+a+sTqHg EIicLN4TDVozPS/5baGLFkoDJrGPUNm7Re2k+zrCay4cSGFScNImMfisIZlxxMNccd02 TVzuNLyD9zELE14Zqzt/TlwOVaxVUqDWPz7WL0AtHEpELEbL2HfZB693zPYoYEVurUGk X30Q== 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=kfxQKEOlP4ohIS01o1tX7PouvvGd/yuJ1ukMhFjn3Qs=; b=hsgR4HB3Uhf6D2f5QZT7tFlbGTemdmhizZvm/wI3rD8A0KfBmCwfZHHE55CYPitUO9 Pna98zS/acWdblIIv/fbHUPVzkYm9F4oW2VFHmbEfa9oPbwJvpCyVbq8W4wUHQBQ4oc3 iHgE+J8lYmJll5+466K5xXfqQZ6/o3bpUOFvLvgTaMQX+lb4fo8voXoKdItYtbyuUkc9 q7Cq+C6nYhkkvoAIivtaCUT2Yu1FVkC8SfeqqaAvsAVZ4Z1FcLlTWRG18LQuQPGHLDYb WwNeeuGBE0nAXqrMDGQNY9FZII9lnaWLLUOMys9HwlxqnFZWyNWl2CsGP/0RtlhpAO89 a6mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=mail header.b=Hyo9TubO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j9-20020a9d7389000000b005cb2fc1385fsi11524503otk.219.2022.03.28.15.13.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 15:13:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=mail header.b=Hyo9TubO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CC3831700BB; Mon, 28 Mar 2022 14:32:57 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244318AbiC1PLR (ORCPT + 99 others); Mon, 28 Mar 2022 11:11:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244276AbiC1PKw (ORCPT ); Mon, 28 Mar 2022 11:10:52 -0400 Received: from mail.baikalelectronics.ru (mail.baikalelectronics.com [87.245.175.226]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2806B53A46; Mon, 28 Mar 2022 08:09:11 -0700 (PDT) Received: from mail.baikalelectronics.ru (unknown [192.168.51.25]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 240DE1E28FF; Thu, 24 Mar 2022 04:25:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.baikalelectronics.ru 240DE1E28FF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baikalelectronics.ru; s=mail; t=1648085128; bh=kfxQKEOlP4ohIS01o1tX7PouvvGd/yuJ1ukMhFjn3Qs=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=Hyo9TubO9jqw3+G+0DYfNyYe5dSrqKR9rJkj8Es47o1CslyJCLOpoU003UJIjkYal /5szf0zP6Za3YC6xG8Unv7GvUyUrQQzKkUhhqmZS9vDbFutFcjjWUeK9ODlCTUtSBW ybh7vQ37yG8axglT5Y/pnIJBiQwQKhCKe5kwHK2A= Received: from localhost (192.168.168.10) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 24 Mar 2022 04:25:27 +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 01/12] PCI: dwc: Stop link in the host init error and de-initialization Date: Thu, 24 Mar 2022 04:25:12 +0300 Message-ID: <20220324012524.16784-2-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20220324012524.16784-1-Sergey.Semin@baikalelectronics.ru> References: <20220324012524.16784-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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 --- .../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 f4755f3a03be..a03619a30c20 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -414,8 +414,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) @@ -426,8 +432,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