All of lore.kernel.org
 help / color / mirror / Atom feed
* Query about xrun on usb/pcm
@ 2022-11-21 21:14 Carl Hetherington
  2022-11-22  7:25 ` Takashi Iwai
  0 siblings, 1 reply; 13+ messages in thread
From: Carl Hetherington @ 2022-11-21 21:14 UTC (permalink / raw)
  To: alsa-devel

Hi all,

I wonder if anybody has any clues/suggestions about problem I'm seeing
with an XMOS-based USB sound card.

As far as I can see, the card has endpoint 0x82 set up for capture data,
0x2 for playback data, and 0x82 is also used as the sync endpoint for
playback.  I'm assuming that's a fairly common arrangement?

I am testing it using simultaneous playback and capture, and simulating
a high-CPU-load case by sleeping for long enough to cause a lot of
xruns.  After some random time, I see a failure case that I'm struggling
to explain.  It goes like this:

There's an XRUN on the playback PCM, so __snd_pcm_xrun happens, then
  stop_endpoints() happens, and:
      it decides not to stop 0x82 because its running is > 1
      it stops 0x2, so its state goes to EP_STATE_STOPPING

Then the ALSA userspace code calls prepare on the playback PCM to get it
going again.

This ends up in wait_clear_urbs(), which does nothing with 0x82 as it is
still running.

At this point, the prepare thread is interrupted by an XRUN on
the capture PCM. With this PCM, there is no sync endpoint, and 0x82 is the data
endpoint.
In the xrun handler:
  stop_urbs() sets 0x82 to EP_STATE_STOPPING.
  ... and the xrun handler finishes.

Then we end up back in the prepare for the playback PCM.
wait_clear_urbs() then sets 0x2 to STOPPED, and the prepare is finished.

Now, snd_usb_endpoint_start() is called on 0x2 and that is fine.  Next,
snd_usb_endpoint_start() is called on 0x82 and that fails because its
state is still STOPPING.

At this point things seem broken.

Does anyone have a hint about where in this sequence things are going
wrong, and maybe even why?

I'm more than happy to clarify anything I can, or provide more debugging
information.

Thanks in advance!
Best,
Carl



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-12-06  7:52 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-21 21:14 Query about xrun on usb/pcm Carl Hetherington
2022-11-22  7:25 ` Takashi Iwai
2022-11-22 11:16   ` Carl Hetherington
2022-11-22 14:19     ` Takashi Iwai
2022-11-22 14:22       ` Takashi Iwai
2022-11-28 22:51       ` Carl Hetherington
2022-11-29  7:45         ` Takashi Iwai
2022-11-30 22:37           ` Carl Hetherington
2022-12-01  7:47             ` Takashi Iwai
2022-12-05 11:59               ` Carl Hetherington
2022-12-05 12:33                 ` Takashi Iwai
2022-12-05 18:53                   ` Carl Hetherington
2022-12-06  7:51                     ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.