From: Zev Weiss <zev@bewilderbeest.net>
To: openbmc@lists.ozlabs.org
Cc: devicetree@vger.kernel.org, Zev Weiss <zev@bewilderbeest.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
Jeremy Kerr <jk@codeconstruct.com.au>,
Frank Rowand <frowand.list@gmail.com>
Subject: [PATCH 5/9] of: add self parameter to of_update_property()
Date: Wed, 6 Oct 2021 17:09:50 -0700 [thread overview]
Message-ID: <20211007000954.30621-6-zev@bewilderbeest.net> (raw)
In-Reply-To: <20211007000954.30621-1-zev@bewilderbeest.net>
This is to indicate that the property is being updated via its own
sysfs method so that we ultimately call into kernfs_remove_self() and
avoid the deadlock that would occur otherwise.
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
---
drivers/of/base.c | 7 ++++---
drivers/of/dynamic.c | 2 +-
drivers/of/kobj.c | 4 ++--
drivers/of/of_private.h | 4 ++--
include/linux/of.h | 7 ++++++-
5 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index f720c0d246f2..ce4d3bc2f8a6 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1902,8 +1902,9 @@ int __of_update_property(struct device_node *np, struct property *newprop,
return 0;
}
+
/*
- * of_update_property - Update a property in a node, if the property does
+ * of_update_property_self - Update a property in a node, if the property does
* not exist, add it.
*
* Note that we don't actually remove it, since we have given out
@@ -1911,7 +1912,7 @@ int __of_update_property(struct device_node *np, struct property *newprop,
* Instead we just move the property to the "dead properties" list,
* and add the new property to the property list
*/
-int of_update_property(struct device_node *np, struct property *newprop)
+int of_update_property_self(struct device_node *np, struct property *newprop, bool self)
{
struct property *oldprop;
unsigned long flags;
@@ -1927,7 +1928,7 @@ int of_update_property(struct device_node *np, struct property *newprop)
raw_spin_unlock_irqrestore(&devtree_lock, flags);
if (!rc)
- __of_update_property_sysfs(np, newprop, oldprop);
+ __of_update_property_sysfs(np, newprop, oldprop, self);
mutex_unlock(&of_mutex);
diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index cd3821a6444f..8a67f3e1b223 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -652,7 +652,7 @@ static int __of_changeset_entry_apply(struct of_changeset_entry *ce)
__of_remove_property_sysfs(ce->np, ce->prop);
break;
case OF_RECONFIG_UPDATE_PROPERTY:
- __of_update_property_sysfs(ce->np, ce->prop, ce->old_prop);
+ __of_update_property_sysfs(ce->np, ce->prop, ce->old_prop, false);
break;
}
diff --git a/drivers/of/kobj.c b/drivers/of/kobj.c
index 06d6c90f7aa1..378cb421aae1 100644
--- a/drivers/of/kobj.c
+++ b/drivers/of/kobj.c
@@ -104,14 +104,14 @@ void __of_remove_property_sysfs(struct device_node *np, struct property *prop)
}
void __of_update_property_sysfs(struct device_node *np, struct property *newprop,
- struct property *oldprop)
+ struct property *oldprop, bool self)
{
/* At early boot, bail out and defer setup to of_init() */
if (!of_kset)
return;
if (oldprop)
- __of_sysfs_remove_bin_file(np, oldprop, false);
+ __of_sysfs_remove_bin_file(np, oldprop, self);
__of_add_property_sysfs(np, newprop);
}
diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
index fff157c63907..3c6816237278 100644
--- a/drivers/of/of_private.h
+++ b/drivers/of/of_private.h
@@ -64,7 +64,7 @@ int of_node_is_attached(struct device_node *node);
int __of_add_property_sysfs(struct device_node *np, struct property *pp);
void __of_remove_property_sysfs(struct device_node *np, struct property *prop);
void __of_update_property_sysfs(struct device_node *np, struct property *newprop,
- struct property *oldprop);
+ struct property *oldprop, bool self);
int __of_attach_node_sysfs(struct device_node *np);
void __of_detach_node_sysfs(struct device_node *np);
#else
@@ -74,7 +74,7 @@ static inline int __of_add_property_sysfs(struct device_node *np, struct propert
}
static inline void __of_remove_property_sysfs(struct device_node *np, struct property *prop) {}
static inline void __of_update_property_sysfs(struct device_node *np,
- struct property *newprop, struct property *oldprop) {}
+ struct property *newprop, struct property *oldprop, bool self) {}
static inline int __of_attach_node_sysfs(struct device_node *np)
{
return 0;
diff --git a/include/linux/of.h b/include/linux/of.h
index 6f1c41f109bb..0e6479a884eb 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -401,7 +401,12 @@ extern int of_machine_is_compatible(const char *compat);
extern int of_add_property(struct device_node *np, struct property *prop);
extern int of_remove_property(struct device_node *np, struct property *prop);
-extern int of_update_property(struct device_node *np, struct property *newprop);
+extern int of_update_property_self(struct device_node *np, struct property *newprop, bool self);
+
+static inline int of_update_property(struct device_node *np, struct property *newprop)
+{
+ return of_update_property_self(np, newprop, false);
+}
/* For updating the device tree at runtime */
#define OF_RECONFIG_ATTACH_NODE 0x0001
--
2.33.0
next prev parent reply other threads:[~2021-10-07 0:14 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-07 0:09 [PATCH 0/9] Dynamic DT device nodes Zev Weiss
2021-10-07 0:09 ` [PATCH 1/9] sysfs: add sysfs_remove_bin_file_self() function Zev Weiss
2021-10-07 5:23 ` Greg Kroah-Hartman
2021-10-07 5:58 ` Zev Weiss
2021-10-07 6:12 ` Greg Kroah-Hartman
2021-10-07 6:55 ` Zev Weiss
2021-10-07 0:09 ` [PATCH 2/9] sysfs: add growable flag to struct bin_attribute Zev Weiss
2021-10-07 0:09 ` [PATCH 3/9] lib/string: add sysfs_buf_streq() Zev Weiss
2021-10-07 0:09 ` [PATCH 4/9] of: add self parameter to __of_sysfs_remove_bin_file() Zev Weiss
2021-10-07 5:25 ` Greg Kroah-Hartman
2021-10-07 0:09 ` Zev Weiss [this message]
2021-10-07 5:26 ` [PATCH 5/9] of: add self parameter to of_update_property() Greg Kroah-Hartman
2021-10-07 0:09 ` [PATCH 6/9] of: add support for 'dynamic' DT property Zev Weiss
2021-10-08 18:51 ` Frank Rowand
2021-10-08 19:19 ` Frank Rowand
2021-10-11 13:58 ` Frank Rowand
2021-10-11 14:46 ` Frank Rowand
2021-10-11 17:35 ` Zev Weiss
2021-10-07 0:09 ` [PATCH 7/9] of: make OF_DYNAMIC selectable independently of OF_UNITTEST Zev Weiss
2021-10-08 19:01 ` Frank Rowand
2021-10-07 0:09 ` [PATCH 8/9] dt-bindings: document new 'dynamic' common property Zev Weiss
2021-10-07 5:26 ` Greg Kroah-Hartman
2021-10-07 6:03 ` Zev Weiss
2021-10-07 0:09 ` [PATCH 9/9] ARM: dts: aspeed: Add e3c246d4i BIOS flash device Zev Weiss
2021-10-07 2:46 ` [PATCH 0/9] Dynamic DT device nodes Florian Fainelli
2021-10-07 5:44 ` Zev Weiss
2021-10-07 7:04 ` Andy Shevchenko
2021-10-07 9:05 ` Zev Weiss
2021-10-07 10:31 ` Greg Kroah-Hartman
2021-10-07 15:41 ` Zev Weiss
2021-10-07 20:03 ` Rob Herring
2021-10-08 5:41 ` Greg Kroah-Hartman
2021-10-08 19:43 ` Frank Rowand
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=20211007000954.30621-6-zev@bewilderbeest.net \
--to=zev@bewilderbeest.net \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jk@codeconstruct.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=openbmc@lists.ozlabs.org \
--cc=robh+dt@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).