aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2008-07-11 11:14:20 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-11 12:01:09 -0400
commit5694703f14b1f6219fce42a27229b0c7d2c23edd (patch)
tree70bee17ae0aa4a86a070119d37fefe474a5d0bf2
parent299a140dacaa514be5e567b5851c187c42ec38c4 (diff)
x86, AMD IOMMU: add comments to amd_iommu_types.h
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Cc: iommu@lists.linux-foundation.org Cc: bhavna.sarathy@amd.com Cc: robert.richter@amd.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--include/asm-x86/amd_iommu_types.h104
1 files changed, 98 insertions, 6 deletions
diff --git a/include/asm-x86/amd_iommu_types.h b/include/asm-x86/amd_iommu_types.h
index 7bfcb47cc452..945fd498a3ad 100644
--- a/include/asm-x86/amd_iommu_types.h
+++ b/include/asm-x86/amd_iommu_types.h
@@ -158,78 +158,170 @@
158 158
159#define MAX_DOMAIN_ID 65536 159#define MAX_DOMAIN_ID 65536
160 160
161/*
162 * This structure contains generic data for IOMMU protection domains
163 * independent of their use.
164 */
161struct protection_domain { 165struct protection_domain {
162 spinlock_t lock; 166 spinlock_t lock; /* mostly used to lock the page table*/
163 u16 id; 167 u16 id; /* the domain id written to the device table */
164 int mode; 168 int mode; /* paging mode (0-6 levels) */
165 u64 *pt_root; 169 u64 *pt_root; /* page table root pointer */
166 void *priv; 170 void *priv; /* private data */
167}; 171};
168 172
173/*
174 * Data container for a dma_ops specific protection domain
175 */
169struct dma_ops_domain { 176struct dma_ops_domain {
170 struct list_head list; 177 struct list_head list;
178
179 /* generic protection domain information */
171 struct protection_domain domain; 180 struct protection_domain domain;
181
182 /* size of the aperture for the mappings */
172 unsigned long aperture_size; 183 unsigned long aperture_size;
184
185 /* address we start to search for free addresses */
173 unsigned long next_bit; 186 unsigned long next_bit;
187
188 /* address allocation bitmap */
174 unsigned long *bitmap; 189 unsigned long *bitmap;
190
191 /*
192 * Array of PTE pages for the aperture. In this array we save all the
193 * leaf pages of the domain page table used for the aperture. This way
194 * we don't need to walk the page table to find a specific PTE. We can
195 * just calculate its address in constant time.
196 */
175 u64 **pte_pages; 197 u64 **pte_pages;
176}; 198};
177 199
200/*
201 * Structure where we save information about one hardware AMD IOMMU in the
202 * system.
203 */
178struct amd_iommu { 204struct amd_iommu {
179 struct list_head list; 205 struct list_head list;
206
207 /* locks the accesses to the hardware */
180 spinlock_t lock; 208 spinlock_t lock;
181 209
210 /* device id of this IOMMU */
182 u16 devid; 211 u16 devid;
212 /*
213 * Capability pointer. There could be more than one IOMMU per PCI
214 * device function if there are more than one AMD IOMMU capability
215 * pointers.
216 */
183 u16 cap_ptr; 217 u16 cap_ptr;
184 218
219 /* physical address of MMIO space */
185 u64 mmio_phys; 220 u64 mmio_phys;
221 /* virtual address of MMIO space */
186 u8 *mmio_base; 222 u8 *mmio_base;
223
224 /* capabilities of that IOMMU read from ACPI */
187 u32 cap; 225 u32 cap;
226
227 /* first device this IOMMU handles. read from PCI */
188 u16 first_device; 228 u16 first_device;
229 /* last device this IOMMU handles. read from PCI */
189 u16 last_device; 230 u16 last_device;
231
232 /* start of exclusion range of that IOMMU */
190 u64 exclusion_start; 233 u64 exclusion_start;
234 /* length of exclusion range of that IOMMU */
191 u64 exclusion_length; 235 u64 exclusion_length;
192 236
237 /* command buffer virtual address */
193 u8 *cmd_buf; 238 u8 *cmd_buf;
239 /* size of command buffer */
194 u32 cmd_buf_size; 240 u32 cmd_buf_size;
195 241
242 /* if one, we need to send a completion wait command */
196 int need_sync; 243 int need_sync;
197 244
245 /* default dma_ops domain for that IOMMU */
198 struct dma_ops_domain *default_dom; 246 struct dma_ops_domain *default_dom;
199}; 247};
200 248
249/*
250 * List with all IOMMUs in the system. This list is not locked because it is
251 * only written and read at driver initialization or suspend time
252 */
201extern struct list_head amd_iommu_list; 253extern struct list_head amd_iommu_list;
202 254
255/*
256 * Structure defining one entry in the device table
257 */
203struct dev_table_entry { 258struct dev_table_entry {
204 u32 data[8]; 259 u32 data[8];
205}; 260};
206 261
262/*
263 * One entry for unity mappings parsed out of the ACPI table.
264 */
207struct unity_map_entry { 265struct unity_map_entry {
208 struct list_head list; 266 struct list_head list;
267
268 /* starting device id this entry is used for (including) */
209 u16 devid_start; 269 u16 devid_start;
270 /* end device id this entry is used for (including) */
210 u16 devid_end; 271 u16 devid_end;
272
273 /* start address to unity map (including) */
211 u64 address_start; 274 u64 address_start;
275 /* end address to unity map (including) */
212 u64 address_end; 276 u64 address_end;
277
278 /* required protection */
213 int prot; 279 int prot;
214}; 280};
215 281
282/*
283 * List of all unity mappings. It is not locked because as runtime it is only
284 * read. It is created at ACPI table parsing time.
285 */
216extern struct list_head amd_iommu_unity_map; 286extern struct list_head amd_iommu_unity_map;
217 287
218/* data structures for device handling */ 288/*
289 * Data structures for device handling
290 */
291
292/*
293 * Device table used by hardware. Read and write accesses by software are
294 * locked with the amd_iommu_pd_table lock.
295 */
219extern struct dev_table_entry *amd_iommu_dev_table; 296extern struct dev_table_entry *amd_iommu_dev_table;
297
298/*
299 * Alias table to find requestor ids to device ids. Not locked because only
300 * read on runtime.
301 */
220extern u16 *amd_iommu_alias_table; 302extern u16 *amd_iommu_alias_table;
303
304/*
305 * Reverse lookup table to find the IOMMU which translates a specific device.
306 */
221extern struct amd_iommu **amd_iommu_rlookup_table; 307extern struct amd_iommu **amd_iommu_rlookup_table;
222 308
309/* size of the dma_ops aperture as power of 2 */
223extern unsigned amd_iommu_aperture_order; 310extern unsigned amd_iommu_aperture_order;
224 311
312/* largest PCI device id we expect translation requests for */
225extern u16 amd_iommu_last_bdf; 313extern u16 amd_iommu_last_bdf;
226 314
227/* data structures for protection domain handling */ 315/* data structures for protection domain handling */
228extern struct protection_domain **amd_iommu_pd_table; 316extern struct protection_domain **amd_iommu_pd_table;
317
318/* allocation bitmap for domain ids */
229extern unsigned long *amd_iommu_pd_alloc_bitmap; 319extern unsigned long *amd_iommu_pd_alloc_bitmap;
230 320
321/* will be 1 if device isolation is enabled */
231extern int amd_iommu_isolate; 322extern int amd_iommu_isolate;
232 323
324/* takes a PCI device id and prints it out in a readable form */
233static inline void print_devid(u16 devid, int nl) 325static inline void print_devid(u16 devid, int nl)
234{ 326{
235 int bus = devid >> 8; 327 int bus = devid >> 8;