gpu: drm: tegra: Adding new typedef vm_fault_t
PATCH 1/1 gpu: drm: tegra: Adding new typedef 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.
Reference id -> 1c8f422059ae ("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.
--- drivers/gpu/drm/tegra/gem.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-)
drivers/gpu/drm/tegra/gem.c +2 -16
@@ -422,14 +422,13 @@ int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,return 0 ; } -static int tegra_bo_fault (struct vm_fault *vmf) +static vm_fault_t tegra_bo_fault (struct vm_fault *vmf) {struct vm_area_struct *vma = vmf->vma;struct drm_gem_object *gem = vma->vm_private_data;struct tegra_bo *bo =to_tegra_bo (gem);struct page *page;pgoff_t offset; -int err;if (!bo->pages)return VM_FAULT_SIGBUS ;
@@ -437,20 +436,7 @@ static int tegra_bo_fault(struct vm_fault *vmf) offset = (vmf->address - vma->vm_start) >>PAGE_SHIFT ; page = bo->pages[offset]; - err =vm_insert_page (vma, vmf->address, page); -switch (err) { -case -EAGAIN : -case 0 : -case -ERESTARTSYS : -case -EINTR : -case -EBUSY : -return VM_FAULT_NOPAGE ; - -case -ENOMEM : -return VM_FAULT_OOM ; - } - -return VM_FAULT_SIGBUS ; +return vmf_insert_page (vma, vmf->address, page); }const struct vm_operations_struct tegra_bo_vm_ops = {
--
1.9.1
Quoted 48 lines · Souptick Joarder
Use new return type
vm_fault_tfor fault handler. For now, this is just documenting that the function returns aVM_FAULTvalue rather than an errno. Once all instances are converted,vm_fault_twill become a distinct type.Reference id ->
1c8f422059ae("mm: change return type tovm_fault_t")Previously
vm_insert_page()returns err which driver mapped into VM_FAULT_* type. The new functionvmf_insert_page()will replace this inefficiency by returning VM_FAULT_* type.Signed-off-by Souptick Joarder <[email protected]>--- drivers/gpu/drm/tegra/gem.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-)drivers/gpu/drm/tegra/gem.c +1
-8@@ -422,14 +422,13 @@ int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,return 0 ; } -static int tegra_bo_fault (struct vm_fault *vmf) +static vm_fault_t tegra_bo_fault (struct vm_fault *vmf) {struct vm_area_struct *vma = vmf->vma;struct drm_gem_object *gem = vma->vm_private_data;struct tegra_bo *bo =to_tegra_bo (gem);struct page *page;pgoff_t offset; -int err;if (!bo->pages)return VM_FAULT_SIGBUS ;@@ -437,20 +436,7 @@ static int tegra_bo_fault(struct vm_fault *vmf) offset = (vmf->address - vma->vm_start) >>PAGE_SHIFT ; page = bo->pages[offset]; - err =vm_insert_page (vma, vmf->address, page); -switch (err) { -case -EAGAIN : -case 0 : -case -ERESTARTSYS : -case -EINTR :
drivers/gpu/drm/tegra/gem.c static int tegra_bo_fault(struct vm_fault *vmf) · line 440
Quoted 10 lines
drivers/gpu/drm/tegra/gem.c +1
-8-case -EBUSY : -return VM_FAULT_NOPAGE ; - -case -ENOMEM : -return VM_FAULT_OOM ; - } - -return VM_FAULT_SIGBUS ; +return vmf_insert_page (vma, vmf->address, page); }
This new function returns VM_FAULT_NOPAGE only for 0 and -EBUSY, whereas we used to return VM_FAULT_NOPAGE for -EAGAIN, -ERESTARTSYS and -EINTR as well. Was this previously wrong?
Thierry
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 3 lines
This new function returns
VM_FAULT_NOPAGEonly for 0 and-EBUSY, whereas we used to returnVM_FAULT_NOPAGEfor-EAGAIN,-ERESTARTSYSand-EINTRas well.
Previously vm_insert_page unable to return VM_FAULT_ type due to which different drivers
have their own mapping from err to VM_FAULT_ type. With new vmf_insert_page() introduce
in 4.17-rc1 we have a common mapping for err to VM_FAULT_ which remain same for everydrivers/file systems.
Was this previously wrong?
I think Matthew is the right person to answer this.
Quoted 16 lines · Thierry Reding
Quoted 16 lines
drivers/gpu/drm/tegra/gem.c +0
-12@@ -437,20 +436,7 @@ static int tegra_bo_fault(struct vm_fault *vmf) offset = (vmf->address - vma->vm_start) >>PAGE_SHIFT ; page = bo->pages[offset]; - err =vm_insert_page (vma, vmf->address, page); -switch (err) { -case -EAGAIN : -case 0 : -case -ERESTARTSYS : -case -EINTR : -case -EBUSY : -return VM_FAULT_NOPAGE ; - -case -ENOMEM : -return VM_FAULT_OOM ; - }
Quoted 8 lines
drivers/gpu/drm/tegra/gem.c static int tegra_bo_fault(struct vm_fault *vmf) · line 440
Quoted 4 lines
drivers/gpu/drm/tegra/gem.c +1
-2- -return VM_FAULT_SIGBUS ; +return vmf_insert_page (vma, vmf->address, page); }This new function returns
VM_FAULT_NOPAGEonly for 0 and-EBUSY, whereas we used to returnVM_FAULT_NOPAGEfor-EAGAIN,-ERESTARTSYSand-EINTRas well. Was this previously wrong?
Not so much wrong as unnecessary. vm_insert_page() can't return -EAGAIN, -ERESTARTSYS or -EINTR.
Quoted 26 lines · Matthew Wilcox
Quoted 16 lines · Thierry Reding
Quoted 16 lines
drivers/gpu/drm/tegra/gem.c +0
-12@@ -437,20 +436,7 @@ static int tegra_bo_fault(struct vm_fault *vmf) offset = (vmf->address - vma->vm_start) >>PAGE_SHIFT ; page = bo->pages[offset]; - err =vm_insert_page (vma, vmf->address, page); -switch (err) { -case -EAGAIN : -case 0 : -case -ERESTARTSYS : -case -EINTR : -case -EBUSY : -return VM_FAULT_NOPAGE ; - -case -ENOMEM : -return VM_FAULT_OOM ; - }Quoted 8 lines
drivers/gpu/drm/tegra/gem.c static int tegra_bo_fault(struct vm_fault *vmf) · line 440
Quoted 4 lines
drivers/gpu/drm/tegra/gem.c +1
-2- -return VM_FAULT_SIGBUS ; +return vmf_insert_page (vma, vmf->address, page); }This new function returns
VM_FAULT_NOPAGEonly for 0 and-EBUSY, whereas we used to returnVM_FAULT_NOPAGEfor-EAGAIN,-ERESTARTSYSand-EINTRas well. Was this previously wrong?
Quoted 2 lines
Not so much wrong as unnecessary.
vm_insert_page()can't return-EAGAIN,-ERESTARTSYSor-EINTR.
If no further comment on this patch, We would like to get this patch queued for 4.18.
Thierry Reding
AppliedQuoted 13 lines · Souptick Joarder
Use new return type
vm_fault_tfor fault handler. For now, this is just documenting that the function returns aVM_FAULTvalue rather than an errno. Once all instances are converted,vm_fault_twill become a distinct type.Reference id ->
1c8f422059ae("mm: change return type tovm_fault_t")Previously
vm_insert_page()returns err which driver mapped into VM_FAULT_* type. The new functionvmf_insert_page()will replace this inefficiency by returning VM_FAULT_* type.
Quoted 4 lines
Signed-off-by Souptick Joarder <[email protected]>--- drivers/gpu/drm/tegra/gem.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-)
Applied, thanks.
Thierry