All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: lapbether: Remove netif_start_queue / netif_stop_queue
@ 2021-03-07 11:33 Xie He
  2021-03-09 13:48 ` Martin Schiller
  2021-03-10  0:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Xie He @ 2021-03-07 11:33 UTC (permalink / raw)
  To: Martin Schiller, David S. Miller, Jakub Kicinski, linux-x25,
	netdev, linux-kernel
  Cc: Xie He

For the devices in this driver, the default qdisc is "noqueue",
because their "tx_queue_len" is 0.

In function "__dev_queue_xmit" in "net/core/dev.c", devices with the
"noqueue" qdisc are specially handled. Packets are transmitted without
being queued after a "dev->flags & IFF_UP" check. However, it's possible
that even if this check succeeds, "ops->ndo_stop" may still have already
been called. This is because in "__dev_close_many", "ops->ndo_stop" is
called before clearing the "IFF_UP" flag.

If we call "netif_stop_queue" in "ops->ndo_stop", then it's possible in
"__dev_queue_xmit", it sees the "IFF_UP" flag is present, and then it
checks "netif_xmit_stopped" and finds that the queue is already stopped.
In this case, it will complain that:
"Virtual device ... asks to queue packet!"

To prevent "__dev_queue_xmit" from generating this complaint, we should
not call "netif_stop_queue" in "ops->ndo_stop".

We also don't need to call "netif_start_queue" in "ops->ndo_open",
because after a netdev is allocated and registered, the
"__QUEUE_STATE_DRV_XOFF" flag is initially not set, so there is no need
to call "netif_start_queue" to clear it.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Xie He <xie.he.0141@gmail.com>
---
 drivers/net/wan/lapbether.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
index 605fe555e157..c3372498f4f1 100644
--- a/drivers/net/wan/lapbether.c
+++ b/drivers/net/wan/lapbether.c
@@ -292,7 +292,6 @@ static int lapbeth_open(struct net_device *dev)
 		return -ENODEV;
 	}
 
-	netif_start_queue(dev);
 	return 0;
 }
 
@@ -300,8 +299,6 @@ static int lapbeth_close(struct net_device *dev)
 {
 	int err;
 
-	netif_stop_queue(dev);
-
 	if ((err = lapb_unregister(dev)) != LAPB_OK)
 		pr_err("lapb_unregister error: %d\n", err);
 
-- 
2.27.0


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

* Re: [PATCH net] net: lapbether: Remove netif_start_queue / netif_stop_queue
  2021-03-07 11:33 [PATCH net] net: lapbether: Remove netif_start_queue / netif_stop_queue Xie He
@ 2021-03-09 13:48 ` Martin Schiller
  2021-03-10  0:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Martin Schiller @ 2021-03-09 13:48 UTC (permalink / raw)
  To: Xie He; +Cc: David S. Miller, Jakub Kicinski, linux-x25, netdev, linux-kernel

On 2021-03-07 12:33, Xie He wrote:
> For the devices in this driver, the default qdisc is "noqueue",
> because their "tx_queue_len" is 0.
> 
> In function "__dev_queue_xmit" in "net/core/dev.c", devices with the
> "noqueue" qdisc are specially handled. Packets are transmitted without
> being queued after a "dev->flags & IFF_UP" check. However, it's 
> possible
> that even if this check succeeds, "ops->ndo_stop" may still have 
> already
> been called. This is because in "__dev_close_many", "ops->ndo_stop" is
> called before clearing the "IFF_UP" flag.
> 
> If we call "netif_stop_queue" in "ops->ndo_stop", then it's possible in
> "__dev_queue_xmit", it sees the "IFF_UP" flag is present, and then it
> checks "netif_xmit_stopped" and finds that the queue is already 
> stopped.
> In this case, it will complain that:
> "Virtual device ... asks to queue packet!"
> 
> To prevent "__dev_queue_xmit" from generating this complaint, we should
> not call "netif_stop_queue" in "ops->ndo_stop".
> 
> We also don't need to call "netif_start_queue" in "ops->ndo_open",
> because after a netdev is allocated and registered, the
> "__QUEUE_STATE_DRV_XOFF" flag is initially not set, so there is no need
> to call "netif_start_queue" to clear it.
> 
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Xie He <xie.he.0141@gmail.com>
> ---
>  drivers/net/wan/lapbether.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
> index 605fe555e157..c3372498f4f1 100644
> --- a/drivers/net/wan/lapbether.c
> +++ b/drivers/net/wan/lapbether.c
> @@ -292,7 +292,6 @@ static int lapbeth_open(struct net_device *dev)
>  		return -ENODEV;
>  	}
> 
> -	netif_start_queue(dev);
>  	return 0;
>  }
> 
> @@ -300,8 +299,6 @@ static int lapbeth_close(struct net_device *dev)
>  {
>  	int err;
> 
> -	netif_stop_queue(dev);
> -
>  	if ((err = lapb_unregister(dev)) != LAPB_OK)
>  		pr_err("lapb_unregister error: %d\n", err);

Seems reasonable to me.

Acked-by: Martin Schiller <ms@dev.tdt.de>

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

* Re: [PATCH net] net: lapbether: Remove netif_start_queue / netif_stop_queue
  2021-03-07 11:33 [PATCH net] net: lapbether: Remove netif_start_queue / netif_stop_queue Xie He
  2021-03-09 13:48 ` Martin Schiller
@ 2021-03-10  0:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-03-10  0:10 UTC (permalink / raw)
  To: Xie He; +Cc: ms, davem, kuba, linux-x25, netdev, linux-kernel

Hello:

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

On Sun,  7 Mar 2021 03:33:07 -0800 you wrote:
> For the devices in this driver, the default qdisc is "noqueue",
> because their "tx_queue_len" is 0.
> 
> In function "__dev_queue_xmit" in "net/core/dev.c", devices with the
> "noqueue" qdisc are specially handled. Packets are transmitted without
> being queued after a "dev->flags & IFF_UP" check. However, it's possible
> that even if this check succeeds, "ops->ndo_stop" may still have already
> been called. This is because in "__dev_close_many", "ops->ndo_stop" is
> called before clearing the "IFF_UP" flag.
> 
> [...]

Here is the summary with links:
  - [net] net: lapbether: Remove netif_start_queue / netif_stop_queue
    https://git.kernel.org/netdev/net/c/f7d9d4854519

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

end of thread, other threads:[~2021-03-10  0:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-07 11:33 [PATCH net] net: lapbether: Remove netif_start_queue / netif_stop_queue Xie He
2021-03-09 13:48 ` Martin Schiller
2021-03-10  0:10 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.