1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
3 * Copyright 2018-2022 Advanced Micro Devices, Inc.
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:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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.
24 #ifndef __KFD_IOMMU_H__
25 #define __KFD_IOMMU_H__
27 #include <linux/kconfig.h>
29 #if IS_REACHABLE(CONFIG_AMD_IOMMU_V2)
31 #define KFD_SUPPORT_IOMMU_V2
33 int kfd_iommu_check_device(struct kfd_dev *kfd);
34 int kfd_iommu_device_init(struct kfd_dev *kfd);
36 int kfd_iommu_bind_process_to_device(struct kfd_process_device *pdd);
37 void kfd_iommu_unbind_process(struct kfd_process *p);
39 void kfd_iommu_suspend(struct kfd_dev *kfd);
40 int kfd_iommu_resume(struct kfd_dev *kfd);
42 int kfd_iommu_add_perf_counters(struct kfd_topology_device *kdev);
46 static inline int kfd_iommu_check_device(struct kfd_dev *kfd)
50 static inline int kfd_iommu_device_init(struct kfd_dev *kfd)
52 #if IS_MODULE(CONFIG_AMD_IOMMU_V2)
53 WARN_ONCE(1, "iommu_v2 module is not usable by built-in KFD");
58 static inline int kfd_iommu_bind_process_to_device(
59 struct kfd_process_device *pdd)
63 static inline void kfd_iommu_unbind_process(struct kfd_process *p)
68 static inline void kfd_iommu_suspend(struct kfd_dev *kfd)
72 static inline int kfd_iommu_resume(struct kfd_dev *kfd)
77 static inline int kfd_iommu_add_perf_counters(struct kfd_topology_device *kdev)
82 #endif /* IS_REACHABLE(CONFIG_AMD_IOMMU_V2) */
84 #endif /* __KFD_IOMMU_H__ */