Skip to content

Commit d6f1c17

Browse files
mmarcinidledford
authored andcommitted
IB/qib: Change lkey table allocation to support more MRs
The lkey table is allocated with with a get_user_pages() with an order based on a number of index bits from a module parameter. The underlying kernel code cannot allocate that many contiguous pages. There is no reason the underlying memory needs to be physically contiguous. This patch: - switches the allocation/deallocation to vmalloc/vfree - caps the number of bits to 23 to insure at least 1 generation bit o this matches the module parameter description Cc: [email protected] Reviewed-by: Vinit Agnihotri <[email protected]> Signed-off-by: Mike Marciniszyn <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent e0238a6 commit d6f1c17

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

drivers/infiniband/hw/qib/qib_keys.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ int qib_alloc_lkey(struct qib_mregion *mr, int dma_region)
8686
* unrestricted LKEY.
8787
*/
8888
rkt->gen++;
89+
/*
90+
* bits are capped in qib_verbs.c to insure enough bits
91+
* for generation number
92+
*/
8993
mr->lkey = (r << (32 - ib_qib_lkey_table_size)) |
9094
((((1 << (24 - ib_qib_lkey_table_size)) - 1) & rkt->gen)
9195
<< 8);

drivers/infiniband/hw/qib/qib_verbs.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <linux/rculist.h>
4141
#include <linux/mm.h>
4242
#include <linux/random.h>
43+
#include <linux/vmalloc.h>
4344

4445
#include "qib.h"
4546
#include "qib_common.h"
@@ -2109,10 +2110,16 @@ int qib_register_ib_device(struct qib_devdata *dd)
21092110
* the LKEY). The remaining bits act as a generation number or tag.
21102111
*/
21112112
spin_lock_init(&dev->lk_table.lock);
2113+
/* insure generation is at least 4 bits see keys.c */
2114+
if (ib_qib_lkey_table_size > MAX_LKEY_TABLE_BITS) {
2115+
qib_dev_warn(dd, "lkey bits %u too large, reduced to %u\n",
2116+
ib_qib_lkey_table_size, MAX_LKEY_TABLE_BITS);
2117+
ib_qib_lkey_table_size = MAX_LKEY_TABLE_BITS;
2118+
}
21122119
dev->lk_table.max = 1 << ib_qib_lkey_table_size;
21132120
lk_tab_size = dev->lk_table.max * sizeof(*dev->lk_table.table);
21142121
dev->lk_table.table = (struct qib_mregion __rcu **)
2115-
__get_free_pages(GFP_KERNEL, get_order(lk_tab_size));
2122+
vmalloc(lk_tab_size);
21162123
if (dev->lk_table.table == NULL) {
21172124
ret = -ENOMEM;
21182125
goto err_lk;
@@ -2286,7 +2293,7 @@ int qib_register_ib_device(struct qib_devdata *dd)
22862293
sizeof(struct qib_pio_header),
22872294
dev->pio_hdrs, dev->pio_hdrs_phys);
22882295
err_hdrs:
2289-
free_pages((unsigned long) dev->lk_table.table, get_order(lk_tab_size));
2296+
vfree(dev->lk_table.table);
22902297
err_lk:
22912298
kfree(dev->qp_table);
22922299
err_qpt:
@@ -2340,8 +2347,7 @@ void qib_unregister_ib_device(struct qib_devdata *dd)
23402347
sizeof(struct qib_pio_header),
23412348
dev->pio_hdrs, dev->pio_hdrs_phys);
23422349
lk_tab_size = dev->lk_table.max * sizeof(*dev->lk_table.table);
2343-
free_pages((unsigned long) dev->lk_table.table,
2344-
get_order(lk_tab_size));
2350+
vfree(dev->lk_table.table);
23452351
kfree(dev->qp_table);
23462352
}
23472353

drivers/infiniband/hw/qib/qib_verbs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,8 @@ struct qib_qpn_table {
647647
struct qpn_map map[QPNMAP_ENTRIES];
648648
};
649649

650+
#define MAX_LKEY_TABLE_BITS 23
651+
650652
struct qib_lkey_table {
651653
spinlock_t lock; /* protect changes in this struct */
652654
u32 next; /* next unused index (speeds search) */

0 commit comments

Comments
 (0)