Linux PCI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Hans Zhang" <18255117159@163.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH 6/9] PCI: mediatek: Protect root bus removal with rescan lock
Date: Thu, 21 May 2026 20:11:11 +0000	[thread overview]
Message-ID: <20260521201111.CAE891F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260521161822.132996-7-18255117159@163.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Unbalanced clock disable and PM runtime disable when PCIe links are down.
--

commit 92b7c7047c2235e7192b983ddc544d37ac83ba04
Author: Hans Zhang <18255117159@163.com>

PCI: mediatek: Protect root bus removal with rescan lock

Secure mtk_pcie_remove() by adding pci_lock_rescan_remove() /
pci_unlock_rescan_remove() around pci_stop_root_bus() and
pci_remove_root_bus().

> diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c
> index 75722524fe744..2fedb6d2939de 100644
> --- a/drivers/pci/controller/pcie-mediatek.c
> +++ b/drivers/pci/controller/pcie-mediatek.c
> @@ -1172,8 +1172,10 @@ static void mtk_pcie_remove(struct platform_device *pdev)
>  	struct mtk_pcie *pcie = platform_get_drvdata(pdev);
>  	struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie);
>  
> +	pci_lock_rescan_remove();
>  	pci_stop_root_bus(host->bus);
>  	pci_remove_root_bus(host->bus);
> +	pci_unlock_rescan_remove();
>  	mtk_pcie_free_resources(pcie);
>  
>  	mtk_pcie_irq_teardown(pcie);

[Severity: High]
This is a pre-existing issue, but does the unconditional call to
mtk_pcie_put_resources(pcie) at the end of this function cause unbalanced
disables if all port links failed to come up?

In mtk_pcie_setup(), if all port links fail to come up (for instance, if no
PCIe endpoint is connected), list_empty(&pcie->ports) evaluates to true.
When this happens, mtk_pcie_subsys_powerdown(pcie) is called early,
disabling the clock and PM runtime. However, mtk_pcie_probe() successfully
completes and registers the empty root bus.

When the driver is later unbound or removed, mtk_pcie_remove()
unconditionally executes mtk_pcie_put_resources(pcie), without the necessary
!list_empty(&pcie->ports) guard that correctly exists in the probe error
path. This calls mtk_pcie_subsys_powerdown() a second time.

Will this double clk_disable_unprepare() trigger a clock framework WARN,
and increment the PM disable depth to 2?

If the driver is later re-probed, pm_runtime_enable() only decrements the
depth by 1, leaving the device disabled.

Can this result in pm_runtime_get_sync() silently failing to power on the
PCIe power domain, causing subsequent MMIO register accesses in
mtk_pcie_enable_port() to trigger a synchronous external abort?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260521161822.132996-1-18255117159@163.com?part=6

  reply	other threads:[~2026-05-21 20:11 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-21 16:18 [PATCH 0/9] PCI: controller: Add missing rescan lock around root bus removal Hans Zhang
2026-05-21 16:18 ` [PATCH 1/9] PCI: cadence: Protect root bus removal with rescan lock Hans Zhang
2026-05-21 16:18 ` [PATCH 2/9] PCI: dwc: " Hans Zhang
2026-05-21 16:18 ` [PATCH 3/9] PCI: altera: " Hans Zhang
2026-05-21 18:51   ` sashiko-bot
2026-05-21 16:18 ` [PATCH 4/9] PCI: brcmstb: " Hans Zhang
2026-05-21 19:19   ` sashiko-bot
2026-05-21 16:18 ` [PATCH 5/9] PCI: iproc: " Hans Zhang
2026-05-21 16:18 ` [PATCH 6/9] PCI: mediatek: " Hans Zhang
2026-05-21 20:11   ` sashiko-bot [this message]
2026-05-21 16:18 ` [PATCH 7/9] PCI: rockchip: " Hans Zhang
2026-05-21 20:40   ` sashiko-bot
2026-05-21 16:18 ` [PATCH 8/9] PCI: vmd: " Hans Zhang
2026-05-21 21:20   ` sashiko-bot
2026-06-10 17:28     ` Manivannan Sadhasivam
2026-06-11  4:42       ` Hans Zhang
2026-06-11  6:30         ` Manivannan Sadhasivam
2026-06-11 14:00           ` Hans Zhang
2026-05-21 16:18 ` [PATCH 9/9] PCI: plda: " Hans Zhang
2026-06-11  7:04 ` (subset) [PATCH 0/9] PCI: controller: Add missing rescan lock around root bus removal Manivannan Sadhasivam
2026-06-18 16:59 ` Bjorn Helgaas

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=20260521201111.CAE891F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=18255117159@163.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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