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