1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#ifndef AMDGPU_AMDKFD_H_INCLUDED
26#define AMDGPU_AMDKFD_H_INCLUDED
27
28#include <linux/types.h>
29#include <linux/mmu_context.h>
30#include <kgd_kfd_interface.h>
31
32struct amdgpu_device;
33
34struct kgd_mem {
35 struct amdgpu_bo *bo;
36 uint64_t gpu_addr;
37 void *cpu_ptr;
38};
39
40int amdgpu_amdkfd_init(void);
41void amdgpu_amdkfd_fini(void);
42
43void amdgpu_amdkfd_suspend(struct amdgpu_device *adev);
44int amdgpu_amdkfd_resume(struct amdgpu_device *adev);
45void amdgpu_amdkfd_interrupt(struct amdgpu_device *adev,
46 const void *ih_ring_entry);
47void amdgpu_amdkfd_device_probe(struct amdgpu_device *adev);
48void amdgpu_amdkfd_device_init(struct amdgpu_device *adev);
49void amdgpu_amdkfd_device_fini(struct amdgpu_device *adev);
50
51struct kfd2kgd_calls *amdgpu_amdkfd_gfx_7_get_functions(void);
52struct kfd2kgd_calls *amdgpu_amdkfd_gfx_8_0_get_functions(void);
53
54
55int alloc_gtt_mem(struct kgd_dev *kgd, size_t size,
56 void **mem_obj, uint64_t *gpu_addr,
57 void **cpu_ptr);
58void free_gtt_mem(struct kgd_dev *kgd, void *mem_obj);
59uint64_t get_vmem_size(struct kgd_dev *kgd);
60uint64_t get_gpu_clock_counter(struct kgd_dev *kgd);
61
62uint32_t get_max_engine_clock_in_mhz(struct kgd_dev *kgd);
63
64#define read_user_wptr(mmptr, wptr, dst) \
65 ({ \
66 bool valid = false; \
67 if ((mmptr) && (wptr)) { \
68 if ((mmptr) == current->mm) { \
69 valid = !get_user((dst), (wptr)); \
70 } else if (current->mm == NULL) { \
71 use_mm(mmptr); \
72 valid = !get_user((dst), (wptr)); \
73 unuse_mm(mmptr); \
74 } \
75 } \
76 valid; \
77 })
78
79#endif
80