diff options
author | Philipp Zabel <p.zabel@pengutronix.de> | 2012-07-25 08:22:07 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-09-26 15:51:19 -0400 |
commit | 2fb57f06319ec71c94d842281326aa575066f188 (patch) | |
tree | 34f21c4f399918c3d87740d51b3c27a8fb4064c7 /drivers/media/platform | |
parent | e11f3e6ef64726c64dae435f7059715adf5de2ff (diff) |
[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.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index 176741c3941c..7a41ea1bec34 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c | |||
@@ -136,6 +136,7 @@ struct coda_dev { | |||
136 | struct vb2_alloc_ctx *alloc_ctx; | 136 | struct vb2_alloc_ctx *alloc_ctx; |
137 | struct list_head instances; | 137 | struct list_head instances; |
138 | unsigned long instance_mask; | 138 | unsigned long instance_mask; |
139 | struct delayed_work timeout; | ||
139 | }; | 140 | }; |
140 | 141 | ||
141 | struct coda_params { | 142 | struct coda_params { |
@@ -727,6 +728,9 @@ static void coda_device_run(void *m2m_priv) | |||
727 | CODA7_REG_BIT_AXI_SRAM_USE); | 728 | CODA7_REG_BIT_AXI_SRAM_USE); |
728 | } | 729 | } |
729 | 730 | ||
731 | /* 1 second timeout in case CODA locks up */ | ||
732 | schedule_delayed_work(&dev->timeout, HZ); | ||
733 | |||
730 | coda_command_async(ctx, CODA_COMMAND_PIC_RUN); | 734 | coda_command_async(ctx, CODA_COMMAND_PIC_RUN); |
731 | } | 735 | } |
732 | 736 | ||
@@ -1213,6 +1217,7 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count) | |||
1213 | static int coda_stop_streaming(struct vb2_queue *q) | 1217 | static int coda_stop_streaming(struct vb2_queue *q) |
1214 | { | 1218 | { |
1215 | struct coda_ctx *ctx = vb2_get_drv_priv(q); | 1219 | struct coda_ctx *ctx = vb2_get_drv_priv(q); |
1220 | struct coda_dev *dev = ctx->dev; | ||
1216 | 1221 | ||
1217 | if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { | 1222 | if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { |
1218 | v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, | 1223 | v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, |
@@ -1225,6 +1230,8 @@ static int coda_stop_streaming(struct vb2_queue *q) | |||
1225 | } | 1230 | } |
1226 | 1231 | ||
1227 | if (!ctx->rawstreamon && !ctx->compstreamon) { | 1232 | if (!ctx->rawstreamon && !ctx->compstreamon) { |
1233 | cancel_delayed_work(&dev->timeout); | ||
1234 | |||
1228 | v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, | 1235 | v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, |
1229 | "%s: sent command 'SEQ_END' to coda\n", __func__); | 1236 | "%s: sent command 'SEQ_END' to coda\n", __func__); |
1230 | if (coda_command_sync(ctx, CODA_COMMAND_SEQ_END)) { | 1237 | if (coda_command_sync(ctx, CODA_COMMAND_SEQ_END)) { |
@@ -1495,6 +1502,8 @@ static irqreturn_t coda_irq_handler(int irq, void *data) | |||
1495 | u32 wr_ptr, start_ptr; | 1502 | u32 wr_ptr, start_ptr; |
1496 | struct coda_ctx *ctx; | 1503 | struct coda_ctx *ctx; |
1497 | 1504 | ||
1505 | __cancel_delayed_work(&dev->timeout); | ||
1506 | |||
1498 | /* read status register to attend the IRQ */ | 1507 | /* read status register to attend the IRQ */ |
1499 | coda_read(dev, CODA_REG_BIT_INT_STATUS); | 1508 | coda_read(dev, CODA_REG_BIT_INT_STATUS); |
1500 | coda_write(dev, CODA_REG_BIT_INT_CLEAR_SET, | 1509 | coda_write(dev, CODA_REG_BIT_INT_CLEAR_SET, |
@@ -1567,6 +1576,22 @@ static irqreturn_t coda_irq_handler(int irq, void *data) | |||
1567 | return IRQ_HANDLED; | 1576 | return IRQ_HANDLED; |
1568 | } | 1577 | } |
1569 | 1578 | ||
1579 | static void coda_timeout(struct work_struct *work) | ||
1580 | { | ||
1581 | struct coda_ctx *ctx; | ||
1582 | struct coda_dev *dev = container_of(to_delayed_work(work), | ||
1583 | struct coda_dev, timeout); | ||
1584 | |||
1585 | v4l2_err(&dev->v4l2_dev, "CODA PIC_RUN timeout, stopping all streams\n"); | ||
1586 | |||
1587 | mutex_lock(&dev->dev_mutex); | ||
1588 | list_for_each_entry(ctx, &dev->instances, list) { | ||
1589 | v4l2_m2m_streamoff(NULL, ctx->m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); | ||
1590 | v4l2_m2m_streamoff(NULL, ctx->m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); | ||
1591 | } | ||
1592 | mutex_unlock(&dev->dev_mutex); | ||
1593 | } | ||
1594 | |||
1570 | static u32 coda_supported_firmwares[] = { | 1595 | static u32 coda_supported_firmwares[] = { |
1571 | CODA_FIRMWARE_VERNUM(CODA_DX6, 2, 2, 5), | 1596 | CODA_FIRMWARE_VERNUM(CODA_DX6, 2, 2, 5), |
1572 | CODA_FIRMWARE_VERNUM(CODA_7541, 13, 4, 29), | 1597 | CODA_FIRMWARE_VERNUM(CODA_7541, 13, 4, 29), |
@@ -1839,6 +1864,7 @@ static int __devinit coda_probe(struct platform_device *pdev) | |||
1839 | 1864 | ||
1840 | spin_lock_init(&dev->irqlock); | 1865 | spin_lock_init(&dev->irqlock); |
1841 | INIT_LIST_HEAD(&dev->instances); | 1866 | INIT_LIST_HEAD(&dev->instances); |
1867 | INIT_DELAYED_WORK(&dev->timeout, coda_timeout); | ||
1842 | 1868 | ||
1843 | dev->plat_dev = pdev; | 1869 | dev->plat_dev = pdev; |
1844 | dev->clk_per = devm_clk_get(&pdev->dev, "per"); | 1870 | dev->clk_per = devm_clk_get(&pdev->dev, "per"); |