All of lore.kernel.org
 help / color / mirror / Atom feed
From: Koen Kooi <koen@dominion.thruhere.net>
To: Pantelis Antoniou <panto@antoniou-consulting.com>
Cc: Grant Likely <grant.likely@secretlab.ca>,
	Rob Herring <robherring2@gmail.com>,
	Stephen Warren <swarren@wwwdotorg.org>,
	Matt Porter <matt.porter@linaro.org>,
	Alison Chaiken <Alison_Chaiken@mentor.com>,
	Dinh Nguyen <dinh.linux@gmail.com>, Jan Lubbe <jluebbe@lasnet.de>,
	Alexander Sverdlin <alexander.sverdlin@nsn.com>,
	Michael Stickel <ms@mycable.de>,
	Guenter Roeck <linux@roeck-us.net>,
	Dirk Behme <dirk.behme@gmail.com>,
	Alan Tull <delicious.quinoa@gmail.com>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Michael Bohan <mbohan@codeaurora.org>,
	Ionut Nicu <ioan.nicu.ext@nsn.com>,
	Michal Simek <monstr@monstr.eu>,
	Matt Ranostay <mranostay@gmail.com>,
	Device Tree Mailing List <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org List"
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/3] of: Fix early OF builtup on kobj-ification
Date: Wed, 11 Dec 2013 08:06:42 +0100	[thread overview]
Message-ID: <C3A30FEB-11CB-4CEA-8CB3-B1CA53A87C61@dominion.thruhere.net> (raw)
In-Reply-To: <1386684833-24112-2-git-send-email-panto@antoniou-consulting.com>


Op 10 dec. 2013, om 15:13 heeft Pantelis Antoniou <panto@antoniou-consulting.com> het volgende geschreven:

> When booting platforms that do very early OF initialization before
> core_initcalls are performed of_init is called too late.
> 
> This results in a hard-hard without getting a chance to output anything.

I think that should be 'hard-hang'.

regards,

Koen

> 
> Fixed by adding a flag that marks when init has been done, and
> performing the per-node init at that time.
> 
> Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
> ---
> drivers/of/base.c | 28 +++++++++++++++++++++++-----
> 1 file changed, 23 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 734689b..a4f3dda 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -98,7 +98,7 @@ int __weak of_node_to_nid(struct device_node *np)
>  */
> struct device_node *of_node_get(struct device_node *node)
> {
> -	if (node)
> +	if (node && of_kset)
> 		kobject_get(&node->kobj);
> 	return node;
> }
> @@ -156,7 +156,7 @@ static void of_node_release(struct kobject *kobj)
>  */
> void of_node_put(struct device_node *node)
> {
> -	if (node)
> +	if (node && of_kset)
> 		kobject_put(&node->kobj);
> }
> EXPORT_SYMBOL(of_node_put);
> @@ -202,9 +202,16 @@ static const char *safe_name(struct kobject *kobj, const char *orig_name)
> static int __of_add_property(struct device_node *np, struct property *pp)
> {
> 	int rc;
> +	bool secure;
> +
> +	/* note that we don't take a lock here */
> +
> +	/* fake the return while of_init is not yet called */
> +	if (!of_kset)
> +		return 0;
> 
> 	/* Important: Don't leak passwords */
> -	bool secure = strncmp(pp->name, "security-", 9) == 0;
> +	secure = strncmp(pp->name, "security-", 9) == 0;
> 
> 	pp->attr.attr.name = safe_name(&np->kobj, pp->name);
> 	pp->attr.attr.mode = secure ? S_IRUSR : S_IRUGO;
> @@ -222,6 +229,12 @@ static int __of_node_add(struct device_node *np)
> 	struct property *pp;
> 	int rc;
> 
> +	/* note that we don't take a lock here */
> +
> +	/* fake the return while of_init is not yet called */
> +	if (!of_kset)
> +		return 0;
> +
> 	np->kobj.kset = of_kset;
> 	if (!np->parent) {
> 		/* Nodes without parents are new top level trees */
> @@ -245,11 +258,14 @@ static int __of_node_add(struct device_node *np)
> int of_node_add(struct device_node *np)
> {
> 	int rc = 0;
> -	kobject_init(&np->kobj, &of_node_ktype);
> +
> +	/* fake the return while of_init is not yet called */
> 	mutex_lock(&of_aliases_mutex);
> +	kobject_init(&np->kobj, &of_node_ktype);
> 	if (of_kset)
> 		rc = __of_node_add(np);
> 	mutex_unlock(&of_aliases_mutex);
> +
> 	return rc;
> }
> 
> @@ -275,14 +291,16 @@ static int __init of_init(void)
> 
> 	/* Make sure all nodes added before this time get added to sysfs */
> 	mutex_lock(&of_aliases_mutex);
> +
> 	for_each_of_allnodes(np)
> 		__of_node_add(np);
> -	mutex_unlock(&of_aliases_mutex);
> 
> 	/* Symlink in /proc as required by userspace ABI */
> 	if (of_allnodes)
> 		proc_symlink("device-tree", NULL, "/sys/firmware/devicetree/base");
> 
> +	mutex_unlock(&of_aliases_mutex);
> +
> 	return 0;
> }
> core_initcall(of_init);
> -- 
> 1.7.12
> 
> 


WARNING: multiple messages have this Message-ID (diff)
From: Koen Kooi <koen-QLwJDigV5abLmq1fohREcCpxlwaOVQ5f@public.gmane.org>
To: Pantelis Antoniou
	<panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org>
Cc: Grant Likely
	<grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>,
	Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>,
	Matt Porter <matt.porter-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Alison Chaiken
	<Alison_Chaiken-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>,
	Dinh Nguyen <dinh.linux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Jan Lubbe <jluebbe-H4yykcOXDpCzQB+pC5nmwQ@public.gmane.org>,
	Alexander Sverdlin
	<alexander.sverdlin-OYasijW0DpE@public.gmane.org>,
	Michael Stickel <ms-g5CePrrZ5ROELgA04lAiVw@public.gmane.org>,
	Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>,
	Dirk Behme <dirk.behme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Alan Tull
	<delicious.quinoa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
	Michael Bohan <mbohan-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	Ionut Nicu <ioan.nicu.ext-OYasijW0DpE@public.gmane.org>,
	Michal Simek <monstr-pSz03upnqPeHXe+LvDLADg@public.gmane.org>,
	Matt Ranostay <mranostay-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Device Tree Mailing List
	<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH 1/3] of: Fix early OF builtup on kobj-ification
Date: Wed, 11 Dec 2013 08:06:42 +0100	[thread overview]
Message-ID: <C3A30FEB-11CB-4CEA-8CB3-B1CA53A87C61@dominion.thruhere.net> (raw)
In-Reply-To: <1386684833-24112-2-git-send-email-panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org>


Op 10 dec. 2013, om 15:13 heeft Pantelis Antoniou <panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org> het volgende geschreven:

> When booting platforms that do very early OF initialization before
> core_initcalls are performed of_init is called too late.
> 
> This results in a hard-hard without getting a chance to output anything.

I think that should be 'hard-hang'.

regards,

Koen

> 
> Fixed by adding a flag that marks when init has been done, and
> performing the per-node init at that time.
> 
> Signed-off-by: Pantelis Antoniou <panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org>
> ---
> drivers/of/base.c | 28 +++++++++++++++++++++++-----
> 1 file changed, 23 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 734689b..a4f3dda 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -98,7 +98,7 @@ int __weak of_node_to_nid(struct device_node *np)
>  */
> struct device_node *of_node_get(struct device_node *node)
> {
> -	if (node)
> +	if (node && of_kset)
> 		kobject_get(&node->kobj);
> 	return node;
> }
> @@ -156,7 +156,7 @@ static void of_node_release(struct kobject *kobj)
>  */
> void of_node_put(struct device_node *node)
> {
> -	if (node)
> +	if (node && of_kset)
> 		kobject_put(&node->kobj);
> }
> EXPORT_SYMBOL(of_node_put);
> @@ -202,9 +202,16 @@ static const char *safe_name(struct kobject *kobj, const char *orig_name)
> static int __of_add_property(struct device_node *np, struct property *pp)
> {
> 	int rc;
> +	bool secure;
> +
> +	/* note that we don't take a lock here */
> +
> +	/* fake the return while of_init is not yet called */
> +	if (!of_kset)
> +		return 0;
> 
> 	/* Important: Don't leak passwords */
> -	bool secure = strncmp(pp->name, "security-", 9) == 0;
> +	secure = strncmp(pp->name, "security-", 9) == 0;
> 
> 	pp->attr.attr.name = safe_name(&np->kobj, pp->name);
> 	pp->attr.attr.mode = secure ? S_IRUSR : S_IRUGO;
> @@ -222,6 +229,12 @@ static int __of_node_add(struct device_node *np)
> 	struct property *pp;
> 	int rc;
> 
> +	/* note that we don't take a lock here */
> +
> +	/* fake the return while of_init is not yet called */
> +	if (!of_kset)
> +		return 0;
> +
> 	np->kobj.kset = of_kset;
> 	if (!np->parent) {
> 		/* Nodes without parents are new top level trees */
> @@ -245,11 +258,14 @@ static int __of_node_add(struct device_node *np)
> int of_node_add(struct device_node *np)
> {
> 	int rc = 0;
> -	kobject_init(&np->kobj, &of_node_ktype);
> +
> +	/* fake the return while of_init is not yet called */
> 	mutex_lock(&of_aliases_mutex);
> +	kobject_init(&np->kobj, &of_node_ktype);
> 	if (of_kset)
> 		rc = __of_node_add(np);
> 	mutex_unlock(&of_aliases_mutex);
> +
> 	return rc;
> }
> 
> @@ -275,14 +291,16 @@ static int __init of_init(void)
> 
> 	/* Make sure all nodes added before this time get added to sysfs */
> 	mutex_lock(&of_aliases_mutex);
> +
> 	for_each_of_allnodes(np)
> 		__of_node_add(np);
> -	mutex_unlock(&of_aliases_mutex);
> 
> 	/* Symlink in /proc as required by userspace ABI */
> 	if (of_allnodes)
> 		proc_symlink("device-tree", NULL, "/sys/firmware/devicetree/base");
> 
> +	mutex_unlock(&of_aliases_mutex);
> +
> 	return 0;
> }
> core_initcall(of_init);
> -- 
> 1.7.12
> 
> 

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

  reply	other threads:[~2013-12-11  7:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-10 14:13 [PATCH 0/3] OF: kobj-ification fixes Pantelis Antoniou
2013-12-10 14:13 ` Pantelis Antoniou
2013-12-10 14:13 ` [PATCH 1/3] of: Fix early OF builtup on kobj-ification Pantelis Antoniou
2013-12-11  7:06   ` Koen Kooi [this message]
2013-12-11  7:06     ` Koen Kooi
2013-12-11 14:51   ` Grant Likely
2013-12-10 14:13 ` [PATCH 2/3] OF: Add a allnodes pointer back to the tree Pantelis Antoniou
2013-12-10 14:13   ` Pantelis Antoniou
2013-12-12 11:20   ` Grant Likely
2013-12-12 11:20     ` Grant Likely
2013-12-12 20:28     ` Pantelis Antoniou
2013-12-12 20:28       ` Pantelis Antoniou
2013-12-10 14:13 ` [PATCH 3/3] OF: kobj ops should only happen on attached nodes Pantelis Antoniou
2013-12-10 14:13   ` Pantelis Antoniou
2013-12-11 13:14   ` Grant Likely
2013-12-11 13:14     ` Grant Likely

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=C3A30FEB-11CB-4CEA-8CB3-B1CA53A87C61@dominion.thruhere.net \
    --to=koen@dominion.thruhere.net \
    --cc=Alison_Chaiken@mentor.com \
    --cc=alexander.sverdlin@nsn.com \
    --cc=delicious.quinoa@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dinh.linux@gmail.com \
    --cc=dirk.behme@gmail.com \
    --cc=grant.likely@secretlab.ca \
    --cc=ioan.nicu.ext@nsn.com \
    --cc=jluebbe@lasnet.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=matt.porter@linaro.org \
    --cc=mbohan@codeaurora.org \
    --cc=monstr@monstr.eu \
    --cc=mranostay@gmail.com \
    --cc=ms@mycable.de \
    --cc=panto@antoniou-consulting.com \
    --cc=robherring2@gmail.com \
    --cc=s.hauer@pengutronix.de \
    --cc=swarren@wwwdotorg.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.