-
Notifications
You must be signed in to change notification settings - Fork 6
Expectations from IOMMU functions
Miouyouyou edited this page Aug 13, 2017
·
1 revision
static struct vcodec_iommu_ops drm_ops = {
.create = vcodec_drm_create,
.import = vcodec_drm_import,
.free = vcodec_drm_free,
.free_fd = vcodec_drm_free_fd,
.map_kernel = vcodec_drm_map_kernel,
.unmap_kernel = vcodec_drm_unmap_kernel,
.map_iommu = vcodec_drm_map_iommu,
.unmap_iommu = vcodec_drm_unmap_iommu,
.destroy = vcodec_drm_destroy,
.dump = vcdoec_drm_dump_info,
.attach = vcodec_drm_attach,
.detach = vcodec_drm_detach,
.clear = vcodec_drm_clear_session,
};
Analysis of the VCODEC IOMMU ION implementation :
.map_iommu returns 0 on success, a negative value on failure, using :
ion_map_iommu(vpu_dev: struct device *iommu_dev,
ion_client: struct ion_client *client,
ion_handle: struct ion_handle *handle,
iova: unsigned long *iova (Not setup),
size: unsigned long *size (Not setup))
→ __ion_iommu_map(handle->buffer: struct ion_buffer *buffer,
iommu_dev: struct device *iommu_dev,
iova: unsigned long *iova (Not setup))
→ map_iommu(buffer: struct ion_buffer *buffer,
iommu_dev: struct device *iommu_dev,
data: struct ion_iommu_map *data,
buffer->size: unsigned long iova_length,
buffer->flags: unsigned long flags)
→ rockchip_iovmm_map(iommu_dev: struct device *dev,
table->sgl: struct scatterlist *sg,
0: off_t offset,
iova_length: size_t size);
← Returns (dma_addr_t) ( gen_pool_alloc(vmm->vmm_pool, size+IOMMU_REGION_GUARD) + offset_in_page(sg_phys(sg)) )
vmm->vmm_pool = gen_pool_create(PAGE_SHIFT, -1);
gen_pool_add(vmm->vmm_pool, IOVA_START, IOVM_SIZE, -1);
#define IOVA_START 0x10000000
#define IOVM_SIZE (SZ_1G - SZ_4K) /* last 4K is for error values */
→ Setup data->iova to the value returned by rockchip_iovmm_map
.map_kernel returns NULL (0) when using the drm_heap ION implementation and the cpu address of the ION buffer allocated using the coherent allocator of the Linux DMA API; when using the cma_heap ION implementation.