summaryrefslogtreecommitdiffstats
path: root/drivers/of/of_private.h
diff options
context:
space:
mode:
authorFrank Rowand <frank.rowand@sony.com>2017-10-18 01:36:29 +0200
committerRob Herring <robh@kernel.org>2017-10-18 03:47:27 +0200
commitf948d6d8b792bb90041edc12eac35faf83030994 (patch)
treef98bad2bb9e0701c3fc198e72575216e442006b5 /drivers/of/of_private.h
parentof: overlay: loosen overly strict phandle clash check (diff)
downloadlinux-f948d6d8b792bb90041edc12eac35faf83030994.tar.xz
linux-f948d6d8b792bb90041edc12eac35faf83030994.zip
of: overlay: avoid race condition between applying multiple overlays
The process of applying an overlay consists of: - unflatten an overlay FDT (flattened device tree) into an EDT (expanded device tree) - fixup the phandle values in the overlay EDT to fit in a range above the phandle values in the live device tree - create the overlay changeset to reflect the contents of the overlay EDT - apply the overlay changeset, to modify the live device tree, potentially changing the maximum phandle value in the live device tree There is currently no protection against two overlay applies concurrently determining what range of phandle values are in use in the live device tree, and subsequently changing that range. Add a mutex to prevent multiple overlay applies from occurring simultaneously. Move of_resolve_phandles() into of_overlay_apply() so that it does not have to be duplicated by each caller of of_overlay_apply(). The test in of_resolve_phandles() that the overlay tree is detached is temporarily disabled so that old style overlay unittests do not fail. Signed-off-by: Frank Rowand <frank.rowand@sony.com> Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'drivers/of/of_private.h')
-rw-r--r--drivers/of/of_private.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
index 36357f571df2..248730567dbe 100644
--- a/drivers/of/of_private.h
+++ b/drivers/of/of_private.h
@@ -76,6 +76,18 @@ static inline int __of_attach_node_sysfs(struct device_node *np)
static inline void __of_detach_node_sysfs(struct device_node *np) {}
#endif
+#if defined(CONFIG_OF_RESOLVE)
+int of_resolve_phandles(struct device_node *tree);
+#endif
+
+#if defined(CONFIG_OF_OVERLAY)
+void of_overlay_mutex_lock(void);
+void of_overlay_mutex_unlock(void);
+#else
+static inline void of_overlay_mutex_lock(void) {};
+static inline void of_overlay_mutex_unlock(void) {};
+#endif
+
#if defined(CONFIG_OF_UNITTEST) && defined(CONFIG_OF_OVERLAY)
extern void __init unittest_unflatten_overlay_base(void);
#else