All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Krishna Chaitanya Chundru" <krishna.chundru@oss.qualcomm.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v6 3/3] PCI: qcom: Implement shutdown() callback
Date: Wed, 09 Sep 2026 12:34:18 +0000	[thread overview]
Message-ID: <20260909123419.750A61F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260909-shutdown-v6-3-62b7bd123236@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] The local variable `pcie` is used uninitialized on the `firmware_managed` code path, leading to undefined behavior and a likely kernel panic when evaluated and dereferenced.
- [High] Calling `dw_pcie_free_msi()` during `.shutdown` destroys the active MSI IRQ domain while child endpoints still have IRQs mapped, triggering a spurious kernel warning and leaving dangling state.
--

commit 27c88a203aab0fef576a235de5067454639a8757
Author: Manivannan Sadhasivam <mani@kernel.org>

PCI: qcom: Implement shutdown() callback

This commit implements a shutdown callback for PCIe host controllers to
bring the link down cleanly before system shutdown or reboot proceeds.
It reuses dw_pcie_suspend_noirq() in the shutdown path to force the link
into L2 and masks chained MSI IRQs to prevent late spurious interrupts.

> diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c
> index 2693a98d0b279..3133e2b2eda69 100644
> --- a/drivers/pci/controller/dwc/pcie-qcom.c
> +++ b/drivers/pci/controller/dwc/pcie-qcom.c

[ ... ]

> @@ -2408,6 +2411,37 @@ static int qcom_pcie_probe(struct platform_device *pdev)
>  	return ret;
>  }
>  
> +static void qcom_pcie_shutdown(struct platform_device *pdev)
> +{
> +	const struct qcom_pcie_cfg *pcie_cfg = of_device_get_match_data(&pdev->dev);
> +	struct qcom_pcie *pcie;
> +	struct dw_pcie *pci;
> +
> +	if (pcie_cfg && pcie_cfg->firmware_managed) {
> +		/*
> +		 * Firmware owns the link teardown and clock/PHY shutdown in
> +		 * this mode; Linux only owns the chained MSI IRQ(s), which
> +		 * still need to be masked off before shutdown proceeds.
> +		 */
> +		pci = platform_get_drvdata(pdev);
> +	} else {
> +		pcie = platform_get_drvdata(pdev);
> +		pci = pcie->pci;
> +
> +		if (pcie->global_irq)
> +			disable_irq(pcie->global_irq);
> +	}
> +
> +	if (pci->pp.use_imsi_rx)
> +		dw_pcie_free_msi(&pci->pp);

[Severity: High]
Does calling dw_pcie_free_msi() here trigger a core IRQ subsystem warning?

During system shutdown, child endpoints have their .shutdown callbacks
executed rather than .remove, so they do not naturally release their
allocated MSI vectors.

dw_pcie_free_msi() unconditionally destroys the IRQ domain:

drivers/pci/controller/dwc/pcie-designware-host.c:dw_pcie_free_msi() {
    ...
    irq_domain_remove(pp->irq_domain);
}

Will destroying this domain while child endpoints still hold IRQ mappings
leave dangling IRQ descriptors and trigger a warning when checking if the
domain tree is empty?

> +
> +	if (pcie)
> +		dw_pcie_suspend_noirq(pcie->pci, true);

[Severity: Critical]
Is the pcie variable left uninitialized in the firmware_managed path?

When pcie_cfg->firmware_managed is true, pci is initialized but pcie is
not. It looks like this branch will then evaluate stack garbage for the
condition check.

If it evaluates to true, could this cause a kernel panic by dereferencing
stack garbage when accessing pcie->pci in dw_pcie_suspend_noirq()?

> +
> +	pm_runtime_put_sync(&pdev->dev);
> +	pm_runtime_disable(&pdev->dev);
> +}

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260909-shutdown-v6-0-62b7bd123236@oss.qualcomm.com?part=3

  reply	other threads:[~2026-09-09 12:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-09 12:24 [PATCH v6 0/3] PCI: qcom: Implement shutdown() to avoid SMMU/NoC errors on reboot Krishna Chaitanya Chundru
2026-09-09 12:24 ` [PATCH v6 1/3] PCI: host-common: Fix early bus-walk exit in d3cold_possible() Krishna Chaitanya Chundru
2026-09-09 12:29   ` sashiko-bot
2026-09-09 12:24 ` [PATCH v6 2/3] PCI: dwc: Force L2 link entry on shutdown/reboot without D3cold check Krishna Chaitanya Chundru
2026-09-09 12:34   ` sashiko-bot
2026-09-09 12:24 ` [PATCH v6 3/3] PCI: qcom: Implement shutdown() callback Krishna Chaitanya Chundru
2026-09-09 12:34   ` sashiko-bot [this message]
2026-09-09 12:36   ` Konrad Dybcio
2026-09-09 12:40     ` Krishna Chaitanya Chundru
2026-09-09 13:18       ` Konrad Dybcio
2026-09-10  3:26         ` Krishna Chaitanya Chundru
2026-09-11  6:00           ` Manivannan Sadhasivam
2026-09-09 12:38 ` [PATCH v6 0/3] PCI: qcom: Implement shutdown() to avoid SMMU/NoC errors on reboot Konrad Dybcio
2026-09-09 12:42   ` Krishna Chaitanya Chundru

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=20260909123419.750A61F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=krishna.chundru@oss.qualcomm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.