Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Bhavin Sharma" <bhavin.sharma@siliconsignals.io>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
	media-ci@linuxtv.org
Subject: Re: [PATCH v2 2/2] media: i2c: add os05e10 image sensor driver
Date: Fri, 04 Dec 2026 13:57:03 +0000	[thread overview]
Message-ID: <sashiko-outbox-249911@kernel.org> (raw)
In-Reply-To: <20261204132832.130979-3-bhavin.sharma@siliconsignals.io>

Thank you for your contribution! Sashiko AI review found 7 potential
issues to consider:
- [Medium] media: i2c: os05e10: 32-bit integer overflow in
  os05e10_pixel_rate()
- [Medium] media: i2c: os05e10: missing V4L2_CID_HBLANK control in
  os05e10_init_controls()
- [Medium] media: i2c: os05e10: os05e10_disable_streams() desyncs stream
  state on error
- [Medium] media: i2c: os05e10: Bayer format mismatch between commit
  message and code
- [Medium] media: os05e10: unconditional os05e10_power_off() on probe
  error
- [Low] media: i2c: os05e10: os05e10_set_pad_format() leaves
  ycbcr_enc/flags unset
- [Low] media: i2c: os05e10: stray semicolon, unused code, and Kconfig
  indentation
--

commit 71a3e0effda749e1cf7f74b7c3298d02c8541eec
Author: Bhavin Sharma <bhavin.sharma@siliconsignals.io>

media: i2c: add os05e10 image sensor driver

This commit adds a V4L2 subdevice driver for the OmniVision OS05E10 CMOS
image sensor supporting 2592x1944 output with exposure, gain, and vertical
blanking controls.

> diff --git a/drivers/media/i2c/os05e10.c b/drivers/media/i2c/os05e10.c
> new file mode 100644
> index 0000000000000..daf5297a6fad5
> --- /dev/null
> +++ b/drivers/media/i2c/os05e10.c

[ ... ]

> +static const u32 os05e10_mbus_codes[] = {
> +	MEDIA_BUS_FMT_SRGGB10_1X10,
> +};

[Severity: Medium]
Does the sensor output SRGGB10 or SBGGR10?  The commit message says
SBGGR10, while os05e10_mbus_codes[] advertises
MEDIA_BUS_FMT_SRGGB10_1X10.  If the hardware outputs SBGGR10, reporting
SRGGB10 swaps red and blue channels in downstream debayering.

[ ... ]

> +static u64 os05e10_pixel_rate(const struct os05e10_mode *mode)
> +{
> +	/* pixel_rate = link_freq * 2 * nr_of_lanes / bits_per_sample */
> +	return div_u64(OS05E10_LINK_FREQ_720MHZ * 2 * OS05E10_DATA_LANES,
> +		       mode->bpp);
> +}

[Severity: Medium]
Can OS05E10_LINK_FREQ_720MHZ * 2 * OS05E10_DATA_LANES overflow on 32-bit
architectures?  HZ_PER_MHZ is 1000000UL, so the product 5,760,000,000 is
evaluated in 32-bit unsigned long before widening to u64 for div_u64().

That triggers a compile-time overflow warning and wraps V4L2_CID_PIXEL_RATE
from 576,000,000 Hz to 146,503,270 Hz.  Using 64-bit arithmetic (such as
720ULL * HZ_PER_MHZ or link_freq_menu_items[0]) avoids the wrap.

[ ... ]

> +	vblank_def = mode->vts - mode->height;
> +	os05e10->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &os05e10_ctrl_ops,
> +					    V4L2_CID_VBLANK,
> +					    OS05E10_VTS_BASE - mode->height,
> +					    OS05E10_VTS_BASE - mode->height +
> +					    OS05E10_VBLANK_MAX,
> +					    1, vblank_def);

[Severity: Medium]
Should os05e10_init_controls() also register V4L2_CID_HBLANK?  Raw camera
sensor drivers are expected to expose V4L2_CID_HBLANK alongside
V4L2_CID_VBLANK and V4L2_CID_PIXEL_RATE so userspace stacks such as
libcamera can compute line length, exposure duration, and frame interval.

OS05E10_REG_VTS and OS05E10_REG_HTS are defined earlier in the file but
never used.

[ ... ]

> +static int os05e10_disable_streams(struct v4l2_subdev *sd,
> +				   struct v4l2_subdev_state *state, u32 pad,
> +				   u64 streams_mask)
> +{
> +	struct os05e10 *os05e10 = to_os05e10(sd);
> +	int ret;
> +
> +	ret = cci_write(os05e10->cci, OS05E10_REG_STREAM_CTRL,
> +			OS05E10_STREAM_CTRL_OFF, NULL);
> +	if (ret)
> +		dev_err(os05e10->dev, "Failed to stop stream\n");
> +
> +	pm_runtime_put(os05e10->dev);
> +
> +	return ret;
> +}

[Severity: Medium]
Does returning a non-zero ret after pm_runtime_put() leave V4L2 stream
state out of sync with runtime PM?  When cci_write() fails, the sensor is
still powered down, but v4l2_subdev_disable_streams() skips
v4l2_subdev_set_streams_enabled(..., false) on error.

Subsequent enable calls then fail with -EALREADY, and a retry of disable
runs pm_runtime_put() a second time and underflows usage_count.  Returning
0 after logging the error and calling pm_runtime_put() keeps both in sync.

[ ... ]

> +	fmt->format.code = os05e10_mbus_codes[0];
> +	fmt->format.width = mode->width;
> +	fmt->format.height = mode->height;
> +	fmt->format.field = V4L2_FIELD_NONE;
> +	fmt->format.colorspace = V4L2_COLORSPACE_RAW;
> +	fmt->format.quantization = V4L2_QUANTIZATION_FULL_RANGE;
> +	fmt->format.xfer_func = V4L2_XFER_FUNC_NONE;
> +
> +	*format = fmt->format;

[Severity: Low]
Should os05e10_set_pad_format() also initialize fmt->format.ycbcr_enc and
clear fmt->format.flags?  VIDIOC_SUBDEV_S_FMT only zeroes the reserved
fields, so arbitrary values passed by userspace in ycbcr_enc or flags are
stored in the subdev state and returned on VIDIOC_SUBDEV_G_FMT.

[ ... ]

> +error_out:
> +	v4l2_fwnode_endpoint_free(&bus_cfg);
> +
> +	return ret;
> +};

[Severity: Low]
There is a stray semicolon after the closing brace of
os05e10_parse_endpoint().  A few other small cleanups: struct os05e10 has
an unused vblank pointer, linux/bitops.h and linux/cleanup.h are included
without being used, and the VIDEO_OS05E10 entry in
drivers/media/i2c/Kconfig uses spaces instead of tabs for indentation.

[ ... ]

> +	pm_runtime_set_active(os05e10->dev);
> +	pm_runtime_enable(os05e10->dev);
> +
> +	ret = v4l2_async_register_subdev_sensor(&os05e10->sd);
> +	if (ret) {
> +		dev_err_probe(os05e10->dev, ret,
> +			      "failed to register os05e10 sub-device\n");
> +		goto error_subdev_cleanup;
> +	}
> +
> +	pm_runtime_idle(os05e10->dev);
> +
> +	return 0;
> +
> +error_subdev_cleanup:
> +	v4l2_subdev_cleanup(&os05e10->sd);
> +	pm_runtime_disable(os05e10->dev);
> +	pm_runtime_set_suspended(os05e10->dev);
> +
> +error_media_entity:
> +	media_entity_cleanup(&os05e10->sd.entity);
> +
> +error_handler_free:
> +	v4l2_ctrl_handler_free(os05e10->sd.ctrl_handler);
> +
> +error_power_off:
> +	os05e10_power_off(os05e10->dev);

[Severity: Medium]
Can error_power_off call os05e10_power_off() a second time if the device
runtime-suspends while v4l2_async_register_subdev_sensor() is running?

Runtime PM is enabled with usage_count at 0 before registration.  If an
async notifier exposes /dev/v4l-subdevX and then fails a later step such as
media_device_register(), a concurrent VIDIOC_S_CTRL can suspend the sensor
before the probe error path runs:

CPU0 (os05e10_probe)              CPU1 (VIDIOC_S_CTRL / kworker)
pm_runtime_set_active()
pm_runtime_enable()
v4l2_async_register_subdev_sensor()
  ...
  v4l2_device_register_subdev_nodes()
                                  os05e10_set_ctrl()
                                    pm_runtime_get_if_active() (0 -> 1)
                                    pm_runtime_put() (1 -> 0)
                                  pm_runtime_work -> os05e10_power_off()
  media_device_register() fails
error_subdev_cleanup:
  pm_runtime_disable()
  pm_runtime_set_suspended()
error_power_off:
  os05e10_power_off()             <-- second clk/regulator disable

That causes unbalanced clk_disable_unprepare() and regulator_bulk_disable()
calls and WARN splats.  Calling pm_runtime_get_noresume() before
pm_runtime_enable() (paired with pm_runtime_put() on success and
pm_runtime_put_noidle() on error) prevents runtime suspend during probe.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204132832.130979-1-bhavin.sharma@siliconsignals.io?part=2

      reply	other threads:[~2026-12-04 13:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 13:28 [PATCH v2 0/2] media: i2c: Add os05e10 camera sensor driver Bhavin Sharma
2026-12-04 13:28 ` [PATCH v2 1/2] dt-bindings: media: i2c: Add os05e10 sensor Bhavin Sharma
2026-12-04 13:41   ` sashiko-bot
2026-12-04 13:28 ` [PATCH v2 2/2] media: i2c: add os05e10 image sensor driver Bhavin Sharma
2026-12-04 13:57   ` sashiko-bot [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=sashiko-outbox-249911@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bhavin.sharma@siliconsignals.io \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=media-ci@linuxtv.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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