diff options
-rw-r--r-- | drivers/pci/intel-iommu.c | 33 | ||||
-rw-r--r-- | include/linux/dma_remapping.h | 34 |
2 files changed, 34 insertions, 33 deletions
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c index 6fadbb9bc180..29bf2d8176e2 100644 --- a/drivers/pci/intel-iommu.c +++ b/drivers/pci/intel-iommu.c | |||
@@ -57,6 +57,39 @@ | |||
57 | #define DMA_32BIT_PFN IOVA_PFN(DMA_32BIT_MASK) | 57 | #define DMA_32BIT_PFN IOVA_PFN(DMA_32BIT_MASK) |
58 | #define DMA_64BIT_PFN IOVA_PFN(DMA_64BIT_MASK) | 58 | #define DMA_64BIT_PFN IOVA_PFN(DMA_64BIT_MASK) |
59 | 59 | ||
60 | /* | ||
61 | * 0: Present | ||
62 | * 1-11: Reserved | ||
63 | * 12-63: Context Ptr (12 - (haw-1)) | ||
64 | * 64-127: Reserved | ||
65 | */ | ||
66 | struct root_entry { | ||
67 | u64 val; | ||
68 | u64 rsvd1; | ||
69 | }; | ||
70 | #define ROOT_ENTRY_NR (VTD_PAGE_SIZE/sizeof(struct root_entry)) | ||
71 | static inline bool root_present(struct root_entry *root) | ||
72 | { | ||
73 | return (root->val & 1); | ||
74 | } | ||
75 | static inline void set_root_present(struct root_entry *root) | ||
76 | { | ||
77 | root->val |= 1; | ||
78 | } | ||
79 | static inline void set_root_value(struct root_entry *root, unsigned long value) | ||
80 | { | ||
81 | root->val |= value & VTD_PAGE_MASK; | ||
82 | } | ||
83 | |||
84 | static inline struct context_entry * | ||
85 | get_context_addr_from_root(struct root_entry *root) | ||
86 | { | ||
87 | return (struct context_entry *) | ||
88 | (root_present(root)?phys_to_virt( | ||
89 | root->val & VTD_PAGE_MASK) : | ||
90 | NULL); | ||
91 | } | ||
92 | |||
60 | static void flush_unmaps_timeout(unsigned long data); | 93 | static void flush_unmaps_timeout(unsigned long data); |
61 | 94 | ||
62 | DEFINE_TIMER(unmap_timer, flush_unmaps_timeout, 0, 0); | 95 | DEFINE_TIMER(unmap_timer, flush_unmaps_timeout, 0, 0); |
diff --git a/include/linux/dma_remapping.h b/include/linux/dma_remapping.h index 2e5a5c0b6acd..d8521662a495 100644 --- a/include/linux/dma_remapping.h +++ b/include/linux/dma_remapping.h | |||
@@ -9,39 +9,7 @@ | |||
9 | #define VTD_PAGE_MASK (((u64)-1) << VTD_PAGE_SHIFT) | 9 | #define VTD_PAGE_MASK (((u64)-1) << VTD_PAGE_SHIFT) |
10 | #define VTD_PAGE_ALIGN(addr) (((addr) + VTD_PAGE_SIZE - 1) & VTD_PAGE_MASK) | 10 | #define VTD_PAGE_ALIGN(addr) (((addr) + VTD_PAGE_SIZE - 1) & VTD_PAGE_MASK) |
11 | 11 | ||
12 | /* | 12 | struct root_entry; |
13 | * 0: Present | ||
14 | * 1-11: Reserved | ||
15 | * 12-63: Context Ptr (12 - (haw-1)) | ||
16 | * 64-127: Reserved | ||
17 | */ | ||
18 | struct root_entry { | ||
19 | u64 val; | ||
20 | u64 rsvd1; | ||
21 | }; | ||
22 | #define ROOT_ENTRY_NR (VTD_PAGE_SIZE/sizeof(struct root_entry)) | ||
23 | static inline bool root_present(struct root_entry *root) | ||
24 | { | ||
25 | return (root->val & 1); | ||
26 | } | ||
27 | static inline void set_root_present(struct root_entry *root) | ||
28 | { | ||
29 | root->val |= 1; | ||
30 | } | ||
31 | static inline void set_root_value(struct root_entry *root, unsigned long value) | ||
32 | { | ||
33 | root->val |= value & VTD_PAGE_MASK; | ||
34 | } | ||
35 | |||
36 | struct context_entry; | ||
37 | static inline struct context_entry * | ||
38 | get_context_addr_from_root(struct root_entry *root) | ||
39 | { | ||
40 | return (struct context_entry *) | ||
41 | (root_present(root)?phys_to_virt( | ||
42 | root->val & VTD_PAGE_MASK) : | ||
43 | NULL); | ||
44 | } | ||
45 | 13 | ||
46 | /* | 14 | /* |
47 | * low 64 bits: | 15 | * low 64 bits: |