Skip to contentSkip to conversation

ALSA: compress_offload: import DMA_BUF namespace

PATCH In review Arnd Bergmann 4 participants 7 messages Dec 16, 2024 – Dec 20, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ALSA: compress_offload: import DMA_BUF namespace

From: Arnd Bergmann <[email protected]>

The compression offload code cannot be in a loadable module unless it imports that namespace:

ERROR: modpost: module snd-compress uses symbol dma_buf_get from namespace DMA_BUF, but does not import it.
ERROR: modpost: module snd-compress uses symbol dma_buf_put from namespace DMA_BUF, but does not import it.
ERROR: modpost: module snd-compress uses symbol dma_buf_fd from namespace DMA_BUF, but does not import it.

Fixes 04177158cf98 ("ALSA: compress_offload: introduce accel operation mode")
---
 sound/core/compress_offload.c | 1 +
 1 file changed, 1 insertion(+)
sound/core/compress_offload.c +1 -0
index 86ed2fbee0c8..ec2485c00e49 100644
@@ -1247,6 +1247,7 @@ void snd_compr_task_finished(struct snd_compr_stream *stream,
 }
 EXPORT_SYMBOL_GPL(snd_compr_task_finished);
 
+MODULE_IMPORT_NS("DMA_BUF");
 #endif /* CONFIG_SND_COMPRESS_ACCEL */
 
 static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
Signature · 1 line
2.39.5
#1 lore raw

PATCH 2/2 ALSA: compress_offload: avoid 64-bit get_user()

From: Arnd Bergmann <[email protected]>

On some architectures, get_user() cannot read a 64-bit user variable:

arm-linux-gnueabi-ld: sound/core/compress_offload.o: in function `snd_compr_ioctl':
compress_offload.c:(.text.snd_compr_ioctl+0x538): undefined reference to `__get_user_bad'

Use an equivalent copy_from_user() instead.

Fixes 04177158cf98 ("ALSA: compress_offload: introduce accel operation mode")
---
 sound/core/compress_offload.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
sound/core/compress_offload.c +3 -3
index ec2485c00e49..1d6769a66810 100644
@@ -1180,9 +1180,9 @@ static int snd_compr_task_seq(struct snd_compr_stream *stream, unsigned long arg
 
 	if (stream->runtime->state != SNDRV_PCM_STATE_SETUP)
 		return -EPERM;
-	retval = get_user(seqno, (__u64 __user *)arg);
-	if (retval < 0)
-		return retval;
+	retval = copy_from_user(&seqno, (__u64 __user *)arg, sizeof(seqno));
+	if (retval)
+		return -EFAULT;
 	retval = 0;
 	if (seqno == 0) {
 		list_for_each_entry_reverse(task, &stream->runtime->tasks, list)
Signature · 1 line
2.39.5
Acked-by on v1 1/2
#4 lore raw
In reply to Arnd Bergmann
Quoted 6 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The compression offload code cannot be in a loadable module unless it imports that namespace:

Quoted 6 lines

ERROR: modpost: module snd-compress uses symbol dma_buf_get from namespace DMA_BUF, but does not import it.
ERROR: modpost: module snd-compress uses symbol dma_buf_put from namespace DMA_BUF, but does not import it.
ERROR: modpost: module snd-compress uses symbol dma_buf_fd from namespace DMA_BUF, but does not import it.

Fixes 04177158cf98 ("ALSA: compress_offload: introduce accel operation mode")

Best regards
Shengjiu Wang

Quoted 20 lines
---
 sound/core/compress_offload.c | 1 +
 1 file changed, 1 insertion(+)
sound/core/compress_offload.c +1 -1
index 86ed2fbee0c8..ec2485c00e49 100644
@@ -1247,6 +1247,7 @@ void snd_compr_task_finished(struct snd_compr_stream *stream,
 }
 EXPORT_SYMBOL_GPL(snd_compr_task_finished);
 
+MODULE_IMPORT_NS("DMA_BUF");
 #endif /* CONFIG_SND_COMPRESS_ACCEL */
 
 static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
--

2.39.5

Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] ALSA: compress_offload: avoid 64-bit get_user()

In reply to Arnd Bergmann
Quoted 5 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

On some architectures, get_user() cannot read a 64-bit user variable:

Quoted 7 lines

arm-linux-gnueabi-ld: sound/core/compress_offload.o: in function `snd_compr_ioctl':
compress_offload.c:(.text.snd_compr_ioctl+0x538): undefined reference to `__get_user_bad'

Use an equivalent copy_from_user() instead.

Fixes 04177158cf98 ("ALSA: compress_offload: introduce accel operation mode")

Best regards
Shengjiu Wang

Quoted 25 lines
---
 sound/core/compress_offload.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
sound/core/compress_offload.c +3 -4
index ec2485c00e49..1d6769a66810 100644
@@ -1180,9 +1180,9 @@ static int snd_compr_task_seq(struct snd_compr_stream *stream, unsigned long arg
 
        if (stream->runtime->state != SNDRV_PCM_STATE_SETUP)
                return -EPERM;
-       retval = get_user(seqno, (__u64 __user *)arg);
-       if (retval < 0)
-               return retval;
+       retval = copy_from_user(&seqno, (__u64 __user *)arg, sizeof(seqno));
+       if (retval)
+               return -EFAULT;
        retval = 0;
        if (seqno == 0) {
                list_for_each_entry_reverse(task, &stream->runtime->tasks, list)
--

2.39.5

maintainer Acked-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] ALSA: compress_offload: avoid 64-bit get_user()

In reply to Arnd Bergmann
Quoted 8 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

On some architectures, get_user() cannot read a 64-bit user variable:

arm-linux-gnueabi-ld: sound/core/compress_offload.o: in function `snd_compr_ioctl':
compress_offload.c:(.text.snd_compr_ioctl+0x538): undefined reference to `__get_user_bad'

Use an equivalent copy_from_user() instead.

Signature · 1 line
~Vinod
#6 lore raw
In reply to Arnd Bergmann
Quoted 6 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The compression offload code cannot be in a loadable module unless it imports that namespace:

Quoted 6 lines

ERROR: modpost: module snd-compress uses symbol dma_buf_get from namespace DMA_BUF, but does not import it.
ERROR: modpost: module snd-compress uses symbol dma_buf_put from namespace DMA_BUF, but does not import it.
ERROR: modpost: module snd-compress uses symbol dma_buf_fd from namespace DMA_BUF, but does not import it.

Fixes 04177158cf98 ("ALSA: compress_offload: introduce accel operation mode")

Sorry for the delay, as I've been (still) off.
Applied both patches now. Thanks!

Takashi