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

ASoC: Intel: avs: Drop usage of debug members in non-debug code

Switch 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.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20221202152841.672536-9-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Cezary Rojewski and committed by
Mark Brown
f7de161f b3eefa5d

+26 -42
+4 -7
sound/soc/intel/avs/apl.c
··· 59 59 60 60 memcpy_fromio(&layout, addr, sizeof(layout)); 61 61 62 - if (!kfifo_initialized(&adev->dbg.trace_fifo)) 62 + if (!avs_logging_fw(adev)) 63 63 /* consume the logs regardless of consumer presence */ 64 64 goto update_read_ptr; 65 65 66 66 buf = apl_log_payload_addr(addr); 67 67 68 68 if (layout.read_ptr > layout.write_ptr) { 69 - __kfifo_fromio(&adev->dbg.trace_fifo, buf + layout.read_ptr, 70 - apl_log_payload_size(adev) - layout.read_ptr); 69 + avs_dump_fw_log(adev, buf + layout.read_ptr, 70 + apl_log_payload_size(adev) - layout.read_ptr); 71 71 layout.read_ptr = 0; 72 72 } 73 - __kfifo_fromio(&adev->dbg.trace_fifo, buf + layout.read_ptr, 74 - layout.write_ptr - layout.read_ptr); 75 - 76 - wake_up(&adev->dbg.trace_waitq); 73 + avs_dump_fw_log_wakeup(adev, buf + layout.read_ptr, layout.write_ptr - layout.read_ptr); 77 74 78 75 update_read_ptr: 79 76 writel(layout.write_ptr, addr);
+2 -14
sound/soc/intel/avs/avs.h
··· 94 94 struct list_head node; 95 95 }; 96 96 97 - struct avs_debug { 98 - struct kfifo trace_fifo; 99 - spinlock_t trace_lock; /* serialize debug window I/O between each LOG_BUFFER_STATUS */ 100 - wait_queue_head_t trace_waitq; 101 - u32 aging_timer_period; 102 - u32 fifo_full_timer_period; 103 - u32 logged_resources; /* context dependent: core or library */ 104 - }; 105 - 106 97 /* 107 98 * struct avs_dev - Intel HD-Audio driver data 108 99 * ··· 137 146 spinlock_t path_list_lock; 138 147 struct mutex path_mutex; 139 148 140 - struct avs_debug dbg; 141 149 spinlock_t trace_lock; /* serialize debug window I/O between each LOG_BUFFER_STATUS */ 142 150 #ifdef CONFIG_DEBUG_FS 143 151 struct kfifo trace_fifo; ··· 329 339 330 340 /* Firmware tracing helpers */ 331 341 332 - unsigned int __kfifo_fromio(struct kfifo *fifo, const void __iomem *src, unsigned int len); 333 - 334 342 #define avs_log_buffer_size(adev) \ 335 343 ((adev)->fw_cfg.trace_log_bytes / (adev)->hw_cfg.dsp_cores) 336 344 ··· 344 356 unsigned long flags; 345 357 int ret; 346 358 347 - spin_lock_irqsave(&adev->dbg.trace_lock, flags); 359 + spin_lock_irqsave(&adev->trace_lock, flags); 348 360 ret = avs_dsp_op(adev, log_buffer_status, msg); 349 - spin_unlock_irqrestore(&adev->dbg.trace_lock, flags); 361 + spin_unlock_irqrestore(&adev->trace_lock, flags); 350 362 351 363 return ret; 352 364 }
+18
sound/soc/intel/avs/debugfs.c
··· 11 11 #include <linux/wait.h> 12 12 #include "avs.h" 13 13 14 + static unsigned int __kfifo_fromio(struct kfifo *fifo, const void __iomem *src, unsigned int len) 15 + { 16 + struct __kfifo *__fifo = &fifo->kfifo; 17 + unsigned int l, off; 18 + 19 + len = min(len, kfifo_avail(fifo)); 20 + off = __fifo->in & __fifo->mask; 21 + l = min(len, kfifo_size(fifo) - off); 22 + 23 + memcpy_fromio(__fifo->data + off, src, l); 24 + memcpy_fromio(__fifo->data, src + l, len - l); 25 + /* Make sure data copied from SRAM is visible to all CPUs. */ 26 + smp_mb(); 27 + __fifo->in += len; 28 + 29 + return len; 30 + } 31 + 14 32 bool avs_logging_fw(struct avs_dev *adev) 15 33 { 16 34 return kfifo_initialized(&adev->trace_fifo);
+2 -3
sound/soc/intel/avs/skl.c
··· 59 59 void __iomem *buf; 60 60 u16 size, write, offset; 61 61 62 - if (!kfifo_initialized(&adev->dbg.trace_fifo)) 62 + if (!avs_logging_fw(adev)) 63 63 return 0; 64 64 65 65 size = avs_log_buffer_size(adev) / 2; ··· 69 69 70 70 /* Address is guaranteed to exist in SRAM2. */ 71 71 buf = avs_log_buffer_addr(adev, msg->log.core) + offset; 72 - __kfifo_fromio(&adev->dbg.trace_fifo, buf, size); 73 - wake_up(&adev->dbg.trace_waitq); 72 + avs_dump_fw_log_wakeup(adev, buf, size); 74 73 75 74 return 0; 76 75 }
-18
sound/soc/intel/avs/utils.c
··· 300 300 kfree(entry); 301 301 } 302 302 } 303 - 304 - unsigned int __kfifo_fromio(struct kfifo *fifo, const void __iomem *src, unsigned int len) 305 - { 306 - struct __kfifo *__fifo = &fifo->kfifo; 307 - unsigned int l, off; 308 - 309 - len = min(len, kfifo_avail(fifo)); 310 - off = __fifo->in & __fifo->mask; 311 - l = min(len, kfifo_size(fifo) - off); 312 - 313 - memcpy_fromio(__fifo->data + off, src, l); 314 - memcpy_fromio(__fifo->data, src + l, len - l); 315 - /* Make sure data copied from SRAM is visible to all CPUs. */ 316 - smp_mb(); 317 - __fifo->in += len; 318 - 319 - return len; 320 - }