Skip to content

Commit 8fdd401

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: "A very quiet cycle with few notable changes. Mostly the usual list of one or two patches to drivers changing something that isn't quite rc worthy. The subsystem seems to be seeing a larger number of rework and cleanup style patches right now, I feel that several vendors are prepping their drivers for new silicon. Summary: - Driver updates and cleanup for qedr, bnxt_re, hns, siw, mlx5, mlx4, rxe, i40iw - Larger series doing cleanup and rework for hns and hfi1. - Some general reworking of the CM code to make it a little more understandable - Unify the different code paths connected to the uverbs FD scheme - New UAPI ioctls conversions for get context and get async fd - Trace points for CQ and CM portions of the RDMA stack - mlx5 driver support for virtio-net formatted rings as RDMA raw ethernet QPs - verbs support for setting the PCI-E relaxed ordering bit on DMA traffic connected to a MR - A couple of bug fixes that came too late to make rc7" * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: (108 commits) RDMA/core: Make the entire API tree static RDMA/efa: Mask access flags with the correct optional range RDMA/cma: Fix unbalanced cm_id reference count during address resolve RDMA/umem: Fix ib_umem_find_best_pgsz() IB/mlx4: Fix leak in id_map_find_del IB/opa_vnic: Spelling correction of 'erorr' to 'error' IB/hfi1: Fix logical condition in msix_request_irq RDMA/cm: Remove CM message structs RDMA/cm: Use IBA functions for complex structure members RDMA/cm: Use IBA functions for simple structure members RDMA/cm: Use IBA functions for swapping get/set acessors RDMA/cm: Use IBA functions for simple get/set acessors RDMA/cm: Add SET/GET implementations to hide IBA wire format RDMA/cm: Add accessors for CM_REQ transport_type IB/mlx5: Return the administrative GUID if exists RDMA/core: Ensure that rdma_user_mmap_entry_remove() is a fence IB/mlx4: Fix memory leak in add_gid error flow IB/mlx5: Expose RoCE accelerator counters RDMA/mlx5: Set relaxed ordering when requested RDMA/core: Add the core support field to METHOD_GET_CONTEXT ...
2 parents 68b62e5 + 8889f6f commit 8fdd401

Some content is hidden

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

103 files changed

+4659
-3200
lines changed

drivers/infiniband/core/Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ ib_core-y := packer.o ud_header.o verbs.o cq.o rw.o sysfs.o \
1111
device.o fmr_pool.o cache.o netlink.o \
1212
roce_gid_mgmt.o mr_pool.o addr.o sa_query.o \
1313
multicast.o mad.o smi.o agent.o mad_rmpp.o \
14-
nldev.o restrack.o counters.o ib_core_uverbs.o
14+
nldev.o restrack.o counters.o ib_core_uverbs.o \
15+
trace.o
1516

1617
ib_core-$(CONFIG_SECURITY_INFINIBAND) += security.o
1718
ib_core-$(CONFIG_CGROUP_RDMA) += cgroup.o
@@ -20,7 +21,8 @@ ib_cm-y := cm.o
2021

2122
iw_cm-y := iwcm.o iwpm_util.o iwpm_msg.o
2223

23-
rdma_cm-y := cma.o
24+
CFLAGS_cma_trace.o += -I$(src)
25+
rdma_cm-y := cma.o cma_trace.o
2426

2527
rdma_cm-$(CONFIG_INFINIBAND_ADDR_TRANS_CONFIGFS) += cma_configfs.o
2628

@@ -33,6 +35,7 @@ ib_uverbs-y := uverbs_main.o uverbs_cmd.o uverbs_marshall.o \
3335
uverbs_std_types_cq.o \
3436
uverbs_std_types_flow_action.o uverbs_std_types_dm.o \
3537
uverbs_std_types_mr.o uverbs_std_types_counters.o \
36-
uverbs_uapi.o uverbs_std_types_device.o
38+
uverbs_uapi.o uverbs_std_types_device.o \
39+
uverbs_std_types_async_fd.o
3740
ib_uverbs-$(CONFIG_INFINIBAND_USER_MEM) += umem.o
3841
ib_uverbs-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += umem_odp.o

drivers/infiniband/core/addr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ int ib_nl_handle_ip_res_resp(struct sk_buff *skb,
139139
if (ib_nl_is_good_ip_resp(nlh))
140140
ib_nl_process_good_ip_rsep(nlh);
141141

142-
return skb->len;
142+
return 0;
143143
}
144144

145145
static int ib_nl_ip_send_msg(struct rdma_dev_addr *dev_addr,

drivers/infiniband/core/cache.c

Lines changed: 90 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ struct ib_pkey_cache {
5151

5252
struct ib_update_work {
5353
struct work_struct work;
54-
struct ib_device *device;
55-
u8 port_num;
56-
bool enforce_security;
54+
struct ib_event event;
55+
bool enforce_security;
5756
};
5857

5958
union ib_gid zgid;
@@ -130,7 +129,7 @@ static void dispatch_gid_change_event(struct ib_device *ib_dev, u8 port)
130129
event.element.port_num = port;
131130
event.event = IB_EVENT_GID_CHANGE;
132131

133-
ib_dispatch_event(&event);
132+
ib_dispatch_event_clients(&event);
134133
}
135134

136135
static const char * const gid_type_str[] = {
@@ -1034,7 +1033,7 @@ int ib_get_cached_pkey(struct ib_device *device,
10341033
if (!rdma_is_port_valid(device, port_num))
10351034
return -EINVAL;
10361035

1037-
read_lock_irqsave(&device->cache.lock, flags);
1036+
read_lock_irqsave(&device->cache_lock, flags);
10381037

10391038
cache = device->port_data[port_num].cache.pkey;
10401039

@@ -1043,7 +1042,7 @@ int ib_get_cached_pkey(struct ib_device *device,
10431042
else
10441043
*pkey = cache->table[index];
10451044

1046-
read_unlock_irqrestore(&device->cache.lock, flags);
1045+
read_unlock_irqrestore(&device->cache_lock, flags);
10471046

10481047
return ret;
10491048
}
@@ -1058,9 +1057,9 @@ int ib_get_cached_subnet_prefix(struct ib_device *device,
10581057
if (!rdma_is_port_valid(device, port_num))
10591058
return -EINVAL;
10601059

1061-
read_lock_irqsave(&device->cache.lock, flags);
1060+
read_lock_irqsave(&device->cache_lock, flags);
10621061
*sn_pfx = device->port_data[port_num].cache.subnet_prefix;
1063-
read_unlock_irqrestore(&device->cache.lock, flags);
1062+
read_unlock_irqrestore(&device->cache_lock, flags);
10641063

10651064
return 0;
10661065
}
@@ -1080,7 +1079,7 @@ int ib_find_cached_pkey(struct ib_device *device,
10801079
if (!rdma_is_port_valid(device, port_num))
10811080
return -EINVAL;
10821081

1083-
read_lock_irqsave(&device->cache.lock, flags);
1082+
read_lock_irqsave(&device->cache_lock, flags);
10841083

10851084
cache = device->port_data[port_num].cache.pkey;
10861085

@@ -1101,7 +1100,7 @@ int ib_find_cached_pkey(struct ib_device *device,
11011100
ret = 0;
11021101
}
11031102

1104-
read_unlock_irqrestore(&device->cache.lock, flags);
1103+
read_unlock_irqrestore(&device->cache_lock, flags);
11051104

11061105
return ret;
11071106
}
@@ -1120,7 +1119,7 @@ int ib_find_exact_cached_pkey(struct ib_device *device,
11201119
if (!rdma_is_port_valid(device, port_num))
11211120
return -EINVAL;
11221121

1123-
read_lock_irqsave(&device->cache.lock, flags);
1122+
read_lock_irqsave(&device->cache_lock, flags);
11241123

11251124
cache = device->port_data[port_num].cache.pkey;
11261125

@@ -1133,7 +1132,7 @@ int ib_find_exact_cached_pkey(struct ib_device *device,
11331132
break;
11341133
}
11351134

1136-
read_unlock_irqrestore(&device->cache.lock, flags);
1135+
read_unlock_irqrestore(&device->cache_lock, flags);
11371136

11381137
return ret;
11391138
}
@@ -1149,9 +1148,9 @@ int ib_get_cached_lmc(struct ib_device *device,
11491148
if (!rdma_is_port_valid(device, port_num))
11501149
return -EINVAL;
11511150

1152-
read_lock_irqsave(&device->cache.lock, flags);
1151+
read_lock_irqsave(&device->cache_lock, flags);
11531152
*lmc = device->port_data[port_num].cache.lmc;
1154-
read_unlock_irqrestore(&device->cache.lock, flags);
1153+
read_unlock_irqrestore(&device->cache_lock, flags);
11551154

11561155
return ret;
11571156
}
@@ -1167,9 +1166,9 @@ int ib_get_cached_port_state(struct ib_device *device,
11671166
if (!rdma_is_port_valid(device, port_num))
11681167
return -EINVAL;
11691168

1170-
read_lock_irqsave(&device->cache.lock, flags);
1169+
read_lock_irqsave(&device->cache_lock, flags);
11711170
*port_state = device->port_data[port_num].cache.port_state;
1172-
read_unlock_irqrestore(&device->cache.lock, flags);
1171+
read_unlock_irqrestore(&device->cache_lock, flags);
11731172

11741173
return ret;
11751174
}
@@ -1381,21 +1380,20 @@ static int config_non_roce_gid_cache(struct ib_device *device,
13811380
return ret;
13821381
}
13831382

1384-
static void ib_cache_update(struct ib_device *device,
1385-
u8 port,
1386-
bool enforce_security)
1383+
static int
1384+
ib_cache_update(struct ib_device *device, u8 port, bool enforce_security)
13871385
{
13881386
struct ib_port_attr *tprops = NULL;
13891387
struct ib_pkey_cache *pkey_cache = NULL, *old_pkey_cache;
13901388
int i;
13911389
int ret;
13921390

13931391
if (!rdma_is_port_valid(device, port))
1394-
return;
1392+
return -EINVAL;
13951393

13961394
tprops = kmalloc(sizeof *tprops, GFP_KERNEL);
13971395
if (!tprops)
1398-
return;
1396+
return -ENOMEM;
13991397

14001398
ret = ib_query_port(device, port, tprops);
14011399
if (ret) {
@@ -1413,8 +1411,10 @@ static void ib_cache_update(struct ib_device *device,
14131411
pkey_cache = kmalloc(struct_size(pkey_cache, table,
14141412
tprops->pkey_tbl_len),
14151413
GFP_KERNEL);
1416-
if (!pkey_cache)
1414+
if (!pkey_cache) {
1415+
ret = -ENOMEM;
14171416
goto err;
1417+
}
14181418

14191419
pkey_cache->table_len = tprops->pkey_tbl_len;
14201420

@@ -1428,7 +1428,7 @@ static void ib_cache_update(struct ib_device *device,
14281428
}
14291429
}
14301430

1431-
write_lock_irq(&device->cache.lock);
1431+
write_lock_irq(&device->cache_lock);
14321432

14331433
old_pkey_cache = device->port_data[port].cache.pkey;
14341434

@@ -1437,7 +1437,7 @@ static void ib_cache_update(struct ib_device *device,
14371437
device->port_data[port].cache.port_state = tprops->state;
14381438

14391439
device->port_data[port].cache.subnet_prefix = tprops->subnet_prefix;
1440-
write_unlock_irq(&device->cache.lock);
1440+
write_unlock_irq(&device->cache_lock);
14411441

14421442
if (enforce_security)
14431443
ib_security_cache_change(device,
@@ -1446,57 +1446,91 @@ static void ib_cache_update(struct ib_device *device,
14461446

14471447
kfree(old_pkey_cache);
14481448
kfree(tprops);
1449-
return;
1449+
return 0;
14501450

14511451
err:
14521452
kfree(pkey_cache);
14531453
kfree(tprops);
1454+
return ret;
1455+
}
1456+
1457+
static void ib_cache_event_task(struct work_struct *_work)
1458+
{
1459+
struct ib_update_work *work =
1460+
container_of(_work, struct ib_update_work, work);
1461+
int ret;
1462+
1463+
/* Before distributing the cache update event, first sync
1464+
* the cache.
1465+
*/
1466+
ret = ib_cache_update(work->event.device, work->event.element.port_num,
1467+
work->enforce_security);
1468+
1469+
/* GID event is notified already for individual GID entries by
1470+
* dispatch_gid_change_event(). Hence, notifiy for rest of the
1471+
* events.
1472+
*/
1473+
if (!ret && work->event.event != IB_EVENT_GID_CHANGE)
1474+
ib_dispatch_event_clients(&work->event);
1475+
1476+
kfree(work);
14541477
}
14551478

1456-
static void ib_cache_task(struct work_struct *_work)
1479+
static void ib_generic_event_task(struct work_struct *_work)
14571480
{
14581481
struct ib_update_work *work =
14591482
container_of(_work, struct ib_update_work, work);
14601483

1461-
ib_cache_update(work->device,
1462-
work->port_num,
1463-
work->enforce_security);
1484+
ib_dispatch_event_clients(&work->event);
14641485
kfree(work);
14651486
}
14661487

1467-
static void ib_cache_event(struct ib_event_handler *handler,
1468-
struct ib_event *event)
1488+
static bool is_cache_update_event(const struct ib_event *event)
1489+
{
1490+
return (event->event == IB_EVENT_PORT_ERR ||
1491+
event->event == IB_EVENT_PORT_ACTIVE ||
1492+
event->event == IB_EVENT_LID_CHANGE ||
1493+
event->event == IB_EVENT_PKEY_CHANGE ||
1494+
event->event == IB_EVENT_CLIENT_REREGISTER ||
1495+
event->event == IB_EVENT_GID_CHANGE);
1496+
}
1497+
1498+
/**
1499+
* ib_dispatch_event - Dispatch an asynchronous event
1500+
* @event:Event to dispatch
1501+
*
1502+
* Low-level drivers must call ib_dispatch_event() to dispatch the
1503+
* event to all registered event handlers when an asynchronous event
1504+
* occurs.
1505+
*/
1506+
void ib_dispatch_event(const struct ib_event *event)
14691507
{
14701508
struct ib_update_work *work;
14711509

1472-
if (event->event == IB_EVENT_PORT_ERR ||
1473-
event->event == IB_EVENT_PORT_ACTIVE ||
1474-
event->event == IB_EVENT_LID_CHANGE ||
1475-
event->event == IB_EVENT_PKEY_CHANGE ||
1476-
event->event == IB_EVENT_CLIENT_REREGISTER ||
1477-
event->event == IB_EVENT_GID_CHANGE) {
1478-
work = kmalloc(sizeof *work, GFP_ATOMIC);
1479-
if (work) {
1480-
INIT_WORK(&work->work, ib_cache_task);
1481-
work->device = event->device;
1482-
work->port_num = event->element.port_num;
1483-
if (event->event == IB_EVENT_PKEY_CHANGE ||
1484-
event->event == IB_EVENT_GID_CHANGE)
1485-
work->enforce_security = true;
1486-
else
1487-
work->enforce_security = false;
1488-
1489-
queue_work(ib_wq, &work->work);
1490-
}
1491-
}
1510+
work = kzalloc(sizeof(*work), GFP_ATOMIC);
1511+
if (!work)
1512+
return;
1513+
1514+
if (is_cache_update_event(event))
1515+
INIT_WORK(&work->work, ib_cache_event_task);
1516+
else
1517+
INIT_WORK(&work->work, ib_generic_event_task);
1518+
1519+
work->event = *event;
1520+
if (event->event == IB_EVENT_PKEY_CHANGE ||
1521+
event->event == IB_EVENT_GID_CHANGE)
1522+
work->enforce_security = true;
1523+
1524+
queue_work(ib_wq, &work->work);
14921525
}
1526+
EXPORT_SYMBOL(ib_dispatch_event);
14931527

14941528
int ib_cache_setup_one(struct ib_device *device)
14951529
{
14961530
unsigned int p;
14971531
int err;
14981532

1499-
rwlock_init(&device->cache.lock);
1533+
rwlock_init(&device->cache_lock);
15001534

15011535
err = gid_table_setup_one(device);
15021536
if (err)
@@ -1505,9 +1539,6 @@ int ib_cache_setup_one(struct ib_device *device)
15051539
rdma_for_each_port (device, p)
15061540
ib_cache_update(device, p, true);
15071541

1508-
INIT_IB_EVENT_HANDLER(&device->cache.event_handler,
1509-
device, ib_cache_event);
1510-
ib_register_event_handler(&device->cache.event_handler);
15111542
return 0;
15121543
}
15131544

@@ -1529,14 +1560,12 @@ void ib_cache_release_one(struct ib_device *device)
15291560

15301561
void ib_cache_cleanup_one(struct ib_device *device)
15311562
{
1532-
/* The cleanup function unregisters the event handler,
1533-
* waits for all in-progress workqueue elements and cleans
1534-
* up the GID cache. This function should be called after
1535-
* the device was removed from the devices list and all
1536-
* clients were removed, so the cache exists but is
1563+
/* The cleanup function waits for all in-progress workqueue
1564+
* elements and cleans up the GID cache. This function should be
1565+
* called after the device was removed from the devices list and
1566+
* all clients were removed, so the cache exists but is
15371567
* non-functional and shouldn't be updated anymore.
15381568
*/
1539-
ib_unregister_event_handler(&device->cache.event_handler);
15401569
flush_workqueue(ib_wq);
15411570
gid_table_cleanup_one(device);
15421571

0 commit comments

Comments
 (0)