drm/etnaviv: 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- commit 1c8f422059
("mm: change return type to vm_fault_t")
Previously vm_insert_page() returns err which driver
mapped into VM_FAULT_* type. The new function
vmf_insert_page() will replace this inefficiency by
returning VM_FAULT_* type.
vmf_error() is the newly introduce inline function
in 4.17-rc6.
Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
Reviewed-by: Matthew Wilcox <mawilcox@microsoft.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
This commit is contained in:
parent
a0780bb1df
commit
cfad05a24d
2 changed files with 11 additions and 29 deletions
|
@ -18,6 +18,7 @@
|
|||
#include <linux/time64.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/sizes.h>
|
||||
#include <linux/mm_types.h>
|
||||
|
||||
#include <drm/drmP.h>
|
||||
#include <drm/drm_crtc_helper.h>
|
||||
|
@ -53,7 +54,7 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
|
|||
struct drm_file *file);
|
||||
|
||||
int etnaviv_gem_mmap(struct file *filp, struct vm_area_struct *vma);
|
||||
int etnaviv_gem_fault(struct vm_fault *vmf);
|
||||
vm_fault_t etnaviv_gem_fault(struct vm_fault *vmf);
|
||||
int etnaviv_gem_mmap_offset(struct drm_gem_object *obj, u64 *offset);
|
||||
struct sg_table *etnaviv_gem_prime_get_sg_table(struct drm_gem_object *obj);
|
||||
void *etnaviv_gem_prime_vmap(struct drm_gem_object *obj);
|
||||
|
|
|
@ -169,31 +169,30 @@ int etnaviv_gem_mmap(struct file *filp, struct vm_area_struct *vma)
|
|||
return obj->ops->mmap(obj, vma);
|
||||
}
|
||||
|
||||
int etnaviv_gem_fault(struct vm_fault *vmf)
|
||||
vm_fault_t etnaviv_gem_fault(struct vm_fault *vmf)
|
||||
{
|
||||
struct vm_area_struct *vma = vmf->vma;
|
||||
struct drm_gem_object *obj = vma->vm_private_data;
|
||||
struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj);
|
||||
struct page **pages, *page;
|
||||
pgoff_t pgoff;
|
||||
int ret;
|
||||
int err;
|
||||
|
||||
/*
|
||||
* Make sure we don't parallel update on a fault, nor move or remove
|
||||
* something from beneath our feet. Note that vm_insert_page() is
|
||||
* something from beneath our feet. Note that vmf_insert_page() is
|
||||
* specifically coded to take care of this, so we don't have to.
|
||||
*/
|
||||
ret = mutex_lock_interruptible(&etnaviv_obj->lock);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
err = mutex_lock_interruptible(&etnaviv_obj->lock);
|
||||
if (err)
|
||||
return VM_FAULT_NOPAGE;
|
||||
/* make sure we have pages attached now */
|
||||
pages = etnaviv_gem_get_pages(etnaviv_obj);
|
||||
mutex_unlock(&etnaviv_obj->lock);
|
||||
|
||||
if (IS_ERR(pages)) {
|
||||
ret = PTR_ERR(pages);
|
||||
goto out;
|
||||
err = PTR_ERR(pages);
|
||||
return vmf_error(err);
|
||||
}
|
||||
|
||||
/* We don't use vmf->pgoff since that has the fake offset: */
|
||||
|
@ -204,25 +203,7 @@ int etnaviv_gem_fault(struct vm_fault *vmf)
|
|||
VERB("Inserting %p pfn %lx, pa %lx", (void *)vmf->address,
|
||||
page_to_pfn(page), page_to_pfn(page) << PAGE_SHIFT);
|
||||
|
||||
ret = vm_insert_page(vma, vmf->address, page);
|
||||
|
||||
out:
|
||||
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;
|
||||
}
|
||||
return vmf_insert_page(vma, vmf->address, page);
|
||||
}
|
||||
|
||||
int etnaviv_gem_mmap_offset(struct drm_gem_object *obj, u64 *offset)
|
||||
|
|
Loading…
Reference in a new issue