Commit f7de161f authored by Cezary Rojewski's avatar Cezary Rojewski Committed by Mark Brown

ASoC: Intel: avs: Drop usage of debug members in non-debug code

Switch to debug-context aware wrappers instead of accessing debug
members directly allowing for readable separation of debug and non-debug
related code. Duplicates are removed along the way.
Signed-off-by: default avatarCezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20221202152841.672536-9-cezary.rojewski@intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent b3eefa5d
......@@ -59,21 +59,18 @@ static int apl_log_buffer_status(struct avs_dev *adev, union avs_notify_msg *msg
memcpy_fromio(&layout, addr, sizeof(layout));
if (!kfifo_initialized(&adev->dbg.trace_fifo))
if (!avs_logging_fw(adev))
/* consume the logs regardless of consumer presence */
goto update_read_ptr;
buf = apl_log_payload_addr(addr);
if (layout.read_ptr > layout.write_ptr) {
__kfifo_fromio(&adev->dbg.trace_fifo, buf + layout.read_ptr,
avs_dump_fw_log(adev, buf + layout.read_ptr,
apl_log_payload_size(adev) - layout.read_ptr);
layout.read_ptr = 0;
}
__kfifo_fromio(&adev->dbg.trace_fifo, buf + layout.read_ptr,
layout.write_ptr - layout.read_ptr);
wake_up(&adev->dbg.trace_waitq);
avs_dump_fw_log_wakeup(adev, buf + layout.read_ptr, layout.write_ptr - layout.read_ptr);
update_read_ptr:
writel(layout.write_ptr, addr);
......
......@@ -94,15 +94,6 @@ struct avs_fw_entry {
struct list_head node;
};
struct avs_debug {
struct kfifo trace_fifo;
spinlock_t trace_lock; /* serialize debug window I/O between each LOG_BUFFER_STATUS */
wait_queue_head_t trace_waitq;
u32 aging_timer_period;
u32 fifo_full_timer_period;
u32 logged_resources; /* context dependent: core or library */
};
/*
* struct avs_dev - Intel HD-Audio driver data
*
......@@ -146,7 +137,6 @@ struct avs_dev {
spinlock_t path_list_lock;
struct mutex path_mutex;
struct avs_debug dbg;
spinlock_t trace_lock; /* serialize debug window I/O between each LOG_BUFFER_STATUS */
#ifdef CONFIG_DEBUG_FS
struct kfifo trace_fifo;
......@@ -339,8 +329,6 @@ void avs_unregister_all_boards(struct avs_dev *adev);
/* Firmware tracing helpers */
unsigned int __kfifo_fromio(struct kfifo *fifo, const void __iomem *src, unsigned int len);
#define avs_log_buffer_size(adev) \
((adev)->fw_cfg.trace_log_bytes / (adev)->hw_cfg.dsp_cores)
......@@ -356,9 +344,9 @@ static inline int avs_log_buffer_status_locked(struct avs_dev *adev, union avs_n
unsigned long flags;
int ret;
spin_lock_irqsave(&adev->dbg.trace_lock, flags);
spin_lock_irqsave(&adev->trace_lock, flags);
ret = avs_dsp_op(adev, log_buffer_status, msg);
spin_unlock_irqrestore(&adev->dbg.trace_lock, flags);
spin_unlock_irqrestore(&adev->trace_lock, flags);
return ret;
}
......
......@@ -11,6 +11,24 @@
#include <linux/wait.h>
#include "avs.h"
static unsigned int __kfifo_fromio(struct kfifo *fifo, const void __iomem *src, unsigned int len)
{
struct __kfifo *__fifo = &fifo->kfifo;
unsigned int l, off;
len = min(len, kfifo_avail(fifo));
off = __fifo->in & __fifo->mask;
l = min(len, kfifo_size(fifo) - off);
memcpy_fromio(__fifo->data + off, src, l);
memcpy_fromio(__fifo->data, src + l, len - l);
/* Make sure data copied from SRAM is visible to all CPUs. */
smp_mb();
__fifo->in += len;
return len;
}
bool avs_logging_fw(struct avs_dev *adev)
{
return kfifo_initialized(&adev->trace_fifo);
......
......@@ -59,7 +59,7 @@ skl_log_buffer_status(struct avs_dev *adev, union avs_notify_msg *msg)
void __iomem *buf;
u16 size, write, offset;
if (!kfifo_initialized(&adev->dbg.trace_fifo))
if (!avs_logging_fw(adev))
return 0;
size = avs_log_buffer_size(adev) / 2;
......@@ -69,8 +69,7 @@ skl_log_buffer_status(struct avs_dev *adev, union avs_notify_msg *msg)
/* Address is guaranteed to exist in SRAM2. */
buf = avs_log_buffer_addr(adev, msg->log.core) + offset;
__kfifo_fromio(&adev->dbg.trace_fifo, buf, size);
wake_up(&adev->dbg.trace_waitq);
avs_dump_fw_log_wakeup(adev, buf, size);
return 0;
}
......
......@@ -300,21 +300,3 @@ void avs_release_firmwares(struct avs_dev *adev)
kfree(entry);
}
}
unsigned int __kfifo_fromio(struct kfifo *fifo, const void __iomem *src, unsigned int len)
{
struct __kfifo *__fifo = &fifo->kfifo;
unsigned int l, off;
len = min(len, kfifo_avail(fifo));
off = __fifo->in & __fifo->mask;
l = min(len, kfifo_size(fifo) - off);
memcpy_fromio(__fifo->data + off, src, l);
memcpy_fromio(__fifo->data, src + l, len - l);
/* Make sure data copied from SRAM is visible to all CPUs. */
smp_mb();
__fifo->in += len;
return len;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment