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 /* amdgpu_amdkfd.h defines the private interface between amdgpu and amdkfd. */
25 #ifndef AMDGPU_AMDKFD_H_INCLUDED
26 #define AMDGPU_AMDKFD_H_INCLUDED
28 #include <linux/types.h>
29 #include <linux/mmu_context.h>
30 #include <kgd_kfd_interface.h>
40 int amdgpu_amdkfd_init(void);
41 void amdgpu_amdkfd_fini(void);
43 void amdgpu_amdkfd_suspend(struct amdgpu_device *adev);
44 int amdgpu_amdkfd_resume(struct amdgpu_device *adev);
45 void amdgpu_amdkfd_interrupt(struct amdgpu_device *adev,
46 const void *ih_ring_entry);
47 void amdgpu_amdkfd_device_probe(struct amdgpu_device *adev);
48 void amdgpu_amdkfd_device_init(struct amdgpu_device *adev);
49 void amdgpu_amdkfd_device_fini(struct amdgpu_device *adev);
51 struct kfd2kgd_calls *amdgpu_amdkfd_gfx_7_get_functions(void);
52 struct kfd2kgd_calls *amdgpu_amdkfd_gfx_8_0_get_functions(void);
55 int alloc_gtt_mem(struct kgd_dev *kgd, size_t size,
56 void **mem_obj, uint64_t *gpu_addr,
58 void free_gtt_mem(struct kgd_dev *kgd, void *mem_obj);
59 void get_local_mem_info(struct kgd_dev *kgd,
60 struct kfd_local_mem_info *mem_info);
61 uint64_t get_gpu_clock_counter(struct kgd_dev *kgd);
63 uint32_t get_max_engine_clock_in_mhz(struct kgd_dev *kgd);
64 void get_cu_info(struct kgd_dev *kgd, struct kfd_cu_info *cu_info);
65 uint64_t amdgpu_amdkfd_get_vram_usage(struct kgd_dev *kgd);
67 #define read_user_wptr(mmptr, wptr, dst) \
70 if ((mmptr) && (wptr)) { \
71 if ((mmptr) == current->mm) { \
72 valid = !get_user((dst), (wptr)); \
73 } else if (current->mm == NULL) { \
75 valid = !get_user((dst), (wptr)); \
82 #endif /* AMDGPU_AMDKFD_H_INCLUDED */