Skip to content

Commit 9963b1f

Browse files
committed
ASoC: Intel: avs: Code cleanups and separation
Merge series from Cezary Rojewski <[email protected]>: Set of patches that brings no new functionality but makes it easier to maintain and read the avs-driver code. There is one 'fix' among them - the third patch, described below. First, debug-related code - mainly the data-probing feature - is mixed with non-debug PCM code. Separate it into debug.h and update the pcm.c file. Next, as the probing-board is not tied to any topology file, it shall not using struct avs_soc_component descriptor but the basic struct snd_soc_component one. While on the first sight this is just bump in LOCs, runtime is simplified as no topology checks and related code will be engaged. With probing-board addressed and debug code relocated: - address the component-teardown issues when the componet->name points to a string which is shared by multiple components and/or machine boards. devm_kstrdup() makes this go away. - streamline the naming scheme for the functions engaged in the components registration. This is purely a readability improvement.
2 parents 7ed3723 + 2a55135 commit 9963b1f

16 files changed

Lines changed: 153 additions & 106 deletions

File tree

sound/soc/intel/avs/apl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/slab.h>
1111
#include <sound/hdaudio_ext.h>
1212
#include "avs.h"
13+
#include "debug.h"
1314
#include "messages.h"
1415
#include "path.h"
1516
#include "registers.h"

sound/soc/intel/avs/avs.h

Lines changed: 8 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -348,91 +348,18 @@ struct avs_soc_component {
348348

349349
extern const struct snd_soc_dai_ops avs_dai_fe_ops;
350350

351-
int avs_soc_component_register(struct device *dev, const char *name,
352-
struct snd_soc_component_driver *drv,
353-
struct snd_soc_dai_driver *cpu_dais, int num_cpu_dais);
354-
int avs_dmic_platform_register(struct avs_dev *adev, const char *name);
355-
int avs_i2s_platform_register(struct avs_dev *adev, const char *name, unsigned long port_mask,
356-
unsigned long *tdms);
357-
int avs_hda_platform_register(struct avs_dev *adev, const char *name);
351+
int avs_register_dmic_component(struct avs_dev *adev, const char *name);
352+
int avs_register_i2s_component(struct avs_dev *adev, const char *name, unsigned long port_mask,
353+
unsigned long *tdms);
354+
int avs_register_hda_component(struct avs_dev *adev, const char *name);
355+
int avs_register_component(struct device *dev, const char *name,
356+
struct snd_soc_component_driver *drv,
357+
struct snd_soc_dai_driver *cpu_dais, int num_cpu_dais);
358358

359359
int avs_register_all_boards(struct avs_dev *adev);
360360
void avs_unregister_all_boards(struct avs_dev *adev);
361361

362-
/* Firmware tracing helpers */
363-
364-
#define avs_log_buffer_size(adev) \
365-
((adev)->fw_cfg.trace_log_bytes / (adev)->hw_cfg.dsp_cores)
366-
367-
#define avs_log_buffer_addr(adev, core) \
368-
({ \
369-
s32 __offset = avs_dsp_op(adev, log_buffer_offset, core); \
370-
(__offset < 0) ? NULL : \
371-
(avs_sram_addr(adev, AVS_DEBUG_WINDOW) + __offset); \
372-
})
373-
374-
static inline int avs_log_buffer_status_locked(struct avs_dev *adev, union avs_notify_msg *msg)
375-
{
376-
unsigned long flags;
377-
int ret;
378-
379-
spin_lock_irqsave(&adev->trace_lock, flags);
380-
ret = avs_dsp_op(adev, log_buffer_status, msg);
381-
spin_unlock_irqrestore(&adev->trace_lock, flags);
382-
383-
return ret;
384-
}
385-
386-
struct avs_apl_log_buffer_layout {
387-
u32 read_ptr;
388-
u32 write_ptr;
389-
u8 buffer[];
390-
} __packed;
391-
static_assert(sizeof(struct avs_apl_log_buffer_layout) == 8);
392-
393-
#define avs_apl_log_payload_size(adev) \
394-
(avs_log_buffer_size(adev) - sizeof(struct avs_apl_log_buffer_layout))
395-
396-
#define avs_apl_log_payload_addr(addr) \
397-
(addr + sizeof(struct avs_apl_log_buffer_layout))
398-
399-
#ifdef CONFIG_DEBUG_FS
400-
#define AVS_SET_ENABLE_LOGS_OP(name) \
401-
.enable_logs = avs_##name##_enable_logs
402-
403-
bool avs_logging_fw(struct avs_dev *adev);
404-
void avs_dump_fw_log(struct avs_dev *adev, const void __iomem *src, unsigned int len);
405-
void avs_dump_fw_log_wakeup(struct avs_dev *adev, const void __iomem *src, unsigned int len);
406-
407-
int avs_probe_platform_register(struct avs_dev *adev, const char *name);
408-
409-
void avs_debugfs_init(struct avs_dev *adev);
410-
void avs_debugfs_exit(struct avs_dev *adev);
411-
#else
412-
#define AVS_SET_ENABLE_LOGS_OP(name)
413-
414-
static inline bool avs_logging_fw(struct avs_dev *adev)
415-
{
416-
return false;
417-
}
418-
419-
static inline void avs_dump_fw_log(struct avs_dev *adev, const void __iomem *src, unsigned int len)
420-
{
421-
}
422-
423-
static inline void
424-
avs_dump_fw_log_wakeup(struct avs_dev *adev, const void __iomem *src, unsigned int len)
425-
{
426-
}
427-
428-
static inline int avs_probe_platform_register(struct avs_dev *adev, const char *name)
429-
{
430-
return 0;
431-
}
432-
433-
static inline void avs_debugfs_init(struct avs_dev *adev) { }
434-
static inline void avs_debugfs_exit(struct avs_dev *adev) { }
435-
#endif
362+
int avs_parse_sched_cfg(struct avs_dev *adev, const char *buf, size_t len);
436363

437364
/* Filesystems integration */
438365

sound/soc/intel/avs/board_selection.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include <sound/soc-acpi.h>
1818
#include <sound/soc-component.h>
1919
#include "avs.h"
20+
#include "debug.h"
21+
#include "pcm.h"
2022
#include "utils.h"
2123

2224
static char *i2s_test;
@@ -409,7 +411,7 @@ static int __maybe_unused avs_register_probe_board(struct avs_dev *adev)
409411
struct snd_soc_acpi_mach mach = {{0}};
410412
int ret;
411413

412-
ret = avs_probe_platform_register(adev, "probe-platform");
414+
ret = avs_register_probe_component(adev, "probe-platform");
413415
if (ret < 0)
414416
return ret;
415417

@@ -454,7 +456,7 @@ static int avs_register_dmic_board(struct avs_dev *adev)
454456
return ret;
455457
}
456458

457-
ret = avs_dmic_platform_register(adev, "dmic-platform");
459+
ret = avs_register_dmic_component(adev, "dmic-platform");
458460
if (ret < 0)
459461
return ret;
460462

@@ -515,7 +517,7 @@ static int avs_register_i2s_board(struct avs_dev *adev, struct snd_soc_acpi_mach
515517
if (!name)
516518
return -ENOMEM;
517519

518-
ret = avs_i2s_platform_register(adev, name, mach->mach_params.i2s_link_mask, pdata->tdms);
520+
ret = avs_register_i2s_component(adev, name, mach->mach_params.i2s_link_mask, pdata->tdms);
519521
if (ret < 0)
520522
return ret;
521523

@@ -654,7 +656,7 @@ static int avs_register_hda_board(struct avs_dev *adev, struct hda_codec *codec)
654656
pdata->obsolete_card_names = obsolete_card_names;
655657
pdata->codec = codec;
656658

657-
ret = avs_hda_platform_register(adev, pname);
659+
ret = avs_register_hda_component(adev, pname);
658660
if (ret < 0)
659661
return ret;
660662

sound/soc/intel/avs/cnl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <sound/hdaudio_ext.h>
1010
#include "avs.h"
11+
#include "debug.h"
1112
#include "messages.h"
1213
#include "registers.h"
1314

sound/soc/intel/avs/core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "../../codecs/hda.h"
2828
#include "avs.h"
2929
#include "cldma.h"
30+
#include "debug.h"
3031
#include "messages.h"
3132
#include "pcm.h"
3233

sound/soc/intel/avs/debug.h

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* Copyright(c) 2024-2025 Intel Corporation
4+
*
5+
* Authors: Cezary Rojewski <[email protected]>
6+
* Amadeusz Slawinski <[email protected]>
7+
*/
8+
9+
#ifndef __SOUND_SOC_INTEL_AVS_DEBUG_H
10+
#define __SOUND_SOC_INTEL_AVS_DEBUG_H
11+
12+
#include "messages.h"
13+
#include "registers.h"
14+
15+
struct avs_dev;
16+
17+
#define avs_log_buffer_size(adev) \
18+
((adev)->fw_cfg.trace_log_bytes / (adev)->hw_cfg.dsp_cores)
19+
20+
#define avs_log_buffer_addr(adev, core) \
21+
({ \
22+
s32 __offset = avs_dsp_op(adev, log_buffer_offset, core); \
23+
(__offset < 0) ? NULL : \
24+
(avs_sram_addr(adev, AVS_DEBUG_WINDOW) + __offset); \
25+
})
26+
27+
static inline int avs_log_buffer_status_locked(struct avs_dev *adev, union avs_notify_msg *msg)
28+
{
29+
unsigned long flags;
30+
int ret;
31+
32+
spin_lock_irqsave(&adev->trace_lock, flags);
33+
ret = avs_dsp_op(adev, log_buffer_status, msg);
34+
spin_unlock_irqrestore(&adev->trace_lock, flags);
35+
36+
return ret;
37+
}
38+
39+
struct avs_apl_log_buffer_layout {
40+
u32 read_ptr;
41+
u32 write_ptr;
42+
u8 buffer[];
43+
} __packed;
44+
static_assert(sizeof(struct avs_apl_log_buffer_layout) == 8);
45+
46+
#define avs_apl_log_payload_size(adev) \
47+
(avs_log_buffer_size(adev) - sizeof(struct avs_apl_log_buffer_layout))
48+
49+
#define avs_apl_log_payload_addr(addr) \
50+
(addr + sizeof(struct avs_apl_log_buffer_layout))
51+
52+
#ifdef CONFIG_DEBUG_FS
53+
int avs_register_probe_component(struct avs_dev *adev, const char *name);
54+
55+
#define AVS_SET_ENABLE_LOGS_OP(name) \
56+
.enable_logs = avs_##name##_enable_logs
57+
58+
bool avs_logging_fw(struct avs_dev *adev);
59+
void avs_dump_fw_log(struct avs_dev *adev, const void __iomem *src, unsigned int len);
60+
void avs_dump_fw_log_wakeup(struct avs_dev *adev, const void __iomem *src, unsigned int len);
61+
62+
void avs_debugfs_init(struct avs_dev *adev);
63+
void avs_debugfs_exit(struct avs_dev *adev);
64+
65+
#else
66+
static inline int avs_register_probe_component(struct avs_dev *adev, const char *name)
67+
{
68+
return -EOPNOTSUPP;
69+
}
70+
71+
#define AVS_SET_ENABLE_LOGS_OP(name)
72+
73+
static inline bool avs_logging_fw(struct avs_dev *adev)
74+
{
75+
return false;
76+
}
77+
78+
static inline void avs_dump_fw_log(struct avs_dev *adev, const void __iomem *src, unsigned int len)
79+
{
80+
}
81+
82+
static inline void avs_dump_fw_log_wakeup(struct avs_dev *adev, const void __iomem *src,
83+
unsigned int len)
84+
{
85+
}
86+
87+
static inline void avs_debugfs_init(struct avs_dev *adev) { }
88+
static inline void avs_debugfs_exit(struct avs_dev *adev) { }
89+
#endif
90+
91+
#endif

sound/soc/intel/avs/debugfs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/string_helpers.h>
1414
#include <sound/soc.h>
1515
#include "avs.h"
16+
#include "debug.h"
1617
#include "messages.h"
1718

1819
static unsigned int __kfifo_fromio(struct kfifo *fifo, const void __iomem *src, unsigned int len)

sound/soc/intel/avs/icl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <sound/hdaudio.h>
1111
#include <sound/hdaudio_ext.h>
1212
#include "avs.h"
13+
#include "debug.h"
1314
#include "messages.h"
1415

1516
#define ICL_VS_LTRP_GB_ICCMAX 95

sound/soc/intel/avs/ipc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/slab.h>
1111
#include <sound/hdaudio_ext.h>
1212
#include "avs.h"
13+
#include "debug.h"
1314
#include "messages.h"
1415
#include "registers.h"
1516
#include "trace.h"

sound/soc/intel/avs/lnl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <sound/hdaudio_ext.h>
1010
#include "avs.h"
11+
#include "debug.h"
1112
#include "registers.h"
1213

1314
int avs_lnl_core_stall(struct avs_dev *adev, u32 core_mask, bool stall)

0 commit comments

Comments
 (0)