All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Razvan Dinculescu" <razvandinculescu@gmail.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH] ALSA: hda/hdmi: Don't share an assigned converter on NVIDIA codecs
Date: Mon, 02 Nov 2026 18:44:19 +0000	[thread overview]
Message-ID: <sashiko-outbox-193962@kernel.org> (raw)
In-Reply-To: <20261102182213.2154560-1-razvandinculescu@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] ALSA: hda/hdmi: missing active pin mux verification in nvhdmi_pin_cvt_fixup()
--

commit ee77c613ae50ec059d4a1e50bc80fe9f42246e54
Author: Razvan Dinculescu <razvandinculescu@gmail.com>

ALSA: hda/hdmi: Don't share an assigned converter on NVIDIA codecs

This commit implements the pin_cvt_fixup callback for generic NVIDIA HDMI/DP
codecs to move other connected pins off a newly assigned converter so idle
pins do not steal the active audio stream.

> diff --git a/sound/hda/codecs/hdmi/nvhdmi.c b/sound/hda/codecs/hdmi/nvhdmi.c
> index 94671ad24b5eb..95ae7730eed5b 100644
> --- a/sound/hda/codecs/hdmi/nvhdmi.c
> +++ b/sound/hda/codecs/hdmi/nvhdmi.c
> @@ -66,6 +66,81 @@ static const struct drm_audio_component_audio_ops nvhdmi_audio_ops = {
>  	.master_unbind = snd_hda_hdmi_acomp_master_unbind,
>  };
>  
> +/*
> + * All pins of these codecs share one connection list, as on Intel.  An idle
> + * pin left selecting the converter that another pin streams on takes that
> + * stream: the display that plays stays silent and the audio goes to the
> + * other display instead.  Seen on GB202 (0x10de00aa) with an HDMI TV and a
> + * DP monitor: whenever the monitor's PCM was opened first (PipeWire probes
> + * every PCM at start-up), its pin kept the converter the TV got next.
> + *
> + * Move every other connected pin off the converter just assigned, to a
> + * converter nobody uses.
> + */
> +static void nvhdmi_not_share_assigned_cvt(struct hda_codec *codec,
> +					  hda_nid_t pin_nid, int dev_id,
> +					  hda_nid_t cvt_nid)
> +{

[ ... ]

> +}
> +
> +static void nvhdmi_pin_cvt_fixup(struct hda_codec *codec,
> +				 struct hdmi_spec_per_pin *per_pin,
> +				 hda_nid_t cvt_nid)
> +{
> +	if (per_pin)
> +		nvhdmi_not_share_assigned_cvt(codec, per_pin->pin_nid,
> +					      per_pin->dev_id, per_pin->cvt_nid);
> +	else
> +		nvhdmi_not_share_assigned_cvt(codec, 0, 0, cvt_nid);
> +}

[Severity: Medium]
Should nvhdmi_pin_cvt_fixup() also select per_pin->dev_id and verify that
per_pin's own AC_VERB_GET_CONNECT_SEL matches per_pin->mux_idx when per_pin
is non-NULL?

In sound/hda/codecs/hdmi/hdmi.c, snd_hda_hdmi_generic_pcm_prepare() does not
write AC_VERB_SET_CONNECT_SEL directly; it relies on pin_cvt_fixup() to
verify and restore the active pin's converter selection (for example, after
S3 resume or a display reset where hardware resets pin converter selections
to the default converter):

sound/hda/codecs/hdmi/hdmi.c:snd_hda_hdmi_generic_pcm_prepare() {
	...
	/* Verify pin:cvt selections to avoid silent audio after S3.
	 * After S3, the audio driver restores pin:cvt selections
	 * but this can happen before gfx is ready and such selection
	 * is overlooked by HW. Thus multiple pins can share a same
	 * default converter and mute control will affect each other,
	 * which can cause a resumed audio playback become silent
	 * after S3.
	 */
	pin_cvt_fixup(codec, per_pin, 0);
	...
}

On Intel codecs, i915_pin_cvt_fixup() in sound/hda/codecs/hdmi/intelhdmi.c
selects per_pin->dev_id and calls intel_verify_pin_cvt_connect() to restore
per_pin->mux_idx before moving other pins off the converter:

sound/hda/codecs/hdmi/intelhdmi.c:i915_pin_cvt_fixup() {
	if (per_pin) {
		haswell_verify_D0(codec, per_pin->cvt_nid, per_pin->pin_nid);
		snd_hda_set_dev_select(codec, per_pin->pin_nid,
			       per_pin->dev_id);
		intel_verify_pin_cvt_connect(codec, per_pin);
		intel_not_share_assigned_cvt(codec, per_pin->pin_nid,
				     per_pin->dev_id, per_pin->mux_idx);
	} else {
		intel_not_share_assigned_cvt_nid(codec, 0, 0, cvt_nid);
	}
}

Because nvhdmi_pin_cvt_fixup() only calls nvhdmi_not_share_assigned_cvt() and
skips per_pin itself, if hardware resets pin connections while two PCMs are
open (say pin A assigned to converter 0x08 and pin B assigned to converter
0x09, with both reset in hardware to 0x08), preparing pin A first will cause
nvhdmi_not_share_assigned_cvt() to move pin B to an unassigned converter
(such as 0x0a, since 0x09 is marked assigned), and preparing pin B next will
never restore pin B's AC_VERB_SET_CONNECT_SEL back to per_pin->mux_idx for
converter 0x09.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261102182213.2154560-1-razvandinculescu@gmail.com?part=1

      reply	other threads:[~2026-11-02 18:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02 18:22 [PATCH] ALSA: hda/hdmi: Don't share an assigned converter on NVIDIA codecs Razvan Dinculescu
2026-11-02 18:44 ` sashiko-bot [this message]

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-193962@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=razvandinculescu@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.