mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mikko Perttunen <mperttunen@nvidia.com>
To: "Bartosz Golaszewski" <brgl@kernel.org>,
	"Manivannan Sadhasivam" <mani@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Thierry Reding" <thierry.reding@kernel.org>,
	"Jonathan Hunter" <jonathanh@nvidia.com>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-tegra@vger.kernel.org, devicetree@vger.kernel.org,
	 Mikko Perttunen <mperttunen@nvidia.com>,
	 Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Subject: [PATCH v2 3/5] PCI: tegra264: Power endpoint devices before enumeration
Date: Fri, 04 Dec 2026 12:05:15 +0900	[thread overview]
Message-ID: <20261204-b4-t264-igpu-pci-v2-3-e36cd85f4778@nvidia.com> (raw)
In-Reply-To: <20261204-b4-t264-igpu-pci-v2-0-e36cd85f4778@nvidia.com>

Add calls into the PCI pwrctrl framework to do required power sequencing
for endpoint devices before attempting to enumerate them, and select
PCI_PWRCTRL_GENERIC in Kconfig.

This is required for the integrated GB10B GPU on Tegra264 that requires
a power domain to be enabled before it appears on the PCI bus.

Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
---
 drivers/pci/controller/Kconfig         |  1 +
 drivers/pci/controller/pcie-tegra264.c | 22 ++++++++++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig
index d246bbe37948..ab8cb1be28ba 100644
--- a/drivers/pci/controller/Kconfig
+++ b/drivers/pci/controller/Kconfig
@@ -261,6 +261,7 @@ config PCIE_TEGRA264
 	tristate "NVIDIA Tegra264 PCIe controller"
 	depends on ARCH_TEGRA || COMPILE_TEST
 	select PCI_ECAM
+	select PCI_PWRCTRL_GENERIC
 	help
 	  Say Y here if you want support for the PCIe Host Controller found
 	  on NVIDIA Tegra264 SoCs.
diff --git a/drivers/pci/controller/pcie-tegra264.c b/drivers/pci/controller/pcie-tegra264.c
index c97576ab4a31..1d65ed5d0381 100644
--- a/drivers/pci/controller/pcie-tegra264.c
+++ b/drivers/pci/controller/pcie-tegra264.c
@@ -17,6 +17,7 @@
 #include <linux/of_pci.h>
 #include <linux/of_platform.h>
 #include <linux/pci-ecam.h>
+#include <linux/pci-pwrctrl.h>
 #include <linux/pci.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
@@ -391,6 +392,14 @@ static int tegra264_pcie_probe(struct platform_device *pdev)
 	bridge->sysdata = pcie->cfg;
 	pcie->ecam = pcie->cfg->win;
 
+	err = pci_pwrctrl_create_devices(dev);
+	if (err)
+		goto err_free_ecam;
+
+	err = pci_pwrctrl_power_on_devices(dev);
+	if (err)
+		goto err_destroy_pwrctrl;
+
 	tegra264_pcie_init(pcie);
 
 	/*
@@ -402,17 +411,23 @@ static int tegra264_pcie_probe(struct platform_device *pdev)
 				    "PCIe #%u link is down and not hotplug-capable, turning off\n",
 				    pcie->ctl_id);
 		tegra264_pcie_power_off(pcie);
-		goto err_free_ecam;
+		goto err_power_off;
 	}
 
 	err = pci_host_probe(bridge);
 	if (err < 0) {
 		dev_err_probe(dev, err, "failed to register Host Bridge\n");
-		goto err_free_ecam;
+		goto err_power_off;
 	}
 
 	return 0;
 
+err_power_off:
+	pci_pwrctrl_power_off_devices(dev);
+err_destroy_pwrctrl:
+	/* Keep devices registered so their drivers can bind before we retry. */
+	if (err != -EPROBE_DEFER)
+		pci_pwrctrl_destroy_devices(dev);
 err_free_ecam:
 	pci_ecam_free(pcie->cfg);
 err_put_pm:
@@ -437,6 +452,9 @@ static void tegra264_pcie_remove(struct platform_device *pdev)
 	pci_remove_root_bus(pcie->bridge->bus);
 	pci_unlock_rescan_remove();
 
+	pci_pwrctrl_power_off_devices(&pdev->dev);
+	pci_pwrctrl_destroy_devices(&pdev->dev);
+
 	pm_runtime_put_sync(&pdev->dev);
 	tegra_bpmp_put(pcie->bpmp);
 	pci_ecam_free(pcie->cfg);

-- 
2.56.1


  parent reply	other threads:[~2026-12-04  3:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  3:05 [PATCH v2 0/5] Tegra264 GB10B boards the bus Mikko Perttunen
2026-12-04  3:05 ` [PATCH v2 1/5] PCI/pwrctrl: Enable pwrctrl for devices powered by a power domain Mikko Perttunen
2026-12-04  3:05 ` [PATCH v2 2/5] PCI/pwrctrl: Add the Tegra264 iGPU to the generic match table Mikko Perttunen
2026-12-04  3:05 ` Mikko Perttunen [this message]
2026-12-04  3:05 ` [PATCH v2 4/5] arm64: tegra: Add node for the GB10B GPU on Tegra264 Mikko Perttunen
2026-12-04  3:05 ` [PATCH v2 5/5] arm64: tegra: Enable and mark the Tegra264 GPU PCIe controller as ATS supported Mikko Perttunen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261204-b4-t264-igpu-pci-v2-3-e36cd85f4778@nvidia.com \
    --to=mperttunen@nvidia.com \
    --cc=bartosz.golaszewski@oss.qualcomm.com \
    --cc=bhelgaas@google.com \
    --cc=brgl@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=krzk+dt@kernel.org \
    --cc=kwilczynski@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mani@kernel.org \
    --cc=robh@kernel.org \
    --cc=thierry.reding@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®