/*
* Generic direct DMA implementation
+ *
+ * This implementation supports a global offset that can be applied if
+ * the address at which memory is visible to devices is not 0.
*/
+unsigned long dma_direct_offset;
static void *dma_direct_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t flag)
ret = (void *)__get_free_pages(flag, get_order(size));
if (ret != NULL) {
memset(ret, 0, size);
- *dma_handle = virt_to_abs(ret);
+ *dma_handle = virt_to_abs(ret) | dma_direct_offset;
}
return ret;
}
size_t size,
enum dma_data_direction direction)
{
- return virt_to_abs(ptr);
+ return virt_to_abs(ptr) | dma_direct_offset;
}
static void dma_direct_unmap_single(struct device *dev, dma_addr_t dma_addr,
int i;
for (i = 0; i < nents; i++, sg++) {
- sg->dma_address = page_to_phys(sg->page) + sg->offset;
+ sg->dma_address = (page_to_phys(sg->page) + sg->offset) |
+ dma_direct_offset;
sg->dma_length = sg->length;
}
extern struct dma_mapping_ops dma_iommu_ops;
extern struct dma_mapping_ops dma_direct_ops;
+extern unsigned long dma_direct_offset;
+
#else /* CONFIG_PPC64 */
#define dma_supported(dev, mask) (1)