mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 07:12:09 +00:00
dma-mapping: add a dma_alloc_noncontiguous API
Add a new API that returns a potentiall virtually non-contigous sg_table and a DMA address. This API is only properly implemented for dma-iommu and will simply return a contigious chunk as a fallback. The intent is that drivers can use this API if either: - no kernel mapping or only temporary kernel mappings are required. That is as a better replacement for DMA_ATTR_NO_KERNEL_MAPPING - a kernel mapping is required for cached and DMA mapped pages, but the driver also needs the pages to e.g. map them to userspace. In that sense it is a replacement for some aspects of the recently removed and never fully implemented DMA_ATTR_NON_CONSISTENT Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Tested-by: Ricardo Ribalda <ribalda@chromium.org>
This commit is contained in:
parent
198c50e2cc
commit
7d5b5738d1
4 changed files with 235 additions and 0 deletions
|
@ -144,6 +144,15 @@ u64 dma_get_required_mask(struct device *dev);
|
|||
size_t dma_max_mapping_size(struct device *dev);
|
||||
bool dma_need_sync(struct device *dev, dma_addr_t dma_addr);
|
||||
unsigned long dma_get_merge_boundary(struct device *dev);
|
||||
struct sg_table *dma_alloc_noncontiguous(struct device *dev, size_t size,
|
||||
enum dma_data_direction dir, gfp_t gfp, unsigned long attrs);
|
||||
void dma_free_noncontiguous(struct device *dev, size_t size,
|
||||
struct sg_table *sgt, enum dma_data_direction dir);
|
||||
void *dma_vmap_noncontiguous(struct device *dev, size_t size,
|
||||
struct sg_table *sgt);
|
||||
void dma_vunmap_noncontiguous(struct device *dev, void *vaddr);
|
||||
int dma_mmap_noncontiguous(struct device *dev, struct vm_area_struct *vma,
|
||||
size_t size, struct sg_table *sgt);
|
||||
#else /* CONFIG_HAS_DMA */
|
||||
static inline dma_addr_t dma_map_page_attrs(struct device *dev,
|
||||
struct page *page, size_t offset, size_t size,
|
||||
|
@ -257,6 +266,29 @@ static inline unsigned long dma_get_merge_boundary(struct device *dev)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
static inline struct sg_table *dma_alloc_noncontiguous(struct device *dev,
|
||||
size_t size, enum dma_data_direction dir, gfp_t gfp,
|
||||
unsigned long attrs)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
static inline void dma_free_noncontiguous(struct device *dev, size_t size,
|
||||
struct sg_table *sgt, enum dma_data_direction dir)
|
||||
{
|
||||
}
|
||||
static inline void *dma_vmap_noncontiguous(struct device *dev, size_t size,
|
||||
struct sg_table *sgt)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
static inline void dma_vunmap_noncontiguous(struct device *dev, void *vaddr)
|
||||
{
|
||||
}
|
||||
static inline int dma_mmap_noncontiguous(struct device *dev,
|
||||
struct vm_area_struct *vma, size_t size, struct sg_table *sgt)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif /* CONFIG_HAS_DMA */
|
||||
|
||||
struct page *dma_alloc_pages(struct device *dev, size_t size,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue