Skip to content

Commit

Permalink
ocxl: Change return type for fault handler
Browse files Browse the repository at this point in the history
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 1c8f422 ("mm: change return type to vm_fault_t")

There is an existing bug when vm_insert_pfn() can return ENOMEM which
was ignored and VM_FAULT_NOPAGE returned as default. The new inline
vmf_insert_pfn() has removed this inefficiency by returning correct
vm_fault_ type.

Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Acked-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
  • Loading branch information
Souptick Joarder authored and Michael Ellerman committed Jul 2, 2018
1 parent 021c917 commit a545cf0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
22 changes: 11 additions & 11 deletions drivers/misc/ocxl/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ int ocxl_context_attach(struct ocxl_context *ctx, u64 amr)
return rc;
}

static int map_afu_irq(struct vm_area_struct *vma, unsigned long address,
static vm_fault_t map_afu_irq(struct vm_area_struct *vma, unsigned long address,
u64 offset, struct ocxl_context *ctx)
{
u64 trigger_addr;
Expand All @@ -95,15 +95,15 @@ static int map_afu_irq(struct vm_area_struct *vma, unsigned long address,
if (!trigger_addr)
return VM_FAULT_SIGBUS;

vm_insert_pfn(vma, address, trigger_addr >> PAGE_SHIFT);
return VM_FAULT_NOPAGE;
return vmf_insert_pfn(vma, address, trigger_addr >> PAGE_SHIFT);
}

static int map_pp_mmio(struct vm_area_struct *vma, unsigned long address,
static vm_fault_t map_pp_mmio(struct vm_area_struct *vma, unsigned long address,
u64 offset, struct ocxl_context *ctx)
{
u64 pp_mmio_addr;
int pasid_off;
vm_fault_t ret;

if (offset >= ctx->afu->config.pp_mmio_stride)
return VM_FAULT_SIGBUS;
Expand All @@ -121,27 +121,27 @@ static int map_pp_mmio(struct vm_area_struct *vma, unsigned long address,
pasid_off * ctx->afu->config.pp_mmio_stride +
offset;

vm_insert_pfn(vma, address, pp_mmio_addr >> PAGE_SHIFT);
ret = vmf_insert_pfn(vma, address, pp_mmio_addr >> PAGE_SHIFT);
mutex_unlock(&ctx->status_mutex);
return VM_FAULT_NOPAGE;
return ret;
}

static int ocxl_mmap_fault(struct vm_fault *vmf)
static vm_fault_t ocxl_mmap_fault(struct vm_fault *vmf)
{
struct vm_area_struct *vma = vmf->vma;
struct ocxl_context *ctx = vma->vm_file->private_data;
u64 offset;
int rc;
vm_fault_t ret;

offset = vmf->pgoff << PAGE_SHIFT;
pr_debug("%s: pasid %d address 0x%lx offset 0x%llx\n", __func__,
ctx->pasid, vmf->address, offset);

if (offset < ctx->afu->irq_base_offset)
rc = map_pp_mmio(vma, vmf->address, offset, ctx);
ret = map_pp_mmio(vma, vmf->address, offset, ctx);
else
rc = map_afu_irq(vma, vmf->address, offset, ctx);
return rc;
ret = map_afu_irq(vma, vmf->address, offset, ctx);
return ret;
}

static const struct vm_operations_struct ocxl_vmops = {
Expand Down
5 changes: 2 additions & 3 deletions drivers/misc/ocxl/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static ssize_t global_mmio_read(struct file *filp, struct kobject *kobj,
return count;
}

static int global_mmio_fault(struct vm_fault *vmf)
static vm_fault_t global_mmio_fault(struct vm_fault *vmf)
{
struct vm_area_struct *vma = vmf->vma;
struct ocxl_afu *afu = vma->vm_private_data;
Expand All @@ -75,8 +75,7 @@ static int global_mmio_fault(struct vm_fault *vmf)

offset = vmf->pgoff;
offset += (afu->global_mmio_start >> PAGE_SHIFT);
vm_insert_pfn(vma, vmf->address, offset);
return VM_FAULT_NOPAGE;
return vmf_insert_pfn(vma, vmf->address, offset);
}

static const struct vm_operations_struct global_mmio_vmops = {
Expand Down

0 comments on commit a545cf0

Please sign in to comment.