RE: [PATCH RFC 1/2] regmap: add option to disable debugfs

From: Aisheng Dong
Date: Mon Jun 20 2022 - 12:15:49 EST


> From: Mark Brown <broonie@xxxxxxxxxx>
> Sent: Monday, June 20, 2022 11:50 PM
>
> On Mon, Jun 20, 2022 at 03:47:05PM +0000, Aisheng Dong wrote:
>
> > > As indicated in the message you're linking to here if the device
> > > can't be accessed it should be being put in cache only mode which
> > > will ensure that nothing can do any physical accesses.
>
> > I wonder that's not a stable solution assuming there're possible volatile
> registers.
> > Isn't that?
>
> The driver is going to need to power the device back up to access the volatile
> registers so it can take the device out of cache only mode when it's doing that
> can't it?

Sorry, I didn't quite get it.
There's no problem in driver to access volatile registers as it usually will power up
device first by rpm.
But for debugfs, from what I saw in code, if there's a volatile register, _regmap_read()
will bypass cache and try to read the register value from HW.
Then system may hang as no one powered up the device before.
Anything I missed?

static int _regmap_read(struct regmap *map, unsigned int reg,
unsigned int *val)
{
int ret;
void *context = _regmap_map_get_context(map);

if (!map->cache_bypass) {
ret = regcache_read(map, reg, val);
if (ret == 0)
return 0;
}

ret = map->reg_read(context, reg, val);
...
}

Or you mean simply forgetting about volatile registers and let debugfs
to read the stale value from cache?

Regards
Aisheng