18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: MIT */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright © 2019 Intel Corporation
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#ifndef __I915_PERF_H__
78c2ecf20Sopenharmony_ci#define __I915_PERF_H__
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/kref.h>
108c2ecf20Sopenharmony_ci#include <linux/types.h>
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include "i915_perf_types.h"
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_cistruct drm_device;
158c2ecf20Sopenharmony_cistruct drm_file;
168c2ecf20Sopenharmony_cistruct drm_i915_private;
178c2ecf20Sopenharmony_cistruct i915_oa_config;
188c2ecf20Sopenharmony_cistruct intel_context;
198c2ecf20Sopenharmony_cistruct intel_engine_cs;
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_civoid i915_perf_init(struct drm_i915_private *i915);
228c2ecf20Sopenharmony_civoid i915_perf_fini(struct drm_i915_private *i915);
238c2ecf20Sopenharmony_civoid i915_perf_register(struct drm_i915_private *i915);
248c2ecf20Sopenharmony_civoid i915_perf_unregister(struct drm_i915_private *i915);
258c2ecf20Sopenharmony_ciint i915_perf_ioctl_version(void);
268c2ecf20Sopenharmony_civoid i915_perf_sysctl_register(void);
278c2ecf20Sopenharmony_civoid i915_perf_sysctl_unregister(void);
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ciint i915_perf_open_ioctl(struct drm_device *dev, void *data,
308c2ecf20Sopenharmony_ci			 struct drm_file *file);
318c2ecf20Sopenharmony_ciint i915_perf_add_config_ioctl(struct drm_device *dev, void *data,
328c2ecf20Sopenharmony_ci			       struct drm_file *file);
338c2ecf20Sopenharmony_ciint i915_perf_remove_config_ioctl(struct drm_device *dev, void *data,
348c2ecf20Sopenharmony_ci				  struct drm_file *file);
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_civoid i915_oa_init_reg_state(const struct intel_context *ce,
378c2ecf20Sopenharmony_ci			    const struct intel_engine_cs *engine);
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_cistruct i915_oa_config *
408c2ecf20Sopenharmony_cii915_perf_get_oa_config(struct i915_perf *perf, int metrics_set);
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_cistatic inline struct i915_oa_config *
438c2ecf20Sopenharmony_cii915_oa_config_get(struct i915_oa_config *oa_config)
448c2ecf20Sopenharmony_ci{
458c2ecf20Sopenharmony_ci	if (kref_get_unless_zero(&oa_config->ref))
468c2ecf20Sopenharmony_ci		return oa_config;
478c2ecf20Sopenharmony_ci	else
488c2ecf20Sopenharmony_ci		return NULL;
498c2ecf20Sopenharmony_ci}
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_civoid i915_oa_config_release(struct kref *ref);
528c2ecf20Sopenharmony_cistatic inline void i915_oa_config_put(struct i915_oa_config *oa_config)
538c2ecf20Sopenharmony_ci{
548c2ecf20Sopenharmony_ci	if (!oa_config)
558c2ecf20Sopenharmony_ci		return;
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci	kref_put(&oa_config->ref, i915_oa_config_release);
588c2ecf20Sopenharmony_ci}
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci#endif /* __I915_PERF_H__ */
61