Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma

Pull rdma fixes from Jason Gunthorpe:
"Several mlx5 bugs, crashers, and reports:

- Limit stack usage

- Fix mis-use of __xa_store/erase() without holding the lock to a
locked version

- Rate limit prints in the gid cache error cases

- Fully initialize the event object before making it globally visible
in an xarray

- Fix deadlock inside the ODP code if the MMU notifier was called
from a reclaim context

- Include missed counters for some switchdev configurations and
mulit-port MPV mode

- Fix loopback packet support when in mulit-port MPV mode"

* tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma:
RDMA/mlx5: Fix vport loopback for MPV device
RDMA/mlx5: Fix CC counters query for MPV
RDMA/mlx5: Fix HW counters query for non-representor devices
IB/core: Annotate umem_mutex acquisition under fs_reclaim for lockdep
IB/mlx5: Fix potential deadlock in MR deregistration
RDMA/mlx5: Initialize obj_event->obj_sub_list before xa_insert
RDMA/core: Rate limit GID cache warning messages
RDMA/mlx5: Fix unsafe xarray access in implicit ODP handling
RDMA/mlx5: reduce stack usage in mlx5_ib_ufile_hw_cleanup

+107 -24
+2 -2
drivers/infiniband/core/cache.c
··· 582 582 out_unlock: 583 583 mutex_unlock(&table->lock); 584 584 if (ret) 585 - pr_warn("%s: unable to add gid %pI6 error=%d\n", 586 - __func__, gid->raw, ret); 585 + pr_warn_ratelimited("%s: unable to add gid %pI6 error=%d\n", 586 + __func__, gid->raw, ret); 587 587 return ret; 588 588 } 589 589
+11
drivers/infiniband/core/umem_odp.c
··· 76 76 end = ALIGN(end, page_size); 77 77 if (unlikely(end < page_size)) 78 78 return -EOVERFLOW; 79 + /* 80 + * The mmu notifier can be called within reclaim contexts and takes the 81 + * umem_mutex. This is rare to trigger in testing, teach lockdep about 82 + * it. 83 + */ 84 + if (IS_ENABLED(CONFIG_LOCKDEP)) { 85 + fs_reclaim_acquire(GFP_KERNEL); 86 + mutex_lock(&umem_odp->umem_mutex); 87 + mutex_unlock(&umem_odp->umem_mutex); 88 + fs_reclaim_release(GFP_KERNEL); 89 + } 79 90 80 91 nr_entries = (end - start) >> PAGE_SHIFT; 81 92 if (!(nr_entries * PAGE_SIZE / page_size))
+2 -2
drivers/infiniband/hw/mlx5/counters.c
··· 398 398 return ret; 399 399 400 400 /* We don't expose device counters over Vports */ 401 - if (is_mdev_switchdev_mode(dev->mdev) && port_num != 0) 401 + if (is_mdev_switchdev_mode(dev->mdev) && dev->is_rep && port_num != 0) 402 402 goto done; 403 403 404 404 if (MLX5_CAP_PCAM_FEATURE(dev->mdev, rx_icrc_encapsulated_counter)) { ··· 418 418 */ 419 419 goto done; 420 420 } 421 - ret = mlx5_lag_query_cong_counters(dev->mdev, 421 + ret = mlx5_lag_query_cong_counters(mdev, 422 422 stats->value + 423 423 cnts->num_q_counters, 424 424 cnts->num_cong_counters,
+8 -2
drivers/infiniband/hw/mlx5/devx.c
··· 1958 1958 /* Level1 is valid for future use, no need to free */ 1959 1959 return -ENOMEM; 1960 1960 1961 + INIT_LIST_HEAD(&obj_event->obj_sub_list); 1961 1962 err = xa_insert(&event->object_ids, 1962 1963 key_level2, 1963 1964 obj_event, ··· 1967 1966 kfree(obj_event); 1968 1967 return err; 1969 1968 } 1970 - INIT_LIST_HEAD(&obj_event->obj_sub_list); 1971 1969 } 1972 1970 1973 1971 return 0; ··· 2669 2669 2670 2670 void mlx5_ib_ufile_hw_cleanup(struct ib_uverbs_file *ufile) 2671 2671 { 2672 - struct mlx5_async_cmd async_cmd[MAX_ASYNC_CMDS]; 2672 + struct mlx5_async_cmd *async_cmd; 2673 2673 struct ib_ucontext *ucontext = ufile->ucontext; 2674 2674 struct ib_device *device = ucontext->device; 2675 2675 struct mlx5_ib_dev *dev = to_mdev(device); ··· 2677 2677 struct devx_obj *obj; 2678 2678 int head = 0; 2679 2679 int tail = 0; 2680 + 2681 + async_cmd = kcalloc(MAX_ASYNC_CMDS, sizeof(*async_cmd), GFP_KERNEL); 2682 + if (!async_cmd) 2683 + return; 2680 2684 2681 2685 list_for_each_entry(uobject, &ufile->uobjects, list) { 2682 2686 WARN_ON(uverbs_try_lock_object(uobject, UVERBS_LOOKUP_WRITE)); ··· 2717 2713 devx_wait_async_destroy(&async_cmd[head % MAX_ASYNC_CMDS]); 2718 2714 head++; 2719 2715 } 2716 + 2717 + kfree(async_cmd); 2720 2718 } 2721 2719 2722 2720 static ssize_t devx_async_cmd_event_read(struct file *filp, char __user *buf,
+33
drivers/infiniband/hw/mlx5/main.c
··· 1791 1791 context->devx_uid); 1792 1792 } 1793 1793 1794 + static int mlx5_ib_enable_lb_mp(struct mlx5_core_dev *master, 1795 + struct mlx5_core_dev *slave) 1796 + { 1797 + int err; 1798 + 1799 + err = mlx5_nic_vport_update_local_lb(master, true); 1800 + if (err) 1801 + return err; 1802 + 1803 + err = mlx5_nic_vport_update_local_lb(slave, true); 1804 + if (err) 1805 + goto out; 1806 + 1807 + return 0; 1808 + 1809 + out: 1810 + mlx5_nic_vport_update_local_lb(master, false); 1811 + return err; 1812 + } 1813 + 1814 + static void mlx5_ib_disable_lb_mp(struct mlx5_core_dev *master, 1815 + struct mlx5_core_dev *slave) 1816 + { 1817 + mlx5_nic_vport_update_local_lb(slave, false); 1818 + mlx5_nic_vport_update_local_lb(master, false); 1819 + } 1820 + 1794 1821 int mlx5_ib_enable_lb(struct mlx5_ib_dev *dev, bool td, bool qp) 1795 1822 { 1796 1823 int err = 0; ··· 3522 3495 3523 3496 lockdep_assert_held(&mlx5_ib_multiport_mutex); 3524 3497 3498 + mlx5_ib_disable_lb_mp(ibdev->mdev, mpi->mdev); 3499 + 3525 3500 mlx5_core_mp_event_replay(ibdev->mdev, 3526 3501 MLX5_DRIVER_EVENT_AFFILIATION_REMOVED, 3527 3502 NULL); ··· 3618 3589 mlx5_core_mp_event_replay(ibdev->mdev, 3619 3590 MLX5_DRIVER_EVENT_AFFILIATION_DONE, 3620 3591 &key); 3592 + 3593 + err = mlx5_ib_enable_lb_mp(ibdev->mdev, mpi->mdev); 3594 + if (err) 3595 + goto unbind; 3621 3596 3622 3597 return true; 3623 3598
+47 -14
drivers/infiniband/hw/mlx5/mr.c
··· 2027 2027 } 2028 2028 } 2029 2029 2030 - static int mlx5_revoke_mr(struct mlx5_ib_mr *mr) 2030 + static int mlx5_umr_revoke_mr_with_lock(struct mlx5_ib_mr *mr) 2031 2031 { 2032 - struct mlx5_ib_dev *dev = to_mdev(mr->ibmr.device); 2033 - struct mlx5_cache_ent *ent = mr->mmkey.cache_ent; 2034 - bool is_odp = is_odp_mr(mr); 2035 2032 bool is_odp_dma_buf = is_dmabuf_mr(mr) && 2036 - !to_ib_umem_dmabuf(mr->umem)->pinned; 2037 - bool from_cache = !!ent; 2038 - int ret = 0; 2033 + !to_ib_umem_dmabuf(mr->umem)->pinned; 2034 + bool is_odp = is_odp_mr(mr); 2035 + int ret; 2039 2036 2040 2037 if (is_odp) 2041 2038 mutex_lock(&to_ib_umem_odp(mr->umem)->umem_mutex); 2042 2039 2043 2040 if (is_odp_dma_buf) 2044 - dma_resv_lock(to_ib_umem_dmabuf(mr->umem)->attach->dmabuf->resv, NULL); 2041 + dma_resv_lock(to_ib_umem_dmabuf(mr->umem)->attach->dmabuf->resv, 2042 + NULL); 2045 2043 2046 - if (mr->mmkey.cacheable && !mlx5r_umr_revoke_mr(mr) && !cache_ent_find_and_store(dev, mr)) { 2044 + ret = mlx5r_umr_revoke_mr(mr); 2045 + 2046 + if (is_odp) { 2047 + if (!ret) 2048 + to_ib_umem_odp(mr->umem)->private = NULL; 2049 + mutex_unlock(&to_ib_umem_odp(mr->umem)->umem_mutex); 2050 + } 2051 + 2052 + if (is_odp_dma_buf) { 2053 + if (!ret) 2054 + to_ib_umem_dmabuf(mr->umem)->private = NULL; 2055 + dma_resv_unlock( 2056 + to_ib_umem_dmabuf(mr->umem)->attach->dmabuf->resv); 2057 + } 2058 + 2059 + return ret; 2060 + } 2061 + 2062 + static int mlx5r_handle_mkey_cleanup(struct mlx5_ib_mr *mr) 2063 + { 2064 + bool is_odp_dma_buf = is_dmabuf_mr(mr) && 2065 + !to_ib_umem_dmabuf(mr->umem)->pinned; 2066 + struct mlx5_ib_dev *dev = to_mdev(mr->ibmr.device); 2067 + struct mlx5_cache_ent *ent = mr->mmkey.cache_ent; 2068 + bool is_odp = is_odp_mr(mr); 2069 + bool from_cache = !!ent; 2070 + int ret; 2071 + 2072 + if (mr->mmkey.cacheable && !mlx5_umr_revoke_mr_with_lock(mr) && 2073 + !cache_ent_find_and_store(dev, mr)) { 2047 2074 ent = mr->mmkey.cache_ent; 2048 2075 /* upon storing to a clean temp entry - schedule its cleanup */ 2049 2076 spin_lock_irq(&ent->mkeys_queue.lock); ··· 2082 2055 ent->tmp_cleanup_scheduled = true; 2083 2056 } 2084 2057 spin_unlock_irq(&ent->mkeys_queue.lock); 2085 - goto out; 2058 + return 0; 2086 2059 } 2087 2060 2088 2061 if (ent) { ··· 2091 2064 mr->mmkey.cache_ent = NULL; 2092 2065 spin_unlock_irq(&ent->mkeys_queue.lock); 2093 2066 } 2067 + 2068 + if (is_odp) 2069 + mutex_lock(&to_ib_umem_odp(mr->umem)->umem_mutex); 2070 + 2071 + if (is_odp_dma_buf) 2072 + dma_resv_lock(to_ib_umem_dmabuf(mr->umem)->attach->dmabuf->resv, 2073 + NULL); 2094 2074 ret = destroy_mkey(dev, mr); 2095 - out: 2096 2075 if (is_odp) { 2097 2076 if (!ret) 2098 2077 to_ib_umem_odp(mr->umem)->private = NULL; ··· 2108 2075 if (is_odp_dma_buf) { 2109 2076 if (!ret) 2110 2077 to_ib_umem_dmabuf(mr->umem)->private = NULL; 2111 - dma_resv_unlock(to_ib_umem_dmabuf(mr->umem)->attach->dmabuf->resv); 2078 + dma_resv_unlock( 2079 + to_ib_umem_dmabuf(mr->umem)->attach->dmabuf->resv); 2112 2080 } 2113 - 2114 2081 return ret; 2115 2082 } 2116 2083 ··· 2159 2126 } 2160 2127 2161 2128 /* Stop DMA */ 2162 - rc = mlx5_revoke_mr(mr); 2129 + rc = mlx5r_handle_mkey_cleanup(mr); 2163 2130 if (rc) 2164 2131 return rc; 2165 2132
+4 -4
drivers/infiniband/hw/mlx5/odp.c
··· 259 259 } 260 260 261 261 if (MLX5_CAP_ODP(mr_to_mdev(mr)->mdev, mem_page_fault)) 262 - __xa_erase(&mr_to_mdev(mr)->odp_mkeys, 263 - mlx5_base_mkey(mr->mmkey.key)); 262 + xa_erase(&mr_to_mdev(mr)->odp_mkeys, 263 + mlx5_base_mkey(mr->mmkey.key)); 264 264 xa_unlock(&imr->implicit_children); 265 265 266 266 /* Freeing a MR is a sleeping operation, so bounce to a work queue */ ··· 532 532 } 533 533 534 534 if (MLX5_CAP_ODP(dev->mdev, mem_page_fault)) { 535 - ret = __xa_store(&dev->odp_mkeys, mlx5_base_mkey(mr->mmkey.key), 536 - &mr->mmkey, GFP_KERNEL); 535 + ret = xa_store(&dev->odp_mkeys, mlx5_base_mkey(mr->mmkey.key), 536 + &mr->mmkey, GFP_KERNEL); 537 537 if (xa_is_err(ret)) { 538 538 ret = ERR_PTR(xa_err(ret)); 539 539 __xa_erase(&imr->implicit_children, idx);