[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <65db2835-f70a-dcaf-7949-879e10bd9ebc@arm.com>
Date: Wed, 14 Sep 2022 11:47:32 +0100
From: Robin Murphy <robin.murphy@....com>
To: Qingfang DENG <dqfext@...il.com>,
Giuseppe Cavallaro <peppe.cavallaro@...com>,
Alexandre Torgue <alexandre.torgue@...s.st.com>,
Jose Abreu <joabreu@...opsys.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Maxime Coquelin <mcoquelin.stm32@...il.com>,
Ong Boon Leong <boon.leong.ong@...el.com>,
netdev@...r.kernel.org, linux-stm32@...md-mailman.stormreply.com,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net] net: stmmac: fix invalid usage of
irq_set_affinity_hint
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@...il.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;
Powered by blists - more mailing lists