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: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20221202152841.672536-9-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Cezary Rojewski 2022-12-02 16:28:33 +01:00 коммит произвёл Mark Brown
Родитель b3eefa5d8d
Коммит f7de161fc8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 24D68B725D5487D0
5 изменённых файлов: 26 добавлений и 42 удалений

Просмотреть файл

@ -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)); 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 */ /* consume the logs regardless of consumer presence */
goto update_read_ptr; goto update_read_ptr;
buf = apl_log_payload_addr(addr); buf = apl_log_payload_addr(addr);
if (layout.read_ptr > layout.write_ptr) { 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); apl_log_payload_size(adev) - layout.read_ptr);
layout.read_ptr = 0; layout.read_ptr = 0;
} }
__kfifo_fromio(&adev->dbg.trace_fifo, buf + layout.read_ptr, avs_dump_fw_log_wakeup(adev, buf + layout.read_ptr, layout.write_ptr - layout.read_ptr);
layout.write_ptr - layout.read_ptr);
wake_up(&adev->dbg.trace_waitq);
update_read_ptr: update_read_ptr:
writel(layout.write_ptr, addr); writel(layout.write_ptr, addr);

Просмотреть файл

@ -94,15 +94,6 @@ struct avs_fw_entry {
struct list_head node; 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 * struct avs_dev - Intel HD-Audio driver data
* *
@ -146,7 +137,6 @@ struct avs_dev {
spinlock_t path_list_lock; spinlock_t path_list_lock;
struct mutex path_mutex; struct mutex path_mutex;
struct avs_debug dbg;
spinlock_t trace_lock; /* serialize debug window I/O between each LOG_BUFFER_STATUS */ spinlock_t trace_lock; /* serialize debug window I/O between each LOG_BUFFER_STATUS */
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
struct kfifo trace_fifo; struct kfifo trace_fifo;
@ -339,8 +329,6 @@ void avs_unregister_all_boards(struct avs_dev *adev);
/* Firmware tracing helpers */ /* Firmware tracing helpers */
unsigned int __kfifo_fromio(struct kfifo *fifo, const void __iomem *src, unsigned int len);
#define avs_log_buffer_size(adev) \ #define avs_log_buffer_size(adev) \
((adev)->fw_cfg.trace_log_bytes / (adev)->hw_cfg.dsp_cores) ((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; unsigned long flags;
int ret; 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); 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; return ret;
} }

Просмотреть файл

@ -11,6 +11,24 @@
#include <linux/wait.h> #include <linux/wait.h>
#include "avs.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) bool avs_logging_fw(struct avs_dev *adev)
{ {
return kfifo_initialized(&adev->trace_fifo); 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; void __iomem *buf;
u16 size, write, offset; u16 size, write, offset;
if (!kfifo_initialized(&adev->dbg.trace_fifo)) if (!avs_logging_fw(adev))
return 0; return 0;
size = avs_log_buffer_size(adev) / 2; 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. */ /* Address is guaranteed to exist in SRAM2. */
buf = avs_log_buffer_addr(adev, msg->log.core) + offset; buf = avs_log_buffer_addr(adev, msg->log.core) + offset;
__kfifo_fromio(&adev->dbg.trace_fifo, buf, size); avs_dump_fw_log_wakeup(adev, buf, size);
wake_up(&adev->dbg.trace_waitq);
return 0; return 0;
} }

Просмотреть файл

@ -300,21 +300,3 @@ void avs_release_firmwares(struct avs_dev *adev)
kfree(entry); 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;
}