Commit fba917b1 authored by Praveen Kaligineedi's avatar Praveen Kaligineedi Committed by Jakub Kicinski

gve: Fix use of netif_carrier_ok()

GVE driver wrongly relies on netif_carrier_ok() to check the
interface administrative state when resources are being
allocated/deallocated for queue(s). netif_carrier_ok() needs
to be replaced with netif_running() for all such cases.

Administrative state is the result of "ip link set dev <dev>
up/down". It reflects whether the administrator wants to use
the device for traffic and the corresponding resources have
been allocated.

Fixes: 5f08cd3d ("gve: Alloc before freeing when adjusting queues")
Signed-off-by: default avatarPraveen Kaligineedi <pkaligineedi@google.com>
Reviewed-by: default avatarShailend Chand <shailend@google.com>
Reviewed-by: default avatarWillem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20240801205619.987396-1-pkaligineedi@google.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 89108cb5
...@@ -495,7 +495,7 @@ static int gve_set_channels(struct net_device *netdev, ...@@ -495,7 +495,7 @@ static int gve_set_channels(struct net_device *netdev,
return -EINVAL; return -EINVAL;
} }
if (!netif_carrier_ok(netdev)) { if (!netif_running(netdev)) {
priv->tx_cfg.num_queues = new_tx; priv->tx_cfg.num_queues = new_tx;
priv->rx_cfg.num_queues = new_rx; priv->rx_cfg.num_queues = new_rx;
return 0; return 0;
......
...@@ -1566,7 +1566,7 @@ static int gve_set_xdp(struct gve_priv *priv, struct bpf_prog *prog, ...@@ -1566,7 +1566,7 @@ static int gve_set_xdp(struct gve_priv *priv, struct bpf_prog *prog,
u32 status; u32 status;
old_prog = READ_ONCE(priv->xdp_prog); old_prog = READ_ONCE(priv->xdp_prog);
if (!netif_carrier_ok(priv->dev)) { if (!netif_running(priv->dev)) {
WRITE_ONCE(priv->xdp_prog, prog); WRITE_ONCE(priv->xdp_prog, prog);
if (old_prog) if (old_prog)
bpf_prog_put(old_prog); bpf_prog_put(old_prog);
...@@ -1847,7 +1847,7 @@ int gve_adjust_queues(struct gve_priv *priv, ...@@ -1847,7 +1847,7 @@ int gve_adjust_queues(struct gve_priv *priv,
rx_alloc_cfg.qcfg = &new_rx_config; rx_alloc_cfg.qcfg = &new_rx_config;
tx_alloc_cfg.num_rings = new_tx_config.num_queues; tx_alloc_cfg.num_rings = new_tx_config.num_queues;
if (netif_carrier_ok(priv->dev)) { if (netif_running(priv->dev)) {
err = gve_adjust_config(priv, &tx_alloc_cfg, &rx_alloc_cfg); err = gve_adjust_config(priv, &tx_alloc_cfg, &rx_alloc_cfg);
return err; return err;
} }
...@@ -2064,7 +2064,7 @@ static int gve_set_features(struct net_device *netdev, ...@@ -2064,7 +2064,7 @@ static int gve_set_features(struct net_device *netdev,
if ((netdev->features & NETIF_F_LRO) != (features & NETIF_F_LRO)) { if ((netdev->features & NETIF_F_LRO) != (features & NETIF_F_LRO)) {
netdev->features ^= NETIF_F_LRO; netdev->features ^= NETIF_F_LRO;
if (netif_carrier_ok(netdev)) { if (netif_running(netdev)) {
err = gve_adjust_config(priv, &tx_alloc_cfg, &rx_alloc_cfg); err = gve_adjust_config(priv, &tx_alloc_cfg, &rx_alloc_cfg);
if (err) if (err)
goto revert_features; goto revert_features;
...@@ -2359,7 +2359,7 @@ static int gve_reset_recovery(struct gve_priv *priv, bool was_up) ...@@ -2359,7 +2359,7 @@ static int gve_reset_recovery(struct gve_priv *priv, bool was_up)
int gve_reset(struct gve_priv *priv, bool attempt_teardown) int gve_reset(struct gve_priv *priv, bool attempt_teardown)
{ {
bool was_up = netif_carrier_ok(priv->dev); bool was_up = netif_running(priv->dev);
int err; int err;
dev_info(&priv->pdev->dev, "Performing reset\n"); dev_info(&priv->pdev->dev, "Performing reset\n");
...@@ -2700,7 +2700,7 @@ static void gve_shutdown(struct pci_dev *pdev) ...@@ -2700,7 +2700,7 @@ static void gve_shutdown(struct pci_dev *pdev)
{ {
struct net_device *netdev = pci_get_drvdata(pdev); struct net_device *netdev = pci_get_drvdata(pdev);
struct gve_priv *priv = netdev_priv(netdev); struct gve_priv *priv = netdev_priv(netdev);
bool was_up = netif_carrier_ok(priv->dev); bool was_up = netif_running(priv->dev);
rtnl_lock(); rtnl_lock();
if (was_up && gve_close(priv->dev)) { if (was_up && gve_close(priv->dev)) {
...@@ -2718,7 +2718,7 @@ static int gve_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -2718,7 +2718,7 @@ static int gve_suspend(struct pci_dev *pdev, pm_message_t state)
{ {
struct net_device *netdev = pci_get_drvdata(pdev); struct net_device *netdev = pci_get_drvdata(pdev);
struct gve_priv *priv = netdev_priv(netdev); struct gve_priv *priv = netdev_priv(netdev);
bool was_up = netif_carrier_ok(priv->dev); bool was_up = netif_running(priv->dev);
priv->suspend_cnt++; priv->suspend_cnt++;
rtnl_lock(); rtnl_lock();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment