All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: core: Call substream ack() method upon compat mmap, commit
@ 2021-07-09  8:53 Alan Young
  2021-07-12  9:12 ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Alan Young @ 2021-07-09  8:53 UTC (permalink / raw)
  To: alsa-devel, tiwai

If a 32-bit application is being used with a 64-bit kernel and is using
the mmap mechanism to write data, then the SNDRV_PCM_IOCTL_SYNC_PTR
ioctl results in calling snd_pcm_ioctl_sync_ptr_compat(). Make this use
pcm_lib_apply_appl_ptr() so that the substream's ack() method, if
defined, is called.

The snd_pcm_sync_ptr() function, used in the 64-bit ioctl case, already
uses snd_pcm_ioctl_sync_ptr_compat().

Signed-off-by: Alan Young <consult.awy@gmail.com>
---
  sound/core/pcm_native.c | 11 ++++++++---
  1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 17a85f4815d5..91a749835ca1 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -3057,9 +3057,14 @@ static int snd_pcm_ioctl_sync_ptr_compat(struct 
snd_pcm_substream *substream,
          boundary = 0x7fffffff;
      snd_pcm_stream_lock_irq(substream);
      /* FIXME: we should consider the boundary for the sync from app */
-    if (!(sflags & SNDRV_PCM_SYNC_PTR_APPL))
-        control->appl_ptr = scontrol.appl_ptr;
-    else
+    if (!(sflags & SNDRV_PCM_SYNC_PTR_APPL)) {
+        err = pcm_lib_apply_appl_ptr(substream,
+                scontrol.appl_ptr);
+        if (err < 0) {
+            snd_pcm_stream_unlock_irq(substream);
+            return err;
+        }
+    } else
          scontrol.appl_ptr = control->appl_ptr % boundary;
      if (!(sflags & SNDRV_PCM_SYNC_PTR_AVAIL_MIN))
          control->avail_min = scontrol.avail_min;
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ALSA: core: Call substream ack() method upon compat mmap, commit
  2021-07-09  8:53 [PATCH] ALSA: core: Call substream ack() method upon compat mmap, commit Alan Young
@ 2021-07-12  9:12 ` Takashi Iwai
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2021-07-12  9:12 UTC (permalink / raw)
  To: Alan Young; +Cc: alsa-devel

On Fri, 09 Jul 2021 10:53:42 +0200,
Alan Young wrote:
> 
> If a 32-bit application is being used with a 64-bit kernel and is using
> the mmap mechanism to write data, then the SNDRV_PCM_IOCTL_SYNC_PTR
> ioctl results in calling snd_pcm_ioctl_sync_ptr_compat(). Make this use
> pcm_lib_apply_appl_ptr() so that the substream's ack() method, if
> defined, is called.
> 
> The snd_pcm_sync_ptr() function, used in the 64-bit ioctl case, already
> uses snd_pcm_ioctl_sync_ptr_compat().
> 
> Signed-off-by: Alan Young <consult.awy@gmail.com>

A good catch.  But unfortunately the posted patch couldn't be applied
cleanly.  Could you check your MUA setup and resubmit?


thanks,

Takashi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ALSA: core: Call substream ack() method upon compat mmap, commit
  2021-07-12 10:05 Alan Young
@ 2021-07-12 11:11 ` Takashi Iwai
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2021-07-12 11:11 UTC (permalink / raw)
  To: Alan Young; +Cc: alsa-devel

On Mon, 12 Jul 2021 12:05:40 +0200,
Alan Young wrote:
> 
> If a 32-bit application is being used with a 64-bit kernel and is using
> the mmap mechanism to write data, then the SNDRV_PCM_IOCTL_SYNC_PTR
> ioctl results in calling snd_pcm_ioctl_sync_ptr_compat(). Make this use
> pcm_lib_apply_appl_ptr() so that the substream's ack() method, if
> defined, is called.
> 
> The snd_pcm_sync_ptr() function, used in the 64-bit ioctl case, already
> uses snd_pcm_ioctl_sync_ptr_compat().
> 
> 
> >From 9c3a4ffca82a0106cd858db8be29945cfbcc9952 Mon Sep 17 00:00:00 2001
> From: Alan Young <consult.awy@gmail.com>
> Date: Fri, 9 Jul 2021 09:48:54 +0100
> Subject: [PATCH] ALSA: core: Call substream ack() method upon compat mmap
>  commit
> 
> If a 32-bit application is being used with a 64-bit kernel and is using
> the mmap mechanism to write data, then the SNDRV_PCM_IOCTL_SYNC_PTR
> ioctl results in calling snd_pcm_ioctl_sync_ptr_compat(). Make this use
> pcm_lib_apply_appl_ptr() so that the substream's ack() method, if
> defined, is called.
> 
> The snd_pcm_sync_ptr() function, used in the 64-bit ioctl case, already
> uses snd_pcm_ioctl_sync_ptr_compat().
> 
> Signed-off-by: Alan Young <consult.awy@gmail.com>

Thanks, applied.


Takashi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] ALSA: core: Call substream ack() method upon compat mmap, commit
@ 2021-07-12 10:05 Alan Young
  2021-07-12 11:11 ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Alan Young @ 2021-07-12 10:05 UTC (permalink / raw)
  To: alsa-devel, tiwai

[-- Attachment #1: Type: text/plain, Size: 429 bytes --]

   If a 32-bit application is being used with a 64-bit kernel and is using
   the mmap mechanism to write data, then the SNDRV_PCM_IOCTL_SYNC_PTR
   ioctl results in calling snd_pcm_ioctl_sync_ptr_compat(). Make this use
   pcm_lib_apply_appl_ptr() so that the substream's ack() method, if
   defined, is called.
   The snd_pcm_sync_ptr() function, used in the 64-bit ioctl case, already
   uses snd_pcm_ioctl_sync_ptr_compat().

[-- Attachment #2: 0001-ALSA-core-Call-substream-ack-method-upon-compat-mmap.patch --]
[-- Type: text/x-patch, Size: 1637 bytes --]

From 9c3a4ffca82a0106cd858db8be29945cfbcc9952 Mon Sep 17 00:00:00 2001
From: Alan Young <consult.awy@gmail.com>
Date: Fri, 9 Jul 2021 09:48:54 +0100
Subject: [PATCH] ALSA: core: Call substream ack() method upon compat mmap
 commit

If a 32-bit application is being used with a 64-bit kernel and is using
the mmap mechanism to write data, then the SNDRV_PCM_IOCTL_SYNC_PTR
ioctl results in calling snd_pcm_ioctl_sync_ptr_compat(). Make this use
pcm_lib_apply_appl_ptr() so that the substream's ack() method, if
defined, is called.

The snd_pcm_sync_ptr() function, used in the 64-bit ioctl case, already
uses snd_pcm_ioctl_sync_ptr_compat().

Signed-off-by: Alan Young <consult.awy@gmail.com>
---
 sound/core/pcm_native.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 17a85f4815d5..91a749835ca1 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -3057,9 +3057,14 @@ static int snd_pcm_ioctl_sync_ptr_compat(struct snd_pcm_substream *substream,
 		boundary = 0x7fffffff;
 	snd_pcm_stream_lock_irq(substream);
 	/* FIXME: we should consider the boundary for the sync from app */
-	if (!(sflags & SNDRV_PCM_SYNC_PTR_APPL))
-		control->appl_ptr = scontrol.appl_ptr;
-	else
+	if (!(sflags & SNDRV_PCM_SYNC_PTR_APPL)) {
+		err = pcm_lib_apply_appl_ptr(substream,
+				scontrol.appl_ptr);
+		if (err < 0) {
+			snd_pcm_stream_unlock_irq(substream);
+			return err;
+		}
+	} else
 		scontrol.appl_ptr = control->appl_ptr % boundary;
 	if (!(sflags & SNDRV_PCM_SYNC_PTR_AVAIL_MIN))
 		control->avail_min = scontrol.avail_min;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-12 11:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-09  8:53 [PATCH] ALSA: core: Call substream ack() method upon compat mmap, commit Alan Young
2021-07-12  9:12 ` Takashi Iwai
2021-07-12 10:05 Alan Young
2021-07-12 11:11 ` Takashi Iwai

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.