]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net/mlx5: Fix incorrect IRQ pool usage when releasing IRQs
authorShay Drory <shayd@nvidia.com>
Mon, 10 Mar 2025 22:01:41 +0000 (00:01 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 13 Mar 2025 12:11:14 +0000 (13:11 +0100)
mlx5_irq_pool_get() is a getter for completion IRQ pool only.
However, after the cited commit, mlx5_irq_pool_get() is called during
ctrl IRQ release flow to retrieve the pool, resulting in the use of an
incorrect IRQ pool.

Hence, use the newly introduced mlx5_irq_get_pool() getter to retrieve
the correct IRQ pool based on the IRQ itself. While at it, rename
mlx5_irq_pool_get() to mlx5_irq_table_get_comp_irq_pool() which
accurately reflects its purpose and improves code readability.

Fixes: 0477d5168bbb ("net/mlx5: Expose SFs IRQs")
Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Maher Sanalla <msanalla@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Link: https://patch.msgid.link/1741644104-97767-4-git-send-email-tariqt@nvidia.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/mellanox/mlx5/core/eq.c
drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c
drivers/net/ethernet/mellanox/mlx5/core/mlx5_irq.h
drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c
drivers/net/ethernet/mellanox/mlx5/core/pci_irq.h

index 2b229b6226c6a77f0b65a88e4ae62ed0283bebaa..dfb079e59d8588a07541005b9425305bf689de76 100644 (file)
@@ -871,8 +871,8 @@ static void comp_irq_release_sf(struct mlx5_core_dev *dev, u16 vecidx)
 
 static int comp_irq_request_sf(struct mlx5_core_dev *dev, u16 vecidx)
 {
+       struct mlx5_irq_pool *pool = mlx5_irq_table_get_comp_irq_pool(dev);
        struct mlx5_eq_table *table = dev->priv.eq_table;
-       struct mlx5_irq_pool *pool = mlx5_irq_pool_get(dev);
        struct irq_affinity_desc af_desc = {};
        struct mlx5_irq *irq;
 
index 1477db7f5307e095ca1025417598c444215893d1..2691d88cdee1f7f61da738a3a0bac9cf1ab7f296 100644 (file)
@@ -175,7 +175,7 @@ unlock:
 
 void mlx5_irq_affinity_irq_release(struct mlx5_core_dev *dev, struct mlx5_irq *irq)
 {
-       struct mlx5_irq_pool *pool = mlx5_irq_pool_get(dev);
+       struct mlx5_irq_pool *pool = mlx5_irq_get_pool(irq);
        int cpu;
 
        cpu = cpumask_first(mlx5_irq_get_affinity_mask(irq));
index 0881e961d8b177e5bcb3e40451aaf5fa81d74840..586688da9940ee17969ac69234d97ad65d26d475 100644 (file)
 
 struct mlx5_irq;
 struct cpu_rmap;
+struct mlx5_irq_pool;
 
 int mlx5_irq_table_init(struct mlx5_core_dev *dev);
 void mlx5_irq_table_cleanup(struct mlx5_core_dev *dev);
 int mlx5_irq_table_create(struct mlx5_core_dev *dev);
 void mlx5_irq_table_destroy(struct mlx5_core_dev *dev);
 void mlx5_irq_table_free_irqs(struct mlx5_core_dev *dev);
+struct mlx5_irq_pool *
+mlx5_irq_table_get_comp_irq_pool(struct mlx5_core_dev *dev);
 int mlx5_irq_table_get_num_comp(struct mlx5_irq_table *table);
 int mlx5_irq_table_get_sfs_vec(struct mlx5_irq_table *table);
 struct mlx5_irq_table *mlx5_irq_table_get(struct mlx5_core_dev *dev);
@@ -38,7 +41,6 @@ struct cpumask *mlx5_irq_get_affinity_mask(struct mlx5_irq *irq);
 int mlx5_irq_get_index(struct mlx5_irq *irq);
 int mlx5_irq_get_irq(const struct mlx5_irq *irq);
 
-struct mlx5_irq_pool;
 #ifdef CONFIG_MLX5_SF
 struct mlx5_irq *mlx5_irq_affinity_irq_request_auto(struct mlx5_core_dev *dev,
                                                    struct cpumask *used_cpus, u16 vecidx);
index d9362eabc6a1cad9bc87427aab9ce721ef3c6244..2c5f850c31f68324ad030aecc55646f7eb6c166a 100644 (file)
@@ -378,6 +378,11 @@ int mlx5_irq_get_index(struct mlx5_irq *irq)
        return irq->map.index;
 }
 
+struct mlx5_irq_pool *mlx5_irq_get_pool(struct mlx5_irq *irq)
+{
+       return irq->pool;
+}
+
 /* irq_pool API */
 
 /* requesting an irq from a given pool according to given index */
@@ -405,18 +410,20 @@ static struct mlx5_irq_pool *sf_ctrl_irq_pool_get(struct mlx5_irq_table *irq_tab
        return irq_table->sf_ctrl_pool;
 }
 
-static struct mlx5_irq_pool *sf_irq_pool_get(struct mlx5_irq_table *irq_table)
+static struct mlx5_irq_pool *
+sf_comp_irq_pool_get(struct mlx5_irq_table *irq_table)
 {
        return irq_table->sf_comp_pool;
 }
 
-struct mlx5_irq_pool *mlx5_irq_pool_get(struct mlx5_core_dev *dev)
+struct mlx5_irq_pool *
+mlx5_irq_table_get_comp_irq_pool(struct mlx5_core_dev *dev)
 {
        struct mlx5_irq_table *irq_table = mlx5_irq_table_get(dev);
        struct mlx5_irq_pool *pool = NULL;
 
        if (mlx5_core_is_sf(dev))
-               pool = sf_irq_pool_get(irq_table);
+               pool = sf_comp_irq_pool_get(irq_table);
 
        /* In some configs, there won't be a pool of SFs IRQs. Hence, returning
         * the PF IRQs pool in case the SF pool doesn't exist.
index c4d377f8df308917c89e0c8306cbd6c9ef3d8f83..cc064425fe16085b67b4b13d3334f29c21b949bd 100644 (file)
@@ -28,7 +28,6 @@ struct mlx5_irq_pool {
        struct mlx5_core_dev *dev;
 };
 
-struct mlx5_irq_pool *mlx5_irq_pool_get(struct mlx5_core_dev *dev);
 static inline bool mlx5_irq_pool_is_sf_pool(struct mlx5_irq_pool *pool)
 {
        return !strncmp("mlx5_sf", pool->name, strlen("mlx5_sf"));
@@ -40,5 +39,6 @@ struct mlx5_irq *mlx5_irq_alloc(struct mlx5_irq_pool *pool, int i,
 int mlx5_irq_get_locked(struct mlx5_irq *irq);
 int mlx5_irq_read_locked(struct mlx5_irq *irq);
 int mlx5_irq_put(struct mlx5_irq *irq);
+struct mlx5_irq_pool *mlx5_irq_get_pool(struct mlx5_irq *irq);
 
 #endif /* __PCI_IRQ_H__ */