aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/radeon')
-rw-r--r--drivers/gpu/drm/radeon/evergreen_blit_kms.c2
-rw-r--r--drivers/gpu/drm/radeon/r600.c2
-rw-r--r--drivers/gpu/drm/radeon/r600_blit_kms.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon.h1
-rw-r--r--drivers/gpu/drm/radeon/radeon_benchmark.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_gart.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_gem.c22
-rw-r--r--drivers/gpu/drm/radeon/radeon_object.c20
-rw-r--r--drivers/gpu/drm/radeon/radeon_object.h7
-rw-r--r--drivers/gpu/drm/radeon/radeon_ring.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_test.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_ttm.c2
-rw-r--r--drivers/gpu/drm/radeon/rv770.c2
14 files changed, 39 insertions, 37 deletions
diff --git a/drivers/gpu/drm/radeon/evergreen_blit_kms.c b/drivers/gpu/drm/radeon/evergreen_blit_kms.c
index a1ba4b3053d0..2ed930e02f3a 100644
--- a/drivers/gpu/drm/radeon/evergreen_blit_kms.c
+++ b/drivers/gpu/drm/radeon/evergreen_blit_kms.c
@@ -572,7 +572,7 @@ int evergreen_blit_init(struct radeon_device *rdev)
572 obj_size += evergreen_ps_size * 4; 572 obj_size += evergreen_ps_size * 4;
573 obj_size = ALIGN(obj_size, 256); 573 obj_size = ALIGN(obj_size, 256);
574 574
575 r = radeon_bo_create(rdev, NULL, obj_size, PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM, 575 r = radeon_bo_create(rdev, obj_size, PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM,
576 &rdev->r600_blit.shader_obj); 576 &rdev->r600_blit.shader_obj);
577 if (r) { 577 if (r) {
578 DRM_ERROR("evergreen failed to allocate shader\n"); 578 DRM_ERROR("evergreen failed to allocate shader\n");
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 650672a0f5ad..be780a6b9b1d 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -2728,7 +2728,7 @@ static int r600_ih_ring_alloc(struct radeon_device *rdev)
2728 2728
2729 /* Allocate ring buffer */ 2729 /* Allocate ring buffer */
2730 if (rdev->ih.ring_obj == NULL) { 2730 if (rdev->ih.ring_obj == NULL) {
2731 r = radeon_bo_create(rdev, NULL, rdev->ih.ring_size, 2731 r = radeon_bo_create(rdev, rdev->ih.ring_size,
2732 PAGE_SIZE, true, 2732 PAGE_SIZE, true,
2733 RADEON_GEM_DOMAIN_GTT, 2733 RADEON_GEM_DOMAIN_GTT,
2734 &rdev->ih.ring_obj); 2734 &rdev->ih.ring_obj);
diff --git a/drivers/gpu/drm/radeon/r600_blit_kms.c b/drivers/gpu/drm/radeon/r600_blit_kms.c
index 86e5aa07f0db..16e211a614d7 100644
--- a/drivers/gpu/drm/radeon/r600_blit_kms.c
+++ b/drivers/gpu/drm/radeon/r600_blit_kms.c
@@ -501,7 +501,7 @@ int r600_blit_init(struct radeon_device *rdev)
501 obj_size += r6xx_ps_size * 4; 501 obj_size += r6xx_ps_size * 4;
502 obj_size = ALIGN(obj_size, 256); 502 obj_size = ALIGN(obj_size, 256);
503 503
504 r = radeon_bo_create(rdev, NULL, obj_size, PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM, 504 r = radeon_bo_create(rdev, obj_size, PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM,
505 &rdev->r600_blit.shader_obj); 505 &rdev->r600_blit.shader_obj);
506 if (r) { 506 if (r) {
507 DRM_ERROR("r600 failed to allocate shader\n"); 507 DRM_ERROR("r600 failed to allocate shader\n");
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index a4605362c528..f4d194649012 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -259,6 +259,7 @@ struct radeon_bo {
259 /* Constant after initialization */ 259 /* Constant after initialization */
260 struct radeon_device *rdev; 260 struct radeon_device *rdev;
261 struct drm_gem_object *gobj; 261 struct drm_gem_object *gobj;
262 struct drm_gem_object gem_base;
262}; 263};
263 264
264struct radeon_bo_list { 265struct radeon_bo_list {
diff --git a/drivers/gpu/drm/radeon/radeon_benchmark.c b/drivers/gpu/drm/radeon/radeon_benchmark.c
index c558685cc637..10191d9372d8 100644
--- a/drivers/gpu/drm/radeon/radeon_benchmark.c
+++ b/drivers/gpu/drm/radeon/radeon_benchmark.c
@@ -41,7 +41,7 @@ void radeon_benchmark_move(struct radeon_device *rdev, unsigned bsize,
41 41
42 size = bsize; 42 size = bsize;
43 n = 1024; 43 n = 1024;
44 r = radeon_bo_create(rdev, NULL, size, PAGE_SIZE, true, sdomain, &sobj); 44 r = radeon_bo_create(rdev, size, PAGE_SIZE, true, sdomain, &sobj);
45 if (r) { 45 if (r) {
46 goto out_cleanup; 46 goto out_cleanup;
47 } 47 }
@@ -53,7 +53,7 @@ void radeon_benchmark_move(struct radeon_device *rdev, unsigned bsize,
53 if (r) { 53 if (r) {
54 goto out_cleanup; 54 goto out_cleanup;
55 } 55 }
56 r = radeon_bo_create(rdev, NULL, size, PAGE_SIZE, true, ddomain, &dobj); 56 r = radeon_bo_create(rdev, size, PAGE_SIZE, true, ddomain, &dobj);
57 if (r) { 57 if (r) {
58 goto out_cleanup; 58 goto out_cleanup;
59 } 59 }
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 0d478932b1a9..13945bd10461 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -184,7 +184,7 @@ int radeon_wb_init(struct radeon_device *rdev)
184 int r; 184 int r;
185 185
186 if (rdev->wb.wb_obj == NULL) { 186 if (rdev->wb.wb_obj == NULL) {
187 r = radeon_bo_create(rdev, NULL, RADEON_GPU_PAGE_SIZE, PAGE_SIZE, true, 187 r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE, PAGE_SIZE, true,
188 RADEON_GEM_DOMAIN_GTT, &rdev->wb.wb_obj); 188 RADEON_GEM_DOMAIN_GTT, &rdev->wb.wb_obj);
189 if (r) { 189 if (r) {
190 dev_warn(rdev->dev, "(%d) create WB bo failed\n", r); 190 dev_warn(rdev->dev, "(%d) create WB bo failed\n", r);
diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c
index 65016117d95f..9ac1bf0c41a8 100644
--- a/drivers/gpu/drm/radeon/radeon_gart.c
+++ b/drivers/gpu/drm/radeon/radeon_gart.c
@@ -78,7 +78,7 @@ int radeon_gart_table_vram_alloc(struct radeon_device *rdev)
78 int r; 78 int r;
79 79
80 if (rdev->gart.table.vram.robj == NULL) { 80 if (rdev->gart.table.vram.robj == NULL) {
81 r = radeon_bo_create(rdev, NULL, rdev->gart.table_size, 81 r = radeon_bo_create(rdev, rdev->gart.table_size,
82 PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM, 82 PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM,
83 &rdev->gart.table.vram.robj); 83 &rdev->gart.table.vram.robj);
84 if (r) { 84 if (r) {
diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
index ede5dccdf79f..69d00bf85b13 100644
--- a/drivers/gpu/drm/radeon/radeon_gem.c
+++ b/drivers/gpu/drm/radeon/radeon_gem.c
@@ -32,7 +32,8 @@
32 32
33int radeon_gem_object_init(struct drm_gem_object *obj) 33int radeon_gem_object_init(struct drm_gem_object *obj)
34{ 34{
35 /* we do nothings here */ 35 BUG();
36
36 return 0; 37 return 0;
37} 38}
38 39
@@ -44,9 +45,6 @@ void radeon_gem_object_free(struct drm_gem_object *gobj)
44 if (robj) { 45 if (robj) {
45 radeon_bo_unref(&robj); 46 radeon_bo_unref(&robj);
46 } 47 }
47
48 drm_gem_object_release(gobj);
49 kfree(gobj);
50} 48}
51 49
52int radeon_gem_object_create(struct radeon_device *rdev, int size, 50int radeon_gem_object_create(struct radeon_device *rdev, int size,
@@ -54,29 +52,27 @@ int radeon_gem_object_create(struct radeon_device *rdev, int size,
54 bool discardable, bool kernel, 52 bool discardable, bool kernel,
55 struct drm_gem_object **obj) 53 struct drm_gem_object **obj)
56{ 54{
57 struct drm_gem_object *gobj;
58 struct radeon_bo *robj; 55 struct radeon_bo *robj;
59 int r; 56 int r;
60 57
61 *obj = NULL; 58 *obj = NULL;
62 gobj = drm_gem_object_alloc(rdev->ddev, size);
63 if (!gobj) {
64 return -ENOMEM;
65 }
66 /* At least align on page size */ 59 /* At least align on page size */
67 if (alignment < PAGE_SIZE) { 60 if (alignment < PAGE_SIZE) {
68 alignment = PAGE_SIZE; 61 alignment = PAGE_SIZE;
69 } 62 }
70 r = radeon_bo_create(rdev, gobj, size, alignment, kernel, initial_domain, &robj); 63 r = radeon_bo_create(rdev, size, alignment, kernel, initial_domain, &robj);
71 if (r) { 64 if (r) {
72 if (r != -ERESTARTSYS) 65 if (r != -ERESTARTSYS)
73 DRM_ERROR("Failed to allocate GEM object (%d, %d, %u, %d)\n", 66 DRM_ERROR("Failed to allocate GEM object (%d, %d, %u, %d)\n",
74 size, initial_domain, alignment, r); 67 size, initial_domain, alignment, r);
75 drm_gem_object_unreference_unlocked(gobj);
76 return r; 68 return r;
77 } 69 }
78 gobj->driver_private = robj; 70 *obj = &robj->gem_base;
79 *obj = gobj; 71
72 mutex_lock(&rdev->gem.mutex);
73 list_add_tail(&robj->list, &rdev->gem.objects);
74 mutex_unlock(&rdev->gem.mutex);
75
80 return 0; 76 return 0;
81} 77}
82 78
diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
index 7d6b8e88f746..9324c881d640 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -55,6 +55,7 @@ static void radeon_ttm_bo_destroy(struct ttm_buffer_object *tbo)
55 list_del_init(&bo->list); 55 list_del_init(&bo->list);
56 mutex_unlock(&bo->rdev->gem.mutex); 56 mutex_unlock(&bo->rdev->gem.mutex);
57 radeon_bo_clear_surface_reg(bo); 57 radeon_bo_clear_surface_reg(bo);
58 drm_gem_object_release(&bo->gem_base);
58 kfree(bo); 59 kfree(bo);
59} 60}
60 61
@@ -86,7 +87,7 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain)
86 rbo->placement.num_busy_placement = c; 87 rbo->placement.num_busy_placement = c;
87} 88}
88 89
89int radeon_bo_create(struct radeon_device *rdev, struct drm_gem_object *gobj, 90int radeon_bo_create(struct radeon_device *rdev,
90 unsigned long size, int byte_align, bool kernel, u32 domain, 91 unsigned long size, int byte_align, bool kernel, u32 domain,
91 struct radeon_bo **bo_ptr) 92 struct radeon_bo **bo_ptr)
92{ 93{
@@ -96,6 +97,8 @@ int radeon_bo_create(struct radeon_device *rdev, struct drm_gem_object *gobj,
96 unsigned long max_size = 0; 97 unsigned long max_size = 0;
97 int r; 98 int r;
98 99
100 size = ALIGN(size, PAGE_SIZE);
101
99 if (unlikely(rdev->mman.bdev.dev_mapping == NULL)) { 102 if (unlikely(rdev->mman.bdev.dev_mapping == NULL)) {
100 rdev->mman.bdev.dev_mapping = rdev->ddev->dev_mapping; 103 rdev->mman.bdev.dev_mapping = rdev->ddev->dev_mapping;
101 } 104 }
@@ -118,8 +121,14 @@ retry:
118 bo = kzalloc(sizeof(struct radeon_bo), GFP_KERNEL); 121 bo = kzalloc(sizeof(struct radeon_bo), GFP_KERNEL);
119 if (bo == NULL) 122 if (bo == NULL)
120 return -ENOMEM; 123 return -ENOMEM;
124 r = drm_gem_object_init(rdev->ddev, &bo->gem_base, size);
125 if (unlikely(r)) {
126 kfree(bo);
127 return r;
128 }
121 bo->rdev = rdev; 129 bo->rdev = rdev;
122 bo->gobj = gobj; 130 bo->gobj = &bo->gem_base;
131 bo->gem_base.driver_private = bo;
123 bo->surface_reg = -1; 132 bo->surface_reg = -1;
124 INIT_LIST_HEAD(&bo->list); 133 INIT_LIST_HEAD(&bo->list);
125 radeon_ttm_placement_from_domain(bo, domain); 134 radeon_ttm_placement_from_domain(bo, domain);
@@ -142,12 +151,9 @@ retry:
142 return r; 151 return r;
143 } 152 }
144 *bo_ptr = bo; 153 *bo_ptr = bo;
145 if (gobj) { 154
146 mutex_lock(&bo->rdev->gem.mutex);
147 list_add_tail(&bo->list, &rdev->gem.objects);
148 mutex_unlock(&bo->rdev->gem.mutex);
149 }
150 trace_radeon_bo_create(bo); 155 trace_radeon_bo_create(bo);
156
151 return 0; 157 return 0;
152} 158}
153 159
diff --git a/drivers/gpu/drm/radeon/radeon_object.h b/drivers/gpu/drm/radeon/radeon_object.h
index 22d4c237dea5..7f8e778dba46 100644
--- a/drivers/gpu/drm/radeon/radeon_object.h
+++ b/drivers/gpu/drm/radeon/radeon_object.h
@@ -137,10 +137,9 @@ static inline int radeon_bo_wait(struct radeon_bo *bo, u32 *mem_type,
137} 137}
138 138
139extern int radeon_bo_create(struct radeon_device *rdev, 139extern int radeon_bo_create(struct radeon_device *rdev,
140 struct drm_gem_object *gobj, unsigned long size, 140 unsigned long size, int byte_align,
141 int byte_align, 141 bool kernel, u32 domain,
142 bool kernel, u32 domain, 142 struct radeon_bo **bo_ptr);
143 struct radeon_bo **bo_ptr);
144extern int radeon_bo_kmap(struct radeon_bo *bo, void **ptr); 143extern int radeon_bo_kmap(struct radeon_bo *bo, void **ptr);
145extern void radeon_bo_kunmap(struct radeon_bo *bo); 144extern void radeon_bo_kunmap(struct radeon_bo *bo);
146extern void radeon_bo_unref(struct radeon_bo **bo); 145extern void radeon_bo_unref(struct radeon_bo **bo);
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
index 06e79822a2bf..992d99d13fc5 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -175,7 +175,7 @@ int radeon_ib_pool_init(struct radeon_device *rdev)
175 return 0; 175 return 0;
176 INIT_LIST_HEAD(&rdev->ib_pool.bogus_ib); 176 INIT_LIST_HEAD(&rdev->ib_pool.bogus_ib);
177 /* Allocate 1M object buffer */ 177 /* Allocate 1M object buffer */
178 r = radeon_bo_create(rdev, NULL, RADEON_IB_POOL_SIZE*64*1024, 178 r = radeon_bo_create(rdev, RADEON_IB_POOL_SIZE*64*1024,
179 PAGE_SIZE, true, RADEON_GEM_DOMAIN_GTT, 179 PAGE_SIZE, true, RADEON_GEM_DOMAIN_GTT,
180 &rdev->ib_pool.robj); 180 &rdev->ib_pool.robj);
181 if (r) { 181 if (r) {
@@ -332,7 +332,7 @@ int radeon_ring_init(struct radeon_device *rdev, unsigned ring_size)
332 rdev->cp.ring_size = ring_size; 332 rdev->cp.ring_size = ring_size;
333 /* Allocate ring buffer */ 333 /* Allocate ring buffer */
334 if (rdev->cp.ring_obj == NULL) { 334 if (rdev->cp.ring_obj == NULL) {
335 r = radeon_bo_create(rdev, NULL, rdev->cp.ring_size, PAGE_SIZE, true, 335 r = radeon_bo_create(rdev, rdev->cp.ring_size, PAGE_SIZE, true,
336 RADEON_GEM_DOMAIN_GTT, 336 RADEON_GEM_DOMAIN_GTT,
337 &rdev->cp.ring_obj); 337 &rdev->cp.ring_obj);
338 if (r) { 338 if (r) {
diff --git a/drivers/gpu/drm/radeon/radeon_test.c b/drivers/gpu/drm/radeon/radeon_test.c
index 5b44f652145c..dee4a0c1b4b2 100644
--- a/drivers/gpu/drm/radeon/radeon_test.c
+++ b/drivers/gpu/drm/radeon/radeon_test.c
@@ -52,7 +52,7 @@ void radeon_test_moves(struct radeon_device *rdev)
52 goto out_cleanup; 52 goto out_cleanup;
53 } 53 }
54 54
55 r = radeon_bo_create(rdev, NULL, size, PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM, 55 r = radeon_bo_create(rdev, size, PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM,
56 &vram_obj); 56 &vram_obj);
57 if (r) { 57 if (r) {
58 DRM_ERROR("Failed to create VRAM object\n"); 58 DRM_ERROR("Failed to create VRAM object\n");
@@ -71,7 +71,7 @@ void radeon_test_moves(struct radeon_device *rdev)
71 void **gtt_start, **gtt_end; 71 void **gtt_start, **gtt_end;
72 void **vram_start, **vram_end; 72 void **vram_start, **vram_end;
73 73
74 r = radeon_bo_create(rdev, NULL, size, PAGE_SIZE, true, 74 r = radeon_bo_create(rdev, size, PAGE_SIZE, true,
75 RADEON_GEM_DOMAIN_GTT, gtt_obj + i); 75 RADEON_GEM_DOMAIN_GTT, gtt_obj + i);
76 if (r) { 76 if (r) {
77 DRM_ERROR("Failed to create GTT object %d\n", i); 77 DRM_ERROR("Failed to create GTT object %d\n", i);
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 1272e4b6a1d4..e17e5958e564 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -529,7 +529,7 @@ int radeon_ttm_init(struct radeon_device *rdev)
529 DRM_ERROR("Failed initializing VRAM heap.\n"); 529 DRM_ERROR("Failed initializing VRAM heap.\n");
530 return r; 530 return r;
531 } 531 }
532 r = radeon_bo_create(rdev, NULL, 256 * 1024, PAGE_SIZE, true, 532 r = radeon_bo_create(rdev, 256 * 1024, PAGE_SIZE, true,
533 RADEON_GEM_DOMAIN_VRAM, 533 RADEON_GEM_DOMAIN_VRAM,
534 &rdev->stollen_vga_memory); 534 &rdev->stollen_vga_memory);
535 if (r) { 535 if (r) {
diff --git a/drivers/gpu/drm/radeon/rv770.c b/drivers/gpu/drm/radeon/rv770.c
index 2211a323db41..3a95999d2fef 100644
--- a/drivers/gpu/drm/radeon/rv770.c
+++ b/drivers/gpu/drm/radeon/rv770.c
@@ -999,7 +999,7 @@ static int rv770_vram_scratch_init(struct radeon_device *rdev)
999 u64 gpu_addr; 999 u64 gpu_addr;
1000 1000
1001 if (rdev->vram_scratch.robj == NULL) { 1001 if (rdev->vram_scratch.robj == NULL) {
1002 r = radeon_bo_create(rdev, NULL, RADEON_GPU_PAGE_SIZE, 1002 r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE,
1003 PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM, 1003 PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM,
1004 &rdev->vram_scratch.robj); 1004 &rdev->vram_scratch.robj);
1005 if (r) { 1005 if (r) {