Skip to content

Commit 08bb558

Browse files
Jack Morgensteinjgunthorpe
authored andcommitted
IB/core: Make testing MR flags for writability a static inline function
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]>
1 parent 55ba49c commit 08bb558

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
@@ -3734,6 +3734,20 @@ static inline int ib_check_mr_access(int flags)
37343734
return 0;
37353735
}
37363736

3737+
static inline bool ib_access_writable(int access_flags)
3738+
{
3739+
/*
3740+
* We have writable memory backing the MR if any of the following
3741+
* access flags are set. "Local write" and "remote write" obviously
3742+
* require write access. "Remote atomic" can do things like fetch and
3743+
* add, which will modify memory, and "MW bind" can change permissions
3744+
* by binding a window.
3745+
*/
3746+
return access_flags &
3747+
(IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_WRITE |
3748+
IB_ACCESS_REMOTE_ATOMIC | IB_ACCESS_MW_BIND);
3749+
}
3750+
37373751
/**
37383752
* ib_check_mr_status: lightweight check of MR status.
37393753
* This routine may provide status checks on a selected

0 commit comments

Comments
 (0)