From 4db7a1b3fa3feca59108bff6bde7f32d141a14f7 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 14 Jan 2007 09:33:24 -0200 Subject: Some fixes at stream waitqueue on vivi From: Mauro Carvalho Chehab There are several potential troubles on vivi waitqueue code: - Watchdog timer should be reset at every received frame; - Watchdog timer should be reset at the beginning of vivi_thread(); - Checks for errors when creating a newer thread with kernel_thread(); - Wake up vivi_thread() after creating it. Signed-off-by: Mauro Carvalho Chehab --- linux/drivers/media/video/vivi.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'linux/drivers') diff --git a/linux/drivers/media/video/vivi.c b/linux/drivers/media/video/vivi.c index 30f70c0a1..155c9a75a 100644 --- a/linux/drivers/media/video/vivi.c +++ b/linux/drivers/media/video/vivi.c @@ -492,11 +492,12 @@ static void vivi_thread_tick(struct vivi_dmaqueue *dma_q) /* Fill buffer */ vivi_fillbuff(dev,buf); - } - if (list_empty(&dma_q->active)) { - del_timer(&dma_q->timeout); - } else { - mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT); + + if (list_empty(&dma_q->active)) { + del_timer(&dma_q->timeout); + } else { + mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT); + } } if (bc != 1) dprintk(1,"%s: %d buffers handled (should be 1)\n",__FUNCTION__,bc); @@ -568,6 +569,8 @@ static int vivi_thread(void *data) #endif dprintk(1,"thread started\n"); + mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT); + for (;;) { vivi_sleep(dma_q); @@ -607,10 +610,18 @@ static int vivi_start_thread(struct vivi_dmaqueue *dma_q) dma_q->kthread = NULL; dma_q->notify = &sem; - kernel_thread(vivi_thread, dma_q, 0); + + if (kernel_thread(vivi_thread, dma_q, 0) < 0) { + printk (KERN_ERR "sdim: kernel_thread() failed\n"); + return -EINVAL; + } + down(&sem); dma_q->notify = NULL; #endif + /* Wakes thread */ + wake_up_interruptible(&dma_q->wq); + dprintk(1,"returning from %s\n",__FUNCTION__); return 0; } -- cgit v1.2.3