Commit 3a781f21 authored by Jean-Paul Saman's avatar Jean-Paul Saman

davinci_vpfe: extra safety checks

parent e316b56c
...@@ -264,19 +264,19 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size) ...@@ -264,19 +264,19 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
for (i = VPFE_DEFNUM_FBUFS; i < *count; i++) for (i = VPFE_DEFNUM_FBUFS; i < *count; i++)
{ {
u32 size = PAGE_SIZE << VPFE_MAX_FBUF_ORDER; u32 bufsize = PAGE_SIZE << VPFE_MAX_FBUF_ORDER;
void *mem = (void *)__get_free_pages(GFP_KERNEL |GFP_DMA, void *mem = (void *)__get_free_pages(GFP_KERNEL |GFP_DMA,
VPFE_MAX_FBUF_ORDER); VPFE_MAX_FBUF_ORDER);
if (mem) if (mem)
{ {
unsigned long adr = (unsigned long)mem; unsigned long adr = (unsigned long)mem;
while (size > 0) while (bufsize > 0)
{ {
/* make sure the frame buffers are never /* make sure the frame buffers are never
swapped out of memory */ swapped out of memory */
SetPageReserved(virt_to_page(adr)); SetPageReserved(virt_to_page(adr));
adr += PAGE_SIZE; adr += PAGE_SIZE;
size -= PAGE_SIZE; bufsize -= PAGE_SIZE;
} }
vpfe->fbuffers[i] = mem; vpfe->fbuffers[i] = mem;
} }
...@@ -301,7 +301,7 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) ...@@ -301,7 +301,7 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
{ {
/* free the buffer if it is not one of the 3 allocated at initializaiton time */ /* free the buffer if it is not one of the 3 allocated at initialization time */
if (vb->i < vpfe_device.numbuffers if (vb->i < vpfe_device.numbuffers
&& vb->i >= VPFE_DEFNUM_FBUFS && vb->i >= VPFE_DEFNUM_FBUFS
&& vpfe_device.fbuffers[vb->i]) && vpfe_device.fbuffers[vb->i])
...@@ -969,12 +969,17 @@ static int vpfe_doioctl(struct inode *inode, struct file *file, ...@@ -969,12 +969,17 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
ret = -EINVAL; ret = -EINVAL;
break; break;
} }
flush_scheduled_work();
/* disable CCDC */ /* disable CCDC */
down_interruptible(&vpfe->lock); down_interruptible(&vpfe->lock);
ccdc_enable(FALSE); ccdc_enable(FALSE);
vpfe->io_usrs = 0;
vpfe->started = FALSE; vpfe->started = FALSE;
up(&vpfe->lock); up(&vpfe->lock);
ret = videobuf_streamoff(&vpfe->bufqueue); ret = videobuf_streamoff(&vpfe->bufqueue);
debug_print(KERN_INFO "stopped video streaming.\n");
break; break;
} }
case VPFE_CMD_CONFIG_CCDC: case VPFE_CMD_CONFIG_CCDC:
...@@ -1124,8 +1129,10 @@ static int vpfe_release(struct inode *inode, struct file *filep) ...@@ -1124,8 +1129,10 @@ static int vpfe_release(struct inode *inode, struct file *filep)
vpfe_fh *fh = filep->private_data; vpfe_fh *fh = filep->private_data;
vpfe_obj *vpfe = fh->dev; vpfe_obj *vpfe = fh->dev;
flush_scheduled_work();
down_interruptible(&vpfe->lock); down_interruptible(&vpfe->lock);
if (fh->io_allowed) if (fh->io_allowed && vpfe->started && vpfe->io_usrs != 0)
{ {
vpfe->io_usrs = 0; vpfe->io_usrs = 0;
ccdc_enable(FALSE); ccdc_enable(FALSE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment