Skip to content

Commit 9e3c15b

Browse files
crojewsk-intelbroonie
authored andcommitted
ASoC: Intel: avs: Introduce debug-context aware helpers
Debug-related fields and log-dumping are useful when debugfs is enabled. Define them under CONFIG_DEBUG_FS and provide stubs when the config is disabled so that the code that makes use of these needs not to be complicated unnecessarily. Members that are duplicated by this patch will be removed by the follow up changes. Signed-off-by: Cezary Rojewski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 58029b7 commit 9e3c15b

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

sound/soc/intel/avs/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ snd-soc-avs-objs += trace.o
99
# tell define_trace.h where to find the trace header
1010
CFLAGS_trace.o := -I$(src)
1111

12+
ifneq ($(CONFIG_DEBUG_FS),)
13+
snd-soc-avs-objs += debugfs.o
14+
endif
15+
1216
obj-$(CONFIG_SND_SOC_INTEL_AVS) += snd-soc-avs.o
1317

1418
# Machine support

sound/soc/intel/avs/avs.h

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

12+
#include <linux/debugfs.h>
1213
#include <linux/device.h>
1314
#include <linux/firmware.h>
1415
#include <linux/kfifo.h>
@@ -146,6 +147,14 @@ struct avs_dev {
146147
struct mutex path_mutex;
147148

148149
struct avs_debug dbg;
150+
spinlock_t trace_lock; /* serialize debug window I/O between each LOG_BUFFER_STATUS */
151+
#ifdef CONFIG_DEBUG_FS
152+
struct kfifo trace_fifo;
153+
wait_queue_head_t trace_waitq;
154+
u32 aging_timer_period;
155+
u32 fifo_full_timer_period;
156+
u32 logged_resources; /* context dependent: core or library */
157+
#endif
149158
};
150159

151160
/* from hda_bus to avs_dev */
@@ -366,4 +375,24 @@ struct apl_log_buffer_layout {
366375
#define apl_log_payload_addr(addr) \
367376
(addr + sizeof(struct apl_log_buffer_layout))
368377

378+
#ifdef CONFIG_DEBUG_FS
379+
bool avs_logging_fw(struct avs_dev *adev);
380+
void avs_dump_fw_log(struct avs_dev *adev, const void __iomem *src, unsigned int len);
381+
void avs_dump_fw_log_wakeup(struct avs_dev *adev, const void __iomem *src, unsigned int len);
382+
#else
383+
static inline bool avs_logging_fw(struct avs_dev *adev)
384+
{
385+
return false;
386+
}
387+
388+
static inline void avs_dump_fw_log(struct avs_dev *adev, const void __iomem *src, unsigned int len)
389+
{
390+
}
391+
392+
static inline void
393+
avs_dump_fw_log_wakeup(struct avs_dev *adev, const void __iomem *src, unsigned int len)
394+
{
395+
}
396+
#endif
397+
369398
#endif /* __SOUND_SOC_INTEL_AVS_H */

sound/soc/intel/avs/debugfs.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
//
3+
// Copyright(c) 2021-2022 Intel Corporation. All rights reserved.
4+
//
5+
// Authors: Cezary Rojewski <[email protected]>
6+
// Amadeusz Slawinski <[email protected]>
7+
//
8+
9+
#include <linux/debugfs.h>
10+
#include <linux/kfifo.h>
11+
#include <linux/wait.h>
12+
#include "avs.h"
13+
14+
bool avs_logging_fw(struct avs_dev *adev)
15+
{
16+
return kfifo_initialized(&adev->trace_fifo);
17+
}
18+
19+
void avs_dump_fw_log(struct avs_dev *adev, const void __iomem *src, unsigned int len)
20+
{
21+
__kfifo_fromio(&adev->trace_fifo, src, len);
22+
}
23+
24+
void avs_dump_fw_log_wakeup(struct avs_dev *adev, const void __iomem *src, unsigned int len)
25+
{
26+
avs_dump_fw_log(adev, src, len);
27+
wake_up(&adev->trace_waitq);
28+
}

0 commit comments

Comments
 (0)