Skip to content

Commit 009bd55

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 smaller set of patches, nothing stands out as being particularly major this cycle. The biggest item would be the new HIP09 HW support from HNS, otherwise it was pretty quiet for new work here: - Driver bug fixes and updates: bnxt_re, cxgb4, rxe, hns, i40iw, cxgb4, mlx4 and mlx5 - Bug fixes and polishing for the new rts ULP - Cleanup of uverbs checking for allowed driver operations - Use sysfs_emit all over the place - Lots of bug fixes and clarity improvements for hns - hip09 support for hns - NDR and 50/100Gb signaling rates - Remove dma_virt_ops and go back to using the IB DMA wrappers - mlx5 optimizations for contiguous DMA regions" * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: (147 commits) RDMA/cma: Don't overwrite sgid_attr after device is released RDMA/mlx5: Fix MR cache memory leak RDMA/rxe: Use acquire/release for memory ordering RDMA/hns: Simplify AEQE process for different types of queue RDMA/hns: Fix inaccurate prints RDMA/hns: Fix incorrect symbol types RDMA/hns: Clear redundant variable initialization RDMA/hns: Fix coding style issues RDMA/hns: Remove unnecessary access right set during INIT2INIT RDMA/hns: WARN_ON if get a reserved sl from users RDMA/hns: Avoid filling sl in high 3 bits of vlan_id RDMA/hns: Do shift on traffic class when using RoCEv2 RDMA/hns: Normalization the judgment of some features RDMA/hns: Limit the length of data copied between kernel and userspace RDMA/mlx4: Remove bogus dev_base_lock usage RDMA/uverbs: Fix incorrect variable type RDMA/core: Do not indicate device ready when device enablement fails RDMA/core: Clean up cq pool mechanism RDMA/core: Update kernel documentation for ib_create_named_qp() MAINTAINERS: SOFT-ROCE: Change Zhu Yanjun's email address ...
2 parents 60f7c50 + e246b7c commit 009bd55

File tree

175 files changed

+3845
-3915
lines changed

Some content is hidden

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

175 files changed

+3845
-3915
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,3 +345,4 @@ Wolfram Sang <[email protected]> <[email protected]>
345345
346346
347347
Yusuke Goda <[email protected]>
348+

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16399,7 +16399,7 @@ F: drivers/infiniband/sw/siw/
1639916399
F: include/uapi/rdma/siw-abi.h
1640016400

1640116401
SOFT-ROCE DRIVER (rxe)
16402-
M: Zhu Yanjun <yanjunz@nvidia.com>
16402+
M: Zhu Yanjun <zyjzyj2000@gmail.com>
1640316403
1640416404
S: Supported
1640516405
F: drivers/infiniband/sw/rxe/

drivers/infiniband/core/cm.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,8 @@ int ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id, __be64 service_mask)
12511251
EXPORT_SYMBOL(ib_cm_listen);
12521252

12531253
/**
1254-
* Create a new listening ib_cm_id and listen on the given service ID.
1254+
* ib_cm_insert_listen - Create a new listening ib_cm_id and listen on
1255+
* the given service ID.
12551256
*
12561257
* If there's an existing ID listening on that same device and service ID,
12571258
* return it.
@@ -1765,7 +1766,7 @@ static u16 cm_get_bth_pkey(struct cm_work *work)
17651766
}
17661767

17671768
/**
1768-
* Convert OPA SGID to IB SGID
1769+
* cm_opa_to_ib_sgid - Convert OPA SGID to IB SGID
17691770
* ULPs (such as IPoIB) do not understand OPA GIDs and will
17701771
* reject them as the local_gid will not match the sgid. Therefore,
17711772
* change the pathrec's SGID to an IB SGID.
@@ -4273,8 +4274,8 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
42734274
group = container_of(obj, struct cm_counter_group, obj);
42744275
cm_attr = container_of(attr, struct cm_counter_attribute, attr);
42754276

4276-
return sprintf(buf, "%ld\n",
4277-
atomic_long_read(&group->counter[cm_attr->index]));
4277+
return sysfs_emit(buf, "%ld\n",
4278+
atomic_long_read(&group->counter[cm_attr->index]));
42784279
}
42794280

42804281
static const struct sysfs_ops cm_counter_ops = {

drivers/infiniband/core/cma.c

Lines changed: 117 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,10 @@ static void cma_release_dev(struct rdma_id_private *id_priv)
477477
list_del(&id_priv->list);
478478
cma_dev_put(id_priv->cma_dev);
479479
id_priv->cma_dev = NULL;
480+
if (id_priv->id.route.addr.dev_addr.sgid_attr) {
481+
rdma_put_gid_attr(id_priv->id.route.addr.dev_addr.sgid_attr);
482+
id_priv->id.route.addr.dev_addr.sgid_attr = NULL;
483+
}
480484
mutex_unlock(&lock);
481485
}
482486

@@ -1861,9 +1865,6 @@ static void _destroy_id(struct rdma_id_private *id_priv,
18611865

18621866
kfree(id_priv->id.route.path_rec);
18631867

1864-
if (id_priv->id.route.addr.dev_addr.sgid_attr)
1865-
rdma_put_gid_attr(id_priv->id.route.addr.dev_addr.sgid_attr);
1866-
18671868
put_net(id_priv->id.route.addr.dev_addr.net);
18681869
rdma_restrack_del(&id_priv->res);
18691870
kfree(id_priv);
@@ -2495,30 +2496,31 @@ static int cma_listen_handler(struct rdma_cm_id *id,
24952496
return id_priv->id.event_handler(id, event);
24962497
}
24972498

2498-
static void cma_listen_on_dev(struct rdma_id_private *id_priv,
2499-
struct cma_device *cma_dev)
2499+
static int cma_listen_on_dev(struct rdma_id_private *id_priv,
2500+
struct cma_device *cma_dev,
2501+
struct rdma_id_private **to_destroy)
25002502
{
25012503
struct rdma_id_private *dev_id_priv;
25022504
struct net *net = id_priv->id.route.addr.dev_addr.net;
25032505
int ret;
25042506

25052507
lockdep_assert_held(&lock);
25062508

2509+
*to_destroy = NULL;
25072510
if (cma_family(id_priv) == AF_IB && !rdma_cap_ib_cm(cma_dev->device, 1))
2508-
return;
2511+
return 0;
25092512

25102513
dev_id_priv =
25112514
__rdma_create_id(net, cma_listen_handler, id_priv,
25122515
id_priv->id.ps, id_priv->id.qp_type, id_priv);
25132516
if (IS_ERR(dev_id_priv))
2514-
return;
2517+
return PTR_ERR(dev_id_priv);
25152518

25162519
dev_id_priv->state = RDMA_CM_ADDR_BOUND;
25172520
memcpy(cma_src_addr(dev_id_priv), cma_src_addr(id_priv),
25182521
rdma_addr_size(cma_src_addr(id_priv)));
25192522

25202523
_cma_attach_to_dev(dev_id_priv, cma_dev);
2521-
list_add_tail(&dev_id_priv->listen_list, &id_priv->listen_list);
25222524
cma_id_get(id_priv);
25232525
dev_id_priv->internal_id = 1;
25242526
dev_id_priv->afonly = id_priv->afonly;
@@ -2527,19 +2529,42 @@ static void cma_listen_on_dev(struct rdma_id_private *id_priv,
25272529

25282530
ret = rdma_listen(&dev_id_priv->id, id_priv->backlog);
25292531
if (ret)
2530-
dev_warn(&cma_dev->device->dev,
2531-
"RDMA CMA: cma_listen_on_dev, error %d\n", ret);
2532+
goto err_listen;
2533+
list_add_tail(&dev_id_priv->listen_list, &id_priv->listen_list);
2534+
return 0;
2535+
err_listen:
2536+
/* Caller must destroy this after releasing lock */
2537+
*to_destroy = dev_id_priv;
2538+
dev_warn(&cma_dev->device->dev, "RDMA CMA: %s, error %d\n", __func__, ret);
2539+
return ret;
25322540
}
25332541

2534-
static void cma_listen_on_all(struct rdma_id_private *id_priv)
2542+
static int cma_listen_on_all(struct rdma_id_private *id_priv)
25352543
{
2544+
struct rdma_id_private *to_destroy;
25362545
struct cma_device *cma_dev;
2546+
int ret;
25372547

25382548
mutex_lock(&lock);
25392549
list_add_tail(&id_priv->list, &listen_any_list);
2540-
list_for_each_entry(cma_dev, &dev_list, list)
2541-
cma_listen_on_dev(id_priv, cma_dev);
2550+
list_for_each_entry(cma_dev, &dev_list, list) {
2551+
ret = cma_listen_on_dev(id_priv, cma_dev, &to_destroy);
2552+
if (ret) {
2553+
/* Prevent racing with cma_process_remove() */
2554+
if (to_destroy)
2555+
list_del_init(&to_destroy->list);
2556+
goto err_listen;
2557+
}
2558+
}
25422559
mutex_unlock(&lock);
2560+
return 0;
2561+
2562+
err_listen:
2563+
list_del(&id_priv->list);
2564+
mutex_unlock(&lock);
2565+
if (to_destroy)
2566+
rdma_destroy_id(&to_destroy->id);
2567+
return ret;
25432568
}
25442569

25452570
void rdma_set_service_type(struct rdma_cm_id *id, int tos)
@@ -3692,8 +3717,11 @@ int rdma_listen(struct rdma_cm_id *id, int backlog)
36923717
ret = -ENOSYS;
36933718
goto err;
36943719
}
3695-
} else
3696-
cma_listen_on_all(id_priv);
3720+
} else {
3721+
ret = cma_listen_on_all(id_priv);
3722+
if (ret)
3723+
goto err;
3724+
}
36973725

36983726
return 0;
36993727
err:
@@ -4773,69 +4801,6 @@ static struct notifier_block cma_nb = {
47734801
.notifier_call = cma_netdev_callback
47744802
};
47754803

4776-
static int cma_add_one(struct ib_device *device)
4777-
{
4778-
struct cma_device *cma_dev;
4779-
struct rdma_id_private *id_priv;
4780-
unsigned int i;
4781-
unsigned long supported_gids = 0;
4782-
int ret;
4783-
4784-
cma_dev = kmalloc(sizeof *cma_dev, GFP_KERNEL);
4785-
if (!cma_dev)
4786-
return -ENOMEM;
4787-
4788-
cma_dev->device = device;
4789-
cma_dev->default_gid_type = kcalloc(device->phys_port_cnt,
4790-
sizeof(*cma_dev->default_gid_type),
4791-
GFP_KERNEL);
4792-
if (!cma_dev->default_gid_type) {
4793-
ret = -ENOMEM;
4794-
goto free_cma_dev;
4795-
}
4796-
4797-
cma_dev->default_roce_tos = kcalloc(device->phys_port_cnt,
4798-
sizeof(*cma_dev->default_roce_tos),
4799-
GFP_KERNEL);
4800-
if (!cma_dev->default_roce_tos) {
4801-
ret = -ENOMEM;
4802-
goto free_gid_type;
4803-
}
4804-
4805-
rdma_for_each_port (device, i) {
4806-
supported_gids = roce_gid_type_mask_support(device, i);
4807-
WARN_ON(!supported_gids);
4808-
if (supported_gids & (1 << CMA_PREFERRED_ROCE_GID_TYPE))
4809-
cma_dev->default_gid_type[i - rdma_start_port(device)] =
4810-
CMA_PREFERRED_ROCE_GID_TYPE;
4811-
else
4812-
cma_dev->default_gid_type[i - rdma_start_port(device)] =
4813-
find_first_bit(&supported_gids, BITS_PER_LONG);
4814-
cma_dev->default_roce_tos[i - rdma_start_port(device)] = 0;
4815-
}
4816-
4817-
init_completion(&cma_dev->comp);
4818-
refcount_set(&cma_dev->refcount, 1);
4819-
INIT_LIST_HEAD(&cma_dev->id_list);
4820-
ib_set_client_data(device, &cma_client, cma_dev);
4821-
4822-
mutex_lock(&lock);
4823-
list_add_tail(&cma_dev->list, &dev_list);
4824-
list_for_each_entry(id_priv, &listen_any_list, list)
4825-
cma_listen_on_dev(id_priv, cma_dev);
4826-
mutex_unlock(&lock);
4827-
4828-
trace_cm_add_one(device);
4829-
return 0;
4830-
4831-
free_gid_type:
4832-
kfree(cma_dev->default_gid_type);
4833-
4834-
free_cma_dev:
4835-
kfree(cma_dev);
4836-
return ret;
4837-
}
4838-
48394804
static void cma_send_device_removal_put(struct rdma_id_private *id_priv)
48404805
{
48414806
struct rdma_cm_event event = { .event = RDMA_CM_EVENT_DEVICE_REMOVAL };
@@ -4898,6 +4863,80 @@ static void cma_process_remove(struct cma_device *cma_dev)
48984863
wait_for_completion(&cma_dev->comp);
48994864
}
49004865

4866+
static int cma_add_one(struct ib_device *device)
4867+
{
4868+
struct rdma_id_private *to_destroy;
4869+
struct cma_device *cma_dev;
4870+
struct rdma_id_private *id_priv;
4871+
unsigned int i;
4872+
unsigned long supported_gids = 0;
4873+
int ret;
4874+
4875+
cma_dev = kmalloc(sizeof(*cma_dev), GFP_KERNEL);
4876+
if (!cma_dev)
4877+
return -ENOMEM;
4878+
4879+
cma_dev->device = device;
4880+
cma_dev->default_gid_type = kcalloc(device->phys_port_cnt,
4881+
sizeof(*cma_dev->default_gid_type),
4882+
GFP_KERNEL);
4883+
if (!cma_dev->default_gid_type) {
4884+
ret = -ENOMEM;
4885+
goto free_cma_dev;
4886+
}
4887+
4888+
cma_dev->default_roce_tos = kcalloc(device->phys_port_cnt,
4889+
sizeof(*cma_dev->default_roce_tos),
4890+
GFP_KERNEL);
4891+
if (!cma_dev->default_roce_tos) {
4892+
ret = -ENOMEM;
4893+
goto free_gid_type;
4894+
}
4895+
4896+
rdma_for_each_port (device, i) {
4897+
supported_gids = roce_gid_type_mask_support(device, i);
4898+
WARN_ON(!supported_gids);
4899+
if (supported_gids & (1 << CMA_PREFERRED_ROCE_GID_TYPE))
4900+
cma_dev->default_gid_type[i - rdma_start_port(device)] =
4901+
CMA_PREFERRED_ROCE_GID_TYPE;
4902+
else
4903+
cma_dev->default_gid_type[i - rdma_start_port(device)] =
4904+
find_first_bit(&supported_gids, BITS_PER_LONG);
4905+
cma_dev->default_roce_tos[i - rdma_start_port(device)] = 0;
4906+
}
4907+
4908+
init_completion(&cma_dev->comp);
4909+
refcount_set(&cma_dev->refcount, 1);
4910+
INIT_LIST_HEAD(&cma_dev->id_list);
4911+
ib_set_client_data(device, &cma_client, cma_dev);
4912+
4913+
mutex_lock(&lock);
4914+
list_add_tail(&cma_dev->list, &dev_list);
4915+
list_for_each_entry(id_priv, &listen_any_list, list) {
4916+
ret = cma_listen_on_dev(id_priv, cma_dev, &to_destroy);
4917+
if (ret)
4918+
goto free_listen;
4919+
}
4920+
mutex_unlock(&lock);
4921+
4922+
trace_cm_add_one(device);
4923+
return 0;
4924+
4925+
free_listen:
4926+
list_del(&cma_dev->list);
4927+
mutex_unlock(&lock);
4928+
4929+
/* cma_process_remove() will delete to_destroy */
4930+
cma_process_remove(cma_dev);
4931+
kfree(cma_dev->default_roce_tos);
4932+
free_gid_type:
4933+
kfree(cma_dev->default_gid_type);
4934+
4935+
free_cma_dev:
4936+
kfree(cma_dev);
4937+
return ret;
4938+
}
4939+
49014940
static void cma_remove_one(struct ib_device *device, void *client_data)
49024941
{
49034942
struct cma_device *cma_dev = client_data;

drivers/infiniband/core/cma_configfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static ssize_t default_roce_mode_show(struct config_item *item,
115115
if (gid_type < 0)
116116
return gid_type;
117117

118-
return sprintf(buf, "%s\n", ib_cache_gid_type_str(gid_type));
118+
return sysfs_emit(buf, "%s\n", ib_cache_gid_type_str(gid_type));
119119
}
120120

121121
static ssize_t default_roce_mode_store(struct config_item *item,
@@ -157,7 +157,7 @@ static ssize_t default_roce_tos_show(struct config_item *item, char *buf)
157157
tos = cma_get_default_roce_tos(cma_dev, group->port_num);
158158
cma_configfs_params_put(cma_dev);
159159

160-
return sprintf(buf, "%u\n", tos);
160+
return sysfs_emit(buf, "%u\n", tos);
161161
}
162162

163163
static ssize_t default_roce_tos_store(struct config_item *item,

drivers/infiniband/core/core_priv.h

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,12 @@ struct ib_device *ib_device_get_by_index(const struct net *net, u32 index);
318318
void nldev_init(void);
319319
void nldev_exit(void);
320320

321-
static inline struct ib_qp *_ib_create_qp(struct ib_device *dev,
322-
struct ib_pd *pd,
323-
struct ib_qp_init_attr *attr,
324-
struct ib_udata *udata,
325-
struct ib_uqp_object *uobj)
321+
static inline struct ib_qp *
322+
_ib_create_qp(struct ib_device *dev, struct ib_pd *pd,
323+
struct ib_qp_init_attr *attr, struct ib_udata *udata,
324+
struct ib_uqp_object *uobj, const char *caller)
326325
{
327-
enum ib_qp_type qp_type = attr->qp_type;
328326
struct ib_qp *qp;
329-
bool is_xrc;
330327

331328
if (!dev->ops.create_qp)
332329
return ERR_PTR(-EOPNOTSUPP);
@@ -347,23 +344,17 @@ static inline struct ib_qp *_ib_create_qp(struct ib_device *dev,
347344
qp->srq = attr->srq;
348345
qp->rwq_ind_tbl = attr->rwq_ind_tbl;
349346
qp->event_handler = attr->event_handler;
347+
qp->port = attr->port_num;
350348

351349
atomic_set(&qp->usecnt, 0);
352350
spin_lock_init(&qp->mr_lock);
353351
INIT_LIST_HEAD(&qp->rdma_mrs);
354352
INIT_LIST_HEAD(&qp->sig_mrs);
355353

356354
rdma_restrack_new(&qp->res, RDMA_RESTRACK_QP);
357-
/*
358-
* We don't track XRC QPs for now, because they don't have PD
359-
* and more importantly they are created internaly by driver,
360-
* see mlx5 create_dev_resources() as an example.
361-
*/
362-
is_xrc = qp_type == IB_QPT_XRC_INI || qp_type == IB_QPT_XRC_TGT;
363-
if ((qp_type < IB_QPT_MAX && !is_xrc) || qp_type == IB_QPT_DRIVER) {
364-
rdma_restrack_parent_name(&qp->res, &pd->res);
365-
rdma_restrack_add(&qp->res);
366-
}
355+
WARN_ONCE(!udata && !caller, "Missing kernel QP owner");
356+
rdma_restrack_set_name(&qp->res, udata ? NULL : caller);
357+
rdma_restrack_add(&qp->res);
367358
return qp;
368359
}
369360

@@ -411,7 +402,6 @@ void rdma_umap_priv_init(struct rdma_umap_priv *priv,
411402
struct vm_area_struct *vma,
412403
struct rdma_user_mmap_entry *entry);
413404

414-
void ib_cq_pool_init(struct ib_device *dev);
415-
void ib_cq_pool_destroy(struct ib_device *dev);
405+
void ib_cq_pool_cleanup(struct ib_device *dev);
416406

417407
#endif /* _CORE_PRIV_H */

0 commit comments

Comments
 (0)