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