• Russell King's avatar
    net: fec: quiesce packet processing before stopping device in fec_suspend() · 31a6de34
    Russell King authored
    fec_suspend() calls fec_stop() to stop the transmit ring while the
    transmit packet processing is still active.  This can lead to the
    transmit queue being restarted by an intervening packet queued for
    transmission, or by the tx quirk timer expiring.
    
    Fix this by disabling NAPI first, which will ensure that the NAPI
    handlers are not running.  Then, take the transmit lock before
    detaching the netif device.  This ensures that there are no races
    with the transmit path - and also ensures that the watchdog won't
    fire.
    
    We can then safely stop the ethernet device itself, knowing that the
    rest of the driver is safely shut down.
    
    On resume, we bring the device back up in reverse order - we restart
    the device, reattach the device (under the tx lock), and then enable
    the NAPI handlers.
    
    We also need to adjust the close function to cope with this new
    sequence, so that it's possible to cleanly close down the driver
    after the hardware fails to resume (eg, due to the regulator_enable()
    or pinctrl calls in the resume path returning an error.)
    Acked-by: default avatarFugang Duan <B38611@freescale.com>
    Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    31a6de34
fec_main.c 70.9 KB