| ee9aeb31 | 16-Jun-2021 |
Hans Petter Selasky <[email protected]> |
ibcore: Implement ib_uverbs_get_ucontext_file().
Expose ib_ucontext from a given ib_uverbs_file. Drivers that use the ioctl(9) API may have the ib_uverbs_file and need a way to get the related ib_uc
ibcore: Implement ib_uverbs_get_ucontext_file().
Expose ib_ucontext from a given ib_uverbs_file. Drivers that use the ioctl(9) API may have the ib_uverbs_file and need a way to get the related ib_ucontext from it, this is enabled by this patch.
Downstream patches from this series will use it.
Linux commit: 7dc08dcfc8c86cb4457e383734ff6844ddaff876
Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking
(cherry picked from commit 79b817084ca891e465fe1a868ef1d9f1a3f33a69)
show more ...
|
| 11f42801 | 16-Jun-2021 |
Hans Petter Selasky <[email protected]> |
ibcore: Clean up INIT_UDATA() and INIT_UDATA_BUF_OR_NULL() macro usage.
We get a harmless warning about the fact that we use the result of a multiplication as a condition in INIT_UDATA_BUF_OR_NULL()
ibcore: Clean up INIT_UDATA() and INIT_UDATA_BUF_OR_NULL() macro usage.
We get a harmless warning about the fact that we use the result of a multiplication as a condition in INIT_UDATA_BUF_OR_NULL():
uverbs_main.c: In function 'ib_uverbs_write': error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
This avoids the problem by using an inline function in place of the macro.
After changing INIT_UDATA_BUF_OR_NULL() to an inline function, do the same change to INIT_UDATA() for consistency.
Using an inline function gives us better type safety here among other issues with macros. I'm using u64_to_user_ptr() to convert the user pointer to simplify the logic rather than adding lots of new type casts.
Linux commit: 12f727721eee61b3d19dedb95cb893b2baa9fe41 40a203396cc1c239f2e71c47c66ed03097123d2c
Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking
(cherry picked from commit 05f4691919d6d0219795a1ca8ad84dd82d87b1cf)
show more ...
|
| 4c033941 | 16-Jun-2021 |
Hans Petter Selasky <[email protected]> |
ibcore: Support rate limit for packet pacing
Add new member rate_limit to ib_qp_attr which holds the packet pacing rate in kbps, 0 means unlimited.
IB_QP_RATE_LIMIT is added to ib_attr_mask and cou
ibcore: Support rate limit for packet pacing
Add new member rate_limit to ib_qp_attr which holds the packet pacing rate in kbps, 0 means unlimited.
IB_QP_RATE_LIMIT is added to ib_attr_mask and could be used by RAW QPs when changing QP state from RTR to RTS, RTS to RTS.
Linux commit: 528e5a1bd3f0e9b760cb3a1062fce7513712a15d
Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking
(cherry picked from commit 0c13880cccd75655c878ce31e767bce04b1d6e85)
show more ...
|
| d76e6346 | 16-Jun-2021 |
Hans Petter Selasky <[email protected]> |
ibcore: Add new IB rates.
Add the new rates that were added to Infiniband spec as part of HDR and 2x support.
Linux commit: a5a5d1993696419e7d5357fc3128e53d219d382e
Reviewed by: kib Sponsored by:
ibcore: Add new IB rates.
Add the new rates that were added to Infiniband spec as part of HDR and 2x support.
Linux commit: a5a5d1993696419e7d5357fc3128e53d219d382e
Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking
(cherry picked from commit 3d2fb36a9ce72053e8865852caad30044dbd1059)
show more ...
|
| d857bf20 | 16-Jun-2021 |
Hans Petter Selasky <[email protected]> |
ibcore: Don't allocate method table, if already present.
This commit aligns the code in question with upstream Linux.
Linux commit: 2468b82d69e3a53d024f28d79ba0fdb8bf43dfbf
Reviewed by: kib Sponso
ibcore: Don't allocate method table, if already present.
This commit aligns the code in question with upstream Linux.
Linux commit: 2468b82d69e3a53d024f28d79ba0fdb8bf43dfbf
Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking
(cherry picked from commit 721b795b721b349db5e6198f8681d5992447c775)
show more ...
|
| a0d74ac3 | 16-Jun-2021 |
Hans Petter Selasky <[email protected]> |
ibcore: Fix a use-after-free in ucma_resolve_ip().
There is a race condition between ucma_close() and ucma_resolve_ip():
CPU0 CPU1 ucma_resolve_ip(): ucma_cl
ibcore: Fix a use-after-free in ucma_resolve_ip().
There is a race condition between ucma_close() and ucma_resolve_ip():
CPU0 CPU1 ucma_resolve_ip(): ucma_close():
ctx = ucma_get_ctx(file, cmd.id);
list_for_each_entry_safe(ctx, tmp, &file->ctx_list, list) { mutex_lock(&mut); idr_remove(&ctx_idr, ctx->id); mutex_unlock(&mut); ... mutex_lock(&mut); if (!ctx->closing) { mutex_unlock(&mut); rdma_destroy_id(ctx->cm_id); ... ucma_free_ctx(ctx); }
ret = rdma_resolve_addr(); ucma_put_ctx(ctx);
Before idr_remove(), ucma_get_ctx() could still find the ctx and after rdma_destroy_id(), rdma_resolve_addr() may still access id_priv pointer. Also, ucma_put_ctx() may use ctx after ucma_free_ctx() too.
ucma_close() should call ucma_put_ctx() too which tests the refcnt and waits for the last one releasing it. The similar pattern is already used by ucma_destroy_id().
Linux commit: 5fe23f262e0548ca7f19fb79f89059a60d087d22
Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking
(cherry picked from commit c6ccb08686f3b92c12778b4b903431b2ce71ec2c)
show more ...
|
| 1753641a | 16-Jun-2021 |
Hans Petter Selasky <[email protected]> |
ibcore: Define option to set ack timeout.
Define new option in 'rdma_set_option' to override calculated QP timeout when requested to provide QP attributes to modify a QP.
At the same time, pack tos
ibcore: Define option to set ack timeout.
Define new option in 'rdma_set_option' to override calculated QP timeout when requested to provide QP attributes to modify a QP.
At the same time, pack tos_set to be bitfield.
Linux commit: 2c1619edef61a03cb516efaa81750784c3071d10
Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking
(cherry picked from commit 20fea7ac64683b064ffe4cefa750e46ba20de4f9)
show more ...
|
| 7449dd9a | 16-Jun-2021 |
Hans Petter Selasky <[email protected]> |
ibcore: Do not overreact to SM LID change event.
When IPoIB receives an SM LID change event, it reacts by flushing its path record cache and rejoining multicast groups. This is the same behavior it
ibcore: Do not overreact to SM LID change event.
When IPoIB receives an SM LID change event, it reacts by flushing its path record cache and rejoining multicast groups. This is the same behavior it performs when it receives a reregistration event. This behavior is unnecessary as an SM may have database backup or synchronization mechanisms which permit the SM location or LID to change without loss of multicast membership and without impact to path records.
Both opensm and the OPA FM issue reregistration events if a new SM is started (or restarted with a new config) or an SM event occurs which results in loss of multicast membership records by the SM (such as opensm failover) or the SM encounters new nodes with Active ports (such as after joining 2 fabrics by connecting switches via ISLs). Hence this event can be depended on as the trigger for IPoIB cache and multicast flushing.
It appears that some drivers, such as qib, and hfi1 issue the IB_EVENT_SM_CHANGE but other drivers such as mlx4 and mlx5 do not. Empirical testing on Mellanox EDR using ibv_asyncwatch has confirmed that Mellanox EDR HCAs do not generate SM change events and that opensm does generate reregistration.
An SM LID change event is generated by the mentioned drivers to reflect that sm_lid and/or sm_sl in the local port info has changed. The intent of this event is to permit applications and ULPs which have a local copy of this information (or an address handle using it) to update their information.
The intent is that the reregistration event (caused by the SM via a bit in Set(PortInfo)) be used to inform nodes that they need to rejoin multicast groups, resubscribe for notices and potentially update path records.
When an SM migrates or fails over, a SM LID change event can occur. In response IPoIB discards path records and multicast membership and loses connectivity until these records are restored via SA requests. In very large fabrics, it may take minutes for the SM to be ready and for the SA responses to be supplied. This can result in undesirable and unnecessary IPoIB connectivity impacts. It also can result in an unnecessary storm of SA queries from all nodes in a cluster potentially followed by yet another storm if the SM issues the reregistration request.
The fact the Mellanox HCAs do not even generate this event, is further evidence that on modern IB fabrics there will be no ill side effects from the proposed changes below to reduce the reaction by 3 kernel components to this event. So these changes should be benign for Mellanox IB fabrics and will benefit OPA fabrics while also making ib_core and ULP behavor "correct" as intended by the IBTA spec and kernel RDMA event APIs.
Address these issues by removing IB_EVENT_SM_CHANGE handling from ipoib. IPoIB does not locally store sm_lid nor sm_sl, so it does not need to do anything on SM LID change. IPoIB makes use of other ib_core components to issue SA requests for it and those components correctly track SM LID and SM LID changes.
Also in ib_core multicast handling, remove the test for IB_EVENT_SM_CHANGE. This code is moving all multicast groups to the error state, which will trigger rejoins. This code is used by IPoIB as well as the connection manager and other clients of multicast groups. This kernel module centralizes group membership status and joins since a node can only join a given group once but multiple ULPs or applications may want to join the same group. It makes use of the sa_query.c component in ib_core, which correctly trackes SM LID and SL. This component does not track SM LID nor SL itself and hence need not react to their changes.
Similarly in the ib_core cache code remove the handling for the IB_EVENT_SM_CHANGE. In this function. The ib_cache_update function which is ultimately called is updating local copies of the pkey table, gid table and lmc. It does not update nor retain sm_lid nor sm_sl. As such it does not need to be called on an SM LID change. It technically also does not need to be called on a reregistration. The LID_CHANGE, PKEY_CHANGE, GID_CHANGE and port state change events (PORT_ERR, PORT_ACTICE) should be sufficient triggers.
It is worth noting that the alternative of simply having the hfi1 and qib drivers not generate the SM LID change event was explored. While this would duplicate what Mellanox drivers do now, it is not the correct behavior and removes the ability for an SM to migrate without requiring reregistration. Since both opensm and OPA SM have mechanisms to backup or synchronize registration information, it is desirable to let them perform SM migrations (with LID or SL changes) without requiring reregistration when they deem it appropriate.
Linux commit: ba7d8117f3cca8eb70d579fde3f9ec8cd6a28f39
Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking
(cherry picked from commit df1df0c742ec22de6ee7656a91ea8773c05f3b81)
show more ...
|
| fe866f58 | 16-Jun-2021 |
Hans Petter Selasky <[email protected]> |
ibcore: Remove debug prints after allocation failure.
The prints after [k|v][m|z|c]alloc() functions are not needed, because in case of failure, allocator will print their internal error prints anyw
ibcore: Remove debug prints after allocation failure.
The prints after [k|v][m|z|c]alloc() functions are not needed, because in case of failure, allocator will print their internal error prints anyway.
Linux commit: 2716243212241855cd9070883779f6e58967dec5
Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking
(cherry picked from commit 26646ba5bcdadbd513dc4dfccc772952732aea5c)
show more ...
|
| 36f60545 | 16-Jun-2021 |
Hans Petter Selasky <[email protected]> |
ibcore: Fix use-after-free in IB mad completion handling.
We encountered a use-after-free bug when unloading the driver:
BUG: KASAN: use-after-free in ib_mad_post_receive_mads+0xddc/0xed0 [ib_core]
ibcore: Fix use-after-free in IB mad completion handling.
We encountered a use-after-free bug when unloading the driver:
BUG: KASAN: use-after-free in ib_mad_post_receive_mads+0xddc/0xed0 [ib_core] Read of size 4 at addr ffff8882ca5aa868 by task kworker/u13:2/23862
Workqueue: ib-comp-unb-wq ib_cq_poll_work [ib_core] Call Trace: dump_stack+0x9a/0xeb print_address_description+0xe3/0x2e0 ib_mad_post_receive_mads+0xddc/0xed0 [ib_core] __kasan_report+0x15c/0x1df ib_mad_post_receive_mads+0xddc/0xed0 [ib_core] kasan_report+0xe/0x20 ib_mad_post_receive_mads+0xddc/0xed0 [ib_core] find_mad_agent+0xa00/0xa00 [ib_core] qlist_free_all+0x51/0xb0 mlx4_ib_sqp_comp_worker+0x1970/0x1970 [mlx4_ib] quarantine_reduce+0x1fa/0x270 kasan_unpoison_shadow+0x30/0x40 ib_mad_recv_done+0xdf6/0x3000 [ib_core] _raw_spin_unlock_irqrestore+0x46/0x70 ib_mad_send_done+0x1810/0x1810 [ib_core] mlx4_ib_destroy_cq+0x2a0/0x2a0 [mlx4_ib] _raw_spin_unlock_irqrestore+0x46/0x70 debug_object_deactivate+0x2b9/0x4a0 __ib_process_cq+0xe2/0x1d0 [ib_core] ib_cq_poll_work+0x45/0xf0 [ib_core] process_one_work+0x90c/0x1860 pwq_dec_nr_in_flight+0x320/0x320 worker_thread+0x87/0xbb0 __kthread_parkme+0xb6/0x180 process_one_work+0x1860/0x1860 kthread+0x320/0x3e0 kthread_park+0x120/0x120 ret_from_fork+0x24/0x30 ... Freed by task 31682: save_stack+0x19/0x80 __kasan_slab_free+0x11d/0x160 kfree+0xf5/0x2f0 ib_mad_port_close+0x200/0x380 [ib_core] ib_mad_remove_device+0xf0/0x230 [ib_core] remove_client_context+0xa6/0xe0 [ib_core] disable_device+0x14e/0x260 [ib_core] __ib_unregister_device+0x79/0x150 [ib_core] ib_unregister_device+0x21/0x30 [ib_core] mlx4_ib_remove+0x162/0x690 [mlx4_ib] mlx4_remove_device+0x204/0x2c0 [mlx4_core] mlx4_unregister_interface+0x49/0x1d0 [mlx4_core] mlx4_ib_cleanup+0xc/0x1d [mlx4_ib] __x64_sys_delete_module+0x2d2/0x400 do_syscall_64+0x95/0x470 entry_SYSCALL_64_after_hwframe+0x49/0xbe
The problem was that the MAD PD was deallocated before the MAD CQ. There was completion work pending for the CQ when the PD got deallocated. When the mad completion handling reached procedure ib_mad_post_receive_mads(), we got a use-after-free bug in the following line of code in that procedure: sg_list.lkey = qp_info->port_priv->pd->local_dma_lkey; (the pd pointer in the above line is no longer valid, because the pd has been deallocated).
We fix this by allocating the PD before the CQ in procedure ib_mad_port_open(), and deallocating the PD after freeing the CQ in procedure ib_mad_port_close().
Since the CQ completion work queue is flushed during ib_free_cq(), no completions will be pending for that CQ when the PD is later deallocated.
Note that freeing the CQ before deallocating the PD is the practice in the ULPs.
Linux commit: 770b7d96cfff6a8bf6c9f261ba6f135dc9edf484
Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking
(cherry picked from commit 468a6b5055f0b6ea0bdb1ee8cbdf749204cb3b25)
show more ...
|
| 7da85a0d | 16-Jun-2021 |
Hans Petter Selasky <[email protected]> |
ibcore: Fail early if unsupported QP is provided.
When requested QP type is not supported for a {device, port}, return the error right away before validating all parameters during mad agent registra
ibcore: Fail early if unsupported QP is provided.
When requested QP type is not supported for a {device, port}, return the error right away before validating all parameters during mad agent registration time.
Linux commit: 798bba01b44b0ddf8cd6e542635b37cc9a9b739c
Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking
(cherry picked from commit 507389a35a41f5f15592d2156d34039e3ee1c3e5)
show more ...
|
| dd7241e0 | 16-Jun-2021 |
Hans Petter Selasky <[email protected]> |
ibcore: Use inline function to validate port
Linux commit: 24dc831b77eca9361cf835be59fa69ea0e471afc
Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking
(cherry picked from co
ibcore: Use inline function to validate port
Linux commit: 24dc831b77eca9361cf835be59fa69ea0e471afc
Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking
(cherry picked from commit e2ae502d28605db0ca2af6e6261513106fe2b57d)
show more ...
|
| a4b27295 | 16-Jun-2021 |
Hans Petter Selasky <[email protected]> |
ibcore: Validate port number in query_pkey verb.
Before calling the driver's function let's make sure port is valid.
Linux commit: 9af3f5cf9d64a056eca53bc643f6288ad28bbbb5
Reviewed by: kib Sponsor
ibcore: Validate port number in query_pkey verb.
Before calling the driver's function let's make sure port is valid.
Linux commit: 9af3f5cf9d64a056eca53bc643f6288ad28bbbb5
Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking
(cherry picked from commit 31525faed8b43c579767cf3ac211f41764b2a46c)
show more ...
|
| 6ee86212 | 16-Jun-2021 |
Hans Petter Selasky <[email protected]> |
ibcore: Protect against concurrent access to hardware stats.
Currently access to hardware stats buffer isn't protected, this can result in multiple writes and reads at the same time to the same memo
ibcore: Protect against concurrent access to hardware stats.
Currently access to hardware stats buffer isn't protected, this can result in multiple writes and reads at the same time to the same memory location. This can lead to providing an incorrect value to the user. Add a mutex to protect against it.
Linux commit: e945130b52bea65d15f9bdf54949d4cb7a88db7f
Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking
(cherry picked from commit 912e98cedee2590748a9893d3152b11694de3379)
show more ...
|
| e898f1af | 16-Jun-2021 |
Hans Petter Selasky <[email protected]> |
ibcore: Do not expose unsupported counters.
If the provider driver (such as rdma_rxe) doesn't support PMA counters, avoid exposing its directory similar to optional hw_counters directory. If core fa
ibcore: Do not expose unsupported counters.
If the provider driver (such as rdma_rxe) doesn't support PMA counters, avoid exposing its directory similar to optional hw_counters directory. If core fails to read the PMA counter, return an error so that user can retry later if needed.
Linux commit: 0f6ef65d1c6ec8deb5d0f11f86631ec4cfe8f22e
Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking
(cherry picked from commit ac4174e064f447ed3b19a8b395625b7d2b3739d1)
show more ...
|
| 2cbd2889 | 16-Jun-2021 |
Hans Petter Selasky <[email protected]> |
ibcore: Introduce ib_port_phys_state enum.
In order to improve readability, add ib_port_phys_state enum to replace the use of magic numbers.
Linux commit: 72a7720fca37fec0daf295923f17ac5d88a613e1
ibcore: Introduce ib_port_phys_state enum.
In order to improve readability, add ib_port_phys_state enum to replace the use of magic numbers.
Linux commit: 72a7720fca37fec0daf295923f17ac5d88a613e1
Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking
(cherry picked from commit 4238b4a7a2cfe44e95f3553ff4a3f6f813fb81f5)
show more ...
|
| 645d0710 | 16-Jun-2021 |
Hans Petter Selasky <[email protected]> |
ibcore: Fix unable to change lifespan entry for hw_counters.
This patch fixes the case where 'lifespan' entry of the hw_counters is not writable. Currently write callback is not exposed for for the
ibcore: Fix unable to change lifespan entry for hw_counters.
This patch fixes the case where 'lifespan' entry of the hw_counters is not writable. Currently write callback is not exposed for for the hw_counters sysfs operation. Due to this, modifying lifespan value results into permission denied error in below example.
echo 10 > /sys/class/infiniband/mlx5_0/ports/1/hw_counters/lifespan -bash: /sys/class/infiniband/mlx5_0/ports/1/hw_counters/lifespan: Permission denied
This patch adds the hook to modify any attribute which implements store() operation.
Linux commit: 79c4d80b43b8e43684894574a508a871f0c196bf
Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking
(cherry picked from commit d7d833e20ba33f5b9f3052a534af7ecdd602f152)
show more ...
|