* [PATCH] regmap: maple: Don't sync read-only registers
@ 2023-06-13 7:45 Takashi Iwai
2023-06-13 10:16 ` Mark Brown
0 siblings, 1 reply; 5+ messages in thread
From: Takashi Iwai @ 2023-06-13 7:45 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-kernel, alsa-devel
regcache_maple_sync() tries to sync all cached values no matter
whether it's writable or not. OTOH, regache_sync_val() does care the
wrtability and returns -EIO for a read-only register. This results in
an error message like:
snd_hda_codec_realtek hdaudioC0D0: Unable to sync register 0x2f0009. -5
and the sync loop is aborted incompletely.
This patch adds the writable register check in the loop for addressing
the bug.
Fixes: f033c26de5a5 ("regmap: Add maple tree based register cache")
Link: https://lore.kernel.org/r/877cs7g6f1.wl-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
drivers/base/regmap/regcache-maple.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/base/regmap/regcache-maple.c b/drivers/base/regmap/regcache-maple.c
index c2e3a0f6c218..d2dad32dd399 100644
--- a/drivers/base/regmap/regcache-maple.c
+++ b/drivers/base/regmap/regcache-maple.c
@@ -203,6 +203,8 @@ static int regcache_maple_sync(struct regmap *map, unsigned int min,
mas_for_each(&mas, entry, max) {
for (r = max(mas.index, lmin); r <= min(mas.last, lmax); r++) {
+ if (!regmap_writeable(map, r))
+ continue;
mas_pause(&mas);
rcu_read_unlock();
ret = regcache_sync_val(map, r, entry[r - mas.index]);
--
2.35.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] regmap: maple: Don't sync read-only registers
2023-06-13 7:45 [PATCH] regmap: maple: Don't sync read-only registers Takashi Iwai
@ 2023-06-13 10:16 ` Mark Brown
2023-06-13 10:34 ` Takashi Iwai
0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2023-06-13 10:16 UTC (permalink / raw)
To: Takashi Iwai; +Cc: linux-kernel, alsa-devel
[-- Attachment #1: Type: text/plain, Size: 552 bytes --]
On Tue, Jun 13, 2023 at 09:45:11AM +0200, Takashi Iwai wrote:
> regcache_maple_sync() tries to sync all cached values no matter
> whether it's writable or not. OTOH, regache_sync_val() does care the
> wrtability and returns -EIO for a read-only register. This results in
> an error message like:
> snd_hda_codec_realtek hdaudioC0D0: Unable to sync register 0x2f0009. -5
> and the sync loop is aborted incompletely.
>
> This patch adds the writable register check in the loop for addressing
> the bug.
This should be in _needs_sync().
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] regmap: maple: Don't sync read-only registers
2023-06-13 10:16 ` Mark Brown
@ 2023-06-13 10:34 ` Takashi Iwai
2023-06-13 10:59 ` Mark Brown
0 siblings, 1 reply; 5+ messages in thread
From: Takashi Iwai @ 2023-06-13 10:34 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-kernel, alsa-devel
On Tue, 13 Jun 2023 12:16:37 +0200,
Mark Brown wrote:
>
> On Tue, Jun 13, 2023 at 09:45:11AM +0200, Takashi Iwai wrote:
> > regcache_maple_sync() tries to sync all cached values no matter
> > whether it's writable or not. OTOH, regache_sync_val() does care the
> > wrtability and returns -EIO for a read-only register. This results in
> > an error message like:
> > snd_hda_codec_realtek hdaudioC0D0: Unable to sync register 0x2f0009. -5
> > and the sync loop is aborted incompletely.
> >
> > This patch adds the writable register check in the loop for addressing
> > the bug.
>
> This should be in _needs_sync().
I thought it's a different logic? regacahe_reg_needs_sync() checks
only whether it's a default value, and other call paths already check
regmap_writeable().
But I can put the check there instead if you still prefer, too.
thanks,
Takashi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] regmap: maple: Don't sync read-only registers
2023-06-13 10:34 ` Takashi Iwai
@ 2023-06-13 10:59 ` Mark Brown
2023-06-13 11:09 ` Takashi Iwai
0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2023-06-13 10:59 UTC (permalink / raw)
To: Takashi Iwai; +Cc: linux-kernel, alsa-devel
[-- Attachment #1: Type: text/plain, Size: 588 bytes --]
On Tue, Jun 13, 2023 at 12:34:45PM +0200, Takashi Iwai wrote:
> Mark Brown wrote:
> > On Tue, Jun 13, 2023 at 09:45:11AM +0200, Takashi Iwai wrote:
> > This should be in _needs_sync().
> I thought it's a different logic? regacahe_reg_needs_sync() checks
> only whether it's a default value, and other call paths already check
> regmap_writeable().
Yeah, but it feels like that's the reason we ran into this issue given
that you'd expect _needs_sync() to check this too.
> But I can put the check there instead if you still prefer, too.
It should avoid any similar issues in future.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] regmap: maple: Don't sync read-only registers
2023-06-13 10:59 ` Mark Brown
@ 2023-06-13 11:09 ` Takashi Iwai
0 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2023-06-13 11:09 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-kernel, alsa-devel
On Tue, 13 Jun 2023 12:59:27 +0200,
Mark Brown wrote:
>
> On Tue, Jun 13, 2023 at 12:34:45PM +0200, Takashi Iwai wrote:
> > Mark Brown wrote:
> > > On Tue, Jun 13, 2023 at 09:45:11AM +0200, Takashi Iwai wrote:
>
> > > This should be in _needs_sync().
>
> > I thought it's a different logic? regacahe_reg_needs_sync() checks
> > only whether it's a default value, and other call paths already check
> > regmap_writeable().
>
> Yeah, but it feels like that's the reason we ran into this issue given
> that you'd expect _needs_sync() to check this too.
>
> > But I can put the check there instead if you still prefer, too.
>
> It should avoid any similar issues in future.
OK, then let me cook the v2.
Takashi
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-06-13 11:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-13 7:45 [PATCH] regmap: maple: Don't sync read-only registers Takashi Iwai
2023-06-13 10:16 ` Mark Brown
2023-06-13 10:34 ` Takashi Iwai
2023-06-13 10:59 ` Mark Brown
2023-06-13 11:09 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox