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=1796309733; b=AmVr3TTQ9Z++rZrMioSmseDOAu1atTSwET9t9ciGszhekmHNNbbJ2OnBEkaGYaqiCt4g X+EkXDS6iOjrQtrdJlDGZCWsbZ+RyTVutPF8VNHxBJrsKe/qK8OP2qPs8On9YIHMfWsD3 UN7E1dXCHJTkOgSbnRmsEsqnQBaD2onay2wM2wuc+3TLafOWnZOt+2t/vMajvnN1LH1JB wAoxjrPyVOUiyxtBunyP64Q8zx/1czgCka1uiU8YE5fWyXjqd6W94AWFnPcgKmK5JIOmI pwaV6RRc9jZ2oulHvqU0fmZEsdk74DhWt3oMU2fVi/xlDdVgVLVN8e+tfoYCMFGF6Qg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796309733; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=+DOSE1z+3K+rboQq2GfLeOaf4MbcQJQ3VkKWsQUbXM0=; b=J54hdQHkcHnyVCMqLKrzbztNslEB1DXsl+spK4B26fJvbVfWWw4D7FRL9OiP9IQRKl96 oel5Z2bR8b/2ftO3tlxqPlmF/FWqyHCqDNKmf5MFbS9nudxWNAB+kg1EovIwitQwV1EX6 Z125SXdqhJT0ctJpx1Dle6gTr3c+2ALlPdWYyP5pUb/PRN7STKr71fsxvALJHAhrZCHJq braFTx1zq0cySUYZgolhZVEvvdx9xo3QMJAHqAC6Kw3PGHhWMwv/Pzq2opf1P1YDCiJU2 428bFFnknQEbxd8x7XWWspAoNhxbUEeOCYbeQ8XpehKbpX1TZ51mFrTB2e2uoMKkDtQ== 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=hi3+mkky; 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 DD195606A322 for ; Thu, 3 Dec 2026 14:55:33 +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=hi3+mkky Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46CFF1F00899; Thu, 3 Dec 2026 14:55:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796309733; bh=+DOSE1z+3K+rboQq2GfLeOaf4MbcQJQ3VkKWsQUbXM0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=hi3+mkkyou5ATI0HIe7TDiVpvwAalGldT9SnBYdHTcR4Ksv5eYU13sPhO5WxjQLUw 1bomNvuTgVAOcAiQBmsgSwO3lkRlcWYv4p4y7NrmWJc+p4/zILJrokwuS5VZ60KpSh bWsXPqRvVT9q2ql0FFiLRWbiTmA/LGk+WwDmyDSPTtmyQXYMBEDM/g4Kkl/j5SFIo/ B9MWeVIOwvbKJ1gFDSpvZYJD3L97tv6NkX6gtMPIsR1Tg3yePbI1QudzKyZRHI64mz W6cAlQFI4Fgo5pU/xvIs1Q/6KZ1/KJV5Zr3pI9Gv+ttPmYYao79zC69epbeF3ZJ2NN XS7lPzZ7fy8Tg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 2/8] ASoC: cs35l41: Prevent software reset when using SPI Reply-To: sashiko-reviews@lists.linux.dev To: "Stefan Binding" Cc: linux-sound@vger.kernel.org In-Reply-To: <20261203141359.150688-3-sbinding@opensource.cirrus.com> References: <20261203141359.150688-1-sbinding@opensource.cirrus.com> <20261203141359.150688-3-sbinding@opensource.cirrus.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 14:55:31 +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 3 potential issues to consider: - [Medium] ASoC: cs35l41: cs35l41_reset_and_boot() skips SPI reset on unload/rebind - [Low] ASoC: cs35l41: dev_err() called with NULL dev in cs35l41_is_spi_regmap() - [Low] ASoC: cs35l41: Fixes tag cites refactor instead of introducing commits -- commit 1cc179574843ec0efb1395f06726b215379a855a Author: Stefan Binding > ASoC: cs35l41: Prevent software reset when using SPI > > If there is any SPI Bus activity during a software reset, even if the > chip select is not set for that Amp, the amp may not boot. > > This affects both CS35L41 ASoC and HDA drivers. For HDA this also > affects system resume. > > Whilst the driver needs the amp to be reset when coming out of system > suspend, the driver will try to toggle the reset GPIO off and on to > ensure this occurs. If a reset GPIO is not defined for the amplifier, > the amplifier will not probe - unless the amp is using a shared reset. > In the case of a shared reset, the GPIO will control resets for both > amps anyway. > > Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D221161 > Fixes: 9bfbc1af0713 ("ALSA: hda: cs35l41: Add common wait_for_boot api an= d reset_and_boot api") > > Signed-off-by: Stefan Binding [Severity: Low] Should the Fixes tag cite the commits that originally introduced the software reset on SPI rather than the refactor 9bfbc1af0713 ("ALSA: hda: cs35l41: Add common wait_for_boot api and reset_and_boot api")? Commit 2ee06ff5d7cf ("ALSA: hda: cs35l41: Force a software reset after hardware reset") added the HDA software reset and commit a04a1a820f37 ("ASoC: cs35l41: Use common wait_for_boot and reset_and_boot apis") brought it to ASoC. Citing only the refactor hides older stable trees: Fixes: 2ee06ff5d7cf ("ALSA: hda: cs35l41: Force a software reset after ha= rdware reset") Fixes: a04a1a820f37 ("ASoC: cs35l41: Use common wait_for_boot and reset_a= nd_boot apis") > diff --git a/sound/soc/codecs/cs35l41-lib.c b/sound/soc/codecs/cs35l41-li= b.c > index 9e6bed22fbdb5..e11810795ee86 100644 > --- a/sound/soc/codecs/cs35l41-lib.c > +++ b/sound/soc/codecs/cs35l41-lib.c [ ... ] > @@ -1588,6 +1589,18 @@ int cs35l41_exit_hibernate(struct device *dev, str= uct regmap *regmap) > } > EXPORT_SYMBOL_GPL(cs35l41_exit_hibernate); > =20 > +static bool cs35l41_is_spi_regmap(struct regmap *regmap) > +{ > + struct device *dev =3D regmap_get_device(regmap); > + > + if (!dev) { > + dev_err(dev, "Failed to get device from regmap\n"); > + return false; > + } > + > + return (IS_ENABLED(CONFIG_SPI) && dev->bus =3D=3D &spi_bus_type); > +} [Severity: Low] Is passing dev to dev_err() inside the if (!dev) branch intentional? __dev_printk() guards against NULL and logs "(NULL device *)", so this won't crash, but it drops device context. Since cs35l41_reset_and_boot() already receives struct device *dev, this helper could check that dev directly and drop the regmap_get_device() lookup and error path. [ ... ] > @@ -1627,27 +1640,36 @@ int cs35l41_reset_and_boot(struct device *dev, st= ruct regmap *regmap) > { > int ret; > =20 > - ret =3D regmap_write(regmap, CS35L41_SFT_RESET, CS35L41_SOFTWARE_RESET); > - if (ret) { > - dev_warn(dev, "Failed to write software reset: %d\n", ret); > - > + if (cs35l41_is_spi_regmap(regmap)) { > /* > - * If the write failed, it is likely because the chip is still booting= after a > - * reset. Wait for boot, then retry the software reset. If the initial= write failed > - * for another reason, then either waiting for boot, or the second wri= te will fail, > - * So we can return the error then. > + * If there is any SPI Bus activity during a software reset, even if t= he > + * chip select is not set for that Amp, the amp may not boot. > */ > - ret =3D cs35l41_wait_boot_done(dev, regmap); > - if (ret) > - return ret; > + dev_dbg(dev, "Preventing Software Reset on SPI\n"); > =20 > + } else { [Severity: Medium] As reported by Mark Brown on v2 [1], what happens on driver unload/reload or unbind/rebind for an SPI amplifier without an owned reset GPIO? cs35l41_probe() gets reset_gpio with devm_gpiod_get_optional() (clearing it on -EBUSY for shared resets), and HDA secondary shared-reset amps also probe with reset_gpio set to NULL. Neither remove path issues an SPI software reset, so re-probing now skips CS35L41_SFT_RESET altogether. That leaves hardware in its prior state while devm_regmap_init_spi() seeds a fresh REGCACHE_MAPLE cache with defaults, causing cache divergence on regmap_update_bits() and -ETIMEDOUT in HDA cs35l41_wait_boot_done() if CS35L41_OTP_BOOT_DONE was already cleared. Commit "ALSA: hda/cs35l41: Ensure SPI devices are always reset during system suspend" only handles HDA suspend aborts in cs35l41_system_suspend(), leaving unload/reload and unbind/rebind unaddressed. [1] https://lore.kernel.org/r/179574575897.838304.8691157769089102804.b4-re= view@b4 --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203141359.1506= 88-1-sbinding@opensource.cirrus.com?part=3D2