Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1720972lqg; Mon, 4 Mar 2024 01:25:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXlr6Ys3i20kRyeGJ0+ngPfIZcsrUbGVT3ojROZOkrJU3cI2VLYJQcYHTIdgOpdPMngYLXnTy5yT8IT5FFPLKr6wbWCFJa3ldgInrwxOQ== X-Google-Smtp-Source: AGHT+IFm1+kSi2V+E60f0cjn6xe1Y4u/5hLFiGbqM5+NRZXhxgJlr7oTp9JhO1FD5k+lEDFLn3NJ X-Received: by 2002:a0c:f3cc:0:b0:68f:ecde:f13b with SMTP id f12-20020a0cf3cc000000b0068fecdef13bmr9682007qvm.62.1709544305384; Mon, 04 Mar 2024 01:25:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709544305; cv=pass; d=google.com; s=arc-20160816; b=clWH7bTRduBVp9x06/WDRW1ldCZ2NqSUm6O6L2UZF6dBFbU6/evlb1ZcZC1w5BDIFc +VAIwbHIBa3L4pbGK8Xzwetxl/ggUGC6XTlsUsDVseoU1txiXAPmfdmZd3RJBPV+7tMD oaf77yupUPtLr1d6MUOr00A2qfh5Ss0lgl+LeezqOZeWTwiqa9VwMig3l1TyrnVjO1mM CGHR0x9v1IqrP97H4he7oQxRgbAnHajTyHerHKYxYkD5/yprs2Wreal25D5+9ycFE2D8 gUrDry/rL9Fg/F4Ny8Jov8yGHmcDHVtEJgxHu5odobSUNrEq+1mL5h8nUddW2PvFTsLf 3jVQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=nT6lhmjvLXnA6i0OgikSdr/3C7tCoAH1ArKKxud/V4I=; fh=WGfgrTdssj4Q5RxwZXtGmxD9zRAb78RfvkX8mLKV0+k=; b=i/aeW0D1AbG4VS8JRtwHZo8pVBgYipnB4x2kvMCucC5AsSMskxw+jT5VdOt5sjWvTe Rrv4AqWycV3+b16tbveLP0BVLMsvIslCumj4iFMpVpLFEwTyJIsll+NPIf+acQnKOWiC mUR3vM26UXIFsVtSlsNznJJtvNRsga2AkJ38UvApgxcbrLdHQ7QAVpZsBUttnReVOWH1 ICpc5DwByWXLaIVbVL68tJm8TI5X69pOla9ClXwUZV46Fv+FQ9wxnJ43EsOG8niixMOx L09ORaGEaHkz/aGukjiy8rdOgI7W9UdafvQ0xKnvXPMtPvERCjTd8KZ2FQoX/SzABz3y Ob+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="qx/ZNE13"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-90309-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90309-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id jz10-20020a0562140e6a00b0068f5cbb3f36si9067449qvb.298.2024.03.04.01.25.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 01:25:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90309-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="qx/ZNE13"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-90309-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90309-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 15B9C1C22623 for ; Mon, 4 Mar 2024 09:25:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 28FF43613A; Mon, 4 Mar 2024 09:23:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="qx/ZNE13" Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E4BF8225A9 for ; Mon, 4 Mar 2024 09:23:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709544229; cv=none; b=mNrTPeC46Ouf2uvXIoyUMY3+Tk7AR7xizicCXUs0b9t5q99rRly0gbwv1K2CqTqAf+Eff3evpqbWCYncRFtcb+pQZIvimmzgQB703KRgfcJALAqjW8RnUpeCRr2GDjmCOmH55vmTCZorskr2hV1KqDPOb32SK0LvY0okOChMXMM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709544229; c=relaxed/simple; bh=YU6uuC25aD6HmjqNZdabeo9wTfVLw6zZvEjqCvQIMnE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PobLWnYf6yqb+JT0PyD4caVTP3M2V/HyP9AI1cLd72AgMosPd6SzkjWWsLHcZw1NPmli6k3L1VGWUigCt6Y87KM8/PW+QHZrc9BZD5BjxMryI0uO4dh/38rQ0XsTwElVJbCD/F7CcaEbowGW0V7i6iWlf5N562kn31/w21epk0c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=qx/ZNE13; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1dcd6a3da83so30670575ad.3 for ; Mon, 04 Mar 2024 01:23:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709544227; x=1710149027; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=nT6lhmjvLXnA6i0OgikSdr/3C7tCoAH1ArKKxud/V4I=; b=qx/ZNE13UEkDEU8RWiSgOQmEOyTsuLCEpFuO4YXc6ePNBuDD/5qIPWEE15o96Tm21V otFSCe+zquoQJHf1PLA+39RfnI41bQP/Cu9gBt3bwvnckjbJSvMwczQHIgyN9wdmNG+D euk4iDIFtiZxAggcjD59R6w5lSoqAW1ChxdbSdu9cTnQ95gNLt1P71qQ077tIYr8JqU+ vCa+euJwrpePx/UCxF8Vez3RjYRPmNMyig2HWzWEAbNz4gGAEEyA7ZarJE5EyauXpyIc 0XLtNpWej4AWzUKV4FWvbuZZ1/C1OUyIrm4FFC5BDfp1+dY7thJMqmdHmswC1uwONEzx 36qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709544227; x=1710149027; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nT6lhmjvLXnA6i0OgikSdr/3C7tCoAH1ArKKxud/V4I=; b=kwvqFmzgIn/ktKY8HxJMCCH5sQM1MUkTv8fO/85NtUex5o8hiozRXau7/quqBwo56K 0Qr6ucAAUErksC1zfY+jUhl1x9FS9g+lZlnHH6RsM203TtktO0vCLl9HFNjb6p1nsR3t ov9TN68PlbH4NTMiRd7GpZU4YtDcWKSEPQtZKEs45jHVXxfjyWM1qKWM1KVIDmfqYqra ZseAsQr9rTUFuQZHMRwlizyDbksphr/OQNrshj/h/rrFXtXplEyqdTL5hbO+SkSj98yy K2vNkKvGUlGr7VzULsmjy279tUp+IqtmbyXATlrp8b49ETyHjtYuTfwlGF2/Trtk4yIP 6sYQ== X-Forwarded-Encrypted: i=1; AJvYcCVhMrWy0WOMLVnhteVy7zqaKSbBOgtLLxZhCWbH3l00/dmNa1LKeqXfhRpcIGCSDIhTqlaJ2af8FVxI0i6TVIYtc5gi4Mw7Jqfa4fRW X-Gm-Message-State: AOJu0Yy+CUoTwwQZrt08F61WBqTJikABrJB7JUwwnFVdejhDI6QOmZFM T1rKXHYCZx5Ar7aSg85lfIXZ4CPBg7BBYwMjtZeXK8+ajELEBCAK+YWzvBVL9w== X-Received: by 2002:a17:902:64cf:b0:1dc:efb2:95fe with SMTP id y15-20020a17090264cf00b001dcefb295femr8420199pli.48.1709544227173; Mon, 04 Mar 2024 01:23:47 -0800 (PST) Received: from [127.0.1.1] ([117.202.187.165]) by smtp.gmail.com with ESMTPSA id c5-20020a170902c1c500b001dbb06b6138sm7996648plc.252.2024.03.04.01.23.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 01:23:46 -0800 (PST) From: Manivannan Sadhasivam Date: Mon, 04 Mar 2024 14:52:18 +0530 Subject: [PATCH v9 06/10] PCI: dwc: ep: Call dw_pcie_ep_init_registers() API directly from all glue drivers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240304-pci-dbi-rework-v9-6-29d433d99cda@linaro.org> References: <20240304-pci-dbi-rework-v9-0-29d433d99cda@linaro.org> In-Reply-To: <20240304-pci-dbi-rework-v9-0-29d433d99cda@linaro.org> To: Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Marek Vasut , Yoshihiro Shimoda , Thierry Reding , Jonathan Hunter , Kishon Vijay Abraham I , Vidya Sagar , Vignesh Raghavendra , Richard Zhu , Lucas Stach , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Minghuan Lian , Mingkai Hu , Roy Zang , Kunihiko Hayashi , Masami Hiramatsu , Kishon Vijay Abraham I , Jesper Nilsson , Srikanth Thokala Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, Niklas Cassel , linux-arm-kernel@axis.com, Manivannan Sadhasivam X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=10177; i=manivannan.sadhasivam@linaro.org; h=from:subject:message-id; bh=YU6uuC25aD6HmjqNZdabeo9wTfVLw6zZvEjqCvQIMnE=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBl5ZLYcIN2HtmxaUjM9mZ+eAEiEUUHetTxfGNBF qInukUvYL2JATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCZeWS2AAKCRBVnxHm/pHO 9R45B/4+vSlFur+3TnDh9W6PyQJuO4RhVfMvG37PfQ2rthtfMX8QDM2v9G6eKpzgoZwpnw8oxpu v2NDu0oalF9ro0U+tNK87E4rgKxwcJULYSuRbMT6+iYK2YfcdB7EndVkB3tXhmRPUSP2iFV7MWN yvnMfKMhMxU0zrS/zvxc+h7JbrrKhK/utJ3Q/sEGwjnWstufpuQ/T+8zbvJaB9jBDh7Wqta8iTg haMgVoC8mZJfuDzRdwC3VZZt+AO051NNOi/miX3pDSQZ8EUPI3lHz0o1cLjRhTi8FM1KzFtjY0V mlZlJbrlsW1heORRWJXseycsufD/K3pRjM48y3ts6HVAd07R X-Developer-Key: i=manivannan.sadhasivam@linaro.org; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 Currently, dw_pcie_ep_init_registers() API is directly called by the glue drivers requiring active refclk from host. But for the other drivers, it is getting called implicitly by dw_pcie_ep_init(). This is due to the fact that this API initializes DWC EP specific registers and that requires an active refclk (either from host or generated locally by endpoint itsef). But, this causes a discrepancy among the glue drivers. So to avoid this confusion, let's call this API directly from all glue drivers irrespective of refclk dependency. Only difference here is that the drivers requiring refclk from host will call this API only after the refclk is received and other drivers without refclk dependency will call this API right after dw_pcie_ep_init(). With this change, the check for 'core_init_notifier' flag can now be dropped from dw_pcie_ep_init() API. This will also allow us to remove the 'core_init_notifier' flag completely in the later commits. Signed-off-by: Manivannan Sadhasivam --- drivers/pci/controller/dwc/pci-dra7xx.c | 7 +++++++ drivers/pci/controller/dwc/pci-imx6.c | 8 ++++++++ drivers/pci/controller/dwc/pci-keystone.c | 9 +++++++++ drivers/pci/controller/dwc/pci-layerscape-ep.c | 7 +++++++ drivers/pci/controller/dwc/pcie-artpec6.c | 13 ++++++++++++- drivers/pci/controller/dwc/pcie-designware-ep.c | 22 ---------------------- drivers/pci/controller/dwc/pcie-designware-plat.c | 9 +++++++++ drivers/pci/controller/dwc/pcie-keembay.c | 16 +++++++++++++++- drivers/pci/controller/dwc/pcie-rcar-gen4.c | 12 +++++++++++- drivers/pci/controller/dwc/pcie-uniphier-ep.c | 13 ++++++++++++- 10 files changed, 90 insertions(+), 26 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c index 0e406677060d..395042b29ffc 100644 --- a/drivers/pci/controller/dwc/pci-dra7xx.c +++ b/drivers/pci/controller/dwc/pci-dra7xx.c @@ -467,6 +467,13 @@ static int dra7xx_add_pcie_ep(struct dra7xx_pcie *dra7xx, return ret; } + ret = dw_pcie_ep_init_registers(ep); + if (ret) { + dev_err(dev, "Failed to initialize DWC endpoint registers\n"); + dw_pcie_ep_deinit(ep); + return ret; + } + return 0; } diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index dc2c036ab28c..bfcafa440ddb 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -1136,6 +1136,14 @@ static int imx6_add_pcie_ep(struct imx6_pcie *imx6_pcie, dev_err(dev, "failed to initialize endpoint\n"); return ret; } + + ret = dw_pcie_ep_init_registers(ep); + if (ret) { + dev_err(dev, "Failed to initialize DWC endpoint registers\n"); + dw_pcie_ep_deinit(ep); + return ret; + } + /* Start LTSSM. */ imx6_pcie_ltssm_enable(dev); diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c index c0c62533a3f1..8392894ed286 100644 --- a/drivers/pci/controller/dwc/pci-keystone.c +++ b/drivers/pci/controller/dwc/pci-keystone.c @@ -1286,6 +1286,13 @@ static int ks_pcie_probe(struct platform_device *pdev) ret = dw_pcie_ep_init(&pci->ep); if (ret < 0) goto err_get_sync; + + ret = dw_pcie_ep_init_registers(&pci->ep); + if (ret < 0) { + dev_err(dev, "Failed to initialize DWC endpoint registers\n"); + goto err_ep_init; + } + break; default: dev_err(dev, "INVALID device type %d\n", mode); @@ -1295,6 +1302,8 @@ static int ks_pcie_probe(struct platform_device *pdev) return 0; +err_ep_init: + dw_pcie_ep_deinit(&pci->ep); err_get_sync: pm_runtime_put(dev); pm_runtime_disable(dev); diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c index 2e398494e7c0..b712fdd06549 100644 --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c @@ -276,6 +276,13 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev) if (ret) return ret; + ret = dw_pcie_ep_init_registers(&pci->ep); + if (ret) { + dev_err(dev, "Failed to initialize DWC endpoint registers\n"); + dw_pcie_ep_deinit(&pci->ep); + return ret; + } + return ls_pcie_ep_interrupt_init(pcie, pdev); } diff --git a/drivers/pci/controller/dwc/pcie-artpec6.c b/drivers/pci/controller/dwc/pcie-artpec6.c index 9ed0a9ba7619..0edd9ab3f139 100644 --- a/drivers/pci/controller/dwc/pcie-artpec6.c +++ b/drivers/pci/controller/dwc/pcie-artpec6.c @@ -441,7 +441,18 @@ static int artpec6_pcie_probe(struct platform_device *pdev) pci->ep.ops = &pcie_ep_ops; - return dw_pcie_ep_init(&pci->ep); + ret = dw_pcie_ep_init(&pci->ep); + if (ret < 0) + return ret; + + ret = dw_pcie_ep_init_registers(&pci->ep); + if (ret) { + dev_err(dev, "Failed to initialize DWC endpoint registers\n"); + dw_pcie_ep_deinit(&pci->ep); + return ret; + } + + break; default: dev_err(dev, "INVALID device type %d\n", artpec6_pcie->mode); } diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index ed1f2afd830a..278bdc9b2269 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -729,7 +729,6 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) struct device *dev = pci->dev; struct platform_device *pdev = to_platform_device(dev); struct device_node *np = dev->of_node; - const struct pci_epc_features *epc_features; INIT_LIST_HEAD(&ep->func_list); @@ -775,29 +774,8 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) goto err_exit_epc_mem; } - if (ep->ops->get_features) { - epc_features = ep->ops->get_features(ep); - if (epc_features->core_init_notifier) - return 0; - } - - /* - * NOTE:- Avoid accessing the hardware (Ex:- DBI space) before this - * step as platforms that implement 'core_init_notifier' feature may - * not have the hardware ready (i.e. core initialized) for access - * (Ex: tegra194). Any hardware access on such platforms result - * in system hang. - */ - ret = dw_pcie_ep_init_registers(ep); - if (ret) - goto err_free_epc_mem; - return 0; -err_free_epc_mem: - pci_epc_mem_free_addr(epc, ep->msi_mem_phys, ep->msi_mem, - epc->mem->window.page_size); - err_exit_epc_mem: pci_epc_mem_exit(epc); diff --git a/drivers/pci/controller/dwc/pcie-designware-plat.c b/drivers/pci/controller/dwc/pcie-designware-plat.c index 778588b4be70..ca9b22e654cd 100644 --- a/drivers/pci/controller/dwc/pcie-designware-plat.c +++ b/drivers/pci/controller/dwc/pcie-designware-plat.c @@ -145,6 +145,15 @@ static int dw_plat_pcie_probe(struct platform_device *pdev) pci->ep.ops = &pcie_ep_ops; ret = dw_pcie_ep_init(&pci->ep); + if (ret) + return ret; + + ret = dw_pcie_ep_init_registers(&pci->ep); + if (ret) { + dev_err(dev, "Failed to initialize DWC endpoint registers\n"); + dw_pcie_ep_deinit(&pci->ep); + } + break; default: dev_err(dev, "INVALID device type %d\n", dw_plat_pcie->mode); diff --git a/drivers/pci/controller/dwc/pcie-keembay.c b/drivers/pci/controller/dwc/pcie-keembay.c index 208d3b0ba196..250d6acf16dc 100644 --- a/drivers/pci/controller/dwc/pcie-keembay.c +++ b/drivers/pci/controller/dwc/pcie-keembay.c @@ -392,6 +392,7 @@ static int keembay_pcie_probe(struct platform_device *pdev) struct keembay_pcie *pcie; struct dw_pcie *pci; enum dw_pcie_device_mode mode; + int ret; data = device_get_match_data(dev); if (!data) @@ -426,11 +427,24 @@ static int keembay_pcie_probe(struct platform_device *pdev) return -ENODEV; pci->ep.ops = &keembay_pcie_ep_ops; - return dw_pcie_ep_init(&pci->ep); + ret = dw_pcie_ep_init(&pci->ep); + if (ret) + return ret; + + ret = dw_pcie_ep_init_registers(&pci->ep); + if (ret) { + dev_err(dev, "Failed to initialize DWC endpoint registers\n"); + dw_pcie_ep_deinit(&pci->ep); + return ret; + } + + break; default: dev_err(dev, "Invalid device type %d\n", pcie->mode); return -ENODEV; } + + return 0; } static const struct keembay_pcie_of_data keembay_pcie_rc_of_data = { diff --git a/drivers/pci/controller/dwc/pcie-rcar-gen4.c b/drivers/pci/controller/dwc/pcie-rcar-gen4.c index 9d9d22e367bb..fb7c03639a53 100644 --- a/drivers/pci/controller/dwc/pcie-rcar-gen4.c +++ b/drivers/pci/controller/dwc/pcie-rcar-gen4.c @@ -414,6 +414,7 @@ static const struct dw_pcie_ep_ops pcie_ep_ops = { static int rcar_gen4_add_dw_pcie_ep(struct rcar_gen4_pcie *rcar) { struct dw_pcie_ep *ep = &rcar->dw.ep; + struct device *dev = rcar->dw.dev; int ret; if (!IS_ENABLED(CONFIG_PCIE_RCAR_GEN4_EP)) @@ -422,8 +423,17 @@ static int rcar_gen4_add_dw_pcie_ep(struct rcar_gen4_pcie *rcar) ep->ops = &pcie_ep_ops; ret = dw_pcie_ep_init(ep); - if (ret) + if (ret) { rcar_gen4_pcie_ep_deinit(rcar); + return ret; + } + + ret = dw_pcie_ep_init_registers(ep); + if (ret) { + dev_err(dev, "Failed to initialize DWC endpoint registers\n"); + dw_pcie_ep_deinit(ep); + rcar_gen4_pcie_ep_deinit(rcar); + } return ret; } diff --git a/drivers/pci/controller/dwc/pcie-uniphier-ep.c b/drivers/pci/controller/dwc/pcie-uniphier-ep.c index 3fced0d3e851..82ccaea089be 100644 --- a/drivers/pci/controller/dwc/pcie-uniphier-ep.c +++ b/drivers/pci/controller/dwc/pcie-uniphier-ep.c @@ -399,7 +399,18 @@ static int uniphier_pcie_ep_probe(struct platform_device *pdev) return ret; priv->pci.ep.ops = &uniphier_pcie_ep_ops; - return dw_pcie_ep_init(&priv->pci.ep); + ret = dw_pcie_ep_init(&priv->pci.ep); + if (ret) + return ret; + + ret = dw_pcie_ep_init_registers(&priv->pci.ep); + if (ret) { + dev_err(dev, "Failed to initialize DWC endpoint registers\n"); + dw_pcie_ep_deinit(&priv->pci.ep); + return ret; + } + + return 0; } static const struct uniphier_pcie_ep_soc_data uniphier_pro5_data = { -- 2.25.1