mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sander Vanheule <sander@svanheule.net>
To: Mark Brown <broonie@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] regmap: add cache validity to REGCACHE_FLAT
Date: Thu, 16 Oct 2025 10:46:33 +0200	[thread overview]
Message-ID: <0b2fa71f1ccd49d66ca02b6c44ba8fe2135e9b6f.camel@svanheule.net> (raw)
In-Reply-To: <a2f7e2c3-f072-40f7-a865-5693b82b636e@sirena.org.uk>

Hi Mark,

On Thu, 2025-01-09 at 20:11 +0000, Mark Brown wrote:
> On Thu, Jan 09, 2025 at 07:02:55PM +0100, Sander Vanheule wrote:
> > The flat regcache will always assume the data in the cache is valid.
> > Since the cache takes priority over hardware values, this may shadow the
> > actual state of the device. This is not the case with REGCACHE_RBTREE
> > for example, which makes these implementation behave differently.
> 
> This is causing spurious events to be generated by the audio drivers on
> Pine64 Plus, the audio drivers for that do use the flat cache (see
> sound/soc/sunxi):
> 
>    https://lava.sirena.org.uk/scheduler/job/1056879#L1897
> 
> I haven't investigated yet but I suspect this is going to have been
> triggered by the change from assuming all registers default to 0 if not
> otherwise specified to reading back from the hardware if the first
> access is a read.  That does seem a bit like a driver bug (I'm not clear
> on the precise mechanism apart from anything else) but I worry that
> it'll be a widespread one where things do read/modify/write cycles.
> There may also be initialisation from suspend issues where we stop
> resetting values after resume.  We do need a plan for this, possibly we
> should default to the old behaviour.
> 
> It's definitely too late in the release cycle to apply the change in any
> case.

Apologies for the delay, it took me some time to get back to this properly.

Would you be open to providing a new type of flat cache with sparse
initalisation (e.g. REGCACHE_FLAT_SPARSE) to provide the behavior provided by
this patches? Most of the code could be shared with REGCACHE_FLAT.

REGCACHE_FLAT and REGCACHE_FLAT_SPARSE would both maintain the cache validity as
in this patch. On a read, _FLAT_SPARSE would return -ENOENT on an invalid cache
entry. _FLAT would then always return 0 and the (zero-initialized) value,
ignoring the cache validity and maintaining the behavior drivers may currently
rely on.

If you would like existing drivers to transition to REGCACHE_FLAT_SPARSE, I
could also add a deprecation warning for users of REGCACHE_FLAT.

I can also just send a patch series, if that helps.

Best,
Sander

  reply	other threads:[~2025-10-16  8:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-09 18:02 Sander Vanheule
2025-01-09 20:11 ` Mark Brown
2025-10-16  8:46   ` Sander Vanheule [this message]
2025-10-16 11:53     ` Mark Brown
2025-10-16 12:08       ` Sander Vanheule
2025-10-16 13:55         ` Mark Brown
2025-10-16 20:49           ` Sander Vanheule
2025-10-17 13:56             ` Mark Brown
2025-10-22 20:21               ` Sander Vanheule

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0b2fa71f1ccd49d66ca02b6c44ba8fe2135e9b6f.camel@svanheule.net \
    --to=sander@svanheule.net \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®