Merge tag 'drm-misc-next-2020-10-27' of git://anongit.freedesktop.org/drm/drm-misc...
[sfrench/cifs-2.6.git] / drivers / gpu / drm / tegra / gem.c
index 5df577682878c3923cf56f49c122f76f37242502..26af8daa9a1681b0d1c860903fc469c17434ac4e 100644 (file)
@@ -98,8 +98,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 {
@@ -201,8 +201,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;
@@ -277,8 +276,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);
@@ -303,12 +301,9 @@ static int tegra_bo_get_pages(struct drm_device *drm, struct tegra_bo *bo)
                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;
 
@@ -584,7 +579,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;
@@ -603,7 +598,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);
@@ -622,8 +617,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;
 }
@@ -636,8 +630,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;
 }