[net,02/11] net/mlx5: Fix get vector affinity helper function

Message ID 20180112003723.19208-3-saeedm@mellanox.com
State Accepted
Delegated to: David Miller
Headers show
Series
  • [net,01/11] {net,ib}/mlx5: Don't disable local loopback multicast traffic when needed
Related show

Commit Message

Saeed Mahameed Jan. 12, 2018, 12:37 a.m.
mlx5_get_vector_affinity used to call pci_irq_get_affinity and after
reverting the patch that sets the device affinity via PCI_IRQ_AFFINITY
API, calling pci_irq_get_affinity becomes useless and it breaks RDMA
mlx5 users.  To fix this, this patch provides an alternative way to
retrieve IRQ vector affinity using legacy IRQ API, following
smp_affinity read procfs implementation.

Fixes: 231243c82793 ("Revert mlx5: move affinity hints assignments to generic code")
Fixes: a435393acafb ("mlx5: move affinity hints assignments to generic code")
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: Qing Huang <qing.huang@oracle.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 include/linux/mlx5/driver.h | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

Comments

Sagi Grimberg Jan. 14, 2018, 9:29 a.m. | #1
Hi Saeed,

> mlx5_get_vector_affinity used to call pci_irq_get_affinity and after
> reverting the patch that sets the device affinity via PCI_IRQ_AFFINITY
> API, calling pci_irq_get_affinity becomes useless and it breaks RDMA
> mlx5 users.  To fix this, this patch provides an alternative way to
> retrieve IRQ vector affinity using legacy IRQ API, following
> smp_affinity read procfs implementation.
> 
> Fixes: 231243c82793 ("Revert mlx5: move affinity hints assignments to generic code")
> Fixes: a435393acafb ("mlx5: move affinity hints assignments to generic code")
> Cc: Sagi Grimberg <sagi@grimberg.me>
> Cc: Qing Huang <qing.huang@oracle.com>
> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
I didn't have time to test it out thus far, I assume you tested it
though, so looks good to me,

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>

Patch

diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index 1f509d072026..a0610427e168 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -36,6 +36,7 @@ 
 #include <linux/kernel.h>
 #include <linux/completion.h>
 #include <linux/pci.h>
+#include <linux/irq.h>
 #include <linux/spinlock_types.h>
 #include <linux/semaphore.h>
 #include <linux/slab.h>
@@ -1231,7 +1232,23 @@  enum {
 static inline const struct cpumask *
 mlx5_get_vector_affinity(struct mlx5_core_dev *dev, int vector)
 {
-	return pci_irq_get_affinity(dev->pdev, MLX5_EQ_VEC_COMP_BASE + vector);
+	const struct cpumask *mask;
+	struct irq_desc *desc;
+	unsigned int irq;
+	int eqn;
+	int err;
+
+	err = mlx5_vector2eqn(dev, vector, &eqn, &irq);
+	if (err)
+		return NULL;
+
+	desc = irq_to_desc(irq);
+#ifdef CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK
+	mask = irq_data_get_effective_affinity_mask(&desc->irq_data);
+#else
+	mask = desc->irq_common_data.affinity;
+#endif
+	return mask;
 }
 
 #endif /* MLX5_DRIVER_H */