From nobody Sat Feb 7 11:31:52 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C18DC4332F for ; Wed, 19 Oct 2022 10:42:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232508AbiJSKma (ORCPT ); Wed, 19 Oct 2022 06:42:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232297AbiJSKli (ORCPT ); Wed, 19 Oct 2022 06:41:38 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D05C38B3; Wed, 19 Oct 2022 03:19:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 18F5DB8241E; Wed, 19 Oct 2022 08:55:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89A2CC433D6; Wed, 19 Oct 2022 08:55:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169755; bh=GT2VMBbT8oyd3xN+8SDhxONqhXZD0SajvrZKEinfg3w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yzlX3Vgs2AIzYlRP0bHRzexNFlv3pYnPo1kU1T8HMzbLIytE6PZTOnFkNpZRymiSO f4o+JOqjJimK8s3f2iYTlS/UF41PMNNtcD0Fgpe9kmevgt7ecg+4yUZj4cROcU39iY CuB+Vg0aLBvFQ3GfioWCa9uRN2ngULt1dY1xCmsU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jaroslav Kysela , Kai Vehmanen , Takashi Iwai , Sasha Levin Subject: [PATCH 6.0 396/862] ALSA: hda/hdmi: Fix the converter allocation for the silent stream Date: Wed, 19 Oct 2022 10:28:03 +0200 Message-Id: <20221019083307.428832707@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Jaroslav Kysela [ Upstream commit fc6f923ecfa2fafd0600f1b7e2de09baf29865e2 ] Track the converters handling the silent stream using a new variable to avoid mixing of the open/close and silent stream use. This change ensures the proper allocation of the converters. Fixes: 5f80d6bd2b01 ("ALSA: hda/hdmi: Fix the converter reuse for the silen= t stream") Signed-off-by: Jaroslav Kysela Reviewed-by: Kai Vehmanen Link: https://lore.kernel.org/r/20220919135444.3554982-1-perex@perex.cz Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/pci/hda/patch_hdmi.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 69afea67bf3e..d463c968b3a4 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -54,6 +54,7 @@ MODULE_PARM_DESC(enable_all_pins, "Forcibly enable all pi= ns"); struct hdmi_spec_per_cvt { hda_nid_t cvt_nid; bool assigned; /* the stream has been assigned */ + bool silent_stream; /* silent stream activated */ unsigned int channels_min; unsigned int channels_max; u32 rates; @@ -988,7 +989,8 @@ static int hdmi_setup_stream(struct hda_codec *codec, h= da_nid_t cvt_nid, * of the pin. */ static int hdmi_choose_cvt(struct hda_codec *codec, - int pin_idx, int *cvt_id) + int pin_idx, int *cvt_id, + bool silent) { struct hdmi_spec *spec =3D codec->spec; struct hdmi_spec_per_pin *per_pin; @@ -1003,6 +1005,9 @@ static int hdmi_choose_cvt(struct hda_codec *codec, =20 if (per_pin && per_pin->silent_stream) { cvt_idx =3D cvt_nid_to_cvt_index(codec, per_pin->cvt_nid); + per_cvt =3D get_cvt(spec, cvt_idx); + if (per_cvt->assigned && !silent) + return -EBUSY; if (cvt_id) *cvt_id =3D cvt_idx; return 0; @@ -1013,7 +1018,7 @@ static int hdmi_choose_cvt(struct hda_codec *codec, per_cvt =3D get_cvt(spec, cvt_idx); =20 /* Must not already be assigned */ - if (per_cvt->assigned) + if (per_cvt->assigned || per_cvt->silent_stream) continue; if (per_pin =3D=3D NULL) break; @@ -1199,7 +1204,7 @@ static int hdmi_pcm_open_no_pin(struct hda_pcm_stream= *hinfo, if (pcm_idx < 0) return -EINVAL; =20 - err =3D hdmi_choose_cvt(codec, -1, &cvt_idx); + err =3D hdmi_choose_cvt(codec, -1, &cvt_idx, false); if (err) return err; =20 @@ -1267,7 +1272,7 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, } } =20 - err =3D hdmi_choose_cvt(codec, pin_idx, &cvt_idx); + err =3D hdmi_choose_cvt(codec, pin_idx, &cvt_idx, false); if (err < 0) goto unlock; =20 @@ -1278,7 +1283,6 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, set_bit(pcm_idx, &spec->pcm_in_use); per_pin =3D get_pin(spec, pin_idx); per_pin->cvt_nid =3D per_cvt->cvt_nid; - per_pin->silent_stream =3D false; hinfo->nid =3D per_cvt->cvt_nid; =20 /* flip stripe flag for the assigned stream if supported */ @@ -1760,14 +1764,14 @@ static void silent_stream_enable(struct hda_codec *= codec, } =20 pin_idx =3D pin_id_to_pin_index(codec, per_pin->pin_nid, per_pin->dev_id); - err =3D hdmi_choose_cvt(codec, pin_idx, &cvt_idx); + err =3D hdmi_choose_cvt(codec, pin_idx, &cvt_idx, true); if (err) { codec_err(codec, "hdmi: no free converter to enable silent mode\n"); goto unlock_out; } =20 per_cvt =3D get_cvt(spec, cvt_idx); - per_cvt->assigned =3D true; + per_cvt->silent_stream =3D true; per_pin->cvt_nid =3D per_cvt->cvt_nid; per_pin->silent_stream =3D true; =20 @@ -1827,7 +1831,7 @@ static void silent_stream_disable(struct hda_codec *c= odec, cvt_idx =3D cvt_nid_to_cvt_index(codec, per_pin->cvt_nid); if (cvt_idx >=3D 0 && cvt_idx < spec->num_cvts) { per_cvt =3D get_cvt(spec, cvt_idx); - per_cvt->assigned =3D false; + per_cvt->silent_stream =3D false; } =20 if (spec->silent_stream_type =3D=3D SILENT_STREAM_I915) { --=20 2.35.1