Message ID | 20220914015120.3023123-1-dqfext@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [net] net: stmmac: fix invalid usage of irq_set_affinity_hint | expand |
On 2022-09-14 02:51, Qingfang DENG wrote: > The cpumask should not be a local variable, since its pointer is saved > to irq_desc and may be accessed from procfs. > To fix it, store cpumask to the heap. FWIW, by the look of it you might be able to use cpumask_of() and not store anything at all. Robin. > Fixes: 8deec94c6040 ("net: stmmac: set IRQ affinity hint for multi MSI vectors") > Signed-off-by: Qingfang DENG <dqfext@gmail.com> > --- > drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 ++ > drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 15 ++++++++------- > 2 files changed, 10 insertions(+), 7 deletions(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h > index bdbf86cb102a..720e9f2a40d8 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h > @@ -77,6 +77,7 @@ struct stmmac_tx_queue { > dma_addr_t dma_tx_phy; > dma_addr_t tx_tail_addr; > u32 mss; > + cpumask_t cpu_mask; > }; > > struct stmmac_rx_buffer { > @@ -114,6 +115,7 @@ struct stmmac_rx_queue { > unsigned int len; > unsigned int error; > } state; > + cpumask_t cpu_mask; > }; > > struct stmmac_channel { > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > index 8418e795cc21..7b1c1be998e3 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > @@ -3469,7 +3469,6 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev) > { > struct stmmac_priv *priv = netdev_priv(dev); > enum request_irq_err irq_err; > - cpumask_t cpu_mask; > int irq_idx = 0; > char *int_name; > int ret; > @@ -3580,9 +3579,10 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev) > irq_idx = i; > goto irq_error; > } > - cpumask_clear(&cpu_mask); > - cpumask_set_cpu(i % num_online_cpus(), &cpu_mask); > - irq_set_affinity_hint(priv->rx_irq[i], &cpu_mask); > + cpumask_set_cpu(i % num_online_cpus(), > + &priv->dma_conf.rx_queue[i].cpu_mask); > + irq_set_affinity_hint(priv->rx_irq[i], > + &priv->dma_conf.rx_queue[i].cpu_mask); > } > > /* Request Tx MSI irq */ > @@ -3605,9 +3605,10 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev) > irq_idx = i; > goto irq_error; > } > - cpumask_clear(&cpu_mask); > - cpumask_set_cpu(i % num_online_cpus(), &cpu_mask); > - irq_set_affinity_hint(priv->tx_irq[i], &cpu_mask); > + cpumask_set_cpu(i % num_online_cpus(), > + &priv->dma_conf.tx_queue[i].cpu_mask); > + irq_set_affinity_hint(priv->tx_irq[i], > + &priv->dma_conf.tx_queue[i].cpu_mask); > } > > return 0;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index bdbf86cb102a..720e9f2a40d8 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -77,6 +77,7 @@ struct stmmac_tx_queue { dma_addr_t dma_tx_phy; dma_addr_t tx_tail_addr; u32 mss; + cpumask_t cpu_mask; }; struct stmmac_rx_buffer { @@ -114,6 +115,7 @@ struct stmmac_rx_queue { unsigned int len; unsigned int error; } state; + cpumask_t cpu_mask; }; struct stmmac_channel { diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 8418e795cc21..7b1c1be998e3 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -3469,7 +3469,6 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev) { struct stmmac_priv *priv = netdev_priv(dev); enum request_irq_err irq_err; - cpumask_t cpu_mask; int irq_idx = 0; char *int_name; int ret; @@ -3580,9 +3579,10 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev) irq_idx = i; goto irq_error; } - cpumask_clear(&cpu_mask); - cpumask_set_cpu(i % num_online_cpus(), &cpu_mask); - irq_set_affinity_hint(priv->rx_irq[i], &cpu_mask); + cpumask_set_cpu(i % num_online_cpus(), + &priv->dma_conf.rx_queue[i].cpu_mask); + irq_set_affinity_hint(priv->rx_irq[i], + &priv->dma_conf.rx_queue[i].cpu_mask); } /* Request Tx MSI irq */ @@ -3605,9 +3605,10 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev) irq_idx = i; goto irq_error; } - cpumask_clear(&cpu_mask); - cpumask_set_cpu(i % num_online_cpus(), &cpu_mask); - irq_set_affinity_hint(priv->tx_irq[i], &cpu_mask); + cpumask_set_cpu(i % num_online_cpus(), + &priv->dma_conf.tx_queue[i].cpu_mask); + irq_set_affinity_hint(priv->tx_irq[i], + &priv->dma_conf.tx_queue[i].cpu_mask); } return 0;
The cpumask should not be a local variable, since its pointer is saved to irq_desc and may be accessed from procfs. To fix it, store cpumask to the heap. Fixes: 8deec94c6040 ("net: stmmac: set IRQ affinity hint for multi MSI vectors") Signed-off-by: Qingfang DENG <dqfext@gmail.com> --- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 ++ drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 15 ++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-)