net: dsa: bcm_sf2: Fix unbind ordering
authorFlorian Fainelli <f.fainelli@gmail.com>
Tue, 9 Oct 2018 23:48:57 +0000 (16:48 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 11 Oct 2018 05:53:02 +0000 (22:53 -0700)
commit448765e1cfa6b9b286dc45b0224b9a641b05eeb9
treee6a30efb847bf0b7066e916bf0fa721e0a724fd6
parentf98ebd47fd0da1717267ce1583a105d8cc29a16a
net: dsa: bcm_sf2: Fix unbind ordering

The order in which we release resources is unfortunately leading to bus
errors while dismantling the port. This is because we set
priv->wol_ports_mask to 0 to tell bcm_sf2_sw_suspend() that it is now
permissible to clock gate the switch. Later on, when dsa_slave_destroy()
comes in from dsa_unregister_switch() and calls
dsa_switch_ops::port_disable, we perform the same dismantling again, and
this time we hit registers that are clock gated.

Make sure that dsa_unregister_switch() is the first thing that happens,
which takes care of releasing all user visible resources, then proceed
with clock gating hardware. We still need to set priv->wol_ports_mask to
0 to make sure that an enabled port properly gets disabled in case it
was previously used as part of Wake-on-LAN.

Fixes: d9338023fb8e ("net: dsa: bcm_sf2: Make it a real platform device driver")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/bcm_sf2.c