Home | History | Annotate | Line # | Download | only in gt
      1 /*	$NetBSD: intel_context_types.h,v 1.2 2021/12/18 23:45:30 riastradh Exp $	*/
      2 
      3 /*
      4  * SPDX-License-Identifier: MIT
      5  *
      6  * Copyright  2019 Intel Corporation
      7  */
      8 
      9 #ifndef __INTEL_CONTEXT_TYPES__
     10 #define __INTEL_CONTEXT_TYPES__
     11 
     12 #include <linux/kref.h>
     13 #include <linux/list.h>
     14 #include <linux/mutex.h>
     15 #include <linux/types.h>
     16 
     17 #include "i915_active_types.h"
     18 #include "i915_utils.h"
     19 #include "intel_engine_types.h"
     20 #include "intel_sseu.h"
     21 
     22 #define CONTEXT_REDZONE POISON_INUSE
     23 
     24 struct i915_gem_context;
     25 struct i915_vma;
     26 struct intel_context;
     27 struct intel_ring;
     28 
     29 struct intel_context_ops {
     30 	int (*alloc)(struct intel_context *ce);
     31 
     32 	int (*pin)(struct intel_context *ce);
     33 	void (*unpin)(struct intel_context *ce);
     34 
     35 	void (*enter)(struct intel_context *ce);
     36 	void (*exit)(struct intel_context *ce);
     37 
     38 	void (*reset)(struct intel_context *ce);
     39 	void (*destroy)(struct kref *kref);
     40 };
     41 
     42 struct intel_context {
     43 	struct kref ref;
     44 
     45 	struct intel_engine_cs *engine;
     46 	struct intel_engine_cs *inflight;
     47 #define intel_context_inflight(ce) ptr_mask_bits((ce)->inflight, 2)
     48 #define intel_context_inflight_count(ce) ptr_unmask_bits((ce)->inflight, 2)
     49 
     50 	struct i915_address_space *vm;
     51 	struct i915_gem_context __rcu *gem_context;
     52 
     53 	struct list_head signal_link;
     54 	struct list_head signals;
     55 
     56 	struct i915_vma *state;
     57 	struct intel_ring *ring;
     58 	struct intel_timeline *timeline;
     59 
     60 	unsigned long flags;
     61 #define CONTEXT_BARRIER_BIT		0
     62 #define CONTEXT_ALLOC_BIT		1
     63 #define CONTEXT_VALID_BIT		2
     64 #define CONTEXT_USE_SEMAPHORES		3
     65 #define CONTEXT_BANNED			4
     66 #define CONTEXT_FORCE_SINGLE_SUBMISSION	5
     67 #define CONTEXT_NOPREEMPT		6
     68 
     69 	u32 *lrc_reg_state;
     70 	u64 lrc_desc;
     71 	u32 tag; /* cookie passed to HW to track this context on submission */
     72 
     73 	unsigned int active_count; /* protected by timeline->mutex */
     74 
     75 	atomic_t pin_count;
     76 	struct mutex pin_mutex; /* guards pinning and associated on-gpuing */
     77 
     78 	/**
     79 	 * active: Active tracker for the rq activity (inc. external) on this
     80 	 * intel_context object.
     81 	 */
     82 	struct i915_active active;
     83 
     84 	const struct intel_context_ops *ops;
     85 
     86 	/** sseu: Control eu/slice partitioning */
     87 	struct intel_sseu sseu;
     88 };
     89 
     90 #endif /* __INTEL_CONTEXT_TYPES__ */
     91