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