Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: Intel: avs: Code cleanups and separation

Merge series from Cezary Rojewski <cezary.rojewski@intel.com>:

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.

+153 -106
+1
sound/soc/intel/avs/apl.c
··· 10 10 #include <linux/slab.h> 11 11 #include <sound/hdaudio_ext.h> 12 12 #include "avs.h" 13 + #include "debug.h" 13 14 #include "messages.h" 14 15 #include "path.h" 15 16 #include "registers.h"
+8 -81
sound/soc/intel/avs/avs.h
··· 348 348 349 349 extern const struct snd_soc_dai_ops avs_dai_fe_ops; 350 350 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); 358 358 359 359 int avs_register_all_boards(struct avs_dev *adev); 360 360 void avs_unregister_all_boards(struct avs_dev *adev); 361 361 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); 436 363 437 364 /* Filesystems integration */ 438 365
+6 -4
sound/soc/intel/avs/board_selection.c
··· 17 17 #include <sound/soc-acpi.h> 18 18 #include <sound/soc-component.h> 19 19 #include "avs.h" 20 + #include "debug.h" 21 + #include "pcm.h" 20 22 #include "utils.h" 21 23 22 24 static char *i2s_test; ··· 411 409 struct snd_soc_acpi_mach mach = {{0}}; 412 410 int ret; 413 411 414 - ret = avs_probe_platform_register(adev, "probe-platform"); 412 + ret = avs_register_probe_component(adev, "probe-platform"); 415 413 if (ret < 0) 416 414 return ret; 417 415 ··· 456 454 return ret; 457 455 } 458 456 459 - ret = avs_dmic_platform_register(adev, "dmic-platform"); 457 + ret = avs_register_dmic_component(adev, "dmic-platform"); 460 458 if (ret < 0) 461 459 return ret; 462 460 ··· 517 515 if (!name) 518 516 return -ENOMEM; 519 517 520 - ret = avs_i2s_platform_register(adev, name, mach->mach_params.i2s_link_mask, pdata->tdms); 518 + ret = avs_register_i2s_component(adev, name, mach->mach_params.i2s_link_mask, pdata->tdms); 521 519 if (ret < 0) 522 520 return ret; 523 521 ··· 656 654 pdata->obsolete_card_names = obsolete_card_names; 657 655 pdata->codec = codec; 658 656 659 - ret = avs_hda_platform_register(adev, pname); 657 + ret = avs_register_hda_component(adev, pname); 660 658 if (ret < 0) 661 659 return ret; 662 660
+1
sound/soc/intel/avs/cnl.c
··· 8 8 9 9 #include <sound/hdaudio_ext.h> 10 10 #include "avs.h" 11 + #include "debug.h" 11 12 #include "messages.h" 12 13 #include "registers.h" 13 14
+1
sound/soc/intel/avs/core.c
··· 27 27 #include "../../codecs/hda.h" 28 28 #include "avs.h" 29 29 #include "cldma.h" 30 + #include "debug.h" 30 31 #include "messages.h" 31 32 #include "pcm.h" 32 33
+91
sound/soc/intel/avs/debug.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + /* 3 + * Copyright(c) 2024-2025 Intel Corporation 4 + * 5 + * Authors: Cezary Rojewski <cezary.rojewski@intel.com> 6 + * Amadeusz Slawinski <amadeuszx.slawinski@linux.intel.com> 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
+1
sound/soc/intel/avs/debugfs.c
··· 13 13 #include <linux/string_helpers.h> 14 14 #include <sound/soc.h> 15 15 #include "avs.h" 16 + #include "debug.h" 16 17 #include "messages.h" 17 18 18 19 static unsigned int __kfifo_fromio(struct kfifo *fifo, const void __iomem *src, unsigned int len)
+1
sound/soc/intel/avs/icl.c
··· 10 10 #include <sound/hdaudio.h> 11 11 #include <sound/hdaudio_ext.h> 12 12 #include "avs.h" 13 + #include "debug.h" 13 14 #include "messages.h" 14 15 15 16 #define ICL_VS_LTRP_GB_ICCMAX 95
+1
sound/soc/intel/avs/ipc.c
··· 10 10 #include <linux/slab.h> 11 11 #include <sound/hdaudio_ext.h> 12 12 #include "avs.h" 13 + #include "debug.h" 13 14 #include "messages.h" 14 15 #include "registers.h" 15 16 #include "trace.h"
+1
sound/soc/intel/avs/lnl.c
··· 8 8 9 9 #include <sound/hdaudio_ext.h> 10 10 #include "avs.h" 11 + #include "debug.h" 11 12 #include "registers.h" 12 13 13 14 int avs_lnl_core_stall(struct avs_dev *adev, u32 core_mask, bool stall)
+1
sound/soc/intel/avs/mtl.c
··· 8 8 9 9 #include <sound/hdaudio_ext.h> 10 10 #include "avs.h" 11 + #include "debug.h" 11 12 #include "registers.h" 12 13 #include "trace.h" 13 14
+18 -17
sound/soc/intel/avs/pcm.c
··· 1379 1379 .topology_name_prefix = "intel/avs", 1380 1380 }; 1381 1381 1382 - int avs_soc_component_register(struct device *dev, const char *name, 1383 - struct snd_soc_component_driver *drv, 1384 - struct snd_soc_dai_driver *cpu_dais, int num_cpu_dais) 1382 + int avs_register_component(struct device *dev, const char *name, 1383 + struct snd_soc_component_driver *drv, 1384 + struct snd_soc_dai_driver *cpu_dais, int num_cpu_dais) 1385 1385 { 1386 1386 struct avs_soc_component *acomp; 1387 1387 int ret; ··· 1390 1390 if (!acomp) 1391 1391 return -ENOMEM; 1392 1392 1393 - ret = snd_soc_component_initialize(&acomp->base, drv, dev); 1394 - if (ret < 0) 1395 - return ret; 1393 + acomp->base.name = devm_kstrdup(dev, name, GFP_KERNEL); 1394 + if (!acomp->base.name) 1395 + return -ENOMEM; 1396 1396 1397 - /* force name change after ASoC is done with its init */ 1398 - acomp->base.name = name; 1399 1397 INIT_LIST_HEAD(&acomp->node); 1400 1398 1401 1399 drv->use_dai_pcm_id = !obsolete_card_names; 1400 + 1401 + ret = snd_soc_component_initialize(&acomp->base, drv, dev); 1402 + if (ret < 0) 1403 + return ret; 1402 1404 1403 1405 return snd_soc_add_component(&acomp->base, cpu_dais, num_cpu_dais); 1404 1406 } ··· 1428 1426 }, 1429 1427 }; 1430 1428 1431 - int avs_dmic_platform_register(struct avs_dev *adev, const char *name) 1429 + int avs_register_dmic_component(struct avs_dev *adev, const char *name) 1432 1430 { 1433 1431 const struct snd_soc_dai_ops *ops; 1434 1432 ··· 1439 1437 1440 1438 dmic_cpu_dais[0].ops = ops; 1441 1439 dmic_cpu_dais[1].ops = ops; 1442 - return avs_soc_component_register(adev->dev, name, &avs_component_driver, dmic_cpu_dais, 1443 - ARRAY_SIZE(dmic_cpu_dais)); 1440 + return avs_register_component(adev->dev, name, &avs_component_driver, dmic_cpu_dais, 1441 + ARRAY_SIZE(dmic_cpu_dais)); 1444 1442 } 1445 1443 1446 1444 static const struct snd_soc_dai_driver i2s_dai_template = { ··· 1472 1470 }, 1473 1471 }; 1474 1472 1475 - int avs_i2s_platform_register(struct avs_dev *adev, const char *name, unsigned long port_mask, 1476 - unsigned long *tdms) 1473 + int avs_register_i2s_component(struct avs_dev *adev, const char *name, unsigned long port_mask, 1474 + unsigned long *tdms) 1477 1475 { 1478 1476 struct snd_soc_dai_driver *cpus, *dai; 1479 1477 const struct snd_soc_dai_ops *ops; ··· 1539 1537 } 1540 1538 1541 1539 plat_register: 1542 - return avs_soc_component_register(adev->dev, name, &avs_component_driver, cpus, cpu_count); 1540 + return avs_register_component(adev->dev, name, &avs_component_driver, cpus, cpu_count); 1543 1541 } 1544 1542 1545 1543 /* HD-Audio CPU DAI template */ ··· 1764 1762 .topology_name_prefix = "intel/avs", 1765 1763 }; 1766 1764 1767 - int avs_hda_platform_register(struct avs_dev *adev, const char *name) 1765 + int avs_register_hda_component(struct avs_dev *adev, const char *name) 1768 1766 { 1769 - return avs_soc_component_register(adev->dev, name, 1770 - &avs_hda_component_driver, NULL, 0); 1767 + return avs_register_component(adev->dev, name, &avs_hda_component_driver, NULL, 0); 1771 1768 }
+19 -4
sound/soc/intel/avs/probes.c
··· 11 11 #include <sound/hdaudio.h> 12 12 #include <sound/soc.h> 13 13 #include "avs.h" 14 + #include "debug.h" 14 15 #include "messages.h" 15 16 16 17 static int avs_dsp_init_probe(struct avs_dev *adev, union avs_connector_node_id node_id, ··· 285 284 }, 286 285 }; 287 286 288 - static struct snd_soc_component_driver avs_probe_component_driver = { 287 + static const struct snd_soc_component_driver avs_probe_component_driver = { 289 288 .name = "avs-probe-compr", 290 289 .compress_ops = &avs_probe_compress_ops, 291 290 .module_get_upon_open = 1, /* increment refcount when a stream is opened */ 292 291 }; 293 292 294 - int avs_probe_platform_register(struct avs_dev *adev, const char *name) 293 + int avs_register_probe_component(struct avs_dev *adev, const char *name) 295 294 { 296 - return avs_soc_component_register(adev->dev, name, &avs_probe_component_driver, 297 - probe_cpu_dais, ARRAY_SIZE(probe_cpu_dais)); 295 + struct snd_soc_component *component; 296 + int ret; 297 + 298 + component = devm_kzalloc(adev->dev, sizeof(*component), GFP_KERNEL); 299 + if (!component) 300 + return -ENOMEM; 301 + 302 + component->name = devm_kstrdup(adev->dev, name, GFP_KERNEL); 303 + if (!component->name) 304 + return -ENOMEM; 305 + 306 + ret = snd_soc_component_initialize(component, &avs_probe_component_driver, adev->dev); 307 + if (ret) 308 + return ret; 309 + 310 + return snd_soc_add_component(component, probe_cpu_dais, ARRAY_SIZE(probe_cpu_dais)); 298 311 }
+1
sound/soc/intel/avs/ptl.c
··· 8 8 9 9 #include <sound/hdaudio_ext.h> 10 10 #include "avs.h" 11 + #include "debug.h" 11 12 #include "registers.h" 12 13 #include "trace.h" 13 14
+1
sound/soc/intel/avs/skl.c
··· 11 11 #include <sound/hdaudio_ext.h> 12 12 #include "avs.h" 13 13 #include "cldma.h" 14 + #include "debug.h" 14 15 #include "messages.h" 15 16 #include "registers.h" 16 17
+1
sound/soc/intel/avs/tgl.c
··· 8 8 9 9 #include <linux/pci.h> 10 10 #include "avs.h" 11 + #include "debug.h" 11 12 #include "messages.h" 12 13 13 14 #define CPUID_TSC_LEAF 0x15