clocksource: arm_arch_timer: fix system hang
Subsystems (2)
PATCH 1/1 clocksource: arm_arch_timer: fix system hang
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.
--- drivers/clocksource/arm_arch_timer.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/clocksource/arm_arch_timer.c +6 -5
@@ -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); + }return probed; }
Signature · 1 line
1.8.3.1
Mark Rutland
maintainerHi Mark,
Quoted 10 lines · Mark Salter
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.
Quoted 6 lines
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 <[email protected]>
Marc Zyngier had a similar fix for this issue a few days ago [1].
Quoted 15 lines
--- drivers/clocksource/arm_arch_timer.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)drivers/clocksource/arm_arch_timer.c +1
-1@@ -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;
drivers/clocksource/arm_arch_timer.c static bool __init · line 676
Quoted 10 lines
drivers/clocksource/arm_arch_timer.c +5
-4dn =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
Quoted 37 lines · Mark Rutland
Hi Mark,
Quoted 10 lines · Mark Salter
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.Quoted 6 lines
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 <[email protected]>Marc Zyngier had a similar fix for this issue a few days ago [1].
Quoted 15 lines
--- drivers/clocksource/arm_arch_timer.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)drivers/clocksource/arm_arch_timer.c +1
-1@@ -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;
Quoted 15 lines
drivers/clocksource/arm_arch_timer.c static bool __init · line 676
Quoted 10 lines
drivers/clocksource/arm_arch_timer.c +5
-4dn =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?
No. It just looked weird to do the of_node_put unconditionally even though of_node_put does check for NULL also.
Quoted 10 lines
Thanks,
Mark.[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-October/294744.html
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel