1 /* SPDX-License-Identifier: MIT */ 2 /* 3 * Copyright © 2019 Intel Corporation 4 */ 5 6 #ifndef __I915_PERF_H__ 7 #define __I915_PERF_H__ 8 9 #include <linux/kref.h> 10 #include <linux/types.h> 11 12 #include "i915_perf_types.h" 13 14 struct drm_device; 15 struct drm_file; 16 struct drm_i915_private; 17 struct i915_oa_config; 18 struct intel_context; 19 struct intel_engine_cs; 20 21 void i915_perf_init(struct drm_i915_private *i915); 22 void i915_perf_fini(struct drm_i915_private *i915); 23 void i915_perf_register(struct drm_i915_private *i915); 24 void i915_perf_unregister(struct drm_i915_private *i915); 25 int i915_perf_ioctl_version(void); 26 27 int i915_perf_open_ioctl(struct drm_device *dev, void *data, 28 struct drm_file *file); 29 int i915_perf_add_config_ioctl(struct drm_device *dev, void *data, 30 struct drm_file *file); 31 int i915_perf_remove_config_ioctl(struct drm_device *dev, void *data, 32 struct drm_file *file); 33 34 void i915_oa_init_reg_state(const struct intel_context *ce, 35 const struct intel_engine_cs *engine); 36 37 struct i915_oa_config * 38 i915_perf_get_oa_config(struct i915_perf *perf, int metrics_set); 39 40 static inline struct i915_oa_config * 41 i915_oa_config_get(struct i915_oa_config *oa_config) 42 { 43 if (kref_get_unless_zero(&oa_config->ref)) 44 return oa_config; 45 else 46 return NULL; 47 } 48 49 void i915_oa_config_release(struct kref *ref); 50 static inline void i915_oa_config_put(struct i915_oa_config *oa_config) 51 { 52 if (!oa_config) 53 return; 54 55 kref_put(&oa_config->ref, i915_oa_config_release); 56 } 57 58 #endif /* __I915_PERF_H__ */ 59