drm/amdkfd: Add memory exception handling
[linux/fpc-iii.git] / drivers / gpu / drm / amd / amdkfd / kfd_priv.h
blob35945032fff9e90fb1faab51a3bf6632d8644233
1 /*
2 * Copyright 2014 Advanced Micro Devices, Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
23 #ifndef KFD_PRIV_H_INCLUDED
24 #define KFD_PRIV_H_INCLUDED
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>
36 #define KFD_SYSFS_FILE_MODE 0444
38 #define KFD_MMAP_DOORBELL_MASK 0x8000000000000
39 #define KFD_MMAP_EVENTS_MASK 0x4000000000000
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.
48 #define KFD_CIK_HIQ_PIPE 4
49 #define KFD_CIK_HIQ_QUEUE 0
51 /* GPU ID hash width in bits */
52 #define KFD_GPU_ID_HASH_WIDTH 16
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))
58 #define KFD_MAX_NUM_OF_PROCESSES 512
59 #define KFD_MAX_NUM_OF_QUEUES_PER_PROCESS 1024
62 * Kernel module parameter to specify maximum number of supported queues per
63 * device
65 extern int max_num_of_queues_per_device;
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)
72 #define KFD_KERNEL_QUEUE_SIZE 2048
74 /* Kernel module parameter to specify the scheduling policy */
75 extern int sched_policy;
77 /**
78 * enum kfd_sched_policy
80 * @KFD_SCHED_POLICY_HWS: H/W scheduling policy known as command processor (cp)
81 * scheduling. In this scheduling mode we're using the firmware code to
82 * schedule the user mode queues and kernel queues such as HIQ and DIQ.
83 * the HIQ queue is used as a special queue that dispatches the configuration
84 * to the cp and the user mode queues list that are currently running.
85 * the DIQ queue is a debugging queue that dispatches debugging commands to the
86 * firmware.
87 * in this scheduling mode user mode queues over subscription feature is
88 * enabled.
90 * @KFD_SCHED_POLICY_HWS_NO_OVERSUBSCRIPTION: The same as above but the over
91 * subscription feature disabled.
93 * @KFD_SCHED_POLICY_NO_HWS: no H/W scheduling policy is a mode which directly
94 * set the command processor registers and sets the queues "manually". This
95 * mode is used *ONLY* for debugging proposes.
98 enum kfd_sched_policy {
99 KFD_SCHED_POLICY_HWS = 0,
100 KFD_SCHED_POLICY_HWS_NO_OVERSUBSCRIPTION,
101 KFD_SCHED_POLICY_NO_HWS
104 enum cache_policy {
105 cache_policy_coherent,
106 cache_policy_noncoherent
109 enum asic_family_type {
110 CHIP_KAVERI = 0,
111 CHIP_CARRIZO
114 struct kfd_event_interrupt_class {
115 bool (*interrupt_isr)(struct kfd_dev *dev,
116 const uint32_t *ih_ring_entry);
117 void (*interrupt_wq)(struct kfd_dev *dev,
118 const uint32_t *ih_ring_entry);
121 struct kfd_device_info {
122 unsigned int asic_family;
123 const struct kfd_event_interrupt_class *event_interrupt_class;
124 unsigned int max_pasid_bits;
125 size_t ih_ring_entry_size;
126 uint8_t num_of_watch_points;
127 uint16_t mqd_size_aligned;
130 struct kfd_mem_obj {
131 uint32_t range_start;
132 uint32_t range_end;
133 uint64_t gpu_addr;
134 uint32_t *cpu_ptr;
137 struct kfd_dev {
138 struct kgd_dev *kgd;
140 const struct kfd_device_info *device_info;
141 struct pci_dev *pdev;
143 unsigned int id; /* topology stub index */
145 phys_addr_t doorbell_base; /* Start of actual doorbells used by
146 * KFD. It is aligned for mapping
147 * into user mode
149 size_t doorbell_id_offset; /* Doorbell offset (from KFD doorbell
150 * to HW doorbell, GFX reserved some
151 * at the start)
153 size_t doorbell_process_limit; /* Number of processes we have doorbell
154 * space for.
156 u32 __iomem *doorbell_kernel_ptr; /* This is a pointer for a doorbells
157 * page used by kernel queue
160 struct kgd2kfd_shared_resources shared_resources;
162 const struct kfd2kgd_calls *kfd2kgd;
163 struct mutex doorbell_mutex;
164 unsigned long doorbell_available_index[DIV_ROUND_UP(
165 KFD_MAX_NUM_OF_QUEUES_PER_PROCESS, BITS_PER_LONG)];
167 void *gtt_mem;
168 uint64_t gtt_start_gpu_addr;
169 void *gtt_start_cpu_ptr;
170 void *gtt_sa_bitmap;
171 struct mutex gtt_sa_lock;
172 unsigned int gtt_sa_chunk_size;
173 unsigned int gtt_sa_num_of_chunks;
175 /* Interrupts */
176 void *interrupt_ring;
177 size_t interrupt_ring_size;
178 atomic_t interrupt_ring_rptr;
179 atomic_t interrupt_ring_wptr;
180 struct work_struct interrupt_work;
181 spinlock_t interrupt_lock;
183 /* QCM Device instance */
184 struct device_queue_manager *dqm;
186 bool init_complete;
188 * Interrupts of interest to KFD are copied
189 * from the HW ring into a SW ring.
191 bool interrupts_active;
194 /* KGD2KFD callbacks */
195 void kgd2kfd_exit(void);
196 struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd,
197 struct pci_dev *pdev, const struct kfd2kgd_calls *f2g);
198 bool kgd2kfd_device_init(struct kfd_dev *kfd,
199 const struct kgd2kfd_shared_resources *gpu_resources);
200 void kgd2kfd_device_exit(struct kfd_dev *kfd);
202 enum kfd_mempool {
203 KFD_MEMPOOL_SYSTEM_CACHEABLE = 1,
204 KFD_MEMPOOL_SYSTEM_WRITECOMBINE = 2,
205 KFD_MEMPOOL_FRAMEBUFFER = 3,
208 /* Character device interface */
209 int kfd_chardev_init(void);
210 void kfd_chardev_exit(void);
211 struct device *kfd_chardev(void);
214 * enum kfd_preempt_type_filter
216 * @KFD_PREEMPT_TYPE_FILTER_SINGLE_QUEUE: Preempts single queue.
218 * @KFD_PRERMPT_TYPE_FILTER_ALL_QUEUES: Preempts all queues in the
219 * running queues list.
221 * @KFD_PRERMPT_TYPE_FILTER_BY_PASID: Preempts queues that belongs to
222 * specific process.
225 enum kfd_preempt_type_filter {
226 KFD_PREEMPT_TYPE_FILTER_SINGLE_QUEUE,
227 KFD_PREEMPT_TYPE_FILTER_ALL_QUEUES,
228 KFD_PREEMPT_TYPE_FILTER_BY_PASID
231 enum kfd_preempt_type {
232 KFD_PREEMPT_TYPE_WAVEFRONT,
233 KFD_PREEMPT_TYPE_WAVEFRONT_RESET
237 * enum kfd_queue_type
239 * @KFD_QUEUE_TYPE_COMPUTE: Regular user mode queue type.
241 * @KFD_QUEUE_TYPE_SDMA: Sdma user mode queue type.
243 * @KFD_QUEUE_TYPE_HIQ: HIQ queue type.
245 * @KFD_QUEUE_TYPE_DIQ: DIQ queue type.
247 enum kfd_queue_type {
248 KFD_QUEUE_TYPE_COMPUTE,
249 KFD_QUEUE_TYPE_SDMA,
250 KFD_QUEUE_TYPE_HIQ,
251 KFD_QUEUE_TYPE_DIQ
254 enum kfd_queue_format {
255 KFD_QUEUE_FORMAT_PM4,
256 KFD_QUEUE_FORMAT_AQL
260 * struct queue_properties
262 * @type: The queue type.
264 * @queue_id: Queue identifier.
266 * @queue_address: Queue ring buffer address.
268 * @queue_size: Queue ring buffer size.
270 * @priority: Defines the queue priority relative to other queues in the
271 * process.
272 * This is just an indication and HW scheduling may override the priority as
273 * necessary while keeping the relative prioritization.
274 * the priority granularity is from 0 to f which f is the highest priority.
275 * currently all queues are initialized with the highest priority.
277 * @queue_percent: This field is partially implemented and currently a zero in
278 * this field defines that the queue is non active.
280 * @read_ptr: User space address which points to the number of dwords the
281 * cp read from the ring buffer. This field updates automatically by the H/W.
283 * @write_ptr: Defines the number of dwords written to the ring buffer.
285 * @doorbell_ptr: This field aim is to notify the H/W of new packet written to
286 * the queue ring buffer. This field should be similar to write_ptr and the user
287 * should update this field after he updated the write_ptr.
289 * @doorbell_off: The doorbell offset in the doorbell pci-bar.
291 * @is_interop: Defines if this is a interop queue. Interop queue means that the
292 * queue can access both graphics and compute resources.
294 * @is_active: Defines if the queue is active or not.
296 * @vmid: If the scheduling mode is no cp scheduling the field defines the vmid
297 * of the queue.
299 * This structure represents the queue properties for each queue no matter if
300 * it's user mode or kernel mode queue.
303 struct queue_properties {
304 enum kfd_queue_type type;
305 enum kfd_queue_format format;
306 unsigned int queue_id;
307 uint64_t queue_address;
308 uint64_t queue_size;
309 uint32_t priority;
310 uint32_t queue_percent;
311 uint32_t *read_ptr;
312 uint32_t *write_ptr;
313 uint32_t __iomem *doorbell_ptr;
314 uint32_t doorbell_off;
315 bool is_interop;
316 bool is_active;
317 /* Not relevant for user mode queues in cp scheduling */
318 unsigned int vmid;
319 /* Relevant only for sdma queues*/
320 uint32_t sdma_engine_id;
321 uint32_t sdma_queue_id;
322 uint32_t sdma_vm_addr;
323 /* Relevant only for VI */
324 uint64_t eop_ring_buffer_address;
325 uint32_t eop_ring_buffer_size;
326 uint64_t ctx_save_restore_area_address;
327 uint32_t ctx_save_restore_area_size;
331 * struct queue
333 * @list: Queue linked list.
335 * @mqd: The queue MQD.
337 * @mqd_mem_obj: The MQD local gpu memory object.
339 * @gart_mqd_addr: The MQD gart mc address.
341 * @properties: The queue properties.
343 * @mec: Used only in no cp scheduling mode and identifies to micro engine id
344 * that the queue should be execute on.
346 * @pipe: Used only in no cp scheduling mode and identifies the queue's pipe id.
348 * @queue: Used only in no cp scheduliong mode and identifies the queue's slot.
350 * @process: The kfd process that created this queue.
352 * @device: The kfd device that created this queue.
354 * This structure represents user mode compute queues.
355 * It contains all the necessary data to handle such queues.
359 struct queue {
360 struct list_head list;
361 void *mqd;
362 struct kfd_mem_obj *mqd_mem_obj;
363 uint64_t gart_mqd_addr;
364 struct queue_properties properties;
366 uint32_t mec;
367 uint32_t pipe;
368 uint32_t queue;
370 unsigned int sdma_id;
372 struct kfd_process *process;
373 struct kfd_dev *device;
377 * Please read the kfd_mqd_manager.h description.
379 enum KFD_MQD_TYPE {
380 KFD_MQD_TYPE_COMPUTE = 0, /* for no cp scheduling */
381 KFD_MQD_TYPE_HIQ, /* for hiq */
382 KFD_MQD_TYPE_CP, /* for cp queues and diq */
383 KFD_MQD_TYPE_SDMA, /* for sdma queues */
384 KFD_MQD_TYPE_MAX
387 struct scheduling_resources {
388 unsigned int vmid_mask;
389 enum kfd_queue_type type;
390 uint64_t queue_mask;
391 uint64_t gws_mask;
392 uint32_t oac_mask;
393 uint32_t gds_heap_base;
394 uint32_t gds_heap_size;
397 struct process_queue_manager {
398 /* data */
399 struct kfd_process *process;
400 unsigned int num_concurrent_processes;
401 struct list_head queues;
402 unsigned long *queue_slot_bitmap;
405 struct qcm_process_device {
406 /* The Device Queue Manager that owns this data */
407 struct device_queue_manager *dqm;
408 struct process_queue_manager *pqm;
409 /* Queues list */
410 struct list_head queues_list;
411 struct list_head priv_queue_list;
413 unsigned int queue_count;
414 unsigned int vmid;
415 bool is_debug;
417 * All the memory management data should be here too
419 uint64_t gds_context_area;
420 uint32_t sh_mem_config;
421 uint32_t sh_mem_bases;
422 uint32_t sh_mem_ape1_base;
423 uint32_t sh_mem_ape1_limit;
424 uint32_t page_table_base;
425 uint32_t gds_size;
426 uint32_t num_gws;
427 uint32_t num_oac;
430 /* Data that is per-process-per device. */
431 struct kfd_process_device {
433 * List of all per-device data for a process.
434 * Starts from kfd_process.per_device_data.
436 struct list_head per_device_list;
438 /* The device that owns this data. */
439 struct kfd_dev *dev;
442 /* per-process-per device QCM data structure */
443 struct qcm_process_device qpd;
445 /*Apertures*/
446 uint64_t lds_base;
447 uint64_t lds_limit;
448 uint64_t gpuvm_base;
449 uint64_t gpuvm_limit;
450 uint64_t scratch_base;
451 uint64_t scratch_limit;
453 /* Is this process/pasid bound to this device? (amd_iommu_bind_pasid) */
454 bool bound;
457 #define qpd_to_pdd(x) container_of(x, struct kfd_process_device, qpd)
459 /* Process data */
460 struct kfd_process {
462 * kfd_process are stored in an mm_struct*->kfd_process*
463 * hash table (kfd_processes in kfd_process.c)
465 struct hlist_node kfd_processes;
467 struct mm_struct *mm;
469 struct mutex mutex;
472 * In any process, the thread that started main() is the lead
473 * thread and outlives the rest.
474 * It is here because amd_iommu_bind_pasid wants a task_struct.
476 struct task_struct *lead_thread;
478 /* We want to receive a notification when the mm_struct is destroyed */
479 struct mmu_notifier mmu_notifier;
481 /* Use for delayed freeing of kfd_process structure */
482 struct rcu_head rcu;
484 unsigned int pasid;
487 * List of kfd_process_device structures,
488 * one for each device the process is using.
490 struct list_head per_device_data;
492 struct process_queue_manager pqm;
494 /* The process's queues. */
495 size_t queue_array_size;
497 /* Size is queue_array_size, up to MAX_PROCESS_QUEUES. */
498 struct kfd_queue **queues;
500 unsigned long allocated_queue_bitmap[DIV_ROUND_UP(KFD_MAX_NUM_OF_QUEUES_PER_PROCESS, BITS_PER_LONG)];
502 /*Is the user space process 32 bit?*/
503 bool is_32bit_user_mode;
505 /* Event-related data */
506 struct mutex event_mutex;
507 /* All events in process hashed by ID, linked on kfd_event.events. */
508 DECLARE_HASHTABLE(events, 4);
509 struct list_head signal_event_pages; /* struct slot_page_header.
510 event_pages */
511 u32 next_nonsignal_event_id;
512 size_t signal_event_count;
516 * Ioctl function type.
518 * \param filep pointer to file structure.
519 * \param p amdkfd process pointer.
520 * \param data pointer to arg that was copied from user.
522 typedef int amdkfd_ioctl_t(struct file *filep, struct kfd_process *p,
523 void *data);
525 struct amdkfd_ioctl_desc {
526 unsigned int cmd;
527 int flags;
528 amdkfd_ioctl_t *func;
529 unsigned int cmd_drv;
530 const char *name;
533 void kfd_process_create_wq(void);
534 void kfd_process_destroy_wq(void);
535 struct kfd_process *kfd_create_process(const struct task_struct *);
536 struct kfd_process *kfd_get_process(const struct task_struct *);
537 struct kfd_process *kfd_lookup_process_by_pasid(unsigned int pasid);
539 struct kfd_process_device *kfd_bind_process_to_device(struct kfd_dev *dev,
540 struct kfd_process *p);
541 void kfd_unbind_process_from_device(struct kfd_dev *dev, unsigned int pasid);
542 struct kfd_process_device *kfd_get_process_device_data(struct kfd_dev *dev,
543 struct kfd_process *p);
544 struct kfd_process_device *kfd_create_process_device_data(struct kfd_dev *dev,
545 struct kfd_process *p);
547 /* Process device data iterator */
548 struct kfd_process_device *kfd_get_first_process_device_data(struct kfd_process *p);
549 struct kfd_process_device *kfd_get_next_process_device_data(struct kfd_process *p,
550 struct kfd_process_device *pdd);
551 bool kfd_has_process_device_data(struct kfd_process *p);
553 /* PASIDs */
554 int kfd_pasid_init(void);
555 void kfd_pasid_exit(void);
556 bool kfd_set_pasid_limit(unsigned int new_limit);
557 unsigned int kfd_get_pasid_limit(void);
558 unsigned int kfd_pasid_alloc(void);
559 void kfd_pasid_free(unsigned int pasid);
561 /* Doorbells */
562 void kfd_doorbell_init(struct kfd_dev *kfd);
563 int kfd_doorbell_mmap(struct kfd_process *process, struct vm_area_struct *vma);
564 u32 __iomem *kfd_get_kernel_doorbell(struct kfd_dev *kfd,
565 unsigned int *doorbell_off);
566 void kfd_release_kernel_doorbell(struct kfd_dev *kfd, u32 __iomem *db_addr);
567 u32 read_kernel_doorbell(u32 __iomem *db);
568 void write_kernel_doorbell(u32 __iomem *db, u32 value);
569 unsigned int kfd_queue_id_to_doorbell(struct kfd_dev *kfd,
570 struct kfd_process *process,
571 unsigned int queue_id);
573 /* GTT Sub-Allocator */
575 int kfd_gtt_sa_allocate(struct kfd_dev *kfd, unsigned int size,
576 struct kfd_mem_obj **mem_obj);
578 int kfd_gtt_sa_free(struct kfd_dev *kfd, struct kfd_mem_obj *mem_obj);
580 extern struct device *kfd_device;
582 /* Topology */
583 int kfd_topology_init(void);
584 void kfd_topology_shutdown(void);
585 int kfd_topology_add_device(struct kfd_dev *gpu);
586 int kfd_topology_remove_device(struct kfd_dev *gpu);
587 struct kfd_dev *kfd_device_by_id(uint32_t gpu_id);
588 struct kfd_dev *kfd_device_by_pci_dev(const struct pci_dev *pdev);
589 struct kfd_dev *kfd_topology_enum_kfd_devices(uint8_t idx);
591 /* Interrupts */
592 int kfd_interrupt_init(struct kfd_dev *dev);
593 void kfd_interrupt_exit(struct kfd_dev *dev);
594 void kgd2kfd_interrupt(struct kfd_dev *kfd, const void *ih_ring_entry);
595 bool enqueue_ih_ring_entry(struct kfd_dev *kfd, const void *ih_ring_entry);
596 bool interrupt_is_wanted(struct kfd_dev *dev, const uint32_t *ih_ring_entry);
598 /* Power Management */
599 void kgd2kfd_suspend(struct kfd_dev *kfd);
600 int kgd2kfd_resume(struct kfd_dev *kfd);
602 /* amdkfd Apertures */
603 int kfd_init_apertures(struct kfd_process *process);
605 /* Queue Context Management */
606 inline uint32_t lower_32(uint64_t x);
607 inline uint32_t upper_32(uint64_t x);
608 struct cik_sdma_rlc_registers *get_sdma_mqd(void *mqd);
609 inline uint32_t get_sdma_base_addr(struct cik_sdma_rlc_registers *m);
611 int init_queue(struct queue **q, struct queue_properties properties);
612 void uninit_queue(struct queue *q);
613 void print_queue_properties(struct queue_properties *q);
614 void print_queue(struct queue *q);
616 struct mqd_manager *mqd_manager_init(enum KFD_MQD_TYPE type,
617 struct kfd_dev *dev);
618 struct mqd_manager *mqd_manager_init_cik(enum KFD_MQD_TYPE type,
619 struct kfd_dev *dev);
620 struct mqd_manager *mqd_manager_init_vi(enum KFD_MQD_TYPE type,
621 struct kfd_dev *dev);
622 struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev);
623 void device_queue_manager_uninit(struct device_queue_manager *dqm);
624 struct kernel_queue *kernel_queue_init(struct kfd_dev *dev,
625 enum kfd_queue_type type);
626 void kernel_queue_uninit(struct kernel_queue *kq);
628 /* Process Queue Manager */
629 struct process_queue_node {
630 struct queue *q;
631 struct kernel_queue *kq;
632 struct list_head process_queue_list;
635 int pqm_init(struct process_queue_manager *pqm, struct kfd_process *p);
636 void pqm_uninit(struct process_queue_manager *pqm);
637 int pqm_create_queue(struct process_queue_manager *pqm,
638 struct kfd_dev *dev,
639 struct file *f,
640 struct queue_properties *properties,
641 unsigned int flags,
642 enum kfd_queue_type type,
643 unsigned int *qid);
644 int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid);
645 int pqm_update_queue(struct process_queue_manager *pqm, unsigned int qid,
646 struct queue_properties *p);
648 /* Packet Manager */
650 #define KFD_HIQ_TIMEOUT (500)
652 #define KFD_FENCE_COMPLETED (100)
653 #define KFD_FENCE_INIT (10)
654 #define KFD_UNMAP_LATENCY (150)
656 struct packet_manager {
657 struct device_queue_manager *dqm;
658 struct kernel_queue *priv_queue;
659 struct mutex lock;
660 bool allocated;
661 struct kfd_mem_obj *ib_buffer_obj;
664 int pm_init(struct packet_manager *pm, struct device_queue_manager *dqm);
665 void pm_uninit(struct packet_manager *pm);
666 int pm_send_set_resources(struct packet_manager *pm,
667 struct scheduling_resources *res);
668 int pm_send_runlist(struct packet_manager *pm, struct list_head *dqm_queues);
669 int pm_send_query_status(struct packet_manager *pm, uint64_t fence_address,
670 uint32_t fence_value);
672 int pm_send_unmap_queue(struct packet_manager *pm, enum kfd_queue_type type,
673 enum kfd_preempt_type_filter mode,
674 uint32_t filter_param, bool reset,
675 unsigned int sdma_engine);
677 void pm_release_ib(struct packet_manager *pm);
679 uint64_t kfd_get_number_elems(struct kfd_dev *kfd);
680 phys_addr_t kfd_get_process_doorbells(struct kfd_dev *dev,
681 struct kfd_process *process);
683 /* Events */
684 extern const struct kfd_event_interrupt_class event_interrupt_class_cik;
686 enum kfd_event_wait_result {
687 KFD_WAIT_COMPLETE,
688 KFD_WAIT_TIMEOUT,
689 KFD_WAIT_ERROR
692 void kfd_event_init_process(struct kfd_process *p);
693 void kfd_event_free_process(struct kfd_process *p);
694 int kfd_event_mmap(struct kfd_process *process, struct vm_area_struct *vma);
695 int kfd_wait_on_events(struct kfd_process *p,
696 uint32_t num_events, void __user *data,
697 bool all, uint32_t user_timeout_ms,
698 enum kfd_event_wait_result *wait_result);
699 void kfd_signal_event_interrupt(unsigned int pasid, uint32_t partial_id,
700 uint32_t valid_id_bits);
701 void kfd_signal_iommu_event(struct kfd_dev *dev,
702 unsigned int pasid, unsigned long address,
703 bool is_write_requested, bool is_execute_requested);
704 int kfd_set_event(struct kfd_process *p, uint32_t event_id);
705 int kfd_reset_event(struct kfd_process *p, uint32_t event_id);
706 int kfd_event_create(struct file *devkfd, struct kfd_process *p,
707 uint32_t event_type, bool auto_reset, uint32_t node_id,
708 uint32_t *event_id, uint32_t *event_trigger_data,
709 uint64_t *event_page_offset, uint32_t *event_slot_index);
710 int kfd_event_destroy(struct kfd_process *p, uint32_t event_id);
712 #endif