summaryrefslogtreecommitdiff
path: root/drivers/clocksource/samsung_pwm_timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/clocksource/samsung_pwm_timer.c')
-rw-r--r--drivers/clocksource/samsung_pwm_timer.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/clocksource/samsung_pwm_timer.c b/drivers/clocksource/samsung_pwm_timer.c
index 92b2f130ae9b..0234c8d2c8f2 100644
--- a/drivers/clocksource/samsung_pwm_timer.c
+++ b/drivers/clocksource/samsung_pwm_timer.c
@@ -176,6 +176,19 @@ static void samsung_time_start(unsigned int channel, bool periodic)
static int samsung_set_next_event(unsigned long cycles,
struct clock_event_device *evt)
{
+ /*
+ * This check is needed to account for internal rounding
+ * errors inside clockevents core, which might result in
+ * passing cycles = 0, which in turn would not generate any
+ * timer interrupt and hang the system.
+ *
+ * Another solution would be to set up the clockevent device
+ * with min_delta = 2, but this would unnecessarily increase
+ * the minimum sleep period.
+ */
+ if (!cycles)
+ cycles = 1;
+
samsung_time_setup(pwm.event_id, cycles);
samsung_time_start(pwm.event_id, false);