at master 2.1 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * Copyright (C) 2007-2010 Advanced Micro Devices, Inc. 4 * Author: Joerg Roedel <joerg.roedel@amd.com> 5 * Leo Duran <leo.duran@amd.com> 6 */ 7 8#ifndef _ASM_X86_AMD_IOMMU_H 9#define _ASM_X86_AMD_IOMMU_H 10 11#include <linux/types.h> 12 13struct amd_iommu; 14 15#ifdef CONFIG_AMD_IOMMU 16 17struct task_struct; 18struct pci_dev; 19 20extern void amd_iommu_detect(void); 21 22#else /* CONFIG_AMD_IOMMU */ 23 24static inline void amd_iommu_detect(void) { } 25 26#endif /* CONFIG_AMD_IOMMU */ 27 28#if defined(CONFIG_AMD_IOMMU) && defined(CONFIG_IRQ_REMAP) 29 30/* IOMMU AVIC Function */ 31extern int amd_iommu_register_ga_log_notifier(int (*notifier)(u32)); 32 33extern int amd_iommu_update_ga(void *data, int cpu, bool ga_log_intr); 34extern int amd_iommu_activate_guest_mode(void *data, int cpu, bool ga_log_intr); 35extern int amd_iommu_deactivate_guest_mode(void *data); 36 37#else /* defined(CONFIG_AMD_IOMMU) && defined(CONFIG_IRQ_REMAP) */ 38 39static inline int 40amd_iommu_register_ga_log_notifier(int (*notifier)(u32)) 41{ 42 return 0; 43} 44 45static inline int amd_iommu_update_ga(void *data, int cpu, bool ga_log_intr) 46{ 47 return 0; 48} 49 50static inline int amd_iommu_activate_guest_mode(void *data, int cpu, bool ga_log_intr) 51{ 52 return 0; 53} 54 55static inline int amd_iommu_deactivate_guest_mode(void *data) 56{ 57 return 0; 58} 59#endif /* defined(CONFIG_AMD_IOMMU) && defined(CONFIG_IRQ_REMAP) */ 60 61int amd_iommu_get_num_iommus(void); 62bool amd_iommu_pc_supported(void); 63u8 amd_iommu_pc_get_max_banks(unsigned int idx); 64u8 amd_iommu_pc_get_max_counters(unsigned int idx); 65int amd_iommu_pc_set_reg(struct amd_iommu *iommu, u8 bank, u8 cntr, u8 fxn, 66 u64 *value); 67int amd_iommu_pc_get_reg(struct amd_iommu *iommu, u8 bank, u8 cntr, u8 fxn, 68 u64 *value); 69struct amd_iommu *get_amd_iommu(unsigned int idx); 70 71#ifdef CONFIG_KVM_AMD_SEV 72int amd_iommu_snp_disable(void); 73extern bool amd_iommu_sev_tio_supported(void); 74#else 75static inline int amd_iommu_snp_disable(void) { return 0; } 76static inline bool amd_iommu_sev_tio_supported(void) { return false; } 77#endif 78 79#endif /* _ASM_X86_AMD_IOMMU_H */