Skip to content

Commit 2a163a4

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: "Seveal fixes scattered across the drivers and a few new features: - Minor updates and bug fixes to hfi1, efa, iopob, bnxt, hns - Force disassociate the userspace FD when hns does an async reset - bnxt new features for optimized modify QP to skip certain stayes, CQ coalescing, better debug dumping - mlx5 new data placement ordering feature - Faster destruction of mlx5 devx HW objects - Improvements to RDMA CM mad handling" * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: (51 commits) RDMA/bnxt_re: Correct the sequence of device suspend RDMA/bnxt_re: Use the default mode of congestion control RDMA/bnxt_re: Support different traffic class IB/cm: Rework sending DREQ when destroying a cm_id IB/cm: Do not hold reference on cm_id unless needed IB/cm: Explicitly mark if a response MAD is a retransmission RDMA/mlx5: Move events notifier registration to be after device registration RDMA/bnxt_re: Cache MSIx info to a local structure RDMA/bnxt_re: Refurbish CQ to NQ hash calculation RDMA/bnxt_re: Refactor NQ allocation RDMA/bnxt_re: Fail probe early when not enough MSI-x vectors are reserved RDMA/hns: Fix different dgids mapping to the same dip_idx RDMA/bnxt_re: Add set_func_resources support for P5/P7 adapters RDMA/bnxt_re: Enhance RoCE SRIOV resource configuration design bnxt_en: Add support for RoCE sriov configuration RDMA/hns: Fix NULL pointer derefernce in hns_roce_map_mr_sg() RDMA/hns: Fix out-of-order issue of requester when setting FENCE RDMA/nldev: Add IB device and net device rename events RDMA/mlx5: Add implementation for ufile_hw_cleanup device operation RDMA/core: Move ib_uverbs_file struct to uverbs_types.h ...
2 parents ceba6f6 + 68b3bca commit 2a163a4

Some content is hidden

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

63 files changed

+1977
-499
lines changed

drivers/infiniband/core/cm.c

Lines changed: 87 additions & 83 deletions
Large diffs are not rendered by default.

drivers/infiniband/core/device.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ int ib_device_rename(struct ib_device *ibdev, const char *name)
437437
client->rename(ibdev, client_data);
438438
}
439439
up_read(&ibdev->client_data_rwsem);
440+
rdma_nl_notify_event(ibdev, 0, RDMA_RENAME_EVENT);
440441
up_read(&devices_rwsem);
441442
return 0;
442443
}
@@ -2759,6 +2760,7 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)
27592760
SET_DEVICE_OP(dev_ops, resize_cq);
27602761
SET_DEVICE_OP(dev_ops, set_vf_guid);
27612762
SET_DEVICE_OP(dev_ops, set_vf_link_state);
2763+
SET_DEVICE_OP(dev_ops, ufile_hw_cleanup);
27622764

27632765
SET_OBJ_SIZE(dev_ops, ib_ah);
27642766
SET_OBJ_SIZE(dev_ops, ib_counters);
@@ -2852,6 +2854,40 @@ static const struct rdma_nl_cbs ibnl_ls_cb_table[RDMA_NL_LS_NUM_OPS] = {
28522854
},
28532855
};
28542856

2857+
static int ib_netdevice_event(struct notifier_block *this,
2858+
unsigned long event, void *ptr)
2859+
{
2860+
struct net_device *ndev = netdev_notifier_info_to_dev(ptr);
2861+
struct net_device *ib_ndev;
2862+
struct ib_device *ibdev;
2863+
u32 port;
2864+
2865+
switch (event) {
2866+
case NETDEV_CHANGENAME:
2867+
ibdev = ib_device_get_by_netdev(ndev, RDMA_DRIVER_UNKNOWN);
2868+
if (!ibdev)
2869+
return NOTIFY_DONE;
2870+
2871+
rdma_for_each_port(ibdev, port) {
2872+
ib_ndev = ib_device_get_netdev(ibdev, port);
2873+
if (ndev == ib_ndev)
2874+
rdma_nl_notify_event(ibdev, port,
2875+
RDMA_NETDEV_RENAME_EVENT);
2876+
dev_put(ib_ndev);
2877+
}
2878+
ib_device_put(ibdev);
2879+
break;
2880+
default:
2881+
break;
2882+
}
2883+
2884+
return NOTIFY_DONE;
2885+
}
2886+
2887+
static struct notifier_block nb_netdevice = {
2888+
.notifier_call = ib_netdevice_event,
2889+
};
2890+
28552891
static int __init ib_core_init(void)
28562892
{
28572893
int ret = -ENOMEM;
@@ -2923,6 +2959,8 @@ static int __init ib_core_init(void)
29232959
goto err_parent;
29242960
}
29252961

2962+
register_netdevice_notifier(&nb_netdevice);
2963+
29262964
return 0;
29272965

29282966
err_parent:
@@ -2952,6 +2990,7 @@ static int __init ib_core_init(void)
29522990

29532991
static void __exit ib_core_cleanup(void)
29542992
{
2993+
unregister_netdevice_notifier(&nb_netdevice);
29552994
roce_gid_mgmt_cleanup();
29562995
rdma_nl_unregister(RDMA_NL_LS);
29572996
nldev_exit();

drivers/infiniband/core/nldev.c

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2729,6 +2729,25 @@ static const struct rdma_nl_cbs nldev_cb_table[RDMA_NLDEV_NUM_OPS] = {
27292729
},
27302730
};
27312731

2732+
static int fill_mon_netdev_rename(struct sk_buff *msg,
2733+
struct ib_device *device, u32 port,
2734+
const struct net *net)
2735+
{
2736+
struct net_device *netdev = ib_device_get_netdev(device, port);
2737+
int ret = 0;
2738+
2739+
if (!netdev || !net_eq(dev_net(netdev), net))
2740+
goto out;
2741+
2742+
ret = nla_put_u32(msg, RDMA_NLDEV_ATTR_NDEV_INDEX, netdev->ifindex);
2743+
if (ret)
2744+
goto out;
2745+
ret = nla_put_string(msg, RDMA_NLDEV_ATTR_NDEV_NAME, netdev->name);
2746+
out:
2747+
dev_put(netdev);
2748+
return ret;
2749+
}
2750+
27322751
static int fill_mon_netdev_association(struct sk_buff *msg,
27332752
struct ib_device *device, u32 port,
27342753
const struct net *net)
@@ -2793,6 +2812,18 @@ static void rdma_nl_notify_err_msg(struct ib_device *device, u32 port_num,
27932812
"Failed to send RDMA monitor netdev detach event: port %d\n",
27942813
port_num);
27952814
break;
2815+
case RDMA_RENAME_EVENT:
2816+
dev_warn_ratelimited(&device->dev,
2817+
"Failed to send RDMA monitor rename device event\n");
2818+
break;
2819+
2820+
case RDMA_NETDEV_RENAME_EVENT:
2821+
netdev = ib_device_get_netdev(device, port_num);
2822+
dev_warn_ratelimited(&device->dev,
2823+
"Failed to send RDMA monitor netdev rename event: port %d netdev %d\n",
2824+
port_num, netdev->ifindex);
2825+
dev_put(netdev);
2826+
break;
27962827
default:
27972828
break;
27982829
}
@@ -2822,14 +2853,19 @@ int rdma_nl_notify_event(struct ib_device *device, u32 port_num,
28222853
switch (type) {
28232854
case RDMA_REGISTER_EVENT:
28242855
case RDMA_UNREGISTER_EVENT:
2856+
case RDMA_RENAME_EVENT:
28252857
ret = fill_nldev_handle(skb, device);
28262858
if (ret)
28272859
goto err_free;
28282860
break;
28292861
case RDMA_NETDEV_ATTACH_EVENT:
28302862
case RDMA_NETDEV_DETACH_EVENT:
2831-
ret = fill_mon_netdev_association(skb, device,
2832-
port_num, net);
2863+
ret = fill_mon_netdev_association(skb, device, port_num, net);
2864+
if (ret)
2865+
goto err_free;
2866+
break;
2867+
case RDMA_NETDEV_RENAME_EVENT:
2868+
ret = fill_mon_netdev_rename(skb, device, port_num, net);
28332869
if (ret)
28342870
goto err_free;
28352871
break;

drivers/infiniband/core/rdma_core.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ void uverbs_uobject_put(struct ib_uobject *uobject)
5858
}
5959
EXPORT_SYMBOL(uverbs_uobject_put);
6060

61-
static int uverbs_try_lock_object(struct ib_uobject *uobj,
62-
enum rdma_lookup_mode mode)
61+
int uverbs_try_lock_object(struct ib_uobject *uobj,
62+
enum rdma_lookup_mode mode)
6363
{
6464
/*
6565
* When a shared access is required, we use a positive counter. Each
@@ -84,6 +84,7 @@ static int uverbs_try_lock_object(struct ib_uobject *uobj,
8484
}
8585
return 0;
8686
}
87+
EXPORT_SYMBOL(uverbs_try_lock_object);
8788

8889
static void assert_uverbs_usecnt(struct ib_uobject *uobj,
8990
enum rdma_lookup_mode mode)
@@ -880,9 +881,14 @@ static void ufile_destroy_ucontext(struct ib_uverbs_file *ufile,
880881
static int __uverbs_cleanup_ufile(struct ib_uverbs_file *ufile,
881882
enum rdma_remove_reason reason)
882883
{
884+
struct uverbs_attr_bundle attrs = { .ufile = ufile };
885+
struct ib_ucontext *ucontext = ufile->ucontext;
886+
struct ib_device *ib_dev = ucontext->device;
883887
struct ib_uobject *obj, *next_obj;
884888
int ret = -EINVAL;
885-
struct uverbs_attr_bundle attrs = { .ufile = ufile };
889+
890+
if (ib_dev->ops.ufile_hw_cleanup)
891+
ib_dev->ops.ufile_hw_cleanup(ufile);
886892

887893
/*
888894
* This shouldn't run while executing other commands on this

drivers/infiniband/core/roce_gid_mgmt.c

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,27 @@ void rdma_roce_rescan_device(struct ib_device *ib_dev)
515515
}
516516
EXPORT_SYMBOL(rdma_roce_rescan_device);
517517

518+
/**
519+
* rdma_roce_rescan_port - Rescan all of the network devices in the system
520+
* and add their gids if relevant to the port of the RoCE device.
521+
*
522+
* @ib_dev: IB device
523+
* @port: Port number
524+
*/
525+
void rdma_roce_rescan_port(struct ib_device *ib_dev, u32 port)
526+
{
527+
struct net_device *ndev = NULL;
528+
529+
if (rdma_protocol_roce(ib_dev, port)) {
530+
ndev = ib_device_get_netdev(ib_dev, port);
531+
if (!ndev)
532+
return;
533+
enum_all_gids_of_dev_cb(ib_dev, port, ndev, ndev);
534+
dev_put(ndev);
535+
}
536+
}
537+
EXPORT_SYMBOL(rdma_roce_rescan_port);
538+
518539
static void callback_for_addr_gid_device_scan(struct ib_device *device,
519540
u32 port,
520541
struct net_device *rdma_ndev,
@@ -575,16 +596,17 @@ static void handle_netdev_upper(struct ib_device *ib_dev, u32 port,
575596
}
576597
}
577598

578-
static void _roce_del_all_netdev_gids(struct ib_device *ib_dev, u32 port,
579-
struct net_device *event_ndev)
599+
void roce_del_all_netdev_gids(struct ib_device *ib_dev,
600+
u32 port, struct net_device *ndev)
580601
{
581-
ib_cache_gid_del_all_netdev_gids(ib_dev, port, event_ndev);
602+
ib_cache_gid_del_all_netdev_gids(ib_dev, port, ndev);
582603
}
604+
EXPORT_SYMBOL(roce_del_all_netdev_gids);
583605

584606
static void del_netdev_upper_ips(struct ib_device *ib_dev, u32 port,
585607
struct net_device *rdma_ndev, void *cookie)
586608
{
587-
handle_netdev_upper(ib_dev, port, cookie, _roce_del_all_netdev_gids);
609+
handle_netdev_upper(ib_dev, port, cookie, roce_del_all_netdev_gids);
588610
}
589611

590612
static void add_netdev_upper_ips(struct ib_device *ib_dev, u32 port,

drivers/infiniband/core/uverbs.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -133,35 +133,6 @@ struct ib_uverbs_completion_event_file {
133133
struct ib_uverbs_event_queue ev_queue;
134134
};
135135

136-
struct ib_uverbs_file {
137-
struct kref ref;
138-
struct ib_uverbs_device *device;
139-
struct mutex ucontext_lock;
140-
/*
141-
* ucontext must be accessed via ib_uverbs_get_ucontext() or with
142-
* ucontext_lock held
143-
*/
144-
struct ib_ucontext *ucontext;
145-
struct ib_uverbs_async_event_file *default_async_file;
146-
struct list_head list;
147-
148-
/*
149-
* To access the uobjects list hw_destroy_rwsem must be held for write
150-
* OR hw_destroy_rwsem held for read AND uobjects_lock held.
151-
* hw_destroy_rwsem should be called across any destruction of the HW
152-
* object of an associated uobject.
153-
*/
154-
struct rw_semaphore hw_destroy_rwsem;
155-
spinlock_t uobjects_lock;
156-
struct list_head uobjects;
157-
158-
struct mutex umap_lock;
159-
struct list_head umaps;
160-
struct page *disassociate_page;
161-
162-
struct xarray idr;
163-
};
164-
165136
struct ib_uverbs_event {
166137
union {
167138
struct ib_uverbs_async_event_desc async;

drivers/infiniband/core/uverbs_main.c

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ static dev_t dynamic_uverbs_dev;
7676
static DEFINE_IDA(uverbs_ida);
7777
static int ib_uverbs_add_one(struct ib_device *device);
7878
static void ib_uverbs_remove_one(struct ib_device *device, void *client_data);
79+
static struct ib_client uverbs_client;
7980

8081
static char *uverbs_devnode(const struct device *dev, umode_t *mode)
8182
{
@@ -217,6 +218,7 @@ void ib_uverbs_release_file(struct kref *ref)
217218

218219
if (file->disassociate_page)
219220
__free_pages(file->disassociate_page, 0);
221+
mutex_destroy(&file->disassociation_lock);
220222
mutex_destroy(&file->umap_lock);
221223
mutex_destroy(&file->ucontext_lock);
222224
kfree(file);
@@ -698,8 +700,13 @@ static int ib_uverbs_mmap(struct file *filp, struct vm_area_struct *vma)
698700
ret = PTR_ERR(ucontext);
699701
goto out;
700702
}
703+
704+
mutex_lock(&file->disassociation_lock);
705+
701706
vma->vm_ops = &rdma_umap_ops;
702707
ret = ucontext->device->ops.mmap(ucontext, vma);
708+
709+
mutex_unlock(&file->disassociation_lock);
703710
out:
704711
srcu_read_unlock(&file->device->disassociate_srcu, srcu_key);
705712
return ret;
@@ -721,6 +728,8 @@ static void rdma_umap_open(struct vm_area_struct *vma)
721728
/* We are racing with disassociation */
722729
if (!down_read_trylock(&ufile->hw_destroy_rwsem))
723730
goto out_zap;
731+
mutex_lock(&ufile->disassociation_lock);
732+
724733
/*
725734
* Disassociation already completed, the VMA should already be zapped.
726735
*/
@@ -732,10 +741,12 @@ static void rdma_umap_open(struct vm_area_struct *vma)
732741
goto out_unlock;
733742
rdma_umap_priv_init(priv, vma, opriv->entry);
734743

744+
mutex_unlock(&ufile->disassociation_lock);
735745
up_read(&ufile->hw_destroy_rwsem);
736746
return;
737747

738748
out_unlock:
749+
mutex_unlock(&ufile->disassociation_lock);
739750
up_read(&ufile->hw_destroy_rwsem);
740751
out_zap:
741752
/*
@@ -819,7 +830,7 @@ void uverbs_user_mmap_disassociate(struct ib_uverbs_file *ufile)
819830
{
820831
struct rdma_umap_priv *priv, *next_priv;
821832

822-
lockdep_assert_held(&ufile->hw_destroy_rwsem);
833+
mutex_lock(&ufile->disassociation_lock);
823834

824835
while (1) {
825836
struct mm_struct *mm = NULL;
@@ -845,8 +856,10 @@ void uverbs_user_mmap_disassociate(struct ib_uverbs_file *ufile)
845856
break;
846857
}
847858
mutex_unlock(&ufile->umap_lock);
848-
if (!mm)
859+
if (!mm) {
860+
mutex_unlock(&ufile->disassociation_lock);
849861
return;
862+
}
850863

851864
/*
852865
* The umap_lock is nested under mmap_lock since it used within
@@ -876,7 +889,31 @@ void uverbs_user_mmap_disassociate(struct ib_uverbs_file *ufile)
876889
mmap_read_unlock(mm);
877890
mmput(mm);
878891
}
892+
893+
mutex_unlock(&ufile->disassociation_lock);
894+
}
895+
896+
/**
897+
* rdma_user_mmap_disassociate() - Revoke mmaps for a device
898+
* @device: device to revoke
899+
*
900+
* This function should be called by drivers that need to disable mmaps for the
901+
* device, for instance because it is going to be reset.
902+
*/
903+
void rdma_user_mmap_disassociate(struct ib_device *device)
904+
{
905+
struct ib_uverbs_device *uverbs_dev =
906+
ib_get_client_data(device, &uverbs_client);
907+
struct ib_uverbs_file *ufile;
908+
909+
mutex_lock(&uverbs_dev->lists_mutex);
910+
list_for_each_entry(ufile, &uverbs_dev->uverbs_file_list, list) {
911+
if (ufile->ucontext)
912+
uverbs_user_mmap_disassociate(ufile);
913+
}
914+
mutex_unlock(&uverbs_dev->lists_mutex);
879915
}
916+
EXPORT_SYMBOL(rdma_user_mmap_disassociate);
880917

881918
/*
882919
* ib_uverbs_open() does not need the BKL:
@@ -947,6 +984,8 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp)
947984
mutex_init(&file->umap_lock);
948985
INIT_LIST_HEAD(&file->umaps);
949986

987+
mutex_init(&file->disassociation_lock);
988+
950989
filp->private_data = file;
951990
list_add_tail(&file->list, &dev->uverbs_file_list);
952991
mutex_unlock(&dev->lists_mutex);

drivers/infiniband/hw/bnxt_re/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ ccflags-y := -I $(srctree)/drivers/net/ethernet/broadcom/bnxt
44
obj-$(CONFIG_INFINIBAND_BNXT_RE) += bnxt_re.o
55
bnxt_re-y := main.o ib_verbs.o \
66
qplib_res.o qplib_rcfw.o \
7-
qplib_sp.o qplib_fp.o hw_counters.o
7+
qplib_sp.o qplib_fp.o hw_counters.o \
8+
debugfs.o

0 commit comments

Comments
 (0)