IB/ipath: drop requirement that PIO buffers be mmaped write-only
[linux-drm-fsl-dcu.git] / drivers / infiniband / hw / ipath / ipath_file_ops.c
index bbaa70e57db1ebf4442e6f3cb4e6e9f4a430efe6..e999a46bef9beb72d50c352aed2fb893e6a55663 100644 (file)
@@ -985,15 +985,17 @@ static int mmap_piobufs(struct vm_area_struct *vma,
         * write combining behavior we want on the PIO buffers!
         */
 
-       if (vma->vm_flags & VM_READ) {
-               dev_info(&dd->pcidev->dev,
-                        "Can't map piobufs as readable (flags=%lx)\n",
-                        vma->vm_flags);
-               ret = -EPERM;
-               goto bail;
-       }
+#if defined(__powerpc__)
+       /* There isn't a generic way to specify writethrough mappings */
+       pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE;
+       pgprot_val(vma->vm_page_prot) |= _PAGE_WRITETHRU;
+       pgprot_val(vma->vm_page_prot) &= ~_PAGE_GUARDED;
+#endif
 
-       /* don't allow them to later change to readable with mprotect */
+       /*
+        * don't allow them to later change to readable with mprotect (for when
+        * not initially mapped readable, as is normally the case)
+        */
        vma->vm_flags &= ~VM_MAYREAD;
        vma->vm_flags |= VM_DONTCOPY | VM_DONTEXPAND;