mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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,
	stable@vger.kernel.org, sashiko-reviews@lists.linux.dev
Subject: Re: [PATCH] ALSA: line6: Bound capture copies by the PCM buffer size
Date: Tue, 03 Nov 2026 13:22:23 +0000	[thread overview]
Message-ID: <20261103132205.675-1-enscrpt@pm.me> (raw)
In-Reply-To: <sashiko-outbox-195233@kernel.org>

> Does clamping frames to runtime->buffer_size here cause the capture
> stream to stall whenever an incoming packet exceeds the buffer size
> (for example, when a user configures a 1-period 64-byte capture buffer
> of 11 or 16 frames and receives a regular 44- or 48-frame 1 ms packet
> or a larger USB/IP packet)?

Yes. Clamping frames to buffer_size adds exactly one buffer to pos_done
and then subtracts it, so the ring position never advances and the
stream makes no progress. The same holds for a buffer of exactly one
packet, so the bound has to be two packets.

v2 takes a different approach: snd_line6_capture_open() now constrains
SNDRV_PCM_HW_PARAM_BUFFER_BYTES to at least twice the larger of the two
endpoints' packet sizes, so hw_params rejects a buffer that cannot hold
two packets, and line6_capture_copy() keeps only a guard that drops an
oversized packet with a ratelimited error instead of clamping it, for
the case that should no longer be reachable.

> Also, fsize is not read again after frames is computed at the top of
> line6_capture_copy(), so is the assignment to fsize here unused?

fsize is read in the single-chunk branch (memcpy(..., fbuf, fsize)),
which runs when pos_done is zero, so the assignment was used. It goes
away in v2 with the clamp.

v2 tested on 7.3-rc7 against 1024-byte packets: a 1024-byte buffer is
now refused at hw_params with -EINVAL, and a 2048-byte buffer streams
for 30 s with no KASAN report, with hw_ptr sampled once a second at
positions 0 and 256 inside the 512-frame buffer and advancing by about
450000 frames per second.


      parent reply	other threads:[~2026-11-03 13:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03 12:07 Sinan Turunc
     [not found] ` <sashiko-outbox-195233@kernel.org>
2026-11-03 13:22   ` Sinan Turunc [this message]

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=20261103132205.675-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=sashiko-reviews@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    --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®