From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Benjamin Mugnier <benjamin.mugnier@foss.st.com>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Hans Verkuil <hverkuil@xs4all.nl>,
Sasha Levin <sashal@kernel.org>,
sylvain.petinot@foss.st.com, linux-media@vger.kernel.org
Subject: [PATCH AUTOSEL 6.16] media: i2c: vd55g1: Setup sensor external clock before patching
Date: Tue, 5 Aug 2025 09:09:05 -0400 [thread overview]
Message-ID: <20250805130945.471732-30-sashal@kernel.org> (raw)
In-Reply-To: <20250805130945.471732-1-sashal@kernel.org>
From: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
[ Upstream commit df2f8fd91bde57d5d5aca6adddf7e988f2e8c60e ]
Proper clock configuration is required to advance through FSM states.
Prior than this having a different clock value than default sensor's
value was used (12 MHz) could prevent the sensor from booting.
Signed-off-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
**Backport Status: YES**
This commit should be backported to stable kernel trees for the
following reasons:
## Bug Fix Analysis
1. **Critical Boot Issue**: The commit fixes a sensor initialization
failure where the sensor could fail to boot if a non-default clock
frequency was used. The commit message explicitly states: "Prior than
this having a different clock value than default sensor's value was
used (12 MHz) could prevent the sensor from booting."
2. **Clear Root Cause**: The issue is a timing/sequencing problem where
the external clock must be configured BEFORE the patch is applied to
allow proper FSM (Finite State Machine) state transitions. The commit
message states: "Proper clock configuration is required to advance
through FSM states."
3. **Small and Contained Fix**: The fix is minimal - it simply moves one
line of code (`vd55g1_write(sensor, VD55G1_REG_EXT_CLOCK,
sensor->xclk_freq, &ret);`) from the streaming enable function to the
power-on sequence, specifically between sensor detection and
patching.
## Code Analysis
Looking at the code changes:
- **REMOVED** from `vd55g1_enable_streams()` at line 1040 (after power-
on)
- **ADDED** to `vd55g1_power_on()` at line 1614 (after detect, before
patch)
The new sequence in `vd55g1_power_on()` becomes:
1. Enable power/clock → FSM state: READY_TO_BOOT
2. `vd55g1_detect()` - verify sensor ID
3. **NEW: Configure external clock** ← Critical for FSM advancement
4. `vd55g1_patch()` - apply firmware patch
5. Wait for FSM state: SW_STBY
## Stable Criteria Met
1. **Fixes a real bug**: Yes - sensor initialization failure with non-
default clocks
2. **Small change**: Yes - single line moved between functions
3. **No new features**: Correct - just fixes sequencing
4. **Low regression risk**: Yes - moves existing code to proper location
5. **Hardware enablement**: Fixes broken hardware initialization for
VD55G1 sensor
6. **Recently added driver**: The driver was added in April 2025 (commit
e56616d7b23c), making this an early fix for a new driver that likely
needs to work properly in stable kernels
The fix addresses a fundamental initialization issue that would prevent
the sensor from working with any clock frequency other than the default
12 MHz, making it a critical fix for proper hardware support.
drivers/media/i2c/vd55g1.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/vd55g1.c b/drivers/media/i2c/vd55g1.c
index 25e2fc88a036..8552ce75e1aa 100644
--- a/drivers/media/i2c/vd55g1.c
+++ b/drivers/media/i2c/vd55g1.c
@@ -1038,8 +1038,6 @@ static int vd55g1_enable_streams(struct v4l2_subdev *sd,
if (ret < 0)
return ret;
- vd55g1_write(sensor, VD55G1_REG_EXT_CLOCK, sensor->xclk_freq, &ret);
-
/* Configure output */
vd55g1_write(sensor, VD55G1_REG_MIPI_DATA_RATE,
sensor->mipi_rate, &ret);
@@ -1613,6 +1611,9 @@ static int vd55g1_power_on(struct device *dev)
goto disable_clock;
}
+ /* Setup clock now to advance through system FSM states */
+ vd55g1_write(sensor, VD55G1_REG_EXT_CLOCK, sensor->xclk_freq, &ret);
+
ret = vd55g1_patch(sensor);
if (ret) {
dev_err(dev, "Sensor patch failed %d\n", ret);
--
2.39.5
next prev parent reply other threads:[~2025-08-05 13:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250805130945.471732-1-sashal@kernel.org>
2025-08-05 13:08 ` [PATCH AUTOSEL 6.16-5.4] media: uvcvideo: Fix bandwidth issue for Alcor camera Sasha Levin
2025-08-05 13:08 ` [PATCH AUTOSEL 6.16] media: i2c: vd55g1: Fix RATE macros not being expressed in bps Sasha Levin
2025-08-05 13:08 ` [PATCH AUTOSEL 6.16-5.4] media: usb: hdpvr: disable zero-length read messages Sasha Levin
2025-08-05 13:08 ` [PATCH AUTOSEL 6.16-6.12] media: uvcvideo: Add quirk for HP Webcam HD 2300 Sasha Levin
2025-08-05 13:09 ` Sasha Levin [this message]
2025-08-05 13:09 ` [PATCH AUTOSEL 6.16-6.15] media: iris: Add handling for corrupt and drop frames Sasha Levin
2025-08-05 13:09 ` [PATCH AUTOSEL 6.16-5.4] media: tc358743: Check I2C succeeded during probe Sasha Levin
2025-08-05 13:09 ` [PATCH AUTOSEL 6.16-5.4] media: tc358743: Return an appropriate colorspace from tc358743_set_fmt Sasha Levin
2025-08-05 13:09 ` [PATCH AUTOSEL 6.16-5.4] media: tc358743: Increase FIFO trigger level to 374 Sasha Levin
2025-08-05 13:09 ` [PATCH AUTOSEL 6.16-6.12] media: hi556: Fix reset GPIO timings Sasha Levin
2025-08-05 13:09 ` [PATCH AUTOSEL 6.16-6.15] media: uvcvideo: Set V4L2_CTRL_FLAG_DISABLED during queryctrl errors Sasha Levin
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=20250805130945.471732-30-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=benjamin.mugnier@foss.st.com \
--cc=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
--cc=patches@lists.linux.dev \
--cc=sakari.ailus@linux.intel.com \
--cc=stable@vger.kernel.org \
--cc=sylvain.petinot@foss.st.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox