Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
amd-iommu.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2010 Advanced Micro Devices, Inc.
3  * Author: Joerg Roedel <[email protected]>
4  * Leo Duran <[email protected]>
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License version 2 as published
8  * by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 
20 #ifndef _ASM_X86_AMD_IOMMU_H
21 #define _ASM_X86_AMD_IOMMU_H
22 
23 #include <linux/types.h>
24 
25 #ifdef CONFIG_AMD_IOMMU
26 
27 struct task_struct;
28 struct pci_dev;
29 
30 extern int amd_iommu_detect(void);
31 extern int amd_iommu_init_hardware(void);
32 
46 #define AMD_PRI_DEV_ERRATUM_ENABLE_RESET 0
47 #define AMD_PRI_DEV_ERRATUM_LIMIT_REQ_ONE 1
48 
49 extern void amd_iommu_enable_device_erratum(struct pci_dev *pdev, u32 erratum);
50 
60 extern int amd_iommu_init_device(struct pci_dev *pdev, int pasids);
61 
67 extern void amd_iommu_free_device(struct pci_dev *pdev);
68 
77 extern int amd_iommu_bind_pasid(struct pci_dev *pdev, int pasid,
78  struct task_struct *task);
79 
89 extern void amd_iommu_unbind_pasid(struct pci_dev *pdev, int pasid);
90 
110 #define AMD_IOMMU_INV_PRI_RSP_SUCCESS 0
111 #define AMD_IOMMU_INV_PRI_RSP_INVALID 1
112 #define AMD_IOMMU_INV_PRI_RSP_FAIL 2
113 
114 typedef int (*amd_iommu_invalid_ppr_cb)(struct pci_dev *pdev,
115  int pasid,
116  unsigned long address,
117  u16);
118 
119 extern int amd_iommu_set_invalid_ppr_cb(struct pci_dev *pdev,
120  amd_iommu_invalid_ppr_cb cb);
121 
132 #define AMD_IOMMU_DEVICE_FLAG_ATS_SUP 0x1 /* ATS feature supported */
133 #define AMD_IOMMU_DEVICE_FLAG_PRI_SUP 0x2 /* PRI feature supported */
134 #define AMD_IOMMU_DEVICE_FLAG_PASID_SUP 0x4 /* PASID context supported */
135 #define AMD_IOMMU_DEVICE_FLAG_EXEC_SUP 0x8 /* Device may request execution
136  on memory pages */
137 #define AMD_IOMMU_DEVICE_FLAG_PRIV_SUP 0x10 /* Device may request
138  super-user privileges */
139 
140 struct amd_iommu_device_info {
141  int max_pasids;
142  u32 flags;
143 };
144 
145 extern int amd_iommu_device_info(struct pci_dev *pdev,
146  struct amd_iommu_device_info *info);
147 
160 typedef void (*amd_iommu_invalidate_ctx)(struct pci_dev *pdev, int pasid);
161 
162 extern int amd_iommu_set_invalidate_ctx_cb(struct pci_dev *pdev,
163  amd_iommu_invalidate_ctx cb);
164 
165 #else
166 
167 static inline int amd_iommu_detect(void) { return -ENODEV; }
168 
169 #endif
170 
171 #endif /* _ASM_X86_AMD_IOMMU_H */