All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>,
	linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH v5 10/12] media: rcar-vin: Only expose VIN controls
Date: Fri, 13 Jun 2025 12:16:59 +0200	[thread overview]
Message-ID: <20250613101659.GC1002387@ragnatech.se> (raw)
In-Reply-To: <20250612232820.GG10542@pendragon.ideasonboard.com>

Hi Laurent,

Thanks for your feedback.

On 2025-06-13 02:28:20 +0300, Laurent Pinchart wrote:
> Hi Niklas,
> 
> Thank you for the patch.
> 
> On Fri, Jun 06, 2025 at 08:26:04PM +0200, Niklas Söderlund wrote:
> > Before moving Gen2 to media controller simplify the creation of controls
> > by not exposing the sub-device controls on the video device. This could
> > be done while enabling media controller but doing it separately reduces
> > the changes needed to do so.
> > 
> > The rework also allows the cleanup and remove paths to be simplified by
> > folding all special cases into the only remaining call site.
> > 
> > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> > ---
> > * Changes since v4
> > - Broken out from a larger patch.
> > ---
> >  .../platform/renesas/rcar-vin/rcar-core.c     | 84 ++++---------------
> >  1 file changed, 18 insertions(+), 66 deletions(-)
> > 
> > diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-core.c b/drivers/media/platform/renesas/rcar-vin/rcar-core.c
> > index 8cb3d0a3520f..597e868a6bc5 100644
> > --- a/drivers/media/platform/renesas/rcar-vin/rcar-core.c
> > +++ b/drivers/media/platform/renesas/rcar-vin/rcar-core.c
> > @@ -365,14 +365,6 @@ static int rvin_group_parse_of(struct rvin_dev *vin, unsigned int port,
> >  	return ret;
> >  }
> >  
> > -static void rvin_group_notifier_cleanup(struct rvin_dev *vin)
> > -{
> > -	if (&vin->v4l2_dev == vin->group->notifier.v4l2_dev) {
> > -		v4l2_async_nf_unregister(&vin->group->notifier);
> > -		v4l2_async_nf_cleanup(&vin->group->notifier);
> > -	}
> > -}
> > -
> >  static int rvin_parallel_parse_of(struct rvin_dev *vin)
> >  {
> >  	struct fwnode_handle *fwnode __free(fwnode_handle) = NULL;
> > @@ -510,7 +502,7 @@ static void rvin_free_controls(struct rvin_dev *vin)
> >  	vin->vdev.ctrl_handler = NULL;
> >  }
> >  
> > -static int rvin_create_controls(struct rvin_dev *vin, struct v4l2_subdev *subdev)
> > +static int rvin_create_controls(struct rvin_dev *vin)
> >  {
> >  	int ret;
> >  
> > @@ -528,16 +520,6 @@ static int rvin_create_controls(struct rvin_dev *vin, struct v4l2_subdev *subdev
> >  		return ret;
> >  	}
> >  
> 
> Now that the control handler for the video device only has a single
> control, you can reduce the number of buckets:
> 
> -	ret = v4l2_ctrl_handler_init(&vin->ctrl_handler, 16);
> +	ret = v4l2_ctrl_handler_init(&vin->ctrl_handler, 1);

Agreed.

> 
> > -	/* For the non-MC mode add controls from the subdevice. */
> > -	if (subdev) {
> > -		ret = v4l2_ctrl_add_handler(&vin->ctrl_handler,
> > -					    subdev->ctrl_handler, NULL, true);
> > -		if (ret < 0) {
> > -			rvin_free_controls(vin);
> > -			return ret;
> > -		}
> > -	}
> > -
> >  	vin->vdev.ctrl_handler = &vin->ctrl_handler;
> >  
> >  	return 0;
> > @@ -627,11 +609,6 @@ static int rvin_parallel_subdevice_attach(struct rvin_dev *vin,
> >  	if (ret < 0 && ret != -ENOIOCTLCMD)
> >  		return ret;
> >  
> > -	/* Add the controls */
> > -	ret = rvin_create_controls(vin, subdev);
> > -	if (ret < 0)
> > -		return ret;
> > -
> >  	vin->parallel.subdev = subdev;
> >  
> >  	return 0;
> > @@ -885,34 +862,17 @@ static int rvin_csi2_setup_links(struct rvin_group *group)
> >  	return ret;
> >  }
> >  
> > -static void rvin_csi2_cleanup(struct rvin_dev *vin)
> > -{
> > -	rvin_group_notifier_cleanup(vin);
> > -	rvin_free_controls(vin);
> > -}
> > -
> >  static int rvin_csi2_init(struct rvin_dev *vin)
> >  {
> >  	int ret;
> >  
> > -
> > -	ret = rvin_create_controls(vin, NULL);
> > -	if (ret < 0)
> > -		return ret;
> > -
> >  	ret = rvin_group_get(vin, rvin_csi2_setup_links, &rvin_csi2_media_ops);
> >  	if (ret)
> > -		goto err_controls;
> > +		return ret;
> >  
> >  	ret = rvin_group_notifier_init(vin, 1, RVIN_CSI_MAX);
> >  	if (ret)
> > -		goto err_group;
> > -
> > -	return 0;
> > -err_group:
> > -	rvin_group_put(vin);
> > -err_controls:
> > -	rvin_free_controls(vin);
> > +		rvin_group_put(vin);
> >  
> >  	return ret;
> >  }
> > @@ -966,34 +926,17 @@ static int rvin_isp_setup_links(struct rvin_group *group)
> >  	return ret;
> >  }
> >  
> > -static void rvin_isp_cleanup(struct rvin_dev *vin)
> > -{
> > -	rvin_group_notifier_cleanup(vin);
> > -	rvin_free_controls(vin);
> > -}
> > -
> >  static int rvin_isp_init(struct rvin_dev *vin)
> >  {
> >  	int ret;
> >  
> > -
> > -	ret = rvin_create_controls(vin, NULL);
> > -	if (ret < 0)
> > -		return ret;
> > -
> >  	ret = rvin_group_get(vin, rvin_isp_setup_links, NULL);
> >  	if (ret)
> > -		goto err_controls;
> > +		return ret;
> >  
> >  	ret = rvin_group_notifier_init(vin, 2, RVIN_ISP_MAX);
> >  	if (ret)
> > -		goto err_group;
> > -
> > -	return 0;
> > -err_group:
> > -	rvin_group_put(vin);
> > -err_controls:
> > -	rvin_free_controls(vin);
> > +		rvin_group_put(vin);
> >  
> >  	return ret;
> >  }
> > @@ -1372,6 +1315,10 @@ static int rcar_vin_probe(struct platform_device *pdev)
> >  	if (ret)
> >  		return ret;
> >  
> > +	ret = rvin_create_controls(vin);
> > +	if (ret < 0)
> > +		return ret;
> 
> Don't you need to call rvin_dma_unregister() here ?

Indeed, there is a similar issue where rvin_id_put() is not called where 
it should introduced by this series.

> 
> > +
> >  	if (vin->info->use_isp) {
> >  		ret = rvin_isp_init(vin);
> >  	} else if (vin->info->use_mc) {
> > @@ -1390,6 +1337,7 @@ static int rcar_vin_probe(struct platform_device *pdev)
> >  	}
> >  
> >  	if (ret) {
> > +		rvin_free_controls(vin);
> >  		rvin_dma_unregister(vin);
> >  		rvin_id_put(vin);
> >  		return ret;
> 
> Error labels at the end of the function will make this more manageable.

I agree, I have added a small patch early in this series that converts 
this error path to use labels and fixed the missing call to 
rvin_id_put() and rvin_dma_unregister() in the error paths using labels 
as you suggest it turns out nicer.

> 
> > @@ -1409,13 +1357,17 @@ static void rcar_vin_remove(struct platform_device *pdev)
> >  
> >  	rvin_v4l2_unregister(vin);
> >  
> > -	if (vin->info->use_isp)
> > -		rvin_isp_cleanup(vin);
> > -	else if (vin->info->use_mc)
> > -		rvin_csi2_cleanup(vin);
> > +	if (vin->info->use_isp || vin->info->use_mc) {
> > +		if (&vin->v4l2_dev == vin->group->notifier.v4l2_dev) {
> > +			v4l2_async_nf_unregister(&vin->group->notifier);
> > +			v4l2_async_nf_cleanup(&vin->group->notifier);
> > +		}
> > +	}
> >  
> >  	rvin_group_put(vin);
> >  
> > +	rvin_free_controls(vin);
> > +
> >  	rvin_id_put(vin);
> >  
> >  	rvin_dma_unregister(vin);
> 
> -- 
> Regards,
> 
> Laurent Pinchart

-- 
Kind Regards,
Niklas Söderlund

  reply	other threads:[~2025-06-13 10:17 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-06 18:25 [PATCH v5 00/12] media: rcar-vin: Unify notifiers and enable MC on Gen2 Niklas Söderlund
2025-06-06 18:25 ` [PATCH v5 01/12] media: rcar-vin: Use correct count of remote subdevices Niklas Söderlund
2025-06-09  9:39   ` Sakari Ailus
2025-06-09  9:41     ` Sakari Ailus
2025-06-06 18:25 ` [PATCH v5 02/12] media: rcar-vin: Store platform info with group structure Niklas Söderlund
2025-06-12  0:19   ` Laurent Pinchart
2025-06-06 18:25 ` [PATCH v5 03/12] media: rcar-vin: Change link setup argument Niklas Söderlund
2025-06-12  0:31   ` Laurent Pinchart
2025-06-06 18:25 ` [PATCH v5 04/12] media: rcar-vin: Generate a VIN group ID for Gen2 Niklas Söderlund
2025-06-06 18:25 ` [PATCH v5 05/12] media: rcar-vin: Prepare for unifying all v4l-async notifiers Niklas Söderlund
2025-06-06 18:26 ` [PATCH v5 06/12] media: rcar-vin: Improve error paths for parallel devices Niklas Söderlund
2025-06-12  0:22   ` Laurent Pinchart
2025-06-06 18:26 ` [PATCH v5 07/12] media: rcar-vin: Merge all notifiers Niklas Söderlund
2025-06-12 23:15   ` Laurent Pinchart
2025-06-18  7:44     ` Geert Uytterhoeven
2025-06-18  8:58       ` Laurent Pinchart
2025-06-18 10:59         ` Geert Uytterhoeven
2025-06-18 11:03           ` Wolfram Sang
2025-06-06 18:26 ` [PATCH v5 08/12] media: rcar-vin: Always create a media pad Niklas Söderlund
2025-06-12  0:25   ` Laurent Pinchart
2025-06-06 18:26 ` [PATCH v5 09/12] media: rcar-vin: Remove NTSC workaround Niklas Söderlund
2025-06-12 23:17   ` Laurent Pinchart
2025-06-06 18:26 ` [PATCH v5 10/12] media: rcar-vin: Only expose VIN controls Niklas Söderlund
2025-06-12 23:28   ` Laurent Pinchart
2025-06-13 10:16     ` Niklas Söderlund [this message]
2025-06-06 18:26 ` [PATCH v5 11/12] media: rcar-vin: Enable media-graph on Gen2 Niklas Söderlund
2025-06-12 23:53   ` Laurent Pinchart
2025-06-13  9:38     ` Niklas Söderlund
2025-06-06 18:26 ` [PATCH v5 12/12] media: rcar-vin: Fold event notifier into only user Niklas Söderlund
2025-06-12  0:28   ` Laurent Pinchart
2025-06-12  7:22     ` Niklas Söderlund
2025-06-12  9:44       ` Laurent Pinchart
2025-06-12  9:56         ` Niklas Söderlund

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=20250613101659.GC1002387@ragnatech.se \
    --to=niklas.soderlund+renesas@ragnatech.se \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tomi.valkeinen+renesas@ideasonboard.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.