linux/drivers/usb/cdns3
Pawel Laszczak eae6460f61 usb: cdnsp: fix wakeup from S3 after controller context loss
CDNSP controller may lose its runtime register programming across S3
suspend/resume, depending on SoC power domain configuration. After
resume the operational and interrupter registers may contain reset
values, which prevents the gadget side from recovering correctly and
breaks wakeup from S3.

Fix this by detecting whether the controller lost its register context
after resume and handling both cases:
- If context was lost (CFG_3XPORT_U1_PIPE_CLK_GATE_EN set or power
  lost): reset the controller and reprogram the state required for
  normal operation, including the command ring, DCBAA pointer, doorbell
  base, event ring, ERST base/size and event ring dequeue pointer.
- If context was retained: restart the controller directly without
  reprogramming registers. Issue a wakeup if the link was in U3 before
  suspend.

Move the basic controller register programming out of the one-time memory
initialization path and make it reusable from the resume path. Also
separate ring allocation from ring initialization so that rings can be
reinitialized without reallocating DMA memory.

Always perform the full suspend sequence regardless of the current link
state. Previously, if the device was already in U3, the suspend callback
returned early without stopping the controller, which could lead to
commands being issued on a disabled slot during resume.

Fixes: 3d82904559 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver")
Cc: stable <stable@kernel.org>
Signed-off-by: Pawel Laszczak <pawell@cadence.com>
Acked-by: Peter Chen <peter.chen@kernel.org>
Link: https://patch.msgid.link/20260820-suspend_resume_fix-v3-1-5a713098b977@cadence.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-09-01 16:43:42 +02:00
..
cdns3-debug.h usb: cdns3: change trace event cdns3_ring() operation 2023-03-09 15:35:03 +01:00
cdns3-ep0.c usb: cdns3: Fixed incorrect gadget state 2021-07-29 14:13:02 +08:00
cdns3-gadget.c Linux 7.1-rc6 2026-06-01 17:39:51 +02:00
cdns3-gadget.h usb: cdns3: fix iso transfer error when mult is not zero 2024-01-04 16:01:44 +01:00
cdns3-imx.c usb: Switch back to struct platform_driver::remove() 2024-10-04 15:13:03 +02:00
cdns3-pci-wrap.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
cdns3-plat.c usb: cdns3: plat: fix a typo in cdns3_plat_probe() 2026-07-08 14:15:36 +02:00
cdns3-starfive.c usb: Switch back to struct platform_driver::remove() 2024-10-04 15:13:03 +02:00
cdns3-ti.c usb: cdns3-ti: run HW init at resume() if HW was reset 2025-03-14 09:18:02 +01:00
cdns3-trace.c usb: cdns3: Change file names for cdns3 driver. 2020-12-29 12:36:13 +08:00
cdns3-trace.h cdns3: Remove unused tracepoints 2025-09-06 15:23:39 +02:00
cdnsp-debug.h usb: cdnsp: Fix issue with CV Bad Descriptor test 2025-06-24 15:42:39 +01:00
cdnsp-ep0.c usb: cdnsp: Fix issue with CV Bad Descriptor test 2025-06-24 15:42:39 +01:00
cdnsp-gadget.c usb: cdnsp: fix wakeup from S3 after controller context loss 2026-09-01 16:43:42 +02:00
cdnsp-gadget.h usb: cdnsp: fix wakeup from S3 after controller context loss 2026-09-01 16:43:42 +02:00
cdnsp-mem.c usb: cdnsp: fix wakeup from S3 after controller context loss 2026-09-01 16:43:42 +02:00
cdnsp-pci.c usb: cdnsp: Add support for device-only configuration 2026-05-22 11:36:05 +02:00
cdnsp-ring.c usb: cdnsp: add support for eUSB2v2 port 2026-04-27 05:14:17 -06:00
cdnsp-trace.c usb: cdnsp: Add tracepoints for CDNSP driver 2020-12-29 12:36:13 +08:00
cdnsp-trace.h cdnsp: Remove unused tracepoints 2025-09-06 15:23:39 +02:00
core.c usb: cdnsp: Add support for device-only configuration 2026-05-22 11:36:05 +02:00
core.h usb: cdnsp: Add support for device-only configuration 2026-05-22 11:36:05 +02:00
drd.c usb: cdnsp: Add support for device-only configuration 2026-05-22 11:36:05 +02:00
drd.h usb: cdns3: Add quirk flag to enable suspend residency 2024-06-04 15:41:10 +02:00
gadget-export.h usb: cdns3: Add USBSSP platform driver support 2026-04-27 05:14:18 -06:00
host-export.h usb: cdns3: Add USBSSP platform driver support 2026-04-27 05:14:18 -06:00
host.c usb: host: cdns3: forward lost power information to xhci 2025-03-14 09:18:03 +01:00
Kconfig usb: cdns3: Add USBSSP platform driver support 2026-04-27 05:14:18 -06:00
Makefile usb: cdns3: Add USBSSP platform driver support 2026-04-27 05:14:18 -06:00