From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51CCF224895; Mon, 9 Jun 2025 22:52:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749509576; cv=none; b=gzK6CWIbM4dF4cx1N14rrp1yItZozldfZmwbrSmLj5rbkXM8K8iWkJp2cqH/HqMF6mF9upDT/8jH0HJXuX12IKr3IO8AjJO7TqlDpWjXEG69Aj8ooullmDxJLYsid2/y27Eb/57HI43Yzuyoy9Lk1ao2BECbvUcMM/pHzmUJHAs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749509576; c=relaxed/simple; bh=/Sxb9tbEBR9oK11SSHWoCqhfech9mjueso2ZqqCrIYs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=tB/ywy5Lnhg7Ep0nrJdOXABHVwYAisOORN+Az9rmf+W0hpmOyQRvVSyYbOayVOllSE1DpJWF9gUimjifCcW9J/zhrSIzlcdQRHIGcxnGtMl3OSehjZoqlbBF7j33FZc4FsUPeD9YlgfVZ4ottI50/j7WEgwzDlz5pI9oOGfyXek= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lanwuHIO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lanwuHIO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F0A7C4CEED; Mon, 9 Jun 2025 22:52:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1749509576; bh=/Sxb9tbEBR9oK11SSHWoCqhfech9mjueso2ZqqCrIYs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lanwuHIOgnn8SG4eL+ftQbQ8kmIMp1dnvdGPxQ9wG343MMy6yYIARZSFArW+ILTqF 2s7yCyhr2up/AuzjbAcIcLIf1hwUKNH7n/kO7YQYahNAlB7Squ/usL1dMX0wxPkjGB wBypI59OuoHu/CPNSTAN0VrG0TOGIY4dsh94iS9/9EiCZuL54ECyNWtCQnvsda/2iK mTqB9Bm3QV3J94Gw8gJXuaHIaOpHaKKR27kHJT2zJ8xzZ4vGKm7bwuhRFrSEx314Y2 HyCA2j+XRc23OYEvkVJwCuHDp/Efdu9DrdZmwynvEzs9Q55PIWjEVsDhSCpaxqYKlO CxYGKmwbDEwtw== From: Sasha Levin To: patches@lists.linux.dev, stable@vger.kernel.org Cc: Cezary Rojewski , =?UTF-8?q?Amadeusz=20S=C5=82awi=C5=84ski?= , Takashi Iwai , Sasha Levin , gregkh@linuxfoundation.org Subject: [PATCH AUTOSEL 6.14 04/11] ALSA: hda: Ignore unsol events for cards being shut down Date: Mon, 9 Jun 2025 18:52:38 -0400 Message-Id: <20250609225246.1443679-4-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250609225246.1443679-1-sashal@kernel.org> References: <20250609225246.1443679-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.14.10 Content-Transfer-Encoding: 8bit From: Cezary Rojewski [ Upstream commit 3f100f524e75586537e337b34d18c8d604b398e7 ] For the classic snd_hda_intel driver, codec->card and bus->card point to the exact same thing. When snd_card_diconnect() fires, bus->shutdown is set thanks to azx_dev_disconnect(). card->shutdown is already set when that happens but both provide basically the same functionality. For the DSP snd_soc_avs driver where multiple codecs are located on multiple cards, bus->shutdown 'shortcut' is not sufficient. One codec card may be unregistered while other codecs are still operational. Proper check in form of card->shutdown must be used to verify whether the codec's card is being shut down. Reviewed-by: Amadeusz Sławiński Signed-off-by: Cezary Rojewski Link: https://patch.msgid.link/20250530141309.2943404-1-cezary.rojewski@intel.com Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- **YES** This commit should be backported to stable kernel trees. Here's my extensive analysis: ## Technical Analysis ### Core Problem Being Fixed The commit addresses a **shutdown race condition** in multi-codec HDA systems, specifically in DSP/AVS drivers where multiple HDA codecs exist on the same sound card but with separate bus instances. The change modifies line 47 in `sound/pci/hda/hda_bind.c`: **Before:** ```c if (codec->bus->shutdown) return; ``` **After:** ```c if (codec->card->shutdown || codec->bus->shutdown) return; ``` ### Why This is a Good Backport Candidate **1. Bug Fix Nature - Small and Contained** - This is a clear **bug fix** addressing a specific shutdown race condition - The change is **minimal** (adding one condition check) and **well- contained** - No architectural changes or new features introduced - Low risk of introducing regressions **2. Critical Subsystem Impact** - Affects **HD-audio subsystem** which is critical for audio functionality - Could prevent system crashes or hangs during shutdown in multi-codec scenarios - Improves system stability during shutdown sequences **3. Technical Correctness** The fix addresses a **fundamental timing issue**: - In multi-codec systems, `card->shutdown` is set at the ALSA core level during `snd_card_disconnect()` - `bus->shutdown` is set later at the HDA controller level during individual codec shutdown - **Gap exists** where unsol events could be processed after card shutdown but before bus shutdown - This can cause codec operations on an already-disconnected sound card **4. Follows Stable Tree Criteria** - **Important bug fix**: Prevents potential system instability during shutdown - **Minimal risk**: Only adds an additional safety check, doesn't change existing logic - **Well-understood**: The change is straightforward and follows existing patterns seen in similar commits - **Confined to subsystem**: Only affects HDA audio subsystem **5. Consistency with Similar Backported Commits** This follows the exact same pattern as the historical commits that were successfully backported: - **Similar Commit #1**: Added `bus->shutdown` check to prevent unsol events during shutdown - **Backported (YES)** - **Similar Commit #2**: Added suspend/resume state check to unsol handler - **Backported (YES)** - **Similar Commit #3**: Added jack disconnection during codec unbind - **Backported (YES)** - **Similar Commit #4**: Added bus_probing flag to serialize codec registration - **Backported (YES)** All these commits follow the same pattern: **small, targeted fixes to prevent race conditions in HDA shutdown/initialization sequences**. **6. Real-World Impact** - Affects **DSP/AVS audio systems** which are increasingly common in modern hardware - Without this fix, systems with multiple audio codecs could experience: - Kernel oops during shutdown - System hangs - Audio subsystem corruption - Unpredictable behavior during reboot sequences ### Risk Assessment **Very Low Risk:** - The change only **adds** a safety check, doesn't remove existing functionality - `card->shutdown` check is used extensively throughout the ALSA subsystem already - Maintains **backward compatibility** completely - If `card->shutdown` is false, behavior is identical to before - No changes to data structures, APIs, or functional logic ### Conclusion This commit represents a **textbook stable backport candidate**: it's a small, well-understood bug fix that addresses a real stability issue in a critical subsystem with minimal risk of regression. The pattern matches multiple previously successful backports in the same subsystem, and the technical merit is clear. sound/pci/hda/hda_bind.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/hda/hda_bind.c b/sound/pci/hda/hda_bind.c index b7ca2a83fbb08..95786bdadfe6a 100644 --- a/sound/pci/hda/hda_bind.c +++ b/sound/pci/hda/hda_bind.c @@ -44,7 +44,7 @@ static void hda_codec_unsol_event(struct hdac_device *dev, unsigned int ev) struct hda_codec *codec = container_of(dev, struct hda_codec, core); /* ignore unsol events during shutdown */ - if (codec->bus->shutdown) + if (codec->card->shutdown || codec->bus->shutdown) return; /* ignore unsol events during system suspend/resume */ -- 2.39.5