From: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
To: Mark Brown <broonie@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>
Cc: David Lechner <david@lechnology.com>,
linux-kernel@vger.kernel.org,
Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Subject: [PATCH] regmap: do not call regmap_debugfs_init() from regmap_attach_dev()
Date: Mon, 26 Jul 2021 09:36:27 +0200 [thread overview]
Message-ID: <20210726073627.31589-1-matthias.schiffer@ew.tq-group.com> (raw)
regmap_debugfs_init() should never be called twice for the same regmap,
as it initializes various fields of the regmap struct, including list
heads and mutices. A visible symptom are messages like:
debugfs: Directory 'dummy-iomuxc-gpr@20e4000' with parent 'regmap'
already present!
This happened whenever regmap_attach_dev() was called for an existing
regmap. Remove the call from regmap_attach_dev() and change
__regmap_init() so that regmap_debugfs_init() is called exactly once.
Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Fixes: 9b947a13e7f6 ("regmap: use debugfs even when no device")
---
drivers/base/regmap/regmap.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
As mentioned in my previous mail [1], I believe that the duplicate call to
regmap_debugfs_init() is not the only issue with regmap_attach_dev().
Every single user of regmap_attach_dev() outside of __regmap_init() is
using it to attach a device to a syscon regmap obtained using one of the
syscon_*() functions. AIUI, syscon regmaps do not belong to a single
device, so calling regmap_attach_dev() seems wrong to me. My (possibly
lacking) understanding of the semantics aside, the fact that
regmap_attach_dev() is setting fields on the shared regmap without any
kind of locking is at least suspicious.
Maybe regmap_attach_dev() shouldn't be exported from the regmap code at
all, removing all calls to the functions from drivers?
[1] https://lkml.org/lkml/2021/7/19/500
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index fe3e38dd5324..27625a1330ac 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -630,8 +630,6 @@ int regmap_attach_dev(struct device *dev, struct regmap *map,
if (ret)
return ret;
- regmap_debugfs_init(map);
-
/* Add a devres resource for dev_get_regmap() */
m = devres_alloc(dev_get_regmap_release, sizeof(*m), GFP_KERNEL);
if (!m) {
@@ -1192,10 +1190,10 @@ struct regmap *__regmap_init(struct device *dev,
ret = regmap_attach_dev(dev, map, config);
if (ret != 0)
goto err_regcache;
- } else {
- regmap_debugfs_init(map);
}
+ regmap_debugfs_init(map);
+
return map;
err_regcache:
--
2.17.1
next reply other threads:[~2021-07-26 7:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-26 7:36 Matthias Schiffer [this message]
2021-07-26 11:47 ` [PATCH] regmap: do not call regmap_debugfs_init() from regmap_attach_dev() Mark Brown
2021-07-26 12:01 ` Matthias Schiffer
2021-07-26 12:11 ` Mark Brown
2021-07-26 12:18 ` Matthias Schiffer
2021-07-26 18:48 ` Mark Brown
2021-07-27 12:24 ` (EXT) " Matthias Schiffer
2021-07-27 17:08 ` Mark Brown
2021-07-28 9:13 ` Matthias Schiffer
2021-07-26 12:00 ` Mark Brown
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=20210726073627.31589-1-matthias.schiffer@ew.tq-group.com \
--to=matthias.schiffer@ew.tq-group.com \
--cc=broonie@kernel.org \
--cc=david@lechnology.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).