Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers/gpu/drm/gma500/: change return type to vm_fault_t

Use new return type vm_fault_t for fault handler. For now, this is just
documenting that the function returns a VM_FAULT value rather than an
errno. Once all instances are converted, vm_fault_t will become a
distinct type.

Ref-> 1c8f422059ae ("mm: change return type to vm_fault_t")

Previously vm_insert_{pfn,mixed} returns err which driver mapped into
VM_FAULT_* type. The new function vmf_insert_{pfn,mixed} will replace
this inefficiency by returning VM_FAULT_* type.

vmf_error() is the newly introduce inline function in 4.17-rc6.

Link: http://lkml.kernel.org/r/20180713154541.GA3345@jordon-HP-15-Notebook-PC
Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
Reviewed-by: Matthew Wilcox <mawilcox@microsoft.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Souptick Joarder and committed by
Linus Torvalds
0edf6813 038a07a5

+17 -27
+5 -9
drivers/gpu/drm/gma500/framebuffer.c
··· 108 108 return 0; 109 109 } 110 110 111 - static int psbfb_vm_fault(struct vm_fault *vmf) 111 + static vm_fault_t psbfb_vm_fault(struct vm_fault *vmf) 112 112 { 113 113 struct vm_area_struct *vma = vmf->vma; 114 114 struct psb_framebuffer *psbfb = vma->vm_private_data; ··· 118 118 int page_num; 119 119 int i; 120 120 unsigned long address; 121 - int ret; 121 + vm_fault_t ret = VM_FAULT_SIGBUS; 122 122 unsigned long pfn; 123 123 unsigned long phys_addr = (unsigned long)dev_priv->stolen_base + 124 124 gtt->offset; ··· 131 131 for (i = 0; i < page_num; i++) { 132 132 pfn = (phys_addr >> PAGE_SHIFT); 133 133 134 - ret = vm_insert_mixed(vma, address, 134 + ret = vmf_insert_mixed(vma, address, 135 135 __pfn_to_pfn_t(pfn, PFN_DEV)); 136 - if (unlikely((ret == -EBUSY) || (ret != 0 && i > 0))) 136 + if (unlikely(ret & VM_FAULT_ERROR)) 137 137 break; 138 - else if (unlikely(ret != 0)) { 139 - ret = (ret == -ENOMEM) ? VM_FAULT_OOM : VM_FAULT_SIGBUS; 140 - return ret; 141 - } 142 138 address += PAGE_SIZE; 143 139 phys_addr += PAGE_SIZE; 144 140 } 145 - return VM_FAULT_NOPAGE; 141 + return ret; 146 142 } 147 143 148 144 static void psbfb_vm_open(struct vm_area_struct *vma)
+10 -17
drivers/gpu/drm/gma500/gem.c
··· 134 134 * vma->vm_private_data points to the GEM object that is backing this 135 135 * mapping. 136 136 */ 137 - int psb_gem_fault(struct vm_fault *vmf) 137 + vm_fault_t psb_gem_fault(struct vm_fault *vmf) 138 138 { 139 139 struct vm_area_struct *vma = vmf->vma; 140 140 struct drm_gem_object *obj; 141 141 struct gtt_range *r; 142 - int ret; 142 + int err; 143 + vm_fault_t ret; 143 144 unsigned long pfn; 144 145 pgoff_t page_offset; 145 146 struct drm_device *dev; ··· 159 158 /* For now the mmap pins the object and it stays pinned. As things 160 159 stand that will do us no harm */ 161 160 if (r->mmapping == 0) { 162 - ret = psb_gtt_pin(r); 163 - if (ret < 0) { 164 - dev_err(dev->dev, "gma500: pin failed: %d\n", ret); 161 + err = psb_gtt_pin(r); 162 + if (err < 0) { 163 + dev_err(dev->dev, "gma500: pin failed: %d\n", err); 164 + ret = vmf_error(err); 165 165 goto fail; 166 166 } 167 167 r->mmapping = 1; ··· 177 175 pfn = (dev_priv->stolen_base + r->offset) >> PAGE_SHIFT; 178 176 else 179 177 pfn = page_to_pfn(r->pages[page_offset]); 180 - ret = vm_insert_pfn(vma, vmf->address, pfn); 181 - 178 + ret = vmf_insert_pfn(vma, vmf->address, pfn); 182 179 fail: 183 180 mutex_unlock(&dev_priv->mmap_mutex); 184 - switch (ret) { 185 - case 0: 186 - case -ERESTARTSYS: 187 - case -EINTR: 188 - return VM_FAULT_NOPAGE; 189 - case -ENOMEM: 190 - return VM_FAULT_OOM; 191 - default: 192 - return VM_FAULT_SIGBUS; 193 - } 181 + 182 + return ret; 194 183 }
+2 -1
drivers/gpu/drm/gma500/psb_drv.h
··· 21 21 #define _PSB_DRV_H_ 22 22 23 23 #include <linux/kref.h> 24 + #include <linux/mm_types.h> 24 25 25 26 #include <drm/drmP.h> 26 27 #include <drm/drm_global.h> ··· 750 749 struct drm_file *file); 751 750 extern int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev, 752 751 struct drm_mode_create_dumb *args); 753 - extern int psb_gem_fault(struct vm_fault *vmf); 752 + extern vm_fault_t psb_gem_fault(struct vm_fault *vmf); 754 753 755 754 /* psb_device.c */ 756 755 extern const struct psb_ops psb_chip_ops;