From: Sinan Turunc <enscrpt@pm.me>
To: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ALSA: usx2y: Account for every period a URB completes
Date: Sun, 15 Nov 2026 12:16:55 +0000 [thread overview]
Message-ID: <20261115121638.168-1-enscrpt@pm.me> (raw)
usx2y_urb_capt_retire() and usx2y_urb_play_retire() add the frames of a
whole URB to transfer_done and subtract one period_size when it is
reached. With a period of 1 ms, which snd_usx2y_pcm_open() allows, a
URB of nr_of_packs() packets covers several periods, so transfer_done
grows by the difference on every URB. snd_pcm_period_elapsed() is
called once per URB instead of once per period, and transfer_done
overflows after about 16 hours, after which period wake-ups stop.
Keep only the remainder modulo period_size. ALSA's position comes from
the pointer callback, so one call per URB that crosses a period is
enough.
Measured on 7.3-rc7 with an emulated US-122 over USB/IP and a debug
print of transfer_done every 1024 capture URBs, 45-frame periods and
48-frame packets: before, transfer_done is 150573 after 1024 URBs and
8580141 after 58368; after, it never exceeds a period plus one URB and
the stream runs for 30 s as before.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Sinan Turunc <enscrpt@pm.me>
---
1 file(s) changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c
index a3a0bc13632..681e75917bc 100644
--- a/sound/usb/usx2y/usbusx2yaudio.c
+++ b/sound/usb/usx2y/usbusx2yaudio.c
@@ -72,7 +72,7 @@ static int usx2y_urb_capt_retire(struct snd_usx2y_substream *subs)
subs->transfer_done += lens;
/* update the pointer, call callback if necessary */
if (subs->transfer_done >= runtime->period_size) {
- subs->transfer_done -= runtime->period_size;
+ subs->transfer_done %= runtime->period_size;
snd_pcm_period_elapsed(subs->pcm_substream);
}
return 0;
@@ -155,7 +155,7 @@ static void usx2y_urb_play_retire(struct snd_usx2y_substream *subs, struct urb *
if (subs->hwptr_done >= runtime->buffer_size)
subs->hwptr_done -= runtime->buffer_size;
if (subs->transfer_done >= runtime->period_size) {
- subs->transfer_done -= runtime->period_size;
+ subs->transfer_done %= runtime->period_size;
snd_pcm_period_elapsed(subs->pcm_substream);
}
}
--
2.56.0
next reply other threads:[~2026-11-15 12:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 12:16 Sinan Turunc [this message]
2026-11-16 15:41 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261115121638.168-1-enscrpt@pm.me \
--to=enscrpt@pm.me \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®