Repository navigation
Conversation
Ante042
force-pushed
the
typec-altmode-module-ref
branch
2 times, most recently
from
November 29, 2026 00:39
9507b53 to
83aaec0
Compare
This was referenced Nov 29, 2026
…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]>
Ante042
force-pushed
the
typec-altmode-module-ref
branch
from
November 29, 2026 21:56
83aaec0 to
b38b8a0
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 intypec_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_displayportrefcnt 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
drivers/usb/typec/class.c:317 at typec_altmode_update_activeand twicekernel/module/main.c:957 at module_put, all fromcd321x_update_work.Thanks for taking a look!