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

ASoC: Intel: avs: Introduce avs_log_buffer_status_locked()

Simplify locking of firmware log gathering by providing single location
for such purpose.
Signed-off-by: default avatarCezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20221202152841.672536-5-cezary.rojewski@intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 3e958226
...@@ -50,7 +50,6 @@ static int apl_enable_logs(struct avs_dev *adev, enum avs_log_enable enable, u32 ...@@ -50,7 +50,6 @@ static int apl_enable_logs(struct avs_dev *adev, enum avs_log_enable enable, u32
static int apl_log_buffer_status(struct avs_dev *adev, union avs_notify_msg *msg) static int apl_log_buffer_status(struct avs_dev *adev, union avs_notify_msg *msg)
{ {
struct apl_log_buffer_layout layout; struct apl_log_buffer_layout layout;
unsigned long flags;
void __iomem *addr, *buf; void __iomem *addr, *buf;
addr = avs_log_buffer_addr(adev, msg->log.core); addr = avs_log_buffer_addr(adev, msg->log.core);
...@@ -59,7 +58,6 @@ static int apl_log_buffer_status(struct avs_dev *adev, union avs_notify_msg *msg ...@@ -59,7 +58,6 @@ 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));
spin_lock_irqsave(&adev->dbg.trace_lock, flags);
if (!kfifo_initialized(&adev->dbg.trace_fifo)) if (!kfifo_initialized(&adev->dbg.trace_fifo))
/* consume the logs regardless of consumer presence */ /* consume the logs regardless of consumer presence */
goto update_read_ptr; goto update_read_ptr;
...@@ -78,7 +76,6 @@ static int apl_log_buffer_status(struct avs_dev *adev, union avs_notify_msg *msg ...@@ -78,7 +76,6 @@ static int apl_log_buffer_status(struct avs_dev *adev, union avs_notify_msg *msg
wake_up(&adev->dbg.trace_waitq); wake_up(&adev->dbg.trace_waitq);
update_read_ptr: update_read_ptr:
spin_unlock_irqrestore(&adev->dbg.trace_lock, flags);
writel(layout.write_ptr, addr); writel(layout.write_ptr, addr);
return 0; return 0;
} }
...@@ -140,7 +137,7 @@ static int apl_coredump(struct avs_dev *adev, union avs_notify_msg *msg) ...@@ -140,7 +137,7 @@ static int apl_coredump(struct avs_dev *adev, union avs_notify_msg *msg)
* gathered before dumping stack * gathered before dumping stack
*/ */
lbs_msg.log.core = msg->ext.coredump.core_id; lbs_msg.log.core = msg->ext.coredump.core_id;
avs_dsp_op(adev, log_buffer_status, &lbs_msg); avs_log_buffer_status_locked(adev, &lbs_msg);
} }
pos = dump + AVS_FW_REGS_SIZE; pos = dump + AVS_FW_REGS_SIZE;
......
...@@ -344,6 +344,18 @@ unsigned int __kfifo_fromio_locked(struct kfifo *fifo, const void __iomem *src, ...@@ -344,6 +344,18 @@ unsigned int __kfifo_fromio_locked(struct kfifo *fifo, const void __iomem *src,
(avs_sram_addr(adev, AVS_DEBUG_WINDOW) + __offset); \ (avs_sram_addr(adev, AVS_DEBUG_WINDOW) + __offset); \
}) })
static inline int avs_log_buffer_status_locked(struct avs_dev *adev, union avs_notify_msg *msg)
{
unsigned long flags;
int ret;
spin_lock_irqsave(&adev->dbg.trace_lock, flags);
ret = avs_dsp_op(adev, log_buffer_status, msg);
spin_unlock_irqrestore(&adev->dbg.trace_lock, flags);
return ret;
}
struct apl_log_buffer_layout { struct apl_log_buffer_layout {
u32 read_ptr; u32 read_ptr;
u32 write_ptr; u32 write_ptr;
......
...@@ -266,7 +266,7 @@ static void avs_dsp_process_notification(struct avs_dev *adev, u64 header) ...@@ -266,7 +266,7 @@ static void avs_dsp_process_notification(struct avs_dev *adev, u64 header)
break; break;
case AVS_NOTIFY_LOG_BUFFER_STATUS: case AVS_NOTIFY_LOG_BUFFER_STATUS:
avs_dsp_op(adev, log_buffer_status, &msg); avs_log_buffer_status_locked(adev, &msg);
break; break;
case AVS_NOTIFY_EXCEPTION_CAUGHT: case AVS_NOTIFY_EXCEPTION_CAUGHT:
......
...@@ -55,15 +55,11 @@ int skl_log_buffer_offset(struct avs_dev *adev, u32 core) ...@@ -55,15 +55,11 @@ int skl_log_buffer_offset(struct avs_dev *adev, u32 core)
static int static int
skl_log_buffer_status(struct avs_dev *adev, union avs_notify_msg *msg) skl_log_buffer_status(struct avs_dev *adev, union avs_notify_msg *msg)
{ {
unsigned long flags;
void __iomem *buf; void __iomem *buf;
u16 size, write, offset; u16 size, write, offset;
spin_lock_irqsave(&adev->dbg.trace_lock, flags); if (!kfifo_initialized(&adev->dbg.trace_fifo))
if (!kfifo_initialized(&adev->dbg.trace_fifo)) {
spin_unlock_irqrestore(&adev->dbg.trace_lock, flags);
return 0; return 0;
}
size = avs_log_buffer_size(adev) / 2; size = avs_log_buffer_size(adev) / 2;
write = readl(avs_sram_addr(adev, AVS_FW_REGS_WINDOW) + FW_REGS_DBG_LOG_WP(msg->log.core)); write = readl(avs_sram_addr(adev, AVS_FW_REGS_WINDOW) + FW_REGS_DBG_LOG_WP(msg->log.core));
...@@ -74,7 +70,6 @@ skl_log_buffer_status(struct avs_dev *adev, union avs_notify_msg *msg) ...@@ -74,7 +70,6 @@ skl_log_buffer_status(struct avs_dev *adev, union avs_notify_msg *msg)
buf = avs_log_buffer_addr(adev, msg->log.core) + offset; buf = avs_log_buffer_addr(adev, msg->log.core) + offset;
__kfifo_fromio_locked(&adev->dbg.trace_fifo, buf, size, &adev->dbg.fifo_lock); __kfifo_fromio_locked(&adev->dbg.trace_fifo, buf, size, &adev->dbg.fifo_lock);
wake_up(&adev->dbg.trace_waitq); wake_up(&adev->dbg.trace_waitq);
spin_unlock_irqrestore(&adev->dbg.trace_lock, flags);
return 0; return 0;
} }
......
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