Skip to content

Commit

Permalink
Revert "sh_eth: remove open coded netif_running()"
Browse files Browse the repository at this point in the history
This reverts commit ce1fdb0. It turned
out this actually introduces a race condition. netif_running() is not a
suitable check for get_stats.

Reported-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/20230327152112.15635-1-wsa+renesas@sang-engineering.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Wolfram Sang authored and Jakub Kicinski committed Mar 29, 2023
1 parent 2600bad commit cdeccd1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/net/ethernet/renesas/sh_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -2441,6 +2441,8 @@ static int sh_eth_open(struct net_device *ndev)

netif_start_queue(ndev);

mdp->is_opened = 1;

return ret;

out_free_irq:
Expand Down Expand Up @@ -2563,7 +2565,7 @@ static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev)
if (mdp->cd->no_tx_cntrs)
return &ndev->stats;

if (!netif_running(ndev))
if (!mdp->is_opened)
return &ndev->stats;

sh_eth_update_stat(ndev, &ndev->stats.tx_dropped, TROCR);
Expand Down Expand Up @@ -2612,6 +2614,8 @@ static int sh_eth_close(struct net_device *ndev)
/* Free all the skbuffs in the Rx queue and the DMA buffer. */
sh_eth_ring_free(ndev);

mdp->is_opened = 0;

pm_runtime_put(&mdp->pdev->dev);

return 0;
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/renesas/sh_eth.h
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ struct sh_eth_private {

unsigned no_ether_link:1;
unsigned ether_link_active_low:1;
unsigned is_opened:1;
unsigned wol_enabled:1;
};

Expand Down

0 comments on commit cdeccd1

Please sign in to comment.