mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-24 10:11:26 +03:00
drm/tegra: Update Tegra DRM to align with v5.10
Update the Tegra DRM driver to Linux v5.10 with the 'Host1x/Tegra UAPI' series [0] applied. This driver is built as an external module for testing and development with upstream Linux kernels. [0] https://patchwork.ozlabs.org/project/linux-tegra/list/?series=215770 Bug 3205478 Change-Id: I901aa45779e56cbbef6c58fd9d3bb50ea6bfd472 Signed-off-by: Jon Hunter <jonathanh@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2460064 Reviewed-by: Shanker Donthineni <sdonthineni@nvidia.com> Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
Laxman Dewangan
parent
b8c2d943ed
commit
d088bfa37d
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <linux/dma-buf.h>
|
||||
#include <linux/iommu.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#include <drm/drm_drv.h>
|
||||
#include <drm/drm_prime.h>
|
||||
@@ -98,8 +99,8 @@ static struct sg_table *tegra_bo_pin(struct device *dev, struct host1x_bo *bo,
|
||||
* the SG table needs to be copied to avoid overwriting any
|
||||
* other potential users of the original SG table.
|
||||
*/
|
||||
err = sg_alloc_table_from_sg(sgt, obj->sgt->sgl, obj->sgt->nents,
|
||||
GFP_KERNEL);
|
||||
err = sg_alloc_table_from_sg(sgt, obj->sgt->sgl,
|
||||
obj->sgt->orig_nents, GFP_KERNEL);
|
||||
if (err < 0)
|
||||
goto free;
|
||||
} else {
|
||||
@@ -196,8 +197,7 @@ static int tegra_bo_iommu_map(struct tegra_drm *tegra, struct tegra_bo *bo)
|
||||
|
||||
bo->iova = bo->mm->start;
|
||||
|
||||
bo->size = iommu_map_sg(tegra->domain, bo->iova, bo->sgt->sgl,
|
||||
bo->sgt->nents, prot);
|
||||
bo->size = iommu_map_sgtable(tegra->domain, bo->iova, bo->sgt, prot);
|
||||
if (!bo->size) {
|
||||
dev_err(tegra->drm->dev, "failed to map buffer\n");
|
||||
err = -ENOMEM;
|
||||
@@ -264,8 +264,7 @@ free:
|
||||
static void tegra_bo_free(struct drm_device *drm, struct tegra_bo *bo)
|
||||
{
|
||||
if (bo->pages) {
|
||||
dma_unmap_sg(drm->dev, bo->sgt->sgl, bo->sgt->nents,
|
||||
DMA_FROM_DEVICE);
|
||||
dma_unmap_sgtable(drm->dev, bo->sgt, DMA_FROM_DEVICE, 0);
|
||||
drm_gem_put_pages(&bo->gem, bo->pages, true, true);
|
||||
sg_free_table(bo->sgt);
|
||||
kfree(bo->sgt);
|
||||
@@ -284,18 +283,19 @@ static int tegra_bo_get_pages(struct drm_device *drm, struct tegra_bo *bo)
|
||||
|
||||
bo->num_pages = bo->gem.size >> PAGE_SHIFT;
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)
|
||||
bo->sgt = drm_prime_pages_to_sg(bo->gem.dev, bo->pages, bo->num_pages);
|
||||
#else
|
||||
bo->sgt = drm_prime_pages_to_sg(bo->pages, bo->num_pages);
|
||||
#endif
|
||||
if (IS_ERR(bo->sgt)) {
|
||||
err = PTR_ERR(bo->sgt);
|
||||
goto put_pages;
|
||||
}
|
||||
|
||||
err = dma_map_sg(drm->dev, bo->sgt->sgl, bo->sgt->nents,
|
||||
DMA_FROM_DEVICE);
|
||||
if (err == 0) {
|
||||
err = -EFAULT;
|
||||
err = dma_map_sgtable(drm->dev, bo->sgt, DMA_FROM_DEVICE, 0);
|
||||
if (err)
|
||||
goto free_sgt;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -572,7 +572,7 @@ tegra_gem_prime_map_dma_buf(struct dma_buf_attachment *attach,
|
||||
goto free;
|
||||
}
|
||||
|
||||
if (dma_map_sg(attach->dev, sgt->sgl, sgt->nents, dir) == 0)
|
||||
if (dma_map_sgtable(attach->dev, sgt, dir, 0))
|
||||
goto free;
|
||||
|
||||
return sgt;
|
||||
@@ -591,7 +591,7 @@ static void tegra_gem_prime_unmap_dma_buf(struct dma_buf_attachment *attach,
|
||||
struct tegra_bo *bo = to_tegra_bo(gem);
|
||||
|
||||
if (bo->pages)
|
||||
dma_unmap_sg(attach->dev, sgt->sgl, sgt->nents, dir);
|
||||
dma_unmap_sgtable(attach->dev, sgt, dir, 0);
|
||||
|
||||
sg_free_table(sgt);
|
||||
kfree(sgt);
|
||||
@@ -610,8 +610,7 @@ static int tegra_gem_prime_begin_cpu_access(struct dma_buf *buf,
|
||||
struct drm_device *drm = gem->dev;
|
||||
|
||||
if (bo->pages)
|
||||
dma_sync_sg_for_cpu(drm->dev, bo->sgt->sgl, bo->sgt->nents,
|
||||
DMA_FROM_DEVICE);
|
||||
dma_sync_sgtable_for_cpu(drm->dev, bo->sgt, DMA_FROM_DEVICE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -624,8 +623,7 @@ static int tegra_gem_prime_end_cpu_access(struct dma_buf *buf,
|
||||
struct drm_device *drm = gem->dev;
|
||||
|
||||
if (bo->pages)
|
||||
dma_sync_sg_for_device(drm->dev, bo->sgt->sgl, bo->sgt->nents,
|
||||
DMA_TO_DEVICE);
|
||||
dma_sync_sgtable_for_device(drm->dev, bo->sgt, DMA_TO_DEVICE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user