From: sashiko-bot@kernel.org
To: "Sreeraj S Kurup" <sreekuttan2156239@gmail.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH 3/3] ASoC: codecs: hdac_hdmi: Update codec read API callers
Date: Thu, 03 Dec 2026 18:46:57 +0000 [thread overview]
Message-ID: <sashiko-outbox-248417@kernel.org> (raw)
In-Reply-To: <20261203170741.3873-4-sreekuttan2156239@gmail.com>
Thank you for your contribution! Sashiko AI review found 7 potential
issues to consider:
- [High] ALSA: hda: snd_hdac_check_power_state() still calls
codec_read() with 5 args
- [High] ALSA: hda: hda_codec.h wrappers still call
snd_hdac_codec_read() with 5 args
- [High] ALSA: hda: hdmi_set_channel_count() local current collides with
kernel macro
- [Medium] ALSA: hda: snd_hdac_sync_power_state() returns uninitialized
or stale state
- [Medium] ALSA: hda: non-atomic snd_hdac_codec_read() change breaks
bisect and dup API
- [Medium] ASoC: hdac_hdmi: early break defeats retry loop in
hdac_hdmi_set_power_state()
- [Medium] ASoC: hdac_hdmi: aborting hdac_hdmi_runtime_suspend() on D3
read error
--
commit c39e00c18989bfbf7ab831cd560cf2b65326aa27
Author: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
ASoC: codecs: hdac_hdmi: Update codec read API callers
This commit updates the snd_hdac_codec_read() callers in hdac_hdmi.c to
pass an output pointer for the codec response and check the returned error
status.
> diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
> index f7922ffaad973..8dad9f1644f89 100644
> --- a/sound/soc/codecs/hdac_hdmi.c
> +++ b/sound/soc/codecs/hdac_hdmi.c
> @@ -241,8 +241,15 @@ static int hdac_hdmi_get_port_len(struct hdac_device *hdev, hda_nid_t nid)
> static int hdac_hdmi_port_select_get(struct hdac_device *hdev,
> struct hdac_hdmi_port *port)
> {
> - return snd_hdac_codec_read(hdev, port->pin->nid,
> - 0, AC_VERB_GET_DEVICE_SEL, 0);
> + unsigned int res;
> + int err;
> +
> + err = snd_hdac_codec_read(hdev, port->pin->nid,
> + 0, AC_VERB_GET_DEVICE_SEL, 0, &res);
> + if (err < 0)
> + return err;
> +
> + return res;
> }
[Severity: Medium]
Does splitting the snd_hdac_codec_read() signature change across commits
break git bisect? Commit "ALSA: hda: core: Fix command creation error
handling" changed the exported prototype without updating callers in
sound/hda/core/hdmi_chmap.c and sound/soc/codecs/hdac_hdmi.c in the same
commit, so the intermediate commits fail to build.
Also, every updated call site passes 0 for flags, which the existing
snd_hdac_read() already provides with the same status-return and output
parameter interface. Switching these callers to snd_hdac_read() would
avoid changing snd_hdac_codec_read() at all.
[Severity: High]
Were the inline wrappers in include/sound/hda_codec.h missed when updating
snd_hdac_codec_read()? Both snd_hda_codec_read() and
snd_hda_codec_write_sync() still call snd_hdac_codec_read() with five
arguments, breaking the build for every translation unit that includes
include/sound/hda_codec.h.
Note that snd_hda_codec_read() callers expect the 32-bit response (or -1
on error) as the return value rather than the 0/negative status.
[Severity: High]
Does the local variable named current in hdmi_set_channel_count() break
compilation of sound/hda/core/hdmi_chmap.c? Commit "ALSA: hda:
hdmi_chmap: Update HDMI channel map codec read callers" added:
sound/hda/core/hdmi_chmap.c:hdmi_set_channel_count() {
int current;
current = hdmi_get_channel_count(codec, cvt_nid);
...
}
Because the included headers pull in asm/current.h, the global current
macro expands over the declaration and assignment, causing a syntax error
whenever CONFIG_SND_HDA_CORE is enabled.
[ ... ]
> @@ -740,15 +752,18 @@ static struct hdac_hdmi_pcm *hdac_hdmi_get_pcm(struct hdac_device *hdev,
> static void hdac_hdmi_set_power_state(struct hdac_device *hdev,
> hda_nid_t nid, unsigned int pwr_state)
> {
> - int count;
> - unsigned int state;
> + int count, err;
> + unsigned int state, res;
>
> if (snd_hdac_get_wcaps(hdev, nid) & AC_WCAP_POWER) {
> if (!snd_hdac_check_power_state(hdev, nid, pwr_state)) {
[Severity: High]
Does snd_hdac_check_power_state() still call codec_read() with five
arguments? After commit "ALSA: hda: core: Fix command creation error
handling" added the output parameter to codec_read(),
sound/hda/core/device.c fails to compile:
sound/hda/core/device.c:snd_hdac_check_power_state() {
unsigned int state = codec_read(hdac, nid, 0,
AC_VERB_GET_POWER_STATE, 0);
...
}
It also needs to pass &state and treat a negative error return the same
way AC_PWRST_ERROR was handled previously.
> for (count = 0; count < 10; count++) {
> - snd_hdac_codec_read(hdev, nid, 0,
> + err = snd_hdac_codec_read(hdev, nid, 0,
> AC_VERB_SET_POWER_STATE,
> - pwr_state);
> + pwr_state, &res);
> + if (err < 0)
> + break;
[Severity: Medium]
Does breaking out of the loop on err < 0 defeat the 10-attempt retry logic
here? Previously, a transient HDA verb or RIRB error continued into
snd_hdac_sync_power_state() and retried; now the first error aborts
immediately without logging or reporting failure.
Because hdac_hdmi_set_power_state() returns void, callers such as
hdac_hdmi_pin_output_widget_event() proceed to configure a pin or
converter widget that may still be in D3, leaving audio silent.
>
> state = snd_hdac_sync_power_state(hdev,
> nid, pwr_state);
> if (!(state & AC_PWRST_ERROR))
> break;
[Severity: Medium]
Can snd_hdac_sync_power_state() return an uninitialized or stale state
when snd_hdac_codec_read() fails? In sound/hda/core/device.c, state is
uninitialized on entry and is not set to AC_PWRST_ERROR before breaking
out on error:
sound/hda/core/device.c:snd_hdac_sync_power_state() {
unsigned int state, actual_state, count;
for (count = 0; count < 500; count++) {
if (snd_hdac_codec_read(codec, nid, 0,
AC_VERB_GET_POWER_STATE, 0, &state)) {
msleep(20);
break;
}
...
}
If codec_read() fails early (for example, snd_hdac_make_cmd() returning
-EINVAL or a runtime PM error in call_exec_verb()) without writing *res,
state holds stack garbage or a previous poll value without AC_PWRST_ERROR
set, causing callers to abort retries early. Assigning
state = AC_PWRST_ERROR before breaking restores the previous contract.
[ ... ]
> @@ -1942,6 +1959,8 @@ static int hdac_hdmi_runtime_suspend(struct device *dev)
[ ... ]
> * is received. So setting power state is ensured without using loop
> * to read the state.
> */
> - snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE,
> - AC_PWRST_D3);
> + ret = snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE,
> + AC_PWRST_D3, &res);
> + if (ret < 0)
> + return ret;
[Severity: Medium]
Can returning early on a D3 verb error wedge runtime PM and abort system
suspend? If snd_hdac_codec_read() returns -EIO (such as on an RIRB
timeout), rpm_suspend() sets dev->power.runtime_error = -EIO because it is
neither -EAGAIN nor -EBUSY, and nothing in this driver clears it.
Once runtime_error is set, later HDMI PCM opens fail with -EINVAL in
snd_soc_pcm_component_pm_runtime_get(), the skipped link and display power
teardown keeps the controller and display power well awake (and leaks
hlink->ref_count on unbind), and pm_runtime_force_suspend() aborts system
sleep. Logging the error and continuing with the teardown before
returning 0 would preserve the previous behavior.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203170741.3873-1-sreekuttan2156239@gmail.com?part=3
next prev parent reply other threads:[~2026-12-03 18:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 17:04 [PATCH 0/3] ALSA: hda: Separate codec read status from response Sreeraj S Kurup
2026-12-03 17:05 ` [PATCH 1/3] ALSA: hda: core: Fix command creation error handling Sreeraj S Kurup
2026-12-03 18:12 ` sashiko-bot
2026-12-03 17:05 ` [PATCH 2/3] ALSA: hda: hdmi_chmap: Update HDMI channel map codec read callers Sreeraj S Kurup
2026-12-03 18:22 ` sashiko-bot
2026-12-03 17:05 ` [PATCH 3/3] ASoC: codecs: hdac_hdmi: Update codec read API callers Sreeraj S Kurup
2026-12-03 18:46 ` sashiko-bot [this message]
2026-12-03 17:33 ` [PATCH 0/3] ALSA: hda: Separate codec read status from response Takashi Iwai
2026-12-03 18:10 ` Sreeraj S Kurup
2026-12-03 18:31 ` Sreeraj S Kurup
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=sashiko-outbox-248417@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sreekuttan2156239@gmail.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