Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/tegra: gem: Remove premature import restrictions

All the display related blocks on Tegra require contiguous memory. Using
the DMA API, there is no knowing at import time which device will end up
using the buffer, so it's not known whether or not an IOMMU will be used
to map the buffer.

Move the check for non-contiguous buffers/mappings to the tegra_dc_pin()
function which is now the earliest point where it is known if a DMA BUF
can be used by the given device or not.

v2: add check for contiguous buffer/mapping in tegra_dc_pin()

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Thierry Reding <treding@nvidia.com>

+11 -7
-7
drivers/gpu/drm/tegra/gem.c
··· 440 440 err = tegra_bo_iommu_map(tegra, bo); 441 441 if (err < 0) 442 442 goto detach; 443 - } else { 444 - if (bo->sgt->nents > 1) { 445 - err = -EINVAL; 446 - goto detach; 447 - } 448 - 449 - bo->iova = sg_dma_address(bo->sgt->sgl); 450 443 } 451 444 452 445 bo->gem.import_attach = attach;
+11
drivers/gpu/drm/tegra/plane.c
··· 129 129 goto unpin; 130 130 } 131 131 132 + /* 133 + * The display controller needs contiguous memory, so 134 + * fail if the buffer is discontiguous and we fail to 135 + * map its SG table to a single contiguous chunk of 136 + * I/O virtual memory. 137 + */ 138 + if (err > 1) { 139 + err = -EINVAL; 140 + goto unpin; 141 + } 142 + 132 143 state->iova[i] = sg_dma_address(sgt->sgl); 133 144 state->sgt[i] = sgt; 134 145 } else {