Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The FIFO prefilter can admit streams that exceed their allocated capacity and cause silent audio corruption, while rate-only refinement can accept unsupported sample rates.
2 open issues
What changed in this PR
Enables USB audio offload on Intel Lunar Lake and newer platforms, allowing the SOF DSP to stream through xHCI Audio Sideband while snd-usb-audio retains device ownership.
Changes:
- Adds xHCI sideband resource management and USB audio offload ownership APIs.
- Integrates SOF UAOL streams, feedback DMA, device constraints, suspend/resume handling, and per-stream route controls.
- Adds machine-driver integration, build configuration, documentation, and 384-kHz stream-format support.
| File | Description |
|---|---|
sound/usb/quirks.c |
Exports format quirks for offload use. |
sound/usb/pcm.h |
Declares substream claim/release APIs. |
sound/usb/pcm.c |
Adds exclusive substream claims and propagates endpoint errors. |
sound/usb/offload/offload.h |
Defines internal offload context and bridge interfaces. |
sound/usb/offload/Makefile |
Builds the offload library. |
sound/usb/offload/Kconfig |
Adds offload library configuration. |
sound/usb/offload/init.c |
Implements registration, notifications, and resource placement callbacks. |
sound/usb/Makefile |
Includes the offload build directory. |
sound/usb/Kconfig |
Includes offload configuration. |
sound/usb/endpoint.h |
Declares endpoint ownership APIs. |
sound/usb/endpoint.c |
Prevents host sharing of offloaded endpoints. |
sound/usb/card.h |
Adds ownership state and platform-release declaration. |
sound/usb/card.c |
Disconnects tracked devices before releasing platform operations. |
sound/soc/sof/topology.c |
Recognizes the UAOL DAI type. |
sound/soc/sof/sof-priv.h |
Adds machine-parameter finalization callback. |
sound/soc/sof/ipc4-topology.h |
Defines UAOL gateway configuration and stream mapping. |
sound/soc/sof/ipc4-topology.c |
Configures UAOL FIFOs and refreshes gateway data. |
sound/soc/sof/ipc4-priv.h |
Stores firmware UAOL support and capabilities. |
sound/soc/sof/ipc4-loader.c |
Parses firmware UAOL capabilities. |
sound/soc/sof/intel/Makefile |
Builds Intel UAOL integration. |
sound/soc/sof/intel/Kconfig |
Adds SOF USB offload configuration. |
sound/soc/sof/intel/hda.h |
Defines UAOL state, limits, and shared interfaces. |
sound/soc/sof/intel/hda.c |
Registers offload support and reports usable UAOL links. |
sound/soc/sof/intel/hda-uaol.c |
Implements UAOL routing, constraints, and stream lifecycle. |
sound/soc/sof/intel/hda-pcm.c |
Applies backend constraints and supports 384-kHz formats. |
sound/soc/sof/intel/hda-mlink.c |
Adds UAOL link lookup. |
sound/soc/sof/intel/hda-dai.c |
Adds UAOL DAIs and shares common callbacks. |
sound/soc/sof/intel/hda-dai-ops.c |
Adds UAOL DMA operations and feedback DMA allocation. |
sound/soc/sof/intel/hda-common-ops.c |
Wires UAOL-aware machine registration callbacks. |
sound/soc/sof/core.c |
Finalizes copied machine parameters before registration. |
sound/soc/soc-usb.c |
Adds non-DT matching and per-stream route controls. |
sound/soc/intel/common/sof-function-topology-lib.c |
Recognizes optional UAOL topology fragments. |
sound/soc/intel/boards/sof_uaol_common.h |
Shares UAOL backend naming and counting helpers. |
sound/soc/intel/boards/sof_sdw.c |
Creates UAOL backend links for SoundWire cards. |
sound/soc/intel/boards/sof_board_helpers.h |
Adds UAOL link type and board parameters. |
sound/soc/intel/boards/sof_board_helpers.c |
Creates UAOL links through shared board helpers. |
sound/soc/intel/boards/skl_hda_dsp_generic.c |
Includes UAOL links in generic HDA cards. |
sound/hda/core/device.c |
Adds 384-kHz HDA stream-format encoding. |
include/sound/usb-offload.h |
Defines the public USB audio offload interface. |
include/sound/sof/ipc4/header.h |
Defines firmware UAOL capability messages. |
include/sound/soc-usb.h |
Exposes route state, controls, and selection APIs. |
include/sound/soc-acpi.h |
Adds UAOL machine parameters. |
include/sound/hda-mlink.h |
Declares UAOL link lookup and its stub. |
include/linux/usb/xhci-sideband.h |
Exposes resource, endpoint-property, and restart APIs. |
drivers/usb/host/xhci.h |
Defines extended-property commands and resource tracking. |
drivers/usb/host/xhci.c |
Implements extended-property command execution. |
drivers/usb/host/xhci-sideband.c |
Implements audio endpoint handover and resource management. |
drivers/usb/host/xhci-ring.c |
Queues and handles extended-property commands. |
drivers/usb/host/xhci-mem.c |
Initializes and destroys sideband resource tracking. |
Documentation/sound/soc/usb.rst |
Documents routing APIs and platform-card controls. |
Documentation/sound/soc/index.rst |
Adds the UAOL documentation entry. |
Review effort: Balanced
5465b53 to
60134a0
Compare
|
Changes since v1 Folded into the existing UAOL patches in
Tested on PTL (SoundWire and HDA): 384 kHz S16 on a high-speed adapter, two |
There was a problem hiding this comment.
🟡 Changes recommended
Critical shutdown-ordering and sample-width accounting errors can stop USB endpoint service while the DSP remains active and underestimate FIFO requirements, risking stalled streams and corrupted audio.
3 open issues
2 resolved since last review
Review effort: Balanced
| bytes = frames * params_channels(params) * | ||
| uaol_sample_bytes(params_format(params)) * SOF_UAOL_FIFO_INTERVALS; |
| if ((cmd == SNDRV_PCM_TRIGGER_STOP || cmd == SNDRV_PCM_TRIGGER_SUSPEND) && | ||
| stream->udev) { | ||
| usb_offload_quiesce_stream(hdev->uaol, stream->udev, direction, | ||
| stream->pcm_index); | ||
| stream->quiesced = true; |
| case XHCI_SIDEBAND_AUDIO: | ||
| if (!xhci_sideband_hw_capable(xhci)) { | ||
| dev_info(&udev->dev, "%s: Host not sideband capable\n", | ||
| __func__); | ||
| return NULL; | ||
| } | ||
| break; |
60134a0 to
43ee753
Compare
The sideband structure caches vdev, an xhci_virt_device pointer that the xhci driver may free and reallocate while the sideband is still registered, leaving the sideband with a dangling sb->vdev pointer. This can happen during resume, either when the xhci driver detects xHC power loss and resets the xHC, freeing all virt devices without informing class drivers, or during reset-resume when usb core re-enumerates the device and xhci frees and allocates a new virt device. Store the usb_device pointer (udev) instead. It stays valid across reset-resume and xHC reset. Look up the current virt device and ensure it still points to this sideband before using and dereferencing it in sideband API calls. Make sure xhci_sideband_unregister() works properly when called with an invalid vdev. Don't dereference it, or ask the xHC to stop non-existing endpoints, but make sure the sideband is properly freed. Fail other relevant sideband API calls that would access an invalid vdev. This solution isn't airtight. It only validates vdev when entering sideband API functions. It does not serialize the sideband API functions against the code in the xhci driver that reallocates vdev, so vdev may still be freed in the middle of a sideband call. It's still a big improvement and a first step in resolving this. The following patch starts working on the serialization. Fixes: de66754 ("xhci: sideband: add initial api to register a secondary interrupter entity") Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
…ints Start work to protect sideband API functions against the xhci driver freeing or reallocating the virt device (vdev) in the middle of an API call. Make the following sideband API calls hold xhci->lock while validating the vdev and its endpoint, and while queueing the stop endpoint command: xhci_sideband_unregister() xhci_sideband_stop_endpoint() xhci_sideband_remove_endpoint() Locking changes are still needed in several xhci 'core' driver vdev free paths before the above calls are fully serialized against vdev free. Cases involve xHC reset in resume, enumeration retry, and reset-resume. Move the stop endpoint code from xhci_stop_endpoint_sync() in xhci.c to a new sideband_stop_endpoint_sync() helper in xhci-sideband.c. xhci_stop_endpoint_sync() has no other users, so remove it. Also take sb->mutex in xhci_sideband_stop_endpoint(), and keep holding it in xhci_sideband_unregister() until the sideband is detached from the vdev. Fixes: de66754 ("xhci: sideband: add initial api to register a secondary interrupter entity") Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Extended Property Get and Set commands are used to control and list extended properties. The Get/Set Extended Property Command references a specific Extended Capability using the Extended Capability Identifier (ECI). Some of these commands take a pointer to a Extended Property Context that xHC will fill. Get Extended Property with ECI set to 0 will list all supported extended capabilities Audio sideband control is currently the only supported extended capability. More details in xhci specification sections 6.4.3.16-17 and 7.9.1-2 Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Add easy and usable synchronous helpers for Get and Set Extended Property. These take care of the tedious tasks of allocating a command, dma mapping, queueing a command and waiting for completion. These helper are synchronous and will sleep. Note that the buffer *buf passed to get_ext_property() needs to be dma mappable for all buffers using capability IDs, except for PROP_ECI_ALL (ECI 0) which returns a bitmap of supported capabilities in the command completion event TRB Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Add support for registering standard xHCI Audio Sideband Capability, as described in xHCI specification section 7.9. This is the xHC hardware managed audio sideband that can be controlled by Set and Get Extended properties commands. Define the type of this xHC hardware controlled audio sideband as XHCI_SIDEBAND_AUDIO. Check that xHCI is at least version 1.2 with GSC support bit (Get/Set extended property capability) set, and that extended properties report Audio Sideband Extended Capability is supported. Check if the sideband type is XHCI_SIDEBAND_AUDIO or XHCI_SIDEBAND_VENDOR in codepaths where it matters Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
… IDs Endpoints controlled by the xHC hardware audio sideband need a unique resource ID, used when handing the endpoint over to the sideband with a Set Extended Property: Set Resource Assignment command (xHCI 7.9.2.1). Track the resource IDs of an xHC host in an xarray, and add xhci_sideband_alloc_resource_id() and xhci_sideband_free_resource_id() to the sideband API. An XHCI_SIDEBAND_AUDIO endpoint needs a reserved resource ID before it can be added with xhci_sideband_add_endpoint(). The caller can narrow the ID range within the xHC limits, as an offload engine may tie a function to specific resources. For example, the Intel DSP firmware selects a link FIFO stream by resource ID. Passing 0 for both bounds reserves any free ID. An endpoint holds only one reservation at a time. Co-developed-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
… audio sideband Support assigning endpoints over to xHC sideband control for the hardware controlled XHCI_SIDEBAND_AUDIO sideband type. These endpoints need to have a valid unique resource id allocated by calling xhci_sideband_alloc_resource_id() before assigning the endpoint over to sideband by calling xhci_sideband_add_endpoint() Endpoint control is handed over to sideband with a Set extended property command that includes the allocated unique resource id. See xhci specification 7.9.2.1 "Set Extended Property: Set Resource assignment Command" Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
The max number of endpoints a xHC controller can offload for audio sideband can be fetched with a Get Extended Property: Get supported Resources Command. The limit is returned in the first 8 bit 'Resource count' field of the Extended Property Context structure Store and use this limit as the max xarray index. Intel xHC have a hard resource limit capped at 6 even if host reports otherwise. Many xarray functions use unsigned long types for index, but we can safely cast them to 'int' as the max index is a 8bit value. Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Prepare the xHCI Audio Sideband API for Intel UAOL consumers. Add xhci_sideband_get_ep_properties(), an endpoint property query returning all the xHC and endpoint properties needed to set up Intel UAOL Partially based on work by Peter Ujfalusi CC: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
… a hub Audio quality cannot be guaranteed with Intel xHC audio sideband offloading when the device is connected behind a hub. Only allow Intel hosts to register an audio sideband for devices connected directly to a root hub port. Other hosts are not affected. Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
A client driving endpoints over the audio sideband can stop them with xhci_sideband_stop_endpoint(), but has no way to start them again: a stopped endpoint only returns to the running state when its doorbell is rung, and nothing rings it for an endpoint the sideband owns. A stream which is stopped and then started again without its endpoints being reconfigured in between, like one recovering from an xrun, stays stalled. Add xhci_sideband_start_endpoint(), which rings the doorbell of an endpoint the sideband owns. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
snd_hdac_stream_format() silently falls back to the 48kHz encoding for any rate missing from rate_bits[]. USB audio devices offloaded over the HDaudio link can run at 384kHz, so add the encoding: base 48kHz, mult 8, div 1. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
The offloaded stream is released from the host's hw_free, which runs only after the DSP has stopped and freed its side of the link. Until then the xHCI keeps servicing the offloaded endpoints. An isochronous IN endpoint, the feedback endpoint of a playback stream in particular, then has nowhere to deliver its packets, which can stall the controller's periodic schedule and lock it up. Add usb_offload_quiesce_stream() so that the host can stop the endpoints on the controller once its own side of the link has stopped, before it is torn down. The feedback endpoint is stopped first, then the data endpoint. The sideband resources stay claimed and usb_offload_release_stream() still has to follow. The stream is named the way release_stream() names it, by its direction and USB PCM device number. Co-developed-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com> Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
usb_offload_quiesce_stream() stops the endpoints of an offloaded stream when the host stops it. A stream can be started again without being released in between, which is how an xrun is recovered from, and its endpoints then stay stopped: the stream stalls. Add usb_offload_restart_stream() for the host to run before it starts its own side of the link again. The data endpoint is restarted first, the feedback endpoint, which the quiesce stops first, last. The stream lookup is shared with the quiesce. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
The library claims the USB substream it offloads, but the endpoints the DSP drives can still be shared with a host stream: with implicit feedback the capture data endpoint is also the sync source of the device's playback. An offloaded capture stream and the host's playback then both run that endpoint, the host submitting URBs on a ring the sideband owns, and both stall. Claim the data endpoint, and an explicit feedback endpoint, with snd_usb_endpoint_claim_offload() right after their hw_params, before anything is set up on them, and release them before the stream's hw_free. An endpoint which another stream has open already fails the acquisition with -EBUSY, and the host cannot open one while the stream is held. The test whether a stream has an explicit feedback endpoint is shared with the feedback reservation. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
snd_usb_pcm_prepare() runs snd_usb_set_format_quirk() whenever it sets up the data endpoint afresh. The library prepares the endpoints itself and skipped it, leaving a device which takes its sample rate through vendor requests at whatever rate it ran last. Export the quirk and run it the same way. Some quirks only set up the host's URB path: the MacroSilicon MS2100 and MS2109 capture cards need the first two bytes of the stream dropped, or the channels come out swapped and out of phase, and the E-Mu devices need the start of each packet skipped at 176.4 and 192kHz. The DSP gets the data as the device sends it, so refuse a stream that is left with such an offset with -EOPNOTSUPP. The E-Mu devices are vendor class and never pass the candidate filter, the MacroSilicon cards do. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
…s UAOL The USB stream is released from hw_free, after the DAI copier has been freed and the UAOL link powered off. Until then the xHCI keeps servicing the offloaded endpoints, and the feedback IN endpoint has nowhere to deliver its packets, which can lock up the controller. On TRIGGER_STOP and TRIGGER_SUSPEND, stop the xHCI endpoints with usb_offload_quiesce_stream() right after hda_dai_trigger() has stopped the DAI pipeline. They cannot be stopped any earlier: a UAOL stream cannot go idle once the xHCI no longer services an endpoint still bound to it, so the DSP would time out stopping both the audio and the feedback stream and fall back to resetting them. A stopped endpoint stays stopped until it is restarted, and only a hw_free followed by hw_params, or the reacquire after a system suspend, brings up fresh ones. A stream started again right after a stop, which is how an xrun is recovered from (STOP, prepare, START), would run the DSP against stopped endpoints: the link makes no progress and the application's next write fails with -EIO. Remember that the endpoints were stopped and restart them with usb_offload_restart_stream() on TRIGGER_START, before the DSP starts its side of the link, so that they run then as they do on the first start. Releasing the stream, at hw_free or before a reacquire, forgets it. Co-developed-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com> Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
…meanwhile The route control refuses to change a route while its backend holds a stream, but the backend only reads the selection before acquiring the device and marks the route busy once it has it. A change that goes through in between leaves the stream playing to the device the route selected before, while the control shows the new one. Read the selection back once the stream is set. The control decides whether the route is busy under the lock the selection is read with, so a change made during the acquisition is seen there and a later one is refused. Release the stream and fail with -EBUSY when the selection moved, the stream has not started yet. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
…quired prepare acquires a stream suspended by the SUSPEND trigger again, but the flag is cleared when the old acquisition is released, before the new one is attempted. A prepare retried after a failed one, a route change in between or a device gone meanwhile, finds the flag cleared and no device, and runs the common prepare: the DSP is started on a gateway whose xHCI sideband resources were released and may belong to another stream by then. The same happens on a prepare after the device was unplugged. Clear the flag only once the stream is acquired again, or the stream is closed, and fail prepare when the backend has no device. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
The pieces of the USB audio offload are in place: the device notifications reach the ASoC USB port, the UAOL DAIs acquire, configure, quiesce and restart the USB stream, and the frontends are constrained to what the link and the device can carry. Install hda_machine_register() as the machine_register op, so that the driver registers with the USB audio offload library once the firmware has booted and the library starts reporting the offloadable devices. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Create the UAOL backend DAI links from the link mask and the stream counts reported in mach_params, following the BT offload link, with their own function topology so that the PCMs they add do not collide with the other functions of the card. Each stream of each direction gets a link of its own: the backend hw_params fixup is called without the stream direction, so a duplex link could not tell which of the two DAI copiers describes the stream being configured and would have to constrain both directions to the same format. With two streams per direction the backends are "UAOL0-Play0", "UAOL0-Play1", "UAOL0-Cap0" and "UAOL0-Cap1", on the CPU DAIs "UAOL0 Playback Pin0" and so on. The link and CPU DAI names are kept in sof_uaol_common.h for the other boards to share. The backends are created ordinal first, playback before capture within an ordinal, so the first playback and capture backend keep two consecutive IDs whatever the stream count, and a topology describing one stream per direction stays valid. The ordinal only tells the backends of a direction apart: it is not the UAOL stream the backend runs on, which is decided by the xHCI sideband resource the endpoint gets when the USB device is acquired. The backend names are abbreviated on purpose: the topology names its DAI copier widget "dai-copier.UAOL.<backend>.<direction>", and alsa-lib keeps element ids in SNDRV_CTL_ELEM_ID_NAME_MAXLEN bytes, so from 38 characters on the ids of the widget's "dai.word" and "dai.string" tuple sections collide and one set is silently dropped from the topology. The topology is named sof-uaol-id<BE id>.tplg after the id of the first playback link. The function name carries no link index, like dmic and hdmi, as the host driver reports a single link. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Add a link type creating the UAOL backend DAI links from a link mask and the stream counts per direction, so that boards using the helpers can place them in their link order like any other backend. Each stream of each direction gets a link of its own, named like sof_sdw does it, see sof_uaol_common.h. The backends are created ordinal first, playback before capture within an ordinal, so the IDs of the first playback and capture backend do not depend on how many streams the link has. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Create the UAOL backend DAI links from the link mask and the stream counts reported in mach_params, following the BT offload link. The board assigns fixed backend ids, so the UAOL links can take the ids after the BT offload one regardless of which other functions are present. A topology describing the UAOL therefore does not need a variant per board configuration. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Add Documentation/sound/soc/sof-uaol.rst, describing the USB audio offload on Intel platforms with SOF: how the xHCI Audio Sideband, the USB audio offload library, the ASoC USB framework, the SOF HDA driver and the machine drivers fit together, what the user visible interface is (the route controls and the jack), how a stream is acquired and released, how the UAOL gateway is configured and how the firmware's FIFO layout decides where an endpoint may be placed, the asynchronous playback policy, and the current limits. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
…s behind a hub" This reverts commit 0e544eef569fbdb90db410b3457e37224788a6e2. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
On the Dell Pro Max 14 Premium (MA14260) the CS42L45 (01fa:4245) on SoundWire link 0 never clears ClockStopNotFinished in SCP_Stat. The bit reads 1 from power on, with SCP_SystemCtrl at 0 and all PDEs in PS3, and stays 1 after ClockStopPrepare is written (verified with the SoundWire debugfs command interface). The BIOS advertises the full clock stop prepare state machine, so sdw_bus_prep_clk_stop() waits the default 300 ms and fails on every runtime suspend: soundwire_intel.link.0: prepare clock stop failed -110 soundwire_intel.link.0: intel_stop_bus: cannot stop clock: -110 Besides the noise this adds 300-600 ms to every link suspend and leaves the shim wake disabled on the link, so in-band jack detection cannot wake the system. Treat the part as simple_clk_stop_capable so the bus does not wait for ClockStopNotFinished. With this the link enters and exits clock stop like the CS35L56 links on the same platform. This is a temporary workaround until Cirrus confirms whether this is a device or firmware issue and the proper fix (quirk or firmware) is known. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
ALSA: usb: Add USB audio offload library Add a library that tracks offload capable USB audio devices and forwards their lifecycle to a host driver owning the DSP. Device ownership stays with snd-usb-audio. The library hooks the USB-SND platform-op callbacks and reports the hotplug events of the devices that can be offloaded to the host through a callback table, struct usb_offload_ops. The host turns each callback into whatever its DSP expects; the library builds no IPC message, touches no register and owns no interrupt. The audio-control interface is looked up in the active configuration rather than assumed to be interface 0, so composite devices where the audio function sits behind other interfaces are candidates too. A device exposing more than one audio function is offloaded through the first one. The data path is built on the xHCI Audio Sideband, which routes an endpoint's traffic to the DSP. An endpoint only exists while the streaming altsetting is active, so on stream acquire the library first claims the USB substream and starts it, the same way a host driven stream is started, then reports the data endpoint. Claiming the substream also keeps user space off the device for as long as it is offloaded. A device can expose several PCMs of the same direction (e.g. separate speaker and line-out streams), so the acquisition takes the USB PCM device number the caller wants, or a negative index to take the first PCM matching the format. The acquired streams are kept per USB PCM: a PCM is offloaded once, the other PCMs of the device can be acquired alongside. The PCM number the stream landed on is reported back and names the stream to usb_offload_release_stream(). No card is created here and no stream is driven from here: the host's backend DAI acquires the endpoint with usb_offload_acquire_stream() when its own framework triggers it. A context stands for one offload engine, the link over which a DSP reaches a host controller; a host with several registers one context for each. There is no descriptor filter of its own: by the time the connect callback runs, snd-usb-audio has parsed the device and left the streams it can drive in chip->pcm_list, with the malformed ones already left out. A device is a candidate if it is a full or high speed audio function, and each of its PCMs is offered for offload on its own. The endpoints are claimed and their sideband resources allocated per stream at acquire, so there is nothing to count or reserve beforehand. usb_offload_connect() notifies the host, which can call back into the device record through its own framework before returning (e.g. a route control's busy check), so the device list lock is dropped around the connect and disconnect notifications. The record cannot go away meanwhile: the callbacks that create and free it are serialised by snd-usb-audio's register_mutex. A device being torn down is marked disconnected before the lock is dropped, so that a stream acquire racing with the unplug is refused instead of handing out a device which is already gone. Nothing in the interface is tied to a sound framework, but no consumer outside ALSA exists, so the header lives under include/sound/. Signed-off-by: Rene Sapiens <rene.sapiens@linux.intel.com> Co-developed-by: Pooja Katiyar <pooja.katiyar@intel.com> Signed-off-by: Pooja Katiyar <pooja.katiyar@intel.com> Co-developed-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Update for the library no longer parsing the descriptors itself. snd-usb-audio has parsed the device by the time the connect callback runs, so a device is accepted if it is a full or high speed audio function with PCMs usb-audio set up, and the streams are the ones usb-audio found. Drop the description of the UAC1/UAC2 interface walk and of the strict one-altsetting check, and rename the filter in the connect sequence. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
…playback Keep a playback format with implicit feedback on the host unconditionally. Its sync source is a capture data endpoint the DSP cannot use and the hardware cannot follow it, so such a stream would run blind. usb_offload_playback_kept() returned false for it whenever allow_feedback was set, or when the host did not set async_playback_on_host, and that offloaded the playback and also lifted the hold on the capture endpoint it syncs to. allow_feedback is only meant to open up the explicit feedback path, as the documentation says: implicit feedback is left unused even with it. On a Behringer UMC204HD with allow_feedback=1 both PCMs were offered. Now only the playback format with a feedback endpoint of its own is, and the capture stays on the host. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Do not store the default selection of a route. A route holds only what was picked for it; while nothing is, it resolves on every query to the Nth available pair of its direction (wrapping around), so the routes still spread over what is connected. This replaces auto-select on connect, the take-over of duplicate routes and the fallback on disconnect, and the duplicate/taken/default-entry helpers behind them. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
… DAI Follow the route default in soc-usb. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Follow the route default in soc-usb. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
…B device One rule function for the three device rules, and one for the three shared-parameter rules, both told which parameter they refine by rule->var, and the rules added in a loop. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
…e link FIFO One rule function for the FIFO bound of the rate and of the channels, which are the same bound with the roles swapped. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Have usb_offload_acquire_stream() find the device format itself. When the host asked for S24_LE and no stream runs it, look again with S24_3LE, the container a device packing 24-bit samples into 3 bytes has, and report the format the stream runs in as usb_offload_stream_hw.format. The lookup considers every PCM for the exact format before it falls back, so a PCM with S24_LE is preferred to one with S24_3LE. The caller no longer has to settle on the container with usb_offload_resolve_format() before the acquire and rewrite its parameters in place; it takes the format from the acquire. The old function stays until the callers are converted. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
… DAI Take the format of the stream from the acquire. The device can run a 24-bit stream in another container than the S24_LE the frontend negotiated, and usb_offload_acquire_stream() now reports the one it chose, so there is no need to resolve the container with a separate call before it and in prepare. Set the params the link DMA is programmed from to that format right after the acquire, keep it in the stream, and set it in the backend's own copy of the params on prepare. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Remove usb_offload_resolve_format(). The only callers, the backend's hw_params and prepare, take the format of the stream from usb_offload_acquire_stream() now, which runs the same lookup for the device and reports what it found. Point the documentation of s24_3le_as_s24_le there. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Describe the format of an offloaded stream being reported by usb_offload_acquire_stream() and set by the backend, in place of the separate resolve step. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
|
Changes since v2:
Changelog since the "UAOL diet" marker (12 commits, all fixup! or amend! on top of a239254, so squashing them folds each change into its target patch) Library
ASoC and SOF
Docs (c2d0a93, 2d7ea53, bd7019f): updated for all of the above. Behaviour changes to be aware of
|
There was a problem hiding this comment.
🟡 Changes recommended
Ignored Stop Endpoint failures can allow unsafe link teardown and controller stalls, while endpoint validation outside the lock can race with device removal and crash the kernel.
5 open issues
Serialize endpoint validation with device removal and doorbell writes · New Propagate endpoint stop failures before quiescing the stream · New Do not quiesce USB endpoints when the DSP stop fails Use the resolved physical sample width for FIFO sizing Resume the USB interface before querying offload capabilities
Review effort: Balanced
| if (!sideband_to_vdev(sb) || !ep || ep->sideband != sb) | ||
| return -EINVAL; | ||
|
|
||
| return xhci_stop_endpoint_sync(sb->xhci, ep, 0, GFP_KERNEL); | ||
| guard(spinlock_irqsave)(&sb->xhci->lock); |
| ret = xhci_sideband_stop_endpoint(dev->sb, stream->data_host_ep); | ||
| if (ret) | ||
| dev_dbg(&udev->dev, "USB offload: stop ep: %d\n", ret); |


kconfig patch: thesofproject/kconfig#111
sof-test patch for sof_remove.sh: thesofproject/sof-test#1366
USB Audio Offload Link (UAOL) support. The series lets an Intel audio DSP
source and sink isochronous USB audio directly through the xHCI Audio Sideband,
bypassing the host URB path, while
snd-usb-audiokeeps full ownership of thedevice (descriptors, alternate settings, mixer, PM).
Base:
topic/sof-dev. 54 patches (+1 test-only revert at the tip, see below),53 files, +7248/-141.
Design in brief
sideband registration, resource ID reservation, endpoint hand-over and
property query.
xhci_sideband_start_endpoint()restarts an endpoint stoppedon the sideband.
hands to the DSP; the host cannot open them meanwhile (
-EBUSY).snd_usb_release_platform_ops()lets a platform let go of all devices whenit unregisters.
sound/usb/offload): a host registers oncewith
usb_offload_register(). The library:explicit feedback only);
sideband resources and runs the device's format quirk;
USB Offload <n> Playback/Capture Route, enumerating<card>,<pcm>pairs,and a
USB Offload Jack.constraints on the frontends;
recovery works;
refreshed for the resources it gets;
hda-uaol.cholds the Intel glue.the UAOL backend links. A missing
sof-uaolfunction topology only leavesUSB offload out.
USB Offload <n>frontend; the kernel never migrates a stream.
snd_usb_offload.allow_feedback=1to test the explicit feedback path).
to stay on the host. Devices with nothing to offload are not reported.
Layout
sof-uaol.rst,usb.rst)Testing
-fanalyzer: clean on the CI directories.checkpatch.pl --strict: clean apart from MAINTAINERS notes on the newfiles (xhci patches as provided).
capture.
explicit-feedback playback with
allow_feedback=1.plays there while other devices are offloaded.
capture.
384 kHz on the second PCM, and capture on both.
deep-buffer frontends, and with host playback on another device;
different sideband resource.
Known limitations
is not reacquired: ALSA only sends
TRIGGER_SUSPENDto running streams.This applies to all PCMs, not UAOL specific
test-only revert at the tip lifts that restriction.