Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp614232pxb; Tue, 15 Feb 2022 23:51:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJwqKujhsYvfpLfUIrHZzI7Y8oVgueNYps0dcPY16WYHNoXHZmU4dxLnxqJwJQKecpQB8x4i X-Received: by 2002:a17:902:f68a:b0:14f:308f:ed3b with SMTP id l10-20020a170902f68a00b0014f308fed3bmr1319503plg.147.1644997874293; Tue, 15 Feb 2022 23:51:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644997874; cv=none; d=google.com; s=arc-20160816; b=arPlY67h3k6fc/XUYU32wxXb6BJO6ldcLUlLCP4UwC8VXWen7KXHTDt/js1zH0lN7g 1MwTyBPvTMDwzrRoVZ0tfJrmUm4JM+Qzm0sf4h3lsI7uKYJgvwNJmLP7YiwEDdv9yS5O rYE0E888HJ5oOtn94h3K5v5UVtdutRJdhsdsSQfURj8EceKtXKEgA6zmfPUmhRhGLdA+ hSAgE7cyo2ywUjiH6+ejvQheYP22R45mg1bsjdnayTmA/uJqwqbOUtmiSJB3XWfsruhO EQkZVDdzOxPLAKsRZ1d8Z9CN5BupNiyOYlg+kVW82rYPq8kgd79eP9IEDilzDw1vJuZe ckkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=5gd9oh1l4jLW1LAWSzNbrRmymlxQuefbpPF7ud07hEs=; b=tiXcLJLkbMt5p21DfzoFfDANRF0RDHdbzgaADS4WQey7xbFAT/fEw3rfGmRhp1ZrTl 6CAJNGY0XFINI8wVy46BUVGKSfp/ZLEZAW0KqgZPdbopE9NU7pIeyu57WczwoJ2ulghf gD5ZlaH25J7/Fz1RyeUNzhpdaOo7HRNTQvx6rXJC4xKi7/XLc2gN2wtNPUidH0aJd+yj 7PyvXvKLJWcNdmzh2EU8nWL2pv42fRICneg3WGs9kHcjCeXedVm6UWGuTiZPEwN+zYZT YG7O8yd3EyN/ilab3UlMmEpLiY8/x8H2OWrcJDdoJikEEDoyr5niGKa/zZR03bAJRZ1t K/fw== 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:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id r198si5053027pgr.559.2022.02.15.23.51.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 23:51:14 -0800 (PST) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 26C03D04AD; Tue, 15 Feb 2022 23:18:15 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229879AbiBPHSF (ORCPT + 99 others); Wed, 16 Feb 2022 02:18:05 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:37544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229806AbiBPHR7 (ORCPT ); Wed, 16 Feb 2022 02:17:59 -0500 Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A99FDC8FA4; Tue, 15 Feb 2022 23:17:46 -0800 (PST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id EEDB41A1A5B; Wed, 16 Feb 2022 07:52:56 +0100 (CET) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id B6C5A1A1A59; Wed, 16 Feb 2022 07:52:56 +0100 (CET) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 763DF183F0C0; Wed, 16 Feb 2022 14:52:55 +0800 (+08) From: Richard Zhu To: l.stach@pengutronix.de, bhelgaas@google.com, broonie@kernel.org, lorenzo.pieralisi@arm.com, jingoohan1@gmail.com, festevam@gmail.com, francesco.dolcini@toradex.com Cc: hongxing.zhu@nxp.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de, linux-imx@nxp.com Subject: [PATCH v7 6/8] PCI: dwc: Add dw_pcie_host_ops.host_exit() callback Date: Wed, 16 Feb 2022 14:21:01 +0800 Message-Id: <1644992463-14467-7-git-send-email-hongxing.zhu@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1644992463-14467-1-git-send-email-hongxing.zhu@nxp.com> References: <1644992463-14467-1-git-send-email-hongxing.zhu@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, 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 When link is never came up in the link training after host_init. The clocks and power supplies usage counter balance should be handled properly on some DWC platforms (for example, i.MX PCIe). Add a new host_exit() callback into dw_pcie_host_ops, then it could be invoked to handle the unbalance issue in the error handling after host_init() function when link is down. Signed-off-by: Richard Zhu --- drivers/pci/controller/dwc/pcie-designware-host.c | 5 ++++- drivers/pci/controller/dwc/pcie-designware.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index f4755f3a03be..461863bde3c9 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -405,7 +405,7 @@ int dw_pcie_host_init(struct pcie_port *pp) if (!dw_pcie_link_up(pci) && pci->ops && pci->ops->start_link) { ret = pci->ops->start_link(pci); if (ret) - goto err_free_msi; + goto err_host_init; } /* Ignore errors, the link may come up later */ @@ -417,6 +417,9 @@ int dw_pcie_host_init(struct pcie_port *pp) if (!ret) return 0; +err_host_init: + if (pp->ops->host_exit) + pp->ops->host_exit(pp); err_free_msi: if (pp->has_msi_ctrl) dw_pcie_free_msi(pp); diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index 7d6e9b7576be..1153687ea9a6 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -174,6 +174,7 @@ enum dw_pcie_device_mode { struct dw_pcie_host_ops { int (*host_init)(struct pcie_port *pp); + void (*host_exit)(struct pcie_port *pp); int (*msi_host_init)(struct pcie_port *pp); }; -- 2.25.1