drm/i915: Remove i915->kernel_context
[linux-2.6-block.git] / drivers / gpu / drm / i915 / gt / intel_context_types.h
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_BARRIER_BIT             0
58 #define CONTEXT_ALLOC_BIT               1
59 #define CONTEXT_VALID_BIT               2
60 #define CONTEXT_USE_SEMAPHORES          3
61 #define CONTEXT_BANNED                  4
62 #define CONTEXT_FORCE_SINGLE_SUBMISSION 5
63 #define CONTEXT_NOPREEMPT               6
64
65         u32 *lrc_reg_state;
66         u64 lrc_desc;
67         u32 tag; /* cookie passed to HW to track this context on submission */
68
69         unsigned int active_count; /* protected by timeline->mutex */
70
71         atomic_t pin_count;
72         struct mutex pin_mutex; /* guards pinning and associated on-gpuing */
73
74         /**
75          * active: Active tracker for the rq activity (inc. external) on this
76          * intel_context object.
77          */
78         struct i915_active active;
79
80         const struct intel_context_ops *ops;
81
82         /** sseu: Control eu/slice partitioning */
83         struct intel_sseu sseu;
84 };
85
86 #endif /* __INTEL_CONTEXT_TYPES__ */