From: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
To: "Maxime Ripard" <mripard@kernel.org>,
"Dave Stevenson" <dave.stevenson@raspberrypi.com>,
"Maíra Canal" <mcanal@igalia.com>,
"Raspberry Pi Kernel Maintenance" <kernel-list@raspberrypi.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>
Cc: kernel@collabora.com, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, Sashiko <sashiko-bot@kernel.org>
Subject: [PATCH v3 7/9] drm/vc4: hdmi: Clamp CEC clock divider to its register field width
Date: Wed, 14 Oct 2026 04:03:14 +0300 [thread overview]
Message-ID: <20261014-vc4-common-scramb-v3-7-c68d58d959a2@collabora.com> (raw)
In-Reply-To: <20261014-vc4-common-scramb-v3-0-c68d58d959a2@collabora.com>
The CEC clock divider computed in vc4_hdmi_cec_update_clk_div() is
written unmasked into the 12-bit DIV_CLK_CNT field of the CEC_CNTRL_1
register. On BCM2835, the CEC clock is obtained by dividing the HSM
clock, which in turn is scaled to 101% of the pixel clock. For HSM
clock rates above 163.8 MHz, the divider exceeds the field limit (4095),
corrupting the adjacent CEC_ADDR field and truncating the effective
divider, which breaks CEC entirely.
The BCM2835 maximum pixel clock of 162 MHz yields an HSM clock of 163.62
MHz, so the overflow cannot currently be triggered.
Clamp the divider to the field maximum. This is a prerequisite for
raising the BCM2835 maximum pixel clock to 165 MHz, which pushes the HSM
clock up to 166.65 MHz. The CEC bit clock will then run up to ~1.75%
faster than the nominal 40 kHz, i.e. ~40.7 kHz, which is still within
the CEC bit-timing tolerances.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/all/sashiko-outbox-168686@kernel.org/
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/gpu/drm/vc4/vc4_hdmi.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index 2451ff85e759..0a95e14792e8 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -231,9 +231,14 @@ static void vc4_hdmi_cec_update_clk_div(struct vc4_hdmi *vc4_hdmi)
/*
* Set the clock divider: the hsm_clock rate and this divider
- * setting will give a 40 kHz CEC clock.
+ * setting will give a 40 kHz CEC clock. Clamp the divider to
+ * its 12-bit field to avoid corrupting CEC_ADDR; for HSM rates
+ * above 163.8 MHz, the CEC clock runs marginally faster, but
+ * still within CEC timing tolerances.
*/
- clk_cnt = cec_rate / CEC_CLOCK_FREQ;
+ clk_cnt = min_t(unsigned long, cec_rate / CEC_CLOCK_FREQ,
+ VC4_HDMI_CEC_DIV_CLK_CNT_MASK >>
+ VC4_HDMI_CEC_DIV_CLK_CNT_SHIFT);
value |= clk_cnt << VC4_HDMI_CEC_DIV_CLK_CNT_SHIFT;
HDMI_WRITE(HDMI_CEC_CNTRL_1, value);
--
2.55.0
next prev parent reply other threads:[~2026-10-14 1:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 1:03 [PATCH v3 0/9] drm/vc4: hdmi: Convert to common HDMI 2.0 scrambling infrastructure Cristian Ciocaltea
2026-10-14 1:03 ` [PATCH v3 1/9] drm/vc4: hdmi: Use common TMDS char rate constants Cristian Ciocaltea
2026-10-14 1:03 ` [PATCH v3 2/9] drm/vc4: hdmi: Switch to drm_hdmi_mode_needs_scrambling() Cristian Ciocaltea
2026-10-14 1:03 ` [PATCH v3 3/9] drm/vc4: hdmi: Switch to .force_ctx() connector helper Cristian Ciocaltea
2026-10-14 1:03 ` [PATCH v3 4/9] drm/vc4: hdmi: Propagate -EDEADLK to the top level Cristian Ciocaltea
2026-10-14 1:03 ` [PATCH v3 5/9] drm/vc4: hdmi: Convert to drmm_connector_hdmi_init() Cristian Ciocaltea
2026-10-14 1:03 ` [PATCH v3 6/9] drm/vc4: hdmi: Convert to common HDMI 2.0 scrambling infrastructure Cristian Ciocaltea
2026-10-27 13:35 ` Maíra Canal
2026-10-14 1:03 ` Cristian Ciocaltea [this message]
2026-10-27 17:50 ` [PATCH v3 7/9] drm/vc4: hdmi: Clamp CEC clock divider to its register field width Dave Stevenson
2026-10-14 1:03 ` [PATCH v3 8/9] drm/vc4: hdmi: Bump BCM2835 max pixel clock to 165 MHz Cristian Ciocaltea
2026-10-27 17:51 ` Dave Stevenson
2026-10-14 1:03 ` [PATCH v3 9/9] drm/vc4: hdmi: Defer pixel clock validation to HDMI helpers Cristian Ciocaltea
2026-10-27 1:49 ` [PATCH v3 0/9] drm/vc4: hdmi: Convert to common HDMI 2.0 scrambling infrastructure Cristian Ciocaltea
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=20261014-vc4-common-scramb-v3-7-c68d58d959a2@collabora.com \
--to=cristian.ciocaltea@collabora.com \
--cc=airlied@gmail.com \
--cc=dave.stevenson@raspberrypi.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel-list@raspberrypi.com \
--cc=kernel@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mcanal@igalia.com \
--cc=mripard@kernel.org \
--cc=sashiko-bot@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/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
all inboxes | Powered by JetHome®