Skip to content

usb: typec: take the altmode module reference when the mode is already active - #3571

Draft
Ante042 wants to merge 1 commit into
aurora-silicon:mainfrom
Ante042:typec-altmode-module-ref
Draft

Ante042 wants to merge 1 commit into
aurora-silicon:mainfrom
Ante042:typec-altmode-module-ref

Conversation

@Ante042

@Ante042 Ante042 commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

What: typec_altmode_update_active() takes a reference on the altmode driver's module when a mode becomes active and drops it when the mode is left, but a mode entered before its driver bound took none, so leaving it drops the count below zero and every later replug warns. This takes the missing reference in typec_probe() when the mode is already active at bind.
Tested: J314s M1 Pro at b38b8a0 (candidate 2596602bfaf6 on main 972a566, plus a test-only commit for the HDMI rows): boots, the same failed units as plain main, three disconnects of a USB-C DisplayPort port with 0 kernel warnings and typec_displayport refcnt 1 before and after.
Risk: two-way door · all Macs with Type-C altmodes (generic typec bus code).
Not yet: a mode that goes active while the driver is being bound could be counted twice; not seen, not tested. The USB-C display after s2idle (see #2835).

Details

The case is common on these Macs: the first plug of a boot is what autoloads typec_displayport, so the mode is already active when the driver binds. This is not Apple specific; if you'd rather it went to linux-usb first, that is fine with me. If you'd rather have the state sampled before the driver's probe, or the double count handled another way, say so.

Evidence
  • Plain main at 0285ae5 (with my other open drafts), USB-C to DisplayPort cable, three disconnects done by telling the port's PD controller to drop the connection: four warnings, twice drivers/usb/typec/class.c:317 at typec_altmode_update_active and twice kernel/module/main.c:957 at module_put, all from cd321x_update_work.
  • 2596602bfaf6: the same three disconnects, 0 WARNING splats, refcnt 1.

Thanks for taking a look!

…y active

typec_altmode_update_active() takes a reference on the altmode driver's
module when a mode becomes active and drops it when the mode is left.
A mode that was entered before its driver bound, for example when the
first plug autoloads typec_displayport, took no reference, but leaving
it still drops one. The module refcount then ends up at -1, and every
later replug warns in typec_altmode_update_active() and module_put().

Take the reference in typec_probe() when the mode is already active.

Signed-off-by: Andreas Fernandez <[email protected]>

This branch has not been deployed

No deployments
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