drm/amdkfd: Add module parameter of send_sigterm
[deliverable/linux.git] / drivers / gpu / drm / amd / amdkfd / kfd_priv.h
1 /*
2 * Copyright 2014 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22
23 #ifndef KFD_PRIV_H_INCLUDED
24 #define KFD_PRIV_H_INCLUDED
25
26 #include <linux/hashtable.h>
27 #include <linux/mmu_notifier.h>
28 #include <linux/mutex.h>
29 #include <linux/types.h>
30 #include <linux/atomic.h>
31 #include <linux/workqueue.h>
32 #include <linux/spinlock.h>
33 #include <linux/kfd_ioctl.h>
34 #include <kgd_kfd_interface.h>
35
36 #define KFD_SYSFS_FILE_MODE 0444
37
38 #define KFD_MMAP_DOORBELL_MASK 0x8000000000000
39 #define KFD_MMAP_EVENTS_MASK 0x4000000000000
40
41 /*
42 * When working with cp scheduler we should assign the HIQ manually or via
43 * the radeon driver to a fixed hqd slot, here are the fixed HIQ hqd slot
44 * definitions for Kaveri. In Kaveri only the first ME queues participates
45 * in the cp scheduling taking that in mind we set the HIQ slot in the
46 * second ME.
47 */
48 #define KFD_CIK_HIQ_PIPE 4
49 #define KFD_CIK_HIQ_QUEUE 0
50
51 /* GPU ID hash width in bits */
52 #define KFD_GPU_ID_HASH_WIDTH 16
53
54 /* Macro for allocating structures */
55 #define kfd_alloc_struct(ptr_to_struct) \
56 ((typeof(ptr_to_struct)) kzalloc(sizeof(*ptr_to_struct), GFP_KERNEL))
57
58 #define KFD_MAX_NUM_OF_PROCESSES 512
59 #define KFD_MAX_NUM_OF_QUEUES_PER_PROCESS 1024
60
61 /*
62 * Kernel module parameter to specify maximum number of supported queues per
63 * device
64 */
65 extern int max_num_of_queues_per_device;
66
67 #define KFD_MAX_NUM_OF_QUEUES_PER_DEVICE_DEFAULT 4096
68 #define KFD_MAX_NUM_OF_QUEUES_PER_DEVICE \
69 (KFD_MAX_NUM_OF_PROCESSES * \
70 KFD_MAX_NUM_OF_QUEUES_PER_PROCESS)
71
72 #define KFD_KERNEL_QUEUE_SIZE 2048
73
74 /* Kernel module parameter to specify the scheduling policy */
75 extern int sched_policy;
76
77 /*
78 * Kernel module parameter to specify whether to send sigterm to HSA process on
79 * unhandled exception
80 */
81 extern int send_sigterm;
82
83 /**
84 * enum kfd_sched_policy
85 *
86 * @KFD_SCHED_POLICY_HWS: H/W scheduling policy known as command processor (cp)
87 * scheduling. In this scheduling mode we're using the firmware code to
88 * schedule the user mode queues and kernel queues such as HIQ and DIQ.
89 * the HIQ queue is used as a special queue that dispatches the configuration
90 * to the cp and the user mode queues list that are currently running.
91 * the DIQ queue is a debugging queue that dispatches debugging commands to the
92 * firmware.
93 * in this scheduling mode user mode queues over subscription feature is
94 * enabled.
95 *
96 * @KFD_SCHED_POLICY_HWS_NO_OVERSUBSCRIPTION: The same as above but the over
97 * subscription feature disabled.
98 *
99 * @KFD_SCHED_POLICY_NO_HWS: no H/W scheduling policy is a mode which directly
100 * set the command processor registers and sets the queues "manually". This
101 * mode is used *ONLY* for debugging proposes.
102 *
103 */
104 enum kfd_sched_policy {
105 KFD_SCHED_POLICY_HWS = 0,
106 KFD_SCHED_POLICY_HWS_NO_OVERSUBSCRIPTION,
107 KFD_SCHED_POLICY_NO_HWS
108 };
109
110 enum cache_policy {
111 cache_policy_coherent,
112 cache_policy_noncoherent
113 };
114
115 enum asic_family_type {
116 CHIP_KAVERI = 0,
117 CHIP_CARRIZO
118 };
119
120 struct kfd_event_interrupt_class {
121 bool (*interrupt_isr)(struct kfd_dev *dev,
122 const uint32_t *ih_ring_entry);
123 void (*interrupt_wq)(struct kfd_dev *dev,
124 const uint32_t *ih_ring_entry);
125 };
126
127 struct kfd_device_info {
128 unsigned int asic_family;
129 const struct kfd_event_interrupt_class *event_interrupt_class;
130 unsigned int max_pasid_bits;
131 size_t ih_ring_entry_size;
132 uint8_t num_of_watch_points;
133 uint16_t mqd_size_aligned;
134 };
135
136 struct kfd_mem_obj {
137 uint32_t range_start;
138 uint32_t range_end;
139 uint64_t gpu_addr;
140 uint32_t *cpu_ptr;
141 };
142
143 struct kfd_dev {
144 struct kgd_dev *kgd;
145
146 const struct kfd_device_info *device_info;
147 struct pci_dev *pdev;
148
149 unsigned int id; /* topology stub index */
150
151 phys_addr_t doorbell_base; /* Start of actual doorbells used by
152 * KFD. It is aligned for mapping
153 * into user mode
154 */
155 size_t doorbell_id_offset; /* Doorbell offset (from KFD doorbell
156 * to HW doorbell, GFX reserved some
157 * at the start)
158 */
159 size_t doorbell_process_limit; /* Number of processes we have doorbell
160 * space for.
161 */
162 u32 __iomem *doorbell_kernel_ptr; /* This is a pointer for a doorbells
163 * page used by kernel queue
164 */
165
166 struct kgd2kfd_shared_resources shared_resources;
167
168 const struct kfd2kgd_calls *kfd2kgd;
169 struct mutex doorbell_mutex;
170 unsigned long doorbell_available_index[DIV_ROUND_UP(
171 KFD_MAX_NUM_OF_QUEUES_PER_PROCESS, BITS_PER_LONG)];
172
173 void *gtt_mem;
174 uint64_t gtt_start_gpu_addr;
175 void *gtt_start_cpu_ptr;
176 void *gtt_sa_bitmap;
177 struct mutex gtt_sa_lock;
178 unsigned int gtt_sa_chunk_size;
179 unsigned int gtt_sa_num_of_chunks;
180
181 /* Interrupts */
182 void *interrupt_ring;
183 size_t interrupt_ring_size;
184 atomic_t interrupt_ring_rptr;
185 atomic_t interrupt_ring_wptr;
186 struct work_struct interrupt_work;
187 spinlock_t interrupt_lock;
188
189 /* QCM Device instance */
190 struct device_queue_manager *dqm;
191
192 bool init_complete;
193 /*
194 * Interrupts of interest to KFD are copied
195 * from the HW ring into a SW ring.
196 */
197 bool interrupts_active;
198 };
199
200 /* KGD2KFD callbacks */
201 void kgd2kfd_exit(void);
202 struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd,
203 struct pci_dev *pdev, const struct kfd2kgd_calls *f2g);
204 bool kgd2kfd_device_init(struct kfd_dev *kfd,
205 const struct kgd2kfd_shared_resources *gpu_resources);
206 void kgd2kfd_device_exit(struct kfd_dev *kfd);
207
208 enum kfd_mempool {
209 KFD_MEMPOOL_SYSTEM_CACHEABLE = 1,
210 KFD_MEMPOOL_SYSTEM_WRITECOMBINE = 2,
211 KFD_MEMPOOL_FRAMEBUFFER = 3,
212 };
213
214 /* Character device interface */
215 int kfd_chardev_init(void);
216 void kfd_chardev_exit(void);
217 struct device *kfd_chardev(void);
218
219 /**
220 * enum kfd_preempt_type_filter
221 *
222 * @KFD_PREEMPT_TYPE_FILTER_SINGLE_QUEUE: Preempts single queue.
223 *
224 * @KFD_PRERMPT_TYPE_FILTER_ALL_QUEUES: Preempts all queues in the
225 * running queues list.
226 *
227 * @KFD_PRERMPT_TYPE_FILTER_BY_PASID: Preempts queues that belongs to
228 * specific process.
229 *
230 */
231 enum kfd_preempt_type_filter {
232 KFD_PREEMPT_TYPE_FILTER_SINGLE_QUEUE,
233 KFD_PREEMPT_TYPE_FILTER_ALL_QUEUES,
234 KFD_PREEMPT_TYPE_FILTER_BY_PASID
235 };
236
237 enum kfd_preempt_type {
238 KFD_PREEMPT_TYPE_WAVEFRONT,
239 KFD_PREEMPT_TYPE_WAVEFRONT_RESET
240 };
241
242 /**
243 * enum kfd_queue_type
244 *
245 * @KFD_QUEUE_TYPE_COMPUTE: Regular user mode queue type.
246 *
247 * @KFD_QUEUE_TYPE_SDMA: Sdma user mode queue type.
248 *
249 * @KFD_QUEUE_TYPE_HIQ: HIQ queue type.
250 *
251 * @KFD_QUEUE_TYPE_DIQ: DIQ queue type.
252 */
253 enum kfd_queue_type {
254 KFD_QUEUE_TYPE_COMPUTE,
255 KFD_QUEUE_TYPE_SDMA,
256 KFD_QUEUE_TYPE_HIQ,
257 KFD_QUEUE_TYPE_DIQ
258 };
259
260 enum kfd_queue_format {
261 KFD_QUEUE_FORMAT_PM4,
262 KFD_QUEUE_FORMAT_AQL
263 };
264
265 /**
266 * struct queue_properties
267 *
268 * @type: The queue type.
269 *
270 * @queue_id: Queue identifier.
271 *
272 * @queue_address: Queue ring buffer address.
273 *
274 * @queue_size: Queue ring buffer size.
275 *
276 * @priority: Defines the queue priority relative to other queues in the
277 * process.
278 * This is just an indication and HW scheduling may override the priority as
279 * necessary while keeping the relative prioritization.
280 * the priority granularity is from 0 to f which f is the highest priority.
281 * currently all queues are initialized with the highest priority.
282 *
283 * @queue_percent: This field is partially implemented and currently a zero in
284 * this field defines that the queue is non active.
285 *
286 * @read_ptr: User space address which points to the number of dwords the
287 * cp read from the ring buffer. This field updates automatically by the H/W.
288 *
289 * @write_ptr: Defines the number of dwords written to the ring buffer.
290 *
291 * @doorbell_ptr: This field aim is to notify the H/W of new packet written to
292 * the queue ring buffer. This field should be similar to write_ptr and the user
293 * should update this field after he updated the write_ptr.
294 *
295 * @doorbell_off: The doorbell offset in the doorbell pci-bar.
296 *
297 * @is_interop: Defines if this is a interop queue. Interop queue means that the
298 * queue can access both graphics and compute resources.
299 *
300 * @is_active: Defines if the queue is active or not.
301 *
302 * @vmid: If the scheduling mode is no cp scheduling the field defines the vmid
303 * of the queue.
304 *
305 * This structure represents the queue properties for each queue no matter if
306 * it's user mode or kernel mode queue.
307 *
308 */
309 struct queue_properties {
310 enum kfd_queue_type type;
311 enum kfd_queue_format format;
312 unsigned int queue_id;
313 uint64_t queue_address;
314 uint64_t queue_size;
315 uint32_t priority;
316 uint32_t queue_percent;
317 uint32_t *read_ptr;
318 uint32_t *write_ptr;
319 uint32_t __iomem *doorbell_ptr;
320 uint32_t doorbell_off;
321 bool is_interop;
322 bool is_active;
323 /* Not relevant for user mode queues in cp scheduling */
324 unsigned int vmid;
325 /* Relevant only for sdma queues*/
326 uint32_t sdma_engine_id;
327 uint32_t sdma_queue_id;
328 uint32_t sdma_vm_addr;
329 /* Relevant only for VI */
330 uint64_t eop_ring_buffer_address;
331 uint32_t eop_ring_buffer_size;
332 uint64_t ctx_save_restore_area_address;
333 uint32_t ctx_save_restore_area_size;
334 };
335
336 /**
337 * struct queue
338 *
339 * @list: Queue linked list.
340 *
341 * @mqd: The queue MQD.
342 *
343 * @mqd_mem_obj: The MQD local gpu memory object.
344 *
345 * @gart_mqd_addr: The MQD gart mc address.
346 *
347 * @properties: The queue properties.
348 *
349 * @mec: Used only in no cp scheduling mode and identifies to micro engine id
350 * that the queue should be execute on.
351 *
352 * @pipe: Used only in no cp scheduling mode and identifies the queue's pipe id.
353 *
354 * @queue: Used only in no cp scheduliong mode and identifies the queue's slot.
355 *
356 * @process: The kfd process that created this queue.
357 *
358 * @device: The kfd device that created this queue.
359 *
360 * This structure represents user mode compute queues.
361 * It contains all the necessary data to handle such queues.
362 *
363 */
364
365 struct queue {
366 struct list_head list;
367 void *mqd;
368 struct kfd_mem_obj *mqd_mem_obj;
369 uint64_t gart_mqd_addr;
370 struct queue_properties properties;
371
372 uint32_t mec;
373 uint32_t pipe;
374 uint32_t queue;
375
376 unsigned int sdma_id;
377
378 struct kfd_process *process;
379 struct kfd_dev *device;
380 };
381
382 /*
383 * Please read the kfd_mqd_manager.h description.
384 */
385 enum KFD_MQD_TYPE {
386 KFD_MQD_TYPE_COMPUTE = 0, /* for no cp scheduling */
387 KFD_MQD_TYPE_HIQ, /* for hiq */
388 KFD_MQD_TYPE_CP, /* for cp queues and diq */
389 KFD_MQD_TYPE_SDMA, /* for sdma queues */
390 KFD_MQD_TYPE_MAX
391 };
392
393 struct scheduling_resources {
394 unsigned int vmid_mask;
395 enum kfd_queue_type type;
396 uint64_t queue_mask;
397 uint64_t gws_mask;
398 uint32_t oac_mask;
399 uint32_t gds_heap_base;
400 uint32_t gds_heap_size;
401 };
402
403 struct process_queue_manager {
404 /* data */
405 struct kfd_process *process;
406 unsigned int num_concurrent_processes;
407 struct list_head queues;
408 unsigned long *queue_slot_bitmap;
409 };
410
411 struct qcm_process_device {
412 /* The Device Queue Manager that owns this data */
413 struct device_queue_manager *dqm;
414 struct process_queue_manager *pqm;
415 /* Queues list */
416 struct list_head queues_list;
417 struct list_head priv_queue_list;
418
419 unsigned int queue_count;
420 unsigned int vmid;
421 bool is_debug;
422 /*
423 * All the memory management data should be here too
424 */
425 uint64_t gds_context_area;
426 uint32_t sh_mem_config;
427 uint32_t sh_mem_bases;
428 uint32_t sh_mem_ape1_base;
429 uint32_t sh_mem_ape1_limit;
430 uint32_t page_table_base;
431 uint32_t gds_size;
432 uint32_t num_gws;
433 uint32_t num_oac;
434 };
435
436 /* Data that is per-process-per device. */
437 struct kfd_process_device {
438 /*
439 * List of all per-device data for a process.
440 * Starts from kfd_process.per_device_data.
441 */
442 struct list_head per_device_list;
443
444 /* The device that owns this data. */
445 struct kfd_dev *dev;
446
447
448 /* per-process-per device QCM data structure */
449 struct qcm_process_device qpd;
450
451 /*Apertures*/
452 uint64_t lds_base;
453 uint64_t lds_limit;
454 uint64_t gpuvm_base;
455 uint64_t gpuvm_limit;
456 uint64_t scratch_base;
457 uint64_t scratch_limit;
458
459 /* Is this process/pasid bound to this device? (amd_iommu_bind_pasid) */
460 bool bound;
461 };
462
463 #define qpd_to_pdd(x) container_of(x, struct kfd_process_device, qpd)
464
465 /* Process data */
466 struct kfd_process {
467 /*
468 * kfd_process are stored in an mm_struct*->kfd_process*
469 * hash table (kfd_processes in kfd_process.c)
470 */
471 struct hlist_node kfd_processes;
472
473 struct mm_struct *mm;
474
475 struct mutex mutex;
476
477 /*
478 * In any process, the thread that started main() is the lead
479 * thread and outlives the rest.
480 * It is here because amd_iommu_bind_pasid wants a task_struct.
481 */
482 struct task_struct *lead_thread;
483
484 /* We want to receive a notification when the mm_struct is destroyed */
485 struct mmu_notifier mmu_notifier;
486
487 /* Use for delayed freeing of kfd_process structure */
488 struct rcu_head rcu;
489
490 unsigned int pasid;
491
492 /*
493 * List of kfd_process_device structures,
494 * one for each device the process is using.
495 */
496 struct list_head per_device_data;
497
498 struct process_queue_manager pqm;
499
500 /* The process's queues. */
501 size_t queue_array_size;
502
503 /* Size is queue_array_size, up to MAX_PROCESS_QUEUES. */
504 struct kfd_queue **queues;
505
506 unsigned long allocated_queue_bitmap[DIV_ROUND_UP(KFD_MAX_NUM_OF_QUEUES_PER_PROCESS, BITS_PER_LONG)];
507
508 /*Is the user space process 32 bit?*/
509 bool is_32bit_user_mode;
510
511 /* Event-related data */
512 struct mutex event_mutex;
513 /* All events in process hashed by ID, linked on kfd_event.events. */
514 DECLARE_HASHTABLE(events, 4);
515 struct list_head signal_event_pages; /* struct slot_page_header.
516 event_pages */
517 u32 next_nonsignal_event_id;
518 size_t signal_event_count;
519 };
520
521 /**
522 * Ioctl function type.
523 *
524 * \param filep pointer to file structure.
525 * \param p amdkfd process pointer.
526 * \param data pointer to arg that was copied from user.
527 */
528 typedef int amdkfd_ioctl_t(struct file *filep, struct kfd_process *p,
529 void *data);
530
531 struct amdkfd_ioctl_desc {
532 unsigned int cmd;
533 int flags;
534 amdkfd_ioctl_t *func;
535 unsigned int cmd_drv;
536 const char *name;
537 };
538
539 void kfd_process_create_wq(void);
540 void kfd_process_destroy_wq(void);
541 struct kfd_process *kfd_create_process(const struct task_struct *);
542 struct kfd_process *kfd_get_process(const struct task_struct *);
543 struct kfd_process *kfd_lookup_process_by_pasid(unsigned int pasid);
544
545 struct kfd_process_device *kfd_bind_process_to_device(struct kfd_dev *dev,
546 struct kfd_process *p);
547 void kfd_unbind_process_from_device(struct kfd_dev *dev, unsigned int pasid);
548 struct kfd_process_device *kfd_get_process_device_data(struct kfd_dev *dev,
549 struct kfd_process *p);
550 struct kfd_process_device *kfd_create_process_device_data(struct kfd_dev *dev,
551 struct kfd_process *p);
552
553 /* Process device data iterator */
554 struct kfd_process_device *kfd_get_first_process_device_data(struct kfd_process *p);
555 struct kfd_process_device *kfd_get_next_process_device_data(struct kfd_process *p,
556 struct kfd_process_device *pdd);
557 bool kfd_has_process_device_data(struct kfd_process *p);
558
559 /* PASIDs */
560 int kfd_pasid_init(void);
561 void kfd_pasid_exit(void);
562 bool kfd_set_pasid_limit(unsigned int new_limit);
563 unsigned int kfd_get_pasid_limit(void);
564 unsigned int kfd_pasid_alloc(void);
565 void kfd_pasid_free(unsigned int pasid);
566
567 /* Doorbells */
568 void kfd_doorbell_init(struct kfd_dev *kfd);
569 int kfd_doorbell_mmap(struct kfd_process *process, struct vm_area_struct *vma);
570 u32 __iomem *kfd_get_kernel_doorbell(struct kfd_dev *kfd,
571 unsigned int *doorbell_off);
572 void kfd_release_kernel_doorbell(struct kfd_dev *kfd, u32 __iomem *db_addr);
573 u32 read_kernel_doorbell(u32 __iomem *db);
574 void write_kernel_doorbell(u32 __iomem *db, u32 value);
575 unsigned int kfd_queue_id_to_doorbell(struct kfd_dev *kfd,
576 struct kfd_process *process,
577 unsigned int queue_id);
578
579 /* GTT Sub-Allocator */
580
581 int kfd_gtt_sa_allocate(struct kfd_dev *kfd, unsigned int size,
582 struct kfd_mem_obj **mem_obj);
583
584 int kfd_gtt_sa_free(struct kfd_dev *kfd, struct kfd_mem_obj *mem_obj);
585
586 extern struct device *kfd_device;
587
588 /* Topology */
589 int kfd_topology_init(void);
590 void kfd_topology_shutdown(void);
591 int kfd_topology_add_device(struct kfd_dev *gpu);
592 int kfd_topology_remove_device(struct kfd_dev *gpu);
593 struct kfd_dev *kfd_device_by_id(uint32_t gpu_id);
594 struct kfd_dev *kfd_device_by_pci_dev(const struct pci_dev *pdev);
595 struct kfd_dev *kfd_topology_enum_kfd_devices(uint8_t idx);
596
597 /* Interrupts */
598 int kfd_interrupt_init(struct kfd_dev *dev);
599 void kfd_interrupt_exit(struct kfd_dev *dev);
600 void kgd2kfd_interrupt(struct kfd_dev *kfd, const void *ih_ring_entry);
601 bool enqueue_ih_ring_entry(struct kfd_dev *kfd, const void *ih_ring_entry);
602 bool interrupt_is_wanted(struct kfd_dev *dev, const uint32_t *ih_ring_entry);
603
604 /* Power Management */
605 void kgd2kfd_suspend(struct kfd_dev *kfd);
606 int kgd2kfd_resume(struct kfd_dev *kfd);
607
608 /* amdkfd Apertures */
609 int kfd_init_apertures(struct kfd_process *process);
610
611 /* Queue Context Management */
612 inline uint32_t lower_32(uint64_t x);
613 inline uint32_t upper_32(uint64_t x);
614 struct cik_sdma_rlc_registers *get_sdma_mqd(void *mqd);
615 inline uint32_t get_sdma_base_addr(struct cik_sdma_rlc_registers *m);
616
617 int init_queue(struct queue **q, struct queue_properties properties);
618 void uninit_queue(struct queue *q);
619 void print_queue_properties(struct queue_properties *q);
620 void print_queue(struct queue *q);
621
622 struct mqd_manager *mqd_manager_init(enum KFD_MQD_TYPE type,
623 struct kfd_dev *dev);
624 struct mqd_manager *mqd_manager_init_cik(enum KFD_MQD_TYPE type,
625 struct kfd_dev *dev);
626 struct mqd_manager *mqd_manager_init_vi(enum KFD_MQD_TYPE type,
627 struct kfd_dev *dev);
628 struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev);
629 void device_queue_manager_uninit(struct device_queue_manager *dqm);
630 struct kernel_queue *kernel_queue_init(struct kfd_dev *dev,
631 enum kfd_queue_type type);
632 void kernel_queue_uninit(struct kernel_queue *kq);
633
634 /* Process Queue Manager */
635 struct process_queue_node {
636 struct queue *q;
637 struct kernel_queue *kq;
638 struct list_head process_queue_list;
639 };
640
641 int pqm_init(struct process_queue_manager *pqm, struct kfd_process *p);
642 void pqm_uninit(struct process_queue_manager *pqm);
643 int pqm_create_queue(struct process_queue_manager *pqm,
644 struct kfd_dev *dev,
645 struct file *f,
646 struct queue_properties *properties,
647 unsigned int flags,
648 enum kfd_queue_type type,
649 unsigned int *qid);
650 int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid);
651 int pqm_update_queue(struct process_queue_manager *pqm, unsigned int qid,
652 struct queue_properties *p);
653
654 /* Packet Manager */
655
656 #define KFD_HIQ_TIMEOUT (500)
657
658 #define KFD_FENCE_COMPLETED (100)
659 #define KFD_FENCE_INIT (10)
660 #define KFD_UNMAP_LATENCY (150)
661
662 struct packet_manager {
663 struct device_queue_manager *dqm;
664 struct kernel_queue *priv_queue;
665 struct mutex lock;
666 bool allocated;
667 struct kfd_mem_obj *ib_buffer_obj;
668 };
669
670 int pm_init(struct packet_manager *pm, struct device_queue_manager *dqm);
671 void pm_uninit(struct packet_manager *pm);
672 int pm_send_set_resources(struct packet_manager *pm,
673 struct scheduling_resources *res);
674 int pm_send_runlist(struct packet_manager *pm, struct list_head *dqm_queues);
675 int pm_send_query_status(struct packet_manager *pm, uint64_t fence_address,
676 uint32_t fence_value);
677
678 int pm_send_unmap_queue(struct packet_manager *pm, enum kfd_queue_type type,
679 enum kfd_preempt_type_filter mode,
680 uint32_t filter_param, bool reset,
681 unsigned int sdma_engine);
682
683 void pm_release_ib(struct packet_manager *pm);
684
685 uint64_t kfd_get_number_elems(struct kfd_dev *kfd);
686 phys_addr_t kfd_get_process_doorbells(struct kfd_dev *dev,
687 struct kfd_process *process);
688
689 /* Events */
690 extern const struct kfd_event_interrupt_class event_interrupt_class_cik;
691 extern const struct kfd_device_global_init_class device_global_init_class_cik;
692
693 enum kfd_event_wait_result {
694 KFD_WAIT_COMPLETE,
695 KFD_WAIT_TIMEOUT,
696 KFD_WAIT_ERROR
697 };
698
699 void kfd_event_init_process(struct kfd_process *p);
700 void kfd_event_free_process(struct kfd_process *p);
701 int kfd_event_mmap(struct kfd_process *process, struct vm_area_struct *vma);
702 int kfd_wait_on_events(struct kfd_process *p,
703 uint32_t num_events, void __user *data,
704 bool all, uint32_t user_timeout_ms,
705 enum kfd_event_wait_result *wait_result);
706 void kfd_signal_event_interrupt(unsigned int pasid, uint32_t partial_id,
707 uint32_t valid_id_bits);
708 void kfd_signal_iommu_event(struct kfd_dev *dev,
709 unsigned int pasid, unsigned long address,
710 bool is_write_requested, bool is_execute_requested);
711 void kfd_signal_hw_exception_event(unsigned int pasid);
712 int kfd_set_event(struct kfd_process *p, uint32_t event_id);
713 int kfd_reset_event(struct kfd_process *p, uint32_t event_id);
714 int kfd_event_create(struct file *devkfd, struct kfd_process *p,
715 uint32_t event_type, bool auto_reset, uint32_t node_id,
716 uint32_t *event_id, uint32_t *event_trigger_data,
717 uint64_t *event_page_offset, uint32_t *event_slot_index);
718 int kfd_event_destroy(struct kfd_process *p, uint32_t event_id);
719
720 #endif
This page took 0.060225 seconds and 5 git commands to generate.