Skip to content

Commit c1f67a8

Browse files
Eli CohenRoland Dreier
authored andcommitted
IB/mthca: Add module parameter for number of MTTs per segment
The current MTT allocator uses kmalloc() to allocate a buffer for its buddy allocator, and thus is limited in the amount of MTT segments that it can control. As a result, the size of memory that can be registered is limited too. This patch uses a module parameter to control the number of MTT entries that each segment represents, allowing more memory to be registered with the same number of segments. Signed-off-by: Eli Cohen <[email protected]> Signed-off-by: Roland Dreier <[email protected]>
1 parent 210af91 commit c1f67a8

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

drivers/infiniband/hw/mthca/mthca_cmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ int mthca_QUERY_DEV_LIM(struct mthca_dev *dev,
10591059
MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_MTT_OFFSET);
10601060
if (mthca_is_memfree(dev))
10611061
dev_lim->reserved_mtts = ALIGN((1 << (field >> 4)) * sizeof(u64),
1062-
MTHCA_MTT_SEG_SIZE) / MTHCA_MTT_SEG_SIZE;
1062+
dev->limits.mtt_seg_size) / dev->limits.mtt_seg_size;
10631063
else
10641064
dev_lim->reserved_mtts = 1 << (field >> 4);
10651065
MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_MRW_SZ_OFFSET);

drivers/infiniband/hw/mthca/mthca_dev.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ struct mthca_limits {
159159
int reserved_eqs;
160160
int num_mpts;
161161
int num_mtt_segs;
162+
int mtt_seg_size;
162163
int fmr_reserved_mtts;
163164
int reserved_mtts;
164165
int reserved_mrws;

drivers/infiniband/hw/mthca/mthca_main.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ module_param_named(fmr_reserved_mtts, hca_profile.fmr_reserved_mtts, int, 0444);
125125
MODULE_PARM_DESC(fmr_reserved_mtts,
126126
"number of memory translation table segments reserved for FMR");
127127

128+
static int log_mtts_per_seg = ilog2(MTHCA_MTT_SEG_SIZE / 8);
129+
module_param_named(log_mtts_per_seg, log_mtts_per_seg, int, 0444);
130+
MODULE_PARM_DESC(log_mtts_per_seg, "Log2 number of MTT entries per segment (1-5)");
131+
128132
static char mthca_version[] __devinitdata =
129133
DRV_NAME ": Mellanox InfiniBand HCA driver v"
130134
DRV_VERSION " (" DRV_RELDATE ")\n";
@@ -162,6 +166,7 @@ static int mthca_dev_lim(struct mthca_dev *mdev, struct mthca_dev_lim *dev_lim)
162166
int err;
163167
u8 status;
164168

169+
mdev->limits.mtt_seg_size = (1 << log_mtts_per_seg) * 8;
165170
err = mthca_QUERY_DEV_LIM(mdev, dev_lim, &status);
166171
if (err) {
167172
mthca_err(mdev, "QUERY_DEV_LIM command failed, aborting.\n");
@@ -460,11 +465,11 @@ static int mthca_init_icm(struct mthca_dev *mdev,
460465
}
461466

462467
/* CPU writes to non-reserved MTTs, while HCA might DMA to reserved mtts */
463-
mdev->limits.reserved_mtts = ALIGN(mdev->limits.reserved_mtts * MTHCA_MTT_SEG_SIZE,
464-
dma_get_cache_alignment()) / MTHCA_MTT_SEG_SIZE;
468+
mdev->limits.reserved_mtts = ALIGN(mdev->limits.reserved_mtts * mdev->limits.mtt_seg_size,
469+
dma_get_cache_alignment()) / mdev->limits.mtt_seg_size;
465470

466471
mdev->mr_table.mtt_table = mthca_alloc_icm_table(mdev, init_hca->mtt_base,
467-
MTHCA_MTT_SEG_SIZE,
472+
mdev->limits.mtt_seg_size,
468473
mdev->limits.num_mtt_segs,
469474
mdev->limits.reserved_mtts,
470475
1, 0);
@@ -1315,6 +1320,12 @@ static void __init mthca_validate_profile(void)
13151320
printk(KERN_WARNING PFX "Corrected fmr_reserved_mtts to %d.\n",
13161321
hca_profile.fmr_reserved_mtts);
13171322
}
1323+
1324+
if ((log_mtts_per_seg < 1) || (log_mtts_per_seg > 5)) {
1325+
printk(KERN_WARNING PFX "bad log_mtts_per_seg (%d). Using default - %d\n",
1326+
log_mtts_per_seg, ilog2(MTHCA_MTT_SEG_SIZE / 8));
1327+
log_mtts_per_seg = ilog2(MTHCA_MTT_SEG_SIZE / 8);
1328+
}
13181329
}
13191330

13201331
static int __init mthca_init(void)

drivers/infiniband/hw/mthca/mthca_mr.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ static struct mthca_mtt *__mthca_alloc_mtt(struct mthca_dev *dev, int size,
220220

221221
mtt->buddy = buddy;
222222
mtt->order = 0;
223-
for (i = MTHCA_MTT_SEG_SIZE / 8; i < size; i <<= 1)
223+
for (i = dev->limits.mtt_seg_size / 8; i < size; i <<= 1)
224224
++mtt->order;
225225

226226
mtt->first_seg = mthca_alloc_mtt_range(dev, mtt->order, buddy);
@@ -267,7 +267,7 @@ static int __mthca_write_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt,
267267

268268
while (list_len > 0) {
269269
mtt_entry[0] = cpu_to_be64(dev->mr_table.mtt_base +
270-
mtt->first_seg * MTHCA_MTT_SEG_SIZE +
270+
mtt->first_seg * dev->limits.mtt_seg_size +
271271
start_index * 8);
272272
mtt_entry[1] = 0;
273273
for (i = 0; i < list_len && i < MTHCA_MAILBOX_SIZE / 8 - 2; ++i)
@@ -326,7 +326,7 @@ static void mthca_tavor_write_mtt_seg(struct mthca_dev *dev,
326326
u64 __iomem *mtts;
327327
int i;
328328

329-
mtts = dev->mr_table.tavor_fmr.mtt_base + mtt->first_seg * MTHCA_MTT_SEG_SIZE +
329+
mtts = dev->mr_table.tavor_fmr.mtt_base + mtt->first_seg * dev->limits.mtt_seg_size +
330330
start_index * sizeof (u64);
331331
for (i = 0; i < list_len; ++i)
332332
mthca_write64_raw(cpu_to_be64(buffer_list[i] | MTHCA_MTT_FLAG_PRESENT),
@@ -345,10 +345,10 @@ static void mthca_arbel_write_mtt_seg(struct mthca_dev *dev,
345345
/* For Arbel, all MTTs must fit in the same page. */
346346
BUG_ON(s / PAGE_SIZE != (s + list_len * sizeof(u64) - 1) / PAGE_SIZE);
347347
/* Require full segments */
348-
BUG_ON(s % MTHCA_MTT_SEG_SIZE);
348+
BUG_ON(s % dev->limits.mtt_seg_size);
349349

350350
mtts = mthca_table_find(dev->mr_table.mtt_table, mtt->first_seg +
351-
s / MTHCA_MTT_SEG_SIZE, &dma_handle);
351+
s / dev->limits.mtt_seg_size, &dma_handle);
352352

353353
BUG_ON(!mtts);
354354

@@ -479,7 +479,7 @@ int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
479479
if (mr->mtt)
480480
mpt_entry->mtt_seg =
481481
cpu_to_be64(dev->mr_table.mtt_base +
482-
mr->mtt->first_seg * MTHCA_MTT_SEG_SIZE);
482+
mr->mtt->first_seg * dev->limits.mtt_seg_size);
483483

484484
if (0) {
485485
mthca_dbg(dev, "Dumping MPT entry %08x:\n", mr->ibmr.lkey);
@@ -626,7 +626,7 @@ int mthca_fmr_alloc(struct mthca_dev *dev, u32 pd,
626626
goto err_out_table;
627627
}
628628

629-
mtt_seg = mr->mtt->first_seg * MTHCA_MTT_SEG_SIZE;
629+
mtt_seg = mr->mtt->first_seg * dev->limits.mtt_seg_size;
630630

631631
if (mthca_is_memfree(dev)) {
632632
mr->mem.arbel.mtts = mthca_table_find(dev->mr_table.mtt_table,
@@ -908,7 +908,7 @@ int mthca_init_mr_table(struct mthca_dev *dev)
908908
dev->mr_table.mtt_base);
909909

910910
dev->mr_table.tavor_fmr.mtt_base =
911-
ioremap(addr, mtts * MTHCA_MTT_SEG_SIZE);
911+
ioremap(addr, mtts * dev->limits.mtt_seg_size);
912912
if (!dev->mr_table.tavor_fmr.mtt_base) {
913913
mthca_warn(dev, "MTT ioremap for FMR failed.\n");
914914
err = -ENOMEM;

drivers/infiniband/hw/mthca/mthca_profile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ s64 mthca_make_profile(struct mthca_dev *dev,
9494
profile[MTHCA_RES_RDB].size = MTHCA_RDB_ENTRY_SIZE;
9595
profile[MTHCA_RES_MCG].size = MTHCA_MGM_ENTRY_SIZE;
9696
profile[MTHCA_RES_MPT].size = dev_lim->mpt_entry_sz;
97-
profile[MTHCA_RES_MTT].size = MTHCA_MTT_SEG_SIZE;
97+
profile[MTHCA_RES_MTT].size = dev->limits.mtt_seg_size;
9898
profile[MTHCA_RES_UAR].size = dev_lim->uar_scratch_entry_sz;
9999
profile[MTHCA_RES_UDAV].size = MTHCA_AV_SIZE;
100100
profile[MTHCA_RES_UARC].size = request->uarc_size;
@@ -232,7 +232,7 @@ s64 mthca_make_profile(struct mthca_dev *dev,
232232
dev->limits.num_mtt_segs = profile[i].num;
233233
dev->mr_table.mtt_base = profile[i].start;
234234
init_hca->mtt_base = profile[i].start;
235-
init_hca->mtt_seg_sz = ffs(MTHCA_MTT_SEG_SIZE) - 7;
235+
init_hca->mtt_seg_sz = ffs(dev->limits.mtt_seg_size) - 7;
236236
break;
237237
case MTHCA_RES_UAR:
238238
dev->limits.num_uars = profile[i].num;

0 commit comments

Comments
 (0)