video: tegra: fix syncpoint timeouts in host1x driver
authorColin Cross <ccross@android.com>
Mon, 30 Aug 2010 19:41:23 +0000 (12:41 -0700)
committerColin Cross <ccross@android.com>
Wed, 6 Oct 2010 23:50:36 +0000 (16:50 -0700)
Change-Id: Ief81ad3ce74cc446e21e54c2d2acca977f0fa934
Signed-off-by: Erik Gilling <konkers@android.com>
drivers/video/tegra/host/nvhost_syncpt.c

index 4a51fcf792b32bd7571e1c41e5995a16009b5c07..dd2ab0d379e04b48a1a715034489248950f8c37d 100644 (file)
@@ -194,16 +194,23 @@ int nvhost_syncpt_wait_timeout(struct nvhost_syncpt *sp, u32 id,
        if (err)
                goto done;
 
+       err = -EAGAIN;
        /* wait for the syncpoint, or timeout, or signal */
        while (timeout) {
                u32 check = min_t(u32, SYNCPT_CHECK_PERIOD, timeout);
-               err = wait_event_interruptible_timeout(wq,
+               int remain = wait_event_interruptible_timeout(wq,
                                                nvhost_syncpt_min_cmp(sp, id, thresh),
                                                check);
-               if (err != 0)
+               if (remain > 0 || nvhost_syncpt_min_cmp(sp, id, thresh)) {
+                       err = 0;
                        break;
+               }
+               if (remain < 0) {
+                       err = remain;
+                       break;
+               }
                if (timeout != NVHOST_NO_TIMEOUT)
-                       timeout -= SYNCPT_CHECK_PERIOD;
+                       timeout -= check;
                if (timeout) {
                        dev_warn(&syncpt_to_dev(sp)->pdev->dev,
                                "syncpoint id %d (%s) stuck waiting %d\n",
@@ -211,10 +218,6 @@ int nvhost_syncpt_wait_timeout(struct nvhost_syncpt *sp, u32 id,
                        nvhost_syncpt_debug(sp);
                }
        };
-       if (err > 0)
-               err = 0;
-       else if (err == 0)
-               err = -EAGAIN;
        nvhost_intr_put_ref(&(syncpt_to_dev(sp)->intr), ref);
 
 done: