Merge tag 'exfat-for-5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/linki...
[linux-2.6-microblaze.git] / drivers / gpu / drm / radeon / radeon_ttm.c
index 380b300..ad2a5a7 100644 (file)
@@ -38,7 +38,6 @@
 #include <linux/swap.h>
 #include <linux/swiotlb.h>
 
-#include <drm/drm_agpsupport.h>
 #include <drm/drm_device.h>
 #include <drm/drm_file.h>
 #include <drm/drm_prime.h>
@@ -46,6 +45,7 @@
 #include <drm/ttm/ttm_bo_api.h>
 #include <drm/ttm/ttm_bo_driver.h>
 #include <drm/ttm/ttm_placement.h>
+#include <drm/ttm/ttm_range_manager.h>
 
 #include "radeon_reg.h"
 #include "radeon.h"
@@ -99,12 +99,12 @@ static void radeon_evict_flags(struct ttm_buffer_object *bo,
                return;
        }
        rbo = container_of(bo, struct radeon_bo, tbo);
-       switch (bo->mem.mem_type) {
+       switch (bo->resource->mem_type) {
        case TTM_PL_VRAM:
                if (rbo->rdev->ring[radeon_copy_ring_index(rbo->rdev)].ready == false)
                        radeon_ttm_placement_from_domain(rbo, RADEON_GEM_DOMAIN_CPU);
                else if (rbo->rdev->mc.visible_vram_size < rbo->rdev->mc.real_vram_size &&
-                        bo->mem.start < (rbo->rdev->mc.visible_vram_size >> PAGE_SHIFT)) {
+                        bo->resource->start < (rbo->rdev->mc.visible_vram_size >> PAGE_SHIFT)) {
                        unsigned fpfn = rbo->rdev->mc.visible_vram_size >> PAGE_SHIFT;
                        int i;
 
@@ -136,17 +136,6 @@ static void radeon_evict_flags(struct ttm_buffer_object *bo,
        *placement = rbo->placement;
 }
 
-static int radeon_verify_access(struct ttm_buffer_object *bo, struct file *filp)
-{
-       struct radeon_bo *rbo = container_of(bo, struct radeon_bo, tbo);
-       struct radeon_device *rdev = radeon_get_rdev(bo->bdev);
-
-       if (radeon_ttm_tt_has_userptr(rdev, bo->ttm))
-               return -EPERM;
-       return drm_vma_node_verify_access(&rbo->tbo.base.vma_node,
-                                         filp->private_data);
-}
-
 static int radeon_move_blit(struct ttm_buffer_object *bo,
                        bool evict,
                        struct ttm_resource *new_mem,
@@ -207,9 +196,9 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
                          struct ttm_resource *new_mem,
                          struct ttm_place *hop)
 {
+       struct ttm_resource *old_mem = bo->resource;
        struct radeon_device *rdev;
        struct radeon_bo *rbo;
-       struct ttm_resource *old_mem = &bo->mem;
        int r;
 
        if (new_mem->mem_type == TTM_PL_TT) {
@@ -241,7 +230,7 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
        if (old_mem->mem_type == TTM_PL_TT &&
            new_mem->mem_type == TTM_PL_SYSTEM) {
                radeon_ttm_tt_unbind(bo->bdev, bo->ttm);
-               ttm_resource_free(bo, &bo->mem);
+               ttm_resource_free(bo, &bo->resource);
                ttm_bo_assign_mem(bo, new_mem);
                goto out;
        }
@@ -291,7 +280,7 @@ static int radeon_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resourc
                        /* RADEON_IS_AGP is set only if AGP is active */
                        mem->bus.offset = (mem->start << PAGE_SHIFT) +
                                rdev->mc.agp_base;
-                       mem->bus.is_iomem = !rdev->ddev->agp->cant_use_aperture;
+                       mem->bus.is_iomem = !rdev->agp->cant_use_aperture;
                        mem->bus.caching = ttm_write_combined;
                }
 #endif
@@ -513,8 +502,7 @@ static struct ttm_tt *radeon_ttm_tt_create(struct ttm_buffer_object *bo,
        struct radeon_device *rdev = radeon_get_rdev(bo->bdev);
 
        if (rdev->flags & RADEON_IS_AGP) {
-               return ttm_agp_tt_create(bo, rdev->ddev->agp->bridge,
-                                        page_flags);
+               return ttm_agp_tt_create(bo, rdev->agp->bridge, page_flags);
        }
 #endif
        rbo = container_of(bo, struct radeon_bo, tbo);
@@ -705,7 +693,6 @@ static struct ttm_device_funcs radeon_bo_driver = {
        .eviction_valuable = ttm_bo_eviction_valuable,
        .evict_flags = &radeon_evict_flags,
        .move = &radeon_bo_move,
-       .verify_access = &radeon_verify_access,
        .delete_mem_notify = &radeon_bo_delete_mem_notify,
        .io_mem_reserve = &radeon_ttm_io_mem_reserve,
 };
@@ -802,59 +789,6 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
        man->size = size >> PAGE_SHIFT;
 }
 
-static vm_fault_t radeon_ttm_fault(struct vm_fault *vmf)
-{
-       struct ttm_buffer_object *bo = vmf->vma->vm_private_data;
-       struct radeon_device *rdev = radeon_get_rdev(bo->bdev);
-       vm_fault_t ret;
-
-       down_read(&rdev->pm.mclk_lock);
-
-       ret = ttm_bo_vm_reserve(bo, vmf);
-       if (ret)
-               goto unlock_mclk;
-
-       ret = radeon_bo_fault_reserve_notify(bo);
-       if (ret)
-               goto unlock_resv;
-
-       ret = ttm_bo_vm_fault_reserved(vmf, vmf->vma->vm_page_prot,
-                                      TTM_BO_VM_NUM_PREFAULT, 1);
-       if (ret == VM_FAULT_RETRY && !(vmf->flags & FAULT_FLAG_RETRY_NOWAIT))
-               goto unlock_mclk;
-
-unlock_resv:
-       dma_resv_unlock(bo->base.resv);
-
-unlock_mclk:
-       up_read(&rdev->pm.mclk_lock);
-       return ret;
-}
-
-static const struct vm_operations_struct radeon_ttm_vm_ops = {
-       .fault = radeon_ttm_fault,
-       .open = ttm_bo_vm_open,
-       .close = ttm_bo_vm_close,
-       .access = ttm_bo_vm_access
-};
-
-int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
-{
-       int r;
-       struct drm_file *file_priv = filp->private_data;
-       struct radeon_device *rdev = file_priv->minor->dev->dev_private;
-
-       if (rdev == NULL)
-               return -EINVAL;
-
-       r = ttm_bo_mmap(filp, vma, &rdev->mman.bdev);
-       if (unlikely(r != 0))
-               return r;
-
-       vma->vm_ops = &radeon_ttm_vm_ops;
-       return 0;
-}
-
 #if defined(CONFIG_DEBUG_FS)
 
 static int radeon_mm_vram_dump_table_show(struct seq_file *m, void *unused)