From: Myeonghun Pak <mhun512@gmail.com>
To: linux-pci@vger.kernel.org
Cc: thomas.petazzoni@bootlin.com, pali@kernel.org,
lpieralisi@kernel.org, kwilczynski@kernel.org, mani@kernel.org,
robh@kernel.org, bhelgaas@google.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Myeonghun Pak <mhun512@gmail.com>,
Ijae Kim <ae878000@gmail.com>
Subject: [PATCH] PCI: aardvark: Disable PHY on probe failures
Date: Thu, 10 Sep 2026 18:17:25 -0400 [thread overview]
Message-ID: <20260910221725.91980-1-mhun512@gmail.com> (raw)
advk_pcie_setup_phy() initializes and powers on the PHY before the
emulated bridge and IRQ domains are created. If any of those later
initialization steps or pci_host_probe() fails, probe returns without
powering off or exiting the PHY.
Replace the direct returns with staged cleanup labels. Remove IRQ
domains in reverse order, release the emulated bridge allocation only
after successful initialization, and disable the PHY on every failure
after advk_pcie_setup_phy() succeeds. A setup_phy() failure still
returns directly, so its partial internal cleanup is not repeated.
Fixes: 366697018c9a ("PCI: aardvark: Add PHY support")
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
drivers/pci/controller/pci-aardvark.c | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c
index ecb81ac73019..2bbdb73cfb45 100644
--- a/drivers/pci/controller/pci-aardvark.c
+++ b/drivers/pci/controller/pci-aardvark.c
@@ -1864,28 +1864,25 @@ static int advk_pcie_probe(struct platform_device *pdev)
ret = advk_sw_pci_bridge_init(pcie);
if (ret) {
dev_err(dev, "Failed to register emulated root PCI bridge\n");
- return ret;
+ goto err_disable_phy;
}
ret = advk_pcie_init_irq_domain(pcie);
if (ret) {
dev_err(dev, "Failed to initialize irq\n");
- return ret;
+ goto err_cleanup_bridge;
}
ret = advk_pcie_init_msi_irq_domain(pcie);
if (ret) {
dev_err(dev, "Failed to initialize irq\n");
- advk_pcie_remove_irq_domain(pcie);
- return ret;
+ goto err_remove_irq_domain;
}
ret = advk_pcie_init_rp_irq_domain(pcie);
if (ret) {
dev_err(dev, "Failed to initialize irq\n");
- advk_pcie_remove_msi_irq_domain(pcie);
- advk_pcie_remove_irq_domain(pcie);
- return ret;
+ goto err_remove_msi_irq_domain;
}
bridge->sysdata = pcie;
@@ -1893,14 +1890,22 @@ static int advk_pcie_probe(struct platform_device *pdev)
bridge->map_irq = advk_pcie_map_irq;
ret = pci_host_probe(bridge);
- if (ret < 0) {
- advk_pcie_remove_rp_irq_domain(pcie);
- advk_pcie_remove_msi_irq_domain(pcie);
- advk_pcie_remove_irq_domain(pcie);
- return ret;
- }
+ if (ret < 0)
+ goto err_remove_rp_irq_domain;
return 0;
+
+err_remove_rp_irq_domain:
+ advk_pcie_remove_rp_irq_domain(pcie);
+err_remove_msi_irq_domain:
+ advk_pcie_remove_msi_irq_domain(pcie);
+err_remove_irq_domain:
+ advk_pcie_remove_irq_domain(pcie);
+err_cleanup_bridge:
+ pci_bridge_emul_cleanup(&pcie->bridge);
+err_disable_phy:
+ advk_pcie_disable_phy(pcie);
+ return ret;
}
static void advk_pcie_remove(struct platform_device *pdev)
--
2.50.1
reply other threads:[~2026-09-10 22:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260910221725.91980-1-mhun512@gmail.com \
--to=mhun512@gmail.com \
--cc=ae878000@gmail.com \
--cc=bhelgaas@google.com \
--cc=kwilczynski@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=pali@kernel.org \
--cc=robh@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
/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