From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796141098; b=xPmxgyTPt+wDI7d5Bn8w+juIeP8b2XtZDG+2OL9cnzlxooYWGngsgSvGcmoNyPEdkIdD NIYA6pjTzRDiDO9vV/SZTZAaxrU1vcHIORcO4EhaaRCQwul0Nb52Mv585FznT6ZsRj4c0 BqyiO0saLNhMRHephmUglNcmo44nlCx/hdeDf2EYDGXiMBAhUE9/KWPNHDi459rD4RKBz tQ+Q4hsBK6XePLAnkjNyedxZi3G+Zd39f9h46p6+yS0FvbNLYg+Mr8AKKw5l3NqaVDPvD n3eNO/Vhm4ZVZqWnMRdHMpV+7I05vMtu8W5qT399Phzr9HUg/VkjBZ2ymzd4WKxIXqA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796141098; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=9s8wjla+/WC8J6SUvRvbtmC8g4UAgjuyTzVFPWWQU/A=; b=UcmRu/DLMZUHanpeUiN+1KBS4zwlFOdvEG4I/Zjfq2dc71yUk7K1cT3qMa1u9M9nVyQL pRnKmeoWvuE0p7QKbEuDHuLGS4Ks6vYZimgAVfdajAwGkPjVcGh+RWUySeq44Laj58HIr bi3jwUWbSDeusNHfp6ZF9Dzg8Vhw3ZtMD/7HITziob6IjXp/XvLAl7ZcbPX7zQqzlpGPh U6PbO3ECiPw5onIhkZ/e1UZhjduM1x6ohvij7r/MlMm7ThAheeF7k8huT75APips9v/t8 Jlz+G8E1NYsaMMpQJ5MXh7WGwsr6zHIR5sKZ/JHAGvNQwMHlVaRZ5hxA7MNVY06aPLg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="IWkUHMd/"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D125B606A31A for ; Tue, 1 Dec 2026 16:04:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=IWkUHMd/ Received: by smtp.kernel.org (Postfix) with ESMTPSA id E81CB1F00923; Tue, 1 Dec 2026 16:04:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796141098; bh=9s8wjla+/WC8J6SUvRvbtmC8g4UAgjuyTzVFPWWQU/A=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=IWkUHMd/fB7377olSkOvE2bljhta7njBLM4x0vIhOfj91WAuQjDjCN1Q6BWJQcIGG g505C/BMJopatoYKQkydtrP97S9LEYAAat/GIQXbSy9XegONBgSN1XQaHy5hFsU0X7 8axxHvOfUOXv1pth55AlP5RlXHvWdSKI7ngOa+BSWu6RwXn2q+0vtu4mwOL99Snvef kNM1At1JSx4SvhHjGFaUo1GS5Y8wHB29jNfmA3WlJL1lpWhsQClbU8xNnhNILC1/hr IU+LStt3ECH5OqYMmZl/sWWUp5tU7ffNPC4VSpQ9YwAJRywZAT2l7P/P0G9Kq0d09I DBROvneWT6Lhw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v1 1/2] ALSA: hda/cs420x: Add CS4208 TDM speaker fixup for MacBook8,1 Reply-To: sashiko-reviews@lists.linux.dev To: "Shih-Yuan Lee" Cc: linux-sound@vger.kernel.org In-Reply-To: <20261201153214.25157-2-fourdollars@debian.org> References: <20261201153214.25157-1-fourdollars@debian.org> <20261201153214.25157-2-fourdollars@debian.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 16:04:57 +0000 X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] ALSA: hda/cs420x: lock inversion between gpio_mutex and runtime PM -- commit fa5307267e50e6ff89619572855f03b4f32adc6e Author: Shih-Yuan Lee ALSA: hda/cs420x: Add CS4208 TDM speaker fixup for MacBook8,1 This commit adds a CS4208 fixup for the 12-inch MacBook (MacBook8,1) to configure its 4-channel TDM digital speaker link, pin defaults, vendor coefficients, and GPIO0 speaker amplifier control. Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D110561 > diff --git a/sound/hda/codecs/cirrus/cs420x.c b/sound/hda/codecs/cirrus/c= s420x.c > index 6cba01228c271..d389fd8961d60 100644 > --- a/sound/hda/codecs/cirrus/cs420x.c > +++ b/sound/hda/codecs/cirrus/cs420x.c [ ... ] > @@ -118,12 +126,55 @@ static inline void cs_vendor_coef_set(struct hda_co= dec *codec, unsigned int idx, > * HP/SPK/SPDIF > */ > =20 > +static hda_nid_t cs4208_mb81_hp_pin(struct hda_codec *codec) > +{ > + struct cs_spec *spec =3D codec->spec; > + const struct auto_pin_cfg *cfg =3D &spec->gen.autocfg; > + > + if (cfg->hp_outs) > + return cfg->hp_pins[0]; > + if (cfg->line_outs && cfg->line_out_type =3D=3D AUTO_PIN_HP_OUT) > + return cfg->line_out_pins[0]; > + return 0; > +} > + > +static bool cs4208_mb81_hp_present(struct hda_codec *codec) > +{ > + hda_nid_t hp_pin =3D cs4208_mb81_hp_pin(codec); > + > + return hp_pin && snd_hda_jack_detect(codec, hp_pin); > +} > + > +static void cs4208_mb81_update_gpio(struct hda_codec *codec, bool write_= mask) > +{ > + struct cs_spec *spec =3D codec->spec; > + struct cs4208_mb81_data *mb81 =3D spec->mb81; > + bool hp_present; > + > + mutex_lock(&mb81->gpio_mutex); > + hp_present =3D cs4208_mb81_hp_present(codec); > + spec->gpio_data =3D hp_present ? > + spec->gpio_eapd_hp : spec->gpio_eapd_speaker; > + if (write_mask) > + snd_hda_codec_set_gpio(codec, spec->gpio_mask, spec->gpio_dir, > + spec->gpio_data, 0); > + else > + snd_hda_codec_write(codec, 0x01, 0, > + AC_VERB_SET_GPIO_DATA, spec->gpio_data); > + mutex_unlock(&mb81->gpio_mutex); > +} [Severity: Medium] Can cs4208_mb81_update_gpio() deadlock between mb81->gpio_mutex and codec runtime PM? During runtime resume, hda_codec_runtime_resume() calls cs_init() -> cs4208_mb81_update_gpio(codec, true), acquiring mb81->gpio_mutex inside the runtime resume callback. However, cs4208_mb81_update_gpio() also issues HDA verbs while holding mb81->gpio_mutex, and each verb in call_exec_verb() calls snd_hda_power_up_pm(codec) -> pm_runtime_get_sync(): cs_automute() cs4208_mb81_update_gpio(codec, false) mutex_lock(&mb81->gpio_mutex) snd_hda_codec_write() ... call_exec_verb() snd_hda_power_up_pm() pm_runtime_get_sync() hda_codec_runtime_resume() ... cs_init() cs4208_mb81_update_gpio(codec, true) mutex_lock(&mb81->gpio_mutex) <-- deadlocks When cs_automute() runs without the caller pinning runtime PM (such as from snd_hda_jack_unsol_event(), or from mixer control callbacks like automute_mode_put() even after commit "ALSA: hda/cs420x: Support headset mic type detection on MacBook8,1" wraps unsol_event in snd_hda_power_up()), snd_hda_gen_update_outputs() releases any temporary per-verb runtime PM reference before returning. If the codec is runtime suspended or concurrently resuming when cs4208_mb81_update_gpio() enters snd_hda_codec_write(), pm_runtime_get_sync() will run or wait for hda_codec_runtime_resume() and deadlock on mb81->gpio_mutex. Calling snd_hda_power_up_pm(codec) before mutex_lock(&mb81->gpio_mutex) and snd_hda_power_down_pm(codec) after mutex_unlock(&mb81->gpio_mutex) would keep the lock ordering consistent across all paths. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201153214.2515= 7-1-fourdollars@debian.org?part=3D1