Skip to content

Commit 318d311

Browse files
Sagi Grimbergdledford
authored andcommitted
iser: Accept arbitrary sg lists mapping if the device supports it
If the device support arbitrary sg list mapping (device cap IB_DEVICE_SG_GAPS_REG set) we allocate the memory regions with IB_MR_TYPE_SG_GAPS and allow the block layer to pass us gaps by skip setting the queue virt_boundary. Signed-off-by: Sagi Grimberg <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent b005d31 commit 318d311

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

drivers/infiniband/ulp/iser/iscsi_iser.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,16 @@ static umode_t iser_attr_is_visible(int param_type, int param)
969969

970970
static int iscsi_iser_slave_alloc(struct scsi_device *sdev)
971971
{
972-
blk_queue_virt_boundary(sdev->request_queue, ~MASK_4K);
972+
struct iscsi_session *session;
973+
struct iser_conn *iser_conn;
974+
struct ib_device *ib_dev;
975+
976+
session = starget_to_session(scsi_target(sdev))->dd_data;
977+
iser_conn = session->leadconn->dd_data;
978+
ib_dev = iser_conn->ib_conn.device->ib_device;
979+
980+
if (!(ib_dev->attrs.device_cap_flags & IB_DEVICE_SG_GAPS_REG))
981+
blk_queue_virt_boundary(sdev->request_queue, ~MASK_4K);
973982

974983
return 0;
975984
}

drivers/infiniband/ulp/iser/iser_verbs.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,21 @@ void iser_free_fmr_pool(struct ib_conn *ib_conn)
252252
}
253253

254254
static int
255-
iser_alloc_reg_res(struct ib_device *ib_device,
255+
iser_alloc_reg_res(struct iser_device *device,
256256
struct ib_pd *pd,
257257
struct iser_reg_resources *res,
258258
unsigned int size)
259259
{
260+
struct ib_device *ib_dev = device->ib_device;
261+
enum ib_mr_type mr_type;
260262
int ret;
261263

262-
res->mr = ib_alloc_mr(pd, IB_MR_TYPE_MEM_REG, size);
264+
if (ib_dev->attrs.device_cap_flags & IB_DEVICE_SG_GAPS_REG)
265+
mr_type = IB_MR_TYPE_SG_GAPS;
266+
else
267+
mr_type = IB_MR_TYPE_MEM_REG;
268+
269+
res->mr = ib_alloc_mr(pd, mr_type, size);
263270
if (IS_ERR(res->mr)) {
264271
ret = PTR_ERR(res->mr);
265272
iser_err("Failed to allocate ib_fast_reg_mr err=%d\n", ret);
@@ -277,7 +284,7 @@ iser_free_reg_res(struct iser_reg_resources *rsc)
277284
}
278285

279286
static int
280-
iser_alloc_pi_ctx(struct ib_device *ib_device,
287+
iser_alloc_pi_ctx(struct iser_device *device,
281288
struct ib_pd *pd,
282289
struct iser_fr_desc *desc,
283290
unsigned int size)
@@ -291,7 +298,7 @@ iser_alloc_pi_ctx(struct ib_device *ib_device,
291298

292299
pi_ctx = desc->pi_ctx;
293300

294-
ret = iser_alloc_reg_res(ib_device, pd, &pi_ctx->rsc, size);
301+
ret = iser_alloc_reg_res(device, pd, &pi_ctx->rsc, size);
295302
if (ret) {
296303
iser_err("failed to allocate reg_resources\n");
297304
goto alloc_reg_res_err;
@@ -324,7 +331,7 @@ iser_free_pi_ctx(struct iser_pi_context *pi_ctx)
324331
}
325332

326333
static struct iser_fr_desc *
327-
iser_create_fastreg_desc(struct ib_device *ib_device,
334+
iser_create_fastreg_desc(struct iser_device *device,
328335
struct ib_pd *pd,
329336
bool pi_enable,
330337
unsigned int size)
@@ -336,12 +343,12 @@ iser_create_fastreg_desc(struct ib_device *ib_device,
336343
if (!desc)
337344
return ERR_PTR(-ENOMEM);
338345

339-
ret = iser_alloc_reg_res(ib_device, pd, &desc->rsc, size);
346+
ret = iser_alloc_reg_res(device, pd, &desc->rsc, size);
340347
if (ret)
341348
goto reg_res_alloc_failure;
342349

343350
if (pi_enable) {
344-
ret = iser_alloc_pi_ctx(ib_device, pd, desc, size);
351+
ret = iser_alloc_pi_ctx(device, pd, desc, size);
345352
if (ret)
346353
goto pi_ctx_alloc_failure;
347354
}
@@ -374,7 +381,7 @@ int iser_alloc_fastreg_pool(struct ib_conn *ib_conn,
374381
spin_lock_init(&fr_pool->lock);
375382
fr_pool->size = 0;
376383
for (i = 0; i < cmds_max; i++) {
377-
desc = iser_create_fastreg_desc(device->ib_device, device->pd,
384+
desc = iser_create_fastreg_desc(device, device->pd,
378385
ib_conn->pi_support, size);
379386
if (IS_ERR(desc)) {
380387
ret = PTR_ERR(desc);

0 commit comments

Comments
 (0)