Skip to content

Commit e774004

Browse files
authored
Merge pull request thesofproject#5280 from bardliao/merge/sound-upstream-20250102
Merge/sound upstream 20250102
2 parents 1e81252 + 006a890 commit e774004

File tree

28 files changed

+204
-220
lines changed

28 files changed

+204
-220
lines changed

drivers/soundwire/amd_manager.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,7 @@ static int __maybe_unused amd_resume_runtime(struct device *dev)
11901190
if (amd_manager->power_mode_mask & AMD_SDW_CLK_STOP_MODE) {
11911191
return amd_sdw_clock_stop_exit(amd_manager);
11921192
} else if (amd_manager->power_mode_mask & AMD_SDW_POWER_OFF_MODE) {
1193+
writel(0x00, amd_manager->acp_mmio + ACP_SW_WAKE_EN(amd_manager->instance));
11931194
val = readl(amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL);
11941195
if (val) {
11951196
val |= AMD_SDW_CLK_RESUME_REQ;

drivers/soundwire/bus_type.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,6 @@ static int sdw_drv_remove(struct device *dev)
167167

168168
slave->probed = false;
169169

170-
if (slave->prop.use_domain_irq)
171-
sdw_irq_dispose_mapping(slave);
172-
173170
mutex_unlock(&slave->sdw_dev_lock);
174171

175172
if (drv->remove)

drivers/soundwire/irq.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,18 @@ void sdw_irq_delete(struct sdw_bus *bus)
4646
irq_domain_remove(bus->domain);
4747
}
4848

49+
static void sdw_irq_dispose_mapping(void *data)
50+
{
51+
struct sdw_slave *slave = data;
52+
53+
irq_dispose_mapping(irq_find_mapping(slave->bus->domain, slave->dev_num));
54+
}
55+
4956
void sdw_irq_create_mapping(struct sdw_slave *slave)
5057
{
5158
slave->irq = irq_create_mapping(slave->bus->domain, slave->dev_num);
5259
if (!slave->irq)
5360
dev_warn(&slave->dev, "Failed to map IRQ\n");
54-
}
5561

56-
void sdw_irq_dispose_mapping(struct sdw_slave *slave)
57-
{
58-
irq_dispose_mapping(irq_find_mapping(slave->bus->domain, slave->dev_num));
62+
devm_add_action_or_reset(&slave->dev, sdw_irq_dispose_mapping, slave);
5963
}

drivers/soundwire/irq.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ int sdw_irq_create(struct sdw_bus *bus,
1616
struct fwnode_handle *fwnode);
1717
void sdw_irq_delete(struct sdw_bus *bus);
1818
void sdw_irq_create_mapping(struct sdw_slave *slave);
19-
void sdw_irq_dispose_mapping(struct sdw_slave *slave);
2019

2120
#else /* CONFIG_IRQ_DOMAIN */
2221

@@ -34,10 +33,6 @@ static inline void sdw_irq_create_mapping(struct sdw_slave *slave)
3433
{
3534
}
3635

37-
static inline void sdw_irq_dispose_mapping(struct sdw_slave *slave)
38-
{
39-
}
40-
4136
#endif /* CONFIG_IRQ_DOMAIN */
4237

4338
#endif /* __SDW_IRQ_H */

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 */

include/sound/sdca.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
#ifndef __SDCA_H__
1010
#define __SDCA_H__
1111

12+
#include <linux/types.h>
13+
#include <linux/kconfig.h>
14+
1215
struct sdw_slave;
1316

1417
#define SDCA_MAX_FUNCTION_COUNT 8
@@ -20,9 +23,9 @@ struct sdw_slave;
2023
* @name: human-readable string
2124
*/
2225
struct sdca_function_desc {
23-
u64 adr;
24-
u32 type;
2526
const char *name;
27+
u32 type;
28+
u8 adr;
2629
};
2730

2831
/**

include/sound/sdca_function.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#ifndef __SDCA_FUNCTION_H__
1010
#define __SDCA_FUNCTION_H__
1111

12+
#include <linux/bits.h>
13+
1214
/*
1315
* SDCA Function Types from SDCA specification v1.0a Section 5.1.2
1416
* all Function types not described are reserved
@@ -40,6 +42,7 @@ enum sdca_function_type {
4042
#define SDCA_FUNCTION_TYPE_RJ_NAME "RJ"
4143
#define SDCA_FUNCTION_TYPE_SIMPLE_NAME "SimpleJack"
4244
#define SDCA_FUNCTION_TYPE_HID_NAME "HID"
45+
#define SDCA_FUNCTION_TYPE_IMP_DEF_NAME "ImplementationDefined"
4346

4447
enum sdca_entity0_controls {
4548
SDCA_CONTROL_ENTITY_0_COMMIT_GROUP_MASK = 0x01,

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;

0 commit comments

Comments
 (0)