Devicetree
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Sylvain Petinot <sylvain.petinot@foss.st.com>
Cc: benjamin.mugnier@foss.st.com, mchehab@kernel.org,
	robh@kernel.org, krzysztof.kozlowski+dt@linaro.org,
	conor+dt@kernel.org, laurent.pinchart@ideasonboard.com,
	linux-media@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, tomm.merciai@gmail.com
Subject: Re: [PATCH v6 2/2] media: i2c: Add driver for ST VD56G3 camera sensor
Date: Mon, 5 May 2025 07:24:36 +0000	[thread overview]
Message-ID: <aBhntPR4Wbnz3oJo@kekkonen.localdomain> (raw)
In-Reply-To: <4c8a1359-e7e3-4e1c-a159-e761ed749712@foss.st.com>

Hi Sylvain,

On Fri, May 02, 2025 at 09:39:27PM +0200, Sylvain Petinot wrote:
> Hi Sakari,
> 
> Le 02/05/2025 à 00:20, Sakari Ailus a écrit :
> > Hi Sylvain,
> > 
> > On Wed, Apr 30, 2025 at 04:19:14PM +0200, Sylvain Petinot wrote:
> > > > > +static int vd56g3_subdev_init(struct vd56g3 *sensor)
> > > > > +{
> > > > > +	int ret;
> > > > > +
> > > > > +	/* Init remaining sub device ops */
> > > > > +	sensor->sd.internal_ops = &vd56g3_internal_ops;
> > > > > +	sensor->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
> > > > > +	sensor->sd.entity.ops = &vd56g3_subdev_entity_ops;
> > > > > +
> > > > > +	/* Init source pad */
> > > > > +	sensor->pad.flags = MEDIA_PAD_FL_SOURCE;
> > > > > +	sensor->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
> > > > > +	ret = media_entity_pads_init(&sensor->sd.entity, 1, &sensor->pad);
> > > > > +	if (ret) {
> > > > > +		dev_err(sensor->dev, "Failed to init media entity : %d", ret);
> > > > > +		return ret;
> > > > > +	}
> > > > > +
> > > > > +	/* Init controls */
> > > > > +	ret = vd56g3_init_controls(sensor);
> > > > > +	if (ret) {
> > > > > +		dev_err(sensor->dev, "Controls initialization failed %d", ret);
> > > > > +		goto err_media;
> > > > > +	}
> > > > > +
> > > > > +	/* Init vd56g3 struct : default resolution + raw8 */
> > > > > +	sensor->sd.state_lock = sensor->ctrl_handler.lock;
> > > > > +	ret = v4l2_subdev_init_finalize(&sensor->sd);
> > > > > +	if (ret) {
> > > > > +		dev_err(sensor->dev, "subdev init error: %d", ret);
> > > > > +		goto err_ctrls;
> > > > > +	}
> > > > > +
> > > > > +	return vd56g3_update_controls(sensor);
> > > > 
> > > > You're not holding the control handler's lock in the above call.
> > > 
> > > If your comment is related to the fact that 'vd56g3_update_controls() can
> > > fail and that we do not free control handler not cleanup media entity, it's
> > > fixed in V7.
> > 
> > It's not. The access to the control handler is serialised by a mutex and
> > you're not holding that mutex whilst calling vd56g3_update_controls() here.
> > The same issue exists in accessing sub-device state.
> > 
> 
> I'm sorry, I missed that ...
> That should be better with something like :
> 
> 	state = v4l2_subdev_lock_and_get_active_state(&sensor->sd);
> 	ret = vd56g3_update_controls(sensor);
> 	v4l2_subdev_unlock_state(state);

Correct.

> 
> I'll prepare and push a V8.

Thanks!

-- 
Regards,

Sakari Ailus

      reply	other threads:[~2025-05-05  8:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-27 19:30 [PATCH v6 0/2] media: Add driver for ST VD56G3 camera sensor Sylvain Petinot
2025-04-27 19:30 ` [PATCH v6 1/2] media: dt-bindings: Add " Sylvain Petinot
2025-04-27 19:30 ` [PATCH v6 2/2] media: i2c: Add driver for " Sylvain Petinot
2025-04-29 10:23   ` Sakari Ailus
2025-04-30 14:19     ` Sylvain Petinot
2025-05-01 22:20       ` Sakari Ailus
2025-05-02 19:39         ` Sylvain Petinot
2025-05-05  7:24           ` Sakari Ailus [this message]

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=aBhntPR4Wbnz3oJo@kekkonen.localdomain \
    --to=sakari.ailus@linux.intel.com \
    --cc=benjamin.mugnier@foss.st.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=robh@kernel.org \
    --cc=sylvain.petinot@foss.st.com \
    --cc=tomm.merciai@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox