linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clocksource: arm_arch_timer: discard unavailable timers correctly
@ 2014-09-16 23:50 Sudeep Holla
  2014-09-17  0:01 ` Stephen Boyd
  2014-09-17 19:39 ` [PATCH v2] " Sudeep Holla
  0 siblings, 2 replies; 8+ messages in thread
From: Sudeep Holla @ 2014-09-16 23:50 UTC (permalink / raw)
  To: linux-arm-kernel

Currently we wait until both nodes are probed if we have two timers
without checking if the device is actually available. This might
result in non-functional system as no timer gets registered.

This patch adds the check for the availablity of the timer device
so that unavailable timers are discarded correctly.

Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 drivers/clocksource/arm_arch_timer.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index 5163ec1..4d025ad 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -622,11 +622,15 @@ static void __init arch_timer_common_init(void)
 
 	/* Wait until both nodes are probed if we have two timers */
 	if ((arch_timers_present & mask) != mask) {
-		if (of_find_matching_node(NULL, arch_timer_mem_of_match) &&
-				!(arch_timers_present & ARCH_MEM_TIMER))
+		struct device_node *dn;
+
+		dn = of_find_matching_node(NULL, arch_timer_mem_of_match);
+		if (dn && of_device_is_available(dn) &&
+		    !(arch_timers_present & ARCH_MEM_TIMER))
 			return;
-		if (of_find_matching_node(NULL, arch_timer_of_match) &&
-				!(arch_timers_present & ARCH_CP15_TIMER))
+		dn = of_find_matching_node(NULL, arch_timer_of_match);
+		if (dn && of_device_is_available(dn) &&
+		    !(arch_timers_present & ARCH_CP15_TIMER))
 			return;
 	}
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] clocksource: arm_arch_timer: discard unavailable timers correctly
  2014-09-16 23:50 [PATCH] clocksource: arm_arch_timer: discard unavailable timers correctly Sudeep Holla
@ 2014-09-17  0:01 ` Stephen Boyd
  2014-09-17 19:39 ` [PATCH v2] " Sudeep Holla
  1 sibling, 0 replies; 8+ messages in thread
From: Stephen Boyd @ 2014-09-17  0:01 UTC (permalink / raw)
  To: linux-arm-kernel

On 09/17, Sudeep Holla wrote:
> Currently we wait until both nodes are probed if we have two timers
> without checking if the device is actually available. This might

device node is actually available?

> result in non-functional system as no timer gets registered.
> 
> This patch adds the check for the availablity of the timer device
> so that unavailable timers are discarded correctly.
> 
> Cc: Stephen Boyd <sboyd@codeaurora.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---

Looks mostly ok. Comment below could be a follow up I guess.

>  drivers/clocksource/arm_arch_timer.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
> index 5163ec1..4d025ad 100644
> --- a/drivers/clocksource/arm_arch_timer.c
> +++ b/drivers/clocksource/arm_arch_timer.c
> @@ -622,11 +622,15 @@ static void __init arch_timer_common_init(void)
>  
>  	/* Wait until both nodes are probed if we have two timers */
>  	if ((arch_timers_present & mask) != mask) {
> -		if (of_find_matching_node(NULL, arch_timer_mem_of_match) &&
> -				!(arch_timers_present & ARCH_MEM_TIMER))
> +		struct device_node *dn;
> +
> +		dn = of_find_matching_node(NULL, arch_timer_mem_of_match);
> +		if (dn && of_device_is_available(dn) &&
> +		    !(arch_timers_present & ARCH_MEM_TIMER))
>  			return;
> -		if (of_find_matching_node(NULL, arch_timer_of_match) &&
> -				!(arch_timers_present & ARCH_CP15_TIMER))
> +		dn = of_find_matching_node(NULL, arch_timer_of_match);
> +		if (dn && of_device_is_available(dn) &&
> +		    !(arch_timers_present & ARCH_CP15_TIMER))
>  			return;

Where's the of_node_put()?

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] clocksource: arm_arch_timer: discard unavailable timers correctly
  2014-09-16 23:50 [PATCH] clocksource: arm_arch_timer: discard unavailable timers correctly Sudeep Holla
  2014-09-17  0:01 ` Stephen Boyd
@ 2014-09-17 19:39 ` Sudeep Holla
  2014-09-17 19:51   ` Stephen Boyd
                     ` (2 more replies)
  1 sibling, 3 replies; 8+ messages in thread
From: Sudeep Holla @ 2014-09-17 19:39 UTC (permalink / raw)
  To: linux-arm-kernel

Currently we wait until both cp15 and mem timers are probed if we
have both timer device nodes present in the device tree without
checking if the device is actually available. If one of the timer
device node present is disabled, the system locks up on the boot
as no timer gets registered.

This patch adds the check for the availablity of the timer device
so that we unavailable timers are discarded correctly. It also adds
the missing of_node_put.

Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 drivers/clocksource/arm_arch_timer.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

Changes v1->v2:
	- Added missing of_node_put in the original code
	- Updated the commit log as suggested

diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index 5163ec13429d..7e267e3990ab 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -616,17 +616,29 @@ static const struct of_device_id arch_timer_mem_of_match[] __initconst = {
 	{},
 };
 
+static bool __init
+arch_timer_probed(int type, const struct of_device_id *matches)
+{
+	struct device_node *dn;
+	bool probed = false;
+
+	dn = of_find_matching_node(NULL, matches);
+	if (dn && of_device_is_available(dn) && (arch_timers_present & type))
+		probed = true;
+	of_node_put(dn);
+
+	return probed;
+}
+
 static void __init arch_timer_common_init(void)
 {
 	unsigned mask = ARCH_CP15_TIMER | ARCH_MEM_TIMER;
 
 	/* Wait until both nodes are probed if we have two timers */
 	if ((arch_timers_present & mask) != mask) {
-		if (of_find_matching_node(NULL, arch_timer_mem_of_match) &&
-				!(arch_timers_present & ARCH_MEM_TIMER))
+		if (!arch_timer_probed(ARCH_MEM_TIMER, arch_timer_mem_of_match))
 			return;
-		if (of_find_matching_node(NULL, arch_timer_of_match) &&
-				!(arch_timers_present & ARCH_CP15_TIMER))
+		if (!arch_timer_probed(ARCH_CP15_TIMER, arch_timer_of_match))
 			return;
 	}
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2] clocksource: arm_arch_timer: discard unavailable timers correctly
  2014-09-17 19:39 ` [PATCH v2] " Sudeep Holla
@ 2014-09-17 19:51   ` Stephen Boyd
  2014-09-24 15:16   ` Sudeep Holla
  2014-09-24 16:23   ` [PATCH v3] " Sudeep Holla
  2 siblings, 0 replies; 8+ messages in thread
From: Stephen Boyd @ 2014-09-17 19:51 UTC (permalink / raw)
  To: linux-arm-kernel

On 09/17, Sudeep Holla wrote:
> Currently we wait until both cp15 and mem timers are probed if we
> have both timer device nodes present in the device tree without
> checking if the device is actually available. If one of the timer
> device node present is disabled, the system locks up on the boot
> as no timer gets registered.
> 
> This patch adds the check for the availablity of the timer device
> so that we unavailable timers are discarded correctly. It also adds

s/we//

> the missing of_node_put.
> 
> Cc: Stephen Boyd <sboyd@codeaurora.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---

Thanks.

Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] clocksource: arm_arch_timer: discard unavailable timers correctly
  2014-09-17 19:39 ` [PATCH v2] " Sudeep Holla
  2014-09-17 19:51   ` Stephen Boyd
@ 2014-09-24 15:16   ` Sudeep Holla
  2014-09-24 15:48     ` Mark Rutland
  2014-09-24 16:23   ` [PATCH v3] " Sudeep Holla
  2 siblings, 1 reply; 8+ messages in thread
From: Sudeep Holla @ 2014-09-24 15:16 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Mark,

On 17/09/14 20:39, Sudeep Holla wrote:
> Currently we wait until both cp15 and mem timers are probed if we
> have both timer device nodes present in the device tree without
> checking if the device is actually available. If one of the timer
> device node present is disabled, the system locks up on the boot
> as no timer gets registered.
>
> This patch adds the check for the availablity of the timer device
> so that we unavailable timers are discarded correctly. It also adds
> the missing of_node_put.
>
> Cc: Stephen Boyd <sboyd@codeaurora.org>
> Cc: Mark Rutland <mark.rutland@arm.com>

If your are fine with this, can I ask Daniel you pick this up ?

Regards,
Sudeep

> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
>   drivers/clocksource/arm_arch_timer.c | 20 ++++++++++++++++----
>   1 file changed, 16 insertions(+), 4 deletions(-)
>
> Changes v1->v2:
> 	- Added missing of_node_put in the original code
> 	- Updated the commit log as suggested
>
> diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
> index 5163ec13429d..7e267e3990ab 100644
> --- a/drivers/clocksource/arm_arch_timer.c
> +++ b/drivers/clocksource/arm_arch_timer.c
> @@ -616,17 +616,29 @@ static const struct of_device_id arch_timer_mem_of_match[] __initconst = {
>   	{},
>   };
>
> +static bool __init
> +arch_timer_probed(int type, const struct of_device_id *matches)
> +{
> +	struct device_node *dn;
> +	bool probed = false;
> +
> +	dn = of_find_matching_node(NULL, matches);
> +	if (dn && of_device_is_available(dn) && (arch_timers_present & type))
> +		probed = true;
> +	of_node_put(dn);
> +
> +	return probed;
> +}
> +
>   static void __init arch_timer_common_init(void)
>   {
>   	unsigned mask = ARCH_CP15_TIMER | ARCH_MEM_TIMER;
>
>   	/* Wait until both nodes are probed if we have two timers */
>   	if ((arch_timers_present & mask) != mask) {
> -		if (of_find_matching_node(NULL, arch_timer_mem_of_match) &&
> -				!(arch_timers_present & ARCH_MEM_TIMER))
> +		if (!arch_timer_probed(ARCH_MEM_TIMER, arch_timer_mem_of_match))
>   			return;
> -		if (of_find_matching_node(NULL, arch_timer_of_match) &&
> -				!(arch_timers_present & ARCH_CP15_TIMER))
> +		if (!arch_timer_probed(ARCH_CP15_TIMER, arch_timer_of_match))
>   			return;
>   	}
>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] clocksource: arm_arch_timer: discard unavailable timers correctly
  2014-09-24 15:16   ` Sudeep Holla
@ 2014-09-24 15:48     ` Mark Rutland
  2014-09-24 15:55       ` Sudeep Holla
  0 siblings, 1 reply; 8+ messages in thread
From: Mark Rutland @ 2014-09-24 15:48 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 24, 2014 at 04:16:47PM +0100, Sudeep Holla wrote:
> Hi Mark,
> 
> On 17/09/14 20:39, Sudeep Holla wrote:
> > Currently we wait until both cp15 and mem timers are probed if we
> > have both timer device nodes present in the device tree without
> > checking if the device is actually available. If one of the timer
> > device node present is disabled, the system locks up on the boot
> > as no timer gets registered.
> >
> > This patch adds the check for the availablity of the timer device
> > so that we unavailable timers are discarded correctly. It also adds
> > the missing of_node_put.
> >
> > Cc: Stephen Boyd <sboyd@codeaurora.org>
> > Cc: Mark Rutland <mark.rutland@arm.com>
> 
> If your are fine with this, can I ask Daniel you pick this up ?

While I'd prefer to see the cp15 and mmio timer driver pulled apart,
that's not going to happen at any point soon. For the moment, this is
far better than the current state of affairs. So:

Acked-by: Mark Rutland <mark.rutland@arm.com>

Mark.

> 
> Regards,
> Sudeep
> 
> > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> > ---
> >   drivers/clocksource/arm_arch_timer.c | 20 ++++++++++++++++----
> >   1 file changed, 16 insertions(+), 4 deletions(-)
> >
> > Changes v1->v2:
> > 	- Added missing of_node_put in the original code
> > 	- Updated the commit log as suggested
> >
> > diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
> > index 5163ec13429d..7e267e3990ab 100644
> > --- a/drivers/clocksource/arm_arch_timer.c
> > +++ b/drivers/clocksource/arm_arch_timer.c
> > @@ -616,17 +616,29 @@ static const struct of_device_id arch_timer_mem_of_match[] __initconst = {
> >   	{},
> >   };
> >
> > +static bool __init
> > +arch_timer_probed(int type, const struct of_device_id *matches)
> > +{
> > +	struct device_node *dn;
> > +	bool probed = false;
> > +
> > +	dn = of_find_matching_node(NULL, matches);
> > +	if (dn && of_device_is_available(dn) && (arch_timers_present & type))
> > +		probed = true;
> > +	of_node_put(dn);
> > +
> > +	return probed;
> > +}
> > +
> >   static void __init arch_timer_common_init(void)
> >   {
> >   	unsigned mask = ARCH_CP15_TIMER | ARCH_MEM_TIMER;
> >
> >   	/* Wait until both nodes are probed if we have two timers */
> >   	if ((arch_timers_present & mask) != mask) {
> > -		if (of_find_matching_node(NULL, arch_timer_mem_of_match) &&
> > -				!(arch_timers_present & ARCH_MEM_TIMER))
> > +		if (!arch_timer_probed(ARCH_MEM_TIMER, arch_timer_mem_of_match))
> >   			return;
> > -		if (of_find_matching_node(NULL, arch_timer_of_match) &&
> > -				!(arch_timers_present & ARCH_CP15_TIMER))
> > +		if (!arch_timer_probed(ARCH_CP15_TIMER, arch_timer_of_match))
> >   			return;
> >   	}
> >
> >

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] clocksource: arm_arch_timer: discard unavailable timers correctly
  2014-09-24 15:48     ` Mark Rutland
@ 2014-09-24 15:55       ` Sudeep Holla
  0 siblings, 0 replies; 8+ messages in thread
From: Sudeep Holla @ 2014-09-24 15:55 UTC (permalink / raw)
  To: linux-arm-kernel



On 24/09/14 16:48, Mark Rutland wrote:
> On Wed, Sep 24, 2014 at 04:16:47PM +0100, Sudeep Holla wrote:
>> Hi Mark,
>>
>> On 17/09/14 20:39, Sudeep Holla wrote:
>>> Currently we wait until both cp15 and mem timers are probed if we
>>> have both timer device nodes present in the device tree without
>>> checking if the device is actually available. If one of the timer
>>> device node present is disabled, the system locks up on the boot
>>> as no timer gets registered.
>>>
>>> This patch adds the check for the availablity of the timer device
>>> so that we unavailable timers are discarded correctly. It also adds
>>> the missing of_node_put.
>>>
>>> Cc: Stephen Boyd <sboyd@codeaurora.org>
>>> Cc: Mark Rutland <mark.rutland@arm.com>
>>
>> If your are fine with this, can I ask Daniel you pick this up ?
>
> While I'd prefer to see the cp15 and mmio timer driver pulled apart,
> that's not going to happen at any point soon. For the moment, this is

Agreed :)

> far better than the current state of affairs. So:
>
> Acked-by: Mark Rutland <mark.rutland@arm.com>
>

Thanks

Regards,
Sudeep

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3] clocksource: arm_arch_timer: discard unavailable timers correctly
  2014-09-17 19:39 ` [PATCH v2] " Sudeep Holla
  2014-09-17 19:51   ` Stephen Boyd
  2014-09-24 15:16   ` Sudeep Holla
@ 2014-09-24 16:23   ` Sudeep Holla
  2 siblings, 0 replies; 8+ messages in thread
From: Sudeep Holla @ 2014-09-24 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

Currently we wait until both cp15 and mem timers are probed if we
have both timer device nodes present in the device tree without
checking if the device is actually available. If one of the timer
device node present is disabled, the system locks up on the boot
as no timer gets registered.

This patch adds the check for the availability of the timer device
so that unavailable timers are discarded correctly. It also adds
the missing of_node_put.

Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
---
 drivers/clocksource/arm_arch_timer.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

Hi Daniel,

Can you pick up this fix for v3.18 ?

Regards,
Sudeep

Changes v2->v3:
	- Minor nit in the commit message
	- Added acks/review tags

Changes v1->v2:
	- Added missing of_node_put in the original code
	- Updated the commit log as suggested

diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index 5163ec13429d..7e267e3990ab 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -616,17 +616,29 @@ static const struct of_device_id arch_timer_mem_of_match[] __initconst = {
 	{},
 };
 
+static bool __init
+arch_timer_probed(int type, const struct of_device_id *matches)
+{
+	struct device_node *dn;
+	bool probed = false;
+
+	dn = of_find_matching_node(NULL, matches);
+	if (dn && of_device_is_available(dn) && (arch_timers_present & type))
+		probed = true;
+	of_node_put(dn);
+
+	return probed;
+}
+
 static void __init arch_timer_common_init(void)
 {
 	unsigned mask = ARCH_CP15_TIMER | ARCH_MEM_TIMER;
 
 	/* Wait until both nodes are probed if we have two timers */
 	if ((arch_timers_present & mask) != mask) {
-		if (of_find_matching_node(NULL, arch_timer_mem_of_match) &&
-				!(arch_timers_present & ARCH_MEM_TIMER))
+		if (!arch_timer_probed(ARCH_MEM_TIMER, arch_timer_mem_of_match))
 			return;
-		if (of_find_matching_node(NULL, arch_timer_of_match) &&
-				!(arch_timers_present & ARCH_CP15_TIMER))
+		if (!arch_timer_probed(ARCH_CP15_TIMER, arch_timer_of_match))
 			return;
 	}
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-09-24 16:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-16 23:50 [PATCH] clocksource: arm_arch_timer: discard unavailable timers correctly Sudeep Holla
2014-09-17  0:01 ` Stephen Boyd
2014-09-17 19:39 ` [PATCH v2] " Sudeep Holla
2014-09-17 19:51   ` Stephen Boyd
2014-09-24 15:16   ` Sudeep Holla
2014-09-24 15:48     ` Mark Rutland
2014-09-24 15:55       ` Sudeep Holla
2014-09-24 16:23   ` [PATCH v3] " Sudeep Holla

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