All of lore.kernel.org
 help / color / mirror / Atom feed
From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] clocksource: arm_arch_timer: fix system hang
Date: Sun, 19 Oct 2014 20:40:55 +0100	[thread overview]
Message-ID: <20141019194055.GA24830@leverpostej> (raw)
In-Reply-To: <1413732164-19545-1-git-send-email-msalter@redhat.com>

Hi Mark,

On Sun, Oct 19, 2014 at 04:22:44PM +0100, Mark Salter wrote:
> Arm allows for two possible architectural clock sources. One memory mapped
> and the other coprocessor based. If both timers exist, then the driver waits
> for both to be probed before registering a clocksource.
> 
> Commit c387f07e6205 ("clocksource: arm_arch_timer: Discard unavailable timers
> correctly") attempted to fix a hang occurring when one of the two possible
> timers had a device node, but was disabled. In that case, the second probe
> would never occur and the system would hang without a clocksource being
> registered.
> 
> Unfortunately, incorrect logic in that commit made things worse such that
> a hang would occur unless both timers had a device node and were enabled.
> This patch fixes the logic so that we don't wait to probe a second timer
> unless it exists and is enabled.
> 
> Signed-off-by: Mark Salter <msalter@redhat.com>

Marc Zyngier had a similar fix for this issue a few days ago [1].

> ---
>  drivers/clocksource/arm_arch_timer.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
> index d1a5e35..b73392b 100644
> --- a/drivers/clocksource/arm_arch_timer.c
> +++ b/drivers/clocksource/arm_arch_timer.c
> @@ -666,13 +666,14 @@ static bool __init
>  arch_timer_probed(int type, const struct of_device_id *matches)
>  {
>  	struct device_node *dn;
> -	bool probed = false;
> +	bool probed = true;
>  
>  	dn = of_find_matching_node(NULL, matches);
> -	if (dn && of_device_is_available(dn) && (arch_timers_present & type))
> -		probed = true;
> -	of_node_put(dn);
> -
> +	if (dn) {
> +		if (of_device_is_available(dn) && !(arch_timers_present & type))
> +			probed = false;
> +		of_node_put(dn);
> +	}

Other than the addition of the NULL check, this looks identical to
Marc's fix. There's already a NULL check in of_device_is_available, so I
don't think it's necessary to add one here. Are you seeing some failure
with a NULL np?

Thanks,
Mark.

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-October/294744.html

WARNING: multiple messages have this Message-ID (diff)
From: Mark Rutland <mark.rutland@arm.com>
To: Mark Salter <msalter@redhat.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>,
	Sudeep Holla <Sudeep.Holla@arm.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Stephen Boyd <sboyd@codeaurora.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] clocksource: arm_arch_timer: fix system hang
Date: Sun, 19 Oct 2014 20:40:55 +0100	[thread overview]
Message-ID: <20141019194055.GA24830@leverpostej> (raw)
In-Reply-To: <1413732164-19545-1-git-send-email-msalter@redhat.com>

Hi Mark,

On Sun, Oct 19, 2014 at 04:22:44PM +0100, Mark Salter wrote:
> Arm allows for two possible architectural clock sources. One memory mapped
> and the other coprocessor based. If both timers exist, then the driver waits
> for both to be probed before registering a clocksource.
> 
> Commit c387f07e6205 ("clocksource: arm_arch_timer: Discard unavailable timers
> correctly") attempted to fix a hang occurring when one of the two possible
> timers had a device node, but was disabled. In that case, the second probe
> would never occur and the system would hang without a clocksource being
> registered.
> 
> Unfortunately, incorrect logic in that commit made things worse such that
> a hang would occur unless both timers had a device node and were enabled.
> This patch fixes the logic so that we don't wait to probe a second timer
> unless it exists and is enabled.
> 
> Signed-off-by: Mark Salter <msalter@redhat.com>

Marc Zyngier had a similar fix for this issue a few days ago [1].

> ---
>  drivers/clocksource/arm_arch_timer.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
> index d1a5e35..b73392b 100644
> --- a/drivers/clocksource/arm_arch_timer.c
> +++ b/drivers/clocksource/arm_arch_timer.c
> @@ -666,13 +666,14 @@ static bool __init
>  arch_timer_probed(int type, const struct of_device_id *matches)
>  {
>  	struct device_node *dn;
> -	bool probed = false;
> +	bool probed = true;
>  
>  	dn = of_find_matching_node(NULL, matches);
> -	if (dn && of_device_is_available(dn) && (arch_timers_present & type))
> -		probed = true;
> -	of_node_put(dn);
> -
> +	if (dn) {
> +		if (of_device_is_available(dn) && !(arch_timers_present & type))
> +			probed = false;
> +		of_node_put(dn);
> +	}

Other than the addition of the NULL check, this looks identical to
Marc's fix. There's already a NULL check in of_device_is_available, so I
don't think it's necessary to add one here. Are you seeing some failure
with a NULL np?

Thanks,
Mark.

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-October/294744.html

  reply	other threads:[~2014-10-19 19:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-19 15:22 [PATCH] clocksource: arm_arch_timer: fix system hang Mark Salter
2014-10-19 15:22 ` Mark Salter
2014-10-19 19:40 ` Mark Rutland [this message]
2014-10-19 19:40   ` Mark Rutland
2014-10-19 22:36   ` Mark Salter
2014-10-19 22:36     ` Mark Salter

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=20141019194055.GA24830@leverpostej \
    --to=mark.rutland@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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.