summaryrefslogtreecommitdiff
path: root/dvalin/kernel/drivers/gpu/arm/midgard/mali_kbase_vinstr.h
blob: 6747ec70a4061812ba1dd7645a45ee6831539599 (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
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
 *
 * (C) COPYRIGHT 2015-2018, 2020-2021 ARM Limited. All rights reserved.
 *
 * This program is free software and is provided to you under the terms of the
 * GNU General Public License version 2 as published by the Free Software
 * Foundation, and any use by you of this program is subject to the terms
 * of such GNU license.
 *
 * 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, you can access it online at
 * http://www.gnu.org/licenses/gpl-2.0.html.
 *
 */

/*
 * Vinstr, used to provide an ioctl for userspace access to periodic hardware
 * counters.
 */

#ifndef _KBASE_VINSTR_H_
#define _KBASE_VINSTR_H_

struct kbase_vinstr_context;
struct kbase_hwcnt_virtualizer;
struct kbase_ioctl_hwcnt_reader_setup;

/**
 * kbase_vinstr_init() - Initialise a vinstr context.
 * @hvirt:    Non-NULL pointer to the hardware counter virtualizer.
 * @out_vctx: Non-NULL pointer to where the pointer to the created vinstr
 *            context will be stored on success.
 *
 * On creation, the suspend count of the context will be 0.
 *
 * Return: 0 on success, else error code.
 */
int kbase_vinstr_init(
	struct kbase_hwcnt_virtualizer *hvirt,
	struct kbase_vinstr_context **out_vctx);

/**
 * kbase_vinstr_term() - Terminate a vinstr context.
 * @vctx: Pointer to the vinstr context to be terminated.
 */
void kbase_vinstr_term(struct kbase_vinstr_context *vctx);

/**
 * kbase_vinstr_suspend() - Increment the suspend count of the context.
 * @vctx: Non-NULL pointer to the vinstr context to be suspended.
 *
 * After this function call returns, it is guaranteed that all timers and
 * workers in vinstr will be cancelled, and will not be re-triggered until
 * after the context has been resumed. In effect, this means no new counter
 * dumps will occur for any existing or subsequently added periodic clients.
 */
void kbase_vinstr_suspend(struct kbase_vinstr_context *vctx);

/**
 * kbase_vinstr_resume() - Decrement the suspend count of the context.
 * @vctx: Non-NULL pointer to the vinstr context to be resumed.
 *
 * If a call to this function decrements the suspend count from 1 to 0, then
 * normal operation of vinstr will be resumed (i.e. counter dumps will once
 * again be automatically triggered for all periodic clients).
 *
 * It is only valid to call this function one time for each prior returned call
 * to kbase_vinstr_suspend.
 */
void kbase_vinstr_resume(struct kbase_vinstr_context *vctx);

/**
 * kbase_vinstr_hwcnt_reader_setup() - Set up a new hardware counter reader
 *                                     client.
 * @vinstr_ctx: Non-NULL pointer to the vinstr context.
 * @setup:      Non-NULL pointer to the hwcnt reader configuration.
 *
 * Return: file descriptor on success, else a (negative) error code.
 */
int kbase_vinstr_hwcnt_reader_setup(
	struct kbase_vinstr_context *vinstr_ctx,
	struct kbase_ioctl_hwcnt_reader_setup *setup);

#endif /* _KBASE_VINSTR_H_ */