* [PATCH v2] Removes OF_SELFTEST dependency on OF_DYNAMIC config symbol @ 2014-09-13 12:35 Gaurav Minocha [not found] ` <1410611708-9369-1-git-send-email-gaurav.minocha.os-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Gaurav Minocha @ 2014-09-13 12:35 UTC (permalink / raw) To: devicetree-u79uwXL29TY76Z2rM5mHXA Cc: grant.likely-QSEj5FYQhm4dnm+yROfE0A, rob.herring-QSEj5FYQhm4dnm+yROfE0A, Gaurav Minocha This patch is used to remove the selftests dependency on OF_DYNAMIC config flag. Now, it selectively builds only the functions required by the selftests. Tested with and without OF_DYNAMIC enabled. Signed-off-by: Gaurav Minocha <gaurav.minocha.os-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- drivers/of/Kconfig | 1 - drivers/of/selftest.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 1 deletion(-) diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index 5160c4e..1fe3805 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig @@ -10,7 +10,6 @@ menu "Device Tree and Open Firmware support" config OF_SELFTEST bool "Device Tree Runtime self tests" depends on OF_IRQ && OF_EARLY_FLATTREE - select OF_DYNAMIC help This option builds in test cases for the device tree infrastructure that are executed once at boot time, and the results dumped to the diff --git a/drivers/of/selftest.c b/drivers/of/selftest.c index a737cb5..4b2704e 100644 --- a/drivers/of/selftest.c +++ b/drivers/of/selftest.c @@ -600,6 +600,116 @@ static void __init of_selftest_platform_populate(void) } } +#if !defined(CONFIG_OF_DYNAMIC) +/** + * of_attach_node() - Plug a device node into the tree and global list. + */ +int of_attach_node(struct device_node *np) +{ + unsigned long flags; + const __be32 *phandle; + int sz; + + mutex_lock(&of_mutex); + raw_spin_lock_irqsave(&devtree_lock, flags); + np->name = __of_get_property(np, "name", NULL) ? : "<NULL>"; + np->type = __of_get_property(np, "device_type", NULL) ? : "<NULL>"; + + phandle = __of_get_property(np, "phandle", &sz); + if (!phandle) + phandle = __of_get_property(np, "linux,phandle", &sz); + np->phandle = (phandle && (sz >= 4)) ? be32_to_cpup(phandle) : 0; + + np->child = NULL; + np->sibling = np->parent->child; + np->allnext = np->parent->allnext; + np->parent->allnext = np; + np->parent->child = np; + of_node_clear_flag(np, OF_DETACHED); + raw_spin_unlock_irqrestore(&devtree_lock, flags); + + __of_attach_node_sysfs(np); + mutex_unlock(&of_mutex); + + return 0; +} + +void __of_detach_node_sysfs(struct device_node *np) +{ + struct property *pp; + + if (!IS_ENABLED(CONFIG_SYSFS)) + return; + + BUG_ON(!of_node_is_initialized(np)); + if (!of_kset) + return; + + /* only remove properties if on sysfs */ + if (of_node_is_attached(np)) { + for_each_property_of_node(np, pp) + sysfs_remove_bin_file(&np->kobj, &pp->attr); + kobject_del(&np->kobj); + } + + /* finally remove the kobj_init ref */ + of_node_put(np); +} + +/** + * of_detach_node() - "Unplug" a node from the device tree. + * + * The caller must hold a reference to the node. The memory associated with + * the node is not freed until its refcount goes to zero. + */ +int of_detach_node(struct device_node *np) +{ + unsigned long flags; + int rc = 0; + struct device_node *parent; + + mutex_lock(&of_mutex); + raw_spin_lock_irqsave(&devtree_lock, flags); + + if (!WARN_ON(of_node_check_flag(np, OF_DETACHED))) { + parent = np->parent; + if (!WARN_ON(!parent)) { + if (of_allnodes == np) + of_allnodes = np->allnext; + else { + struct device_node *prev; + + for (prev = of_allnodes; + prev->allnext != np; + prev = prev->allnext) + ; + prev->allnext = np->allnext; + } + + if (parent->child == np) + parent->child = np->sibling; + else { + struct device_node *prevsib; + + for (prevsib = np->parent->child; + prevsib->sibling != np; + prevsib = prevsib->sibling) + ; + prevsib->sibling = np->sibling; + } + + of_node_set_flag(np, OF_DETACHED); + } + } + raw_spin_unlock_irqrestore(&devtree_lock, flags); + + __of_detach_node_sysfs(np); + mutex_unlock(&of_mutex); + + return rc; +} +#endif + /** * update_node_properties - adds the properties * of np into dup node (present in live tree) and -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 5+ messages in thread
[parent not found: <1410611708-9369-1-git-send-email-gaurav.minocha.os-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH v2] Removes OF_SELFTEST dependency on OF_DYNAMIC config symbol [not found] ` <1410611708-9369-1-git-send-email-gaurav.minocha.os-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2014-09-15 9:34 ` Pantelis Antoniou [not found] ` <9D65D8A3-6404-451B-A3F4-E9ED94810B7B-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Pantelis Antoniou @ 2014-09-15 9:34 UTC (permalink / raw) To: Gaurav Minocha Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, grant.likely-QSEj5FYQhm4dnm+yROfE0A, rob.herring-QSEj5FYQhm4dnm+yROfE0A Hi Gaurav, On Sep 13, 2014, at 3:35 PM, Gaurav Minocha wrote: > This patch is used to remove the selftests dependency on > OF_DYNAMIC config flag. Now, it selectively builds only > the functions required by the selftests. > > Tested with and without OF_DYNAMIC enabled. > > Signed-off-by: Gaurav Minocha <gaurav.minocha.os-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- [snip] I'm not happy with this patch. It duplicates core functionality already present in drivers/of/dynamic.c and those two implementations are for sure going to get out of sync. If you require the self-tests to work without OF_DYNAMIC you can do that by including the tests in your dts. If you want to insert them dynamically then use OF_DYNAMIC. Regards -- Pantelis -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <9D65D8A3-6404-451B-A3F4-E9ED94810B7B-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org>]
* Re: [PATCH v2] Removes OF_SELFTEST dependency on OF_DYNAMIC config symbol [not found] ` <9D65D8A3-6404-451B-A3F4-E9ED94810B7B-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org> @ 2014-09-15 19:16 ` Gaurav Minocha 2014-09-27 22:23 ` Grant Likely 1 sibling, 0 replies; 5+ messages in thread From: Gaurav Minocha @ 2014-09-15 19:16 UTC (permalink / raw) To: Pantelis Antoniou Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Grant Likely, Rob Herring On Mon, Sep 15, 2014 at 2:34 AM, Pantelis Antoniou <panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org> wrote: > Hi Gaurav, > > > On Sep 13, 2014, at 3:35 PM, Gaurav Minocha wrote: > >> This patch is used to remove the selftests dependency on >> OF_DYNAMIC config flag. Now, it selectively builds only >> the functions required by the selftests. >> >> Tested with and without OF_DYNAMIC enabled. >> >> Signed-off-by: Gaurav Minocha <gaurav.minocha.os-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> --- > > [snip] > > I'm not happy with this patch. > > It duplicates core functionality already present in drivers/of/dynamic.c and those > two implementations are for sure going to get out of sync. I understand your point, but I did this after discussing with Grant. > > If you require the self-tests to work without OF_DYNAMIC you can do that by including the > tests in your dts. If you want to insert them dynamically then use OF_DYNAMIC. So, according to above, selftest should not attach test data dynamically if the OF_DYNAMIC symbol is disabled. Correct me if wrong. I will discuss and update the patch as appropriate. Thanks! > > Regards > > -- Pantelis > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] Removes OF_SELFTEST dependency on OF_DYNAMIC config symbol [not found] ` <9D65D8A3-6404-451B-A3F4-E9ED94810B7B-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org> 2014-09-15 19:16 ` Gaurav Minocha @ 2014-09-27 22:23 ` Grant Likely [not found] ` <CBCF02E6-831F-425B-9FE7-CB4EE9A2F19C@antoniou-consulting.com> 1 sibling, 1 reply; 5+ messages in thread From: Grant Likely @ 2014-09-27 22:23 UTC (permalink / raw) To: Pantelis Antoniou Cc: Gaurav Minocha, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Rob Herring On Mon, Sep 15, 2014 at 10:34 AM, Pantelis Antoniou <panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org> wrote: > Hi Gaurav, > > > On Sep 13, 2014, at 3:35 PM, Gaurav Minocha wrote: > >> This patch is used to remove the selftests dependency on >> OF_DYNAMIC config flag. Now, it selectively builds only >> the functions required by the selftests. >> >> Tested with and without OF_DYNAMIC enabled. >> >> Signed-off-by: Gaurav Minocha <gaurav.minocha.os-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> --- > > [snip] > > I'm not happy with this patch. > > It duplicates core functionality already present in drivers/of/dynamic.c and those > two implementations are for sure going to get out of sync. > > If you require the self-tests to work without OF_DYNAMIC you can do that by including the > tests in your dts. If you want to insert them dynamically then use OF_DYNAMIC. I asked Gaurav to make this work. The selftest code should always be usable, without requiring the testcase data to be directly included into the dtb. It is important to be able to still test the code paths on any platform when OF_DYNAMIC is not selected. This patch doesn't do it in a very nice way, agreed, but it is important to get working. g. -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <CBCF02E6-831F-425B-9FE7-CB4EE9A2F19C@antoniou-consulting.com>]
[parent not found: <CBCF02E6-831F-425B-9FE7-CB4EE9A2F19C-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org>]
* Re: [PATCH v2] Removes OF_SELFTEST dependency on OF_DYNAMIC config symbol [not found] ` <CBCF02E6-831F-425B-9FE7-CB4EE9A2F19C-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org> @ 2014-09-29 12:51 ` Grant Likely 0 siblings, 0 replies; 5+ messages in thread From: Grant Likely @ 2014-09-29 12:51 UTC (permalink / raw) To: Pantelis Antoniou Cc: Gaurav Minocha, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Rob Herring On Mon, 29 Sep 2014 10:50:52 +0300 , Pantelis Antoniou <panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org> wrote: > Hi Grant, > > On Sep 28, 2014, at 1:23 AM, Grant Likely <grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote: > > > On Mon, Sep 15, 2014 at 10:34 AM, Pantelis Antoniou > > <panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org> wrote: > >> Hi Gaurav, > >> > >> > >> On Sep 13, 2014, at 3:35 PM, Gaurav Minocha wrote: > >> > >>> This patch is used to remove the selftests dependency on > >>> OF_DYNAMIC config flag. Now, it selectively builds only > >>> the functions required by the selftests. > >>> > >>> Tested with and without OF_DYNAMIC enabled. > >>> > >>> Signed-off-by: Gaurav Minocha <gaurav.minocha.os-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > >>> --- > >> > >> [snip] > >> > >> I'm not happy with this patch. > >> > >> It duplicates core functionality already present in drivers/of/dynamic.c and those > >> two implementations are for sure going to get out of sync. > >> > >> If you require the self-tests to work without OF_DYNAMIC you can do that by including the > >> tests in your dts. If you want to insert them dynamically then use OF_DYNAMIC. > > > > I asked Gaurav to make this work. The selftest code should always be > > usable, without requiring the testcase data to be directly included > > into the dtb. It is important to be able to still test the code paths > > on any platform when OF_DYNAMIC is not selected. > > > > OK, I can understand that. However the way it goes about it is wrong IMO. Agreed. > If we need the dynamic node attachment/detachment code to work even when > OF_DYNAMIC is not enabled, we should keep the same implementation but > use a new hidden config option that is CONFIG_OF_DYNAMIC | CONFIG_OF_TESTCASES > and put the code there. I'm thinking that we just drop node detachment in the selftest code when running without CONFIG_OF_DYNAMIC. It doesn't hurt anything to leave the data in-tree. g. -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-09-29 12:51 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-09-13 12:35 [PATCH v2] Removes OF_SELFTEST dependency on OF_DYNAMIC config symbol Gaurav Minocha [not found] ` <1410611708-9369-1-git-send-email-gaurav.minocha.os-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2014-09-15 9:34 ` Pantelis Antoniou [not found] ` <9D65D8A3-6404-451B-A3F4-E9ED94810B7B-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org> 2014-09-15 19:16 ` Gaurav Minocha 2014-09-27 22:23 ` Grant Likely [not found] ` <CBCF02E6-831F-425B-9FE7-CB4EE9A2F19C@antoniou-consulting.com> [not found] ` <CBCF02E6-831F-425B-9FE7-CB4EE9A2F19C-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org> 2014-09-29 12:51 ` Grant Likely
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).