The media status change callback runs with the driver lock held, also
from the tick callout, but the set_speed method of the SoC specific
code can sleep: the Rockchip glue changes a clock, which takes the
clock topology sx lock. WITNESS reports a lock order reversal each
time the link comes up, and with a contended topology lock the callout
would sleep, or a thread would sleep with the driver mutex held.
Do not call the method from the media status change of the cores. The
common handler declares the link down instead and queues a task. The
task calls IF_DWC_SET_SPEED() with no lock held, then declares the link
up and restarts the transmit, unless the media changed again in the
meantime. The task is drained when the device detaches. The transmit
now waits for the task.
Fixes: 57f6320880ab ("dwc: rockchip: Add support for the RK3568 GMAC")
Reported by: llm-postcr
Tested on: Quartz64 Model A (RK3568) with 8GB of RAM: the lock order
reversal of dwc0 is gone at boot, the link comes up through the task with the clock read back at 125MHz, and a TCP transfer runs at 22.5 MB/s received and 19.8 MB/s sent at 816MHz, as before. Not tested on the RK3328 and the RK3399.