Re: [RFC PATCH 04/14] sound: usb: card: Introduce USB SND vendor op callbacks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Oliver,

On 1/3/2023 4:49 AM, Takashi Iwai wrote:
On Tue, 03 Jan 2023 13:20:48 +0100,
Oliver Neukum wrote:



On 30.12.22 08:10, Wesley Cheng wrote:

It may depend on how the offloading is implemented, but we do have a mechanism to force the audio stream off from the qc_usb_audio_offload. Regardless of if the UDEV is suspended first, or the USB backend, as long as we ensure that the offloading is disabled before entering suspend, I think that should be sufficient.

You would presumably output garbage, if the UDEV is asleep but the backend is not.


As long as the stream is halted, i.e. the audio DSP doesn't execute further transfers on the bus, there shouldn't be any noise/static that will continue to be outputted. When I mentioned that we have a mechanism to force for the offloading to be disabled to the audio DSP side, it will no longer submit any audio data to the USB bus.

The reset_resume() path is fine.  Bus reset is going to cause a disconnect() callback in the offload driver, in which we already have the proper handling for ensuring the offload path is halted, and we reject any incoming stream start requests.

How? If we go the reset_resume() code path, we find that usb-audio does not make
a difference between regular resume() and reset_resume()

Note that, for USB audio, there is no much difference between resume()
and reset_resume(), especially about the PCM stream handling that is
the main target for the offload (the mixer isn't handled there).
And for the PCM, we just set the power state for UAC3, and that's
all.  All the rest is handled by the PCM core handler as usual.


Sorry, I was under the impression that the USB SND class driver didn't register a reset_resume() callback, which Takashi helped clarify that it does indeed do. (if no callback is registered, then USB interface is re-binded in the resume path) However, it doesn't explicitly treat the reset_resume differently than a normal resume.

For the offload path, we don't need to do anything special either - if we have ensured that the stream was stopped in the suspend path. (to be added) It would be up to the userspace to restart the ASoC PCM stream, which would cause another stream request enable QMI command handshake to happen before any transfers would start.

One thing that I could add to protect the situation where the USB ASoC backend is resumed before UDEV, is to check the chip->system_suspend state. Normally, the offload driver needs to ensure the bus is in U0 before starting the audio stream, but it is done using runtime PM:

static int enable_audio_stream(struct snd_usb_substream *subs,
				snd_pcm_format_t pcm_format,
				unsigned int channels, unsigned int cur_rate,
				int datainterval)
{
...
	pm_runtime_barrier(&chip->intf[0]->dev);
	snd_usb_autoresume(chip);

In case we're in the PM resume path, I don't believe PM runtime can be triggered to resume a device. In this case, the snd_usb_autoresume() would return w/o ensuring the USB SND device is fully exited from PM suspend. Although, this situation would be a corner case, as userspace entities (userspace ALSA) are going to be unfrozen after kernel devices are resumed, so most likely there should be no request to enable the audio stream if kernel devices are still resuming.

I don't see an issue with the sequence of UDEV being resumed before USB backend. In this case, the USB bus is ready to go, and able to handle stream enable requests.

Thanks
Wesley Cheng



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux