net/mlx4: Replace irq_to_desc() abuse
No driver has any business with the internals of an interrupt descriptor. Storing a pointer to it just to use yet another helper at the actual usage site to retrieve the affinity mask is creative at best. Just because C does not allow encapsulation does not mean that the kernel has no limits. Retrieve a pointer to the affinity mask itself and use that. It's still using an interface which is usually not for random drivers, but definitely less hideous than the previous hack. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Tariq Toukan <tariqt@nvidia.com> Link: https://lore.kernel.org/r/20201210194044.580936243@linutronix.de
This commit is contained in:
@@ -90,7 +90,7 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq,
|
|||||||
int cq_idx)
|
int cq_idx)
|
||||||
{
|
{
|
||||||
struct mlx4_en_dev *mdev = priv->mdev;
|
struct mlx4_en_dev *mdev = priv->mdev;
|
||||||
int err = 0;
|
int irq, err = 0;
|
||||||
int timestamp_en = 0;
|
int timestamp_en = 0;
|
||||||
bool assigned_eq = false;
|
bool assigned_eq = false;
|
||||||
|
|
||||||
@@ -116,10 +116,8 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq,
|
|||||||
|
|
||||||
assigned_eq = true;
|
assigned_eq = true;
|
||||||
}
|
}
|
||||||
|
irq = mlx4_eq_get_irq(mdev->dev, cq->vector);
|
||||||
cq->irq_desc =
|
cq->aff_mask = irq_get_affinity_mask(irq);
|
||||||
irq_to_desc(mlx4_eq_get_irq(mdev->dev,
|
|
||||||
cq->vector));
|
|
||||||
} else {
|
} else {
|
||||||
/* For TX we use the same irq per
|
/* For TX we use the same irq per
|
||||||
ring we assigned for the RX */
|
ring we assigned for the RX */
|
||||||
|
|||||||
@@ -959,8 +959,6 @@ int mlx4_en_poll_rx_cq(struct napi_struct *napi, int budget)
|
|||||||
|
|
||||||
/* If we used up all the quota - we're probably not done yet... */
|
/* If we used up all the quota - we're probably not done yet... */
|
||||||
if (done == budget || !clean_complete) {
|
if (done == budget || !clean_complete) {
|
||||||
const struct cpumask *aff;
|
|
||||||
struct irq_data *idata;
|
|
||||||
int cpu_curr;
|
int cpu_curr;
|
||||||
|
|
||||||
/* in case we got here because of !clean_complete */
|
/* in case we got here because of !clean_complete */
|
||||||
@@ -969,10 +967,8 @@ int mlx4_en_poll_rx_cq(struct napi_struct *napi, int budget)
|
|||||||
INC_PERF_COUNTER(priv->pstats.napi_quota);
|
INC_PERF_COUNTER(priv->pstats.napi_quota);
|
||||||
|
|
||||||
cpu_curr = smp_processor_id();
|
cpu_curr = smp_processor_id();
|
||||||
idata = irq_desc_get_irq_data(cq->irq_desc);
|
|
||||||
aff = irq_data_get_affinity_mask(idata);
|
|
||||||
|
|
||||||
if (likely(cpumask_test_cpu(cpu_curr, aff)))
|
if (likely(cpumask_test_cpu(cpu_curr, cq->aff_mask)))
|
||||||
return budget;
|
return budget;
|
||||||
|
|
||||||
/* Current cpu is not according to smp_irq_affinity -
|
/* Current cpu is not according to smp_irq_affinity -
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <linux/cpu_rmap.h>
|
#include <linux/cpu_rmap.h>
|
||||||
#include <linux/ptp_clock_kernel.h>
|
#include <linux/ptp_clock_kernel.h>
|
||||||
|
#include <linux/irq.h>
|
||||||
#include <net/xdp.h>
|
#include <net/xdp.h>
|
||||||
|
|
||||||
#include <linux/mlx4/device.h>
|
#include <linux/mlx4/device.h>
|
||||||
@@ -380,7 +381,7 @@ struct mlx4_en_cq {
|
|||||||
struct mlx4_cqe *buf;
|
struct mlx4_cqe *buf;
|
||||||
#define MLX4_EN_OPCODE_ERROR 0x1e
|
#define MLX4_EN_OPCODE_ERROR 0x1e
|
||||||
|
|
||||||
struct irq_desc *irq_desc;
|
const struct cpumask *aff_mask;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mlx4_en_port_profile {
|
struct mlx4_en_port_profile {
|
||||||
|
|||||||
Reference in New Issue
Block a user