1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2007-2010 Advanced Micro Devices, Inc.
4 * Author: Joerg Roedel <joerg.roedel@amd.com>
5 * Leo Duran <leo.duran@amd.com>
8 #ifndef _ASM_X86_AMD_IOMMU_H
9 #define _ASM_X86_AMD_IOMMU_H
11 #include <linux/types.h>
16 * This is mainly used to communicate information back-and-forth
17 * between SVM and IOMMU for setting up and tearing down posted
20 struct amd_iommu_pi_data
{
25 struct vcpu_data
*vcpu_data
;
29 #ifdef CONFIG_AMD_IOMMU
34 extern int amd_iommu_detect(void);
36 #else /* CONFIG_AMD_IOMMU */
38 static inline int amd_iommu_detect(void) { return -ENODEV
; }
40 #endif /* CONFIG_AMD_IOMMU */
42 #if defined(CONFIG_AMD_IOMMU) && defined(CONFIG_IRQ_REMAP)
44 /* IOMMU AVIC Function */
45 extern int amd_iommu_register_ga_log_notifier(int (*notifier
)(u32
));
48 amd_iommu_update_ga(int cpu
, bool is_run
, void *data
);
50 extern int amd_iommu_activate_guest_mode(void *data
);
51 extern int amd_iommu_deactivate_guest_mode(void *data
);
53 #else /* defined(CONFIG_AMD_IOMMU) && defined(CONFIG_IRQ_REMAP) */
56 amd_iommu_register_ga_log_notifier(int (*notifier
)(u32
))
62 amd_iommu_update_ga(int cpu
, bool is_run
, void *data
)
67 static inline int amd_iommu_activate_guest_mode(void *data
)
72 static inline int amd_iommu_deactivate_guest_mode(void *data
)
76 #endif /* defined(CONFIG_AMD_IOMMU) && defined(CONFIG_IRQ_REMAP) */
78 int amd_iommu_get_num_iommus(void);
79 bool amd_iommu_pc_supported(void);
80 u8
amd_iommu_pc_get_max_banks(unsigned int idx
);
81 u8
amd_iommu_pc_get_max_counters(unsigned int idx
);
82 int amd_iommu_pc_set_reg(struct amd_iommu
*iommu
, u8 bank
, u8 cntr
, u8 fxn
,
84 int amd_iommu_pc_get_reg(struct amd_iommu
*iommu
, u8 bank
, u8 cntr
, u8 fxn
,
86 struct amd_iommu
*get_amd_iommu(unsigned int idx
);
88 #ifdef CONFIG_KVM_AMD_SEV
89 int amd_iommu_snp_disable(void);
91 static inline int amd_iommu_snp_disable(void) { return 0; }
94 #endif /* _ASM_X86_AMD_IOMMU_H */