From: Takashi Iwai <tiwai@suse.de>
To: Jaroslav Kysela <perex@perex.cz>
Cc: Ai Chao <aichao@kylinos.cn>,
tiwai@suse.com, kees@kernel.org, linux-sound@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ALSA: pcm: Show closed for DISCONNECTED state
Date: Wed, 17 Jun 2026 10:53:08 +0200 [thread overview]
Message-ID: <87tsr1pmyz.wl-tiwai@suse.de> (raw)
In-Reply-To: <0888c20f-0a0f-458f-9a73-f05d85ecddaa@perex.cz>
On Wed, 17 Jun 2026 10:36:44 +0200,
Jaroslav Kysela wrote:
>
> On 6/17/26 09:19, Ai Chao wrote:
> > Hello Takashi
> >
> >> Thanks, it's a bit clearer. But it still means that it's a cargo fix
> >> only for that specific application. The program should receive an
> >> error for any further syscalls, so that it can close gracefully by
> >> itself. Or it doesn't work as expected?
> >
> > The recording software monitors /proc/asound/card0/pcm0c/sub0/status.
> > When the USB device is suddenly disconnected, the recording software fails
> > to capture audio data from the sound card, with both the hardware pointer
> > and application pointer being 0. The software remains in a pending state,
> > continuously displaying "Generating recording file". If the status file shows
> > "closed" (DISCONNECTED), the audio service detects the status change, reinitializes
> > the device, starts processing the recording file, and either resumes recording or
> > notifies the user.
>
> The PCM API ioctls should return an error in this case (device
> disconnection). Does software communicate with the driver through
> ioctl ? It seems that only mmaped appl/hw pointers are used which is
> not enough to detect the disconnection.
Right, I suspect that it might be the case.
Does the change like below help (or worsen) anything?
Takashi
-- 8< --
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -3907,6 +3907,8 @@ static vm_fault_t snd_pcm_mmap_data_fault(struct vm_fault *vmf)
if (substream == NULL)
return VM_FAULT_SIGBUS;
runtime = substream->runtime;
+ if (runtime->state == SNDRV_PCM_STATE_DISCONNECTED)
+ return VM_FAULT_SIGBUS;
offset = vmf->pgoff << PAGE_SHIFT;
dma_bytes = PAGE_ALIGN(runtime->dma_bytes);
if (offset > dma_bytes - PAGE_SIZE)
next prev parent reply other threads:[~2026-06-17 8:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-17 7:19 Re: Re: [PATCH] ALSA: pcm: Show closed for DISCONNECTED state Ai Chao
2026-06-17 8:36 ` Jaroslav Kysela
2026-06-17 8:53 ` Takashi Iwai [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-06-16 2:06 Ai Chao
2026-06-16 7:24 ` Takashi Iwai
2026-06-15 13:26 Ai Chao
2026-06-15 13:51 ` 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=87tsr1pmyz.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=aichao@kylinos.cn \
--cc=kees@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.