aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2015-08-03 13:03:20 -0400
committerAnna Schumaker <Anna.Schumaker@Netapp.com>2015-08-05 16:21:26 -0400
commite531dcabec8dc2ee141aab01ddf20ca87c52d916 (patch)
tree2f8a96a351564e5bb09b3eeb2bd67f71981cc60f
parentd23109302390d61d83675a86453674446eccb776 (diff)
xprtrdma: Remove last ib_reg_phys_mr() call site
All HCA providers have an ib_get_dma_mr() verb. Thus rpcrdma_ia_open() will either grab the device's local_dma_key if one is available, or it will call ib_get_dma_mr(). If ib_get_dma_mr() fails, rpcrdma_ia_open() fails and no transport is created. Therefore execution never reaches the ib_reg_phys_mr() call site in rpcrdma_register_internal(), so it can be removed. The remaining logic in rpcrdma_{de}register_internal() is folded into rpcrdma_{alloc,free}_regbuf(). This is clean up only. No behavior change is expected. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Reviewed-by: Devesh Sharma <devesh.sharma@avagotech.com> Reviewed-By: Sagi Grimberg <sagig@mellanox.com> Tested-by: Devesh Sharma <devesh.sharma@avagotech.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
-rw-r--r--net/sunrpc/xprtrdma/verbs.c102
-rw-r--r--net/sunrpc/xprtrdma/xprt_rdma.h1
2 files changed, 21 insertions, 82 deletions
diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
index 1065808d25b4..da184f98fdf9 100644
--- a/net/sunrpc/xprtrdma/verbs.c
+++ b/net/sunrpc/xprtrdma/verbs.c
@@ -1229,75 +1229,6 @@ rpcrdma_mapping_error(struct rpcrdma_mr_seg *seg)
1229 (unsigned long long)seg->mr_dma, seg->mr_dmalen); 1229 (unsigned long long)seg->mr_dma, seg->mr_dmalen);
1230} 1230}
1231 1231
1232static int
1233rpcrdma_register_internal(struct rpcrdma_ia *ia, void *va, int len,
1234 struct ib_mr **mrp, struct ib_sge *iov)
1235{
1236 struct ib_phys_buf ipb;
1237 struct ib_mr *mr;
1238 int rc;
1239
1240 /*
1241 * All memory passed here was kmalloc'ed, therefore phys-contiguous.
1242 */
1243 iov->addr = ib_dma_map_single(ia->ri_device,
1244 va, len, DMA_BIDIRECTIONAL);
1245 if (ib_dma_mapping_error(ia->ri_device, iov->addr))
1246 return -ENOMEM;
1247
1248 iov->length = len;
1249
1250 if (ia->ri_have_dma_lkey) {
1251 *mrp = NULL;
1252 iov->lkey = ia->ri_dma_lkey;
1253 return 0;
1254 } else if (ia->ri_bind_mem != NULL) {
1255 *mrp = NULL;
1256 iov->lkey = ia->ri_bind_mem->lkey;
1257 return 0;
1258 }
1259
1260 ipb.addr = iov->addr;
1261 ipb.size = iov->length;
1262 mr = ib_reg_phys_mr(ia->ri_pd, &ipb, 1,
1263 IB_ACCESS_LOCAL_WRITE, &iov->addr);
1264
1265 dprintk("RPC: %s: phys convert: 0x%llx "
1266 "registered 0x%llx length %d\n",
1267 __func__, (unsigned long long)ipb.addr,
1268 (unsigned long long)iov->addr, len);
1269
1270 if (IS_ERR(mr)) {
1271 *mrp = NULL;
1272 rc = PTR_ERR(mr);
1273 dprintk("RPC: %s: failed with %i\n", __func__, rc);
1274 } else {
1275 *mrp = mr;
1276 iov->lkey = mr->lkey;
1277 rc = 0;
1278 }
1279
1280 return rc;
1281}
1282
1283static int
1284rpcrdma_deregister_internal(struct rpcrdma_ia *ia,
1285 struct ib_mr *mr, struct ib_sge *iov)
1286{
1287 int rc;
1288
1289 ib_dma_unmap_single(ia->ri_device,
1290 iov->addr, iov->length, DMA_BIDIRECTIONAL);
1291
1292 if (NULL == mr)
1293 return 0;
1294
1295 rc = ib_dereg_mr(mr);
1296 if (rc)
1297 dprintk("RPC: %s: ib_dereg_mr failed %i\n", __func__, rc);
1298 return rc;
1299}
1300
1301/** 1232/**
1302 * rpcrdma_alloc_regbuf - kmalloc and register memory for SEND/RECV buffers 1233 * rpcrdma_alloc_regbuf - kmalloc and register memory for SEND/RECV buffers
1303 * @ia: controlling rpcrdma_ia 1234 * @ia: controlling rpcrdma_ia
@@ -1317,26 +1248,30 @@ struct rpcrdma_regbuf *
1317rpcrdma_alloc_regbuf(struct rpcrdma_ia *ia, size_t size, gfp_t flags) 1248rpcrdma_alloc_regbuf(struct rpcrdma_ia *ia, size_t size, gfp_t flags)
1318{ 1249{
1319 struct rpcrdma_regbuf *rb; 1250 struct rpcrdma_regbuf *rb;
1320 int rc; 1251 struct ib_sge *iov;
1321 1252
1322 rc = -ENOMEM;
1323 rb = kmalloc(sizeof(*rb) + size, flags); 1253 rb = kmalloc(sizeof(*rb) + size, flags);
1324 if (rb == NULL) 1254 if (rb == NULL)
1325 goto out; 1255 goto out;
1326 1256
1327 rb->rg_size = size; 1257 iov = &rb->rg_iov;
1328 rb->rg_owner = NULL; 1258 iov->addr = ib_dma_map_single(ia->ri_device,
1329 rc = rpcrdma_register_internal(ia, rb->rg_base, size, 1259 (void *)rb->rg_base, size,
1330 &rb->rg_mr, &rb->rg_iov); 1260 DMA_BIDIRECTIONAL);
1331 if (rc) 1261 if (ib_dma_mapping_error(ia->ri_device, iov->addr))
1332 goto out_free; 1262 goto out_free;
1333 1263
1264 iov->length = size;
1265 iov->lkey = ia->ri_have_dma_lkey ?
1266 ia->ri_dma_lkey : ia->ri_bind_mem->lkey;
1267 rb->rg_size = size;
1268 rb->rg_owner = NULL;
1334 return rb; 1269 return rb;
1335 1270
1336out_free: 1271out_free:
1337 kfree(rb); 1272 kfree(rb);
1338out: 1273out:
1339 return ERR_PTR(rc); 1274 return ERR_PTR(-ENOMEM);
1340} 1275}
1341 1276
1342/** 1277/**
@@ -1347,10 +1282,15 @@ out:
1347void 1282void
1348rpcrdma_free_regbuf(struct rpcrdma_ia *ia, struct rpcrdma_regbuf *rb) 1283rpcrdma_free_regbuf(struct rpcrdma_ia *ia, struct rpcrdma_regbuf *rb)
1349{ 1284{
1350 if (rb) { 1285 struct ib_sge *iov;
1351 rpcrdma_deregister_internal(ia, rb->rg_mr, &rb->rg_iov); 1286
1352 kfree(rb); 1287 if (!rb)
1353 } 1288 return;
1289
1290 iov = &rb->rg_iov;
1291 ib_dma_unmap_single(ia->ri_device,
1292 iov->addr, iov->length, DMA_BIDIRECTIONAL);
1293 kfree(rb);
1354} 1294}
1355 1295
1356/* 1296/*
diff --git a/net/sunrpc/xprtrdma/xprt_rdma.h b/net/sunrpc/xprtrdma/xprt_rdma.h
index abee4728f885..ce4e79e4cf1d 100644
--- a/net/sunrpc/xprtrdma/xprt_rdma.h
+++ b/net/sunrpc/xprtrdma/xprt_rdma.h
@@ -119,7 +119,6 @@ struct rpcrdma_ep {
119struct rpcrdma_regbuf { 119struct rpcrdma_regbuf {
120 size_t rg_size; 120 size_t rg_size;
121 struct rpcrdma_req *rg_owner; 121 struct rpcrdma_req *rg_owner;
122 struct ib_mr *rg_mr;
123 struct ib_sge rg_iov; 122 struct ib_sge rg_iov;
124 __be32 rg_base[0] __attribute__ ((aligned(256))); 123 __be32 rg_base[0] __attribute__ ((aligned(256)));
125}; 124};