Re: [PATCH 5/5] usb: dwc3: qcom: Allow runtime PM

Johan Hovold
2023-03-28T13:36:15Z

On Tue, Mar 28, 2023 at 06:27:05PM +0530, Manivannan Sadhasivam wrote:
> On Tue, Mar 28, 2023 at 02:18:16PM +0200, Johan Hovold wrote:

> > > > > @@ -948,6 +948,8 @@ static int dwc3_qcom_remove(struct platform_device *pdev)
> > > > > struct device *dev = &pdev->dev;
> > > > > int i;
> > > > >
> > > > > + pm_runtime_get_sync(dev);
> > > >
> > > > This call needs to be balanced. But this is a fix for a bug in the
> > > > current implementation that should go in a separate patch.
> > >
> > > Ok. For balancing I could add pm_runtime_put_noidle() before pm_runtime_disable.
> >
> > You should do it after disabling runtime pm.
>
> May I know why?

The usage counter should be balanced after disabling runtime PM so that
there is no window where you could get a racing suspend request.

> > > > > +
> > > > > device_remove_software_node(&qcom->dwc3->dev);
> > > > > of_platform_depopulate(dev);
> > > > >
> > > > > @@ -960,7 +962,6 @@ static int dwc3_qcom_remove(struct platform_device *pdev)
> > > > > dwc3_qcom_interconnect_exit(qcom);
> > > > > reset_control_assert(qcom->resets);
> > > > >
> > > > > - pm_runtime_allow(dev);
> > > > > pm_runtime_disable(dev);
> > > > >
> > > > > return 0;

Johan