summaryrefslogtreecommitdiff
path: root/drivers/media/platform
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2012-07-25 12:22:07 (GMT)
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-09-26 19:51:19 (GMT)
commit2fb57f06319ec71c94d842281326aa575066f188 (patch)
tree34f21c4f399918c3d87740d51b3c27a8fb4064c7 /drivers/media/platform
parente11f3e6ef64726c64dae435f7059715adf5de2ff (diff)
downloadlinux-2fb57f06319ec71c94d842281326aa575066f188.tar.xz
[media] media: coda: stop all queues in case of lockup
Add a 1 second timeout for each PIC_RUN command to the CODA. In case it locks up, stop all queues and dequeue remaining buffers. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Tested-by: Javier Martin <javier.martin@vista-silicon.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/platform')
-rw-r--r--drivers/media/platform/coda.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
index 176741c..7a41ea1 100644
--- a/drivers/media/platform/coda.c
+++ b/drivers/media/platform/coda.c
@@ -136,6 +136,7 @@ struct coda_dev {
struct vb2_alloc_ctx *alloc_ctx;
struct list_head instances;
unsigned long instance_mask;
+ struct delayed_work timeout;
};
struct coda_params {
@@ -727,6 +728,9 @@ static void coda_device_run(void *m2m_priv)
CODA7_REG_BIT_AXI_SRAM_USE);
}
+ /* 1 second timeout in case CODA locks up */
+ schedule_delayed_work(&dev->timeout, HZ);
+
coda_command_async(ctx, CODA_COMMAND_PIC_RUN);
}
@@ -1213,6 +1217,7 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count)
static int coda_stop_streaming(struct vb2_queue *q)
{
struct coda_ctx *ctx = vb2_get_drv_priv(q);
+ struct coda_dev *dev = ctx->dev;
if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev,
@@ -1225,6 +1230,8 @@ static int coda_stop_streaming(struct vb2_queue *q)
}
if (!ctx->rawstreamon && !ctx->compstreamon) {
+ cancel_delayed_work(&dev->timeout);
+
v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev,
"%s: sent command 'SEQ_END' to coda\n", __func__);
if (coda_command_sync(ctx, CODA_COMMAND_SEQ_END)) {
@@ -1495,6 +1502,8 @@ static irqreturn_t coda_irq_handler(int irq, void *data)
u32 wr_ptr, start_ptr;
struct coda_ctx *ctx;
+ __cancel_delayed_work(&dev->timeout);
+
/* read status register to attend the IRQ */
coda_read(dev, CODA_REG_BIT_INT_STATUS);
coda_write(dev, CODA_REG_BIT_INT_CLEAR_SET,
@@ -1567,6 +1576,22 @@ static irqreturn_t coda_irq_handler(int irq, void *data)
return IRQ_HANDLED;
}
+static void coda_timeout(struct work_struct *work)
+{
+ struct coda_ctx *ctx;
+ struct coda_dev *dev = container_of(to_delayed_work(work),
+ struct coda_dev, timeout);
+
+ v4l2_err(&dev->v4l2_dev, "CODA PIC_RUN timeout, stopping all streams\n");
+
+ mutex_lock(&dev->dev_mutex);
+ list_for_each_entry(ctx, &dev->instances, list) {
+ v4l2_m2m_streamoff(NULL, ctx->m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
+ v4l2_m2m_streamoff(NULL, ctx->m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE);
+ }
+ mutex_unlock(&dev->dev_mutex);
+}
+
static u32 coda_supported_firmwares[] = {
CODA_FIRMWARE_VERNUM(CODA_DX6, 2, 2, 5),
CODA_FIRMWARE_VERNUM(CODA_7541, 13, 4, 29),
@@ -1839,6 +1864,7 @@ static int __devinit coda_probe(struct platform_device *pdev)
spin_lock_init(&dev->irqlock);
INIT_LIST_HEAD(&dev->instances);
+ INIT_DELAYED_WORK(&dev->timeout, coda_timeout);
dev->plat_dev = pdev;
dev->clk_per = devm_clk_get(&pdev->dev, "per");