1db94e9f1SJani Nikula /* SPDX-License-Identifier: MIT */ 2db94e9f1SJani Nikula /* 3db94e9f1SJani Nikula * Copyright © 2019 Intel Corporation 4db94e9f1SJani Nikula */ 5db94e9f1SJani Nikula 6db94e9f1SJani Nikula #ifndef __I915_PERF_H__ 7db94e9f1SJani Nikula #define __I915_PERF_H__ 8db94e9f1SJani Nikula 96a45008aSLionel Landwerlin #include <linux/kref.h> 10db94e9f1SJani Nikula #include <linux/types.h> 11db94e9f1SJani Nikula 121d0f2ebfSLionel Landwerlin #include "i915_perf_types.h" 131d0f2ebfSLionel Landwerlin 14db94e9f1SJani Nikula struct drm_device; 15db94e9f1SJani Nikula struct drm_file; 16db94e9f1SJani Nikula struct drm_i915_private; 176a45008aSLionel Landwerlin struct i915_oa_config; 18db94e9f1SJani Nikula struct intel_context; 19db94e9f1SJani Nikula struct intel_engine_cs; 20db94e9f1SJani Nikula 21772a5803SUmesh Nerlige Ramappa int i915_perf_init(struct drm_i915_private *i915); 22db94e9f1SJani Nikula void i915_perf_fini(struct drm_i915_private *i915); 23db94e9f1SJani Nikula void i915_perf_register(struct drm_i915_private *i915); 24db94e9f1SJani Nikula void i915_perf_unregister(struct drm_i915_private *i915); 25*94d82e95SUmesh Nerlige Ramappa int i915_perf_ioctl_version(struct drm_i915_private *i915); 26a04ea6aeSJason Ekstrand int i915_perf_sysctl_register(void); 273dc716fdSVenkata Sandeep Dhanalakota void i915_perf_sysctl_unregister(void); 28db94e9f1SJani Nikula 29db94e9f1SJani Nikula int i915_perf_open_ioctl(struct drm_device *dev, void *data, 30db94e9f1SJani Nikula struct drm_file *file); 31db94e9f1SJani Nikula int i915_perf_add_config_ioctl(struct drm_device *dev, void *data, 32db94e9f1SJani Nikula struct drm_file *file); 33db94e9f1SJani Nikula int i915_perf_remove_config_ioctl(struct drm_device *dev, void *data, 34db94e9f1SJani Nikula struct drm_file *file); 356a45008aSLionel Landwerlin 367dc56af5SChris Wilson void i915_oa_init_reg_state(const struct intel_context *ce, 377dc56af5SChris Wilson const struct intel_engine_cs *engine); 38db94e9f1SJani Nikula 396a45008aSLionel Landwerlin struct i915_oa_config * 406a45008aSLionel Landwerlin i915_perf_get_oa_config(struct i915_perf *perf, int metrics_set); 416a45008aSLionel Landwerlin 426a45008aSLionel Landwerlin static inline struct i915_oa_config * 436a45008aSLionel Landwerlin i915_oa_config_get(struct i915_oa_config *oa_config) 446a45008aSLionel Landwerlin { 456a45008aSLionel Landwerlin if (kref_get_unless_zero(&oa_config->ref)) 466a45008aSLionel Landwerlin return oa_config; 476a45008aSLionel Landwerlin else 486a45008aSLionel Landwerlin return NULL; 496a45008aSLionel Landwerlin } 506a45008aSLionel Landwerlin 516a45008aSLionel Landwerlin void i915_oa_config_release(struct kref *ref); 526a45008aSLionel Landwerlin static inline void i915_oa_config_put(struct i915_oa_config *oa_config) 536a45008aSLionel Landwerlin { 546a45008aSLionel Landwerlin if (!oa_config) 556a45008aSLionel Landwerlin return; 566a45008aSLionel Landwerlin 576a45008aSLionel Landwerlin kref_put(&oa_config->ref, i915_oa_config_release); 586a45008aSLionel Landwerlin } 596a45008aSLionel Landwerlin 60bc7ed4d3SUmesh Nerlige Ramappa u32 i915_perf_oa_timestamp_frequency(struct drm_i915_private *i915); 61bc7ed4d3SUmesh Nerlige Ramappa 62db94e9f1SJani Nikula #endif /* __I915_PERF_H__ */ 63