Re: [PATCH v4 75/79] media: ti-vpe: use pm_runtime_resume_and_get()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Em Fri, 30 Apr 2021 19:03:11 +0100
Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx> escreveu:

> On Wed, 28 Apr 2021 16:52:36 +0200
> Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx> wrote:

> > diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c
> > index 10251b787674..07cb2c140295 100644
> > --- a/drivers/media/platform/ti-vpe/vpe.c
> > +++ b/drivers/media/platform/ti-vpe/vpe.c
> > @@ -2471,10 +2471,8 @@ static int vpe_runtime_get(struct platform_device *pdev)
> >  
> >  	dev_dbg(&pdev->dev, "vpe_runtime_get\n");
> >  
> > -	r = pm_runtime_get_sync(&pdev->dev);
> > +	r = pm_runtime_resume_and_get(&pdev->dev);
> >  	WARN_ON(r < 0);
> > -	if (r)
> > -		pm_runtime_put_noidle(&pdev->dev);
> >  	return r < 0 ? r : 0;  
> r is <= 0 to zero so this isn't doing anything useful.

Not really. pm_runtime*get* routines may return positive values
as well. From Documentation/power/runtime_pm.rst:

  `int pm_runtime_resume(struct device *dev);`
    - execute the subsystem-level resume callback for the device; returns 0 on
      success, 1 if the device's runtime PM status was already 'active' or
      error code on failure, where -EAGAIN means it may be safe to attempt to
      resume the device again in future, but 'power.runtime_error' should be
      checked additionally, and -EACCES means that 'power.disable_depth' is
      different from 0

  `int pm_runtime_resume_and_get(struct device *dev);`
    - run pm_runtime_resume(dev) and if successful, increment the device's
      usage counter; return the result of pm_runtime_resume

  `int pm_runtime_get_sync(struct device *dev);`
    - increment the device's usage counter, run pm_runtime_resume(dev) and
      return its result

So, basically, if the device was already active, it would return 1.

Now, this is called as:

        ret = vpe_runtime_get(pdev);
        if (ret)
                goto rel_m2m;

So the logic could be simplified if the caller would be
doing, instead:

        ret = vpe_runtime_get(pdev);
        if (ret < 0)
                goto rel_m2m;

I'll do such change for the next version.

Thanks,
Mauro



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux