Skip to content

Commit

Permalink
Merge pull request thesofproject#5280 from bardliao/merge/sound-upstr…
Browse files Browse the repository at this point in the history
…eam-20250102

Merge/sound upstream 20250102
  • Loading branch information
bardliao authored Jan 7, 2025
2 parents 1e81252 + 006a890 commit e774004
Show file tree
Hide file tree
Showing 28 changed files with 204 additions and 220 deletions.
1 change: 1 addition & 0 deletions drivers/soundwire/amd_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,7 @@ static int __maybe_unused amd_resume_runtime(struct device *dev)
if (amd_manager->power_mode_mask & AMD_SDW_CLK_STOP_MODE) {
return amd_sdw_clock_stop_exit(amd_manager);
} else if (amd_manager->power_mode_mask & AMD_SDW_POWER_OFF_MODE) {
writel(0x00, amd_manager->acp_mmio + ACP_SW_WAKE_EN(amd_manager->instance));
val = readl(amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL);
if (val) {
val |= AMD_SDW_CLK_RESUME_REQ;
Expand Down
3 changes: 0 additions & 3 deletions drivers/soundwire/bus_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,6 @@ static int sdw_drv_remove(struct device *dev)

slave->probed = false;

if (slave->prop.use_domain_irq)
sdw_irq_dispose_mapping(slave);

mutex_unlock(&slave->sdw_dev_lock);

if (drv->remove)
Expand Down
12 changes: 8 additions & 4 deletions drivers/soundwire/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,18 @@ void sdw_irq_delete(struct sdw_bus *bus)
irq_domain_remove(bus->domain);
}

static void sdw_irq_dispose_mapping(void *data)
{
struct sdw_slave *slave = data;

irq_dispose_mapping(irq_find_mapping(slave->bus->domain, slave->dev_num));
}

void sdw_irq_create_mapping(struct sdw_slave *slave)
{
slave->irq = irq_create_mapping(slave->bus->domain, slave->dev_num);
if (!slave->irq)
dev_warn(&slave->dev, "Failed to map IRQ\n");
}

void sdw_irq_dispose_mapping(struct sdw_slave *slave)
{
irq_dispose_mapping(irq_find_mapping(slave->bus->domain, slave->dev_num));
devm_add_action_or_reset(&slave->dev, sdw_irq_dispose_mapping, slave);
}
5 changes: 0 additions & 5 deletions drivers/soundwire/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ int sdw_irq_create(struct sdw_bus *bus,
struct fwnode_handle *fwnode);
void sdw_irq_delete(struct sdw_bus *bus);
void sdw_irq_create_mapping(struct sdw_slave *slave);
void sdw_irq_dispose_mapping(struct sdw_slave *slave);

#else /* CONFIG_IRQ_DOMAIN */

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

static inline void sdw_irq_dispose_mapping(struct sdw_slave *slave)
{
}

#endif /* CONFIG_IRQ_DOMAIN */

#endif /* __SDW_IRQ_H */
7 changes: 4 additions & 3 deletions include/sound/pcm.h
Original file line number Diff line number Diff line change
Expand Up @@ -1532,9 +1532,10 @@ static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format)
dev_dbg((pcm)->card->dev, fmt, ##args)

/* helpers for copying between iov_iter and iomem */
int copy_to_iter_fromio(struct iov_iter *itert, const void __iomem *src,
size_t count);
int copy_from_iter_toio(void __iomem *dst, struct iov_iter *iter, size_t count);
size_t copy_to_iter_fromio(const void __iomem *src, size_t bytes,
struct iov_iter *iter) __must_check;
size_t copy_from_iter_toio(void __iomem *dst, size_t bytes,
struct iov_iter *iter) __must_check;

struct snd_pcm_status64 {
snd_pcm_state_t state; /* stream state */
Expand Down
7 changes: 5 additions & 2 deletions include/sound/sdca.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#ifndef __SDCA_H__
#define __SDCA_H__

#include <linux/types.h>
#include <linux/kconfig.h>

struct sdw_slave;

#define SDCA_MAX_FUNCTION_COUNT 8
Expand All @@ -20,9 +23,9 @@ struct sdw_slave;
* @name: human-readable string
*/
struct sdca_function_desc {
u64 adr;
u32 type;
const char *name;
u32 type;
u8 adr;
};

/**
Expand Down
3 changes: 3 additions & 0 deletions include/sound/sdca_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#ifndef __SDCA_FUNCTION_H__
#define __SDCA_FUNCTION_H__

#include <linux/bits.h>

/*
* SDCA Function Types from SDCA specification v1.0a Section 5.1.2
* all Function types not described are reserved
Expand Down Expand Up @@ -40,6 +42,7 @@ enum sdca_function_type {
#define SDCA_FUNCTION_TYPE_RJ_NAME "RJ"
#define SDCA_FUNCTION_TYPE_SIMPLE_NAME "SimpleJack"
#define SDCA_FUNCTION_TYPE_HID_NAME "HID"
#define SDCA_FUNCTION_TYPE_IMP_DEF_NAME "ImplementationDefined"

enum sdca_entity0_controls {
SDCA_CONTROL_ENTITY_0_COMMIT_GROUP_MASK = 0x01,
Expand Down
43 changes: 26 additions & 17 deletions sound/core/compress_offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ static u64 snd_compr_seqno_next(struct snd_compr_stream *stream)
static int snd_compr_task_new(struct snd_compr_stream *stream, struct snd_compr_task *utask)
{
struct snd_compr_task_runtime *task;
int retval;
int retval, fd_i, fd_o;

if (stream->runtime->total_tasks >= stream->runtime->fragments)
return -EBUSY;
Expand All @@ -1039,19 +1039,27 @@ static int snd_compr_task_new(struct snd_compr_stream *stream, struct snd_compr_
retval = stream->ops->task_create(stream, task);
if (retval < 0)
goto cleanup;
utask->input_fd = dma_buf_fd(task->input, O_WRONLY|O_CLOEXEC);
if (utask->input_fd < 0) {
retval = utask->input_fd;
/* similar functionality as in dma_buf_fd(), but ensure that both
file descriptors are allocated before fd_install() */
if (!task->input || !task->input->file || !task->output || !task->output->file) {
retval = -EINVAL;
goto cleanup;
}
utask->output_fd = dma_buf_fd(task->output, O_RDONLY|O_CLOEXEC);
if (utask->output_fd < 0) {
retval = utask->output_fd;
fd_i = get_unused_fd_flags(O_WRONLY|O_CLOEXEC);
if (fd_i < 0)
goto cleanup;
fd_o = get_unused_fd_flags(O_RDONLY|O_CLOEXEC);
if (fd_o < 0) {
put_unused_fd(fd_i);
goto cleanup;
}
/* keep dmabuf reference until freed with task free ioctl */
dma_buf_get(utask->input_fd);
dma_buf_get(utask->output_fd);
get_dma_buf(task->input);
get_dma_buf(task->output);
fd_install(fd_i, task->input->file);
fd_install(fd_o, task->output->file);
utask->input_fd = fd_i;
utask->output_fd = fd_o;
list_add_tail(&task->list, &stream->runtime->tasks);
stream->runtime->total_tasks++;
return 0;
Expand All @@ -1069,7 +1077,7 @@ static int snd_compr_task_create(struct snd_compr_stream *stream, unsigned long
return -EPERM;
task = memdup_user((void __user *)arg, sizeof(*task));
if (IS_ERR(task))
return PTR_ERR(no_free_ptr(task));
return PTR_ERR(task);
retval = snd_compr_task_new(stream, task);
if (retval >= 0)
if (copy_to_user((void __user *)arg, task, sizeof(*task)))
Expand Down Expand Up @@ -1130,7 +1138,7 @@ static int snd_compr_task_start_ioctl(struct snd_compr_stream *stream, unsigned
return -EPERM;
task = memdup_user((void __user *)arg, sizeof(*task));
if (IS_ERR(task))
return PTR_ERR(no_free_ptr(task));
return PTR_ERR(task);
retval = snd_compr_task_start(stream, task);
if (retval >= 0)
if (copy_to_user((void __user *)arg, task, sizeof(*task)))
Expand Down Expand Up @@ -1174,18 +1182,18 @@ typedef void (*snd_compr_seq_func_t)(struct snd_compr_stream *stream,
static int snd_compr_task_seq(struct snd_compr_stream *stream, unsigned long arg,
snd_compr_seq_func_t fcn)
{
struct snd_compr_task_runtime *task;
struct snd_compr_task_runtime *task, *temp;
__u64 seqno;
int retval;

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)
list_for_each_entry_safe_reverse(task, temp, &stream->runtime->tasks, list)
fcn(stream, task);
} else {
task = snd_compr_find_task(stream, seqno);
Expand Down Expand Up @@ -1221,7 +1229,7 @@ static int snd_compr_task_status_ioctl(struct snd_compr_stream *stream, unsigned
return -EPERM;
status = memdup_user((void __user *)arg, sizeof(*status));
if (IS_ERR(status))
return PTR_ERR(no_free_ptr(status));
return PTR_ERR(status);
retval = snd_compr_task_status(stream, status);
if (retval >= 0)
if (copy_to_user((void __user *)arg, status, sizeof(*status)))
Expand All @@ -1247,6 +1255,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)
Expand Down
2 changes: 1 addition & 1 deletion sound/core/memalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ static void *snd_dma_wc_alloc(struct snd_dma_buffer *dmab, size_t size)
if (!p)
return NULL;
dmab->addr = dma_map_single(dmab->dev.dev, p, size, DMA_BIDIRECTIONAL);
if (dmab->addr == DMA_MAPPING_ERROR) {
if (dma_mapping_error(dmab->dev.dev, dmab->addr)) {
do_free_pages(dmab->area, size, true);
return NULL;
}
Expand Down
41 changes: 26 additions & 15 deletions sound/core/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,43 @@ int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size

if (import_ubuf(ITER_DEST, dst, count, &iter))
return -EFAULT;
return copy_to_iter_fromio(&iter, (const void __iomem *)src, count);
if (copy_to_iter_fromio((const void __iomem *)src, count, &iter) != count)
return -EFAULT;
return 0;
}
EXPORT_SYMBOL(copy_to_user_fromio);

/**
* copy_to_iter_fromio - copy data from mmio-space to iov_iter
* @dst: the destination iov_iter
* @src: the source pointer on mmio
* @count: the data size to copy in bytes
* @dst: the destination iov_iter
*
* Copies the data from mmio-space to iov_iter.
*
* Return: Zero if successful, or non-zero on failure.
* Return: number of bytes to be copied
*/
int copy_to_iter_fromio(struct iov_iter *dst, const void __iomem *src,
size_t count)
size_t copy_to_iter_fromio(const void __iomem *src, size_t count,
struct iov_iter *dst)
{
#if defined(__i386__) || defined(CONFIG_SPARC32)
return copy_to_iter((const void __force *)src, count, dst) == count ? 0 : -EFAULT;
return copy_to_iter((const void __force *)src, count, dst);
#else
char buf[256];
size_t res = 0;

while (count) {
size_t c = count;
if (c > sizeof(buf))
c = sizeof(buf);
memcpy_fromio(buf, (void __iomem *)src, c);
if (copy_to_iter(buf, c, dst) != c)
return -EFAULT;
return res;
count -= c;
src += c;
res += c;
}
return 0;
return res;
#endif
}
EXPORT_SYMBOL(copy_to_iter_fromio);
Expand All @@ -79,37 +84,43 @@ int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size

if (import_ubuf(ITER_SOURCE, (void __user *)src, count, &iter))
return -EFAULT;
return copy_from_iter_toio((void __iomem *)dst, &iter, count);
if (copy_from_iter_toio((void __iomem *)dst, count, &iter) != count)
return -EFAULT;
return 0;
}
EXPORT_SYMBOL(copy_from_user_toio);

/**
* copy_from_iter_toio - copy data from iov_iter to mmio-space
* @dst: the destination pointer on mmio-space
* @src: the source iov_iter
* @count: the data size to copy in bytes
* @src: the source iov_iter
*
* Copies the data from iov_iter to mmio-space.
*
* Return: Zero if successful, or non-zero on failure.
* Return: number of bytes to be copied
*/
int copy_from_iter_toio(void __iomem *dst, struct iov_iter *src, size_t count)
size_t copy_from_iter_toio(void __iomem *dst, size_t count,
struct iov_iter *src)
{
#if defined(__i386__) || defined(CONFIG_SPARC32)
return copy_from_iter((void __force *)dst, count, src) == count ? 0 : -EFAULT;
return copy_from_iter((void __force *)dst, count, src);
#else
char buf[256];
size_t res = 0;

while (count) {
size_t c = count;
if (c > sizeof(buf))
c = sizeof(buf);
if (copy_from_iter(buf, c, src) != c)
return -EFAULT;
return res;
memcpy_toio(dst, buf, c);
count -= c;
dst += c;
res += c;
}
return 0;
return res;
#endif
}
EXPORT_SYMBOL(copy_from_iter_toio);
4 changes: 2 additions & 2 deletions sound/core/seq/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ config SND_SEQ_VIRMIDI

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

config SND_SEQ_UMP_CLIENT
def_tristate SND_UMP
def_tristate SND_UMP && SND_SEQ_UMP

endif # SND_SEQUENCER
1 change: 0 additions & 1 deletion sound/core/seq/oss/seq_oss_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ struct seq_oss_chinfo {
struct seq_oss_synthinfo {
struct snd_seq_oss_arg arg;
struct seq_oss_chinfo *ch;
struct seq_oss_synth_sysex *sysex;
int nr_voices;
int opened;
int is_midi;
Expand Down
Loading

0 comments on commit e774004

Please sign in to comment.