Linux Media Controller development
 help / color / mirror / Atom feed
From: xiaolei wang <xiaolei.wang@windriver.com>
To: Dave Stevenson <dave.stevenson@raspberrypi.com>,
	Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>,
	johannes.goede@oss.qualcomm.com, jacopo@jmondi.org,
	mchehab@kernel.org, prabhakar.mahadev-lad.rj@bp.renesas.com,
	laurent.pinchart@ideasonboard.com, hverkuil+cisco@kernel.org,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jai Luthra <jai.luthra@ideasonboard.com>
Subject: Re: [PATCH] media: i2c: ov5647: use our own mutex for the ctrl lock
Date: Tue, 2 Dec 2025 11:18:03 +0800	[thread overview]
Message-ID: <faeeec10-93c5-4fcb-9977-70980a77f0f3@windriver.com> (raw)
In-Reply-To: <CAPY8ntCXb4R48bNCf0EdHeLSiA2xh62Y+=Uq9XRWNEEv2xrnHw@mail.gmail.com>

Hi

On 12/2/25 00:06, Dave Stevenson wrote:
> CAUTION: This email comes from a non Wind River email account!
> Do not click links or open attachments unless you recognize the sender and know the content is safe.
>
> Hi Sakari
>
> On Mon, 1 Dec 2025 at 13:58, Jacopo Mondi <jacopo.mondi@ideasonboard.com> wrote:
>> Hello
>>
>> On Mon, Dec 01, 2025 at 03:02:11PM +0200, Sakari Ailus wrote:
>>> Hi Hans, Xiaolei,
>>>
>>> On Mon, Dec 01, 2025 at 10:31:59AM +0100, johannes.goede@oss.qualcomm.com wrote:
>>>> Hi,
>>>>
>>>> On 1-Dec-25 1:00 AM, Xiaolei Wang wrote:
>>>>> __v4l2_ctrl_handler_setup() and __v4l2_ctrl_modify_range()
>>>>> contains an assertion to verify that the v4l2_ctrl_handler::lock
>>>>> is held, as it should only be called when the lock has already
>>>>> been acquired. Therefore use our own mutex for the ctrl lock,
>>>>> otherwise a warning will be  reported.
>>>>>
>>>>> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
>>>> Generally speaking as a default locking setup for sensor
>>>> drivers we are moving in the direction of removing driver
>>>> specific locks and instead using the control-handler
>>>> lock everywhere, including using it as the active state
>>>> lock, see e.g. :
>>>>
>>>> https://lore.kernel.org/linux-media/20250313184314.91410-14-hdegoede@redhat.com/
>>>>
>>>> which sets ov02c10->sd.state_lock = ov02c10->ctrl_handler.lock
>>>> and then removes a bunch of manual mutex_lock / unlock calls
>>>> since all ops which get called with a sd_state will already
>>>> have the lock called when operating on the active_state
>>>> (and when called in try mode they should not touch anything
>>>> needing locking).
>>>>
>>>> Note if you also want to make the ctrl_handler lock
>>>> the active state lock then you need to add calls to
>>>> v4l2_subdev_init_finalize() / v4l2_subdev_cleanup()
>>>> to allocate the active-state to probe().
>>> I agree with the above, but the driver is old and it uses its own lock to
>>> serialise access to its data structures while it uses the control lock
>>> separately. So this looks like a bugfix that could be backported.
>>>
>>> I wonder if anyone still has a system with this sensor.
>> ov5647 is the rpi camera module v1, so I guess it's still around even
>> if a bit old. Dave in cc is the expert and maintainer of this driver.
> Raspberry Pi stopped selling OV5647 in about 2016 after Omnivision
> gave a last-time-buy date in 2014/5, and we brought out the v2 camera
> module based on imx219. However there are still modules being sold
> even now - stick "OV5647" into eBay or Amazon and you'll get loads of
> hits.
>
> We still support the modules, but have little enthusiasm for investing
> significant development effort into it whilst it remains functional.
>
> As this is a bug fix for a genuine issue and has minimal impact, I'd
> be tempted to accept it. Reworking the driver to use the same mutex
> and all the subdev state can be done at a separate time (unless
> Xiaolei is really keen to do it now).
Thanks for the feedback and support. I appreciate the context about
the OV5647 module.

Currently, I think maintaining the current minimal fix is ​​better, as 
it also

facilitates stable backporting. The driver rework can be done separately

in the future

thanks

xiaolei

>
>    Dave
>
>> Jai has a series in review to upstream all the remaining BSP patches
>> for this driver.
>> https://lore.kernel.org/all/20251118-b4-rpi-ov5647-v2-0-5e78e7cb7f9b@ideasonboard.com/
>>
>> I'll cc him as well
>>
>>> --
>>> Regards,
>>>
>>> Sakari Ailus
>>>

  reply	other threads:[~2025-12-02  3:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-01  0:00 [PATCH] media: i2c: ov5647: use our own mutex for the ctrl lock Xiaolei Wang
2025-12-01  9:31 ` johannes.goede
2025-12-01 13:02   ` Sakari Ailus
2025-12-01 13:58     ` Jacopo Mondi
2025-12-01 16:06       ` Dave Stevenson
2025-12-02  3:18         ` xiaolei wang [this message]
2025-12-04 10:11 ` Sakari Ailus
2025-12-04 10:57   ` xiaolei wang

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=faeeec10-93c5-4fcb-9977-70980a77f0f3@windriver.com \
    --to=xiaolei.wang@windriver.com \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=hverkuil+cisco@kernel.org \
    --cc=jacopo.mondi@ideasonboard.com \
    --cc=jacopo@jmondi.org \
    --cc=jai.luthra@ideasonboard.com \
    --cc=johannes.goede@oss.qualcomm.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=sakari.ailus@linux.intel.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