ion: use vm_insert_pfn for faulted pages
authorColin Cross <ccross@android.com>
Sat, 14 Dec 2013 03:26:24 +0000 (19:26 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2013 16:59:53 +0000 (08:59 -0800)
Most ion userspace mappings are created with remap_pfn_range.  Use
vm_insert_pfn instead of vm_insert_page to make faulted cached
mappings look more like uncached mappings.

Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/android/ion/ion.c

index fc77aa638a9e288399dfdf5338e86d59d2cb6493..45127f5cd2f0e2256c5f7b82c8b7fcea435418d3 100644 (file)
@@ -890,14 +890,15 @@ static void ion_buffer_sync_for_device(struct ion_buffer *buffer,
 int ion_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 {
        struct ion_buffer *buffer = vma->vm_private_data;
+       unsigned long pfn;
        int ret;
 
        mutex_lock(&buffer->lock);
        ion_buffer_page_dirty(buffer->pages + vmf->pgoff);
-
        BUG_ON(!buffer->pages || !buffer->pages[vmf->pgoff]);
-       ret = vm_insert_page(vma, (unsigned long)vmf->virtual_address,
-                            ion_buffer_page(buffer->pages[vmf->pgoff]));
+
+       pfn = page_to_pfn(ion_buffer_page(buffer->pages[vmf->pgoff]));
+       ret = vm_insert_pfn(vma, (unsigned long)vmf->virtual_address, pfn);
        mutex_unlock(&buffer->lock);
        if (ret)
                return VM_FAULT_ERROR;
@@ -956,6 +957,8 @@ static int ion_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
        }
 
        if (ion_buffer_fault_user_mappings(buffer)) {
+               vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND |
+                                                       VM_DONTDUMP;
                vma->vm_private_data = buffer;
                vma->vm_ops = &ion_vma_ops;
                ion_vm_open(vma);