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=1796289824; b=gnI346DyY+UJSOIRt/n8Q2t7QUrCAmBFoXrl2mTG3AwDxfi79iPMt0niuOkk0FOefQiV PQ6Z7aFNiF5U0aL34cxSTEzkGHEAoGpgScG7JSUYmyPXvw8D58eGIGb0vZLRzszf/E5B0 vX1cxZsGqwt03W8IJHAA8u97wJgxlJHbsAOqeUvsgIjZsum4guNQWia7VcGgj8Q3r6iRT v7UZ+ieKhfBHEziDvwaCnuCiLzS7x+OLl+6pU7I1dbIHllW4aKFDn4yaSqEY4tmX/pWkI nXQgcj+17IpEppEwI6AtMPGRMG4YSKxG2wwN5pTGkLy6RB7+GoMdJT82Mo6s1bO1uLA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796289824; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Ouo5WKN8AJn0QrWA3KNrl6suFKzau42hNdk83sJkFgA=; b=GXnR8XviUDDIwHEnpvoVXjNHzn0IPJ8RjcrKvSxWYL7B7oQgvhPfeQW1YobLWvN8LXs3 98lsciw6Sdtfg5I4BgpcMC4jUae+1asyYfObxr1z6AJkkdHCsK62LZOebYcCOEnIA8Pxf iDM/o+elBQ3RQeeXHuwm4A/Btehr4WLLAkswZZiNCIz4HLxLdTYqvZKdHqaQodm849MtV AHGz82dFOuxFjkYntLL+GDjySHKw3hz7qnBAdmOChreDwjXKAaf5Ff8ZEQSZLmYZrCTFl 8ByfpcxP7mQzDsFp4Z02O6XLzuVJSC2aXIE95guE8nMluhN6k0PiSMSw0wH9FxpJzrw== 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=duTEXoXZ; 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 561BE606A322 for ; Thu, 3 Dec 2026 09:23:44 +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=duTEXoXZ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06F171F000C1; Thu, 3 Dec 2026 09:23:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796289824; bh=Ouo5WKN8AJn0QrWA3KNrl6suFKzau42hNdk83sJkFgA=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=duTEXoXZDqOenpqK/YL1zZjgd1HpIl2HTVK7ufxcZkKysq7cRFKrVG62hTH6xPjWs ldnWl1QrYaAT+DAXZji/BlJjuUiPf/NnItB/HiBZsgxhe04WXo7sz3YnR/urC8x0t1 85JmUIsvmFNGlsSNkFVejN/OEj9NgbcrfYAtPCijkO8PQKVkUF1rSfC8M2aVxk1wif iibdt3ZOpDbIMq3AVvS7JiFM7pay7X4x3shNEUzUAmx5RtvjrOv+Pqqqn3jyeys9Gq 6AdHhcHOmGBRW7d2KDGb2ROtnqeNmnbNWwl3X7wioQaK59Uwe/PUzK/LPOFsxz/FHU 1rA0LWN6ADU8w== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] ASoC: rt5645: stop jack detection on component remove Reply-To: sashiko-reviews@lists.linux.dev To: "Yaohan Li" Cc: linux-sound@vger.kernel.org In-Reply-To: <20261203085309.2392653-1-shunsheng1218@gmail.com> References: <20261203085309.2392653-1-shunsheng1218@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 09:23:43 +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: - [Low] ASoC: rt5645: data race on en_button_func in rt5645_set_bias_level() -- commit 99a615fa9435b7376ff9a3e1e4c3496127c1c760 Author: Yaohan Li ASoC: rt5645: stop jack detection on component remove This patch serializes access to rt5645->component and the jack pointers under jd_mutex, clears them and stops btn_check_timer and jack_detect_work in rt5645_remove(), and moves snd_soc_jack_report() outside jd_mutex. It also queues and flushes jack_detect_work in rt5645_sys_resume() instead of calling the work handler directly. > diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c > index e14b66d3118da..92a54e66f14c3 100644 > --- a/sound/soc/codecs/rt5645.c > +++ b/sound/soc/codecs/rt5645.c > @@ -3278,19 +3278,28 @@ int rt5645_set_jack_detect(struct snd_soc_compone= nt *component, > { > struct rt5645_priv *rt5645 =3D snd_soc_component_get_drvdata(component); > =20 > - rt5645->hp_jack =3D hp_jack; > - rt5645->mic_jack =3D mic_jack; > - rt5645->btn_jack =3D btn_jack; > - if (rt5645->btn_jack && rt5645->codec_type =3D=3D CODEC_TYPE_RT5650) { > - rt5645->en_button_func =3D true; > - regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1, > - RT5645_GP1_PIN_IRQ, RT5645_GP1_PIN_IRQ); > - regmap_update_bits(rt5645->regmap, RT5645_GEN_CTRL1, > - RT5645_DIG_GATE_CTRL, RT5645_DIG_GATE_CTRL); > - regmap_update_bits(rt5645->regmap, RT5645_DEPOP_M1, > - RT5645_HP_CB_MASK, RT5645_HP_CB_PU); > + scoped_guard(mutex, &rt5645->jd_mutex) { > + if (!rt5645->component) > + return -ENODEV; > + > + rt5645->hp_jack =3D hp_jack; > + rt5645->mic_jack =3D mic_jack; > + rt5645->btn_jack =3D btn_jack; > + if (rt5645->btn_jack && rt5645->codec_type =3D=3D CODEC_TYPE_RT5650) { > + rt5645->en_button_func =3D true; > + regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1, > + RT5645_GP1_PIN_IRQ, RT5645_GP1_PIN_IRQ); > + regmap_update_bits(rt5645->regmap, RT5645_GEN_CTRL1, > + RT5645_DIG_GATE_CTRL, RT5645_DIG_GATE_CTRL); > + regmap_update_bits(rt5645->regmap, RT5645_DEPOP_M1, > + RT5645_HP_CB_MASK, RT5645_HP_CB_PU); > + } else { > + rt5645->en_button_func =3D false; > + } [Severity: Low] Can this write to rt5645->en_button_func race with rt5645_set_bias_level()? During card teardown, soc_cleanup_card_resources() calls snd_soc_link_exit() before snd_soc_flush_all_delayed_work(). On RT5650 boards whose machine driver clears the jack in dai_link->exit() (such as mt8189-nau8825) and leaves playback pmdown_time enabled, snd_soc_close_delayed_work() can run concurrently under card->dapm_mutex: CPU0 CPU1 soc_cleanup_card_resources() snd_soc_dapm_shutdown() snd_soc_link_exit() snd_soc_close_delayed_work() mt8189_headset_codec_exit() snd_soc_dapm_stream_event() rt5645_set_jack_detect() dapm_power_widgets() lock(&rt5645->jd_mutex) rt5645_set_bias_level() rt5645->en_button_func =3D false if (rt5645->en_button_func) <-- data race If rt5645_jack_detect_work() dirties forced supply pins between snd_soc_dapm_shutdown() and snd_soc_link_exit(), dapm_power_widgets() transitions the codec back to SND_SOC_BIAS_STANDBY and reads rt5645->en_button_func without holding jd_mutex. This is a KCSAN data race, though reading a stale true value only queues jack_detect_work redundantly before rt5645_remove() cancels it. Since rt5645_set_bias_level() runs under card->dapm_mutex and cannot take jd_mutex without inverting lock order with rt5645_jack_detect_work(), using READ_ONCE() and WRITE_ONCE() on rt5645->en_button_func would avoid the race. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203085309.2392= 653-1-shunsheng1218@gmail.com?part=3D1