Lines Matching refs:dev

14 #define can_map_direct(dev, addr) \  argument
15 ((dev)->bus_dma_limit >= phys_to_dma((dev), (addr)))
17 bool arch_dma_map_page_direct(struct device *dev, phys_addr_t addr) in arch_dma_map_page_direct() argument
19 if (likely(!dev->bus_dma_limit)) in arch_dma_map_page_direct()
22 return can_map_direct(dev, addr); in arch_dma_map_page_direct()
25 #define is_direct_handle(dev, h) ((h) >= (dev)->archdata.dma_offset) argument
27 bool arch_dma_unmap_page_direct(struct device *dev, dma_addr_t dma_handle) in arch_dma_unmap_page_direct() argument
29 if (likely(!dev->bus_dma_limit)) in arch_dma_unmap_page_direct()
32 return is_direct_handle(dev, dma_handle); in arch_dma_unmap_page_direct()
35 bool arch_dma_map_sg_direct(struct device *dev, struct scatterlist *sg, in arch_dma_map_sg_direct() argument
41 if (likely(!dev->bus_dma_limit)) in arch_dma_map_sg_direct()
45 if (!can_map_direct(dev, sg_phys(s) + s->offset + s->length)) in arch_dma_map_sg_direct()
52 bool arch_dma_unmap_sg_direct(struct device *dev, struct scatterlist *sg, in arch_dma_unmap_sg_direct() argument
58 if (likely(!dev->bus_dma_limit)) in arch_dma_unmap_sg_direct()
62 if (!is_direct_handle(dev, s->dma_address + s->length)) in arch_dma_unmap_sg_direct()
78 static void *dma_iommu_alloc_coherent(struct device *dev, size_t size, in dma_iommu_alloc_coherent() argument
82 return iommu_alloc_coherent(dev, get_iommu_table_base(dev), size, in dma_iommu_alloc_coherent()
83 dma_handle, dev->coherent_dma_mask, flag, in dma_iommu_alloc_coherent()
84 dev_to_node(dev)); in dma_iommu_alloc_coherent()
87 static void dma_iommu_free_coherent(struct device *dev, size_t size, in dma_iommu_free_coherent() argument
91 iommu_free_coherent(get_iommu_table_base(dev), size, vaddr, dma_handle); in dma_iommu_free_coherent()
99 static dma_addr_t dma_iommu_map_page(struct device *dev, struct page *page, in dma_iommu_map_page() argument
104 return iommu_map_page(dev, get_iommu_table_base(dev), page, offset, in dma_iommu_map_page()
105 size, dma_get_mask(dev), direction, attrs); in dma_iommu_map_page()
109 static void dma_iommu_unmap_page(struct device *dev, dma_addr_t dma_handle, in dma_iommu_unmap_page() argument
113 iommu_unmap_page(get_iommu_table_base(dev), dma_handle, size, direction, in dma_iommu_unmap_page()
118 static int dma_iommu_map_sg(struct device *dev, struct scatterlist *sglist, in dma_iommu_map_sg() argument
122 return ppc_iommu_map_sg(dev, get_iommu_table_base(dev), sglist, nelems, in dma_iommu_map_sg()
123 dma_get_mask(dev), direction, attrs); in dma_iommu_map_sg()
126 static void dma_iommu_unmap_sg(struct device *dev, struct scatterlist *sglist, in dma_iommu_unmap_sg() argument
130 ppc_iommu_unmap_sg(get_iommu_table_base(dev), sglist, nelems, in dma_iommu_unmap_sg()
134 static bool dma_iommu_bypass_supported(struct device *dev, u64 mask) in dma_iommu_bypass_supported() argument
136 struct pci_dev *pdev = to_pci_dev(dev); in dma_iommu_bypass_supported()
145 int dma_iommu_dma_supported(struct device *dev, u64 mask) in dma_iommu_dma_supported() argument
149 if (dev_is_pci(dev) && dma_iommu_bypass_supported(dev, mask)) { in dma_iommu_dma_supported()
155 dev->dma_ops_bypass = dev->bus_dma_limit == 0; in dma_iommu_dma_supported()
156 if (!dev->dma_ops_bypass) in dma_iommu_dma_supported()
157 dev_warn(dev, in dma_iommu_dma_supported()
159 dev->bus_dma_limit); in dma_iommu_dma_supported()
161 dev_dbg(dev, "iommu: 64-bit OK, using fixed ops\n"); in dma_iommu_dma_supported()
165 tbl = get_iommu_table_base(dev); in dma_iommu_dma_supported()
168 dev_err(dev, "Warning: IOMMU dma not supported: mask 0x%08llx, table unavailable\n", mask); in dma_iommu_dma_supported()
173 dev_info(dev, "Warning: IOMMU offset too big for device mask\n"); in dma_iommu_dma_supported()
174 dev_info(dev, "mask: 0x%08llx, table offset: 0x%08lx\n", in dma_iommu_dma_supported()
179 dev_dbg(dev, "iommu: not 64-bit, using default ops\n"); in dma_iommu_dma_supported()
180 dev->dma_ops_bypass = false; in dma_iommu_dma_supported()
184 u64 dma_iommu_get_required_mask(struct device *dev) in dma_iommu_get_required_mask() argument
186 struct iommu_table *tbl = get_iommu_table_base(dev); in dma_iommu_get_required_mask()
189 if (dev_is_pci(dev)) { in dma_iommu_get_required_mask()
190 u64 bypass_mask = dma_direct_get_required_mask(dev); in dma_iommu_get_required_mask()
192 if (dma_iommu_dma_supported(dev, bypass_mask)) { in dma_iommu_get_required_mask()
193 dev_info(dev, "%s: returning bypass mask 0x%llx\n", __func__, bypass_mask); in dma_iommu_get_required_mask()