diff options
author | Muralidharan Karicheri <m-karicheri2@ti.com> | 2009-12-10 14:47:48 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-15 21:18:34 -0500 |
commit | 31bedfa5068936b15a388842be1d03cdd1bdfb07 (patch) | |
tree | d02d9204a0ed1fe2a9eca8b7f2d1553b1d85d5a3 /drivers/media/video/videobuf-dma-contig.c | |
parent | 0d94e29459d372b6c5dda964a8b35a8d40050ca7 (diff) |
V4L/DVB (13598): videobuf_dma_contig_user_get() for non-aligned offsets
If a USERPTR address that is not aligned to page boundary is passed to the
videobuf_dma_contig_user_get() function, it saves a page aligned address to
the dma_handle. This is not correct. This issue is observed when using USERPTR
IO machism for buffer exchange.
Updates from last version:-
Adding offset for size calculation as per comment from Magnus Damm. This
ensures the last page is also included for checking if memory is
contiguous.
Signed-off-by: Muralidharan Karicheri <m-karicheri2@ti.com>
Acked-by: Magnus Damm <damm@opensource.se>
Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/videobuf-dma-contig.c')
-rw-r--r-- | drivers/media/video/videobuf-dma-contig.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/media/video/videobuf-dma-contig.c b/drivers/media/video/videobuf-dma-contig.c index d25f28461da1..22c01097e8a8 100644 --- a/drivers/media/video/videobuf-dma-contig.c +++ b/drivers/media/video/videobuf-dma-contig.c | |||
@@ -141,9 +141,11 @@ static int videobuf_dma_contig_user_get(struct videobuf_dma_contig_memory *mem, | |||
141 | struct vm_area_struct *vma; | 141 | struct vm_area_struct *vma; |
142 | unsigned long prev_pfn, this_pfn; | 142 | unsigned long prev_pfn, this_pfn; |
143 | unsigned long pages_done, user_address; | 143 | unsigned long pages_done, user_address; |
144 | unsigned int offset; | ||
144 | int ret; | 145 | int ret; |
145 | 146 | ||
146 | mem->size = PAGE_ALIGN(vb->size); | 147 | offset = vb->baddr & ~PAGE_MASK; |
148 | mem->size = PAGE_ALIGN(vb->size + offset); | ||
147 | mem->is_userptr = 0; | 149 | mem->is_userptr = 0; |
148 | ret = -EINVAL; | 150 | ret = -EINVAL; |
149 | 151 | ||
@@ -166,7 +168,7 @@ static int videobuf_dma_contig_user_get(struct videobuf_dma_contig_memory *mem, | |||
166 | break; | 168 | break; |
167 | 169 | ||
168 | if (pages_done == 0) | 170 | if (pages_done == 0) |
169 | mem->dma_handle = this_pfn << PAGE_SHIFT; | 171 | mem->dma_handle = (this_pfn << PAGE_SHIFT) + offset; |
170 | else if (this_pfn != (prev_pfn + 1)) | 172 | else if (this_pfn != (prev_pfn + 1)) |
171 | ret = -EFAULT; | 173 | ret = -EFAULT; |
172 | 174 | ||