1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#ifndef KFD_DEVICE_QUEUE_MANAGER_H_
25#define KFD_DEVICE_QUEUE_MANAGER_H_
26
27#include <linux/rwsem.h>
28#include <linux/list.h>
29#include "kfd_priv.h"
30#include "kfd_mqd_manager.h"
31
32#define QUEUE_PREEMPT_DEFAULT_TIMEOUT_MS (500)
33#define CIK_VMID_NUM (8)
34#define KFD_VMID_START_OFFSET (8)
35#define VMID_PER_DEVICE CIK_VMID_NUM
36#define KFD_DQM_FIRST_PIPE (0)
37#define CIK_SDMA_QUEUES (4)
38#define CIK_SDMA_QUEUES_PER_ENGINE (2)
39#define CIK_SDMA_ENGINE_NUM (2)
40
41struct device_process_node {
42 struct qcm_process_device *qpd;
43 struct list_head list;
44};
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84struct device_queue_manager_ops {
85 int (*create_queue)(struct device_queue_manager *dqm,
86 struct queue *q,
87 struct qcm_process_device *qpd,
88 int *allocate_vmid);
89
90 int (*destroy_queue)(struct device_queue_manager *dqm,
91 struct qcm_process_device *qpd,
92 struct queue *q);
93
94 int (*update_queue)(struct device_queue_manager *dqm,
95 struct queue *q);
96
97 struct mqd_manager * (*get_mqd_manager)
98 (struct device_queue_manager *dqm,
99 enum KFD_MQD_TYPE type);
100
101 int (*register_process)(struct device_queue_manager *dqm,
102 struct qcm_process_device *qpd);
103
104 int (*unregister_process)(struct device_queue_manager *dqm,
105 struct qcm_process_device *qpd);
106
107 int (*initialize)(struct device_queue_manager *dqm);
108 int (*start)(struct device_queue_manager *dqm);
109 int (*stop)(struct device_queue_manager *dqm);
110 void (*uninitialize)(struct device_queue_manager *dqm);
111 int (*create_kernel_queue)(struct device_queue_manager *dqm,
112 struct kernel_queue *kq,
113 struct qcm_process_device *qpd);
114
115 void (*destroy_kernel_queue)(struct device_queue_manager *dqm,
116 struct kernel_queue *kq,
117 struct qcm_process_device *qpd);
118
119 bool (*set_cache_memory_policy)(struct device_queue_manager *dqm,
120 struct qcm_process_device *qpd,
121 enum cache_policy default_policy,
122 enum cache_policy alternate_policy,
123 void __user *alternate_aperture_base,
124 uint64_t alternate_aperture_size);
125};
126
127struct device_queue_manager_asic_ops {
128 int (*register_process)(struct device_queue_manager *dqm,
129 struct qcm_process_device *qpd);
130 int (*initialize)(struct device_queue_manager *dqm);
131 bool (*set_cache_memory_policy)(struct device_queue_manager *dqm,
132 struct qcm_process_device *qpd,
133 enum cache_policy default_policy,
134 enum cache_policy alternate_policy,
135 void __user *alternate_aperture_base,
136 uint64_t alternate_aperture_size);
137 void (*init_sdma_vm)(struct device_queue_manager *dqm,
138 struct queue *q,
139 struct qcm_process_device *qpd);
140};
141
142
143
144
145
146
147
148
149
150
151
152
153
154struct device_queue_manager {
155 struct device_queue_manager_ops ops;
156 struct device_queue_manager_asic_ops ops_asic_specific;
157
158 struct mqd_manager *mqds[KFD_MQD_TYPE_MAX];
159 struct packet_manager packets;
160 struct kfd_dev *dev;
161 struct mutex lock;
162 struct list_head queues;
163 unsigned int processes_count;
164 unsigned int queue_count;
165 unsigned int sdma_queue_count;
166 unsigned int total_queue_count;
167 unsigned int next_pipe_to_allocate;
168 unsigned int *allocated_queues;
169 unsigned int sdma_bitmap;
170 unsigned int vmid_bitmap;
171 uint64_t pipelines_addr;
172 struct kfd_mem_obj *pipeline_mem;
173 uint64_t fence_gpu_addr;
174 unsigned int *fence_addr;
175 struct kfd_mem_obj *fence_mem;
176 bool active_runlist;
177};
178
179void device_queue_manager_init_cik(struct device_queue_manager_asic_ops *ops);
180void device_queue_manager_init_vi(struct device_queue_manager_asic_ops *ops);
181void program_sh_mem_settings(struct device_queue_manager *dqm,
182 struct qcm_process_device *qpd);
183unsigned int get_queues_num(struct device_queue_manager *dqm);
184unsigned int get_queues_per_pipe(struct device_queue_manager *dqm);
185unsigned int get_pipes_per_mec(struct device_queue_manager *dqm);
186
187static inline unsigned int get_sh_mem_bases_32(struct kfd_process_device *pdd)
188{
189 return (pdd->lds_base >> 16) & 0xFF;
190}
191
192static inline unsigned int
193get_sh_mem_bases_nybble_64(struct kfd_process_device *pdd)
194{
195 return (pdd->lds_base >> 60) & 0x0E;
196}
197
198#endif
199