]> git.karo-electronics.de Git - linux-beck.git/commitdiff
drm/radeon: Move looping over the PTEs into chip code
authorChristian König <deathsimple@vodafone.de>
Sat, 11 Aug 2012 09:54:05 +0000 (11:54 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 20 Sep 2012 17:10:39 +0000 (13:10 -0400)
Makes it easier to move it into the rings.

Signed-off-by: Christian König <deathsimple@vodafone.de>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
drivers/gpu/drm/radeon/ni.c
drivers/gpu/drm/radeon/radeon.h
drivers/gpu/drm/radeon/radeon_asic.c
drivers/gpu/drm/radeon/radeon_asic.h
drivers/gpu/drm/radeon/radeon_gart.c

index de378d685803d5f2a40950828dfb2ab78ee08017..8bec8113d3a175049a84045b1f9f523244e59577 100644 (file)
@@ -1503,9 +1503,7 @@ void cayman_vm_fini(struct radeon_device *rdev)
 #define R600_PTE_READABLE  (1 << 5)
 #define R600_PTE_WRITEABLE (1 << 6)
 
-uint32_t cayman_vm_page_flags(struct radeon_device *rdev,
-                             struct radeon_vm *vm,
-                             uint32_t flags)
+uint32_t cayman_vm_page_flags(struct radeon_device *rdev, uint32_t flags)
 {
        uint32_t r600_flags = 0;
 
@@ -1520,13 +1518,23 @@ uint32_t cayman_vm_page_flags(struct radeon_device *rdev,
 }
 
 void cayman_vm_set_page(struct radeon_device *rdev, struct radeon_vm *vm,
-                       unsigned pfn, uint64_t addr, uint32_t flags)
+                       unsigned pfn, struct ttm_mem_reg *mem,
+                       unsigned npages, uint32_t flags)
 {
        void __iomem *ptr = (void *)vm->pt;
+       uint64_t addr;
+       int i;
+
+       addr = flags = cayman_vm_page_flags(rdev, flags);
 
-       addr = addr & 0xFFFFFFFFFFFFF000ULL;
-       addr |= flags;
-       writeq(addr, ptr + (pfn * 8));
+        for (i = 0; i < npages; ++i, ++pfn) {
+                if (mem) {
+                        addr = radeon_vm_get_addr(rdev, mem, i);
+                       addr = addr & 0xFFFFFFFFFFFFF000ULL;
+                       addr |= flags;
+                }
+               writeq(addr, ptr + (pfn * 8));
+        }
 }
 
 void cayman_vm_flush(struct radeon_device *rdev, struct radeon_ib *ib)
index d6cd1f57fece62278f06fd8374d271ae8de86ba4..ae7409a0f62ba9ce33af486a6ab79dff36e8c939 100644 (file)
@@ -1135,11 +1135,9 @@ struct radeon_asic {
        struct {
                int (*init)(struct radeon_device *rdev);
                void (*fini)(struct radeon_device *rdev);
-               uint32_t (*page_flags)(struct radeon_device *rdev,
-                                      struct radeon_vm *vm,
-                                      uint32_t flags);
                void (*set_page)(struct radeon_device *rdev, struct radeon_vm *vm,
-                                unsigned pfn, uint64_t addr, uint32_t flags);
+                                unsigned pfn, struct ttm_mem_reg *mem,
+                                unsigned npages, uint32_t flags);
        } vm;
        /* ring specific callbacks */
        struct {
@@ -1751,8 +1749,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t v);
 #define radeon_gart_set_page(rdev, i, p) (rdev)->asic->gart.set_page((rdev), (i), (p))
 #define radeon_asic_vm_init(rdev) (rdev)->asic->vm.init((rdev))
 #define radeon_asic_vm_fini(rdev) (rdev)->asic->vm.fini((rdev))
-#define radeon_asic_vm_page_flags(rdev, v, flags) (rdev)->asic->vm.page_flags((rdev), (v), (flags))
-#define radeon_asic_vm_set_page(rdev, v, pfn, addr, flags) (rdev)->asic->vm.set_page((rdev), (v), (pfn), (addr), (flags))
+#define radeon_asic_vm_set_page(rdev, v, pfn, mem, npages, flags) (rdev)->asic->vm.set_page((rdev), (v), (pfn), (mem), (npages), (flags))
 #define radeon_ring_start(rdev, r, cp) (rdev)->asic->ring[(r)].ring_start((rdev), (cp))
 #define radeon_ring_test(rdev, r, cp) (rdev)->asic->ring[(r)].ring_test((rdev), (cp))
 #define radeon_ib_test(rdev, r, cp) (rdev)->asic->ring[(r)].ib_test((rdev), (cp))
@@ -1837,6 +1834,9 @@ struct radeon_fence *radeon_vm_grab_id(struct radeon_device *rdev,
 void radeon_vm_fence(struct radeon_device *rdev,
                     struct radeon_vm *vm,
                     struct radeon_fence *fence);
+u64 radeon_vm_get_addr(struct radeon_device *rdev,
+                       struct ttm_mem_reg *mem,
+                       unsigned pfn);
 int radeon_vm_bo_update_pte(struct radeon_device *rdev,
                            struct radeon_vm *vm,
                            struct radeon_bo *bo,
index 98c586ac1999b933439cdf95a0fe92165a177841..6e4e67edf60fd76f4eae03b3faaa50f7d9d05680 100644 (file)
@@ -1375,7 +1375,6 @@ static struct radeon_asic cayman_asic = {
        .vm = {
                .init = &cayman_vm_init,
                .fini = &cayman_vm_fini,
-               .page_flags = &cayman_vm_page_flags,
                .set_page = &cayman_vm_set_page,
        },
        .ring = {
@@ -1479,7 +1478,6 @@ static struct radeon_asic trinity_asic = {
        .vm = {
                .init = &cayman_vm_init,
                .fini = &cayman_vm_fini,
-               .page_flags = &cayman_vm_page_flags,
                .set_page = &cayman_vm_set_page,
        },
        .ring = {
@@ -1583,7 +1581,6 @@ static struct radeon_asic si_asic = {
        .vm = {
                .init = &si_vm_init,
                .fini = &si_vm_fini,
-               .page_flags = &cayman_vm_page_flags,
                .set_page = &cayman_vm_set_page,
        },
        .ring = {
index 25e8d000dac970136188416dd5c87c5b0a5bd3d4..2b3dd3173022f0f98afb6106a814c6fe922a8925 100644 (file)
@@ -442,11 +442,10 @@ int cayman_vm_init(struct radeon_device *rdev);
 void cayman_vm_fini(struct radeon_device *rdev);
 void cayman_vm_unbind(struct radeon_device *rdev, struct radeon_vm *vm);
 void cayman_vm_flush(struct radeon_device *rdev, struct radeon_ib *ib);
-uint32_t cayman_vm_page_flags(struct radeon_device *rdev,
-                             struct radeon_vm *vm,
-                             uint32_t flags);
+uint32_t cayman_vm_page_flags(struct radeon_device *rdev, uint32_t flags);
 void cayman_vm_set_page(struct radeon_device *rdev, struct radeon_vm *vm,
-                       unsigned pfn, uint64_t addr, uint32_t flags);
+                       unsigned pfn, struct ttm_mem_reg *mem, 
+                       unsigned npages, uint32_t flags);
 int evergreen_ib_parse(struct radeon_device *rdev, struct radeon_ib *ib);
 
 /* DCE6 - SI */
index da1b2dbe455021ea127a39587300dbe6cc8185c1..0f9a40f84d7a173c4e892f63d890da9b8f44f079 100644 (file)
@@ -450,7 +450,7 @@ int radeon_vm_manager_init(struct radeon_device *rdev)
                r = radeon_asic_vm_init(rdev);
                if (r)
                        return r;
-       
+
                rdev->vm_manager.enabled = true;
 
                r = radeon_sa_bo_manager_start(rdev, &rdev->vm_manager.sa_manager);
@@ -773,9 +773,9 @@ int radeon_vm_bo_add(struct radeon_device *rdev,
  * to (cayman+).
  * Returns the physical address of the page.
  */
-static u64 radeon_vm_get_addr(struct radeon_device *rdev,
-                             struct ttm_mem_reg *mem,
-                             unsigned pfn)
+u64 radeon_vm_get_addr(struct radeon_device *rdev,
+                      struct ttm_mem_reg *mem,
+                      unsigned pfn)
 {
        u64 addr = 0;
 
@@ -819,9 +819,8 @@ int radeon_vm_bo_update_pte(struct radeon_device *rdev,
                            struct ttm_mem_reg *mem)
 {
        struct radeon_bo_va *bo_va;
-       unsigned ngpu_pages, i;
-       uint64_t addr = 0, pfn;
-       uint32_t flags;
+       unsigned ngpu_pages;
+       uint64_t pfn;
 
        /* nothing to do if vm isn't bound */
        if (vm->sa_bo == NULL)
@@ -848,14 +847,11 @@ int radeon_vm_bo_update_pte(struct radeon_device *rdev,
                        bo_va->flags |= RADEON_VM_PAGE_SYSTEM;
                }
        }
-       pfn = bo_va->soffset / RADEON_GPU_PAGE_SIZE;
-       flags = radeon_asic_vm_page_flags(rdev, bo_va->vm, bo_va->flags);
-       for (i = 0, addr = 0; i < ngpu_pages; i++) {
-               if (mem && bo_va->valid) {
-                       addr = radeon_vm_get_addr(rdev, mem, i);
-               }
-               radeon_asic_vm_set_page(rdev, bo_va->vm, i + pfn, addr, flags);
+       if (!bo_va->valid) {
+               mem = NULL;
        }
+       pfn = bo_va->soffset / RADEON_GPU_PAGE_SIZE;
+       radeon_asic_vm_set_page(rdev, bo_va->vm, pfn, mem, ngpu_pages, bo_va->flags);
        radeon_fence_unref(&vm->last_flush);
        return 0;
 }