@@ -3381,7 +3381,7 @@ static void srp_add_one(struct ib_device *device)
struct srp_host *host;
int mr_page_shift, p;
u64 max_pages_per_mr;
- unsigned int mr_flags = 0;
+ bool need_phys_rkey = false;
dev_attr = kmalloc(sizeof *dev_attr, GFP_KERNEL);
if (!dev_attr)
@@ -3403,7 +3403,7 @@ static void srp_add_one(struct ib_device *device)
if (!srp_dev->has_fmr && !srp_dev->has_fr) {
dev_warn(&device->dev, "neither FMR nor FR is supported\n");
/* Fall back to using an insecure all physical rkey */
- mr_flags |= IB_ACCESS_REMOTE_READ | IB_ACCESS_REMOTE_WRITE;
+ need_phys_rkey = true;
}
srp_dev->use_fast_reg = (srp_dev->has_fr &&
@@ -3441,11 +3441,13 @@ static void srp_add_one(struct ib_device *device)
goto free_dev;
if (!register_always)
- mr_flags |= IB_ACCESS_REMOTE_READ | IB_ACCESS_REMOTE_WRITE;
+ need_phys_rkey = true;
- if (mr_flags) {
+ if (need_phys_rkey) {
srp_dev->rkey_mr = ib_get_dma_mr(
- srp_dev->pd, IB_ACCESS_LOCAL_WRITE | mr_flags);
+ srp_dev->pd, IB_ACCESS_LOCAL_WRITE |
+ IB_ACCESS_REMOTE_READ |
+ IB_ACCESS_REMOTE_WRITE);
if (IS_ERR(srp_dev->rkey_mr))
goto err_pd;
} else