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 A87433BBF2; Mon, 4 Aug 2025 00:31:14 +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=1754267474; cv=none; b=lcxsQSbUSuFRiUxU9XSvwWxv9kflvpIT1sILpqeTbWwXM+BZpx+B3MAAw3vo7HwqOGUjtRuol82UiuzVlCEkVLztvNZFlBR2BkpEKwA7/t6XfLdF/mFuWflXjZyvXVvB1uEP/BOc6SVPAkQQC5Wk5dVBguG+5InCsVP9Hfg/grk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754267474; c=relaxed/simple; bh=gSAvcfQnGfkdZ1blGp/WG3UsF1bLnPIjK+fk8e3G8PA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=kP0/ib2k79TT0HMlIJ3FS1MG0WQ0ggDiJhDNnQblKy07vM6SlMj99XNvL9wFJz09GkWYo7brUzdxv3iWOAlIuCrsBEJDC7iej5BpsfE5pyu9S7OjYWZy0Lz5L7KEYi/YUqF4C0+tWFgx0w+2WIdaaafQdAOc9wyJUOXTF77p5ac= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z8xoGu02; 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="Z8xoGu02" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23545C4CEF0; Mon, 4 Aug 2025 00:31:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1754267474; bh=gSAvcfQnGfkdZ1blGp/WG3UsF1bLnPIjK+fk8e3G8PA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z8xoGu02bbAC+fDQ61m9byLSV23fQQ5A3dcn7L9LAqtXbx6zSN0g5Kd7V20bTiIKd b/fLwkt6bUdF+o1Q8GNFjnwYeLQh8477onhK/JcUJwq+cpKGZpYS0K/agk+wGfeT3I uamkE+FowT7rzKLAEipDdmllWFACPNXF8LIcajXNSQ7w9uI4xQNPYy1tOh1rUDQZ8X oEmQIUR5c0LCqLUmRE4UPvMGJLHRBfrautzziqIW9tTMN3YcwRG7FZJ5SkjjGD4Opd tmylD2CGC3mqn48aWop4fJgGov/3BKSlRCGAVDuqQ1gqVPS3oiTznWn0rsuwnmQuuZ NsGDU+5LD3yUA== From: Sasha Levin To: patches@lists.linux.dev, stable@vger.kernel.org Cc: Xinxin Wan , =?UTF-8?q?Amadeusz=20S=C5=82awi=C5=84ski?= , Cezary Rojewski , Mark Brown , Sasha Levin , oder_chiou@realtek.com Subject: [PATCH AUTOSEL 6.15 79/80] ASoC: codecs: rt5640: Retry DEVICE_ID verification Date: Sun, 3 Aug 2025 20:27:46 -0400 Message-Id: <20250804002747.3617039-79-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250804002747.3617039-1-sashal@kernel.org> References: <20250804002747.3617039-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.15.9 Content-Transfer-Encoding: 8bit From: Xinxin Wan [ Upstream commit 19f971057b2d7b99c80530ec1052b45de236a8da ] To be more resilient to codec-detection failures when the hardware powers on slowly, add retry mechanism to the device verification check. Similar pattern is found throughout a number of Realtek codecs. Our tests show that 60ms delay is sufficient to address readiness issues on rt5640 chip. Reviewed-by: Amadeusz Sławiński Reviewed-by: Cezary Rojewski Signed-off-by: Xinxin Wan Signed-off-by: Cezary Rojewski Link: https://patch.msgid.link/20250530142120.2944095-3-cezary.rojewski@intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- LLM Generated explanations, may be completely bogus: **Backport Status: YES** This commit should be backported to stable kernel trees. Here's my detailed analysis: ## Analysis of the Commit ### 1. Bug Fix Nature This commit fixes a real-world hardware detection issue where the RT5640 codec device ID verification fails on systems where the hardware powers on slowly. The failure results in the driver returning `-ENODEV` and the audio codec not being initialized, causing complete audio failure. ### 2. Small and Contained Change The fix is minimal and highly contained: - Only adds 3 lines of code - The change is isolated to the probe function's device ID verification logic - No architectural changes or new features introduced - The retry logic is simple: if initial ID read doesn't match, wait 60-100ms and retry once ### 3. Clear Purpose with No Major Side Effects The code change: ```c regmap_read(rt5640->regmap, RT5640_VENDOR_ID2, &val); +if (val != RT5640_DEVICE_ID) { + usleep_range(60000, 100000); + regmap_read(rt5640->regmap, RT5640_VENDOR_ID2, &val); +} ``` - Only adds a single retry with delay if the first read fails - The delay (60-100ms) is reasonable for probe-time initialization - No impact on normal operation when hardware is ready ### 4. Follows Established Pattern The commit message mentions "Similar pattern is found throughout a number of Realtek codecs," and the probe function already contains a 400ms delay after enabling LDO1 (line 3004), showing that power-on delays are expected for this hardware. ### 5. Minimal Risk of Regression - The retry only occurs when device ID verification would have failed anyway - In the worst case, it adds a 60-100ms delay to failed probe attempts - Systems where the codec is ready immediately continue to work without delay - The pattern is conservative: only one retry attempt ### 6. Important User Impact Without this fix, affected systems experience: - Complete audio failure on boot - No audio codec detection - Requires manual intervention or multiple reboots to get audio working ### 7. Stable Tree Suitability This fix meets all stable kernel criteria: - Fixes a real bug affecting users - Minimal change with clear purpose - No new features or APIs - Low risk of introducing new issues - Self-contained within a single driver The commit represents a classic hardware quirk fix that improves reliability without adding complexity, making it an ideal candidate for stable backport. sound/soc/codecs/rt5640.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 21a18012b4c0..55881a5669e2 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -3013,6 +3013,11 @@ static int rt5640_i2c_probe(struct i2c_client *i2c) } regmap_read(rt5640->regmap, RT5640_VENDOR_ID2, &val); + if (val != RT5640_DEVICE_ID) { + usleep_range(60000, 100000); + regmap_read(rt5640->regmap, RT5640_VENDOR_ID2, &val); + } + if (val != RT5640_DEVICE_ID) { dev_err(&i2c->dev, "Device with ID register %#x is not rt5640/39\n", val); -- 2.39.5