Re: [PATCH v5 09/15] media: i2c: os05b10: Add H/V flip support

From: Sakari Ailus

Date: Fri Nov 20 2026 - 03:11:46 EST


Hi Tarang,

On Fri, Nov 20, 2026 at 07:47:58AM +0000, Tarang Raval wrote:
> Hi Sakari,
>
> Apologies for the delayed reply. I was on leave during the Diwali holidays.
>
> > On Fri, Oct 30, 2026 at 04:17:58PM +0530, Tarang Raval wrote:
> > > Add HFLIP and VFLIP controls, lock them while streaming, and update
> > > the reported Bayer format based on the flip state.
> > >
> > > Signed-off-by: Tarang Raval <tarang.raval@xxxxxxxxxxxxxxxxx>
> > > ---
>
> ...
>
> > > +static u32 os05b10_get_format_code(struct os05b10 *os05b10)
> > > +{
> > > + static const u32 codes[2][2] = {
> > > + { MEDIA_BUS_FMT_SBGGR10_1X10, MEDIA_BUS_FMT_SGBRG10_1X10, },
> > > + { MEDIA_BUS_FMT_SGRBG10_1X10, MEDIA_BUS_FMT_SRGGB10_1X10, },
> > > + };
> > > +
> > > + return codes[os05b10->vflip->val][os05b10->hflip->val];
> >
> > Note that accessing the control values requires holding the handler's mutex
> > here. That's not the case when called from enum_mbus_code() I think.
>
> I checked this, and the handler's mutex is held in all three callers.
>
> The driver sets sd.state_lock = handler.lock before calling
> v4l2_subdev_init_finalize() (this has been there since the initial driver
> patch). With that set, __v4l2_subdev_state_alloc() makes every state
> (active and per-file-handle TRY) use the handler's mutex:
>
> if (sd->state_lock)
> state->lock = sd->state_lock;
>
> The callers then lock that state:
>
> - enum_mbus_code(): subdev_do_ioctl_lock() calls
> v4l2_subdev_lock_state(state) before subdev_do_ioctl(), which calls
> the op, and unlocks it afterwards.
> - init_state(): __v4l2_subdev_state_alloc() calls
> v4l2_subdev_lock_state(state) around ->init_state().
> - set_ctrl(): called with the handler's mutex held by the control core.
>
> So the control values are read under the handler's lock and no extra
> locking is needed in os05b10_get_format_code(). Please let me know if I
> missed a path where the state is not locked.

Ack, thanks for checking!

Can you post a fixup patch to the issue in the second-last patch that I can
squash to it? (I'd just print the frequency in Hz, there's no reason to use
MHz here.)

--
Regards,

Sakari Ailus