Skip to content

Commit a50243b

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma
Pull rdma updates from Jason Gunthorpe: "This has been a slightly more active cycle than normal with ongoing core changes and quite a lot of collected driver updates. - Various driver fixes for bnxt_re, cxgb4, hns, mlx5, pvrdma, rxe - A new data transfer mode for HFI1 giving higher performance - Significant functional and bug fix update to the mlx5 On-Demand-Paging MR feature - A chip hang reset recovery system for hns - Change mm->pinned_vm to an atomic64 - Update bnxt_re to support a new 57500 chip - A sane netlink 'rdma link add' method for creating rxe devices and fixing the various unregistration race conditions in rxe's unregister flow - Allow lookup up objects by an ID over netlink - Various reworking of the core to driver interface: - drivers should not assume umem SGLs are in PAGE_SIZE chunks - ucontext is accessed via udata not other means - start to make the core code responsible for object memory allocation - drivers should convert struct device to struct ib_device via a helper - drivers have more tools to avoid use after unregister problems" * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: (280 commits) net/mlx5: ODP support for XRC transport is not enabled by default in FW IB/hfi1: Close race condition on user context disable and close RDMA/umem: Revert broken 'off by one' fix RDMA/umem: minor bug fix in error handling path RDMA/hns: Use GFP_ATOMIC in hns_roce_v2_modify_qp cxgb4: kfree mhp after the debug print IB/rdmavt: Fix concurrency panics in QP post_send and modify to error IB/rdmavt: Fix loopback send with invalidate ordering IB/iser: Fix dma_nents type definition IB/mlx5: Set correct write permissions for implicit ODP MR bnxt_re: Clean cq for kernel consumers only RDMA/uverbs: Don't do double free of allocated PD RDMA: Handle ucontext allocations by IB/core RDMA/core: Fix a WARN() message bnxt_re: fix the regression due to changes in alloc_pbl IB/mlx4: Increase the timeout for CM cache IB/core: Abort page fault handler silently during owning process exit IB/mlx5: Validate correct PD before prefetch MR IB/mlx5: Protect against prefetch of invalid MR RDMA/uverbs: Store PR pointer before it is overwritten ...
2 parents 2901752 + fca22e7 commit a50243b

264 files changed

Lines changed: 16710 additions & 5014 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.clang-format‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ ForEachMacros:
240240
- 'for_each_set_bit'
241241
- 'for_each_set_bit_from'
242242
- 'for_each_sg'
243+
- 'for_each_sg_dma_page'
243244
- 'for_each_sg_page'
244245
- 'for_each_sibling_event'
245246
- '__for_each_thread'
@@ -360,6 +361,7 @@ ForEachMacros:
360361
- 'radix_tree_for_each_slot'
361362
- 'radix_tree_for_each_tagged'
362363
- 'rbtree_postorder_for_each_entry_safe'
364+
- 'rdma_for_each_port'
363365
- 'resource_list_for_each_entry'
364366
- 'resource_list_for_each_entry_safe'
365367
- 'rhl_for_each_entry_rcu'

‎Documentation/infiniband/user_verbs.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ Memory pinning
4646
I/O targets be kept resident at the same physical address. The
4747
ib_uverbs module manages pinning and unpinning memory regions via
4848
get_user_pages() and put_page() calls. It also accounts for the
49-
amount of memory pinned in the process's locked_vm, and checks that
49+
amount of memory pinned in the process's pinned_vm, and checks that
5050
unprivileged processes do not exceed their RLIMIT_MEMLOCK limit.
5151

5252
Pages that are pinned multiple times are counted each time they are
53-
pinned, so the value of locked_vm may be an overestimate of the
53+
pinned, so the value of pinned_vm may be an overestimate of the
5454
number of pages pinned by a process.
5555

5656
/dev files

‎drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,13 @@ static dma_addr_t __vmw_piter_dma_addr(struct vmw_piter *viter)
311311

312312
static dma_addr_t __vmw_piter_sg_addr(struct vmw_piter *viter)
313313
{
314-
return sg_page_iter_dma_address(&viter->iter);
314+
/*
315+
* FIXME: This driver wrongly mixes DMA and CPU SG list iteration and
316+
* needs revision. See
317+
* https://lore.kernel.org/lkml/20190104223531.GA1705@ziepe.ca/
318+
*/
319+
return sg_page_iter_dma_address(
320+
container_of(&viter->iter, struct sg_dma_page_iter, base));
315321
}
316322

317323

‎drivers/infiniband/Kconfig‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ config INFINIBAND_ADDR_TRANS_CONFIGFS
8989
This allows the user to config the default GID type that the CM
9090
uses for each device, when initiaing new connections.
9191

92+
if INFINIBAND_USER_ACCESS || !INFINIBAND_USER_ACCESS
9293
source "drivers/infiniband/hw/mthca/Kconfig"
9394
source "drivers/infiniband/hw/qib/Kconfig"
9495
source "drivers/infiniband/hw/cxgb3/Kconfig"
@@ -101,6 +102,12 @@ source "drivers/infiniband/hw/ocrdma/Kconfig"
101102
source "drivers/infiniband/hw/vmw_pvrdma/Kconfig"
102103
source "drivers/infiniband/hw/usnic/Kconfig"
103104
source "drivers/infiniband/hw/hns/Kconfig"
105+
source "drivers/infiniband/hw/bnxt_re/Kconfig"
106+
source "drivers/infiniband/hw/hfi1/Kconfig"
107+
source "drivers/infiniband/hw/qedr/Kconfig"
108+
source "drivers/infiniband/sw/rdmavt/Kconfig"
109+
source "drivers/infiniband/sw/rxe/Kconfig"
110+
endif
104111

105112
source "drivers/infiniband/ulp/ipoib/Kconfig"
106113

@@ -111,13 +118,5 @@ source "drivers/infiniband/ulp/iser/Kconfig"
111118
source "drivers/infiniband/ulp/isert/Kconfig"
112119

113120
source "drivers/infiniband/ulp/opa_vnic/Kconfig"
114-
source "drivers/infiniband/sw/rdmavt/Kconfig"
115-
source "drivers/infiniband/sw/rxe/Kconfig"
116-
117-
source "drivers/infiniband/hw/hfi1/Kconfig"
118-
119-
source "drivers/infiniband/hw/qedr/Kconfig"
120-
121-
source "drivers/infiniband/hw/bnxt_re/Kconfig"
122121

123122
endif # INFINIBAND

‎drivers/infiniband/core/Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ ib_core-y := packer.o ud_header.o verbs.o cq.o rw.o sysfs.o \
1515
nldev.o restrack.o
1616

1717
ib_core-$(CONFIG_SECURITY_INFINIBAND) += security.o
18-
ib_core-$(CONFIG_INFINIBAND_USER_MEM) += umem.o
19-
ib_core-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += umem_odp.o
2018
ib_core-$(CONFIG_CGROUP_RDMA) += cgroup.o
2119

2220
ib_cm-y := cm.o
@@ -39,3 +37,5 @@ ib_uverbs-y := uverbs_main.o uverbs_cmd.o uverbs_marshall.o \
3937
uverbs_std_types_flow_action.o uverbs_std_types_dm.o \
4038
uverbs_std_types_mr.o uverbs_std_types_counters.o \
4139
uverbs_uapi.o uverbs_std_types_device.o
40+
ib_uverbs-$(CONFIG_INFINIBAND_USER_MEM) += umem.o
41+
ib_uverbs-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += umem_odp.o

‎drivers/infiniband/core/cache.c‎

Lines changed: 46 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ EXPORT_SYMBOL(ib_cache_gid_parse_type_str);
185185

186186
static struct ib_gid_table *rdma_gid_table(struct ib_device *device, u8 port)
187187
{
188-
return device->cache.ports[port - rdma_start_port(device)].gid;
188+
return device->port_data[port].cache.gid;
189189
}
190190

191191
static bool is_gid_entry_free(const struct ib_gid_table_entry *entry)
@@ -547,21 +547,19 @@ int ib_cache_gid_add(struct ib_device *ib_dev, u8 port,
547547
unsigned long mask;
548548
int ret;
549549

550-
if (ib_dev->ops.get_netdev) {
551-
idev = ib_dev->ops.get_netdev(ib_dev, port);
552-
if (idev && attr->ndev != idev) {
553-
union ib_gid default_gid;
550+
idev = ib_device_get_netdev(ib_dev, port);
551+
if (idev && attr->ndev != idev) {
552+
union ib_gid default_gid;
554553

555-
/* Adding default GIDs in not permitted */
556-
make_default_gid(idev, &default_gid);
557-
if (!memcmp(gid, &default_gid, sizeof(*gid))) {
558-
dev_put(idev);
559-
return -EPERM;
560-
}
561-
}
562-
if (idev)
554+
/* Adding default GIDs is not permitted */
555+
make_default_gid(idev, &default_gid);
556+
if (!memcmp(gid, &default_gid, sizeof(*gid))) {
563557
dev_put(idev);
558+
return -EPERM;
559+
}
564560
}
561+
if (idev)
562+
dev_put(idev);
565563

566564
mask = GID_ATTR_FIND_MASK_GID |
567565
GID_ATTR_FIND_MASK_GID_TYPE |
@@ -765,7 +763,7 @@ static struct ib_gid_table *alloc_gid_table(int sz)
765763
return NULL;
766764
}
767765

768-
static void release_gid_table(struct ib_device *device, u8 port,
766+
static void release_gid_table(struct ib_device *device,
769767
struct ib_gid_table *table)
770768
{
771769
bool leak = false;
@@ -863,31 +861,27 @@ static void gid_table_reserve_default(struct ib_device *ib_dev, u8 port,
863861

864862
static void gid_table_release_one(struct ib_device *ib_dev)
865863
{
866-
struct ib_gid_table *table;
867-
u8 port;
864+
unsigned int p;
868865

869-
for (port = 0; port < ib_dev->phys_port_cnt; port++) {
870-
table = ib_dev->cache.ports[port].gid;
871-
release_gid_table(ib_dev, port, table);
872-
ib_dev->cache.ports[port].gid = NULL;
866+
rdma_for_each_port (ib_dev, p) {
867+
release_gid_table(ib_dev, ib_dev->port_data[p].cache.gid);
868+
ib_dev->port_data[p].cache.gid = NULL;
873869
}
874870
}
875871

876872
static int _gid_table_setup_one(struct ib_device *ib_dev)
877873
{
878-
u8 port;
879874
struct ib_gid_table *table;
875+
unsigned int rdma_port;
880876

881-
for (port = 0; port < ib_dev->phys_port_cnt; port++) {
882-
u8 rdma_port = port + rdma_start_port(ib_dev);
883-
884-
table = alloc_gid_table(
885-
ib_dev->port_immutable[rdma_port].gid_tbl_len);
877+
rdma_for_each_port (ib_dev, rdma_port) {
878+
table = alloc_gid_table(
879+
ib_dev->port_data[rdma_port].immutable.gid_tbl_len);
886880
if (!table)
887881
goto rollback_table_setup;
888882

889883
gid_table_reserve_default(ib_dev, rdma_port, table);
890-
ib_dev->cache.ports[port].gid = table;
884+
ib_dev->port_data[rdma_port].cache.gid = table;
891885
}
892886
return 0;
893887

@@ -898,14 +892,11 @@ static int _gid_table_setup_one(struct ib_device *ib_dev)
898892

899893
static void gid_table_cleanup_one(struct ib_device *ib_dev)
900894
{
901-
struct ib_gid_table *table;
902-
u8 port;
895+
unsigned int p;
903896

904-
for (port = 0; port < ib_dev->phys_port_cnt; port++) {
905-
table = ib_dev->cache.ports[port].gid;
906-
cleanup_gid_table_port(ib_dev, port + rdma_start_port(ib_dev),
907-
table);
908-
}
897+
rdma_for_each_port (ib_dev, p)
898+
cleanup_gid_table_port(ib_dev, p,
899+
ib_dev->port_data[p].cache.gid);
909900
}
910901

911902
static int gid_table_setup_one(struct ib_device *ib_dev)
@@ -983,17 +974,17 @@ const struct ib_gid_attr *rdma_find_gid(struct ib_device *device,
983974
unsigned long mask = GID_ATTR_FIND_MASK_GID |
984975
GID_ATTR_FIND_MASK_GID_TYPE;
985976
struct ib_gid_attr gid_attr_val = {.ndev = ndev, .gid_type = gid_type};
986-
u8 p;
977+
unsigned int p;
987978

988979
if (ndev)
989980
mask |= GID_ATTR_FIND_MASK_NETDEV;
990981

991-
for (p = 0; p < device->phys_port_cnt; p++) {
982+
rdma_for_each_port(device, p) {
992983
struct ib_gid_table *table;
993984
unsigned long flags;
994985
int index;
995986

996-
table = device->cache.ports[p].gid;
987+
table = device->port_data[p].cache.gid;
997988
read_lock_irqsave(&table->rwlock, flags);
998989
index = find_gid(table, gid, &gid_attr_val, false, mask, NULL);
999990
if (index >= 0) {
@@ -1025,7 +1016,7 @@ int ib_get_cached_pkey(struct ib_device *device,
10251016

10261017
read_lock_irqsave(&device->cache.lock, flags);
10271018

1028-
cache = device->cache.ports[port_num - rdma_start_port(device)].pkey;
1019+
cache = device->port_data[port_num].cache.pkey;
10291020

10301021
if (index < 0 || index >= cache->table_len)
10311022
ret = -EINVAL;
@@ -1043,14 +1034,12 @@ int ib_get_cached_subnet_prefix(struct ib_device *device,
10431034
u64 *sn_pfx)
10441035
{
10451036
unsigned long flags;
1046-
int p;
10471037

10481038
if (!rdma_is_port_valid(device, port_num))
10491039
return -EINVAL;
10501040

1051-
p = port_num - rdma_start_port(device);
10521041
read_lock_irqsave(&device->cache.lock, flags);
1053-
*sn_pfx = device->cache.ports[p].subnet_prefix;
1042+
*sn_pfx = device->port_data[port_num].cache.subnet_prefix;
10541043
read_unlock_irqrestore(&device->cache.lock, flags);
10551044

10561045
return 0;
@@ -1073,7 +1062,7 @@ int ib_find_cached_pkey(struct ib_device *device,
10731062

10741063
read_lock_irqsave(&device->cache.lock, flags);
10751064

1076-
cache = device->cache.ports[port_num - rdma_start_port(device)].pkey;
1065+
cache = device->port_data[port_num].cache.pkey;
10771066

10781067
*index = -1;
10791068

@@ -1113,7 +1102,7 @@ int ib_find_exact_cached_pkey(struct ib_device *device,
11131102

11141103
read_lock_irqsave(&device->cache.lock, flags);
11151104

1116-
cache = device->cache.ports[port_num - rdma_start_port(device)].pkey;
1105+
cache = device->port_data[port_num].cache.pkey;
11171106

11181107
*index = -1;
11191108

@@ -1141,7 +1130,7 @@ int ib_get_cached_lmc(struct ib_device *device,
11411130
return -EINVAL;
11421131

11431132
read_lock_irqsave(&device->cache.lock, flags);
1144-
*lmc = device->cache.ports[port_num - rdma_start_port(device)].lmc;
1133+
*lmc = device->port_data[port_num].cache.lmc;
11451134
read_unlock_irqrestore(&device->cache.lock, flags);
11461135

11471136
return ret;
@@ -1159,8 +1148,7 @@ int ib_get_cached_port_state(struct ib_device *device,
11591148
return -EINVAL;
11601149

11611150
read_lock_irqsave(&device->cache.lock, flags);
1162-
*port_state = device->cache.ports[port_num
1163-
- rdma_start_port(device)].port_state;
1151+
*port_state = device->port_data[port_num].cache.port_state;
11641152
read_unlock_irqrestore(&device->cache.lock, flags);
11651153

11661154
return ret;
@@ -1361,16 +1349,13 @@ static void ib_cache_update(struct ib_device *device,
13611349

13621350
write_lock_irq(&device->cache.lock);
13631351

1364-
old_pkey_cache = device->cache.ports[port -
1365-
rdma_start_port(device)].pkey;
1352+
old_pkey_cache = device->port_data[port].cache.pkey;
13661353

1367-
device->cache.ports[port - rdma_start_port(device)].pkey = pkey_cache;
1368-
device->cache.ports[port - rdma_start_port(device)].lmc = tprops->lmc;
1369-
device->cache.ports[port - rdma_start_port(device)].port_state =
1370-
tprops->state;
1354+
device->port_data[port].cache.pkey = pkey_cache;
1355+
device->port_data[port].cache.lmc = tprops->lmc;
1356+
device->port_data[port].cache.port_state = tprops->state;
13711357

1372-
device->cache.ports[port - rdma_start_port(device)].subnet_prefix =
1373-
tprops->subnet_prefix;
1358+
device->port_data[port].cache.subnet_prefix = tprops->subnet_prefix;
13741359
write_unlock_irq(&device->cache.lock);
13751360

13761361
if (enforce_security)
@@ -1428,27 +1413,17 @@ static void ib_cache_event(struct ib_event_handler *handler,
14281413

14291414
int ib_cache_setup_one(struct ib_device *device)
14301415
{
1431-
int p;
1416+
unsigned int p;
14321417
int err;
14331418

14341419
rwlock_init(&device->cache.lock);
14351420

1436-
device->cache.ports =
1437-
kcalloc(rdma_end_port(device) - rdma_start_port(device) + 1,
1438-
sizeof(*device->cache.ports),
1439-
GFP_KERNEL);
1440-
if (!device->cache.ports)
1441-
return -ENOMEM;
1442-
14431421
err = gid_table_setup_one(device);
1444-
if (err) {
1445-
kfree(device->cache.ports);
1446-
device->cache.ports = NULL;
1422+
if (err)
14471423
return err;
1448-
}
14491424

1450-
for (p = 0; p <= rdma_end_port(device) - rdma_start_port(device); ++p)
1451-
ib_cache_update(device, p + rdma_start_port(device), true);
1425+
rdma_for_each_port (device, p)
1426+
ib_cache_update(device, p, true);
14521427

14531428
INIT_IB_EVENT_HANDLER(&device->cache.event_handler,
14541429
device, ib_cache_event);
@@ -1458,19 +1433,18 @@ int ib_cache_setup_one(struct ib_device *device)
14581433

14591434
void ib_cache_release_one(struct ib_device *device)
14601435
{
1461-
int p;
1436+
unsigned int p;
14621437

14631438
/*
14641439
* The release function frees all the cache elements.
14651440
* This function should be called as part of freeing
14661441
* all the device's resources when the cache could no
14671442
* longer be accessed.
14681443
*/
1469-
for (p = 0; p <= rdma_end_port(device) - rdma_start_port(device); ++p)
1470-
kfree(device->cache.ports[p].pkey);
1444+
rdma_for_each_port (device, p)
1445+
kfree(device->port_data[p].cache.pkey);
14711446

14721447
gid_table_release_one(device);
1473-
kfree(device->cache.ports);
14741448
}
14751449

14761450
void ib_cache_cleanup_one(struct ib_device *device)

‎drivers/infiniband/core/cgroup.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@
2121
* Register with the rdma cgroup. Should be called before
2222
* exposing rdma device to user space applications to avoid
2323
* resource accounting leak.
24-
* Returns 0 on success or otherwise failure code.
2524
*/
26-
int ib_device_register_rdmacg(struct ib_device *device)
25+
void ib_device_register_rdmacg(struct ib_device *device)
2726
{
2827
device->cg_device.name = device->name;
29-
return rdmacg_register_device(&device->cg_device);
28+
rdmacg_register_device(&device->cg_device);
3029
}
3130

3231
/**

‎drivers/infiniband/core/cm.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4052,8 +4052,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
40524052
atomic_long_inc(&port->counter_group[CM_RECV].
40534053
counter[attr_id - CM_ATTR_ID_OFFSET]);
40544054

4055-
work = kmalloc(sizeof(*work) + sizeof(struct sa_path_rec) * paths,
4056-
GFP_KERNEL);
4055+
work = kmalloc(struct_size(work, path, paths), GFP_KERNEL);
40574056
if (!work) {
40584057
ib_free_recv_mad(mad_recv_wc);
40594058
return;

0 commit comments

Comments
 (0)