Skip to content

SM8750: drop USB data roles over suspend, re-derive at resume#3049

Open
aanze wants to merge 2 commits into
ROCKNIX:nextfrom
aanze:aanze-pr-ucsi-0510-rework
Open

SM8750: drop USB data roles over suspend, re-derive at resume#3049
aanze wants to merge 2 commits into
ROCKNIX:nextfrom
aanze:aanze-pr-ucsi-0510-rework

Conversation

@aanze

@aanze aanze commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • What is the goal of this PR? Companion to SM8750: fix suspend wedge from ucsi USB role on charger unplug #3039 (charger-only
    case): fix the hard SoC hang on SM8750 (AYN Odin 3) when a
    data-capable partner (dock) is unplugged while the device is
    suspended. Split out of SM8750: fix suspend wedge from ucsi USB role on charger unplug #3039 as requested in review, fully reworked
    to address the review findings there (per-instance PM notifier state
    in struct ucsi, symmetric teardown on the pmic_glink PDR/SSR path so
    an ADSP restart cannot leave a use-after-free, role writes under
    con->lock plus a suspend flag closing the connector-workqueue race,
    and no saved-role restore: the role is re-derived from a fresh
    GET_CONNECTOR_STATUS at resume).

Testing

  • How was this tested? Built the SM8750 kernel with this patch on
    top of 0509 and flashed an AYN Odin 3.
  • Test results: Dock attached -> suspend -> unplug while asleep ->
    clean resume (previously a hard wedge, forced reset needed).
    Suspend/resume with charger and with dock kept attached verified as
    well: charging intact after resume (the resume path re-derives the
    role from fresh PPM state). Several cycles each. Builds clean with
    W=1; checkpatch --strict 0/0/0.

Additional Context

  • A PM notifier is used instead of dev_pm_ops on purpose: at
    PM_SUSPEND_PREPARE the system is fully awake, so the USB controller
    processes the switch to USB_ROLE_NONE and drops the power island
    before any device suspends; a device PM callback would give no
    ordering guarantee against the USB controller's own suspend.

AI Usage

Did you use AI tools to help write this code? YES

aanze added 2 commits July 21, 2026 16:51
Add a SM8750 kernel patch reverting the u_role gating introduced by
0c8ee850572 ("usb: typec: ucsi: Add UCSI_USB4_IMPLIES_USB quirk for
X1E80100"). Without that quirk the USB data role is never cleared for
a charger-only partner and stays attached across suspend, keeping the
USB power island up; the firmware power-collapse then hard-hangs the
SoC when the cable is unplugged while suspended. Device-tested on the
AYN Odin 3.
Companion to the charger-only fix (0509): a dock DOES advertise USB
data, so its role survives suspend, the USB power island stays up and
the SM8750 firmware power-collapse hard-hangs on cable events while
asleep.

Kernel patch 0510 quiesces the USB role on every UCSI connector at
suspend entry and re-derives it from fresh PPM state at resume:

- per-instance state: the PM notifier block lives in struct ucsi
  (container_of in the callback), no globals
- symmetric teardown: registered in ucsi_register(), synchronously
  unregistered first thing in ucsi_unregister() -- the path the
  pmic_glink PDR/SSR teardown takes -- so an ADSP restart cannot leave
  a notifier pointing at freed connectors; ucsi->connector is NULLed
  after the kfree
- synchronization: role writes happen under con->lock and a
  ucsi->usb_role_suspended flag makes every role-setting path compute
  USB_ROLE_NONE while suspend is in progress, closing the race with
  the connector workqueue
- no blind restore: at PM_POST_SUSPEND a partner task re-reads
  GET_CONNECTOR_STATUS and re-derives the role from fresh state,
  covering partners that stayed, vanished or appeared during sleep

Device-tested on AYN Odin 3: dock attached -> suspend -> unplug while
asleep -> clean resume; suspend/resume with charger and with dock kept
attached also verified (charging intact after resume).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant