video: tegra: host: Do not panic on hardware timeout
Terje Bergstrom [Thu, 12 Apr 2012 11:28:40 +0000 (14:28 +0300)]
nvhost panics if hardware does not respond within 30 seconds. Remove
this behavior, as it causes problems in emulation and simulation.
Panic should be used only to prevent corruption.

Submits are now given a default timeout of 30 seconds. The clients
can still override with their own timeout value.

MPE doesn't provide the number of slots for context save/restore.
This information is needed to be able to use the submit timeout for
MPE.

Bug 982946

Change-Id: I0f54d639df0fb726cc3163b317bf9c90bf56798b
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/100246
Reviewed-by: Rohan Somvanshi <rsomvanshi@nvidia.com>
Tested-by: Rohan Somvanshi <rsomvanshi@nvidia.com>

drivers/video/tegra/host/bus_client.c
drivers/video/tegra/host/mpe/mpe.c
drivers/video/tegra/host/nvhost_syncpt.c
drivers/video/tegra/host/nvhost_syncpt.h

index aed44b4..39f34f0 100644 (file)
@@ -141,6 +141,7 @@ static int nvhost_channelopen(struct inode *inode, struct file *filp)
        priv->priority = NVHOST_PRIORITY_MEDIUM;
        priv->clientid = atomic_add_return(1,
                        &nvhost_get_host(ch->dev)->clientid);
+       priv->timeout = MAX_STUCK_CHECK_COUNT * SYNCPT_CHECK_PERIOD;
 
        priv->job = nvhost_job_alloc(ch, priv->hwctx, &priv->hdr,
                        NULL, priv->priority, priv->clientid);
index 6111379..2ca9bb0 100644 (file)
@@ -461,6 +461,7 @@ static struct nvhost_hwctx *ctxmpe_alloc(struct nvhost_hwctx_handler *h,
        ctx->hwctx.valid = false;
        ctx->save_incrs = 3;
        ctx->save_thresh = 2;
+       ctx->save_slots = p->save_slots;
        ctx->restore_phys = nvmap_pin(nvmap, ctx->restore);
        ctx->restore_size = restore_size;
        ctx->restore_incrs = 1;
@@ -567,6 +568,7 @@ struct nvhost_hwctx_handler *nvhost_mpe_ctxhandler_init(
        }
 
        p->save_phys = nvmap_pin(nvmap, p->save_buf);
+       p->save_slots = 1;
 
        setup_save(p, save_ptr);
 
index 4c6655e..f5ecd12 100644 (file)
@@ -27,7 +27,6 @@
 #include "nvhost_acm.h"
 #include "dev.h"
 
-#define MAX_STUCK_CHECK_COUNT 15
 #define MAX_SYNCPT_LENGTH 5
 /* Name of sysfs node for min and max value */
 static const char *min_name = "min";
@@ -206,20 +205,19 @@ int nvhost_syncpt_wait_timeout(struct nvhost_syncpt *sp, u32 id,
                }
                if (timeout != NVHOST_NO_TIMEOUT)
                        timeout -= check;
-               if (timeout) {
+               if (timeout && check_count <= MAX_STUCK_CHECK_COUNT) {
                        dev_warn(&syncpt_to_dev(sp)->dev->dev,
                                "%s: syncpoint id %d (%s) stuck waiting %d, timeout=%d\n",
                                 current->comm, id, syncpt_op().name(sp, id),
                                 thresh, timeout);
                        syncpt_op().debug(sp);
-                       if (check_count > MAX_STUCK_CHECK_COUNT) {
+                       if (check_count == MAX_STUCK_CHECK_COUNT) {
                                if (low_timeout) {
                                        dev_warn(&syncpt_to_dev(sp)->dev->dev,
                                                "is timeout %d too low?\n",
                                                low_timeout);
                                }
                                nvhost_debug_dump(syncpt_to_dev(sp));
-                               BUG();
                        }
                        check_count++;
                }
index 048eeb9..7625905 100644 (file)
@@ -57,6 +57,7 @@ void nvhost_syncpt_deinit(struct nvhost_syncpt *);
 #define client_managed(id) (BIT(id) & sp->client_managed)
 #define syncpt_to_dev(sp) container_of(sp, struct nvhost_master, syncpt)
 #define SYNCPT_CHECK_PERIOD (2 * HZ)
+#define MAX_STUCK_CHECK_COUNT 15
 
 /**
  * Updates the value sent to hardware.