Linux Audio

Check our new training course

Loading...
Note: File does not exist in v5.4.
 1/* SPDX-License-Identifier: GPL-2.0-only */
 2/* Copyright(c) 2023 Intel Corporation */
 3
 4#ifndef ADF_HEARTBEAT_H_
 5#define ADF_HEARTBEAT_H_
 6
 7#include <linux/types.h>
 8
 9struct adf_accel_dev;
10struct dentry;
11
12#define ADF_CFG_HB_TIMER_MIN_MS 200
13#define ADF_CFG_HB_TIMER_DEFAULT_MS 500
14#define ADF_CFG_HB_COUNT_THRESHOLD 3
15
16enum adf_device_heartbeat_status {
17	HB_DEV_UNRESPONSIVE = 0,
18	HB_DEV_ALIVE,
19	HB_DEV_UNSUPPORTED,
20};
21
22struct adf_heartbeat {
23	unsigned int hb_sent_counter;
24	unsigned int hb_failed_counter;
25	unsigned int hb_timer;
26	u64 last_hb_check_time;
27	bool ctrs_cnt_checked;
28	struct hb_dma_addr {
29		dma_addr_t phy_addr;
30		void *virt_addr;
31	} dma;
32	struct {
33		struct dentry *base_dir;
34		struct dentry *status;
35		struct dentry *cfg;
36		struct dentry *sent;
37		struct dentry *failed;
38	} dbgfs;
39};
40
41#ifdef CONFIG_DEBUG_FS
42int adf_heartbeat_init(struct adf_accel_dev *accel_dev);
43int adf_heartbeat_start(struct adf_accel_dev *accel_dev);
44void adf_heartbeat_shutdown(struct adf_accel_dev *accel_dev);
45
46int adf_heartbeat_ms_to_ticks(struct adf_accel_dev *accel_dev, unsigned int time_ms,
47			      uint32_t *value);
48int adf_heartbeat_save_cfg_param(struct adf_accel_dev *accel_dev,
49				 unsigned int timer_ms);
50void adf_heartbeat_status(struct adf_accel_dev *accel_dev,
51			  enum adf_device_heartbeat_status *hb_status);
52void adf_heartbeat_check_ctrs(struct adf_accel_dev *accel_dev);
53
54#else
55static inline int adf_heartbeat_init(struct adf_accel_dev *accel_dev)
56{
57	return 0;
58}
59
60static inline int adf_heartbeat_start(struct adf_accel_dev *accel_dev)
61{
62	return 0;
63}
64
65static inline void adf_heartbeat_shutdown(struct adf_accel_dev *accel_dev)
66{
67}
68
69static inline int adf_heartbeat_save_cfg_param(struct adf_accel_dev *accel_dev,
70					       unsigned int timer_ms)
71{
72	return 0;
73}
74
75static inline void adf_heartbeat_check_ctrs(struct adf_accel_dev *accel_dev)
76{
77}
78#endif
79#endif /* ADF_HEARTBEAT_H_ */