netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/3] ibmvnic: correctly call NAPI APIs
@ 2021-04-14  7:46 Lijun Pan
  2021-04-14  7:46 ` [PATCH net 1/3] ibmvnic: avoid calling napi_disable() twice Lijun Pan
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Lijun Pan @ 2021-04-14  7:46 UTC (permalink / raw)
  To: netdev; +Cc: Lijun Pan

This series correct some misuse of NAPI APIs in the driver.

Lijun Pan (3):
  ibmvnic: avoid calling napi_disable() twice
  ibmvnic: remove duplicate napi_schedule call in do_reset function
  ibmvnic: remove duplicate napi_schedule call in open function

 drivers/net/ethernet/ibm/ibmvnic.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

-- 
2.23.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net 1/3] ibmvnic: avoid calling napi_disable() twice
  2021-04-14  7:46 [PATCH net 0/3] ibmvnic: correctly call NAPI APIs Lijun Pan
@ 2021-04-14  7:46 ` Lijun Pan
  2021-04-14  7:46 ` [PATCH net 2/3] ibmvnic: remove duplicate napi_schedule call in do_reset function Lijun Pan
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Lijun Pan @ 2021-04-14  7:46 UTC (permalink / raw)
  To: netdev; +Cc: Lijun Pan, Thomas Falcon

__ibmvnic_open calls napi_disable without checking whether NAPI polling
has already been disabled or not. This could cause napi_disable
being called twice, which could generate deadlock. For example,
the first napi_disable will spin until NAPI_STATE_SCHED is cleared
by napi_complete_done, then set it again.
When napi_disable is called the second time, it will loop infinitely
because no dev->poll will be running to clear NAPI_STATE_SCHED.

To prevent above scenario from happening, call ibmvnic_napi_disable()
which checks if napi is disabled or not before calling napi_disable.

Fixes: bfc32f297337 ("ibmvnic: Move resource initialization to its own routine")
Suggested-by: Thomas Falcon <tlfalcon@linux.ibm.com>
Signed-off-by: Lijun Pan <lijunp213@gmail.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 110a0d0eaabb..2d27f8aa0d4b 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1149,8 +1149,7 @@ static int __ibmvnic_open(struct net_device *netdev)
 
 	rc = set_link_state(adapter, IBMVNIC_LOGICAL_LNK_UP);
 	if (rc) {
-		for (i = 0; i < adapter->req_rx_queues; i++)
-			napi_disable(&adapter->napi[i]);
+		ibmvnic_napi_disable(adapter);
 		release_resources(adapter);
 		return rc;
 	}
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net 2/3] ibmvnic: remove duplicate napi_schedule call in do_reset function
  2021-04-14  7:46 [PATCH net 0/3] ibmvnic: correctly call NAPI APIs Lijun Pan
  2021-04-14  7:46 ` [PATCH net 1/3] ibmvnic: avoid calling napi_disable() twice Lijun Pan
@ 2021-04-14  7:46 ` Lijun Pan
  2021-04-14  7:46 ` [PATCH net 3/3] ibmvnic: remove duplicate napi_schedule call in open function Lijun Pan
  2021-04-14 20:20 ` [PATCH net 0/3] ibmvnic: correctly call NAPI APIs patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Lijun Pan @ 2021-04-14  7:46 UTC (permalink / raw)
  To: netdev; +Cc: Lijun Pan

During adapter reset, do_reset/do_hard_reset calls ibmvnic_open(),
which will calls napi_schedule if previous state is VNIC_CLOSED
(i.e, the reset case, and "ifconfig down" case). So there is no need
for do_reset to call napi_schedule again at the end of the function
though napi_schedule will neglect the request if napi is already
scheduled.

Fixes: ed651a10875f ("ibmvnic: Updated reset handling")
Signed-off-by: Lijun Pan <lijunp213@gmail.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 2d27f8aa0d4b..f4bd63216672 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1921,7 +1921,7 @@ static int do_reset(struct ibmvnic_adapter *adapter,
 	u64 old_num_rx_queues, old_num_tx_queues;
 	u64 old_num_rx_slots, old_num_tx_slots;
 	struct net_device *netdev = adapter->netdev;
-	int i, rc;
+	int rc;
 
 	netdev_dbg(adapter->netdev,
 		   "[S:%d FOP:%d] Reset reason %d, reset_state %d\n",
@@ -2110,10 +2110,6 @@ static int do_reset(struct ibmvnic_adapter *adapter,
 	/* refresh device's multicast list */
 	ibmvnic_set_multi(netdev);
 
-	/* kick napi */
-	for (i = 0; i < adapter->req_rx_queues; i++)
-		napi_schedule(&adapter->napi[i]);
-
 	if (adapter->reset_reason == VNIC_RESET_FAILOVER ||
 	    adapter->reset_reason == VNIC_RESET_MOBILITY)
 		__netdev_notify_peers(netdev);
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net 3/3] ibmvnic: remove duplicate napi_schedule call in open function
  2021-04-14  7:46 [PATCH net 0/3] ibmvnic: correctly call NAPI APIs Lijun Pan
  2021-04-14  7:46 ` [PATCH net 1/3] ibmvnic: avoid calling napi_disable() twice Lijun Pan
  2021-04-14  7:46 ` [PATCH net 2/3] ibmvnic: remove duplicate napi_schedule call in do_reset function Lijun Pan
@ 2021-04-14  7:46 ` Lijun Pan
  2021-04-14 20:20 ` [PATCH net 0/3] ibmvnic: correctly call NAPI APIs patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Lijun Pan @ 2021-04-14  7:46 UTC (permalink / raw)
  To: netdev; +Cc: Lijun Pan

Remove the unnecessary napi_schedule() call in __ibmvnic_open() since
interrupt_rx() calls napi_schedule_prep/__napi_schedule during every
receive interrupt.

Fixes: ed651a10875f ("ibmvnic: Updated reset handling")
Signed-off-by: Lijun Pan <lijunp213@gmail.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index f4bd63216672..ffb2a91750c7 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1156,11 +1156,6 @@ static int __ibmvnic_open(struct net_device *netdev)
 
 	netif_tx_start_all_queues(netdev);
 
-	if (prev_state == VNIC_CLOSED) {
-		for (i = 0; i < adapter->req_rx_queues; i++)
-			napi_schedule(&adapter->napi[i]);
-	}
-
 	adapter->state = VNIC_OPEN;
 	return rc;
 }
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net 0/3] ibmvnic: correctly call NAPI APIs
  2021-04-14  7:46 [PATCH net 0/3] ibmvnic: correctly call NAPI APIs Lijun Pan
                   ` (2 preceding siblings ...)
  2021-04-14  7:46 ` [PATCH net 3/3] ibmvnic: remove duplicate napi_schedule call in open function Lijun Pan
@ 2021-04-14 20:20 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-04-14 20:20 UTC (permalink / raw)
  To: Lijun Pan; +Cc: netdev

Hello:

This series was applied to netdev/net.git (refs/heads/master):

On Wed, 14 Apr 2021 02:46:13 -0500 you wrote:
> This series correct some misuse of NAPI APIs in the driver.
> 
> Lijun Pan (3):
>   ibmvnic: avoid calling napi_disable() twice
>   ibmvnic: remove duplicate napi_schedule call in do_reset function
>   ibmvnic: remove duplicate napi_schedule call in open function
> 
> [...]

Here is the summary with links:
  - [net,1/3] ibmvnic: avoid calling napi_disable() twice
    https://git.kernel.org/netdev/net/c/0775ebc4cf85
  - [net,2/3] ibmvnic: remove duplicate napi_schedule call in do_reset function
    https://git.kernel.org/netdev/net/c/d3a6abccbd27
  - [net,3/3] ibmvnic: remove duplicate napi_schedule call in open function
    https://git.kernel.org/netdev/net/c/7c451f3ef676

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] 5+ messages in thread

end of thread, other threads:[~2021-04-14 20:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-14  7:46 [PATCH net 0/3] ibmvnic: correctly call NAPI APIs Lijun Pan
2021-04-14  7:46 ` [PATCH net 1/3] ibmvnic: avoid calling napi_disable() twice Lijun Pan
2021-04-14  7:46 ` [PATCH net 2/3] ibmvnic: remove duplicate napi_schedule call in do_reset function Lijun Pan
2021-04-14  7:46 ` [PATCH net 3/3] ibmvnic: remove duplicate napi_schedule call in open function Lijun Pan
2021-04-14 20:20 ` [PATCH net 0/3] ibmvnic: correctly call NAPI APIs patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).