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=1796376680; b=4gQ94W7WBy92dhGoa4XvHm27LMV06htuRvZVHFa3UvcDN9bs8FAnVAs0u9/lkZqmHP+E XHp9PALlw2tNWG/LfxAE/wWqsKuwyWl66RFRTti04pnybPV9EeI9BeJzADbtz1csw8lyj uMyORA+m0PthPgWWDC/qxn6pVZilaFq4/Pd4yOv2xN7FCJ0U4+XxDZxh+LevO6FKdJBwP sFVOMtyXjXT4kaq6orT2bBNzk2lN2IbKltD9r9EE5A3f2SXtcC/k89xJzxulfRk72hi2W yODCMbNyPjp6cGcv/ElGzpOx/rt8Hk5qYt8xdgAFXMi64NG0WZAayKolExYf2MztasQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796376680; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=5J5M2Kc0r08MQ5p1GLDWjmAVUWdK0gckrw4/qPBHB6g=; b=sW0gKQREAz3iym1zo6gvF2guHOk5W14OmFI82mq/F50DmHBgB6njV75mrLKAWPI2A053 FudOpFpfSmT5zmQ9qVciz80HLRYnQnUg3PdHlOxStByZRz/EgDKjXNV2kM+MoIALhVJtj O6gQHdQj5dFjKeTW8uLcB2wYC3anRhENrSNyN/EaVPkv3ATHlIAFbKKXplp9k4rkcnOML 2s0CW1DRC8/B0f27me2g0qJHAEAnXzdEagXINqWLFvzZj5oNAfHMeG/wtbQ4V0o8IKje/ R6g6lbdOtSpHP67NhET+B1UucuBMCH19+gK86JWwcB5vXEGPnIkPGH2apgOdIzxu4Jw== 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=NNCzQzkJ; 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 D1899606A333 for ; Fri, 4 Dec 2026 09:31:20 +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=NNCzQzkJ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57B511F000C2; Fri, 4 Dec 2026 09:31:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796376680; bh=5J5M2Kc0r08MQ5p1GLDWjmAVUWdK0gckrw4/qPBHB6g=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=NNCzQzkJroJKfksvQjc7U8M7cbX0HFJ06ZMN9nCStTZ/fhLTDcDESs4+qakdw2z3s 4zA8ujZVkxlm4sDO4b5H72A19CIyLXDvZH79KlvthqYVUtOIkY1avmqAqF0vS4aOEi b58oKGbF0lqbtETCtaSSie1eyfnLYf1Zm4MHYR0b7PILcrn/dP34z+39yTCWY4bw1I 5lYTbY+Sj3js0F4th3Ej9QhoijXOYYVXNtv60qQAFdVNYEEonjIOae0qWafCeKFctz vqelOn3uwwyu2bh4HdASNAbdbLIp7aBpxlyA/WW59eySd/vdypp6UcYamET8uZLiwo rjfIiiY7hM8fg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2] ALSA: hda: Reset jack_detect on failure Reply-To: sashiko-reviews@lists.linux.dev To: "Sreeraj S Kurup" Cc: linux-sound@vger.kernel.org In-Reply-To: <20261204090300.3099-1-sreekuttan2156239@gmail.com> References: <20261204074922.2913-1-sreekuttan2156239@gmail.com> <20261204090300.3099-1-sreekuttan2156239@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 09:31:20 +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 2 potential issues to consider: - [Medium] ALSA: hda: unlocked hda_jack_tbl bitfield race on jack_detect reset - [Medium] ALSA: hda: race from setting jack_detect before verb write completes -- commit e13216d6c208b5b57631ab503cd320a4c0cfba0f Author: Sreeraj S Kurup ALSA: hda: Reset jack_detect on failure This commit resets jack->jack_detect to 0 in snd_hda_jack_detect_enable_callback_mst() when snd_hda_codec_write_cache() fails, allowing subsequent calls to retry enabling unsolicited responses. > diff --git a/sound/hda/common/jack.c b/sound/hda/common/jack.c > index 6b8aa1a6c0084..9fda0bdd97e93 100644 > --- a/sound/hda/common/jack.c > +++ b/sound/hda/common/jack.c > @@ -364,8 +364,10 @@ snd_hda_jack_detect_enable_callback_mst(struct hda_c= odec *codec, hda_nid_t nid, > err =3D snd_hda_codec_write_cache(codec, nid, 0, > AC_VERB_SET_UNSOLICITED_ENABLE, > AC_USRSP_EN | jack->tag); > - if (err < 0) > + if (err < 0) { > + jack->jack_detect =3D 0; > return ERR_PTR(err); > + } [Severity: Medium] Can resetting jack->jack_detect on failure introduce a data race with jack->jack_dirty updates? In struct hda_jack_tbl, jack_detect and jack_dirty are 1-bit fields in the same unsigned int with no lock protecting them. Previously, jack->jack_detect was set once at probe and never cleared, so later calls returned early without writing the bitfield. With this change, a codec whose init callback ignores errors (such as snd_hda_hdmi_simple_init()) retries enabling jack detection on runtime resume, where unsolicited event work can still run because dev.power.power_state.event stays PM_EVENT_ON: CPU0 (runtime resume) CPU1 (bus->unsol_work) hda_codec_runtime_resume() snd_hdac_bus_process_unsol_events() hda_call_codec_resume() hda_codec_unsol_event() snd_hda_hdmi_simple_init() snd_hda_hdmi_simple_unsol_event() ... snd_hda_jack_set_dirty_all() jack->jack_detect =3D 1; jack->jack_dirty =3D 1; <-- bitfield data race jack->jack_detect =3D 0; Concurrent non-atomic read-modify-write operations on the shared word can lose a jack_dirty =3D 1 update (dropping a hotplug event) or overwrite jack_detect. [Severity: Medium] Should jack->jack_detect only be set after snd_hda_codec_write_cache() succeeds, rather than setting it beforehand and rolling it back? During a bus reset, snd_hda_bus_reset_codecs() calls hda_call_codec_resume() whenever hda_codec_is_power_on() is true, including during RPM_RESUMING. After a probe-time failure on a simplehdmi codec, this can race with runtime resume: CPU0 (runtime resume) CPU1 (bus reset) snd_hda_hdmi_simple_init() snd_hda_bus_reset_codecs() ... hda_call_codec_resume() jack->jack_detect =3D 1; snd_hda_hdmi_simple_init() ... if (jack->jack_detect) return callback; <-- skipped snd_hda_codec_write_cache() fails jack->jack_detect =3D 0; CPU1 skips enabling unsolicited responses because it sees the transient jack_detect =3D=3D 1, and its regmap sync does not write AC_VERB_SET_UNSOLICITED_ENABLE because it is not cached yet. Jack detection then stays disabled until a later resume retries. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204090300.3099= -1-sreekuttan2156239@gmail.com?part=3D1