History

[media] v4l: vb2-dma-contig: let mmap method to use dma_mmap_coherent call

Let mmap method to use dma_mmap_coherent call. Moreover, this patch removes vb2_mmap_pfn_range from videobuf2 helpers as it was suggested by Laurent Pinchart. The function is no longer used in vb2 code.

Marek Szyprowski committed 14 years ago

Commit c60520f1 parent 9bd09fd3 files · +26 −47Browse files

Unified · Split

3 files
  1. drivers/media/v4l2-core/videobuf2-dma-contig.c +26 −2
  2. drivers/media/v4l2-core/videobuf2-memops.c +0 −40
  3. include/media/videobuf2-memops.h +0 −5
drivers/media/v4l2-core/videobuf2-dma-contig.c+26−2
@@ -178,14 +178,38 @@ static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size) · 177 unmodified lines
178static int vb2_dc_mmap(void *buf_priv, struct vm_area_struct *vma)178static int vb2_dc_mmap(void *buf_priv, struct vm_area_struct *vma)
179{179{
180 struct vb2_dc_buf *buf = buf_priv;180 struct vb2_dc_buf *buf = buf_priv;
181 int ret;
181 182
182 if (!buf) {183 if (!buf) {
183 printk(KERN_ERR "No buffer to map\n");184 printk(KERN_ERR "No buffer to map\n");
184 return -EINVAL;185 return -EINVAL;
185 }186 }
186 187
187 return vb2_mmap_pfn_range(vma, buf->dma_addr, buf->size,188 /*
188 &vb2_common_vm_ops, &buf->handler);189 * dma_mmap_* uses vm_pgoff as in-buffer offset, but we want to
190 * map whole buffer
191 */
192 vma->vm_pgoff = 0;
193
194 ret = dma_mmap_coherent(buf->dev, vma, buf->vaddr,
195 buf->dma_addr, buf->size);
196
197 if (ret) {
198 pr_err("Remapping memory failed, error: %d\n", ret);
199 return ret;
200 }
201
202 vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
203 vma->vm_private_data = &buf->handler;
204 vma->vm_ops = &vb2_common_vm_ops;
205
206 vma->vm_ops->open(vma);
207
208 pr_debug("%s: mapped dma addr 0x%08lx at 0x%08lx, size %ld\n",
209 __func__, (unsigned long)buf->dma_addr, vma->vm_start,
210 buf->size);
211
212 return 0;
189}213}
190 214
191/*********************************************/215/*********************************************/
drivers/media/v4l2-core/videobuf2-memops.c+0−40
@@ -136,46 +136,6 @@ int vb2_get_contig_userptr(unsigned long vaddr, unsigned long size, · 135 unmodified lines
136}136}
137EXPORT_SYMBOL_GPL(vb2_get_contig_userptr);137EXPORT_SYMBOL_GPL(vb2_get_contig_userptr);
138 138
139/**
140 * vb2_mmap_pfn_range() - map physical pages to userspace
141 * @vma: virtual memory region for the mapping
142 * @paddr: starting physical address of the memory to be mapped
143 * @size: size of the memory to be mapped
144 * @vm_ops: vm operations to be assigned to the created area
145 * @priv: private data to be associated with the area
146 *
147 * Returns 0 on success.
148 */
149int vb2_mmap_pfn_range(struct vm_area_struct *vma, unsigned long paddr,
150 unsigned long size,
151 const struct vm_operations_struct *vm_ops,
152 void *priv)
153{
154 int ret;
155
156 size = min_t(unsigned long, vma->vm_end - vma->vm_start, size);
157
158 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
159 ret = remap_pfn_range(vma, vma->vm_start, paddr >> PAGE_SHIFT,
160 size, vma->vm_page_prot);
161 if (ret) {
162 printk(KERN_ERR "Remapping memory failed, error: %d\n", ret);
163 return ret;
164 }
165
166 vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
167 vma->vm_private_data = priv;
168 vma->vm_ops = vm_ops;
169
170 vma->vm_ops->open(vma);
171
172 pr_debug("%s: mapped paddr 0x%08lx at 0x%08lx, size %ld\n",
173 __func__, paddr, vma->vm_start, size);
174
175 return 0;
176}
177EXPORT_SYMBOL_GPL(vb2_mmap_pfn_range);
178
179/**139/**
180 * vb2_common_vm_open() - increase refcount of the vma140 * vb2_common_vm_open() - increase refcount of the vma
181 * @vma: virtual memory region for the mapping141 * @vma: virtual memory region for the mapping
include/media/videobuf2-memops.h+0−5
@@ -33,11 +33,6 @@ extern const struct vm_operations_struct vb2_common_vm_ops; · 32 unmodified lines
33int vb2_get_contig_userptr(unsigned long vaddr, unsigned long size,33int vb2_get_contig_userptr(unsigned long vaddr, unsigned long size,
34 struct vm_area_struct **res_vma, dma_addr_t *res_pa);34 struct vm_area_struct **res_vma, dma_addr_t *res_pa);
35 35
36int vb2_mmap_pfn_range(struct vm_area_struct *vma, unsigned long paddr,
37 unsigned long size,
38 const struct vm_operations_struct *vm_ops,
39 void *priv);
40
41struct vm_area_struct *vb2_get_vma(struct vm_area_struct *vma);36struct vm_area_struct *vb2_get_vma(struct vm_area_struct *vma);
42void vb2_put_vma(struct vm_area_struct *vma);37void vb2_put_vma(struct vm_area_struct *vma);
43 38

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t