diff mbox

exynos4210/mct: Avoid infinite loop on non incremental timers

Message ID 50BA39A9.8030402@tribudubois.net
State New
Headers show

Commit Message

Jean-Christophe Dubois Dec. 1, 2012, 5:08 p.m. UTC
Check for a 0 "distance" value to avoid infinite loop when the
expired FCR timer was not programed with auto-increment.

With this change the behavior is coherent with the same type
of code in the exynos4210_gfrc_restart() function in the same
file.

Linux seems to mostly use this timer with auto-increment
which explain why it is not a problem most of the time.

However other OS might have a problem with this if they
don't use the auto-increment feature.

Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net>
---
  hw/exynos4210_mct.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

--

1.7.9.5

Comments

Evgeny Voevodin Dec. 3, 2012, 8:44 a.m. UTC | #1
On 12/01/2012 09:08 PM, Jean-Christophe DUBOIS wrote:
> Check for a 0 "distance" value to avoid infinite loop when the
> expired FCR timer was not programed with auto-increment.
>
> With this change the behavior is coherent with the same type
> of code in the exynos4210_gfrc_restart() function in the same
> file.
>
> Linux seems to mostly use this timer with auto-increment
> which explain why it is not a problem most of the time.
>
> However other OS might have a problem with this if they
> don't use the auto-increment feature.
>
> Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net>
> ---
>  hw/exynos4210_mct.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/exynos4210_mct.c b/hw/exynos4210_mct.c
> index e79cd6a..31a41d5 100644
> --- a/hw/exynos4210_mct.c
> +++ b/hw/exynos4210_mct.c
> @@ -568,7 +568,7 @@ static void exynos4210_gfrc_event(void *opaque)
>      /* Reload FRC to reach nearest comparator */
>      s->g_timer.curr_comp = exynos4210_gcomp_find(s);
>      distance = exynos4210_gcomp_get_distance(s, s->g_timer.curr_comp);
> -    if (distance > MCT_GT_COUNTER_STEP) {
> +    if ((distance > MCT_GT_COUNTER_STEP) || !distance) {

You don't need additional braces here.

> distance = MCT_GT_COUNTER_STEP;
>      }
>      exynos4210_gfrc_set_count(&s->g_timer, distance);
> -- 
>
> 1.7.9.5
>
>
>

Doesn't apply to current master, please, rebase:

Applying: exynos4210/mct: Avoid infinite loop on non incremental timers
error: patch failed: hw/exynos4210_mct.c:568
error: hw/exynos4210_mct.c: patch does not apply
diff mbox

Patch

diff --git a/hw/exynos4210_mct.c b/hw/exynos4210_mct.c
index e79cd6a..31a41d5 100644
--- a/hw/exynos4210_mct.c
+++ b/hw/exynos4210_mct.c
@@ -568,7 +568,7 @@  static void exynos4210_gfrc_event(void *opaque)
      /* Reload FRC to reach nearest comparator */
      s->g_timer.curr_comp = exynos4210_gcomp_find(s);
      distance = exynos4210_gcomp_get_distance(s, s->g_timer.curr_comp);
-    if (distance > MCT_GT_COUNTER_STEP) {
+    if ((distance > MCT_GT_COUNTER_STEP) || !distance) {
          distance = MCT_GT_COUNTER_STEP;
      }
      exynos4210_gfrc_set_count(&s->g_timer, distance);