diff options
Diffstat (limited to 'drivers/staging/rdma/hfi1/file_ops.c')
-rw-r--r-- | drivers/staging/rdma/hfi1/file_ops.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/staging/rdma/hfi1/file_ops.c b/drivers/staging/rdma/hfi1/file_ops.c index 72d38500d..aae9826ec 100644 --- a/drivers/staging/rdma/hfi1/file_ops.c +++ b/drivers/staging/rdma/hfi1/file_ops.c @@ -168,7 +168,7 @@ enum mmap_types { HFI1_MMAP_TOKEN_SET(TYPE, type) | \ HFI1_MMAP_TOKEN_SET(CTXT, ctxt) | \ HFI1_MMAP_TOKEN_SET(SUBCTXT, subctxt) | \ - HFI1_MMAP_TOKEN_SET(OFFSET, ((unsigned long)addr & ~PAGE_MASK))) + HFI1_MMAP_TOKEN_SET(OFFSET, (offset_in_page(addr)))) #define EXP_TID_SET(field, value) \ (((value) & EXP_TID_TID##field##_MASK) << \ @@ -508,7 +508,7 @@ static int hfi1_file_mmap(struct file *fp, struct vm_area_struct *vma) case PIO_BUFS_SOP: memaddr = ((dd->physaddr + TXE_PIO_SEND) + /* chip pio base */ - (uctxt->sc->hw_context * (1 << 16))) + + (uctxt->sc->hw_context * BIT(16))) + /* 64K PIO space / ctxt */ (type == PIO_BUFS_SOP ? (TXE_PIO_SIZE / 2) : 0); /* sop? */ @@ -607,9 +607,9 @@ static int hfi1_file_mmap(struct file *fp, struct vm_area_struct *vma) * Use the page where this context's flags are. User level * knows where it's own bitmap is within the page. */ - memaddr = ((unsigned long)dd->events + - ((uctxt->ctxt - dd->first_user_ctxt) * - HFI1_MAX_SHARED_CTXTS)) & PAGE_MASK; + memaddr = (unsigned long)(dd->events + + ((uctxt->ctxt - dd->first_user_ctxt) * + HFI1_MAX_SHARED_CTXTS)) & PAGE_MASK; memlen = PAGE_SIZE; /* * v3.7 removes VM_RESERVED but the effect is kept by @@ -948,6 +948,7 @@ static int find_shared_ctxt(struct file *fp, /* Skip ctxt if it doesn't match the requested one */ if (memcmp(uctxt->uuid, uinfo->uuid, sizeof(uctxt->uuid)) || + uctxt->jkey != generate_jkey(current_uid()) || uctxt->subctxt_id != uinfo->subctxt_id || uctxt->subctxt_cnt != uinfo->subctxt_cnt) continue; @@ -1335,9 +1336,9 @@ static int get_base_info(struct file *fp, void __user *ubase, __u32 len) */ binfo.user_regbase = HFI1_MMAP_TOKEN(UREGS, uctxt->ctxt, subctxt_fp(fp), 0); - offset = ((((uctxt->ctxt - dd->first_user_ctxt) * + offset = offset_in_page((((uctxt->ctxt - dd->first_user_ctxt) * HFI1_MAX_SHARED_CTXTS) + subctxt_fp(fp)) * - sizeof(*dd->events)) & ~PAGE_MASK; + sizeof(*dd->events)); binfo.events_bufbase = HFI1_MMAP_TOKEN(EVENTS, uctxt->ctxt, subctxt_fp(fp), offset); @@ -1573,7 +1574,7 @@ static int exp_tid_setup(struct file *fp, struct hfi1_tid_info *tinfo) vaddr = tinfo->vaddr; - if (vaddr & ~PAGE_MASK) { + if (offset_in_page(vaddr)) { ret = -EINVAL; goto bail; } @@ -2066,6 +2067,7 @@ static const struct file_operations ui_file_ops = { .open = ui_open, .release = ui_release, }; + #define UI_OFFSET 192 /* device minor offset for UI devices */ static int create_ui = 1; |