Commit 408633d2 authored by Souptick Joarder's avatar Souptick Joarder Committed by Eric Anholt

drm/v3d: use new return type vm_fault_t in v3d_gem_fault

Instead of converting an errno into a vm_fault_t ourselves, use
vmf_insert_mixed() which returns a vm_fault_t directly.
Signed-off-by: default avatarSouptick Joarder <jrdr.linux@gmail.com>
Signed-off-by: default avatarEric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20180704145556.GA11036@jordon-HP-15-Notebook-PCReviewed-by: default avatarMatthew Wilcox <willy@infradead.org>
parent 0b7510d1
...@@ -227,37 +227,19 @@ v3d_set_mmap_vma_flags(struct vm_area_struct *vma) ...@@ -227,37 +227,19 @@ v3d_set_mmap_vma_flags(struct vm_area_struct *vma)
vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags)); vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
} }
int v3d_gem_fault(struct vm_fault *vmf) vm_fault_t v3d_gem_fault(struct vm_fault *vmf)
{ {
struct vm_area_struct *vma = vmf->vma; struct vm_area_struct *vma = vmf->vma;
struct drm_gem_object *obj = vma->vm_private_data; struct drm_gem_object *obj = vma->vm_private_data;
struct v3d_bo *bo = to_v3d_bo(obj); struct v3d_bo *bo = to_v3d_bo(obj);
unsigned long pfn; pfn_t pfn;
pgoff_t pgoff; pgoff_t pgoff;
int ret;
/* We don't use vmf->pgoff since that has the fake offset: */ /* We don't use vmf->pgoff since that has the fake offset: */
pgoff = (vmf->address - vma->vm_start) >> PAGE_SHIFT; pgoff = (vmf->address - vma->vm_start) >> PAGE_SHIFT;
pfn = page_to_pfn(bo->pages[pgoff]); pfn = __pfn_to_pfn_t(page_to_pfn(bo->pages[pgoff]), PFN_DEV);
ret = vm_insert_mixed(vma, vmf->address, __pfn_to_pfn_t(pfn, PFN_DEV)); return vmf_insert_mixed(vma, vmf->address, pfn);
switch (ret) {
case -EAGAIN:
case 0:
case -ERESTARTSYS:
case -EINTR:
case -EBUSY:
/*
* EBUSY is ok: this just means that another thread
* already did the job.
*/
return VM_FAULT_NOPAGE;
case -ENOMEM:
return VM_FAULT_OOM;
default:
return VM_FAULT_SIGBUS;
}
} }
int v3d_mmap(struct file *filp, struct vm_area_struct *vma) int v3d_mmap(struct file *filp, struct vm_area_struct *vma)
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
/* Copyright (C) 2015-2018 Broadcom */ /* Copyright (C) 2015-2018 Broadcom */
#include <linux/reservation.h> #include <linux/reservation.h>
#include <linux/mm_types.h>
#include <drm/drmP.h> #include <drm/drmP.h>
#include <drm/drm_encoder.h> #include <drm/drm_encoder.h>
#include <drm/drm_gem.h> #include <drm/drm_gem.h>
...@@ -252,7 +253,7 @@ int v3d_mmap_bo_ioctl(struct drm_device *dev, void *data, ...@@ -252,7 +253,7 @@ int v3d_mmap_bo_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv); struct drm_file *file_priv);
int v3d_get_bo_offset_ioctl(struct drm_device *dev, void *data, int v3d_get_bo_offset_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv); struct drm_file *file_priv);
int v3d_gem_fault(struct vm_fault *vmf); vm_fault_t v3d_gem_fault(struct vm_fault *vmf);
int v3d_mmap(struct file *filp, struct vm_area_struct *vma); int v3d_mmap(struct file *filp, struct vm_area_struct *vma);
struct reservation_object *v3d_prime_res_obj(struct drm_gem_object *obj); struct reservation_object *v3d_prime_res_obj(struct drm_gem_object *obj);
int v3d_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma); int v3d_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment