Re: [PATCH] ALSA: usx2y: Account for every period a URB completes

From: Takashi Iwai

Date: Mon Nov 16 2026 - 10:41:15 EST


On Sun, 15 Nov 2026 13:16:55 +0100,
Sinan Turunc wrote:
>
> 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@xxxxx>

Applied now. Thanks.


Takashi