aboutsummaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/msm/msm_evtlog.h
blob: 83512899b1e9b7d70dce6f1249006bbd15eda642 (plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#ifndef MSM_MSM_EVTLOG_H_
#define MSM_MSM_EVTLOG_H_

#include <linux/ktime.h>
#include <linux/atomic.h>
#include <linux/dcache.h>

/**
 * struct msm_evtlog_evt - Event log entry
 * @ktime:     Timestamp of event
 * @func:      Calling function name
 * @msg:       User provided string
 * @val1:      User provided value
 * @val2:      User provided value
 * @line:      Line number of caller
 * @pid:       Process id of logger
 */
struct msm_evtlog_evt {
	ktime_t ktime;
	const char *func;
	const char *msg;
	uint64_t val1;
	uint64_t val2;
	uint32_t line;
	uint32_t pid;
};

/**
 * struct msm_evtlog - current driver state information
 * @events:    Pointer to dynamically allocated event log buffer
 * @cnt:       Atomic number of events since clear. Can be used to calculate
 *             the current index. Note: The count does not wrap.
 *             Reset the event log by setting to zero.
 *             Used for lock-less producer synchronization.
 * @size:      Size of events array. Must be power of 2 to facilitate fast
 *             increments by using a bitmask to get rollover.
 * @dentry:    Filesystem entry of debugfs registration
 */
struct msm_evtlog {
	struct msm_evtlog_evt *events;
	atomic_t cnt;
	unsigned long size;
	struct dentry *dentry;
};

/**
 * msm_evtlog_init() - Create an event log, registered with debugfs.
 * @log:     Event log handle
 * @size:    Max # of events in buffer. Will be rounded up to power of 2.
 * @parent:  Parent directory entry for debugfs registration
 *
 * Return: error code.
 */
int msm_evtlog_init(struct msm_evtlog *log, int size, struct dentry *parent);

/**
 * msm_evtlog_destroy() - Destroy event log
 * @log:            Event log handle
 *
 * Unregisters debugfs node and frees memory.
 * Caller needs to make sure that log sampling has stopped.
 */
void msm_evtlog_destroy(struct msm_evtlog *log);

/**
 * msm_evtlog_sample() - Add entry to the event log
 * @evtlog:            Event log handle
 * @func:              Calling function name
 * @msg:               User provided string
 * @val1:              User provided value
 * @val2:              User provided value
 * @line:              Line number of caller
 */
void msm_evtlog_sample(
		struct msm_evtlog *log,
		const char *func,
		const char *msg,
		uint64_t val1,
		uint64_t val2,
		uint32_t line);

#endif /* MSM_MSM_EVTLOG_H_ */