From: Prathyush K prathyush.k@samsung.com
With these set of patches, the Exynos5 DRM module will be able to allocate, export and map non-contiguous memory for GEM objects using the dma-mapping IOMMU framework.
These patches are based on the following references:
1> Exynos 5 SYSMMU driver by Kyongho Cho http://lists.infradead.org/pipermail/linux-arm-kernel/2011-December/078636.h... 2> DMA-MAPPING IOMMU framework by Marek Szyprowski http://lists.infradead.org/pipermail/linux-arm-kernel/2011-June/053636.html 3> DRM-PRIME by Dave Airlie http://patches.linaro.org/7480/ 4> DRM Exynos DMABUF module by Inki Dae http://git.infradead.org/users/kmpark/linux-2.6-samsung/commit/ d59d3e521d8a9d27e7b329f89f24a8473f32f50c/ 5> Support for dma_get_pages by Tomasz Stanislawski http://patchwork.linuxtv.org/patch/9639/
The updated GEM framework by Inki Dae is not considered for this patch set.
IOMMU mapping is created for exynos-drm-device initially. Allocation of GEM objects happens through dma_alloc_writecombine which inturn calls arm_iommu_alloc_attrs. This will allocate a non-contig set of pages, allocate a iova and map all the pages.
The following changes are done to support non-contiguous memory for GEM objects
[PATCH 1/4]: drm/exynos: DMABUF: Added support for exporting non-contig buffers. This patch is for creating and mapping a SGT in map_dma_buf by retrieving the pages by calling dma_get_pages.
[PATCH 2/4]: drm/exynos: Mapping of gem objects uses dma_mmap_writecombine. This patch is for mapping the non-contiguous GEM objects to user space by calling dma_mmap_writecombine.
[PATCH 3/4]: drm/Exynos: Added 'disable' function to Exynos drm crtc module. This patch is required for safe release of DRM. If a FB of a CRTC is released, the driver tries to disable the CRTC if that is supported by the CRTC. This patch adds Exynos DRM CRTC disable functionality.
[PATCH 4/4]: drm: Releasing FBs before releasing GEM objects during drm_release. This patch is required for safe release of DRM. During drm release, all the FBs and GEM objects are released. A gem object which is used as a FB must not be freed first before releasing the FB. This patch modifies the drm release function to first release the FBs and then release the GEMs.
drivers/gpu/drm/drm_fops.c | 6 +- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 11 +++ drivers/gpu/drm/exynos/exynos_drm_dmabuf.c | 98 +++++++++++++++++++++++----- drivers/gpu/drm/exynos/exynos_drm_gem.c | 70 +++++++++----------- 4 files changed, 128 insertions(+), 57 deletions(-)