Repository navigation
usb: dock USB Ethernet Wake-on-LAN (USB 3 per-function remote wake + cdc_ncm WoL for UD-ULTC4K) - #1235
Merged
Conversation
A USB 3 device enables remote wakeup per function: the host arms each function with SET_FEATURE(FUNCTION_SUSPEND) addressed to the first interface of that function (USB 3.2, 9.4.9). usb_enable_remote_wakeup() only ever sent it to interface 0 and carried a FIXME for devices whose interface association descriptors show more than one function. Docks are such devices. The Plugable UD-ULTC4K (DisplayLink 17e9:6011) has a vendor display function at interface 0, DFU at 1, UAC2 audio at 2-4 and its CDC NCM Ethernet at 5-6. With wakeup enabled on the dock, only the display function was armed, and a magic packet to its Ethernet never woke the host from suspend-to-idle (0 of 2 on an M4 Pro MacBook Pro; with this change 6 of 6 wake within 0.6 s). Send FUNCTION_SUSPEND to the first interface of every function: the bFirstInterface of each association, and every interface outside one. Do the same when disarming, so that on resume every function leaves function suspend. The status of the request to the first interface is still the return value. A failure on another function is only logged, so a device that rejects the request there keeps working as it did. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
The Ethernet function of the Plugable UD-ULTC4K (DisplayLink 17e9:6011) wakes the host on a magic packet addressed to it while it is suspended with remote wakeup enabled. It does not wake on other traffic: unicast pings, broadcast and multicast UDP, and a magic packet carrying another station address all leave the host asleep. cdc_ncm had no ethtool WoL operations, so "ethtool -s <dev> wol g" failed and NetworkManager's wake-on-lan setting could not be applied. Its CDC Ethernet descriptor lists 8 power management pattern filters, but the function stalls SET and GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER for every filter, so generic pattern-filter WoL cannot be used with it. The magic packet match is built into the function. Add CDC_NCM_FLAG_WAKE_ON_MAGIC for such functions, pass the driver_info data of cdc_ncm devices on as their driver flags, and give the dock its own entry ahead of the DisplayLink vendor match. With the flag, get_wol/set_wol report WAKE_MAGIC and map it to the remote wakeup setting of the USB device, which is what arms the match. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
Contributor
Author
|
Merge gate: CI host-tests pass. Local tools/asahi/run-host-tests.py on the branch tree: 196/196 passed. Hardware proof on the J616s is in the description (the dock is attached only there). On the other Macs the hub.c change only alters the suspend path for multi-function USB 3 devices that have remote wakeup enabled. FLEET5 carries it, so its s2idle gate covers all four Macs. |
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.
Wake-on-LAN through a dock's USB Ethernet, using the Plugable UD-ULTC4K (DisplayLink 17e9:6011, CDC NCM) on the J616s (M4 Pro). Before this change
ethtool enu1u2i5showed no Wake-on line, and a magic packet did not wake the Mac even with the dock'spower/wakeupenabled. This supersedes #1233, whose pattern-filter approach the dock rejects (details below).Commits
usb_enable_remote_wakeup()only armed interface 0 (the existing FIXME). On this dock interface 0 is the DisplayLink display function. DFU is interface 1, UAC2 audio is 2-4, and the NCM Ethernet is 5-6, so the Ethernet was never armed. With this commit every function is armed (each IAD's bFirstInterface, plus every interface outside an IAD) and every function is disarmed on resume. The status for interface 0 is still the return value. Failures on other functions are only logged.CDC_NCM_FLAG_WAKE_ON_MAGICcomes throughdriver_info->data, and the dock gets its own table entry ahead of the DisplayLink vendor match.get_wol/set_wolreport WAKE_MAGIC and map it to the USB device's remote wakeup setting. Its CDC Ethernet descriptor saysbNumberPowerFilters 8, but the device STALLs every SET/GET_ETHERNET_PM_PATTERN_FILTER request: usbfs probes of filters 0/1/2/7 with full, tiny and clear (wLength 0) patterns all stalled. GET_NTB_PARAMETERS and GET_NET_ADDRESS on the same interface work. So generic pattern-filter WoL cannot be used here.Default behaviour is unchanged: WoL stays off until
ethtool -s <if> wol g(or NM802-3-ethernet.wake-on-lan magic) turns it on.Receipts (J616s, 7.3.0-aurora-ethwol1 = fleet36 6cf0ab0 + these commits, config identical to fleet36, one-shot boot)
Every cycle was
rtcwake -d rtc1 -m freezewith the RTC alarm armed as a fallback. The packet was sent from the host 20 s after the cycle started. The dock keyboard's own wakeup was disabled for the runs (it wakes itself; S2R6's quirk handles that) and restored afterwards.wake.sh j616s eth(UDP 9/7 to 10.1.1.255, 255.255.255.255, 10.1.1.237)2-1.2+xhci-hcd.6.auto; NIC LOWER_UP with IPv4 0.03 s after resumewol dsets the dock's power/wakeup to disabled)Also:
ethtool -s wol d/gtoggles/sys/bus/usb/devices/2-1.2/power/wakeup,wol uis refused (EINVAL), every suspend succeeded, AVC 0, 0 failed units, taint 0. The J616s was restored to fleet36 with the test kernel removed. Traces (own captures, not tainted): traces/usb/20261109-j616s-dock-eth-wol on the lab disk.checkpatch --strict: one WARNING ('Plugable' is the brand name) and one CHECK (alignment, which matches the surrounding code).
🤖 Generated with Claude Code