Merge tag 'sound-5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai...
[linux-2.6-microblaze.git] / drivers / gpu / drm / amd / amdgpu / amdgpu_dma_buf.c
index 37ec593..a9475b2 100644 (file)
 #include <linux/pci-p2pdma.h>
 #include <linux/pm_runtime.h>
 
-/**
- * amdgpu_gem_prime_mmap - &drm_driver.gem_prime_mmap implementation
- * @obj: GEM BO
- * @vma: Virtual memory area
- *
- * Sets up a userspace mapping of the BO's memory in the given
- * virtual memory area.
- *
- * Returns:
- * 0 on success or a negative error code on failure.
- */
-int amdgpu_gem_prime_mmap(struct drm_gem_object *obj,
-                         struct vm_area_struct *vma)
-{
-       struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
-       struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
-       unsigned asize = amdgpu_bo_size(bo);
-       int ret;
-
-       if (!vma->vm_file)
-               return -ENODEV;
-
-       if (adev == NULL)
-               return -ENODEV;
-
-       /* Check for valid size. */
-       if (asize < vma->vm_end - vma->vm_start)
-               return -EINVAL;
-
-       if (amdgpu_ttm_tt_get_usermm(bo->tbo.ttm) ||
-           (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)) {
-               return -EPERM;
-       }
-       vma->vm_pgoff += amdgpu_bo_mmap_offset(bo) >> PAGE_SHIFT;
-
-       /* prime mmap does not need to check access, so allow here */
-       ret = drm_vma_node_allow(&obj->vma_node, vma->vm_file->private_data);
-       if (ret)
-               return ret;
-
-       ret = ttm_bo_mmap(vma->vm_file, vma, &adev->mman.bdev);
-       drm_vma_node_revoke(&obj->vma_node, vma->vm_file->private_data);
-
-       return ret;
-}
-
 static int
 __dma_resv_make_exclusive(struct dma_resv *obj)
 {
@@ -95,10 +49,10 @@ __dma_resv_make_exclusive(struct dma_resv *obj)
        unsigned int count;
        int r;
 
-       if (!dma_resv_get_list(obj)) /* no shared fences to convert */
+       if (!dma_resv_shared_list(obj)) /* no shared fences to convert */
                return 0;
 
-       r = dma_resv_get_fences_rcu(obj, NULL, &count, &fences);
+       r = dma_resv_get_fences(obj, NULL, &count, &fences);
        if (r)
                return r;
 
@@ -284,12 +238,12 @@ static struct sg_table *amdgpu_dma_buf_map(struct dma_buf_attachment *attach,
                if (r)
                        return ERR_PTR(r);
 
-       } else if (!(amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type) &
+       } else if (!(amdgpu_mem_type_to_domain(bo->tbo.resource->mem_type) &
                     AMDGPU_GEM_DOMAIN_GTT)) {
                return ERR_PTR(-EBUSY);
        }
 
-       switch (bo->tbo.mem.mem_type) {
+       switch (bo->tbo.resource->mem_type) {
        case TTM_PL_TT:
                sgt = drm_prime_pages_to_sg(obj->dev,
                                            bo->tbo.ttm->pages,
@@ -303,8 +257,9 @@ static struct sg_table *amdgpu_dma_buf_map(struct dma_buf_attachment *attach,
                break;
 
        case TTM_PL_VRAM:
-               r = amdgpu_vram_mgr_alloc_sgt(adev, &bo->tbo.mem, 0,
-                               bo->tbo.base.size, attach->dev, dir, &sgt);
+               r = amdgpu_vram_mgr_alloc_sgt(adev, bo->tbo.resource, 0,
+                                             bo->tbo.base.size, attach->dev,
+                                             dir, &sgt);
                if (r)
                        return ERR_PTR(r);
                break;
@@ -494,7 +449,7 @@ amdgpu_dma_buf_move_notify(struct dma_buf_attachment *attach)
        struct amdgpu_vm_bo_base *bo_base;
        int r;
 
-       if (bo->tbo.mem.mem_type == TTM_PL_SYSTEM)
+       if (bo->tbo.resource->mem_type == TTM_PL_SYSTEM)
                return;
 
        r = ttm_bo_validate(&bo->tbo, &placement, &ctx);
@@ -505,7 +460,7 @@ amdgpu_dma_buf_move_notify(struct dma_buf_attachment *attach)
 
        for (bo_base = bo->vm_bo; bo_base; bo_base = bo_base->next) {
                struct amdgpu_vm *vm = bo_base->vm;
-               struct dma_resv *resv = vm->root.base.bo->tbo.base.resv;
+               struct dma_resv *resv = vm->root.bo->tbo.base.resv;
 
                if (ticket) {
                        /* When we get an error here it means that somebody