@@ -27,6 +27,9 @@ struct dma_map_ops {
unsigned long attrs);
void (*free_noncontiguous)(struct device *dev, size_t size,
struct sg_table *sgt, enum dma_data_direction dir);
+ void *(*vmap_noncontiguous)(struct device *dev, size_t size,
+ struct sg_table *sgt);
+ void (*vunmap_noncontiguous)(struct device *dev, void *addr);
int (*mmap)(struct device *, struct vm_area_struct *,
void *, dma_addr_t, size_t, unsigned long attrs);
@@ -674,8 +674,14 @@ void *dma_vmap_noncontiguous(struct device *dev, size_t size,
const struct dma_map_ops *ops = get_dma_ops(dev);
unsigned long count = PAGE_ALIGN(size) >> PAGE_SHIFT;
- if (ops && ops->alloc_noncontiguous)
- return vmap(sgt_handle(sgt)->pages, count, VM_MAP, PAGE_KERNEL);
+ if (ops) {
+ if (ops->vmap_noncontiguous)
+ return ops->vmap_noncontiguous(dev, size, sgt);
+ else if (ops->alloc_noncontiguous)
+ return vmap(sgt_handle(sgt)->pages, count, VM_MAP,
+ PAGE_KERNEL);
+ }
+
return page_address(sg_page(sgt->sgl));
}
EXPORT_SYMBOL_GPL(dma_vmap_noncontiguous);
@@ -684,8 +690,12 @@ void dma_vunmap_noncontiguous(struct device *dev, void *vaddr)
{
const struct dma_map_ops *ops = get_dma_ops(dev);
- if (ops && ops->alloc_noncontiguous)
- vunmap(vaddr);
+ if (ops) {
+ if (ops->vunmap_noncontiguous)
+ ops->vunmap_noncontiguous(dev, vaddr);
+ else if (ops->alloc_noncontiguous)
+ vunmap(vaddr);
+ }
}
EXPORT_SYMBOL_GPL(dma_vunmap_noncontiguous);