Linux-Renesas-SoC Archive on lore.kernel.org
 help / color / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Cc: Ulrich Hecht <uli@fpond.eu>,
	linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	Ulrich Hecht <uli+renesas@fpond.eu>
Subject: Re: [PATCH v2 5/8] rcar-vin: Move pm_runtime_{get,put} out of helpers
Date: Thu, 16 May 2019 14:39:42 +0300
Message-ID: <20190516113942.GD14820@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20190516011417.10590-6-niklas.soderlund+renesas@ragnatech.se>

Hi Niklas,

Thank you for the patch.

On Thu, May 16, 2019 at 03:14:14AM +0200, Niklas Söderlund wrote:
> The helpers rvin_power_{on,off} deal with both VIN and the parallel
> subdevice power. This makes it hard to merge the Gen2 and Gen3
> open/release functions. Move the VIN power handling directly to the
> open/release functions to prepare for the merge.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu>
> ---
>  drivers/media/platform/rcar-vin/rcar-v4l2.c | 34 +++++++++++++--------
>  1 file changed, 21 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> index 71651c5a69483367..5a9658b7d848fc86 100644
> --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> @@ -754,8 +754,6 @@ static int rvin_power_on(struct rvin_dev *vin)
>  	int ret;
>  	struct v4l2_subdev *sd = vin_to_source(vin);
>  
> -	pm_runtime_get_sync(vin->v4l2_dev.dev);
> -
>  	ret = v4l2_subdev_call(sd, core, s_power, 1);
>  	if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV)
>  		return ret;
> @@ -768,9 +766,6 @@ static int rvin_power_off(struct rvin_dev *vin)
>  	struct v4l2_subdev *sd = vin_to_source(vin);
>  
>  	ret = v4l2_subdev_call(sd, core, s_power, 0);
> -
> -	pm_runtime_put(vin->v4l2_dev.dev);
> -
>  	if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV)
>  		return ret;
>  
> @@ -802,20 +797,31 @@ static int rvin_open(struct file *file)
>  
>  	file->private_data = vin;
>  
> +	ret = pm_runtime_get_sync(vin->dev);

I like operating on vin->dev much more than on vin->v4l2_dev.dev, even
if the two point to the same platform device.

> +	if (ret < 0)
> +		goto err_unlock;

Would it be useful to do this before locking the mutex, as PM runtime
doesn't need to be protected by that lock, to minimise the time spent
with the mutex held ?

> +
>  	ret = v4l2_fh_open(file);
>  	if (ret)
> -		goto unlock;
> +		goto err_pm;
>  
> -	if (!v4l2_fh_is_singular_file(file))
> -		goto unlock;
> -
> -	if (rvin_initialize_device(file)) {
> -		v4l2_fh_release(file);
> -		ret = -ENODEV;
> +	if (v4l2_fh_is_singular_file(file)) {
> +		if (rvin_initialize_device(file)) {
> +			ret = -ENODEV;

Should you propagate the return value of rvin_initialize_device ?

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> +			goto err_open;
> +		}
>  	}
>  
> -unlock:
>  	mutex_unlock(&vin->lock);
> +
> +	return 0;
> +err_open:
> +	v4l2_fh_release(file);
> +err_pm:
> +	pm_runtime_put(vin->dev);
> +err_unlock:
> +	mutex_unlock(&vin->lock);
> +
>  	return ret;
>  }
>  
> @@ -840,6 +846,8 @@ static int rvin_release(struct file *file)
>  	if (fh_singular)
>  		rvin_power_off(vin);
>  
> +	pm_runtime_put(vin->dev);
> +

This one could also be moved after mutex_unlock().

>  	mutex_unlock(&vin->lock);
>  
>  	return ret;

-- 
Regards,

Laurent Pinchart

  reply index

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-16  1:14 [PATCH v2 0/8] rcar-vin: Merge Gen2 and Gen3 file operations Niklas Söderlund
2019-05-16  1:14 ` [PATCH v2 1/8] rcar-vin: Do not call pm_runtime_{resume,suspend}() Niklas Söderlund
2019-05-16  7:23   ` Geert Uytterhoeven
2019-05-16 11:32     ` Laurent Pinchart
2019-05-16  1:14 ` [PATCH v2 2/8] rcar-vin: Remove unneeded calls to pm_runtime_{enable,disable} Niklas Söderlund
2019-05-16  7:27   ` Geert Uytterhoeven
2019-05-16 11:34     ` Laurent Pinchart
2019-05-16  1:14 ` [PATCH v2 3/8] rcar-vin: Allow interrupting lock when trying to open the video device Niklas Söderlund
2019-05-16 11:21   ` Laurent Pinchart
2019-05-16  1:14 ` [PATCH v2 4/8] rcar-vin: Do not sync subdevice format when opening " Niklas Söderlund
2019-05-16 11:26   ` Laurent Pinchart
2019-05-16 13:25     ` Niklas Söderlund
2019-05-16  1:14 ` [PATCH v2 5/8] rcar-vin: Move pm_runtime_{get,put} out of helpers Niklas Söderlund
2019-05-16 11:39   ` Laurent Pinchart [this message]
2019-05-16  1:14 ` [PATCH v2 6/8] rcar-vin: Merge helpers dealing with powering the parallel subdevice Niklas Söderlund
2019-05-16  7:40   ` Ulrich Hecht
2019-05-16 11:44   ` Laurent Pinchart
2019-05-16  1:14 ` [PATCH v2 7/8] rcar-vin: Fold rvin_initialize_device() into rvin_open() Niklas Söderlund
2019-05-16 11:45   ` Laurent Pinchart
2019-05-16  1:14 ` [PATCH v2 8/8] rcar-vin: Merge Gen2 and Gen3 file operations Niklas Söderlund
2019-05-16 11:48   ` Laurent Pinchart

Reply instructions:

You may reply publically 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=20190516113942.GD14820@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=uli+renesas@fpond.eu \
    --cc=uli@fpond.eu \
    /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

Linux-Renesas-SoC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-renesas-soc/0 linux-renesas-soc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-renesas-soc linux-renesas-soc/ https://lore.kernel.org/linux-renesas-soc \
		linux-renesas-soc@vger.kernel.org linux-renesas-soc@archiver.kernel.org
	public-inbox-index linux-renesas-soc


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-renesas-soc


AGPL code for this site: git clone https://public-inbox.org/ public-inbox