blob: 882fdd0a7680044528e0e0c5b2c1d858100b4062 [file] [log] [blame]
Jani Nikuladb94e9f2019-08-08 16:42:44 +03001/* SPDX-License-Identifier: MIT */
2/*
3 * Copyright © 2019 Intel Corporation
4 */
5
6#ifndef __I915_PERF_H__
7#define __I915_PERF_H__
8
Lionel Landwerlin6a450082019-10-12 08:23:06 +01009#include <linux/kref.h>
Jani Nikuladb94e9f2019-08-08 16:42:44 +030010#include <linux/types.h>
11
Lionel Landwerlin1d0f2eb2019-09-09 12:31:09 +030012#include "i915_perf_types.h"
13
Jani Nikuladb94e9f2019-08-08 16:42:44 +030014struct drm_device;
15struct drm_file;
16struct drm_i915_private;
Lionel Landwerlin6a450082019-10-12 08:23:06 +010017struct i915_oa_config;
Jani Nikuladb94e9f2019-08-08 16:42:44 +030018struct intel_context;
19struct intel_engine_cs;
20
21void i915_perf_init(struct drm_i915_private *i915);
22void i915_perf_fini(struct drm_i915_private *i915);
23void i915_perf_register(struct drm_i915_private *i915);
24void i915_perf_unregister(struct drm_i915_private *i915);
Lionel Landwerlinb8d49f22019-10-14 21:14:01 +010025int i915_perf_ioctl_version(void);
Venkata Sandeep Dhanalakota3dc716fd2019-12-13 07:51:51 -080026void i915_perf_sysctl_register(void);
27void i915_perf_sysctl_unregister(void);
Jani Nikuladb94e9f2019-08-08 16:42:44 +030028
29int i915_perf_open_ioctl(struct drm_device *dev, void *data,
30 struct drm_file *file);
31int i915_perf_add_config_ioctl(struct drm_device *dev, void *data,
32 struct drm_file *file);
33int i915_perf_remove_config_ioctl(struct drm_device *dev, void *data,
34 struct drm_file *file);
Lionel Landwerlin6a450082019-10-12 08:23:06 +010035
Chris Wilson7dc56af2019-09-24 15:59:50 +010036void i915_oa_init_reg_state(const struct intel_context *ce,
37 const struct intel_engine_cs *engine);
Jani Nikuladb94e9f2019-08-08 16:42:44 +030038
Lionel Landwerlin6a450082019-10-12 08:23:06 +010039struct i915_oa_config *
40i915_perf_get_oa_config(struct i915_perf *perf, int metrics_set);
41
42static inline struct i915_oa_config *
43i915_oa_config_get(struct i915_oa_config *oa_config)
44{
45 if (kref_get_unless_zero(&oa_config->ref))
46 return oa_config;
47 else
48 return NULL;
49}
50
51void i915_oa_config_release(struct kref *ref);
52static inline void i915_oa_config_put(struct i915_oa_config *oa_config)
53{
54 if (!oa_config)
55 return;
56
57 kref_put(&oa_config->ref, i915_oa_config_release);
58}
59
Jani Nikuladb94e9f2019-08-08 16:42:44 +030060#endif /* __I915_PERF_H__ */