Skip to contentSkip to conversation

mlx4_en: fix allocation of CPU affinity reverse-map

PATCH Applied Kleber Sacilotto de Souza 3 participants 3 messages Feb 23, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mlx4_en: fix allocation of CPU affinity reverse-map

The mlx4_en driver allocates the number of objects for the CPU affinity reverse-map based on the number of rx rings of the device. However, mlx4_assign_eq() calls irq_cpu_rmap_add() as many times as IRQ's are assigned to EQ's, which can be as large as mlx4_dev->caps.comp_pool. If caps.comp_pool is larger than rx_ring_num we will eventually hit the BUG_ON() in cpu_rmap_add().

Fix this problem by allocating space for the maximum number of CPU affinity reverse-map objects we might want to add.

---
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +1 -1
index 5944dd6..5385474 100644
@@ -1829,7 +1829,7 @@ int mlx4_en_alloc_resources(struct mlx4_en_priv *priv)
 	}
 
 #ifdef CONFIG_RFS_ACCEL
-	priv->dev->rx_cpu_rmap = alloc_irq_cpu_rmap(priv->rx_ring_num);
+	priv->dev->rx_cpu_rmap = alloc_irq_cpu_rmap(priv->mdev->dev->caps.comp_pool);
 	if (!priv->dev->rx_cpu_rmap)
 		goto err;
 #endif
Signature · 1 line
1.7.1
Acked-by on v1 1/1
#1 lore raw
Quoted 21 lines · Kleber Sacilotto de Souza

The mlx4_en driver allocates the number of objects for the CPU affinity reverse-map based on the number of rx rings of the device. However, mlx4_assign_eq() calls irq_cpu_rmap_add() as many times as IRQ's are assigned to EQ's, which can be as large as mlx4_dev->caps.comp_pool. If caps.comp_pool is larger than rx_ring_num we will eventually hit the BUG_ON() in cpu_rmap_add().

Fix this problem by allocating space for the maximum number of CPU affinity reverse-map objects we might want to add.

---
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +0 -0
index 5944dd6..5385474 100644

drivers/net/ethernet/mellanox/mlx4/en_netdev.c int mlx4_en_alloc_resources(struct mlx4_en_priv *priv) · line 1835

Quoted 8 lines
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +1 -1
@@ -1829,7 +1829,7 @@ int mlx4_en_alloc_resources(struct mlx4_en_priv *priv)
 	}
 
 #ifdef CONFIG_RFS_ACCEL
-	priv->dev->rx_cpu_rmap = alloc_irq_cpu_rmap(priv->rx_ring_num);
+	priv->dev->rx_cpu_rmap = alloc_irq_cpu_rmap(priv->mdev->dev->caps.comp_pool);
 	if (!priv->dev->rx_cpu_rmap)
 		goto err;
 #endif
maintainer Applied
#2 lore raw
In reply to Kleber Sacilotto de Souza

From: Kleber Sacilotto de Souza <[email protected]>
Date: Sat, 23 Feb 2013 02:14:52 -0300

Quoted 11 lines

The mlx4_en driver allocates the number of objects for the CPU affinity reverse-map based on the number of rx rings of the device. However, mlx4_assign_eq() calls irq_cpu_rmap_add() as many times as IRQ's are assigned to EQ's, which can be as large as mlx4_dev->caps.comp_pool. If caps.comp_pool is larger than rx_ring_num we will eventually hit the BUG_ON() in cpu_rmap_add().

Fix this problem by allocating space for the maximum number of CPU affinity reverse-map objects we might want to add.

Applied.