Skip to content

Commit 23552f6

Browse files
committed
Merge remote-tracking branch 'takashi/for-next' into sound/upstream-20250102
2 parents f03669d + 9001d51 commit 23552f6

30 files changed

Lines changed: 160 additions & 151 deletions

include/sound/pcm.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,9 +1532,10 @@ static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format)
15321532
dev_dbg((pcm)->card->dev, fmt, ##args)
15331533

15341534
/* helpers for copying between iov_iter and iomem */
1535-
int copy_to_iter_fromio(struct iov_iter *itert, const void __iomem *src,
1536-
size_t count);
1537-
int copy_from_iter_toio(void __iomem *dst, struct iov_iter *iter, size_t count);
1535+
size_t copy_to_iter_fromio(const void __iomem *src, size_t bytes,
1536+
struct iov_iter *iter) __must_check;
1537+
size_t copy_from_iter_toio(void __iomem *dst, size_t bytes,
1538+
struct iov_iter *iter) __must_check;
15381539

15391540
struct snd_pcm_status64 {
15401541
snd_pcm_state_t state; /* stream state */

sound/core/compress_offload.c

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ static u64 snd_compr_seqno_next(struct snd_compr_stream *stream)
10251025
static int snd_compr_task_new(struct snd_compr_stream *stream, struct snd_compr_task *utask)
10261026
{
10271027
struct snd_compr_task_runtime *task;
1028-
int retval;
1028+
int retval, fd_i, fd_o;
10291029

10301030
if (stream->runtime->total_tasks >= stream->runtime->fragments)
10311031
return -EBUSY;
@@ -1039,19 +1039,27 @@ static int snd_compr_task_new(struct snd_compr_stream *stream, struct snd_compr_
10391039
retval = stream->ops->task_create(stream, task);
10401040
if (retval < 0)
10411041
goto cleanup;
1042-
utask->input_fd = dma_buf_fd(task->input, O_WRONLY|O_CLOEXEC);
1043-
if (utask->input_fd < 0) {
1044-
retval = utask->input_fd;
1042+
/* similar functionality as in dma_buf_fd(), but ensure that both
1043+
file descriptors are allocated before fd_install() */
1044+
if (!task->input || !task->input->file || !task->output || !task->output->file) {
1045+
retval = -EINVAL;
10451046
goto cleanup;
10461047
}
1047-
utask->output_fd = dma_buf_fd(task->output, O_RDONLY|O_CLOEXEC);
1048-
if (utask->output_fd < 0) {
1049-
retval = utask->output_fd;
1048+
fd_i = get_unused_fd_flags(O_WRONLY|O_CLOEXEC);
1049+
if (fd_i < 0)
1050+
goto cleanup;
1051+
fd_o = get_unused_fd_flags(O_RDONLY|O_CLOEXEC);
1052+
if (fd_o < 0) {
1053+
put_unused_fd(fd_i);
10501054
goto cleanup;
10511055
}
10521056
/* keep dmabuf reference until freed with task free ioctl */
1053-
dma_buf_get(utask->input_fd);
1054-
dma_buf_get(utask->output_fd);
1057+
get_dma_buf(task->input);
1058+
get_dma_buf(task->output);
1059+
fd_install(fd_i, task->input->file);
1060+
fd_install(fd_o, task->output->file);
1061+
utask->input_fd = fd_i;
1062+
utask->output_fd = fd_o;
10551063
list_add_tail(&task->list, &stream->runtime->tasks);
10561064
stream->runtime->total_tasks++;
10571065
return 0;
@@ -1069,7 +1077,7 @@ static int snd_compr_task_create(struct snd_compr_stream *stream, unsigned long
10691077
return -EPERM;
10701078
task = memdup_user((void __user *)arg, sizeof(*task));
10711079
if (IS_ERR(task))
1072-
return PTR_ERR(no_free_ptr(task));
1080+
return PTR_ERR(task);
10731081
retval = snd_compr_task_new(stream, task);
10741082
if (retval >= 0)
10751083
if (copy_to_user((void __user *)arg, task, sizeof(*task)))
@@ -1130,7 +1138,7 @@ static int snd_compr_task_start_ioctl(struct snd_compr_stream *stream, unsigned
11301138
return -EPERM;
11311139
task = memdup_user((void __user *)arg, sizeof(*task));
11321140
if (IS_ERR(task))
1133-
return PTR_ERR(no_free_ptr(task));
1141+
return PTR_ERR(task);
11341142
retval = snd_compr_task_start(stream, task);
11351143
if (retval >= 0)
11361144
if (copy_to_user((void __user *)arg, task, sizeof(*task)))
@@ -1174,18 +1182,18 @@ typedef void (*snd_compr_seq_func_t)(struct snd_compr_stream *stream,
11741182
static int snd_compr_task_seq(struct snd_compr_stream *stream, unsigned long arg,
11751183
snd_compr_seq_func_t fcn)
11761184
{
1177-
struct snd_compr_task_runtime *task;
1185+
struct snd_compr_task_runtime *task, *temp;
11781186
__u64 seqno;
11791187
int retval;
11801188

11811189
if (stream->runtime->state != SNDRV_PCM_STATE_SETUP)
11821190
return -EPERM;
1183-
retval = get_user(seqno, (__u64 __user *)arg);
1184-
if (retval < 0)
1185-
return retval;
1191+
retval = copy_from_user(&seqno, (__u64 __user *)arg, sizeof(seqno));
1192+
if (retval)
1193+
return -EFAULT;
11861194
retval = 0;
11871195
if (seqno == 0) {
1188-
list_for_each_entry_reverse(task, &stream->runtime->tasks, list)
1196+
list_for_each_entry_safe_reverse(task, temp, &stream->runtime->tasks, list)
11891197
fcn(stream, task);
11901198
} else {
11911199
task = snd_compr_find_task(stream, seqno);
@@ -1221,7 +1229,7 @@ static int snd_compr_task_status_ioctl(struct snd_compr_stream *stream, unsigned
12211229
return -EPERM;
12221230
status = memdup_user((void __user *)arg, sizeof(*status));
12231231
if (IS_ERR(status))
1224-
return PTR_ERR(no_free_ptr(status));
1232+
return PTR_ERR(status);
12251233
retval = snd_compr_task_status(stream, status);
12261234
if (retval >= 0)
12271235
if (copy_to_user((void __user *)arg, status, sizeof(*status)))
@@ -1247,6 +1255,7 @@ void snd_compr_task_finished(struct snd_compr_stream *stream,
12471255
}
12481256
EXPORT_SYMBOL_GPL(snd_compr_task_finished);
12491257

1258+
MODULE_IMPORT_NS("DMA_BUF");
12501259
#endif /* CONFIG_SND_COMPRESS_ACCEL */
12511260

12521261
static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg)

sound/core/memalloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ static void *snd_dma_wc_alloc(struct snd_dma_buffer *dmab, size_t size)
505505
if (!p)
506506
return NULL;
507507
dmab->addr = dma_map_single(dmab->dev.dev, p, size, DMA_BIDIRECTIONAL);
508-
if (dmab->addr == DMA_MAPPING_ERROR) {
508+
if (dma_mapping_error(dmab->dev.dev, dmab->addr)) {
509509
do_free_pages(dmab->area, size, true);
510510
return NULL;
511511
}

sound/core/memory.c

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,38 +27,43 @@ int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size
2727

2828
if (import_ubuf(ITER_DEST, dst, count, &iter))
2929
return -EFAULT;
30-
return copy_to_iter_fromio(&iter, (const void __iomem *)src, count);
30+
if (copy_to_iter_fromio((const void __iomem *)src, count, &iter) != count)
31+
return -EFAULT;
32+
return 0;
3133
}
3234
EXPORT_SYMBOL(copy_to_user_fromio);
3335

3436
/**
3537
* copy_to_iter_fromio - copy data from mmio-space to iov_iter
36-
* @dst: the destination iov_iter
3738
* @src: the source pointer on mmio
3839
* @count: the data size to copy in bytes
40+
* @dst: the destination iov_iter
3941
*
4042
* Copies the data from mmio-space to iov_iter.
4143
*
42-
* Return: Zero if successful, or non-zero on failure.
44+
* Return: number of bytes to be copied
4345
*/
44-
int copy_to_iter_fromio(struct iov_iter *dst, const void __iomem *src,
45-
size_t count)
46+
size_t copy_to_iter_fromio(const void __iomem *src, size_t count,
47+
struct iov_iter *dst)
4648
{
4749
#if defined(__i386__) || defined(CONFIG_SPARC32)
48-
return copy_to_iter((const void __force *)src, count, dst) == count ? 0 : -EFAULT;
50+
return copy_to_iter((const void __force *)src, count, dst);
4951
#else
5052
char buf[256];
53+
size_t res = 0;
54+
5155
while (count) {
5256
size_t c = count;
5357
if (c > sizeof(buf))
5458
c = sizeof(buf);
5559
memcpy_fromio(buf, (void __iomem *)src, c);
5660
if (copy_to_iter(buf, c, dst) != c)
57-
return -EFAULT;
61+
return res;
5862
count -= c;
5963
src += c;
64+
res += c;
6065
}
61-
return 0;
66+
return res;
6267
#endif
6368
}
6469
EXPORT_SYMBOL(copy_to_iter_fromio);
@@ -79,37 +84,43 @@ int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size
7984

8085
if (import_ubuf(ITER_SOURCE, (void __user *)src, count, &iter))
8186
return -EFAULT;
82-
return copy_from_iter_toio((void __iomem *)dst, &iter, count);
87+
if (copy_from_iter_toio((void __iomem *)dst, count, &iter) != count)
88+
return -EFAULT;
89+
return 0;
8390
}
8491
EXPORT_SYMBOL(copy_from_user_toio);
8592

8693
/**
8794
* copy_from_iter_toio - copy data from iov_iter to mmio-space
8895
* @dst: the destination pointer on mmio-space
89-
* @src: the source iov_iter
9096
* @count: the data size to copy in bytes
97+
* @src: the source iov_iter
9198
*
9299
* Copies the data from iov_iter to mmio-space.
93100
*
94-
* Return: Zero if successful, or non-zero on failure.
101+
* Return: number of bytes to be copied
95102
*/
96-
int copy_from_iter_toio(void __iomem *dst, struct iov_iter *src, size_t count)
103+
size_t copy_from_iter_toio(void __iomem *dst, size_t count,
104+
struct iov_iter *src)
97105
{
98106
#if defined(__i386__) || defined(CONFIG_SPARC32)
99-
return copy_from_iter((void __force *)dst, count, src) == count ? 0 : -EFAULT;
107+
return copy_from_iter((void __force *)dst, count, src);
100108
#else
101109
char buf[256];
110+
size_t res = 0;
111+
102112
while (count) {
103113
size_t c = count;
104114
if (c > sizeof(buf))
105115
c = sizeof(buf);
106116
if (copy_from_iter(buf, c, src) != c)
107-
return -EFAULT;
117+
return res;
108118
memcpy_toio(dst, buf, c);
109119
count -= c;
110120
dst += c;
121+
res += c;
111122
}
112-
return 0;
123+
return res;
113124
#endif
114125
}
115126
EXPORT_SYMBOL(copy_from_iter_toio);

sound/core/seq/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ config SND_SEQ_VIRMIDI
6262

6363
config SND_SEQ_UMP
6464
bool "Support for UMP events"
65-
default y if SND_SEQ_UMP_CLIENT
65+
default SND_UMP
6666
help
6767
Say Y here to enable the support for handling UMP (Universal MIDI
6868
Packet) events via ALSA sequencer infrastructure, which is an
@@ -71,6 +71,6 @@ config SND_SEQ_UMP
7171
among legacy and UMP clients.
7272

7373
config SND_SEQ_UMP_CLIENT
74-
def_tristate SND_UMP
74+
def_tristate SND_UMP && SND_SEQ_UMP
7575

7676
endif # SND_SEQUENCER

sound/core/seq/oss/seq_oss_device.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ struct seq_oss_chinfo {
5555
struct seq_oss_synthinfo {
5656
struct snd_seq_oss_arg arg;
5757
struct seq_oss_chinfo *ch;
58-
struct seq_oss_synth_sysex *sysex;
5958
int nr_voices;
6059
int opened;
6160
int is_midi;

sound/core/seq/oss/seq_oss_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ snd_seq_oss_create_client(void)
111111

112112

113113
/*
114-
* receive annoucement from system port, and check the midi device
114+
* receive announcement from system port, and check the midi device
115115
*/
116116
static int
117117
receive_announce(struct snd_seq_event *ev, int direct, void *private, int atomic, int hop)

sound/core/seq/oss/seq_oss_synth.c

Lines changed: 14 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@
2626
* definition of synth info records
2727
*/
2828

29-
/* sysex buffer */
30-
struct seq_oss_synth_sysex {
31-
int len;
32-
int skip;
33-
unsigned char buf[MAX_SYSEX_BUFLEN];
34-
};
35-
3629
/* synth info */
3730
struct seq_oss_synth {
3831
int seq_device;
@@ -318,8 +311,6 @@ snd_seq_oss_synth_cleanup(struct seq_oss_devinfo *dp)
318311
}
319312
snd_use_lock_free(&rec->use_lock);
320313
}
321-
kfree(info->sysex);
322-
info->sysex = NULL;
323314
kfree(info->ch);
324315
info->ch = NULL;
325316
}
@@ -395,8 +386,6 @@ snd_seq_oss_synth_reset(struct seq_oss_devinfo *dp, int dev)
395386
info = get_synthinfo_nospec(dp, dev);
396387
if (!info || !info->opened)
397388
return;
398-
if (info->sysex)
399-
info->sysex->len = 0; /* reset sysex */
400389
reset_channels(info);
401390
if (info->is_midi) {
402391
if (midi_synth_dev.opened <= 0)
@@ -408,8 +397,6 @@ snd_seq_oss_synth_reset(struct seq_oss_devinfo *dp, int dev)
408397
dp->file_mode) < 0) {
409398
midi_synth_dev.opened--;
410399
info->opened = 0;
411-
kfree(info->sysex);
412-
info->sysex = NULL;
413400
kfree(info->ch);
414401
info->ch = NULL;
415402
}
@@ -482,63 +469,26 @@ snd_seq_oss_synth_info(struct seq_oss_devinfo *dp, int dev)
482469

483470
/*
484471
* receive OSS 6 byte sysex packet:
485-
* the full sysex message will be sent if it reaches to the end of data
486-
* (0xff).
472+
* the event is filled and prepared for sending immediately
473+
* (i.e. sysex messages are fragmented)
487474
*/
488475
int
489476
snd_seq_oss_synth_sysex(struct seq_oss_devinfo *dp, int dev, unsigned char *buf, struct snd_seq_event *ev)
490477
{
491-
int i, send;
492-
unsigned char *dest;
493-
struct seq_oss_synth_sysex *sysex;
494-
struct seq_oss_synthinfo *info;
478+
unsigned char *p;
479+
int len = 6;
495480

496-
info = snd_seq_oss_synth_info(dp, dev);
497-
if (!info)
498-
return -ENXIO;
481+
p = memchr(buf, 0xff, 6);
482+
if (p)
483+
len = p - buf + 1;
499484

500-
sysex = info->sysex;
501-
if (sysex == NULL) {
502-
sysex = kzalloc(sizeof(*sysex), GFP_KERNEL);
503-
if (sysex == NULL)
504-
return -ENOMEM;
505-
info->sysex = sysex;
506-
}
507-
508-
send = 0;
509-
dest = sysex->buf + sysex->len;
510-
/* copy 6 byte packet to the buffer */
511-
for (i = 0; i < 6; i++) {
512-
if (buf[i] == 0xff) {
513-
send = 1;
514-
break;
515-
}
516-
dest[i] = buf[i];
517-
sysex->len++;
518-
if (sysex->len >= MAX_SYSEX_BUFLEN) {
519-
sysex->len = 0;
520-
sysex->skip = 1;
521-
break;
522-
}
523-
}
524-
525-
if (sysex->len && send) {
526-
if (sysex->skip) {
527-
sysex->skip = 0;
528-
sysex->len = 0;
529-
return -EINVAL; /* skip */
530-
}
531-
/* copy the data to event record and send it */
532-
ev->flags = SNDRV_SEQ_EVENT_LENGTH_VARIABLE;
533-
if (snd_seq_oss_synth_addr(dp, dev, ev))
534-
return -EINVAL;
535-
ev->data.ext.len = sysex->len;
536-
ev->data.ext.ptr = sysex->buf;
537-
sysex->len = 0;
538-
return 0;
539-
}
540-
541-
return -EINVAL; /* skip */
485+
/* copy the data to event record and send it */
486+
if (snd_seq_oss_synth_addr(dp, dev, ev))
487+
return -EINVAL;
488+
ev->flags = SNDRV_SEQ_EVENT_LENGTH_VARIABLE;
489+
ev->data.ext.len = len;
490+
ev->data.ext.ptr = buf;
491+
return 0;
542492
}
543493

544494
/*

0 commit comments

Comments
 (0)