cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

intel_global_state.h (3020B)


      1/* SPDX-License-Identifier: MIT */
      2/*
      3 * Copyright © 2020 Intel Corporation
      4 */
      5
      6#ifndef __INTEL_GLOBAL_STATE_H__
      7#define __INTEL_GLOBAL_STATE_H__
      8
      9#include <linux/kref.h>
     10#include <linux/list.h>
     11
     12struct drm_i915_private;
     13struct intel_atomic_state;
     14struct intel_global_obj;
     15struct intel_global_state;
     16
     17struct intel_global_state_funcs {
     18	struct intel_global_state *(*atomic_duplicate_state)(struct intel_global_obj *obj);
     19	void (*atomic_destroy_state)(struct intel_global_obj *obj,
     20				     struct intel_global_state *state);
     21};
     22
     23struct intel_global_obj {
     24	struct list_head head;
     25	struct intel_global_state *state;
     26	const struct intel_global_state_funcs *funcs;
     27};
     28
     29#define intel_for_each_global_obj(obj, dev_priv) \
     30	list_for_each_entry(obj, &(dev_priv)->global_obj_list, head)
     31
     32#define for_each_new_global_obj_in_state(__state, obj, new_obj_state, __i) \
     33	for ((__i) = 0; \
     34	     (__i) < (__state)->num_global_objs && \
     35		     ((obj) = (__state)->global_objs[__i].ptr, \
     36		      (new_obj_state) = (__state)->global_objs[__i].new_state, 1); \
     37	     (__i)++) \
     38		for_each_if(obj)
     39
     40#define for_each_old_global_obj_in_state(__state, obj, new_obj_state, __i) \
     41	for ((__i) = 0; \
     42	     (__i) < (__state)->num_global_objs && \
     43		     ((obj) = (__state)->global_objs[__i].ptr, \
     44		      (new_obj_state) = (__state)->global_objs[__i].old_state, 1); \
     45	     (__i)++) \
     46		for_each_if(obj)
     47
     48#define for_each_oldnew_global_obj_in_state(__state, obj, old_obj_state, new_obj_state, __i) \
     49	for ((__i) = 0; \
     50	     (__i) < (__state)->num_global_objs && \
     51		     ((obj) = (__state)->global_objs[__i].ptr, \
     52		      (old_obj_state) = (__state)->global_objs[__i].old_state, \
     53		      (new_obj_state) = (__state)->global_objs[__i].new_state, 1); \
     54	     (__i)++) \
     55		for_each_if(obj)
     56
     57struct intel_global_state {
     58	struct intel_global_obj *obj;
     59	struct intel_atomic_state *state;
     60	struct kref ref;
     61	bool changed;
     62};
     63
     64struct __intel_global_objs_state {
     65	struct intel_global_obj *ptr;
     66	struct intel_global_state *state, *old_state, *new_state;
     67};
     68
     69void intel_atomic_global_obj_init(struct drm_i915_private *dev_priv,
     70				  struct intel_global_obj *obj,
     71				  struct intel_global_state *state,
     72				  const struct intel_global_state_funcs *funcs);
     73void intel_atomic_global_obj_cleanup(struct drm_i915_private *dev_priv);
     74
     75struct intel_global_state *
     76intel_atomic_get_global_obj_state(struct intel_atomic_state *state,
     77				  struct intel_global_obj *obj);
     78struct intel_global_state *
     79intel_atomic_get_old_global_obj_state(struct intel_atomic_state *state,
     80				      struct intel_global_obj *obj);
     81struct intel_global_state *
     82intel_atomic_get_new_global_obj_state(struct intel_atomic_state *state,
     83				      struct intel_global_obj *obj);
     84
     85void intel_atomic_swap_global_state(struct intel_atomic_state *state);
     86void intel_atomic_clear_global_state(struct intel_atomic_state *state);
     87int intel_atomic_lock_global_state(struct intel_global_state *obj_state);
     88int intel_atomic_serialize_global_state(struct intel_global_state *obj_state);
     89
     90#endif