Skip to content

Commit f7de161

Browse files
crojewsk-intelbroonie
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent b3eefa5 commit f7de161

File tree

5 files changed

+26
-42
lines changed

5 files changed

+26
-42
lines changed

sound/soc/intel/avs/apl.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,18 @@ static int apl_log_buffer_status(struct avs_dev *adev, union avs_notify_msg *msg
5959

6060
memcpy_fromio(&layout, addr, sizeof(layout));
6161

62-
if (!kfifo_initialized(&adev->dbg.trace_fifo))
62+
if (!avs_logging_fw(adev))
6363
/* consume the logs regardless of consumer presence */
6464
goto update_read_ptr;
6565

6666
buf = apl_log_payload_addr(addr);
6767

6868
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);
7171
layout.read_ptr = 0;
7272
}
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);
7774

7875
update_read_ptr:
7976
writel(layout.write_ptr, addr);

sound/soc/intel/avs/avs.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,6 @@ struct avs_fw_entry {
9494
struct list_head node;
9595
};
9696

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-
10697
/*
10798
* struct avs_dev - Intel HD-Audio driver data
10899
*
@@ -146,7 +137,6 @@ struct avs_dev {
146137
spinlock_t path_list_lock;
147138
struct mutex path_mutex;
148139

149-
struct avs_debug dbg;
150140
spinlock_t trace_lock; /* serialize debug window I/O between each LOG_BUFFER_STATUS */
151141
#ifdef CONFIG_DEBUG_FS
152142
struct kfifo trace_fifo;
@@ -339,8 +329,6 @@ void avs_unregister_all_boards(struct avs_dev *adev);
339329

340330
/* Firmware tracing helpers */
341331

342-
unsigned int __kfifo_fromio(struct kfifo *fifo, const void __iomem *src, unsigned int len);
343-
344332
#define avs_log_buffer_size(adev) \
345333
((adev)->fw_cfg.trace_log_bytes / (adev)->hw_cfg.dsp_cores)
346334

@@ -356,9 +344,9 @@ static inline int avs_log_buffer_status_locked(struct avs_dev *adev, union avs_n
356344
unsigned long flags;
357345
int ret;
358346

359-
spin_lock_irqsave(&adev->dbg.trace_lock, flags);
347+
spin_lock_irqsave(&adev->trace_lock, flags);
360348
ret = avs_dsp_op(adev, log_buffer_status, msg);
361-
spin_unlock_irqrestore(&adev->dbg.trace_lock, flags);
349+
spin_unlock_irqrestore(&adev->trace_lock, flags);
362350

363351
return ret;
364352
}

sound/soc/intel/avs/debugfs.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,24 @@
1111
#include <linux/wait.h>
1212
#include "avs.h"
1313

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+
1432
bool avs_logging_fw(struct avs_dev *adev)
1533
{
1634
return kfifo_initialized(&adev->trace_fifo);

sound/soc/intel/avs/skl.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ skl_log_buffer_status(struct avs_dev *adev, union avs_notify_msg *msg)
5959
void __iomem *buf;
6060
u16 size, write, offset;
6161

62-
if (!kfifo_initialized(&adev->dbg.trace_fifo))
62+
if (!avs_logging_fw(adev))
6363
return 0;
6464

6565
size = avs_log_buffer_size(adev) / 2;
@@ -69,8 +69,7 @@ skl_log_buffer_status(struct avs_dev *adev, union avs_notify_msg *msg)
6969

7070
/* Address is guaranteed to exist in SRAM2. */
7171
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);
7473

7574
return 0;
7675
}

sound/soc/intel/avs/utils.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -300,21 +300,3 @@ void avs_release_firmwares(struct avs_dev *adev)
300300
kfree(entry);
301301
}
302302
}
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-
}

0 commit comments

Comments
 (0)