xref: /netbsd-src/sys/external/bsd/drm2/dist/drm/amd/amdkfd/kfd_iommu.h (revision 41ec02673d281bbb3d38e6c78504ce6e30c228c1)
1 /*	$NetBSD: kfd_iommu.h,v 1.2 2021/12/18 23:44:59 riastradh Exp $	*/
2 
3 /*
4  * Copyright 2018 Advanced Micro Devices, Inc.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22  * OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef __KFD_IOMMU_H__
26 #define __KFD_IOMMU_H__
27 
28 #if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2)
29 
30 #define KFD_SUPPORT_IOMMU_V2
31 
32 int kfd_iommu_check_device(struct kfd_dev *kfd);
33 int kfd_iommu_device_init(struct kfd_dev *kfd);
34 
35 int kfd_iommu_bind_process_to_device(struct kfd_process_device *pdd);
36 void kfd_iommu_unbind_process(struct kfd_process *p);
37 
38 void kfd_iommu_suspend(struct kfd_dev *kfd);
39 int kfd_iommu_resume(struct kfd_dev *kfd);
40 
41 int kfd_iommu_add_perf_counters(struct kfd_topology_device *kdev);
42 
43 #else
44 
kfd_iommu_check_device(struct kfd_dev * kfd)45 static inline int kfd_iommu_check_device(struct kfd_dev *kfd)
46 {
47 	return -ENODEV;
48 }
kfd_iommu_device_init(struct kfd_dev * kfd)49 static inline int kfd_iommu_device_init(struct kfd_dev *kfd)
50 {
51 	return 0;
52 }
53 
kfd_iommu_bind_process_to_device(struct kfd_process_device * pdd)54 static inline int kfd_iommu_bind_process_to_device(
55 	struct kfd_process_device *pdd)
56 {
57 	return 0;
58 }
kfd_iommu_unbind_process(struct kfd_process * p)59 static inline void kfd_iommu_unbind_process(struct kfd_process *p)
60 {
61 	/* empty */
62 }
63 
kfd_iommu_suspend(struct kfd_dev * kfd)64 static inline void kfd_iommu_suspend(struct kfd_dev *kfd)
65 {
66 	/* empty */
67 }
kfd_iommu_resume(struct kfd_dev * kfd)68 static inline int kfd_iommu_resume(struct kfd_dev *kfd)
69 {
70 	return 0;
71 }
72 
kfd_iommu_add_perf_counters(struct kfd_topology_device * kdev)73 static inline int kfd_iommu_add_perf_counters(struct kfd_topology_device *kdev)
74 {
75 	return 0;
76 }
77 
78 #endif /* defined(CONFIG_AMD_IOMMU_V2) */
79 
80 #endif /* __KFD_IOMMU_H__ */
81