ASoC: Intel: avs: Data probing and fw logging
Subsystems (3)
Cezary Rojewski
maintainerv2 cover ASoC: Intel: avs: Data probing and fw logging
The patchset focuses on debug functionality for the avs-driver. Two major blocks are covered here: data probing and AudioDSP firmware logging. Both are configured and controlled through debugfs.
Data probing is a AudioDSP debug functionality which allows for gathering the actual data that is being routed to or from a module. Helps in debugging its processing capabilities - navigate to a specific module which may have caused a glitch within a pipeline (set of modules bound together).
First few allow for assigning compress stream to a HDAudio stream, what is currently limited to pcm substreams only. These patches were already present on this list and reviewed in the past [1].
The next few tidy existing debug-related code up so it's ready for addition of new functionalities and make it clear which part of the avs is debug related and which is not. These also simplify the existing locking around the trace fifo.
Afterward, debug-related IPCs are defined along with stub soc-component and compress DAI operations. Not much is done there as it's not a standard PCM streaming scenario. Most code found in compress operations is inherited from the HOST side of HDAudio streaming found in pcm.c file of the driver.
Finally, a debugfs file operations are defined. These facilitate connecting to DSP modules from which the data shall be gathered as well as control and configuration of firmware logging. Additionally, entries are added to allow for dumping snapshots of key memory windows.
Changes in v2:
- reordered sign offs in patch 03 as reported by Takashi
- fixed issue reported by ikp - unintilialized 'runtime' variable in patch 03
- added missing module_get_upon_open in component driver declaration
[1]: https://lore.kernel.org/alsa-devel/[email protected]/
Cezary Rojewski (16):
ALSA: hda: Allow for compress stream to hdac_ext_stream assignment
ALSA: hda: Prepare for compress stream support
ALSA: hda: Interrupt servicing and BDL setup for compress streams
ASoC: Intel: avs: Introduce avs_log_buffer_status_locked()
ASoC: Intel: avs: Drop fifo_lock
ASoC: Intel: avs: Introduce debug-context aware helpers
ASoC: Intel: avs: Make enable_logs() dependent on DEBUG_FS
ASoC: Intel: avs: Drop usage of debug members in non-debug code
ASoC: Intel: avs: Add data probing requests
ASoC: Intel: avs: Probe compress operations
ASoC: Intel: avs: Data probing soc-component
ASoC: Intel: avs: Add probe machine board
ASoC: Intel: avs: Probing and firmware tracing over debugfs
ASoC: Intel: avs: Gather remaining logs on strace_release()
ASoC: Intel: avs: Allow for dumping FW_REGS area
ASoC: Intel: avs: Allow for dumping debug window snapshot
include/sound/hdaudio_ext.h | 2 + sound/hda/ext/hdac_ext_stream.c | 41 +++ sound/hda/hdac_controller.c | 4 +- sound/hda/hdac_stream.c | 51 +-- sound/soc/intel/Kconfig | 1 + sound/soc/intel/avs/Makefile | 4 + sound/soc/intel/avs/apl.c | 24 +- sound/soc/intel/avs/avs.h | 80 ++++- sound/soc/intel/avs/board_selection.c | 33 ++ sound/soc/intel/avs/boards/Kconfig | 8 + sound/soc/intel/avs/boards/Makefile | 2 + sound/soc/intel/avs/boards/probe.c | 64 ++++ sound/soc/intel/avs/core.c | 2 + sound/soc/intel/avs/debugfs.c | 436 ++++++++++++++++++++++++++ sound/soc/intel/avs/ipc.c | 2 +- sound/soc/intel/avs/messages.c | 104 +++++- sound/soc/intel/avs/messages.h | 53 ++++ sound/soc/intel/avs/pcm.c | 6 +- sound/soc/intel/avs/probes.c | 313 ++++++++++++++++++ sound/soc/intel/avs/registers.h | 3 +- sound/soc/intel/avs/skl.c | 17 +- sound/soc/intel/avs/utils.c | 22 -- 22 files changed, 1172 insertions(+), 100 deletions(-) create mode 100644 sound/soc/intel/avs/boards/probe.c create mode 100644 sound/soc/intel/avs/debugfs.c create mode 100644 sound/soc/intel/avs/probes.c
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v2 1/16 ALSA: hda: Allow for compress stream to hdac_ext_stream assignment
Currently only PCM streams can enlist hdac_stream for their data transfer. Add cstream field to hdac_ext_stream to expose possibility of compress stream assignment in place of PCM one.
Limited to HOST-type only as there no other users on the horizon.
--- include/sound/hdaudio_ext.h | 2 ++ sound/hda/ext/hdac_ext_stream.c | 41 +++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+)
include/sound/hdaudio_ext.h +2 -0
@@ -75,6 +75,8 @@ struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_bus *bus,struct snd_pcm_substream *substream, int type);void snd_hdac_ext_stream_release (struct hdac_ext_stream *hext_stream,int type); +struct hdac_ext_stream *snd_hdac_ext_cstream_assign (struct hdac_bus *bus, +struct snd_compr_stream *cstream);void snd_hdac_ext_stream_decouple_locked (struct hdac_bus *bus,struct hdac_ext_stream *hext_stream,bool decouple); void snd_hdac_ext_stream_decouple(struct hdac_bus *bus,
sound/hda/ext/hdac_ext_stream.c +41 -0
50 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v2 2/16 ALSA: hda: Prepare for compress stream support
In reply to Cezary RojewskiBefore introducing compress specific changes, adjust BDL and parameters setup functions so these are not tightly coupled with PCM streams.
--- sound/hda/hdac_stream.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
sound/hda/hdac_stream.c +16 -16
@@ -487,11 +487,15 @@ int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev) {struct hdac_bus *bus = azx_dev->bus;struct snd_pcm_substream *substream = azx_dev->substream; -struct snd_pcm_runtime *runtime = substream->runtime; +struct snd_pcm_runtime *runtime; +struct snd_dma_buffer *dmab;__le32 *bdl;int i, ofs, periods, period_bytes;int pos_adj, pos_align; + runtime = substream->runtime; + dmab =snd_pcm_get_dma_buf (substream); +/* reset BDL address */ snd_hdac_stream_writel (azx_dev,SD_BDLPL ,0 );snd_hdac_stream_writel (azx_dev,SD_BDLPU ,0 );
@@ -505,7 +509,7 @@ int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev) azx_dev->frags =0 ; pos_adj = bus->bdl_pos_adj; -if (!azx_dev->no_period_wakeup && pos_adj >0 ) { +if (runtime && !azx_dev->no_period_wakeup && pos_adj >0 ) { pos_align = pos_adj; pos_adj =DIV_ROUND_UP (pos_adj * runtime->rate,48000 );if (!pos_adj)
@@ -518,8 +522,7 @@ int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev) pos_adj); pos_adj =0 ; }else { - ofs =setup_bdle (bus,snd_pcm_get_dma_buf (substream), - azx_dev, + ofs =setup_bdle (bus, dmab, azx_dev, &bdl, ofs, pos_adj, true);if (ofs <0 ) goto error;
@@ -529,13 +532,11 @@ int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev)for (i =0 ; i < periods; i++) {if (i == periods -1 && pos_adj) - ofs =setup_bdle (bus,snd_pcm_get_dma_buf (substream), - azx_dev, &bdl, ofs, - period_bytes - pos_adj,0 ); + ofs =setup_bdle (bus, dmab, azx_dev, + &bdl, ofs, period_bytes - pos_adj,0 );else - ofs =setup_bdle (bus,snd_pcm_get_dma_buf (substream), - azx_dev, &bdl, ofs, - period_bytes, + ofs =setup_bdle (bus, dmab, azx_dev, + &bdl, ofs, period_bytes, !azx_dev->no_period_wakeup);if (ofs <0 ) goto error;
@@ -560,26 +561,25 @@ EXPORT_SYMBOL_GPL(snd_hdac_stream_setup_periods);int snd_hdac_stream_set_params (struct hdac_stream *azx_dev,unsigned int format_val) { - -unsigned int bufsize, period_bytes;struct snd_pcm_substream *substream = azx_dev->substream; -struct snd_pcm_runtime *runtime; +unsigned int bufsize, period_bytes; +unsigned int no_period_wakeup;int err;if (!substream)return -EINVAL ; - runtime = substream->runtime; bufsize =snd_pcm_lib_buffer_bytes (substream); period_bytes =snd_pcm_lib_period_bytes (substream); + no_period_wakeup = substream->runtime->no_period_wakeup;if (bufsize != azx_dev->bufsize || period_bytes != azx_dev->period_bytes || format_val != azx_dev->format_val || - runtime->no_period_wakeup != azx_dev->no_period_wakeup) { + no_period_wakeup != azx_dev->no_period_wakeup) { azx_dev->bufsize = bufsize; azx_dev->period_bytes = period_bytes; azx_dev->format_val = format_val; - azx_dev->no_period_wakeup = runtime->no_period_wakeup; + azx_dev->no_period_wakeup = no_period_wakeup; err =snd_hdac_stream_setup_periods (azx_dev);if (err <0 )return err;
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v2 3/16 ALSA: hda: Interrupt servicing and BDL setup for compress streams
In reply to Cezary RojewskiAccount for compress streams when receiving and servicing buffer completed interrupts. In case of compress stream enlisting hdac_stream for data transfer, setup BDL entries much like it is the case for PCM streams.
--- sound/hda/hdac_controller.c | 4 ++-- sound/hda/hdac_stream.c | 27 ++++++++++++++++++++------- 2 files changed, 22 insertions(+), 9 deletions(-)
sound/hda/hdac_controller.c +2 -2
@@ -578,8 +578,8 @@ int snd_hdac_bus_handle_stream_irq(struct hdac_bus *bus, unsigned int status, sd_status =snd_hdac_stream_readb (azx_dev,SD_STS );snd_hdac_stream_writeb (azx_dev,SD_STS ,SD_INT_MASK ); handled |=1 << azx_dev->index; -if (!azx_dev->substream || !azx_dev->running || - !(sd_status &SD_INT_COMPLETE )) +if ((!azx_dev->substream && !azx_dev->cstream) || + !azx_dev->running || !(sd_status &SD_INT_COMPLETE ))continue ;if (ack)ack (bus, azx_dev);
sound/hda/hdac_stream.c +20 -7
@@ -7,6 +7,7 @@#include <linux/delay.h> #include <linux/export.h> #include <linux/clocksource.h> +#include <sound/compress_driver.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/hdaudio.h>
@@ -487,14 +488,19 @@ int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev) {struct hdac_bus *bus = azx_dev->bus;struct snd_pcm_substream *substream = azx_dev->substream; -struct snd_pcm_runtime *runtime; +struct snd_compr_stream *cstream = azx_dev->cstream; +struct snd_pcm_runtime *runtime =NULL ;struct snd_dma_buffer *dmab;__le32 *bdl;int i, ofs, periods, period_bytes;int pos_adj, pos_align; - runtime = substream->runtime; - dmab =snd_pcm_get_dma_buf (substream); +if (substream) { + runtime = substream->runtime; + dmab =snd_pcm_get_dma_buf (substream); + }else if (cstream) { + dmab =snd_pcm_get_dma_buf (cstream); + }/* reset BDL address */ snd_hdac_stream_writel (azx_dev,SD_BDLPL ,0 );
@@ -562,15 +568,22 @@ int snd_hdac_stream_set_params(struct hdac_stream *azx_dev, unsigned int format_val) {struct snd_pcm_substream *substream = azx_dev->substream; +struct snd_compr_stream *cstream = azx_dev->cstream;unsigned int bufsize, period_bytes;unsigned int no_period_wakeup;int err; -if (!substream) +if (substream) { + bufsize =snd_pcm_lib_buffer_bytes (substream); + period_bytes =snd_pcm_lib_period_bytes (substream); + no_period_wakeup = substream->runtime->no_period_wakeup; + }else if (cstream) { + bufsize = cstream->runtime->buffer_size; + period_bytes = cstream->runtime->fragment_size; + no_period_wakeup =0 ; + }else {return -EINVAL ; - bufsize =snd_pcm_lib_buffer_bytes (substream); - period_bytes =snd_pcm_lib_period_bytes (substream); - no_period_wakeup = substream->runtime->no_period_wakeup; + } if (bufsize != azx_dev->bufsize || period_bytes != azx_dev->period_bytes ||
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v2 4/16 ASoC: Intel: avs: Introduce avs_log_buffer_status_locked()
In reply to Cezary RojewskiSimplify locking of firmware log gathering by providing single location for such purpose.
--- sound/soc/intel/avs/apl.c | 5 +---- sound/soc/intel/avs/avs.h | 12 ++++++++++++ sound/soc/intel/avs/ipc.c | 2 +- sound/soc/intel/avs/skl.c | 7 +------ 4 files changed, 15 insertions(+), 11 deletions(-)
sound/soc/intel/avs/apl.c +1 -4
@@ -50,7 +50,6 @@ static int apl_enable_logs(struct avs_dev *adev, enum avs_log_enable enable, u32static int apl_log_buffer_status (struct avs_dev *adev,union avs_notify_msg *msg) {struct apl_log_buffer_layout layout; -unsigned long flags;void __iomem *addr, *buf; 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 *msgmemcpy_fromio (&layout, addr,sizeof (layout)); -spin_lock_irqsave (&adev->dbg.trace_lock, flags);if (!kfifo_initialized (&adev->dbg.trace_fifo))/* consume the logs regardless of consumer presence */ goto update_read_ptr;
@@ -78,7 +76,6 @@ static int apl_log_buffer_status(struct avs_dev *adev, union avs_notify_msg *msgwake_up (&adev->dbg.trace_waitq); update_read_ptr: -spin_unlock_irqrestore (&adev->dbg.trace_lock, flags);writel (layout.write_ptr, addr);return 0 ; }
@@ -140,7 +137,7 @@ static int apl_coredump(struct avs_dev *adev, union avs_notify_msg *msg)* gathered before dumping stack */ 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 ;
sound/soc/intel/avs/avs.h +12 -0
@@ -344,6 +344,18 @@ unsigned int __kfifo_fromio_locked(struct kfifo *fifo, const void __iomem *src, (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 {u32 read_ptr;u32 write_ptr;
sound/soc/intel/avs/ipc.c +1 -1
@@ -266,7 +266,7 @@ static void avs_dsp_process_notification(struct avs_dev *adev, u64 header)break ;case AVS_NOTIFY_LOG_BUFFER_STATUS : -avs_dsp_op (adev, log_buffer_status, &msg); +avs_log_buffer_status_locked (adev, &msg);break ;case AVS_NOTIFY_EXCEPTION_CAUGHT :
sound/soc/intel/avs/skl.c +1 -6
@@ -55,15 +55,11 @@ int skl_log_buffer_offset(struct avs_dev *adev, u32 core)static int skl_log_buffer_status (struct avs_dev *adev,union avs_notify_msg *msg) { -unsigned long flags;void __iomem *buf;u16 size, write, offset; -spin_lock_irqsave (&adev->dbg.trace_lock, flags); -if (!kfifo_initialized (&adev->dbg.trace_fifo)) { -spin_unlock_irqrestore (&adev->dbg.trace_lock, flags); +if (!kfifo_initialized (&adev->dbg.trace_fifo))return 0 ; - } 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));
@@ -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;__kfifo_fromio_locked (&adev->dbg.trace_fifo, buf, size, &adev->dbg.fifo_lock);wake_up (&adev->dbg.trace_waitq); -spin_unlock_irqrestore (&adev->dbg.trace_lock, flags);return 0 ; }
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v2 5/16 ASoC: Intel: avs: Drop fifo_lock
In reply to Cezary RojewskiLog gathering is already locked, thanks to ->trace_lock.
--- sound/soc/intel/avs/apl.c | 9 ++++----- sound/soc/intel/avs/avs.h | 4 +--- sound/soc/intel/avs/skl.c | 2 +- sound/soc/intel/avs/utils.c | 6 +----- 4 files changed, 7 insertions(+), 14 deletions(-)
sound/soc/intel/avs/apl.c +4 -5
@@ -65,13 +65,12 @@ static int apl_log_buffer_status(struct avs_dev *adev, union avs_notify_msg *msg buf =apl_log_payload_addr (addr);if (layout.read_ptr > layout.write_ptr) { -__kfifo_fromio_locked (&adev->dbg.trace_fifo, buf + layout.read_ptr, -apl_log_payload_size (adev) - layout.read_ptr, - &adev->dbg.fifo_lock); +__kfifo_fromio (&adev->dbg.trace_fifo, buf + layout.read_ptr, +apl_log_payload_size (adev) - layout.read_ptr); layout.read_ptr =0 ; } -__kfifo_fromio_locked (&adev->dbg.trace_fifo, buf + layout.read_ptr, - layout.write_ptr - layout.read_ptr, &adev->dbg.fifo_lock); +__kfifo_fromio (&adev->dbg.trace_fifo, buf + layout.read_ptr, + layout.write_ptr - layout.read_ptr);wake_up (&adev->dbg.trace_waitq);
sound/soc/intel/avs/avs.h +1 -3
@@ -95,7 +95,6 @@ struct avs_fw_entry {struct avs_debug {struct kfifo trace_fifo; -spinlock_t fifo_lock;/* serialize I/O for 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;
@@ -331,8 +330,7 @@ void avs_unregister_all_boards(struct avs_dev *adev);/* Firmware tracing helpers */ -unsigned int __kfifo_fromio_locked (struct kfifo *fifo,const void __iomem *src,unsigned int len, -spinlock_t *lock); +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)
sound/soc/intel/avs/skl.c +1 -1
@@ -68,7 +68,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_locked (&adev->dbg.trace_fifo, buf, size, &adev->dbg.fifo_lock); +__kfifo_fromio (&adev->dbg.trace_fifo, buf, size);wake_up (&adev->dbg.trace_waitq);return 0 ;
sound/soc/intel/avs/utils.c +1 -5
@@ -301,14 +301,11 @@ void avs_release_firmwares(struct avs_dev *adev) } } -unsigned int __kfifo_fromio_locked (struct kfifo *fifo,const void __iomem *src,unsigned int len, -spinlock_t *lock) +unsigned int __kfifo_fromio (struct kfifo *fifo,const void __iomem *src,unsigned int len) {struct __kfifo *__fifo = &fifo->kfifo; -unsigned long flags;unsigned int l, off; -spin_lock_irqsave (lock, flags); len =min (len,kfifo_avail (fifo)); off = __fifo->in & __fifo->mask; l =min (len,kfifo_size (fifo) - off);
@@ -318,7 +315,6 @@ unsigned int __kfifo_fromio_locked(struct kfifo *fifo, const void __iomem *src,/* Make sure data copied from SRAM is visible to all CPUs. */ smp_mb (); __fifo->in += len; -spin_unlock_irqrestore (lock, flags);return len; }
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v2 6/16 ASoC: Intel: avs: Introduce debug-context aware helpers
In reply to Cezary RojewskiDebug-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.
--- sound/soc/intel/avs/Makefile | 4 ++++ sound/soc/intel/avs/avs.h | 29 +++++++++++++++++++++++++++++ sound/soc/intel/avs/debugfs.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 sound/soc/intel/avs/debugfs.c
sound/soc/intel/avs/Makefile +4 -0
@@ -9,6 +9,10 @@ snd-soc-avs-objs += trace.o # tell define_trace.h where to find the trace header CFLAGS_trace.o := -I$(src) +ifneq ($(CONFIG_DEBUG_FS),) +snd-soc-avs-objs += debugfs.o +endif + obj-$(CONFIG_SND_SOC_INTEL_AVS) += snd-soc-avs.o # Machine support
sound/soc/intel/avs/avs.h +29 -0
@@ -9,6 +9,7 @@#ifndef __SOUND_SOC_INTEL_AVS_H#define __SOUND_SOC_INTEL_AVS_H +#include <linux/debugfs.h> #include <linux/device.h> #include <linux/firmware.h> #include <linux/kfifo.h>
@@ -146,6 +147,14 @@ struct avs_dev {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; +wait_queue_head_t trace_waitq; +u32 aging_timer_period; +u32 fifo_full_timer_period; +u32 logged_resources;/* context dependent: core or library */ +#endif };/* from hda_bus to avs_dev */
@@ -366,4 +375,24 @@ struct apl_log_buffer_layout {#define apl_log_payload_addr (addr) \ (addr + sizeof(struct apl_log_buffer_layout)) +#ifdef CONFIG_DEBUG_FS +bool avs_logging_fw (struct avs_dev *adev); +void avs_dump_fw_log (struct avs_dev *adev,const void __iomem *src,unsigned int len); +void avs_dump_fw_log_wakeup (struct avs_dev *adev,const void __iomem *src,unsigned int len); +#else +static inline bool avs_logging_fw (struct avs_dev *adev) +{ +return false; +} + +static inline void avs_dump_fw_log (struct avs_dev *adev,const void __iomem *src,unsigned int len) +{ +} + +static inline void +avs_dump_fw_log_wakeup (struct avs_dev *adev,const void __iomem *src,unsigned int len) +{ +} +#endif +#endif /* __SOUND_SOC_INTEL_AVS_H */
sound/soc/intel/avs/debugfs.c new file +28 -0
@@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright(c) 2021-2022 Intel Corporation. All rights reserved. +// +// Authors: Cezary Rojewski <[email protected]> +// Amadeusz Slawinski <[email protected]> +// + +#include <linux/debugfs.h> +#include <linux/kfifo.h> +#include <linux/wait.h> +#include "avs.h" + +bool avs_logging_fw (struct avs_dev *adev) +{ +return kfifo_initialized (&adev->trace_fifo); +} + +void avs_dump_fw_log (struct avs_dev *adev,const void __iomem *src,unsigned int len) +{ +__kfifo_fromio (&adev->trace_fifo, src, len); +} + +void avs_dump_fw_log_wakeup (struct avs_dev *adev,const void __iomem *src,unsigned int len) +{ +avs_dump_fw_log (adev, src, len); +wake_up (&adev->trace_waitq); +}
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v2 7/16 ASoC: Intel: avs: Make enable_logs() dependent on DEBUG_FS
In reply to Cezary RojewskiWithout debug filesystem present, this code is redundant.
Operations: log_buffer_status and log_buffer_offset are left as is as EXCEPTION_CAUGHT and even unexpected LOG_BUFFER_STATUS notifications may occur without user ever touching debugfs.
--- sound/soc/intel/avs/apl.c | 7 ++++--- sound/soc/intel/avs/avs.h | 5 +++++ sound/soc/intel/avs/messages.c | 36 ++++++++++++++++++---------------- sound/soc/intel/avs/skl.c | 7 ++++--- 4 files changed, 32 insertions(+), 23 deletions(-)
sound/soc/intel/avs/apl.c +4 -3
@@ -13,8 +13,9 @@#include "path.h" #include "topology.h" -static int apl_enable_logs (struct avs_dev *adev,enum avs_log_enable enable,u32 aging_period, -u32 fifo_full_period,unsigned long resource_mask,u32 *priorities) +static int __maybe_unused +apl_enable_logs (struct avs_dev *adev,enum avs_log_enable enable,u32 aging_period, +u32 fifo_full_period,unsigned long resource_mask,u32 *priorities) {struct apl_log_state_info *info;u32 size, num_cores = adev->hw_cfg.dsp_cores;
@@ -239,10 +240,10 @@ const struct avs_dsp_ops apl_dsp_ops = { .load_basefw = avs_hda_load_basefw, .load_lib = avs_hda_load_library, .transfer_mods = avs_hda_transfer_modules, - .enable_logs = apl_enable_logs, .log_buffer_offset = skl_log_buffer_offset, .log_buffer_status = apl_log_buffer_status, .coredump = apl_coredump, .d0ix_toggle = apl_d0ix_toggle, .set_d0ix = apl_set_d0ix, + AVS_SET_ENABLE_LOGS_OP(apl) };
sound/soc/intel/avs/avs.h +5 -0
@@ -376,10 +376,15 @@ struct apl_log_buffer_layout { (addr + sizeof(struct apl_log_buffer_layout))#ifdef CONFIG_DEBUG_FS +#define AVS_SET_ENABLE_LOGS_OP (name) \ + .enable_logs = name##_enable_logs +bool avs_logging_fw (struct avs_dev *adev);void avs_dump_fw_log (struct avs_dev *adev,const void __iomem *src,unsigned int len);void avs_dump_fw_log_wakeup (struct avs_dev *adev,const void __iomem *src,unsigned int len);#else +#define AVS_SET_ENABLE_LOGS_OP (name) +static inline bool avs_logging_fw (struct avs_dev *adev) {return false;
sound/soc/intel/avs/messages.c +19 -17
@@ -685,6 +685,24 @@ int avs_ipc_get_modules_info(struct avs_dev *adev, struct avs_mods_info **info)return 0 ; } +int avs_ipc_copier_set_sink_format (struct avs_dev *adev,u16 module_id, +u8 instance_id,u32 sink_id, +const struct avs_audio_format *src_fmt, +const struct avs_audio_format *sink_fmt) +{ +struct avs_copier_sink_format cpr_fmt; + + cpr_fmt.sink_id = sink_id; +/* Firmware expects driver to resend copier's input format. */ + cpr_fmt.src_fmt = *src_fmt; + cpr_fmt.sink_fmt = *sink_fmt; + +return avs_ipc_set_large_config (adev, module_id, instance_id, +AVS_COPIER_SET_SINK_FORMAT , + (u8 *)&cpr_fmt,sizeof (cpr_fmt)); +} + +#ifdef CONFIG_DEBUG_FS int avs_ipc_set_enable_logs (struct avs_dev *adev,u8 *log_info,size_t size) { return avs_ipc_set_large_config(adev, AVS_BASEFW_MOD_ID, AVS_BASEFW_INST_ID,
@@ -704,20 +722,4 @@ int avs_ipc_set_system_time(struct avs_dev *adev)return avs_ipc_set_large_config (adev,AVS_BASEFW_MOD_ID ,AVS_BASEFW_INST_ID , AVS_BASEFW_SYSTEM_TIME, (u8 *)&sys_time, sizeof(sys_time)); } - -int avs_ipc_copier_set_sink_format (struct avs_dev *adev,u16 module_id, -u8 instance_id,u32 sink_id, -const struct avs_audio_format *src_fmt, -const struct avs_audio_format *sink_fmt) -{ -struct avs_copier_sink_format cpr_fmt; - - cpr_fmt.sink_id = sink_id; -/* Firmware expects driver to resend copier's input format. */ - cpr_fmt.src_fmt = *src_fmt; - cpr_fmt.sink_fmt = *sink_fmt; - -return avs_ipc_set_large_config (adev, module_id, instance_id, -AVS_COPIER_SET_SINK_FORMAT , - (u8 *)&cpr_fmt,sizeof (cpr_fmt)); -} +#endif
sound/soc/intel/avs/skl.c +4 -3
@@ -12,8 +12,9 @@#include "avs.h" #include "messages.h" -static int skl_enable_logs (struct avs_dev *adev,enum avs_log_enable enable,u32 aging_period, -u32 fifo_full_period,unsigned long resource_mask,u32 *priorities) +static int __maybe_unused +skl_enable_logs (struct avs_dev *adev,enum avs_log_enable enable,u32 aging_period, +u32 fifo_full_period,unsigned long resource_mask,u32 *priorities) {struct skl_log_state_info *info;u32 size, num_cores = adev->hw_cfg.dsp_cores;
@@ -111,10 +112,10 @@ const struct avs_dsp_ops skl_dsp_ops = { .load_basefw = avs_cldma_load_basefw, .load_lib = avs_cldma_load_library, .transfer_mods = avs_cldma_transfer_modules, - .enable_logs = skl_enable_logs, .log_buffer_offset = skl_log_buffer_offset, .log_buffer_status = skl_log_buffer_status, .coredump = skl_coredump, .d0ix_toggle = skl_d0ix_toggle, .set_d0ix = skl_set_d0ix, + AVS_SET_ENABLE_LOGS_OP(skl) };
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v2 8/16 ASoC: Intel: avs: Drop usage of debug members in non-debug code
In reply to Cezary RojewskiSwitch 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.
--- sound/soc/intel/avs/apl.c | 11 ++++------- sound/soc/intel/avs/avs.h | 16 ++-------------- sound/soc/intel/avs/debugfs.c | 18 ++++++++++++++++++ sound/soc/intel/avs/skl.c | 5 ++--- sound/soc/intel/avs/utils.c | 18 ------------------ 5 files changed, 26 insertions(+), 42 deletions(-)
sound/soc/intel/avs/apl.c +4 -7
@@ -59,21 +59,18 @@ static int apl_log_buffer_status(struct avs_dev *adev, union avs_notify_msg *msgmemcpy_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, -apl_log_payload_size (adev) - 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);
sound/soc/intel/avs/avs.h +2 -14
@@ -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_nunsigned 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; }
sound/soc/intel/avs/debugfs.c +18 -0
@@ -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);
sound/soc/intel/avs/skl.c +2 -3
@@ -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 ; }
sound/soc/intel/avs/utils.c +0 -18
@@ -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; -}
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v2 9/16 ASoC: Intel: avs: Add data probing requests
In reply to Cezary RojewskiData probing is a cAVS firmware functionality that allows for data extraction and injection directly from or to DMA stream. To support it, new functions and types are added. These facilitate communication with the firmware.
Total of eight IPCs:
- probe module initialization and cleanup
- addition and removal of probe points
- addition and removal of injection DMAs
- dumping list of currently connected probe points or enlisted DMAs
--- sound/soc/intel/avs/Makefile | 2 +- sound/soc/intel/avs/messages.c | 78 ++++++++++++++++++++++++++++++++++ sound/soc/intel/avs/messages.h | 53 +++++++++++++++++++++++ sound/soc/intel/avs/probes.c | 46 ++++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 sound/soc/intel/avs/probes.c
sound/soc/intel/avs/Makefile +1 -1
@@ -10,7 +10,7 @@ snd-soc-avs-objs += trace.o CFLAGS_trace.o := -I$(src) ifneq ($(CONFIG_DEBUG_FS),) -snd-soc-avs-objs += debugfs.o +snd-soc-avs-objs += probes.o debugfs.o endif obj-$(CONFIG_SND_SOC_INTEL_AVS) += snd-soc-avs.o
sound/soc/intel/avs/messages.c +78 -0
82 lines not on this page · raw message
sound/soc/intel/avs/messages.h +53 -0
57 lines not on this page · raw message
sound/soc/intel/avs/probes.c new file +46 -0
46 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v2 10/16 ASoC: Intel: avs: Probe compress operations
In reply to Cezary RojewskiAdd compress operations handlers for data extraction through probes. A single HDAudio stream is enlisted for said purpose. Operations follow same protocol as for standard PCM streaming on HOST side.
--- sound/soc/intel/Kconfig | 1 + sound/soc/intel/avs/avs.h | 3 + sound/soc/intel/avs/probes.c | 224 ++++++++++++++++++++++++++++++++++- 3 files changed, 225 insertions(+), 3 deletions(-)
sound/soc/intel/Kconfig +1 -0
@@ -217,6 +217,7 @@ config SND_SOC_INTEL_AVS select SND_SOC_ACPI if ACPI select SND_SOC_TOPOLOGY select SND_SOC_HDA + select SND_SOC_COMPRESS if DEBUG_FS select SND_HDA_EXT_CORE select SND_HDA_DSP_LOADER select SND_INTEL_DSP_CONFIG
sound/soc/intel/avs/avs.h +3 -0
@@ -144,6 +144,9 @@ struct avs_dev {u32 aging_timer_period;u32 fifo_full_timer_period;u32 logged_resources;/* context dependent: core or library */ +/* probes */ +struct hdac_ext_stream *extractor; +unsigned int num_probe_streams;#endif };
sound/soc/intel/avs/probes.c +221 -3
244 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v2 11/16 ASoC: Intel: avs: Data probing soc-component
In reply to Cezary RojewskiDefine stub component for data probing. Stub as most operations from standard PCM case do not apply here. Specific bits are CPU DAIs and compress_ops. FE DAIs can link against these new CPU DAI to create new compress devices.
--- sound/soc/intel/avs/avs.h | 10 +++++++ sound/soc/intel/avs/pcm.c | 6 ++-- sound/soc/intel/avs/probes.c | 53 ++++++++++++++++++++++++++++++++++-- 3 files changed, 64 insertions(+), 5 deletions(-)
sound/soc/intel/avs/avs.h +10 -0
@@ -322,6 +322,9 @@ struct avs_soc_component {extern const struct snd_soc_dai_ops avs_dai_fe_ops; +int avs_soc_component_register (struct device *dev,const char *name, +const struct snd_soc_component_driver *drv, +struct snd_soc_dai_driver *cpu_dais,int num_cpu_dais);int avs_dmic_platform_register (struct avs_dev *adev,const char *name);int avs_i2s_platform_register (struct avs_dev *adev,const char *name,unsigned long port_mask,unsigned long *tdms);
@@ -373,6 +376,8 @@ struct apl_log_buffer_layout {bool avs_logging_fw (struct avs_dev *adev);void avs_dump_fw_log (struct avs_dev *adev,const void __iomem *src,unsigned int len);void avs_dump_fw_log_wakeup (struct avs_dev *adev,const void __iomem *src,unsigned int len); + +int avs_probe_platform_register (struct avs_dev *adev,const char *name);#else #define AVS_SET_ENABLE_LOGS_OP (name)
@@ -389,6 +394,11 @@ static inline void avs_dump_fw_log_wakeup(struct avs_dev *adev, const void __iomem *src, unsigned int len) { } + +static inline int avs_probe_platform_register (struct avs_dev *adev,const char *name) +{ +return 0 ; +}#endif #endif /* __SOUND_SOC_INTEL_AVS_H */
sound/soc/intel/avs/pcm.c +3 -3
@@ -1126,9 +1126,9 @@ static const struct snd_soc_component_driver avs_component_driver = { .topology_name_prefix = "intel/avs", }; -static int avs_soc_component_register (struct device *dev,const char *name, -const struct snd_soc_component_driver *drv, -struct snd_soc_dai_driver *cpu_dais,int num_cpu_dais) +int avs_soc_component_register (struct device *dev,const char *name, +const struct snd_soc_component_driver *drv, +struct snd_soc_dai_driver *cpu_dais,int num_cpu_dais) {struct avs_soc_component *acomp;int ret;
sound/soc/intel/avs/probes.c +51 -2
65 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v2 12/16 ASoC: Intel: avs: Add probe machine board
In reply to Cezary RojewskiStub machine board driver with no custom DAPM routes and single FE DAI link for userspace to interact with.
--- sound/soc/intel/avs/board_selection.c | 33 ++++++++++++++ sound/soc/intel/avs/boards/Kconfig | 8 ++++ sound/soc/intel/avs/boards/Makefile | 2 + sound/soc/intel/avs/boards/probe.c | 64 +++++++++++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 sound/soc/intel/avs/boards/probe.c
sound/soc/intel/avs/board_selection.c +33 -0
@@ -291,6 +291,33 @@ static void board_pdev_unregister(void *data)platform_device_unregister (data); } +static int __maybe_unused avs_register_probe_board (struct avs_dev *adev) +{ +struct platform_device *board; +struct snd_soc_acpi_mach mach = {{0 }}; +int ret; + + ret =avs_probe_platform_register (adev,"probe-platform" ); +if (ret <0 ) +return ret; + + mach.mach_params.platform ="probe-platform" ; + + board =platform_device_register_data (NULL ,"avs_probe_mb" ,PLATFORM_DEVID_NONE , + (const void *)&mach,sizeof (mach)); +if (IS_ERR (board)) { +dev_err (adev->dev,"probe board register failed\n" ); +return PTR_ERR (board); + } + + ret =devm_add_action (adev->dev, board_pdev_unregister, board); +if (ret <0 ) { +platform_device_unregister (board); +return ret; + } +return 0 ; +} +static int avs_register_dmic_board (struct avs_dev *adev) {struct platform_device *codec, *board;
@@ -500,6 +527,12 @@ int avs_register_all_boards(struct avs_dev *adev) {int ret; +#ifdef CONFIG_DEBUG_FS + ret =avs_register_probe_board (adev); +if (ret <0 ) +dev_warn (adev->dev,"enumerate PROBE endpoints failed: %d\n" , ret); +#endif + ret =avs_register_dmic_board (adev);if (ret <0 ) dev_warn(adev->dev, "enumerate DMIC endpoints failed: %d\n",
sound/soc/intel/avs/boards/Kconfig +8 -0
@@ -77,6 +77,14 @@ config SND_SOC_INTEL_AVS_MACH_NAU8825 Say Y or m if you have such a device. This is a recommended option. If unsure select "N". +config SND_SOC_INTEL_AVS_MACH_PROBE + tristate "Probing (data) board" + depends on DEBUG_FS + select SND_HWDEP + help + This adds support for data probing board which can be used to + gather data from runtime stream over compress operations. + config SND_SOC_INTEL_AVS_MACH_RT274 tristate "rt274 in I2S mode" depends on I2C
sound/soc/intel/avs/boards/Makefile +2 -0
@@ -8,6 +8,7 @@ snd-soc-avs-max98927-objs := max98927.o snd-soc-avs-max98357a-objs := max98357a.o snd-soc-avs-max98373-objs := max98373.o snd-soc-avs-nau8825-objs := nau8825.o +snd-soc-avs-probe-objs := probe.o snd-soc-avs-rt274-objs := rt274.o snd-soc-avs-rt286-objs := rt286.o snd-soc-avs-rt298-objs := rt298.o
@@ -22,6 +23,7 @@ obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_MAX98927) += snd-soc-avs-max98927.o obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_MAX98357A) += snd-soc-avs-max98357a.o obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_MAX98373) += snd-soc-avs-max98373.o obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_NAU8825) += snd-soc-avs-nau8825.o +obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_PROBE) += snd-soc-avs-probe.o obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_RT274) += snd-soc-avs-rt274.o obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_RT286) += snd-soc-avs-rt286.o obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_RT298) += snd-soc-avs-rt298.o
sound/soc/intel/avs/boards/probe.c new file +64 -0
64 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v2 13/16 ASoC: Intel: avs: Probing and firmware tracing over debugfs
In reply to Cezary RojewskiDefine debugfs subdirectory delegated for IPC communication with DSP. Input format: uint,uint,(...) which are later translated into DWORDS sequence and further into instances of struct of interest given the IPC type.
For Extractor probes, following have been enabled:
- PROBE_POINT_ADD (echo <..> probe_points)
- PROBE_POINT_REMOVE (echo <..> probe_points_remove)
- PROBE_POINT_INFO (cat probe_points)
--- sound/soc/intel/avs/avs.h | 7 + sound/soc/intel/avs/core.c | 2 + sound/soc/intel/avs/debugfs.c | 326 ++++++++++++++++++++++++++++++++++ 3 files changed, 335 insertions(+)
sound/soc/intel/avs/avs.h +7 -0
@@ -144,6 +144,7 @@ struct avs_dev {u32 aging_timer_period;u32 fifo_full_timer_period;u32 logged_resources;/* context dependent: core or library */ +struct dentry *debugfs_root;/* probes */ struct hdac_ext_stream *extractor;unsigned int num_probe_streams;
@@ -378,6 +379,9 @@ void avs_dump_fw_log(struct avs_dev *adev, const void __iomem *src, unsigned intvoid avs_dump_fw_log_wakeup (struct avs_dev *adev,const void __iomem *src,unsigned int len);int avs_probe_platform_register (struct avs_dev *adev,const char *name); + +void avs_debugfs_init (struct avs_dev *adev); +void avs_debugfs_exit (struct avs_dev *adev);#else #define AVS_SET_ENABLE_LOGS_OP (name)
@@ -399,6 +403,9 @@ static inline int avs_probe_platform_register(struct avs_dev *adev, const char * {return 0 ; } + +static inline void avs_debugfs_init (struct avs_dev *adev) { } +static inline void avs_debugfs_exit (struct avs_dev *adev) { }#endif #endif /* __SOUND_SOC_INTEL_AVS_H */
sound/soc/intel/avs/core.c +2 -0
@@ -214,6 +214,7 @@ static void avs_hda_probe_work(struct work_struct *work) adev->nhlt =intel_nhlt_init (adev->dev);if (!adev->nhlt)dev_info (bus->dev,"platform has no NHLT\n" ); +avs_debugfs_init (adev);avs_register_all_boards (adev);
@@ -491,6 +492,7 @@ static void avs_pci_remove(struct pci_dev *pci)avs_unregister_all_boards (adev); +avs_debugfs_exit (adev);if (adev->nhlt)intel_nhlt_free (adev->nhlt);
sound/soc/intel/avs/debugfs.c +326 -0
336 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v2 14/16 ASoC: Intel: avs: Gather remaining logs on strace_release()
In reply to Cezary RojewskiWhen user closes the tracer, some logs may still remain in the tail of the buffer as firmware sends LOG_BUFFER_STATUS notification only when certain threshold of data is reached. Add whatever is left to already gathered logs so no information is lost.
--- sound/soc/intel/avs/debugfs.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
sound/soc/intel/avs/debugfs.c +15 -1
@@ -201,11 +201,25 @@ static int strace_open(struct inode *inode, struct file *file)static int strace_release (struct inode *inode,struct file *file) { +union avs_notify_msg msg =AVS_NOTIFICATION (LOG_BUFFER_STATUS );struct avs_dev *adev = file->private_data; -unsigned long flags; +unsigned long resource_mask; +unsigned long flags, i; +u32 num_cores; + + resource_mask = adev->logged_resources; + num_cores = adev->hw_cfg.dsp_cores;spin_lock_irqsave (&adev->trace_lock, flags); + +/* Gather any remaining logs. */ +for_each_set_bit (i, &resource_mask, num_cores) { + msg.log.core = i; +avs_dsp_op (adev, log_buffer_status, &msg); + } +kfifo_free (&adev->trace_fifo); +spin_unlock_irqrestore (&adev->trace_lock, flags);return 0 ;
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v2 15/16 ASoC: Intel: avs: Allow for dumping FW_REGS area
In reply to Cezary RojewskiSRAM0 window begins with a block of memory, usually of size PAGE_SIZE, dedicated to the base firmware registers. When debugging firmware, it is desirable to be able to dump them at will.
--- sound/soc/intel/avs/debugfs.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
sound/soc/intel/avs/debugfs.c +24 -0
@@ -48,6 +48,29 @@ void avs_dump_fw_log_wakeup(struct avs_dev *adev, const void __iomem *src, unsigwake_up (&adev->trace_waitq); } +static ssize_t fw_regs_read (struct file *file,char __user *to,size_t count,loff_t *ppos) +{ +struct avs_dev *adev = file->private_data; +char *buf; +int ret; + + buf =kzalloc (AVS_FW_REGS_SIZE ,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + +memcpy_fromio (buf,avs_sram_addr (adev,AVS_FW_REGS_WINDOW ),AVS_FW_REGS_SIZE ); + + ret =simple_read_from_buffer (to, count, ppos, buf,AVS_FW_REGS_SIZE ); +kfree (buf); +return ret; +} + +static const struct file_operations fw_regs_fops = { + .open = simple_open, + .read = fw_regs_read, + .llseek = no_llseek, +}; +static ssize_t probe_points_read (struct file *file,char __user *to,size_t count,loff_t *ppos) {struct avs_dev *adev = file->private_data;
@@ -369,6 +392,7 @@ void avs_debugfs_init(struct avs_dev *adev)debugfs_create_file ("strace" ,0444 , adev->debugfs_root, adev, &strace_fops);debugfs_create_file ("trace_control" ,0644 , adev->debugfs_root, adev, &trace_control_fops); +debugfs_create_file ("fw_regs" ,0444 , adev->debugfs_root, adev, &fw_regs_fops);debugfs_create_u32 ("trace_aging_period" ,0644 , adev->debugfs_root, &adev->aging_timer_period);
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v2 16/16 ASoC: Intel: avs: Allow for dumping debug window snapshot
In reply to Cezary RojewskiAdd new read-only debugfs entry which dumps entire content of the SRAM window 2 i.e.: the debug window.
--- sound/soc/intel/avs/debugfs.c | 26 ++++++++++++++++++++++++++ sound/soc/intel/avs/registers.h | 3 ++- 2 files changed, 28 insertions(+), 1 deletion(-)
sound/soc/intel/avs/debugfs.c +26 -0
@@ -71,6 +71,31 @@ static const struct file_operations fw_regs_fops = { .llseek = no_llseek, }; +static ssize_t debug_window_read (struct file *file,char __user *to,size_t count,loff_t *ppos) +{ +struct avs_dev *adev = file->private_data; +size_t size; +char *buf; +int ret; + + size = adev->hw_cfg.dsp_cores *AVS_WINDOW_CHUNK_SIZE ; + buf =kzalloc (size,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + +memcpy_fromio (buf,avs_sram_addr (adev,AVS_DEBUG_WINDOW ), size); + + ret =simple_read_from_buffer (to, count, ppos, buf, size); +kfree (buf); +return ret; +} + +static const struct file_operations debug_window_fops = { + .open = simple_open, + .read = debug_window_read, + .llseek = no_llseek, +}; +static ssize_t probe_points_read (struct file *file,char __user *to,size_t count,loff_t *ppos) {struct avs_dev *adev = file->private_data;
@@ -393,6 +418,7 @@ void avs_debugfs_init(struct avs_dev *adev)debugfs_create_file ("strace" ,0444 , adev->debugfs_root, adev, &strace_fops);debugfs_create_file ("trace_control" ,0644 , adev->debugfs_root, adev, &trace_control_fops);debugfs_create_file ("fw_regs" ,0444 , adev->debugfs_root, adev, &fw_regs_fops); +debugfs_create_file ("debug_window" ,0444 , adev->debugfs_root, adev, &debug_window_fops);debugfs_create_u32 ("trace_aging_period" ,0644 , adev->debugfs_root, &adev->aging_timer_period);
sound/soc/intel/avs/registers.h +2 -1
@@ -59,7 +59,8 @@#define AVS_FW_REG_STATUS (adev) (AVS_FW_REG_BASE(adev) + 0x0)#define AVS_FW_REG_ERROR_CODE (adev) (AVS_FW_REG_BASE(adev) + 0x4) -#define AVS_FW_REGS_SIZE PAGE_SIZE +#define AVS_WINDOW_CHUNK_SIZE PAGE_SIZE +#define AVS_FW_REGS_SIZE AVS_WINDOW_CHUNK_SIZE#define AVS_FW_REGS_WINDOW 0/* DSP -> HOST communication window */ #define AVS_UPLINK_WINDOW AVS_FW_REGS_WINDOW
Signature · 1 line
2.25.1
Mark Brown
maintainerQuoted 11 lines · Cezary Rojewski
The patchset focuses on debug functionality for the avs-driver. Two major blocks are covered here: data probing and AudioDSP firmware logging. Both are configured and controlled through debugfs.
Data probing is a AudioDSP debug functionality which allows for gathering the actual data that is being routed to or from a module. Helps in debugging its processing capabilities - navigate to a specific module which may have caused a glitch within a pipeline (set of modules bound together).
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[01/16] ALSA: hda: Allow for compress stream to hdac_ext_stream assignment
commit: 97d73d978271ade27fc751ad606f23c1c4c43678
[02/16] ALSA: hda: Prepare for compress stream support
commit: f6b1254664a0a15c8bbe0a17b2c86840aa38d3d7
[03/16] ALSA: hda: Interrupt servicing and BDL setup for compress streams
commit: 3e9582267e3a06bfd9622dbd2304a8cfac977b43
[04/16] ASoC: Intel: avs: Introduce avs_log_buffer_status_locked()
commit: bb03099bf2253fcd1a4d57e6f5ee4e8000911e77
[05/16] ASoC: Intel: avs: Drop fifo_lock
commit: 58029b7734ec84738aeb8fb391e625832bb6b0a6
[06/16] ASoC: Intel: avs: Introduce debug-context aware helpers
commit: 9e3c15beb8976771f95ba30b3da8bd35dc7188ac
[07/16] ASoC: Intel: avs: Make enable_logs() dependent on DEBUG_FS
commit: b3eefa5d8dbfe5286c3308fa706fc9c45b38fe19
[08/16] ASoC: Intel: avs: Drop usage of debug members in non-debug code
commit: f7de161fc8d5e1ebac3c361a37b1d748e7086330
[09/16] ASoC: Intel: avs: Add data probing requests
commit: dab8d000e25c3e91154efca287434a4f78ab65d2
[10/16] ASoC: Intel: avs: Probe compress operations
commit: 700462f55493c6831ad71b209eaebe310dcf11fd
[11/16] ASoC: Intel: avs: Data probing soc-component
commit: ed914a2a45a45e7d8f900ae8997ca4573792afcc
[12/16] ASoC: Intel: avs: Add probe machine board
commit: e17527e167ae5bd71fc9cb67da4e73bbb050e6f7
[13/16] ASoC: Intel: avs: Probing and firmware tracing over debugfs
commit: 5a565ba23abe478f3d4c3b0c8798bcb5215b82f5
[14/16] ASoC: Intel: avs: Gather remaining logs on strace_release()
commit: 34d27c71707c4ed615105376e0f3907d99b1b271
[15/16] ASoC: Intel: avs: Allow for dumping FW_REGS area
commit: 870f6e5abba95ac78e750b61cf8f3f15be96796f
[16/16] ASoC: Intel: avs: Allow for dumping debug window snapshot
commit: 85ac9c8c8eed76e8a320a9e017c6d36e2a52745bAll being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark