regmap: mmio: lack of runtime_pm support for debugfs

From: Brian Norris
Date: Mon Jan 24 2022 - 22:34:21 EST


[[ Retitling from '[PATCH] regmap: mmio: prepare/unprepare clk only when
read/write' ]]

Hi,

Sorry to bring up an old thread, but it appears there's an unresolved
problem in here that I'm also hitting:

On Fri, Apr 24, 2020 at 11:30:04AM +0100, Mark Brown wrote:
> On Fri, Apr 24, 2020 at 01:27:29AM +0000, Peng Fan wrote:
>
> > If we not pass clk to regmap, accessing regmap registers will hang system with
> > Debugfs enabled.
>
> If you're not using a cache then that'll be a problem, however there is
> a flag runtime_pm in the regmap config which when set should cause the
> device to be runtime PM enabled when it's accessed so if you do your
> clock management in runtime PM it should still get enabled. I *think*
> that interacts OK with being in an atomic context but I can't say I've
> verified.

The only 'runtime_pm' flag I'm finding for regmap is for regmap_irq_chip
-- there isn't anything useful for other kinds of regmaps (like MMIO).

If this seems like an expected/useful feature, I'll look at adding it to
the generic 'struct regmap_config' / drivers/base/regmap/regmap.c.

This could be tricky in theory given the atomic context requirements,
but in reality, I think it would still be OK: this feature would really
be useful _only_ for otherwise-unregulated contexts, like debugfs
access (where we can sleep). For all non-debugfs accesses, we expect to
already be RPM_ACTIVE, because the driver should already be managing
runtime PM.

Brian