From: Robin Murphy <robin.murphy@arm.com>
To: Qingfang DENG <dqfext@gmail.com>,
Giuseppe Cavallaro <peppe.cavallaro@st.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Jose Abreu <joabreu@synopsys.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Ong Boon Leong <boon.leong.ong@intel.com>,
netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] net: stmmac: fix invalid usage of irq_set_affinity_hint
Date: Wed, 14 Sep 2022 11:47:32 +0100 [thread overview]
Message-ID: <65db2835-f70a-dcaf-7949-879e10bd9ebc@arm.com> (raw)
In-Reply-To: <20220914015120.3023123-1-dqfext@gmail.com>
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;
prev parent reply other threads:[~2022-09-14 10:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-14 1:51 Qingfang DENG
2022-09-14 10:47 ` Robin Murphy [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=65db2835-f70a-dcaf-7949-879e10bd9ebc@arm.com \
--to=robin.murphy@arm.com \
--cc=alexandre.torgue@foss.st.com \
--cc=boon.leong.ong@intel.com \
--cc=davem@davemloft.net \
--cc=dqfext@gmail.com \
--cc=edumazet@google.com \
--cc=joabreu@synopsys.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=peppe.cavallaro@st.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®