Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Hikmah Gumelar" <hikmahgumelar@gmail.com>
Cc: devicetree@vger.kernel.org, linux-clk@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org, media-ci@linuxtv.org
Subject: Re: [PATCH v5 5/7] media: i2c: add ov12a10 image sensor driver
Date: Fri, 27 Nov 2026 13:59:45 +0000	[thread overview]
Message-ID: <sashiko-outbox-237527@kernel.org> (raw)
In-Reply-To: <20261127134507.125513-6-hikmahgumelar@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] media: i2c: ov12a10: self-deadlock on ov12a10->mutex in
  ov12a10_set_format()
- [Low] media: i2c: ov12a10: Kconfig selects unused V4L2_CCI_I2C while
  duplicating CCI
- [Low] media: i2c: ov12a10: ov12a10_set_ctrl() skips register writes
  when !CONFIG_PM
--

commit a28b7978efda2c7b1cde0c21ec38f6018f80694c
Author: Hikmah Gumelar <hikmahgumelar@gmail.com>

media: i2c: add ov12a10 image sensor driver

This commit adds a V4L2 subdevice driver for the OmniVision OV12A10 MIPI
CSI-2 CMOS image sensor.

> diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
> index 4c622e5eef73f..338244aa23eb4 100644
> --- a/drivers/media/i2c/Kconfig
> +++ b/drivers/media/i2c/Kconfig
> @@ -538,6 +538,16 @@ config VIDEO_OV08X40
>  	  To compile this driver as a module, choose M here: the
>  	  module will be called ov08x40.
>  
> +config VIDEO_OV12A10
> +	tristate "OmniVision OV12A10 sensor support"
> +	select V4L2_CCI_I2C
> +	help
> +	  This is a Video4Linux2 sensor-level driver for the OmniVision
> +	  OV12A10 12MP camera.
> +
> +	  To compile this driver as a module, choose M here: the
> +	  module will be called ov12a10.
> +
>  config VIDEO_OV13858
>  	tristate "OmniVision OV13858 sensor support"
>  	help
> diff --git a/drivers/media/i2c/ov12a10.c b/drivers/media/i2c/ov12a10.c
> new file mode 100644
> index 0000000000000..99580ceedceff
> --- /dev/null
> +++ b/drivers/media/i2c/ov12a10.c
> @@ -0,0 +1,770 @@

[ ... ]

> +static int ov12a10_read_reg(struct ov12a10 *ov12a10, u16 reg, u32 len, u32 *val)
> +{
> +	struct i2c_client *client = v4l2_get_subdevdata(&ov12a10->sd);
> +	struct i2c_msg msgs[2];
> +	u8 addr_buf[2], data_buf[4] = { 0 };
> +	int ret;
> +
> +	put_unaligned_be16(reg, addr_buf);
> +	msgs[0].addr = client->addr;
> +	msgs[0].flags = 0;
> +	msgs[0].len = 2;
> +	msgs[0].buf = addr_buf;
> +	msgs[1].addr = client->addr;
> +	msgs[1].flags = I2C_M_RD;
> +	msgs[1].len = len;
> +	msgs[1].buf = &data_buf[4 - len];
> +	ret = i2c_transfer(client->adapter, msgs, 2);
> +	if (ret != 2)
> +		return ret < 0 ? ret : -EIO;
> +	*val = get_unaligned_be32(data_buf);
> +	return 0;
> +}
> +
> +static int ov12a10_write_reg(struct ov12a10 *ov12a10, u16 reg, u32 len, u32 val)
> +{
> +	struct i2c_client *client = v4l2_get_subdevdata(&ov12a10->sd);
> +	u8 buf[6];
> +	int ret;
> +
> +	put_unaligned_be16(reg, buf);
> +	put_unaligned_be32(val << (8 * (4 - len)), buf + 2);
> +	ret = i2c_master_send(client, buf, len + 2);
> +	return ret == len + 2 ? 0 : (ret < 0 ? ret : -EIO);
> +}
> +
> +static int ov12a10_write_regs(struct ov12a10 *ov12a10, const struct ov12a10_reg *regs, u32 len)
> +{
> +	u32 i;
> +	int ret;
> +
> +	for (i = 0; i < len; i++) {
> +		ret = ov12a10_write_reg(ov12a10, regs[i].address, 1, regs[i].val);
> +		if (!ret && regs[i].address == 0x0103)
> +			usleep_range(5000, 6000);
> +		if (ret)
> +			return ret;
> +	}
> +	return 0;
> +}

[Severity: Low]
Why does VIDEO_OV12A10 select V4L2_CCI_I2C in Kconfig while the driver
open-codes its own 16-bit big-endian I2C register access in
ov12a10_read_reg(), ov12a10_write_reg() and ov12a10_write_regs() instead of
using the V4L2 CCI helpers?

[ ... ]

> +static int ov12a10_set_ctrl(struct v4l2_ctrl *ctrl)
> +{
> +	struct ov12a10 *ov12a10 = container_of(ctrl->handler, struct ov12a10, ctrl_handler);
> +	int ret = 0;
> +
> +	if (ctrl->id == V4L2_CID_VBLANK) {
> +		s64 exp_max = ov12a10->cur_mode->height + ctrl->val - 4;
> +
> +		ret = __v4l2_ctrl_modify_range(ov12a10->exposure, 4, exp_max, 1,
> +					       min_t(s64, 2400, exp_max));
> +		if (ret)
> +			return ret;
> +	}
> +	if (pm_runtime_get_if_active(ov12a10->dev) <= 0)
> +		return 0;

[Severity: Low]
Does this pm_runtime_get_if_active() check skip all control register writes
when CONFIG_PM is disabled?

When CONFIG_PM is disabled, ov12a10_probe() leaves the sensor powered on
and pm_runtime_get_if_active() returns -EINVAL, so ov12a10_set_ctrl()
returns early without programming exposure, gain, vblank or test pattern
registers.  Using pm_runtime_get_if_in_use() == 0 avoids skipping register
writes when runtime PM is disabled.

[ ... ]

> +static int ov12a10_set_format(struct v4l2_subdev *sd,
> +			      const struct v4l2_subdev_client_info *ci,
> +			      struct v4l2_subdev_state *sd_state,
> +			      struct v4l2_subdev_format *fmt)
> +{
> +	struct ov12a10 *ov12a10 = to_ov12a10(sd);
> +
> +	mutex_lock(&ov12a10->mutex);
> +	if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE && ov12a10->streaming) {
> +		mutex_unlock(&ov12a10->mutex);
> +		return -EBUSY;
> +	}
> +
> +	ov12a10_update_pad_format(&default_mode, &fmt->format);
> +	if (fmt->which != V4L2_SUBDEV_FORMAT_TRY)
> +		ov12a10->cur_mode = &default_mode;
> +	*v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format;
> +	mutex_unlock(&ov12a10->mutex);
> +
> +	return 0;
> +}

[Severity: High]
Does ov12a10_set_format() self-deadlock on ov12a10->mutex?

ov12a10_probe() sets ov12a10->sd.state_lock = &ov12a10->mutex before calling
v4l2_subdev_init_finalize(), so the V4L2 subdev core already acquires
ov12a10->mutex via v4l2_subdev_lock_state(state) before invoking .set_fmt.
Any VIDIOC_SUBDEV_S_FMT ioctl will hang permanently on this second
mutex_lock(&ov12a10->mutex).

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261127134507.125513-1-hikmahgumelar@gmail.com?part=5

  reply	other threads:[~2026-11-27 13:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 13:45 [PATCH v5 0/7] Enable front and rear cameras on Xiaomi Mi A1 (tissot) Hikmah Gumelar
2026-11-27 13:45 ` [PATCH v5 1/7] clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent Hikmah Gumelar
2026-11-27 13:45 ` [PATCH v5 2/7] media: dt-bindings: media: i2c: add Samsung S5K5E8 Hikmah Gumelar
2026-11-27 13:45 ` [PATCH v5 3/7] media: i2c: add s5k5e8 image sensor driver Hikmah Gumelar
2026-11-27 14:01   ` sashiko-bot
2026-11-27 13:45 ` [PATCH v5 4/7] media: dt-bindings: media: i2c: add OmniVision OV12A10 Hikmah Gumelar
2026-11-27 13:45 ` [PATCH v5 5/7] media: i2c: add ov12a10 image sensor driver Hikmah Gumelar
2026-11-27 13:59   ` sashiko-bot [this message]
2026-11-27 13:45 ` [PATCH v5 6/7] arm64: dts: qcom: msm8953: add CAMSS node and MCLK pinctrl states Hikmah Gumelar
2026-11-27 13:45 ` [PATCH v5 7/7] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar
2026-11-27 13:58   ` sashiko-bot

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-237527@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=hikmahgumelar@gmail.com \
    --cc=linux-clk@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