Skip to content

Commit

Permalink
net: mdio: introduce a shutdown method to mdio device drivers
Browse files Browse the repository at this point in the history
MDIO-attached devices might have interrupts and other things that might
need quiesced when we kexec into a new kernel. Things are even more
creepy when those interrupt lines are shared, and in that case it is
absolutely mandatory to disable all interrupt sources.

Moreover, MDIO devices might be DSA switches, and DSA needs its own
shutdown method to unlink from the DSA master, which is a new
requirement that appeared after commit 2f1e8ea ("net: dsa: link
interfaces with the DSA master to get rid of lockdep warnings").

So introduce a ->shutdown method in the MDIO device driver structure.

Signed-off-by: Vladimir Oltean <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
Reviewed-by: Florian Fainelli <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
vladimiroltean authored and davem330 committed Sep 19, 2021
1 parent 02319bf commit cf95799
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/net/phy/mdio_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,16 @@ static int mdio_remove(struct device *dev)
return 0;
}

static void mdio_shutdown(struct device *dev)
{
struct mdio_device *mdiodev = to_mdio_device(dev);
struct device_driver *drv = mdiodev->dev.driver;
struct mdio_driver *mdiodrv = to_mdio_driver(drv);

if (mdiodrv->shutdown)
mdiodrv->shutdown(mdiodev);
}

/**
* mdio_driver_register - register an mdio_driver with the MDIO layer
* @drv: new mdio_driver to register
Expand All @@ -193,6 +203,7 @@ int mdio_driver_register(struct mdio_driver *drv)
mdiodrv->driver.bus = &mdio_bus_type;
mdiodrv->driver.probe = mdio_probe;
mdiodrv->driver.remove = mdio_remove;
mdiodrv->driver.shutdown = mdio_shutdown;

retval = driver_register(&mdiodrv->driver);
if (retval) {
Expand Down
3 changes: 3 additions & 0 deletions include/linux/mdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ struct mdio_driver {

/* Clears up any memory if needed */
void (*remove)(struct mdio_device *mdiodev);

/* Quiesces the device on system shutdown, turns off interrupts etc */
void (*shutdown)(struct mdio_device *mdiodev);
};

static inline struct mdio_driver *
Expand Down

0 comments on commit cf95799

Please sign in to comment.