summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/vivi.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2007-12-13 17:13:37 -0200
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-12-13 17:13:37 -0200
commit73496c4df0fd7d4a818bccfcd1f99fdd0958d82e (patch)
tree4b24a3dfae8f0035862beb7e92441a11b049d0d2 /linux/drivers/media/video/vivi.c
parent96670291ffbd33cc0cd84ab417e0bb77678bb482 (diff)
downloadmediapointer-dvb-s2-73496c4df0fd7d4a818bccfcd1f99fdd0958d82e.tar.gz
mediapointer-dvb-s2-73496c4df0fd7d4a818bccfcd1f99fdd0958d82e.tar.bz2
Add proper locking for buffer filling
From: Mauro Carvalho Chehab <mchehab@infradead.org> Avoids de-alocating buffers before finishing to fill a buffer Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'linux/drivers/media/video/vivi.c')
-rw-r--r--linux/drivers/media/video/vivi.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/linux/drivers/media/video/vivi.c b/linux/drivers/media/video/vivi.c
index 7a38637ec..66826c0f1 100644
--- a/linux/drivers/media/video/vivi.c
+++ b/linux/drivers/media/video/vivi.c
@@ -180,6 +180,7 @@ struct vivi_dev {
#else
struct semaphore lock;
#endif
+ spinlock_t slock;
int users;
@@ -405,6 +406,7 @@ static void vivi_thread_tick(struct vivi_dmaqueue *dma_q)
int bc;
+ spin_lock(&dev->slock);
/* Announces videobuf that all went ok */
for (bc = 0;; bc++) {
if (list_empty(&dma_q->active)) {
@@ -418,6 +420,7 @@ static void vivi_thread_tick(struct vivi_dmaqueue *dma_q)
/* Nobody is waiting something to be done, just return */
if (!waitqueue_active(&buf->vb.done)) {
mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT);
+ spin_unlock(&dev->slock);
return;
}
@@ -436,6 +439,7 @@ static void vivi_thread_tick(struct vivi_dmaqueue *dma_q)
if (bc != 1)
dprintk(dev, 1, "%s: %d buffers handled (should be 1)\n",
__FUNCTION__, bc);
+ spin_unlock(&dev->slock);
}
static void vivi_sleep(struct vivi_dmaqueue *dma_q)
@@ -664,6 +668,8 @@ static void vivi_vid_timeout(unsigned long data)
struct vivi_dmaqueue *vidq = &dev->vidq;
struct vivi_buffer *buf;
+ spin_lock(&dev->slock);
+
while (!list_empty(&vidq->active)) {
buf = list_entry(vidq->active.next,
struct vivi_buffer, vb.queue);
@@ -672,8 +678,9 @@ static void vivi_vid_timeout(unsigned long data)
wake_up(&buf->vb.done);
printk(KERN_INFO "vivi/0: [%p/%d] timeout\n", buf, buf->vb.i);
}
-
restart_video_queue(vidq);
+
+ spin_unlock(&dev->slock);
}
/* ------------------------------------------------------------------
@@ -1137,7 +1144,7 @@ found:
dev->h, dev->m, dev->s, (dev->us + 500) / 1000);
videobuf_queue_vmalloc_init(&fh->vb_vidq, &vivi_video_qops,
- NULL, NULL, fh->type, V4L2_FIELD_INTERLACED,
+ NULL, &dev->slock, fh->type, V4L2_FIELD_INTERLACED,
sizeof(struct vivi_buffer), fh);
return 0;
@@ -1297,6 +1304,7 @@ static int __init vivi_init(void)
/* initialize locks */
mutex_init(&dev->lock);
+ spin_lock_init(&dev->slock);
dev->vidq.timeout.function = vivi_vid_timeout;
dev->vidq.timeout.data = (unsigned long)dev;