]> git.baikalelectronics.ru Git - kernel.git/commit
net: dsa: lantiq_gswip: don't use devres for mdiobus
authorVladimir Oltean <vladimir.oltean@nxp.com>
Mon, 7 Feb 2022 16:15:53 +0000 (18:15 +0200)
committerJakub Kicinski <kuba@kernel.org>
Wed, 9 Feb 2022 04:30:36 +0000 (20:30 -0800)
commitb88a9e845fcd11752117c61973db9649380bd53a
treeedb2ef6be23852af1ccd20ca0ec12e30fa931e70
parent902c4a2b95e54a09c76c4a00d8fc2cf4ea42d16d
net: dsa: lantiq_gswip: don't use devres for mdiobus

As explained in commits:
be17118eaf26 ("net: dsa: realtek: register the MDIO bus under devres")
2032b9170e22 ("net: dsa: don't allocate the slave_mii_bus using devres")

mdiobus_free() will panic when called from devm_mdiobus_free() <-
devres_release_all() <- __device_release_driver(), and that mdiobus was
not previously unregistered.

The GSWIP switch is a platform device, so the initial set of constraints
that I thought would cause this (I2C or SPI buses which call ->remove on
->shutdown) do not apply. But there is one more which applies here.

If the DSA master itself is on a bus that calls ->remove from ->shutdown
(like dpaa2-eth, which is on the fsl-mc bus), there is a device link
between the switch and the DSA master, and device_links_unbind_consumers()
will unbind the GSWIP switch driver on shutdown.

So the same treatment must be applied to all DSA switch drivers, which
is: either use devres for both the mdiobus allocation and registration,
or don't use devres at all.

The gswip driver has the code structure in place for orderly mdiobus
removal, so just replace devm_mdiobus_alloc() with the non-devres
variant, and add manual free where necessary, to ensure that we don't
let devres free a still-registered bus.

Fixes: 50298441a391 ("net: phy: don't abuse devres in devm_mdiobus_register()")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/lantiq_gswip.c