Re: Linux 6.6.3

From: Matthias Reichl
Date: Fri Dec 01 2023 - 14:56:01 EST


On Tue, Nov 28, 2023 at 06:27:10PM +0000, Greg Kroah-Hartman wrote:
> Mark Brown (1):
> regmap: Ensure range selector registers are updated after cache sync

This commit caused a regression, accessing a pcm512x based soundcard now
fails with EINVAL and dmesg shows sync cache and pm_runtime_get errors:

# speaker-test -D hw:CARD=PCM5122,DEV=0 -c 2 -t sine
speaker-test 1.1.8

Playback device is hw:CARD=PCM5122,DEV=0
Stream parameters are 48000Hz, S16_LE, 2 channels
Sine wave rate is 440.0000Hz
Playback open error: -22,Invalid argument
# dmesg | grep pcm512x
[ 228.794676] pcm512x 1-004c: Failed to sync cache: -22
[ 228.794740] pcm512x 1-004c: ASoC: error at snd_soc_pcm_component_pm_runtime_get on pcm512x.1-004c: -22

We initially noticed that on the downstream RPi kernels 6.6.3 and
6.1.64 https://github.com/raspberrypi/linux/issues/5763 and
I now reproduced that with vanilla 6.6.3 running on a RPi2
(multi_v7_defconfig plus CONFIG_SND_SOC_PCM512x_I2C and a pcm5122
soundcard with simple-audio-card driver).

Reverting the commit fixes the issue.

I'm not familiar with the regcache code but it looks a bit like the
return value from the regcache_read check is leaking out - not
assigning the value to ret seems to resolve the issue, too
(no idea though if that would be the correct fix):

diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index 92592f944a3df..ac63a73ccdaaa 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -410,8 +410,7 @@ int regcache_sync(struct regmap *map)
rb_entry(node, struct regmap_range_node, node);

/* If there's nothing in the cache there's nothing to sync */
- ret = regcache_read(map, this->selector_reg, &i);
- if (ret != 0)
+ if (regcache_read(map, this->selector_reg, &i) != 0)
continue;

ret = _regmap_write(map, this->selector_reg, i);

so long,

Hias