Re: [PATCH] bus: mhi: host: pci_generic: Resume the device before executing mhi_pci_remove()
From: Manivannan Sadhasivam
Date: Tue Mar 03 2026 - 00:12:14 EST
On Mon, Mar 02, 2026 at 05:43:33PM -0800, Qiang Yu wrote:
> 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?
>
Oops... I completely forgot this. Yes, the device gets resumed by the PCI core
before invoking the remove() callback to ensure that the device stays active.
Then the driver bumps the reference correctly using pm_runtime_get_noresume() to
balance pm_runtime_put_noidle() in probe().
So yes, your understanding was correct and I overlooked it. Thanks!
- Mani
--
மணிவண்ணன் சதாசிவம்