]>
git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - lib/dma-noop.c
4 * DMA operations that map to physical addresses without flushing memory.
6 #include <linux/export.h>
8 #include <linux/dma-mapping.h>
9 #include <linux/scatterlist.h>
11 static void *dma_noop_alloc(struct device
*dev
, size_t size
,
12 dma_addr_t
*dma_handle
, gfp_t gfp
,
17 ret
= (void *)__get_free_pages(gfp
, get_order(size
));
19 *dma_handle
= virt_to_phys(ret
);
23 static void dma_noop_free(struct device
*dev
, size_t size
,
24 void *cpu_addr
, dma_addr_t dma_addr
,
27 free_pages((unsigned long)cpu_addr
, get_order(size
));
30 static dma_addr_t
dma_noop_map_page(struct device
*dev
, struct page
*page
,
31 unsigned long offset
, size_t size
,
32 enum dma_data_direction dir
,
35 return page_to_phys(page
) + offset
;
38 static int dma_noop_map_sg(struct device
*dev
, struct scatterlist
*sgl
, int nents
,
39 enum dma_data_direction dir
,
43 struct scatterlist
*sg
;
45 for_each_sg(sgl
, sg
, nents
, i
) {
50 sg_dma_address(sg
) = (dma_addr_t
)virt_to_phys(va
);
51 sg_dma_len(sg
) = sg
->length
;
57 const struct dma_map_ops dma_noop_ops
= {
58 .alloc
= dma_noop_alloc
,
59 .free
= dma_noop_free
,
60 .map_page
= dma_noop_map_page
,
61 .map_sg
= dma_noop_map_sg
,
64 EXPORT_SYMBOL(dma_noop_ops
);