From: Sen Wang <sen@ti.com>
To: Andrzej Hajda <andrzej.hajda@intel.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Robert Foss <rfoss@kernel.org>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
Jonas Karlman <jonas@kwiboo.se>,
"Jernej Skrabec" <jernej.skrabec@gmail.com>,
Luca Ceresoli <luca.ceresoli@bootlin.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Jyri Sarha <jsarha@ti.com>
Cc: <dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>,
"Sen Wang" <sen@ti.com>
Subject: [PATCH] drm/bridge: sii902x: Balance audio mclk enable and disable
Date: Thu, 5 Nov 2026 12:28:08 -0600 [thread overview]
Message-ID: <20261105182809.290537-1-sen@ti.com> (raw)
The driver currently has an unbalanced clk enable count, as
sii902x_audio_hw_params() enables the mclk, but sii902x_audio_shutdown()
disables it unconditionally. This creates a few issues:
1. hdmi-codec calls audio_shutdown() on every PCM close, even if
hw_params() never ran. For example, PipeWire queries the hw params
at initialization, via:
aplay -D hw:0,0 --dump-hw-params /dev/zero
The clock core then hits WARN() in clk_core_disable() and
clk_core_unprepare(), printing a backtrace and tainting the kernel:
sii9022-mclk already disabled
sii9022-mclk already unprepared
2. A second hw_params() without a shutdown in between enables the
clock again, thus the count never returns to zero.
Therefore track whether hw_params() enabled the clock, and only disable
it in that case, to keep the clock enable count balanced.
Fixes: ff5781634c41 ("drm/bridge: sii902x: Implement HDMI audio support")
Signed-off-by: Sen Wang <sen@ti.com>
---
drivers/gpu/drm/bridge/sii902x.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index 9aac44ed5b67..df72712f4296 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -186,6 +186,7 @@ struct sii902x {
*/
struct mutex mutex;
struct sii902x_audio {
+ bool mclk_enabled;
struct platform_device *pdev;
struct clk *mclk;
u32 i2s_fifo_sequence[4];
@@ -681,10 +682,13 @@ static int sii902x_audio_hw_params(struct device *dev, void *data,
}
}
- ret = clk_prepare_enable(sii902x->audio.mclk);
- if (ret) {
- dev_err(dev, "Enabling mclk failed: %d\n", ret);
- return ret;
+ if (!sii902x->audio.mclk_enabled) {
+ ret = clk_prepare_enable(sii902x->audio.mclk);
+ if (ret) {
+ dev_err(dev, "Enabling mclk failed: %d\n", ret);
+ return ret;
+ }
+ sii902x->audio.mclk_enabled = true;
}
if (sii902x->audio.mclk) {
@@ -761,6 +765,7 @@ static int sii902x_audio_hw_params(struct device *dev, void *data,
if (ret) {
clk_disable_unprepare(sii902x->audio.mclk);
+ sii902x->audio.mclk_enabled = false;
dev_err(dev, "%s: hdmi audio enable failed: %d\n", __func__,
ret);
}
@@ -779,7 +784,10 @@ static void sii902x_audio_shutdown(struct device *dev, void *data)
mutex_unlock(&sii902x->mutex);
- clk_disable_unprepare(sii902x->audio.mclk);
+ if (sii902x->audio.mclk_enabled) {
+ clk_disable_unprepare(sii902x->audio.mclk);
+ sii902x->audio.mclk_enabled = false;
+ }
}
static int sii902x_audio_mute(struct device *dev, void *data,
--
2.43.0
reply other threads:[~2026-11-05 18:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261105182809.290537-1-sen@ti.com \
--to=sen@ti.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=jsarha@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luca.ceresoli@bootlin.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=rfoss@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®