For dma-direct we know that the DMA address is an encoding of the physical address that we can trivially decode. Use that fact to provide implementations that do not need the arch_dma_coherent_to_pfn architecture hook. Note that we still can only support mmap of non-coherent memory only if the architecture provides a way to set an uncached bit in the page tables. This must be true for architectures that use the generic remap helpers, but other architectures can also manually select it.
Showing the changes to include/linux (2 of 16 files). Show all
Unified · Split
| @@ -68,5 +68,12 @@ void dma_direct_free_pages(struct device *dev, size_t size, void *cpu_addr, · 67 unmodified lines | |||
| 68 | dma_addr_t dma_addr, unsigned long attrs); | 68 | dma_addr_t dma_addr, unsigned long attrs); |
| 69 | struct page *__dma_direct_alloc_pages(struct device *dev, size_t size, | 69 | struct page *__dma_direct_alloc_pages(struct device *dev, size_t size, |
| 70 | gfp_t gfp, unsigned long attrs); | 70 | gfp_t gfp, unsigned long attrs); |
| 71 | int dma_direct_get_sgtable(struct device *dev, struct sg_table *sgt, | ||
| 72 | void *cpu_addr, dma_addr_t dma_addr, size_t size, | ||
| 73 | unsigned long attrs); | ||
| 74 | bool dma_direct_can_mmap(struct device *dev); | ||
| 75 | int dma_direct_mmap(struct device *dev, struct vm_area_struct *vma, | ||
| 76 | void *cpu_addr, dma_addr_t dma_addr, size_t size, | ||
| 77 | unsigned long attrs); | ||
| 71 | int dma_direct_supported(struct device *dev, u64 mask); | 78 | int dma_direct_supported(struct device *dev, u64 mask); |
| 72 | #endif /* _LINUX_DMA_DIRECT_H */ | 79 | #endif /* _LINUX_DMA_DIRECT_H */ |
| @@ -41,8 +41,6 @@ void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, · 40 unmodified lines | |||
| 41 | gfp_t gfp, unsigned long attrs); | 41 | gfp_t gfp, unsigned long attrs); |
| 42 | void arch_dma_free(struct device *dev, size_t size, void *cpu_addr, | 42 | void arch_dma_free(struct device *dev, size_t size, void *cpu_addr, |
| 43 | dma_addr_t dma_addr, unsigned long attrs); | 43 | dma_addr_t dma_addr, unsigned long attrs); |
| 44 | long arch_dma_coherent_to_pfn(struct device *dev, void *cpu_addr, | ||
| 45 | dma_addr_t dma_addr); | ||
| 46 | 44 | ||
| 47 | #ifdef CONFIG_MMU | 45 | #ifdef CONFIG_MMU |
| 48 | /* | 46 | /* |