drm/tegra: Update to support v5.11

For Linux v5.11, there are a some changes to the DRM APIs that require
updates to the Tegra DRM driver. These are:
1. Commit 6619ccf1bb1d ("dma-buf: Use struct dma_buf_map in
   dma_buf_vmap() interfaces") changes to the dma_buf_vmap() and
   dma_buf_vunmap() APIs to pass a new parameter of type
   'struct dma_buf_map'.
2. Commit 351f950db4ab ("drm/atomic: Pass the full state to CRTC atomic
   enable/disable) and commit f6ebe9f9c923 ("drm/atomic: Pass the full
   state to CRTC atomic begin and flush") changes the structure type
   passed to APIs referenced by the commits.

Finally, commit dd311c6fe8af ("drm/tegra: Introduce GEM object
functions") update the Tegra DRM driver to use GEM object functions.

Update the Tegra DRM driver to support these updated APIs for
Linux v5.11+ and align with the latest changes.

Bug 200687525

Change-Id: I7b11c3f4c4f03afe23563a3de12170c7543c28fe
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2469985
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Jon Hunter
2021-01-11 16:44:42 +00:00
committed by Laxman Dewangan
parent d3ea27d381
commit 636389b442
3 changed files with 78 additions and 14 deletions

View File

@@ -133,24 +133,41 @@ static void tegra_bo_unpin(struct device *dev, struct sg_table *sgt)
static void *tegra_bo_mmap(struct host1x_bo *bo)
{
struct tegra_bo *obj = host1x_to_tegra_bo(bo);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
struct dma_buf_map map;
int ret;
#endif
if (obj->vaddr)
if (obj->vaddr) {
return obj->vaddr;
else if (obj->gem.import_attach)
} else if (obj->gem.import_attach) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
ret = dma_buf_vmap(obj->gem.import_attach->dmabuf, &map);
return ret ? NULL : map.vaddr;
#else
return dma_buf_vmap(obj->gem.import_attach->dmabuf);
else
#endif
} else {
return vmap(obj->pages, obj->num_pages, VM_MAP,
pgprot_writecombine(PAGE_KERNEL));
}
}
static void tegra_bo_munmap(struct host1x_bo *bo, void *addr)
{
struct tegra_bo *obj = host1x_to_tegra_bo(bo);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(addr);
#endif
if (obj->vaddr)
return;
else if (obj->gem.import_attach)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
dma_buf_vunmap(obj->gem.import_attach->dmabuf, &map);
#else
dma_buf_vunmap(obj->gem.import_attach->dmabuf, addr);
#endif
else
vunmap(addr);
}
@@ -231,6 +248,12 @@ static int tegra_bo_iommu_unmap(struct tegra_drm *tegra, struct tegra_bo *bo)
return 0;
}
static const struct drm_gem_object_funcs tegra_gem_object_funcs = {
.free = tegra_bo_free_object,
.export = tegra_gem_prime_export,
.vm_ops = &tegra_bo_vm_ops,
};
static struct tegra_bo *tegra_bo_alloc_object(struct drm_device *drm,
size_t size)
{
@@ -241,6 +264,8 @@ static struct tegra_bo *tegra_bo_alloc_object(struct drm_device *drm,
if (!bo)
return ERR_PTR(-ENOMEM);
bo->gem.funcs = &tegra_gem_object_funcs;
host1x_bo_init(&bo->base, &tegra_bo_ops);
size = round_up(size, PAGE_SIZE);
@@ -640,6 +665,21 @@ static int tegra_gem_prime_mmap(struct dma_buf *buf, struct vm_area_struct *vma)
return __tegra_gem_mmap(gem, vma);
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
static int tegra_gem_prime_vmap(struct dma_buf *buf, struct dma_buf_map *map)
{
struct drm_gem_object *gem = buf->priv;
struct tegra_bo *bo = to_tegra_bo(gem);
dma_buf_map_set_vaddr(map, bo->vaddr);
return 0;
}
static void tegra_gem_prime_vunmap(struct dma_buf *buf, struct dma_buf_map *map)
{
}
#else
static void *tegra_gem_prime_vmap(struct dma_buf *buf)
{
struct drm_gem_object *gem = buf->priv;
@@ -651,6 +691,7 @@ static void *tegra_gem_prime_vmap(struct dma_buf *buf)
static void tegra_gem_prime_vunmap(struct dma_buf *buf, void *vaddr)
{
}
#endif
static const struct dma_buf_ops tegra_gem_prime_dmabuf_ops = {
.map_dma_buf = tegra_gem_prime_map_dma_buf,