[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210503144925.05b56132@coco.lan>
Date: Mon, 3 May 2021 14:49:25 +0200
From: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
To: Jonathan Cameron <Jonathan.Cameron@...wei.com>
Cc: <linuxarm@...wei.com>, <mauro.chehab@...wei.com>,
Benoit Parrot <bparrot@...com>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
<linux-kernel@...r.kernel.org>, <linux-media@...r.kernel.org>
Subject: Re: [PATCH v4 75/79] media: ti-vpe: use pm_runtime_resume_and_get()
Em Fri, 30 Apr 2021 19:03:11 +0100
Jonathan Cameron <Jonathan.Cameron@...wei.com> escreveu:
> On Wed, 28 Apr 2021 16:52:36 +0200
> Mauro Carvalho Chehab <mchehab+huawei@...nel.org> 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
Powered by blists - more mailing lists