e6000sw: fix incorrect locking

During attach we release the lock to call e6000sw_attach_miibus(), which
calls mii_attach(). The mii_attach() function calls miibus_readreg() /
miibus_writereg(). However, these are set to be
e6000sw_readphy_locked().

That is, the read/write phy functions do not acquire the lock, but
expect to be called while locked.  Simply do not unlock and relock while
calling mii_attach().

Reviewed by:	Hubert Mazur <hum@semihalf.com>
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D36117
This commit is contained in:
Kristof Provost 2022-08-10 15:57:05 +02:00
parent 820bafd0bc
commit 7647626d33

View File

@ -529,20 +529,11 @@ e6000sw_attach(device_t dev)
if (!e6000sw_is_phyport(sc, port))
continue;
/*
* It's necessary to unlock mutex, because e6000sw_attach_miibus
* calls functions, which try to lock mutex.That leads
* to recursive lock on non recursive mutex.
*/
E6000SW_UNLOCK(sc);
err = e6000sw_attach_miibus(sc, port);
if (err != 0) {
device_printf(sc->dev, "failed to attach miibus\n");
goto out_fail;
}
E6000SW_LOCK(sc);
}
etherswitch_info.es_nports = sc->num_ports;