Example #1
0
/* Allocates a contiguous real buffer and creates mappings over it.
 * Returns the virtual address of the buffer and sets dma_handle
 * to the dma address (mapping) of the first page.
 */
static void *pci_iommu_alloc_coherent(struct device *hwdev, size_t size,
			   dma_addr_t *dma_handle, gfp_t flag)
{
	return iommu_alloc_coherent(device_to_table(hwdev), size, dma_handle,
			device_to_mask(hwdev), flag,
			pcibus_to_node(to_pci_dev(hwdev)->bus));
}
Example #2
0
/* We support DMA to/from any memory page via the iommu */
static int ofdev_iommu_dma_supported(struct device *dev, u64 mask)
{
	struct iommu_table *tbl = device_to_table(dev);

	if (!tbl || tbl->it_offset > mask) {
		printk(KERN_INFO "Warning: IOMMU table offset too big for device mask\n");
		if (tbl)
			printk(KERN_INFO "mask: 0x%08lx, table offset: 0x%08lx\n",
				mask, tbl->it_offset);
		else
			printk(KERN_INFO "mask: 0x%08lx, table unavailable\n",
				mask);
		return 0;
	} else
		return 1;
}
Example #3
0
static void ofdev_iommu_unmap_single(struct device *hwdev, dma_addr_t dma_handle,
		size_t size, enum dma_data_direction direction)
{
	iommu_unmap_single(device_to_table(hwdev), dma_handle, size, direction);
}
Example #4
0
/* Creates TCEs for a user provided buffer.  The user buffer must be
 * contiguous real kernel storage (not vmalloc).  The address of the buffer
 * passed here is the kernel (virtual) address of the buffer.  The buffer
 * need not be page aligned, the dma_addr_t returned will point to the same
 * byte within the page as vaddr.
 */
static dma_addr_t ofdev_iommu_map_single(struct device *hwdev, void *vaddr,
		size_t size, enum dma_data_direction direction)
{
	return iommu_map_single(device_to_table(hwdev), vaddr, size,
			        device_to_mask(hwdev), direction);
}
Example #5
0
static void ofdev_iommu_free_coherent(struct device *hwdev, size_t size,
			 void *vaddr, dma_addr_t dma_handle)
{
	iommu_free_coherent(device_to_table(hwdev), size, vaddr, dma_handle);
}
Example #6
0
/* Allocates a contiguous real buffer and creates mappings over it.
 * Returns the virtual address of the buffer and sets dma_handle
 * to the dma address (mapping) of the first page.
 */
static void *ofdev_iommu_alloc_coherent(struct device *hwdev, size_t size,
			   dma_addr_t *dma_handle, gfp_t flag)
{
	return iommu_alloc_coherent(device_to_table(hwdev), size, dma_handle,
			device_to_mask(hwdev), flag, device_to_node(hwdev));
}
Example #7
0
static void ofdev_iommu_unmap_sg(struct device *dev, struct scatterlist *sglist,
		int nelems, enum dma_data_direction direction)
{
	iommu_unmap_sg(device_to_table(dev), sglist, nelems, direction);
}
Example #8
0
static int ofdev_iommu_map_sg(struct device *dev, struct scatterlist *sglist,
		int nelems, enum dma_data_direction direction)
{
	return iommu_map_sg(dev, device_to_table(dev), sglist,
			nelems, device_to_mask(dev), direction);
}