* [PATCH net 1/2] nfp: fix NULL pointer access when scheduling dim work
2021-10-29 11:29 [PATCH net 0/2] nfp: fix bugs caused by adaptive coalesce Simon Horman
@ 2021-10-29 11:29 ` Simon Horman
2021-10-29 11:29 ` [PATCH net 2/2] nfp: fix potential deadlock when canceling " Simon Horman
2021-10-29 12:50 ` [PATCH net 0/2] nfp: fix bugs caused by adaptive coalesce patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2021-10-29 11:29 UTC (permalink / raw)
To: David Miller, Jakub Kicinski
Cc: netdev, oss-drivers, Yinjun Zhang, Louis Peens, Simon Horman
From: Yinjun Zhang <yinjun.zhang@corigine.com>
Each rx/tx ring has a related dim work, when rx/tx ring number is
decreased by `ethtool -L`, the corresponding rx_ring or tx_ring is
assigned NULL, while its related work is not destroyed. When scheduled,
the work will access NULL pointer.
Fixes: 9d32e4e7e9e1 ("nfp: add support for coalesce adaptive feature")
Signed-off-by: Yinjun Zhang <yinjun.zhang@corigine.com>
Signed-off-by: Louis Peens <louis.peens@corigine.com>
Signed-off-by: Simon Horman <simon.horman@corigine.com>
---
drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
index 5bfa22accf2c..f8b880c8e514 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
@@ -2067,7 +2067,7 @@ static int nfp_net_poll(struct napi_struct *napi, int budget)
if (napi_complete_done(napi, pkts_polled))
nfp_net_irq_unmask(r_vec->nfp_net, r_vec->irq_entry);
- if (r_vec->nfp_net->rx_coalesce_adapt_on) {
+ if (r_vec->nfp_net->rx_coalesce_adapt_on && r_vec->rx_ring) {
struct dim_sample dim_sample = {};
unsigned int start;
u64 pkts, bytes;
@@ -2082,7 +2082,7 @@ static int nfp_net_poll(struct napi_struct *napi, int budget)
net_dim(&r_vec->rx_dim, dim_sample);
}
- if (r_vec->nfp_net->tx_coalesce_adapt_on) {
+ if (r_vec->nfp_net->tx_coalesce_adapt_on && r_vec->tx_ring) {
struct dim_sample dim_sample = {};
unsigned int start;
u64 pkts, bytes;
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH net 2/2] nfp: fix potential deadlock when canceling dim work
2021-10-29 11:29 [PATCH net 0/2] nfp: fix bugs caused by adaptive coalesce Simon Horman
2021-10-29 11:29 ` [PATCH net 1/2] nfp: fix NULL pointer access when scheduling dim work Simon Horman
@ 2021-10-29 11:29 ` Simon Horman
2021-10-29 12:50 ` [PATCH net 0/2] nfp: fix bugs caused by adaptive coalesce patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2021-10-29 11:29 UTC (permalink / raw)
To: David Miller, Jakub Kicinski
Cc: netdev, oss-drivers, Yinjun Zhang, Louis Peens, Simon Horman
From: Yinjun Zhang <yinjun.zhang@corigine.com>
When port is linked down, the process which has acquired rtnl_lock
will wait for the in-progress dim work to finish, and the work also
acquires rtnl_lock, which may cause deadlock.
Currently IRQ_MOD registers can be configured by `ethtool -C` and
dim work, and which will take effect depends on the execution order,
rtnl_lock is useless here, so remove them.
Fixes: 9d32e4e7e9e1 ("nfp: add support for coalesce adaptive feature")
Signed-off-by: Yinjun Zhang <yinjun.zhang@corigine.com>
Signed-off-by: Louis Peens <louis.peens@corigine.com>
Signed-off-by: Simon Horman <simon.horman@corigine.com>
---
drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
index f8b880c8e514..850bfdf83d0a 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
@@ -3016,10 +3016,8 @@ static void nfp_net_rx_dim_work(struct work_struct *work)
/* copy RX interrupt coalesce parameters */
value = (moder.pkts << 16) | (factor * moder.usec);
- rtnl_lock();
nn_writel(nn, NFP_NET_CFG_RXR_IRQ_MOD(r_vec->rx_ring->idx), value);
(void)nfp_net_reconfig(nn, NFP_NET_CFG_UPDATE_IRQMOD);
- rtnl_unlock();
dim->state = DIM_START_MEASURE;
}
@@ -3047,10 +3045,8 @@ static void nfp_net_tx_dim_work(struct work_struct *work)
/* copy TX interrupt coalesce parameters */
value = (moder.pkts << 16) | (factor * moder.usec);
- rtnl_lock();
nn_writel(nn, NFP_NET_CFG_TXR_IRQ_MOD(r_vec->tx_ring->idx), value);
(void)nfp_net_reconfig(nn, NFP_NET_CFG_UPDATE_IRQMOD);
- rtnl_unlock();
dim->state = DIM_START_MEASURE;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net 0/2] nfp: fix bugs caused by adaptive coalesce
2021-10-29 11:29 [PATCH net 0/2] nfp: fix bugs caused by adaptive coalesce Simon Horman
2021-10-29 11:29 ` [PATCH net 1/2] nfp: fix NULL pointer access when scheduling dim work Simon Horman
2021-10-29 11:29 ` [PATCH net 2/2] nfp: fix potential deadlock when canceling " Simon Horman
@ 2021-10-29 12:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-10-29 12:50 UTC (permalink / raw)
To: Simon Horman; +Cc: davem, kuba, netdev, oss-drivers, yinjun.zhang, louis.peens
Hello:
This series was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:
On Fri, 29 Oct 2021 13:29:01 +0200 you wrote:
> Hi,
>
> this series contains fixes for two bugs introduced when
> when adaptive coalesce support was added to the NFP driver in
> v5.15 by 9d32e4e7e9e1 ("nfp: add support for coalesce adaptive feature")
>
> Yinjun Zhang (2):
> nfp: fix NULL pointer access when scheduling dim work
> nfp: fix potential deadlock when canceling dim work
>
> [...]
Here is the summary with links:
- [net,1/2] nfp: fix NULL pointer access when scheduling dim work
https://git.kernel.org/netdev/net/c/f8d384a640dd
- [net,2/2] nfp: fix potential deadlock when canceling dim work
https://git.kernel.org/netdev/net/c/17e712c6a1ba
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread