All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Aisheng Dong <aisheng.dong@nxp.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"dongas86@gmail.com" <dongas86@gmail.com>,
	"l.stach@pengutronix.de" <l.stach@pengutronix.de>,
	Peng Fan <peng.fan@nxp.com>,
	"shawnguo@kernel.org" <shawnguo@kernel.org>
Subject: Re: [PATCH RFC 1/2] regmap: add option to disable debugfs
Date: Mon, 20 Jun 2022 18:51:25 +0100	[thread overview]
Message-ID: <YrCznap77OyHu4bO@sirena.org.uk> (raw)
In-Reply-To: <DB9PR04MB8477CD99D5847291A629994180B09@DB9PR04MB8477.eurprd04.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 2035 bytes --]

On Mon, Jun 20, 2022 at 04:15:40PM +0000, Aisheng Dong wrote:

> > 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.

So the runtime power managment seems like a good place to manage cache
only mode.

> 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);

That's not what the code is upstream, upstream between the cache_bypass
check and the reg_read we have 

	if (map->cache_only)
		return -EBUSY;

	if (!regmap_readable(map, reg))
		return -EIO;

so if we can't satisfy the read from the cache then we'll hit the
cache_only check and return -EBUSY before we start trying to do any
physical I/O.  The debugfs code will handle that gracefully, indicating
that it couldn't get a value for the volatile register by showing all Xs
for the value.  If none of the registers are cached then the file won't
be terribly useful but it at least shouldn't cause any errors with
accessing the device when it's powered down.

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

We shouldn't cache anything for volatile registers, if we are then
that's an issue.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2022-06-20 17:51 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-20 13:47 [PATCH RFC 0/2] regmap: option to disable debugfs Dong Aisheng
2022-06-20 13:47 ` [PATCH RFC 1/2] regmap: add " Dong Aisheng
2022-06-20 15:05   ` Mark Brown
2022-06-20 15:47     ` Aisheng Dong
2022-06-20 15:49       ` Mark Brown
2022-06-20 16:15         ` Aisheng Dong
2022-06-20 17:51           ` Mark Brown [this message]
2022-06-21 14:56             ` Aisheng Dong
2022-06-21 15:31               ` Mark Brown
2022-06-21 18:16                 ` Aisheng Dong
2022-06-22  8:08                   ` Lucas Stach
2022-06-22  8:18                     ` Aisheng Dong
2022-06-22  8:35                       ` Lucas Stach
2022-06-22 12:25                     ` Mark Brown
2022-06-22 10:12                   ` Dong Aisheng
2022-06-22 12:36                     ` Mark Brown
2022-06-22 16:05                       ` Dong Aisheng
2022-06-22 16:27                         ` Mark Brown
2022-06-22 16:42                           ` Dong Aisheng
2022-06-22 16:48                             ` Mark Brown
2022-06-22 17:01                               ` Dong Aisheng
2022-06-22 17:07                                 ` Mark Brown
2022-06-20 13:47 ` [PATCH RFC 2/2] soc: imx8m-blk-ctrl: do not export debugfs Dong Aisheng

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=YrCznap77OyHu4bO@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=aisheng.dong@nxp.com \
    --cc=dongas86@gmail.com \
    --cc=l.stach@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peng.fan@nxp.com \
    --cc=shawnguo@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.