Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
0002 /*
0003  * Copyright 2018-2022 Advanced Micro Devices, Inc.
0004  *
0005  * Permission is hereby granted, free of charge, to any person obtaining a
0006  * copy of this software and associated documentation files (the "Software"),
0007  * to deal in the Software without restriction, including without limitation
0008  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0009  * and/or sell copies of the Software, and to permit persons to whom the
0010  * Software is furnished to do so, subject to the following conditions:
0011  *
0012  * The above copyright notice and this permission notice shall be included in
0013  * all copies or substantial portions of the Software.
0014  *
0015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0016  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0017  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0018  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0019  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0020  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0021  * OTHER DEALINGS IN THE SOFTWARE.
0022  */
0023 
0024 #ifndef __KFD_IOMMU_H__
0025 #define __KFD_IOMMU_H__
0026 
0027 #include <linux/kconfig.h>
0028 
0029 #if IS_REACHABLE(CONFIG_AMD_IOMMU_V2)
0030 
0031 #define KFD_SUPPORT_IOMMU_V2
0032 
0033 int kfd_iommu_check_device(struct kfd_dev *kfd);
0034 int kfd_iommu_device_init(struct kfd_dev *kfd);
0035 
0036 int kfd_iommu_bind_process_to_device(struct kfd_process_device *pdd);
0037 void kfd_iommu_unbind_process(struct kfd_process *p);
0038 
0039 void kfd_iommu_suspend(struct kfd_dev *kfd);
0040 int kfd_iommu_resume(struct kfd_dev *kfd);
0041 
0042 int kfd_iommu_add_perf_counters(struct kfd_topology_device *kdev);
0043 
0044 #else
0045 
0046 static inline int kfd_iommu_check_device(struct kfd_dev *kfd)
0047 {
0048     return -ENODEV;
0049 }
0050 static inline int kfd_iommu_device_init(struct kfd_dev *kfd)
0051 {
0052 #if IS_MODULE(CONFIG_AMD_IOMMU_V2)
0053     WARN_ONCE(1, "iommu_v2 module is not usable by built-in KFD");
0054 #endif
0055     return 0;
0056 }
0057 
0058 static inline int kfd_iommu_bind_process_to_device(
0059     struct kfd_process_device *pdd)
0060 {
0061     return 0;
0062 }
0063 static inline void kfd_iommu_unbind_process(struct kfd_process *p)
0064 {
0065     /* empty */
0066 }
0067 
0068 static inline void kfd_iommu_suspend(struct kfd_dev *kfd)
0069 {
0070     /* empty */
0071 }
0072 static inline int kfd_iommu_resume(struct kfd_dev *kfd)
0073 {
0074     return 0;
0075 }
0076 
0077 static inline int kfd_iommu_add_perf_counters(struct kfd_topology_device *kdev)
0078 {
0079     return 0;
0080 }
0081 
0082 #endif /* IS_REACHABLE(CONFIG_AMD_IOMMU_V2) */
0083 
0084 #endif /* __KFD_IOMMU_H__ */