linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: Sylwester Nawrocki <snawrocki@kernel.org>
Cc: linuxarm@huawei.com, mauro.chehab@huawei.com,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Sylwester Nawrocki <s.nawrocki@samsung.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	linux-samsung-soc@vger.kernel.org
Subject: Re: [PATCH 57/78] media: exynos4-is: use pm_runtime_resume_and_get()
Date: Mon, 26 Apr 2021 15:12:24 +0200	[thread overview]
Message-ID: <20210426151224.2b677d1b@coco.lan> (raw)
In-Reply-To: <45068e81-8f9b-fea8-b7bc-bdd0443ba7e6@kernel.org>

Em Sun, 25 Apr 2021 22:57:25 +0200
Sylwester Nawrocki <snawrocki@kernel.org> escreveu:

> On 24.04.2021 08:45, Mauro Carvalho Chehab wrote:
> > Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
> > added pm_runtime_resume_and_get() in order to automatically handle
> > dev->power.usage_count decrement on errors.
> > 
> > Use the new API, in order to cleanup the error check logic.
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> > ---
> >   drivers/media/platform/exynos4-is/fimc-capture.c   | 6 ++----
> >   drivers/media/platform/exynos4-is/fimc-is.c        | 3 ++-
> >   drivers/media/platform/exynos4-is/fimc-isp-video.c | 3 +--
> >   drivers/media/platform/exynos4-is/fimc-isp.c       | 7 +++----
> >   drivers/media/platform/exynos4-is/fimc-lite.c      | 5 +++--
> >   drivers/media/platform/exynos4-is/fimc-m2m.c       | 2 +-
> >   drivers/media/platform/exynos4-is/media-dev.c      | 8 +++-----
> >   drivers/media/platform/exynos4-is/mipi-csis.c      | 5 ++---
> >   8 files changed, 17 insertions(+), 22 deletions(-)
> > 
> > diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c
> > index 13c838d3f947..0da36443173c 100644
> > --- a/drivers/media/platform/exynos4-is/fimc-capture.c
> > +++ b/drivers/media/platform/exynos4-is/fimc-capture.c
> > @@ -478,11 +478,9 @@ static int fimc_capture_open(struct file *file)
> >   		goto unlock;
> >   
> >   	set_bit(ST_CAPT_BUSY, &fimc->state);
> > -	ret = pm_runtime_get_sync(&fimc->pdev->dev);
> > -	if (ret < 0) {
> > -		pm_runtime_put_sync(&fimc->pdev->dev);
> > +	ret = pm_runtime_resume_and_get(&fimc->pdev->dev);
> > +	if (ret < 0)
> >   		goto unlock;
> > -	}
> >   
> >   	ret = v4l2_fh_open(file);
> >   	if (ret) {
> > diff --git a/drivers/media/platform/exynos4-is/fimc-is.c b/drivers/media/platform/exynos4-is/fimc-is.c
> > index 972d9601d236..bca35866cc74 100644
> > --- a/drivers/media/platform/exynos4-is/fimc-is.c
> > +++ b/drivers/media/platform/exynos4-is/fimc-is.c
> > @@ -828,7 +828,7 @@ static int fimc_is_probe(struct platform_device *pdev)
> >   			goto err_irq;
> >   	}
> >   
> > -	ret = pm_runtime_get_sync(dev);
> > +	ret = pm_runtime_resume_and_get(dev);
> >   	if (ret < 0)
> >   		goto err_pm;  
> 
> It seems you intended to use err_suspend label here. We don't need
> a new label though, instead of err_pm we can jump to err_irq when
> pm_runtime_resume_and_get() fails. 

Thanks! Will fix at the next version.

> Note that when runtime PM is
> disabled pm_runtime_resume_and_get() always returns 0.

Ok, but there are a couple of conditions at rpm_resume() function
at drivers/base/power/runtime.c (which is the code that actually
handles those PM macros) that could make it to return errors,
which are independent on the PM callbacks, like those:

        if (dev->power.runtime_error)
                retval = -EINVAL;
        else if (dev->power.disable_depth > 0)
                retval = -EACCES;

and more might be added as the PM core changes.

> 
> > @@ -862,6 +862,7 @@ static int fimc_is_probe(struct platform_device *pdev)
> >   	fimc_is_unregister_subdevs(is);
> >   err_pm:
> >   	pm_runtime_put_noidle(dev);
> > +err_suspend:
> >   	if (!pm_runtime_enabled(dev))
> >   		fimc_is_runtime_suspend(dev);
> >   err_irq:  
> 
> 
> > diff --git a/drivers/media/platform/exynos4-is/mipi-csis.c b/drivers/media/platform/exynos4-is/mipi-csis.c
> > index 1aac167abb17..a0218237d66b 100644
> > --- a/drivers/media/platform/exynos4-is/mipi-csis.c
> > +++ b/drivers/media/platform/exynos4-is/mipi-csis.c
> > @@ -494,7 +494,7 @@ static int s5pcsis_s_power(struct v4l2_subdev *sd, int on)
> >   	struct device *dev = &state->pdev->dev;
> >   
> >   	if (on)
> > -		return pm_runtime_get_sync(dev);
> > +		return pm_runtime_resume_and_get(dev);
> >   
> >   	return pm_runtime_put_sync(dev);
> >   }
> > @@ -509,9 +509,8 @@ static int s5pcsis_s_stream(struct v4l2_subdev *sd, int enable)
> >   
> >   	if (enable) {
> >   		s5pcsis_clear_counters(state);
> > -		ret = pm_runtime_get_sync(&state->pdev->dev);
> > +		ret = pm_runtime_resume_and_get(&state->pdev->dev);
> >   		if (ret && ret != 1) {
> > -			pm_runtime_put_noidle(&state->pdev->dev);
> >   			return ret;
> >   		}  
> 
> Braces could be dropped as well here.

OK.

> 
> >   	}  
> 
> 
> Thanks,
> Sylwester
> 



Thanks,
Mauro

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-04-26 13:14 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1619191723.git.mchehab+huawei@kernel.org>
2021-04-24  6:44 ` [PATCH 01/78] media: atmel: properly get pm_runtime Mauro Carvalho Chehab
2021-04-24  9:36   ` kernel test robot
2021-04-24  6:44 ` [PATCH 03/78] media: mdk-mdp: fix pm_runtime_get_sync() usage count Mauro Carvalho Chehab
2021-04-24  6:44 ` [PATCH 05/78] " Mauro Carvalho Chehab
2021-04-24 18:23   ` Ezequiel Garcia
2021-04-24  6:44 ` [PATCH 14/78] staging: media: imx7-mipi-csis: use pm_runtime_resume_and_get() Mauro Carvalho Chehab
2021-04-26 10:11   ` Rui Miguel Silva
2021-04-24  6:44 ` [PATCH 16/78] staging: media: cedrus_video: " Mauro Carvalho Chehab
2021-04-24  6:44 ` [PATCH 20/78] media: mtk-vcodec: fix pm_runtime_get_sync() usage count Mauro Carvalho Chehab
2021-04-24  6:44 ` [PATCH 21/78] media: s5p-jpeg: " Mauro Carvalho Chehab
2021-04-27  9:14   ` Sylwester Nawrocki
2021-04-24  6:44 ` [PATCH 23/78] media: sun8i_rotate: " Mauro Carvalho Chehab
2021-04-24  6:45 ` [PATCH 57/78] media: exynos4-is: use pm_runtime_resume_and_get() Mauro Carvalho Chehab
2021-04-25 20:57   ` Sylwester Nawrocki
2021-04-26 13:12     ` Mauro Carvalho Chehab [this message]
2021-04-27  8:06       ` Sylwester Nawrocki
2021-04-24  6:45 ` [PATCH 58/78] media: exynos-gsc: " Mauro Carvalho Chehab
2021-04-27  8:18   ` Sylwester Nawrocki
2021-04-27  9:30     ` Mauro Carvalho Chehab
2021-04-27  9:42       ` Mauro Carvalho Chehab
2021-04-27 11:50         ` Sylwester Nawrocki
2021-04-28  7:13           ` Mauro Carvalho Chehab
2021-04-28  7:17             ` Mauro Carvalho Chehab
2021-04-28  8:27               ` Sylwester Nawrocki
2021-04-24  6:45 ` [PATCH 59/78] media: mtk-jpeg: " Mauro Carvalho Chehab
2021-04-24  6:45 ` [PATCH 70/78] media: rga-buf: " Mauro Carvalho Chehab
2021-04-28 17:09   ` Ezequiel Garcia
2021-04-24  6:45 ` [PATCH 71/78] media: rkisp1-capture: " Mauro Carvalho Chehab
2021-04-24  6:45 ` [PATCH 73/78] media: s5p-mfc: " Mauro Carvalho Chehab
2021-04-27  9:36   ` Sylwester Nawrocki
2021-04-24  6:45 ` [PATCH 75/78] media: stm32: " Mauro Carvalho Chehab
2021-04-24  6:45 ` [PATCH 76/78] media: sun4i_v4l2: " Mauro Carvalho Chehab
2021-04-24 10:21   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210426151224.2b677d1b@coco.lan \
    --to=mchehab+huawei@kernel.org \
    --cc=krzk@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=mauro.chehab@huawei.com \
    --cc=mchehab@kernel.org \
    --cc=s.nawrocki@samsung.com \
    --cc=snawrocki@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).