From: <Hermes.Wu@ite.com.tw>
To: <sakari.ailus@linux.intel.com>
Cc: <mchehab@kernel.org>, <robh@kernel.org>, <krzk+dt@kernel.org>,
<conor+dt@kernel.org>, <linux-media@vger.kernel.org>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH 20/21] media: i2c: it6625: use centrally managed active state
Date: Fri, 18 Sep 2026 11:19:38 +0000 [thread overview]
Message-ID: <69a3df11b37f466fbdca8be37a6cc378@ite.com.tw> (raw)
In-Reply-To: <aq0RaLPX5o0HU_yC@kekkonen.localdomain>
Hi Sakari,
Thank you for the review.
> I don't think all the above is relevant in the commit message.
Agreed, trimmed.
> This paragraph could go to the cover letter.
Agreed, moved the lock-audit-trace paragraph there.
> + /*
> + * Protects concurrent access to the chip's registers and state.
> + * Also shared as sd.state_lock and hdl.lock (see
> [...]
>
> This doesn't hold anymore, does it? Typically drivers do without such
> locks as the subdev state lock is used instead -- assigning your own lock
> also has the effect the same lock is used for try states, too.
You're right, and on reflection sharing it was the wrong call, not just
an under-explained one. it6625_lock is an MCU/register lock: the
chip's internal MCU firmware processes one register-driven command at
a time, and some commands are multi-step I2C transactions (write a
config register, then poll REG_HOST_CTRL_INT/B_CONFIG_UPDATE via
it6625_wait_for_status()) that must not be interleaved with another
such command. That's a real, separate constraint, but it isn't a
reason to also make it the subdev state lock or the control handler's
lock -- neither the pad format nor the control handler is chip state.
Dropped both aliasing assignments (sd->state_lock, hdl->lock) and let
the core give the subdev state and the control handler their own
independent locks, like most drivers do. it6625_lock stays exactly
what it always was: a private mutex taken explicitly around MCU/
register access. That did mean re-auditing every caller that used to
reach the active pad format under the implicit
state_lock == it6625_lock assumption -- it6625_initial_setup(),
it6625_clear_timings(), it6625_log_status(), and
it6625_update_timings_if_changed() now take the active state's lock
explicitly (the last two aren't core-locked to begin with:
VIDIOC_LOG_STATUS and VIDIOC_SUBDEV_S_DV_TIMINGS aren't in
subdev_ioctl_get_state()'s switch in v4l2-subdev.c), nesting
it6625_lock inside where they also touch it6625->timings. The rule
going forward: a subdev state lock, when held, is always the outer
lock; it6625_lock nests inside it, never the reverse.
> Could you rework the code to keep this for active and try paths?
Agreed. Moved the ACTIVE-only hardware programming into its own guarded
block and let both TRY and ACTIVE fall through to one shared commit tail
instead of duplicating it.
> There are a few lines longer than 80; please split unless there's a
> tangible reason to do otherwise.
Agreed. Hoisted the repeated it6625_formats[idx].csi_format lookup into
a local variable, which gets the it6625_set_mipi_config_locked() call
(and the neighboring comment) under 80 columns without an awkward wrap.
> + if (active) {
> + *fmt = *v4l2_subdev_state_get_format(active, 0);
> + return 0;
> + }
>
> This function should work the same way independently of whether the
> state is active or not.
Agreed. I was special-casing on whether sd->active_state existed yet, to
seed a new TRY state from the current active format instead of reverting
to boot defaults. Reworked it to always set the same defaults regardless
of which state it's initializing -- it6625->timings and the default
format index -- following the same unconditional-defaults pattern
hm1246_init_state() uses for the same active/TRY distinction. The
core already holds whichever state init_state() is initializing before
calling in, so reading it6625->timings under a nested it6625_lock (see
the locking reply above) is safe there too; a TRY state opened after
signal detection still reflects the live detected width/height/field,
and the code always starts from the default format index, same as
it6625_init_data() seeds it at probe.
> This comment is hardly useful; the same applies to pretty much all
> drivers using sub-device state and V4L2 controls.
Agreed, dropped it.
Kind regards,
Hermes
next prev parent reply other threads:[~2026-09-18 11:19 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 8:57 [PATCH 00/21] media: i2c: it6625: address review feedback and adopt subdev state Hermes Wu
2026-09-18 8:57 ` Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 01/21] media: dt-bindings: ite,it6625: document the default CSI-2 bus type Hermes Wu
2026-09-18 8:57 ` Hermes Wu via B4 Relay
2026-09-28 19:21 ` Rob Herring (Arm)
2026-09-18 8:57 ` [PATCH 02/21] media: i2c: it6625: propagate control-update errors Hermes Wu
2026-09-18 8:57 ` Hermes Wu via B4 Relay
2026-09-18 10:05 ` Sakari Ailus
2026-09-18 11:05 ` Hermes.Wu
2026-09-18 8:57 ` [PATCH 03/21] media: i2c: it6625: default the debug module parameter to 0 Hermes Wu
2026-09-18 8:57 ` Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 04/21] media: i2c: it6625: drop unused bus field from struct it6625 Hermes Wu
2026-09-18 8:57 ` Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 05/21] media: i2c: it6625: drop stale GCC < 4.4.6 workaround Hermes Wu
2026-09-18 8:57 ` Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 06/21] media: i2c: it6625: use unsigned int loop indices in table lookups Hermes Wu
2026-09-18 8:57 ` Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 07/21] media: i2c: it6625: drop redundant parentheses in status helpers Hermes Wu
2026-09-18 8:57 ` Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 08/21] media: i2c: it6625: make the audio sampling-rate table static const Hermes Wu
2026-09-18 8:57 ` Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 09/21] media: i2c: it6625: tidy CEC buffer init and a continuation line Hermes Wu
2026-09-18 8:57 ` Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 10/21] media: i2c: it6625: clean up it6625_wait_for_status() Hermes Wu
2026-09-18 8:57 ` Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 11/21] media: i2c: it6625: use unsigned int indices in EDID read/write Hermes Wu
2026-09-18 8:57 ` Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 12/21] media: i2c: it6625: use unaligned/units helpers to decode pixel clock Hermes Wu
2026-09-18 8:57 ` Hermes Wu via B4 Relay
2026-09-18 9:11 ` sashiko-bot
2026-09-18 8:57 ` [PATCH 13/21] media: i2c: it6625: decode detected timings via typed register structs Hermes Wu
2026-09-18 8:57 ` Hermes Wu via B4 Relay
2026-09-18 10:09 ` Sakari Ailus
2026-09-18 8:57 ` [PATCH 14/21] media: i2c: it6625: fix link-frequency reporting for one-/two-trio C-PHY Hermes Wu
2026-09-18 8:57 ` Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 15/21] media: i2c: it6625: use early returns in it6625_update_timings_if_changed() Hermes Wu
2026-09-18 8:57 ` Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 16/21] media: i2c: it6625: drop the private CSI-format name table Hermes Wu
2026-09-18 8:57 ` Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 17/21] media: i2c: it6625: require a DT endpoint and simplify endpoint parsing Hermes Wu
2026-09-18 8:57 ` Hermes Wu via B4 Relay
2026-09-18 9:16 ` sashiko-bot
2026-09-18 8:57 ` [PATCH 18/21] media: i2c: it6625: finish reverse fir-tree declaration order Hermes Wu
2026-09-18 8:57 ` Hermes Wu via B4 Relay
2026-09-18 8:57 ` [PATCH 19/21] media: i2c: it6625: fold subdev initialization into probe Hermes Wu
2026-09-18 8:57 ` Hermes Wu via B4 Relay
2026-09-18 10:13 ` Sakari Ailus
2026-09-18 8:57 ` [PATCH 20/21] media: i2c: it6625: use centrally managed active state Hermes Wu
2026-09-18 8:57 ` Hermes Wu via B4 Relay
2026-09-18 10:24 ` Sakari Ailus
2026-09-18 11:19 ` Hermes.Wu [this message]
2026-09-18 15:28 ` Sakari Ailus
2026-09-21 2:24 ` Hermes.Wu
2026-09-25 11:35 ` Sakari Ailus
2026-09-18 8:57 ` [PATCH 21/21] media: i2c: it6625: use enable_streams and disable_streams Hermes Wu
2026-09-18 8:57 ` Hermes Wu via B4 Relay
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=69a3df11b37f466fbdca8be37a6cc378@ite.com.tw \
--to=hermes.wu@ite.com.tw \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=robh@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.