Re: [PATCH 3/3] ASoC: tas2783: drop firmware-owned registers from the regmap cache

Mark Brown <[email protected]>
Newsgroups org.kernel.vger.linux-sound,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Sun, Aug 09, 2026 at 10:16:10AM +0000, Ville Saarinen wrote:

> The firmware image is downloaded with sdw_nwrite_no_pm(), which writes
> straight to the peripheral and bypasses the regmap cache. The cache keeps
> holding the tas2783_reg_default[] entries for every register the firmware
> image owns, so cache and device disagree from the moment the download
> completes.

> +		/*
> +		 * The firmware image is written with sdw_nwrite_no_pm(), which
> +		 * bypasses the regmap cache. The cache therefore keeps holding
> +		 * the stale reg_defaults entries for every register the
> +		 * firmware owns, and the regcache_sync() done on resume writes
> +		 * those defaults back out over the firmware tuning. That wipes
> +		 * the per-amp configuration, including the channel assignment,
> +		 * and leaves the speakers silent until the next full re-init.
> +		 *
> +		 * Drop the firmware-owned registers from the cache so nothing
> +		 * stale can ever be synced over them. This is safe because a
> +		 * suspend deep enough to lose device state also takes the
> +		 * peripheral UNATTACHED, which clears hw_init and triggers a
> +		 * full firmware re-download on re-attach.
> +		 */
> +		if (file->length)
> +			regcache_drop_region(tas_dev->regmap, file->dest_addr,
> +					     file->dest_addr + file->length - 1);
> +

Are there any controls with values that come from the firmware, and
shouldn't we do this before rather than after the firmware download?  In
general this feels like the wrong shape of fix, it feels like the
problem here is that we've got a register cache for the (somewhat)
dynamic values written by the firmware download but we never synchronize
those two.  I think a more robust fix is probably a combination of
writing the firmware values into the cache and marking registers that
get programmed by firmware download but should never be cached for
whatever reason as volatile.
signature.asc (application/pgp-signature, 488 B)
-----BEGIN PGP SIGNATURE-----

iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmp8xA4ACgkQJNaLcl1U
h9DRewf+PdDWe2/OmQna3KDFecd8RTcN2vfxuUkeZfYbNEziLvzEdBv3uuwm/rrO
nr9DnHCqXSOS6eejYHElYflsNwkXwVn9+qa2c1v+iOuPfDVZjLe8iPwYO/8jcxva
aKIFNEhucdkn3E9t4oGnw2ABxGqkVpSlfgp9fuh3w75z3l4JytjpezHI+cVdLAJS
DnBoh4N0B2cxsX6c1Z28ww1HrslTSBAoDm3KHxK3X7LxOdqg77KM7kQeJAuXbyo2
OBewrJaGGDA0Ue2H1uwwJi7lh+nYkaq86EwinGFrTOz9d8bNwI4SQJIL9JndBraB
+0SEd5V9XPEE8u6o4giE4W1G2iW5ig==
=Dlx9
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.