blob: cb1a6631b8f449bcf2738f37208783dd23be87ba [file] [log] [blame]
Joerg Roedel16489932008-10-15 22:01:03 -07001#ifndef __LINUX_SWIOTLB_H
2#define __LINUX_SWIOTLB_H
3
4#include <linux/types.h>
5
6struct device;
7struct dma_attrs;
8struct scatterlist;
9
Ian Campbell0016fde2008-12-16 12:17:27 -080010/*
11 * Maximum allowable number of contiguous slabs to map,
12 * must be a power of 2. What is the appropriate value ?
13 * The complexity of {map,unmap}_single is linearly dependent on this value.
14 */
15#define IO_TLB_SEGSIZE 128
16
17
18/*
19 * log of the size of each IO TLB slab. The number of slabs is command line
20 * controllable.
21 */
22#define IO_TLB_SHIFT 11
23
Joerg Roedel16489932008-10-15 22:01:03 -070024extern void
25swiotlb_init(void);
26
Jeremy Fitzhardinge8c5df162008-12-16 12:17:26 -080027extern void *swiotlb_alloc_boot(size_t bytes, unsigned long nslabs);
28extern void *swiotlb_alloc(unsigned order, unsigned long nslabs);
29
Jeremy Fitzhardinge70a7d3c2008-12-22 10:26:05 -080030extern dma_addr_t swiotlb_phys_to_bus(struct device *hwdev,
31 phys_addr_t address);
Becky Bruce42d7c5e2009-04-08 09:09:21 -050032extern phys_addr_t swiotlb_bus_to_phys(struct device *hwdev,
33 dma_addr_t address);
Ian Campbelle08e1f72008-12-16 12:17:30 -080034
Ian Campbell0b8698a2009-01-09 18:32:09 +000035extern int swiotlb_arch_range_needs_mapping(phys_addr_t paddr, size_t size);
Ian Campbellb81ea272008-12-16 12:17:31 -080036
Joerg Roedel16489932008-10-15 22:01:03 -070037extern void
38*swiotlb_alloc_coherent(struct device *hwdev, size_t size,
39 dma_addr_t *dma_handle, gfp_t flags);
40
41extern void
42swiotlb_free_coherent(struct device *hwdev, size_t size,
43 void *vaddr, dma_addr_t dma_handle);
44
FUJITA Tomonorif98eee82009-01-05 23:59:03 +090045extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
46 unsigned long offset, size_t size,
47 enum dma_data_direction dir,
48 struct dma_attrs *attrs);
49extern void swiotlb_unmap_page(struct device *hwdev, dma_addr_t dev_addr,
50 size_t size, enum dma_data_direction dir,
51 struct dma_attrs *attrs);
Joerg Roedel16489932008-10-15 22:01:03 -070052
53extern int
54swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, int nents,
55 int direction);
56
57extern void
58swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents,
59 int direction);
60
61extern int
62swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, int nelems,
FUJITA Tomonori160c1d82009-01-05 23:59:02 +090063 enum dma_data_direction dir, struct dma_attrs *attrs);
Joerg Roedel16489932008-10-15 22:01:03 -070064
65extern void
66swiotlb_unmap_sg_attrs(struct device *hwdev, struct scatterlist *sgl,
FUJITA Tomonori160c1d82009-01-05 23:59:02 +090067 int nelems, enum dma_data_direction dir,
68 struct dma_attrs *attrs);
Joerg Roedel16489932008-10-15 22:01:03 -070069
70extern void
71swiotlb_sync_single_for_cpu(struct device *hwdev, dma_addr_t dev_addr,
FUJITA Tomonori160c1d82009-01-05 23:59:02 +090072 size_t size, enum dma_data_direction dir);
Joerg Roedel16489932008-10-15 22:01:03 -070073
74extern void
75swiotlb_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg,
FUJITA Tomonori160c1d82009-01-05 23:59:02 +090076 int nelems, enum dma_data_direction dir);
Joerg Roedel16489932008-10-15 22:01:03 -070077
78extern void
79swiotlb_sync_single_for_device(struct device *hwdev, dma_addr_t dev_addr,
FUJITA Tomonori160c1d82009-01-05 23:59:02 +090080 size_t size, enum dma_data_direction dir);
Joerg Roedel16489932008-10-15 22:01:03 -070081
82extern void
83swiotlb_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg,
FUJITA Tomonori160c1d82009-01-05 23:59:02 +090084 int nelems, enum dma_data_direction dir);
Joerg Roedel16489932008-10-15 22:01:03 -070085
86extern void
87swiotlb_sync_single_range_for_cpu(struct device *hwdev, dma_addr_t dev_addr,
FUJITA Tomonori160c1d82009-01-05 23:59:02 +090088 unsigned long offset, size_t size,
89 enum dma_data_direction dir);
Joerg Roedel16489932008-10-15 22:01:03 -070090
91extern void
92swiotlb_sync_single_range_for_device(struct device *hwdev, dma_addr_t dev_addr,
93 unsigned long offset, size_t size,
FUJITA Tomonori160c1d82009-01-05 23:59:02 +090094 enum dma_data_direction dir);
Joerg Roedel16489932008-10-15 22:01:03 -070095
96extern int
97swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr);
98
99extern int
100swiotlb_dma_supported(struct device *hwdev, u64 mask);
101
102#endif /* __LINUX_SWIOTLB_H */