You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
drivers: usb: dc: stm32: fix usb_disable() deadlock on certain series
During a teardown sequence performed by the USB DC stack's "usb_disable()",
the controller is first disabled by calling "usb_dc_detach()", which turns
off the USB controller clock in the STM32 implementation. "usb_disable()"
then disables endpoints by calling "usb_dc_ep_disable()" on each of them,
which is merely forwarded to HAL_PCD_EP_Close() by the STM32 driver. This
order of operations means that the latter operation is actually operating
on the no-longer-clocks USB controller! Up until recently, memory accesses
to MMIO of unclocked peripherals in STM32 SoCs would not cause issues, even
if the resulting access was a no-op (read returns zero, write is ignored),
so everything worked fine even if the access was *technically* illegal...
However, on newer series with a different bus fabric, accesses to unclocked
peripherals will instead deadlock the SoC!
Prevent illegal accesses inside "usb_dc_stm32_ep_disable()" by checking if
the USB controller clock is enabled before calling HAL_PCD_EP_Close(), and
skipping the call if it isn't. This allows "usb_disable()" to complete on
series such as STM32N6.
Signed-off-by: Mathieu Choplain <[email protected]>
0 commit comments