forked from thesofproject/sof
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagent.h
More file actions
66 lines (51 loc) · 1.49 KB
/
agent.h
File metadata and controls
66 lines (51 loc) · 1.49 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
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2017 Intel Corporation. All rights reserved.
*
* Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
*/
#ifndef __SOF_LIB_AGENT_H__
#define __SOF_LIB_AGENT_H__
#include <rtos/atomic.h>
#include <sof/lib/memory.h>
#include <sof/lib/perf_cnt.h>
#include <rtos/task.h>
#include <rtos/sof.h>
#include <stdbool.h>
#include <stdint.h>
struct sof;
/* simple agent */
struct sa {
uint64_t last_check; /* time of last activity checking */
uint64_t panic_timeout; /* threshold of panic */
uint64_t warn_timeout; /* threshold of warning */
#if CONFIG_PERFORMANCE_COUNTERS
struct perf_cnt_data pcd;
#endif
struct task work;
atomic_t panic_cnt; /**< ref counter for panic_on_delay property */
bool panic_on_delay; /**< emits panic on delay if true */
};
#if CONFIG_HAVE_AGENT
/**
* Enables or disables panic on agent delay.
* @param enabled True for panic enabling, false otherwise.
*/
static inline void sa_set_panic_on_delay(bool enabled)
{
struct sa *sa = sof_get()->sa;
if (enabled)
atomic_add(&sa->panic_cnt, 1);
else
atomic_sub(&sa->panic_cnt, 1);
/* enable panic only if no refs */
sa->panic_on_delay = !atomic_read(&sa->panic_cnt);
}
void sa_init(struct sof *sof, uint64_t timeout);
void sa_exit(struct sof *sof);
#else
static inline void sa_init(struct sof *sof, uint64_t timeout) { }
static inline void sa_exit(struct sof *sof) { }
static inline void sa_set_panic_on_delay(bool enabled) { }
#endif
#endif /* __SOF_LIB_AGENT_H__ */