* [PATCH] of: Fix locking when calling of_get_next_available_child()
@ 2013-02-11 22:19 ` Grant Likely
0 siblings, 0 replies; 7+ messages in thread
From: Grant Likely @ 2013-02-11 22:19 UTC (permalink / raw)
To: devicetree-discuss, linux-kernel
Cc: Grant Likely, Stephen Warren, Rob Herring
of_get_next_available_child() obtains the devtree_lock and then calls
of_device_is_available() which also attempts to claim the lock. This is
obviously incorrect and causes a deadlock on boot. Fix issue by adding
an variant of of_device_is_available() which doesn't obtain the lock.
Cc: Stephen Warren <swarren@wwwdotorg.org>
Cc: Rob Herring <robherring2@gmail.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
drivers/of/base.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index e8d65af..4af74b7 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -297,7 +297,7 @@ EXPORT_SYMBOL(of_machine_is_compatible);
* Returns 1 if the status property is absent or set to "okay" or "ok",
* 0 otherwise
*/
-int of_device_is_available(const struct device_node *device)
+int __of_device_is_available(const struct device_node *device)
{
const char *status;
int statlen;
@@ -313,6 +313,17 @@ int of_device_is_available(const struct device_node *device)
return 0;
}
+
+int of_device_is_available(const struct device_node *device)
+{
+ unsigned long flags;
+ int rc;
+
+ raw_spin_lock_irqsave(&devtree_lock, flags);
+ rc = __of_device_is_available(device);
+ raw_spin_unlock_irqrestore(&devtree_lock, flags);
+ return rc;
+}
EXPORT_SYMBOL(of_device_is_available);
/**
@@ -404,7 +415,7 @@ struct device_node *of_get_next_available_child(const struct device_node *node,
raw_spin_lock(&devtree_lock);
next = prev ? prev->sibling : node->child;
for (; next; next = next->sibling) {
- if (!of_device_is_available(next))
+ if (!__of_device_is_available(next))
continue;
if (of_node_get(next))
break;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] of: Fix locking when calling of_get_next_available_child()
@ 2013-02-11 22:19 ` Grant Likely
0 siblings, 0 replies; 7+ messages in thread
From: Grant Likely @ 2013-02-11 22:19 UTC (permalink / raw)
To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
of_get_next_available_child() obtains the devtree_lock and then calls
of_device_is_available() which also attempts to claim the lock. This is
obviously incorrect and causes a deadlock on boot. Fix issue by adding
an variant of of_device_is_available() which doesn't obtain the lock.
Cc: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
Cc: Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Signed-off-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
---
drivers/of/base.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index e8d65af..4af74b7 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -297,7 +297,7 @@ EXPORT_SYMBOL(of_machine_is_compatible);
* Returns 1 if the status property is absent or set to "okay" or "ok",
* 0 otherwise
*/
-int of_device_is_available(const struct device_node *device)
+int __of_device_is_available(const struct device_node *device)
{
const char *status;
int statlen;
@@ -313,6 +313,17 @@ int of_device_is_available(const struct device_node *device)
return 0;
}
+
+int of_device_is_available(const struct device_node *device)
+{
+ unsigned long flags;
+ int rc;
+
+ raw_spin_lock_irqsave(&devtree_lock, flags);
+ rc = __of_device_is_available(device);
+ raw_spin_unlock_irqrestore(&devtree_lock, flags);
+ return rc;
+}
EXPORT_SYMBOL(of_device_is_available);
/**
@@ -404,7 +415,7 @@ struct device_node *of_get_next_available_child(const struct device_node *node,
raw_spin_lock(&devtree_lock);
next = prev ? prev->sibling : node->child;
for (; next; next = next->sibling) {
- if (!of_device_is_available(next))
+ if (!__of_device_is_available(next))
continue;
if (of_node_get(next))
break;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] of: Fix locking when calling of_get_next_available_child()
2013-02-11 22:19 ` Grant Likely
(?)
@ 2013-02-11 22:27 ` Rob Herring
2013-02-11 22:30 ` Grant Likely
-1 siblings, 1 reply; 7+ messages in thread
From: Rob Herring @ 2013-02-11 22:27 UTC (permalink / raw)
To: Grant Likely; +Cc: devicetree-discuss, linux-kernel, Stephen Warren
On 02/11/2013 04:19 PM, Grant Likely wrote:
> of_get_next_available_child() obtains the devtree_lock and then calls
> of_device_is_available() which also attempts to claim the lock. This is
> obviously incorrect and causes a deadlock on boot. Fix issue by adding
> an variant of of_device_is_available() which doesn't obtain the lock.
>
> Cc: Stephen Warren <swarren@wwwdotorg.org>
> Cc: Rob Herring <robherring2@gmail.com>
> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
> ---
> drivers/of/base.c | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index e8d65af..4af74b7 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -297,7 +297,7 @@ EXPORT_SYMBOL(of_machine_is_compatible);
> * Returns 1 if the status property is absent or set to "okay" or "ok",
> * 0 otherwise
> */
> -int of_device_is_available(const struct device_node *device)
> +int __of_device_is_available(const struct device_node *device)
> {
> const char *status;
> int statlen;
> @@ -313,6 +313,17 @@ int of_device_is_available(const struct device_node *device)
>
> return 0;
> }
> +
> +int of_device_is_available(const struct device_node *device)
Stephen's version wins because he preserved the documentation. :)
Rob
> +{
> + unsigned long flags;
> + int rc;
> +
> + raw_spin_lock_irqsave(&devtree_lock, flags);
> + rc = __of_device_is_available(device);
> + raw_spin_unlock_irqrestore(&devtree_lock, flags);
> + return rc;
> +}
> EXPORT_SYMBOL(of_device_is_available);
>
> /**
> @@ -404,7 +415,7 @@ struct device_node *of_get_next_available_child(const struct device_node *node,
> raw_spin_lock(&devtree_lock);
> next = prev ? prev->sibling : node->child;
> for (; next; next = next->sibling) {
> - if (!of_device_is_available(next))
> + if (!__of_device_is_available(next))
> continue;
> if (of_node_get(next))
> break;
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] of: Fix locking when calling of_get_next_available_child()
2013-02-11 22:27 ` Rob Herring
@ 2013-02-11 22:30 ` Grant Likely
0 siblings, 0 replies; 7+ messages in thread
From: Grant Likely @ 2013-02-11 22:30 UTC (permalink / raw)
To: Rob Herring; +Cc: devicetree-discuss, Linux Kernel Mailing List, Stephen Warren
On Mon, Feb 11, 2013 at 10:27 PM, Rob Herring <robherring2@gmail.com> wrote:
> On 02/11/2013 04:19 PM, Grant Likely wrote:
>> of_get_next_available_child() obtains the devtree_lock and then calls
>> of_device_is_available() which also attempts to claim the lock. This is
>> obviously incorrect and causes a deadlock on boot. Fix issue by adding
>> an variant of of_device_is_available() which doesn't obtain the lock.
>>
>> Cc: Stephen Warren <swarren@wwwdotorg.org>
>> Cc: Rob Herring <robherring2@gmail.com>
>> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
>> ---
>> drivers/of/base.c | 15 +++++++++++++--
>> 1 file changed, 13 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/of/base.c b/drivers/of/base.c
>> index e8d65af..4af74b7 100644
>> --- a/drivers/of/base.c
>> +++ b/drivers/of/base.c
>> @@ -297,7 +297,7 @@ EXPORT_SYMBOL(of_machine_is_compatible);
>> * Returns 1 if the status property is absent or set to "okay" or "ok",
>> * 0 otherwise
>> */
>> -int of_device_is_available(const struct device_node *device)
>> +int __of_device_is_available(const struct device_node *device)
>> {
>> const char *status;
>> int statlen;
>> @@ -313,6 +313,17 @@ int of_device_is_available(const struct device_node *device)
>>
>> return 0;
>> }
>> +
>> +int of_device_is_available(const struct device_node *device)
>
> Stephen's version wins because he preserved the documentation. :)
Pish. He just cut and paste the documentation so now we have 2 copies.
My version wins because it is already in my tree. So ptfff!
:-)
g.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] of: Fix locking when calling of_get_next_available_child()
2013-02-11 22:19 ` Grant Likely
(?)
(?)
@ 2013-02-11 23:26 ` Stephen Warren
2013-02-12 15:20 ` Thierry Reding
2013-02-13 10:08 ` Grant Likely
-1 siblings, 2 replies; 7+ messages in thread
From: Stephen Warren @ 2013-02-11 23:26 UTC (permalink / raw)
To: Grant Likely; +Cc: devicetree-discuss, linux-kernel, Rob Herring
On 02/11/2013 03:19 PM, Grant Likely wrote:
> of_get_next_available_child() obtains the devtree_lock and then calls
> of_device_is_available() which also attempts to claim the lock. This is
> obviously incorrect and causes a deadlock on boot. Fix issue by adding
> an variant of of_device_is_available() which doesn't obtain the lock.
This patch forgets to update __of_device_is_available() to call
__of_get_property() rather than of_get_property() and hence doesn't
actually solve the problem.
You might want to make __of_device_is_available() static too.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] of: Fix locking when calling of_get_next_available_child()
2013-02-11 23:26 ` Stephen Warren
@ 2013-02-12 15:20 ` Thierry Reding
2013-02-13 10:08 ` Grant Likely
1 sibling, 0 replies; 7+ messages in thread
From: Thierry Reding @ 2013-02-12 15:20 UTC (permalink / raw)
To: Stephen Warren; +Cc: Grant Likely, devicetree-discuss, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 739 bytes --]
On Mon, Feb 11, 2013 at 04:26:46PM -0700, Stephen Warren wrote:
> On 02/11/2013 03:19 PM, Grant Likely wrote:
> > of_get_next_available_child() obtains the devtree_lock and then calls
> > of_device_is_available() which also attempts to claim the lock. This is
> > obviously incorrect and causes a deadlock on boot. Fix issue by adding
> > an variant of of_device_is_available() which doesn't obtain the lock.
>
> This patch forgets to update __of_device_is_available() to call
> __of_get_property() rather than of_get_property() and hence doesn't
> actually solve the problem.
Yes, please. of_get_property() called from __of_device_is_available()
pretty much defeats the purpose of having the non-locked version.
Thierry
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] of: Fix locking when calling of_get_next_available_child()
2013-02-11 23:26 ` Stephen Warren
2013-02-12 15:20 ` Thierry Reding
@ 2013-02-13 10:08 ` Grant Likely
1 sibling, 0 replies; 7+ messages in thread
From: Grant Likely @ 2013-02-13 10:08 UTC (permalink / raw)
To: Stephen Warren; +Cc: devicetree-discuss, linux-kernel, Rob Herring
On Mon, 11 Feb 2013 16:26:46 -0700, Stephen Warren <swarren@wwwdotorg.org> wrote:
> On 02/11/2013 03:19 PM, Grant Likely wrote:
> > of_get_next_available_child() obtains the devtree_lock and then calls
> > of_device_is_available() which also attempts to claim the lock. This is
> > obviously incorrect and causes a deadlock on boot. Fix issue by adding
> > an variant of of_device_is_available() which doesn't obtain the lock.
>
> This patch forgets to update __of_device_is_available() to call
> __of_get_property() rather than of_get_property() and hence doesn't
> actually solve the problem.
>
> You might want to make __of_device_is_available() static too.
Okay, I've dropped this patch and replaced it with your version since
you're actually doing better testing that I it would appear. I had to
respin my tree anyway because I messed up a merge of Rob's branch. :-(
Sorry for the noise.
New version of the tree is pushed out.
g.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-02-13 10:08 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-11 22:19 [PATCH] of: Fix locking when calling of_get_next_available_child() Grant Likely
2013-02-11 22:19 ` Grant Likely
2013-02-11 22:27 ` Rob Herring
2013-02-11 22:30 ` Grant Likely
2013-02-11 23:26 ` Stephen Warren
2013-02-12 15:20 ` Thierry Reding
2013-02-13 10:08 ` Grant Likely
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.