Commit c387f07e6205cc13f57c1def5f885bf0a20e1c2d

Authored by Sudeep Holla
Committed by Daniel Lezcano
1 parent 04f7e3e513

clocksource: arm_arch_timer: Discard unavailable timers correctly

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>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Showing 1 changed file with 16 additions and 4 deletions Side-by-side Diff

drivers/clocksource/arm_arch_timer.c
... ... @@ -616,17 +616,29 @@
616 616 {},
617 617 };
618 618  
  619 +static bool __init
  620 +arch_timer_probed(int type, const struct of_device_id *matches)
  621 +{
  622 + struct device_node *dn;
  623 + bool probed = false;
  624 +
  625 + dn = of_find_matching_node(NULL, matches);
  626 + if (dn && of_device_is_available(dn) && (arch_timers_present & type))
  627 + probed = true;
  628 + of_node_put(dn);
  629 +
  630 + return probed;
  631 +}
  632 +
619 633 static void __init arch_timer_common_init(void)
620 634 {
621 635 unsigned mask = ARCH_CP15_TIMER | ARCH_MEM_TIMER;
622 636  
623 637 /* Wait until both nodes are probed if we have two timers */
624 638 if ((arch_timers_present & mask) != mask) {
625   - if (of_find_matching_node(NULL, arch_timer_mem_of_match) &&
626   - !(arch_timers_present & ARCH_MEM_TIMER))
  639 + if (!arch_timer_probed(ARCH_MEM_TIMER, arch_timer_mem_of_match))
627 640 return;
628   - if (of_find_matching_node(NULL, arch_timer_of_match) &&
629   - !(arch_timers_present & ARCH_CP15_TIMER))
  641 + if (!arch_timer_probed(ARCH_CP15_TIMER, arch_timer_of_match))
630 642 return;
631 643 }
632 644