Skip to content

Commit 96fb9b8

Browse files
Jack Morgensteingregkh
authored andcommitted
IB/core: Make testing MR flags for writability a static inline function
commit 08bb558 upstream. Make the MR writability flags check, which is performed in umem.c, a static inline function in file ib_verbs.h This allows the function to be used by low-level infiniband drivers. Cc: <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]> Signed-off-by: Jack Morgenstein <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1c82abc commit 96fb9b8

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

drivers/infiniband/core/umem.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
119119
umem->length = size;
120120
umem->address = addr;
121121
umem->page_shift = PAGE_SHIFT;
122-
/*
123-
* We ask for writable memory if any of the following
124-
* access flags are set. "Local write" and "remote write"
125-
* obviously require write access. "Remote atomic" can do
126-
* things like fetch and add, which will modify memory, and
127-
* "MW bind" can change permissions by binding a window.
128-
*/
129-
umem->writable = !!(access &
130-
(IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_WRITE |
131-
IB_ACCESS_REMOTE_ATOMIC | IB_ACCESS_MW_BIND));
122+
umem->writable = ib_access_writable(access);
132123

133124
if (access & IB_ACCESS_ON_DEMAND) {
134125
ret = ib_umem_odp_get(context, umem, access);

include/rdma/ib_verbs.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3558,6 +3558,20 @@ static inline int ib_check_mr_access(int flags)
35583558
return 0;
35593559
}
35603560

3561+
static inline bool ib_access_writable(int access_flags)
3562+
{
3563+
/*
3564+
* We have writable memory backing the MR if any of the following
3565+
* access flags are set. "Local write" and "remote write" obviously
3566+
* require write access. "Remote atomic" can do things like fetch and
3567+
* add, which will modify memory, and "MW bind" can change permissions
3568+
* by binding a window.
3569+
*/
3570+
return access_flags &
3571+
(IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_WRITE |
3572+
IB_ACCESS_REMOTE_ATOMIC | IB_ACCESS_MW_BIND);
3573+
}
3574+
35613575
/**
35623576
* ib_check_mr_status: lightweight check of MR status.
35633577
* This routine may provide status checks on a selected

0 commit comments

Comments
 (0)