Commit 230bd958 authored by Matteo Croce's avatar Matteo Croce Committed by David S. Miller

mvpp2: refactor MTU change code

The MTU change code can call napi_disable() with the device already down,
leading to a deadlock. Also, lot of code is duplicated unnecessarily.

Rework mvpp2_change_mtu() to avoid the deadlock and remove duplicated code.

Fixes: 3f518509 ("ethernet: Add new driver for Marvell Armada 375 network unit")
Signed-off-by: default avatarMatteo Croce <mcroce@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 011f1754
...@@ -3700,6 +3700,7 @@ static int mvpp2_set_mac_address(struct net_device *dev, void *p) ...@@ -3700,6 +3700,7 @@ static int mvpp2_set_mac_address(struct net_device *dev, void *p)
static int mvpp2_change_mtu(struct net_device *dev, int mtu) static int mvpp2_change_mtu(struct net_device *dev, int mtu)
{ {
struct mvpp2_port *port = netdev_priv(dev); struct mvpp2_port *port = netdev_priv(dev);
bool running = netif_running(dev);
int err; int err;
if (!IS_ALIGNED(MVPP2_RX_PKT_SIZE(mtu), 8)) { if (!IS_ALIGNED(MVPP2_RX_PKT_SIZE(mtu), 8)) {
...@@ -3708,40 +3709,24 @@ static int mvpp2_change_mtu(struct net_device *dev, int mtu) ...@@ -3708,40 +3709,24 @@ static int mvpp2_change_mtu(struct net_device *dev, int mtu)
mtu = ALIGN(MVPP2_RX_PKT_SIZE(mtu), 8); mtu = ALIGN(MVPP2_RX_PKT_SIZE(mtu), 8);
} }
if (!netif_running(dev)) { if (running)
err = mvpp2_bm_update_mtu(dev, mtu); mvpp2_stop_dev(port);
if (!err) {
port->pkt_size = MVPP2_RX_PKT_SIZE(mtu);
return 0;
}
/* Reconfigure BM to the original MTU */
err = mvpp2_bm_update_mtu(dev, dev->mtu);
if (err)
goto log_error;
}
mvpp2_stop_dev(port);
err = mvpp2_bm_update_mtu(dev, mtu); err = mvpp2_bm_update_mtu(dev, mtu);
if (!err) { if (err) {
netdev_err(dev, "failed to change MTU\n");
/* Reconfigure BM to the original MTU */
mvpp2_bm_update_mtu(dev, dev->mtu);
} else {
port->pkt_size = MVPP2_RX_PKT_SIZE(mtu); port->pkt_size = MVPP2_RX_PKT_SIZE(mtu);
goto out_start;
} }
/* Reconfigure BM to the original MTU */ if (running) {
err = mvpp2_bm_update_mtu(dev, dev->mtu); mvpp2_start_dev(port);
if (err) mvpp2_egress_enable(port);
goto log_error; mvpp2_ingress_enable(port);
}
out_start:
mvpp2_start_dev(port);
mvpp2_egress_enable(port);
mvpp2_ingress_enable(port);
return 0;
log_error:
netdev_err(dev, "failed to change MTU\n");
return err; return err;
} }
......
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