diff options
Diffstat (limited to 'include/linux/intel-iommu.h')
-rw-r--r-- | include/linux/intel-iommu.h | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h index afb0d2a5b7c..3d017cfd245 100644 --- a/include/linux/intel-iommu.h +++ b/include/linux/intel-iommu.h | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/io.h> | 29 | #include <linux/io.h> |
30 | #include <linux/dma_remapping.h> | 30 | #include <linux/dma_remapping.h> |
31 | #include <asm/cacheflush.h> | 31 | #include <asm/cacheflush.h> |
32 | #include <asm/iommu.h> | ||
32 | 33 | ||
33 | /* | 34 | /* |
34 | * Intel IOMMU register specification per version 1.0 public spec. | 35 | * Intel IOMMU register specification per version 1.0 public spec. |
@@ -202,22 +203,21 @@ static inline void dmar_writeq(void __iomem *addr, u64 val) | |||
202 | #define dma_frcd_type(d) ((d >> 30) & 1) | 203 | #define dma_frcd_type(d) ((d >> 30) & 1) |
203 | #define dma_frcd_fault_reason(c) (c & 0xff) | 204 | #define dma_frcd_fault_reason(c) (c & 0xff) |
204 | #define dma_frcd_source_id(c) (c & 0xffff) | 205 | #define dma_frcd_source_id(c) (c & 0xffff) |
205 | #define dma_frcd_page_addr(d) (d & (((u64)-1) << 12)) /* low 64 bit */ | 206 | /* low 64 bit */ |
206 | 207 | #define dma_frcd_page_addr(d) (d & (((u64)-1) << PAGE_SHIFT)) | |
207 | #define DMAR_OPERATION_TIMEOUT ((cycles_t) tsc_khz*10*1000) /* 10sec */ | 208 | |
208 | 209 | #define IOMMU_WAIT_OP(iommu, offset, op, cond, sts) \ | |
209 | #define IOMMU_WAIT_OP(iommu, offset, op, cond, sts) \ | 210 | do { \ |
210 | {\ | 211 | cycles_t start_time = get_cycles(); \ |
211 | cycles_t start_time = get_cycles();\ | 212 | while (1) { \ |
212 | while (1) {\ | 213 | sts = op(iommu->reg + offset); \ |
213 | sts = op (iommu->reg + offset);\ | 214 | if (cond) \ |
214 | if (cond)\ | 215 | break; \ |
215 | break;\ | ||
216 | if (DMAR_OPERATION_TIMEOUT < (get_cycles() - start_time))\ | 216 | if (DMAR_OPERATION_TIMEOUT < (get_cycles() - start_time))\ |
217 | panic("DMAR hardware is malfunctioning\n");\ | 217 | panic("DMAR hardware is malfunctioning\n"); \ |
218 | cpu_relax();\ | 218 | cpu_relax(); \ |
219 | }\ | 219 | } \ |
220 | } | 220 | } while (0) |
221 | 221 | ||
222 | #define QI_LENGTH 256 /* queue length */ | 222 | #define QI_LENGTH 256 /* queue length */ |
223 | 223 | ||
@@ -244,7 +244,7 @@ enum { | |||
244 | #define QI_IOTLB_DR(dr) (((u64)dr) << 7) | 244 | #define QI_IOTLB_DR(dr) (((u64)dr) << 7) |
245 | #define QI_IOTLB_DW(dw) (((u64)dw) << 6) | 245 | #define QI_IOTLB_DW(dw) (((u64)dw) << 6) |
246 | #define QI_IOTLB_GRAN(gran) (((u64)gran) >> (DMA_TLB_FLUSH_GRANU_OFFSET-4)) | 246 | #define QI_IOTLB_GRAN(gran) (((u64)gran) >> (DMA_TLB_FLUSH_GRANU_OFFSET-4)) |
247 | #define QI_IOTLB_ADDR(addr) (((u64)addr) & PAGE_MASK_4K) | 247 | #define QI_IOTLB_ADDR(addr) (((u64)addr) & VTD_PAGE_MASK) |
248 | #define QI_IOTLB_IH(ih) (((u64)ih) << 6) | 248 | #define QI_IOTLB_IH(ih) (((u64)ih) << 6) |
249 | #define QI_IOTLB_AM(am) (((u8)am)) | 249 | #define QI_IOTLB_AM(am) (((u8)am)) |
250 | 250 | ||
@@ -353,4 +353,11 @@ static inline int intel_iommu_found(void) | |||
353 | } | 353 | } |
354 | #endif /* CONFIG_DMAR */ | 354 | #endif /* CONFIG_DMAR */ |
355 | 355 | ||
356 | extern void *intel_alloc_coherent(struct device *, size_t, dma_addr_t *, gfp_t); | ||
357 | extern void intel_free_coherent(struct device *, size_t, void *, dma_addr_t); | ||
358 | extern dma_addr_t intel_map_single(struct device *, phys_addr_t, size_t, int); | ||
359 | extern void intel_unmap_single(struct device *, dma_addr_t, size_t, int); | ||
360 | extern int intel_map_sg(struct device *, struct scatterlist *, int, int); | ||
361 | extern void intel_unmap_sg(struct device *, struct scatterlist *, int, int); | ||
362 | |||
356 | #endif | 363 | #endif |