[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+ASDXP+KeiRKASFakDjJ=cZPD_rGmV4=JgRH26zQi-uZDdiAQ@mail.gmail.com>
Date: Fri, 4 Feb 2022 11:21:51 -0800
From: Brian Norris <briannorris@...omium.org>
To: Mark Brown <broonie@...nel.org>
Cc: Peng Fan <peng.fan@....com>,
"rafael@...nel.org" <rafael@...nel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
dl-linux-imx <linux-imx@....com>,
"S.j. Wang" <shengjiu.wang@....com>
Subject: Re: regmap: mmio: lack of runtime_pm support for debugfs
Hi Mark,
On Fri, Feb 4, 2022 at 11:02 AM Mark Brown <broonie@...nel.org> wrote:
>
> On Mon, Jan 24, 2022 at 03:50:23PM -0800, Brian Norris wrote:
>
> > 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.
>
> Are you sure you wouldn't be better off with a cache here, or marking
> the registers as precious so they don't get read (perhaps conditionally
> to allow reading while the device is live)?
We do actually have a cache for the case I care about, but there's
also a debugfs file for bypassing that and...for some reason I'm
dealing with some diagnostic scripts that purposely toggle that. I'm
not sure how wise that is, but in general I like to reduce the number
of ways dumb user space can screw things up. I've even had to tell
people that recursively grepping through sysfs or debugfs is a bad
idea...
The precious_reg() callback is interesting. Maybe I could have that do
a quick pm_runtime check to make a decision. Thanks for the idea.
> The general idea
> expectation with the debugfs is that it shouldn't materially affect the
> device, this would mean that it could cause the power to get bounced on
> which feels like it might lead to surprises.
Yeah, good point.
> If you are sending a patch
> adding support for this it should be debugfs specific, not a general
> flag so it's clear that it's not going to do power management outside of
> debugfs, as you say in the normal case it seems better for the driver to
> do power management.
Another good point. I did poke around a bit on trying to do it
generically, and it looked I'd have to touch a lot of stuff to avoid
sleeping/atomic conflicts, while likely having no real material
benefit (for well-written uses) outside of debugfs.
Anyway, I'll probably just go with precious_reg() as suggested above.
Thanks a lot for the tips,
Brian
Powered by blists - more mailing lists