forked from thesofproject/sof
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdram.c
More file actions
67 lines (51 loc) · 1.38 KB
/
dram.c
File metadata and controls
67 lines (51 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright(c) 2025 Intel Corporation.
#include <rtos/kernel.h>
#include <rtos/symbol.h>
#include <zephyr/logging/log.h>
#include <zephyr/sys/__assert.h>
LOG_MODULE_REGISTER(dram_debug, CONFIG_SOF_LOG_LEVEL);
static struct k_spinlock hot_path_lock;
static unsigned int hot_path_depth;
static const char *cold_path_fn;
static bool hot_path_confirmed;
void mem_cold_path_enter(const char *fn)
{
k_spinlock_key_t key = k_spin_lock(&hot_path_lock);
cold_path_fn = fn;
k_spin_unlock(&hot_path_lock, key);
}
EXPORT_SYMBOL(mem_cold_path_enter);
void mem_hot_path_start_watching(void)
{
k_spinlock_key_t key = k_spin_lock(&hot_path_lock);
if (!hot_path_depth++) {
cold_path_fn = NULL;
hot_path_confirmed = false;
}
k_spin_unlock(&hot_path_lock, key);
}
void mem_hot_path_confirm(void)
{
k_spinlock_key_t key = k_spin_lock(&hot_path_lock);
hot_path_confirmed = true;
k_spin_unlock(&hot_path_lock, key);
}
void mem_hot_path_stop_watching(void)
{
bool underrun, error;
k_spinlock_key_t key = k_spin_lock(&hot_path_lock);
if (hot_path_depth) {
underrun = false;
hot_path_depth--;
error = hot_path_confirmed && cold_path_fn;
} else {
error = underrun = true;
}
k_spin_unlock(&hot_path_lock, key);
if (underrun)
LOG_ERR("Hot path depth underrun!");
else
__ASSERT(!error, "Cold function %s() has run while on hot path!", cold_path_fn);
}