Re: [PATCH] bus: mhi: host: pci_generic: Resume the device before executing mhi_pci_remove()

From: Qiang Yu

Date: Mon Mar 02 2026 - 20:43:43 EST


On Mon, Mar 02, 2026 at 07:11:16PM +0530, Manivannan Sadhasivam wrote:
> mhi_pci_remove() carries out device specific operations that requires the
> device to be active. But pm_runtime_get_noresume() called at the end of the
> remove() will not guarantee that.
>
> So use pm_runtime_get_sync() and call it at the start of remove().
>
> Cc: <stable@xxxxxxxxxxxxxxx> # 5.13
> Cc: Loic Poulain <loic.poulain@xxxxxxxxxxxxxxxx>
> Fixes: d3800c1dce24 ("bus: mhi: pci_generic: Add support for runtime PM")
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxxxxxxxx>
> ---
> drivers/bus/mhi/host/pci_generic.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/bus/mhi/host/pci_generic.c b/drivers/bus/mhi/host/pci_generic.c
> index 425362037830..fe3aefa15966 100644
> --- a/drivers/bus/mhi/host/pci_generic.c
> +++ b/drivers/bus/mhi/host/pci_generic.c
> @@ -1440,6 +1440,10 @@ static void mhi_pci_remove(struct pci_dev *pdev)
> struct mhi_pci_device *mhi_pdev = pci_get_drvdata(pdev);
> struct mhi_controller *mhi_cntrl = &mhi_pdev->mhi_cntrl;
>
> + /* balancing probe put_noidle */
> + if (pci_pme_capable(pdev, PCI_D3hot))
> + pm_runtime_get_sync(&pdev->dev);

Mani, I don't think we need to resume here. See drivers/pci/pci-driver.c.
PCI framework has called pm_runtime_get_sync before drv->remove(pci_dev);
Is there any other thing I misunderstand?

static void pci_device_remove(struct device *dev)
{
...
if (drv->remove) {
pm_runtime_get_sync(dev);
...
pm_runtime_barrier(dev);
drv->remove(pci_dev);
pm_runtime_put_noidle(dev);

- Qiang Yu
> +
> pci_disable_sriov(pdev);
>
> if (pdev->is_physfn)
> @@ -1451,10 +1455,6 @@ static void mhi_pci_remove(struct pci_dev *pdev)
> mhi_unprepare_after_power_down(mhi_cntrl);
> }
>
> - /* balancing probe put_noidle */
> - if (pci_pme_capable(pdev, PCI_D3hot))
> - pm_runtime_get_noresume(&pdev->dev);
> -
> if (mhi_pdev->reset_on_remove)
> mhi_soc_reset(mhi_cntrl);
>
> --
> 2.51.0
>