Skip to contentSkip to conversation

misc: cxl: Change return type to vm_fault_t

PATCH Superseded Souptick Joarder 3 participants 3 messages Apr 17, 2018 – May 11, 2018 Char and misc drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 misc: cxl: 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.

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

previously cxl_mmap_fault returns VM_FAULT_NOPAGE as default value irrespective of vm_insert_pfn() return value. This bug is fixed with new vmf_insert_pfn() which will return VM_FAULT_ type based on err.

---
 drivers/misc/cxl/context.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/misc/cxl/context.c +4 -3
index 7ff315a..c6ec872 100644
@@ -128,11 +128,12 @@ void cxl_context_set_mapping(struct cxl_context *ctx,
 	mutex_unlock(&ctx->mapping_lock);
 }
 
-static int cxl_mmap_fault(struct vm_fault *vmf)
+static vm_fault_t cxl_mmap_fault(struct vm_fault *vmf)
 {
 	struct vm_area_struct *vma = vmf->vma;
 	struct cxl_context *ctx = vma->vm_file->private_data;
 	u64 area, offset;
+	vm_fault_t ret;
 
 	offset = vmf->pgoff << PAGE_SHIFT;
 
@@ -169,11 +170,11 @@ static int cxl_mmap_fault(struct vm_fault *vmf)
 		return VM_FAULT_SIGBUS;
 	}
 
-	vm_insert_pfn(vma, vmf->address, (area + offset) >> PAGE_SHIFT);
+	ret = vmf_insert_pfn(vma, vmf->address, (area + offset) >> PAGE_SHIFT);
 
 	mutex_unlock(&ctx->status_mutex);
 
-	return VM_FAULT_NOPAGE;
+	return ret;
 }
 
 static const struct vm_operations_struct cxl_mmap_vmops = {

--
1.9.1

Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Souptick Joarder

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")

Quoted 6 lines

previously cxl_mmap_fault returns VM_FAULT_NOPAGE as default value irrespective of vm_insert_pfn() return value. This bug is fixed with new vmf_insert_pfn() which will return VM_FAULT_ type based on err.

This looks good to me

Signature · 2 lines
Andrew Donnellan              OzLabs, ADL Canberra
[email protected]  IBM Australia Limited
Acked-by on v1 1/1
#2 lore raw
In reply to Souptick Joarder

Le 17/04/2018 à 16:53, Souptick Joarder a écrit :

Quoted 8 lines

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")

Quoted 7 lines

previously cxl_mmap_fault returns VM_FAULT_NOPAGE as default value irrespective of vm_insert_pfn() return value. This bug is fixed with new vmf_insert_pfn() which will return VM_FAULT_ type based on err.

---

It looks ok, and it passed some basic testing.

Fred

Quoted 38 lines
  drivers/misc/cxl/context.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
drivers/misc/cxl/context.c +4 -4
index 7ff315a..c6ec872 100644
@@ -128,11 +128,12 @@ void cxl_context_set_mapping(struct cxl_context *ctx,
  	mutex_unlock(&ctx->mapping_lock);
  }
 
-static int cxl_mmap_fault(struct vm_fault *vmf)
+static vm_fault_t cxl_mmap_fault(struct vm_fault *vmf)
  {
  	struct vm_area_struct *vma = vmf->vma;
  	struct cxl_context *ctx = vma->vm_file->private_data;
  	u64 area, offset;
+	vm_fault_t ret;
 
  	offset = vmf->pgoff << PAGE_SHIFT;
 
@@ -169,11 +170,11 @@ static int cxl_mmap_fault(struct vm_fault *vmf)
  		return VM_FAULT_SIGBUS;
  	}
 
-	vm_insert_pfn(vma, vmf->address, (area + offset) >> PAGE_SHIFT);
+	ret = vmf_insert_pfn(vma, vmf->address, (area + offset) >> PAGE_SHIFT);
 
  	mutex_unlock(&ctx->status_mutex);
 
-	return VM_FAULT_NOPAGE;
+	return ret;
  }
 
  static const struct vm_operations_struct cxl_mmap_vmops = {
--

1.9.1