Re: [PATCH v3 1/3] regcache: Move HW readback after cache initialisation

Andy Shevchenko
2026-02-28T13:55:47Z

On Sat, Feb 28, 2026 at 01:09:09PM +0000, Mark Brown wrote:
> On Fri, Feb 27, 2026 at 07:43:59AM +0200, Andy Shevchenko wrote:
>
> > Is it possible to allocate something, then count, then reallocate
> > in the existing caches and in the potential future ones?
>
> > I think it's the patter that we first count the size of the allocation,
> > do the allocation, and only then fill up the allocated area with data.
>
> > Otherwise we came back to the chicken-egg issue this patch tries to solve.
>
> The main worry there would be transiently consuming huge amounts of
> memory if there's a very sparse regsiter map, though we'd also be
> burning lots of CPU time checking all those registers so perhaps it's
> not a real concern, and the whole thing is kind of an edge case anyway.
> Though now I look again we are careful to bypass the cache during the
> hw_init() so we should be safe anyway I think.

Yes, but amending check to be against 'count' needs to be done for clarity.
'count' represent the amount of cacheable registers, it is independent number
on how sparse the map is.

I will send a v4 shortly with the above amendment.

--
With Best Regards,
Andy Shevchenko