From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C8C84A4F00 for ; Wed, 14 Oct 2026 08:15:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791965747; cv=none; b=Qpe3TGOdd0fci+UBLykIoYuotRjP70H0CY4tbIWPoCVHMlSzvSWjLZ4q7ir0gFoWzxTdleUBss8VVpXuOOceXHnLVvTD9wz0SAAnrmuNJgPZC8pyLNd0aA1Hd7KQRdwpc8KjDR7U5PweFGDVFJ/dUffvS3MVep8LHeoUnbbh0sA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791965747; c=relaxed/simple; bh=NfRbfyqv4MISWvfFB6YrL+5/YWMuOqeIK2SxP9SAFo4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mAiGez0HX9vFAj/oZib64WpoqZmewzmQeYM0NU3AqghacTOl+PTzJ0AN5rWF84u/UMrotucKrDZlk13dPW0gqlTMJlDucsYAKM3Dd1pogEgnoR7IJau8uLg54UirVUzW5lSWE1G3MWPP5M58v5PaUWw/SXGtVA6iOTm4hgCnw7k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RmkAmbBm; arc=none smtp.client-ip=209.85.210.180 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) header.d=gmail.com header.i=@gmail.com header.b="RmkAmbBm" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-8875d220446so1926582b3a.3 for ; Wed, 14 Oct 2026 01:15:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1791965743; x=1792570543; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=CCQEOhtmFz7cT7CBUEXeFEMa04vdTqpWMOvtYLUe+QE=; b=RmkAmbBm+kVYQAOBQyaXZDz1KvffjwKtbU7Y/k/HBcLTPyXeTQGnWjUOZZ+D0KPTox rrQTUFVqmK567FTiWa2VSnqtRmLFh7yfrliT1Oqi8gCZxor76IfxAFB3DskrIyEv2kFB bTdA75knQDC88/v5MG/qosdyag/ork1wtWE2JvMKgTLDFX7I6Gbw+7Oh5O2wUsxDPSwQ wY/5qrVUsVT5O5r5xIy/pD7seXf5/ud5iIhC606MfA28wixUDkXv45553z1E1tMSxieU 6T20QWRm29YLgNrBUF3FkQyQ8tUvYRjf5NWAZDDj0dmoEokZZsp9bsbZzxyq50Fx5bTw X+Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791965743; x=1792570543; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to: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=CCQEOhtmFz7cT7CBUEXeFEMa04vdTqpWMOvtYLUe+QE=; b=o+Nv6Iel8uN4Ao6INHFf0irjTxlNypDguxuB2fo9EDPNlTOup1066vC++gc9KxihSB xnrf6/DrtZK+mcnJUIxlu4CWP9wYZQAgzf13LEhTDgvznD0iV/mXWR8SOPdmRf5UlJYx lnRTUPpcwKZBOmWlLet2C4c6u5CdHukEudkrJOv48CDEiI6QiK/1r236b7joQ1HGouQf gAVps3dvFWUMIcP93kYtUNaMoIzXt415mcgrLjv8DiI0+onLTTUjwl5n/la2zdVlQE/W QXtYHprZ3rNQEr5R8mtfXv/2GJCvugkPPfnjE9QkzHz9otHTXshD4UMZ5OsScsu22zrN Sjnw== X-Gm-Message-State: AFq9FYJ0wyVr2N+EOFy+gBOk13ZasfDpxpCYjIvkq0hoGHnUIk+3qIgT OENDkJkEGmg/BcK7+iqA3g837+IqiphAPO8Tiq7h5RQ2rmSSIM8dhRDL X-Gm-Gg: AYBFou0AqgYeWxGPO+XKQZad/YSy6i7ka3WO6p9OqPgwScGHThGgmGIqGXoruGtYRDr T2UFha04ZQ5Q+YEPOp9zor17UloXxXG5XlSLUGBp5XhP5S2DHKUHeIUuOEBzzSNFD4SUZjsrADw umgXXmYUt76LnoxHNTbtv0/KCrnutvSsyNlsqtmv7vi1NCHBPK9Ipe5YW3bLyr9Bx/2eWxm2iuM O4eB1LtLuIR2oA4pQ18o0yhjLLI4LhoSR3O+gEW5FoedkrHq1IHa37HaeUqhuBSP8UUsuQ1y/fo jGlTgqiBMTHilvULAKDm0nkjFZ3hUyHSw6uMsBfx8v0P9MJ5IBd30g9nRoYDQKU5o45HkfJ1YCL SJGEgiEWJ5h99FOXjW3yAA+Fmyy8Ja3v1Ealm7Cycm7dLoZEz5RmJKTkapBcmN4JM7iW+hJV02E 6x/49zq1zO/RPfLMt0bUUYkj3AtUKg7bPCnCbOJ/UGvMwj7n8sbOIoheG+o+q1R23OOgqcSDKLb nEuH0kKd2EqtT7k+heVNzX4dFE7FJ2D52ogdCGcoCsgaLRXGrh+czo43hYutX5Z/3y+xFzqT9z0 RqCAfNshAb0Zgjc7bH6eECnijQ== X-Received: by 2002:a05:6a21:a345:b0:3dd:a197:cf31 with SMTP id adf61e73a8af0-3e16bf67ae8mr11898673637.85.1791965743197; Wed, 14 Oct 2026 01:15:43 -0700 (PDT) Received: from localhost.localdomain ([121.137.86.182]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cd3d9d4fc36sm6523770a12.1.2026.10.14.01.15.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 14 Oct 2026 01:15:42 -0700 (PDT) From: Joonho Lee To: Takashi Iwai , Jaroslav Kysela Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org Subject: [RFC PATCH v2 0/2] ALSA: pcm: preserve capture tail during drain Date: Wed, 14 Oct 2026 17:15:38 +0900 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes since RFC v1 Patch 1 is unchanged. Patch 2 replaces scoped guards with explicit lock and unlock pairs because include/linux/cleanup.h prohibits mixing cleanup helpers and goto within one function. This addresses the Sashiko review. We did not establish an existing double unlock or skipped unlock: the old gotos were outside the scoped blocks. The link-lock scope, per-member pointer refresh, error path and playback wait loop are preserved. The build and regression results below are from the revised candidate. The public base and ordered prerequisite patch IDs appear below. The local v3 tip d58a3ac9b1719fdf8ce9d286be606128aeebf1aa is reconstructed by applying the five v3 patches to that public base; it is not an upstream commit. This is v2 of this follow-up RFC, not v4 of the five-patch virtio-snd lifetime series. The v3 prerequisite thread is: https://lore.kernel.org/all/cover.1791881787.git.mynameisjune111@gmail.com/ The submitted v3 fixes ACK error propagation, failed START recovery, and message/buffer lifetime through completion and reset. It does not add the VZ capture profile or the ALSA core drain handling in these companion RFCs. This series proposes two changes to capture drain handling: 1. Permit capture transfer calls while the runtime is DRAINING, so buffered tail frames remain readable instead of returning -EBADFD at the state check. Playback access rules remain unchanged. 2. Refresh active capture hardware pointers before the linked group enters DRAINING, so a final subperiod tail is accounted. Hold the link read lock across the initial operation and take each member's stream lock for its pointer refresh. Propagate pointer errors before the drain transition. These are ALSA core changes, not VZ quirks. They apply with all VZ options disabled and can affect other capture drivers, including linked-stream drain ordering. No new ioctl is added, but applications can observe buffered data where the previous state check rejected a read. The appropriate core drain semantics and locking scope need review independently of VZ support. Dependencies Apply these two patches in order on v3. They do not depend on the companion STOP/RELEASE wait patch. The VZ capture RFC requires all three prerequisites. The base is pinned for reproducibility; this is not a claim that the core changes are inherently dependent on virtio-snd lifetime fixes. Validation and limits The complete local candidate (v3 plus all four RFC patches, including the revised core locking) was freshly built on 2026-10-14 as an ARM64 Image and full module set with W=1, KASAN, PROVE_LOCKING, LOCKDEP and DEBUG_ATOMIC_SLEEP, release 7.3.0-rc6-snd-rfc-cleanup-lockdep. There were no build errors or warnings in the changed sound paths; 517 -Woverride-init warnings remain in two unchanged ARM64 base files. This is a rebuild of the pinned candidate, not a rebase to a newer upstream or sound maintainer tree. With this kernel under ordinary TCG, no-query short-tail drain returns 1023 frames (FNV-1a64 20d61b4edef6d535) and 2047 frames (af2de207e4d27535); drop returns zero. Each run also passes a following capture with fatal-overrun checking, playback drain guard and teardown. The linked-stream fixture was also rebuilt against this kernel's config and Module.symvers. Normal unlinked/linked drain passed. An injected pointer XRUN in the later member visited both pointers and returned EPIPE with both streams in XRUN. Unlink/prepare, close/reopen, capture/playback recovery and teardown passed with lockdep enabled. This is a synthetic ALSA fixture, not a physical-device test. The QEMU 11.1.2 fixture includes backend reset cleanup changes as well as fault injection. These are integrated candidate results, not standalone v3 or isolated-patch proof, and not stock-QEMU, VZ or hardware acceptance. Earlier runs failed follow-on capture with ring saturation and overruns; those logs remain retained. Final passes do not establish a permanent fix for load or clock/scheduling sensitivity. Physical ALSA devices and the full range of linked capture/playback groups remain untested. Historical AirPods capture does not isolate core drain semantics. Playback access rules remain unchanged, but the shared drain entry locking/order changes also need review for playback-led groups. All ten ordinary-TCG regression scenarios passed with the fresh candidate, as did the additional linked-stream error/recovery fixture and 24 Python harness tests. Successful runtime logs contained no KASAN, lockdep, WARNING, BUG, Oops or panic diagnostics. Initial harness/CPU-configuration failures are retained as invalid attempts, not counted as kernel passes. No new real-microphone or VZ runtime test was performed for this revision. Reproducer The previously published source package remains at this pinned commit: https://github.com/whatisyourname0/virtio-snd-reproducer/tree/7a9876738bdc70ce669f02ec31fe8968eb0ee4fc/rfc/vz-capture-20261014 It contains the original RFC snapshots, kernel builder, QEMU fixture and ten runtime commands. It does not contain the revised core locking or the newly rebuilt linked-stream fixture. Do not treat it as the exact source of the new results above. Existing v3 patches in it are build prerequisites, not patches being resubmitted. The revised source stack, four signed implementation patches, exact kernel config and portable linked-stream fixture are published at this commit: https://github.com/whatisyourname0/virtio-snd-reproducer/tree/64fa85f3260b45e7dbb85c4eee68a5b4a8b064e1/rfc/vz-capture-20261014/sashiko-followup The public source recipe reconstructs all eight changed files byte-for-byte against the tested candidate. The packaged linked fixture also passed with freshly compiled probes, a new Alpine rootfs and a rebuilt test module on the same KASAN/lockdep kernel. The public archive was downloaded and checked against the local source package. See README.md and RESULTS.txt at that URL. This supplements the earlier bundle; use its corrected core 2/2 patch rather than the earlier core 2/2 snapshot. Questions for review - Is reading buffered capture data in DRAINING the intended ALSA contract, or should the driver expose that tail through a different transition? - Is drain entry the correct place to refresh capture pointers, including when draining a paused stream or a linked capture/playback group? - Is the proposed link-lock/member-lock scope appropriate when a pointer error can stop the group? Which other driver or linked-stream cases should be required before treating this as a general core fix? Joonho Lee (2): ALSA: pcm: allow capture reads while draining ALSA: pcm: refresh capture pointers before drain sound/core/pcm_lib.c | 10 +++++++--- sound/core/pcm_native.c | 26 ++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) base-commit: 8d70e364e866bdfca81eee24d0688fac9472cfb9 prerequisite-patch-id: 39fb327a004c966ab90f66a34a64bbdbb3ffb475 prerequisite-patch-id: 7c6bc344656fd839ae0d697ba18d66ac0b47827a prerequisite-patch-id: 9dd290ac3147fa7b49a475d7df8a6172778f2860 prerequisite-patch-id: f4c24a5e441343a690f4ac2437f181c815bc23d0 prerequisite-patch-id: ab4a5b770247a65272ab7af18a75a147daf81287