From: sashiko-bot@kernel.org
To: "Sergey Lebedev" <lsa.uz@pm.me>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org,
media-ci@linuxtv.org
Subject: Re: [PATCH v3 2/3] media: i2c: Add Sony IMX681 sensor driver
Date: Wed, 09 Sep 2026 20:52:43 +0000 [thread overview]
Message-ID: <20260909205244.EDB941F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260909203717.90605-3-lsa.uz@pm.me>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Hardware exposure register becomes out of sync with V4L2 state when VBLANK is changed.
- [Medium] Independent toggling of group hold register defeats atomic parameter updates.
--
commit 7db2a0f5a0754b78ccc388a5ff14535efd86e6ff
Author: Andre Gilerson <andre.gilerson@gmail.com>
media: i2c: Add Sony IMX681 sensor driver
This commit adds a new V4L2 I2C sensor driver for the Sony IMX681 camera,
which is used on the Surface Pro 11 for Business. It implements standard
functionality including register initialization, the streams API, and
runtime PM.
> diff --git a/drivers/media/i2c/imx681.c b/drivers/media/i2c/imx681.c
> new file mode 100644
> index 0000000000000..eba792ca18ef4
> --- /dev/null
> +++ b/drivers/media/i2c/imx681.c
[ ... ]
> +static int imx681_set_ctrl(struct v4l2_ctrl *ctrl)
> +{
> + struct imx681 *imx681 = container_of(ctrl->handler, struct imx681,
> + ctrl_handler);
> + s64 exposure_max;
> + int pm_status;
> + int ret = 0;
> +
> + /* Update exposure max when VBLANK changes (even when not streaming) */
> + if (ctrl->id == V4L2_CID_VBLANK) {
> + exposure_max = IMX681_HEIGHT + ctrl->val - IMX681_EXPOSURE_OFFSET;
> + __v4l2_ctrl_modify_range(imx681->exposure,
> + IMX681_EXPOSURE_MIN, exposure_max,
> + 1, IMX681_EXPOSURE_DEFAULT);
> + }
> +
> + /*
> + * 1 with a reference taken, 0 if the device is not active, or -EINVAL
> + * if runtime PM is unavailable. Only the 0 means there is nothing to
> + * do: without runtime PM the sensor is powered from probe and never
> + * suspended, so the write still has to go out - but no reference was
> + * taken then, and none may be dropped.
> + */
> + pm_status = pm_runtime_get_if_active(imx681->dev);
> + if (!pm_status)
> + return 0;
> +
> + switch (ctrl->id) {
> + case V4L2_CID_VBLANK:
> + cci_write(imx681->cci, IMX681_REG_GROUP_HOLD, 0x01, &ret);
> + cci_write(imx681->cci, IMX681_REG_FRAME_LENGTH,
> + IMX681_HEIGHT + ctrl->val, &ret);
> + cci_write(imx681->cci, IMX681_REG_GROUP_HOLD, 0x00, &ret);
[Severity: Medium]
Does this leave the hardware exposure register out of sync with the V4L2
state?
When VBLANK is modified, the exposure control range is clamped earlier in
this function. However, if the old exposure value is clamped to a new, smaller
maximum, the newly clamped exposure value is never written to the hardware
because VBLANK and EXPOSURE are not clustered. This could leave the sensor's
hardware exposure register with an out-of-bounds value.
> + dev_dbg(imx681->dev, "set frame_length: %d, ret=%d\n",
> + IMX681_HEIGHT + ctrl->val, ret);
> + break;
> +
> + case V4L2_CID_EXPOSURE:
> + cci_write(imx681->cci, IMX681_REG_GROUP_HOLD, 0x01, &ret);
> + cci_write(imx681->cci, IMX681_REG_EXPOSURE, ctrl->val, &ret);
> + cci_write(imx681->cci, IMX681_REG_GROUP_HOLD, 0x00, &ret);
[Severity: Medium]
Does this independent toggling of the group hold register defeat its purpose?
Group hold is intended to defer register updates until a frame boundary to
ensure multiple settings apply atomically. By toggling it independently for
each V4L2 control, simultaneous user updates to VBLANK, EXPOSURE, and GAIN
will take effect individually and may split across different frames,
potentially causing temporary visual tearing or artifacts.
Would it be better to cluster these controls and use a single group hold block
when they are updated together?
> + dev_dbg(imx681->dev, "set exposure: %d, ret=%d\n",
> + ctrl->val, ret);
> + break;
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260909203717.90605-1-lsa.uz@pm.me?part=2
next prev parent reply other threads:[~2026-09-09 20:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 20:37 [PATCH v3 0/3] media: Add support for the Sony IMX681 Sergey Lebedev
2026-09-09 20:37 ` [PATCH v3 1/3] dt-bindings: media: Add " Sergey Lebedev
2026-09-11 7:36 ` Krzysztof Kozlowski
2026-09-09 20:37 ` [PATCH v3 2/3] media: i2c: Add Sony IMX681 sensor driver Sergey Lebedev
2026-09-09 20:52 ` sashiko-bot [this message]
2026-09-09 21:14 ` Sergey Lebedev
2026-09-11 7:38 ` Krzysztof Kozlowski
2026-09-11 9:24 ` Sergey Lebedev
2026-09-09 20:37 ` [PATCH v3 3/3] media: ipu-bridge: Add Sony IMX681 Sergey Lebedev
2026-09-09 20:46 ` sashiko-bot
2026-09-10 10:36 ` Test for [PATCH v3 0/3] media: Add support for the " German
2026-09-10 11:22 ` Sergey Lebedev
2026-09-10 11:48 ` Test on another machine and userspace for [PATCH v3 0/3] media: Add support for the Sony IMX681 Thanks for clarifying the origin of the errors I am more than happy to provide the tag Tested-by: German <germanpapulindez@gmail.com> German
2026-09-10 11:53 ` Test on another machine and userspace for [PATCH v3 0/3] media: Add support for the Sony IMX681 German
2026-09-11 7:35 ` Krzysztof Kozlowski
2026-09-12 16:16 ` cause of the image error in Gnome Snapshot " German
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=20260909205244.EDB941F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=lsa.uz@pm.me \
--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