From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.177 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792809158; b=x5mbNf3p+icvxLUwWl/oq78irFkbDbS9ClNd63BCS1iChDYPLNy7NO2LnpeWhsyeb7fa 5wlEG61vCNUjhkODkG0a/+ObXnCzgjOXVjj5esGwkED3H5ofB4j6I/ve9rYFWMbyKZRxY pf3Bxb8AGXUgF6PDRsmbMwAUOQLoeztwsW/RGyx+LkSeMgnJec2f8ozS3oyBkAfqoS1/3 SXqhPKl+QGyv3gCKN+YAu03YyTKJYsVASImWiX26J+PelBBFSO/b4GrnFkIWn+B8JwORB ybecEGDMJSzWfYhEDkmZQVPQWk/MtA8Qfe8VB6gC1l2juYEFm5bPjo+ZRfGwTZxwNDg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792809158; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=51kv8COGqzMvJBRd7xyPk05iBH4eNFHrYUZxKFt+cc8=; b=wowxd1YQQZGv/gwSDP86ETvsnp3olKjWCHgAroiSn/IL0gWxzUxqIVwKjoqK4cRJGnOn AzpnNr9t/LMTWIN04MR2sEFIp60rD4myHLUOY4lU7iFapEg31vQYIb/5JqK77LjBChErd 84AijVIaIshHkvvfzDQs1TNepi0S902zDGBMSfgO39WkVl592CIbwpxK+duNdwlbb4f2w kyoymsZU6AgpL8li/4gIUjh/GAjUEk6z8ZeJrRqxGVVsX9uBDdYyDDpVBVN0dKEhtXods Dfma5Upug1a3xbZQ2H5nRP1cVaia9yFaw50VzQJYiONuxpE7m0pIzjgsehzzySoU/8g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=QxMhaEBh; arc=none smtp.remote-ip=74.125.82.177 Received: from mail-dy1-f177.google.com (mail-dy1-f177.google.com [74.125.82.177]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C178A606A31E for ; Sat, 24 Oct 2026 02:32:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C178A606A31E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=QxMhaEBh Received: by mail-dy1-f177.google.com with SMTP id 5a478bee46e88-36681e85e87so3598859eec.1 for ; Fri, 23 Oct 2026 19:32:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792809157; x=1793413957; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=51kv8COGqzMvJBRd7xyPk05iBH4eNFHrYUZxKFt+cc8=; b=QxMhaEBhfikMWCAWpnR0tc8eZVZsmkz2ClyByy/KQ2Mt4Hd8Zn+H28qQlA+8AfjxjA 99L/hYPHQd9R/GERaD3YaE0kszRWNTPllTNCXf/B628fueTioZo13itc08kjgqI5D1bv 0QGPglTd7kC6WUTYLnaIGrdxrp7pl05kHmJ0JWcVpOBEIu1Vxtw0ZU0FdxcWR9jRRCjZ 208yIJEAx3H/CCofw4d45xo8i4+aIM4FGj+24cPPYxe1zBZoNnsSvOtdscx250OKuT+k BH3dT1CW2qwE4isnGCBolIbMZzAATvj4hfwD+eZQBh26hH+I/Gjf/9udq2YxYFzSGSeY f/eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792809157; x=1793413957; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=51kv8COGqzMvJBRd7xyPk05iBH4eNFHrYUZxKFt+cc8=; b=s6KJiGNXFRUYNcXtOsTT+4oRrChBJw6QYReYZCm3z/i10VnugqfgxnQeGGemXe2VaQ pF+MtvTSttkm46X6NYOyzA4UPhpXxBtwgNAoS+iRInRFLj6OY1qUYPaYwEqEafWZ2x/B mmy8OJnUGZzgf4ut70tchPhRPbvzjnf3xM6lvKku46gBNBqRwNxRGUciIsKxQj8WBFpv 4dLEhHw0MAQEO1vKcQ+3So7auU83DQYzhZ5zp4AdGGZL1alkey8pJW8OAlfls1OU6DvL OMDDnU9N9RC3XEF24UPbi2L3hO7Pt7Ppk1HB6PEHtHY/WYPrtWk03vWv2KWqKxLNkaA6 nRLg== X-Forwarded-Encrypted: i=1; AKwUvBxFNyWhe+Az5xGyiYPE7gouVtvFurwulxczBPIMzY7hcs/xm74kOhI8r656KgyfkTPGaYCcgttX1eFZY1Q=@vger.kernel.org X-Gm-Message-State: AFq9FYLo+sVQLlb2tXXZJOF9mtbYo0dENEiy4A2Qe4GP1VRlKf9uKugM XWAaTK1dDHRrQNZrLBOxboSoAdCcXTNjk1GXudKwUNBFOhImEHtSgB/s X-Gm-Gg: AYBFou0hruH+CA5zoHuS6hR2qwBnPZ44biWLNUBR6IHt5IlkZeWBLj9pIPN8CT4aKbm WRXe2GGflm03SXsq5I5YyIEAx/f119MNtwnQx4ricjRNqUsthsC6b5fPcQ+zjMKh5q3lWtgjEvL I+7fxJECvTQqxNMbdgRAiwK1i3LugzgpEXF8g1s4YzG+52oz1YOHfxLdBgPXGGQpCaBQWwmd31q RpS8YB+5Fe9ONaZyR/LXm0ifJ6/hkNW8Q1v4MbKa+veJer8nR179OanA0EjsRPJS6ionGqkaqSH QBxbHNM03GzUEJLL1lmdrcaviSzXCTvq/O++ewGxK47+Clhli/OgklUJFywQrTlc0pvshsXhIxY 92Zy+OP/YW7fqNmAnxgImQYhOwcnCISo3GwJZ7SWhpNi2EmRyZx9o128wYFSd1ThUvd2f8YcdbU qwnNy3eci6S64xmgYXTbKAGmOEW97J1eT3/HLU2rGLK+Kt5NbUZWuQ1ZGUp4UT/Dfp/ph94RJgi 2o4PiQTj/PL+RhZmqjIywOs/QrTTnC42HKHPhSFJ4damOLFoF2c/HUjiuuvCi9gbCgLb8Jf/Upc ENhremmiZBmEVRh8oCXQsuOdlujmy93mvGJizqKFLCKGf+LPGsa7fQ2WlbSiR+ZIyIrzM1P9 X-Received: by 2002:a05:693c:810c:b0:367:16cf:4a8d with SMTP id 5a478bee46e88-369e84dcef0mr1536459eec.35.1792809156653; Fri, 23 Oct 2026 19:32:36 -0700 (PDT) Received: from localhost.localdomain ([180.182.24.11]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-369e8ec50bcsm3958542eec.23.2026.10.23.19.32.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Oct 2026 19:32:35 -0700 (PDT) From: Joonho Lee To: linux-sound@vger.kernel.org Cc: perex@perex.cz, tiwai@suse.com, anton.yakovlev@opensynergy.com, mst@redhat.com, virtualization@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 0/2] ALSA: virtio-snd: fix dsnoop capture with staged buffers Date: Sat, 24 Oct 2026 11:32:30 +0900 Message-ID: <20261024023232.84448-1-mynameisjune111@gmail.com> X-Mailer: git-send-email 2.54.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi, This series fixes dsnoop capture on top of the staged-capture virtio-snd changes. dsnoop configures its slave with stop_threshold == boundary and can keep capture running without advancing the slave application pointer as an ordinary reader would. The staged-capture accounting currently exhausts its bounded unread capacity in this configuration. The first patch marks stop_threshold accesses used by the driver's policy sampling. READ_ONCE/WRITE_ONCE provide single-access annotations; the virtio-snd state transitions remain protected by the substream lock. The second patch caches the prepared boundary and samples the stop policy under that lock. A completion uses one sampled policy for validation, copying and queue refill. Free-running capture keeps requests queued and retains the existing frame, payload and pointer-window checks. Returning to bounded capture restores unread accounting from the monotonic counters. If the outstanding data already fills the ring, the policy helper returns -EPIPE without changing the cached mode or counters. The detecting RX, pointer or ACK path then reports XRUN through its existing error path. This does not guarantee a synchronous error from the sw_params ioctl. The ACK accounting and subsequent queue refill each sample the policy under the appropriate locks. Prepare and teardown reset the cached state. The existing ACK-race and priority changes are prerequisites to this series and are excluded from these two diffs. Testing: * ARM64 QEMU synthetic dsnoop capture: 12 files and 2,160,000 frames matched the reference sequence from each client's observed starting position. All 48 corruption, loss, duplication and reordering controls were detected. * Default KCSAN: 13/13 cases and 619 policy transitions passed without race or lockdep reports. Forced RX/ACK policy changes and four isolated policy-helper branches passed under KASAN and KCSAN. * macOS VZ with MOTU UltraLite-mk5 at 48 kHz: comparisons used one or two vCPUs and idle or CPU-saturated guests. The baseline failed all 32 shared-client captures. The candidate passed 48 captures and eight recovery diagnostics, including mixed-rate sharing, client departure, reopening and recovery after an intentionally delayed reader. Loaded shared captures ran for 70 seconds. All eight accepted VM runs shut down on the first request. The physical tests checked frame counts and nonzero input. Exact sample continuity was checked with the QEMU synthetic source. VZ exposed mono; these tests do not establish physical input-channel routing or multichannel support. Aggressive KCSAN still produced dsnoop client-threshold XRUNs with a 160 ms buffer. Further isolation supports a deadline sensitivity, but does not exclude every kernel timing contribution. Separate generic KCSAN reports remain recorded in the test evidence. This series depends on the staged-capture prerequisite stack below. The tested local base is 8d0d4c1a6c4bcb81ae9f52d1c0d979fafb2e22f2, consisting of nine prerequisite patches above sound.git commit 5618f6837ef3314e2c581d4c05ec13b7ed975cb4. Prerequisites, in application order: 1-5. Lifetime and error recovery v3: https://lore.kernel.org/all/cover.1791881787.git.mynameisjune111@gmail.com/ 6. Generic teardown/control wait v2: https://lore.kernel.org/all/rfc-v2-generic-control-wait-0.2eddd58a796e497f@gmail.com/ 7. VZ staged capture v2: https://lore.kernel.org/all/rfc-v2-vz-capture-compat-1.b9ab4c1540dc4691@gmail.com/ 8-9. ACK accounting and high-priority period work: https://lore.kernel.org/all/rfc-virtio-snd-capture-followups-1.f2737c95c12e45b4@gmail.com/ https://lore.kernel.org/all/rfc-virtio-snd-capture-followups-2.f2737c95c12e45b4@gmail.com/ This fixes the staged-capture accounting introduced by that prerequisite stack. The reproductions do not establish the same failure in an unmodified upstream kernel. The policy uses the existing stop_threshold == boundary convention. Sampling it under the driver lock avoids introducing a PCM stream lock into RX completion. A completion overlapping a policy update may finish with the previous policy; its accounting and refill use that same sample. Rejecting a transition whose bounded accounting cannot be restored preserves explicit overflow detection and lets the caller recover the stream. Patches: ALSA: pcm: mark stop-threshold accesses for capture policy sampling ALSA: virtio-snd: fix dsnoop capture with staged buffers Thanks, Joonho