diff options
author | Christian König <deathsimple@vodafone.de> | 2012-05-09 09:34:53 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-05-09 12:22:35 -0400 |
commit | 2e0d99103e7b62ad27dcbc8c92337687dd8294e6 (patch) | |
tree | 694b08c575a0dbc36c3ac6be116e876ccee64c4d | |
parent | e6661a96647447aee83db976e8aad3d3a5c30cbd (diff) |
drm/radeon: make sa bo a stand alone object
Allocating and freeing it seperately.
Signed-off-by: Christian König <deathsimple@vodafone.de>
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | drivers/gpu/drm/radeon/radeon.h | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_cs.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_gart.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_object.h | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_ring.c | 6 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_sa.c | 28 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_semaphore.c | 4 |
7 files changed, 32 insertions, 22 deletions
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index d1c21540e08d..9374ab1b4264 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h | |||
@@ -638,7 +638,7 @@ void radeon_irq_kms_pflip_irq_put(struct radeon_device *rdev, int crtc); | |||
638 | */ | 638 | */ |
639 | 639 | ||
640 | struct radeon_ib { | 640 | struct radeon_ib { |
641 | struct radeon_sa_bo sa_bo; | 641 | struct radeon_sa_bo *sa_bo; |
642 | unsigned idx; | 642 | unsigned idx; |
643 | uint32_t length_dw; | 643 | uint32_t length_dw; |
644 | uint64_t gpu_addr; | 644 | uint64_t gpu_addr; |
@@ -693,7 +693,7 @@ struct radeon_vm { | |||
693 | unsigned last_pfn; | 693 | unsigned last_pfn; |
694 | u64 pt_gpu_addr; | 694 | u64 pt_gpu_addr; |
695 | u64 *pt; | 695 | u64 *pt; |
696 | struct radeon_sa_bo sa_bo; | 696 | struct radeon_sa_bo *sa_bo; |
697 | struct mutex mutex; | 697 | struct mutex mutex; |
698 | /* last fence for cs using this vm */ | 698 | /* last fence for cs using this vm */ |
699 | struct radeon_fence *fence; | 699 | struct radeon_fence *fence; |
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c index b77803721cf3..5c065bf2d162 100644 --- a/drivers/gpu/drm/radeon/radeon_cs.c +++ b/drivers/gpu/drm/radeon/radeon_cs.c | |||
@@ -477,7 +477,7 @@ static int radeon_cs_ib_vm_chunk(struct radeon_device *rdev, | |||
477 | /* ib pool is bind at 0 in virtual address space to gpu_addr is the | 477 | /* ib pool is bind at 0 in virtual address space to gpu_addr is the |
478 | * offset inside the pool bo | 478 | * offset inside the pool bo |
479 | */ | 479 | */ |
480 | parser->const_ib->gpu_addr = parser->const_ib->sa_bo.soffset; | 480 | parser->const_ib->gpu_addr = parser->const_ib->sa_bo->soffset; |
481 | r = radeon_ib_schedule(rdev, parser->const_ib); | 481 | r = radeon_ib_schedule(rdev, parser->const_ib); |
482 | if (r) | 482 | if (r) |
483 | goto out; | 483 | goto out; |
@@ -487,7 +487,7 @@ static int radeon_cs_ib_vm_chunk(struct radeon_device *rdev, | |||
487 | /* ib pool is bind at 0 in virtual address space to gpu_addr is the | 487 | /* ib pool is bind at 0 in virtual address space to gpu_addr is the |
488 | * offset inside the pool bo | 488 | * offset inside the pool bo |
489 | */ | 489 | */ |
490 | parser->ib->gpu_addr = parser->ib->sa_bo.soffset; | 490 | parser->ib->gpu_addr = parser->ib->sa_bo->soffset; |
491 | parser->ib->is_const_ib = false; | 491 | parser->ib->is_const_ib = false; |
492 | r = radeon_ib_schedule(rdev, parser->ib); | 492 | r = radeon_ib_schedule(rdev, parser->ib); |
493 | out: | 493 | out: |
diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c index 4a5d9d4ef7ee..c5789efb78a5 100644 --- a/drivers/gpu/drm/radeon/radeon_gart.c +++ b/drivers/gpu/drm/radeon/radeon_gart.c | |||
@@ -404,8 +404,8 @@ retry: | |||
404 | radeon_vm_unbind(rdev, vm_evict); | 404 | radeon_vm_unbind(rdev, vm_evict); |
405 | goto retry; | 405 | goto retry; |
406 | } | 406 | } |
407 | vm->pt = radeon_sa_bo_cpu_addr(&vm->sa_bo); | 407 | vm->pt = radeon_sa_bo_cpu_addr(vm->sa_bo); |
408 | vm->pt_gpu_addr = radeon_sa_bo_gpu_addr(&vm->sa_bo); | 408 | vm->pt_gpu_addr = radeon_sa_bo_gpu_addr(vm->sa_bo); |
409 | memset(vm->pt, 0, RADEON_GPU_PAGE_ALIGN(vm->last_pfn * 8)); | 409 | memset(vm->pt, 0, RADEON_GPU_PAGE_ALIGN(vm->last_pfn * 8)); |
410 | 410 | ||
411 | retry_id: | 411 | retry_id: |
diff --git a/drivers/gpu/drm/radeon/radeon_object.h b/drivers/gpu/drm/radeon/radeon_object.h index 99ab46afff00..4fc7f07e06d1 100644 --- a/drivers/gpu/drm/radeon/radeon_object.h +++ b/drivers/gpu/drm/radeon/radeon_object.h | |||
@@ -168,10 +168,10 @@ extern int radeon_sa_bo_manager_suspend(struct radeon_device *rdev, | |||
168 | struct radeon_sa_manager *sa_manager); | 168 | struct radeon_sa_manager *sa_manager); |
169 | extern int radeon_sa_bo_new(struct radeon_device *rdev, | 169 | extern int radeon_sa_bo_new(struct radeon_device *rdev, |
170 | struct radeon_sa_manager *sa_manager, | 170 | struct radeon_sa_manager *sa_manager, |
171 | struct radeon_sa_bo *sa_bo, | 171 | struct radeon_sa_bo **sa_bo, |
172 | unsigned size, unsigned align); | 172 | unsigned size, unsigned align); |
173 | extern void radeon_sa_bo_free(struct radeon_device *rdev, | 173 | extern void radeon_sa_bo_free(struct radeon_device *rdev, |
174 | struct radeon_sa_bo *sa_bo); | 174 | struct radeon_sa_bo **sa_bo); |
175 | #if defined(CONFIG_DEBUG_FS) | 175 | #if defined(CONFIG_DEBUG_FS) |
176 | extern void radeon_sa_bo_dump_debug_info(struct radeon_sa_manager *sa_manager, | 176 | extern void radeon_sa_bo_dump_debug_info(struct radeon_sa_manager *sa_manager, |
177 | struct seq_file *m); | 177 | struct seq_file *m); |
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c index f49c9c069e6b..45adb37152e1 100644 --- a/drivers/gpu/drm/radeon/radeon_ring.c +++ b/drivers/gpu/drm/radeon/radeon_ring.c | |||
@@ -127,8 +127,8 @@ retry: | |||
127 | size, 256); | 127 | size, 256); |
128 | if (!r) { | 128 | if (!r) { |
129 | *ib = &rdev->ib_pool.ibs[idx]; | 129 | *ib = &rdev->ib_pool.ibs[idx]; |
130 | (*ib)->ptr = radeon_sa_bo_cpu_addr(&(*ib)->sa_bo); | 130 | (*ib)->ptr = radeon_sa_bo_cpu_addr((*ib)->sa_bo); |
131 | (*ib)->gpu_addr = radeon_sa_bo_gpu_addr(&(*ib)->sa_bo); | 131 | (*ib)->gpu_addr = radeon_sa_bo_gpu_addr((*ib)->sa_bo); |
132 | (*ib)->fence = fence; | 132 | (*ib)->fence = fence; |
133 | (*ib)->vm_id = 0; | 133 | (*ib)->vm_id = 0; |
134 | (*ib)->is_const_ib = false; | 134 | (*ib)->is_const_ib = false; |
@@ -227,7 +227,7 @@ int radeon_ib_pool_init(struct radeon_device *rdev) | |||
227 | rdev->ib_pool.ibs[i].fence = NULL; | 227 | rdev->ib_pool.ibs[i].fence = NULL; |
228 | rdev->ib_pool.ibs[i].idx = i; | 228 | rdev->ib_pool.ibs[i].idx = i; |
229 | rdev->ib_pool.ibs[i].length_dw = 0; | 229 | rdev->ib_pool.ibs[i].length_dw = 0; |
230 | INIT_LIST_HEAD(&rdev->ib_pool.ibs[i].sa_bo.list); | 230 | rdev->ib_pool.ibs[i].sa_bo = NULL; |
231 | } | 231 | } |
232 | rdev->ib_pool.head_id = 0; | 232 | rdev->ib_pool.head_id = 0; |
233 | rdev->ib_pool.ready = true; | 233 | rdev->ib_pool.ready = true; |
diff --git a/drivers/gpu/drm/radeon/radeon_sa.c b/drivers/gpu/drm/radeon/radeon_sa.c index 3bea7ba1e488..625f2d4f638a 100644 --- a/drivers/gpu/drm/radeon/radeon_sa.c +++ b/drivers/gpu/drm/radeon/radeon_sa.c | |||
@@ -131,7 +131,7 @@ int radeon_sa_bo_manager_suspend(struct radeon_device *rdev, | |||
131 | */ | 131 | */ |
132 | int radeon_sa_bo_new(struct radeon_device *rdev, | 132 | int radeon_sa_bo_new(struct radeon_device *rdev, |
133 | struct radeon_sa_manager *sa_manager, | 133 | struct radeon_sa_manager *sa_manager, |
134 | struct radeon_sa_bo *sa_bo, | 134 | struct radeon_sa_bo **sa_bo, |
135 | unsigned size, unsigned align) | 135 | unsigned size, unsigned align) |
136 | { | 136 | { |
137 | struct radeon_sa_bo *tmp; | 137 | struct radeon_sa_bo *tmp; |
@@ -140,6 +140,9 @@ int radeon_sa_bo_new(struct radeon_device *rdev, | |||
140 | 140 | ||
141 | BUG_ON(align > RADEON_GPU_PAGE_SIZE); | 141 | BUG_ON(align > RADEON_GPU_PAGE_SIZE); |
142 | BUG_ON(size > sa_manager->size); | 142 | BUG_ON(size > sa_manager->size); |
143 | |||
144 | *sa_bo = kmalloc(sizeof(struct radeon_sa_bo), GFP_KERNEL); | ||
145 | |||
143 | spin_lock(&sa_manager->lock); | 146 | spin_lock(&sa_manager->lock); |
144 | 147 | ||
145 | /* no one ? */ | 148 | /* no one ? */ |
@@ -175,23 +178,30 @@ int radeon_sa_bo_new(struct radeon_device *rdev, | |||
175 | if ((sa_manager->size - offset) < size) { | 178 | if ((sa_manager->size - offset) < size) { |
176 | /* failed to find somethings big enough */ | 179 | /* failed to find somethings big enough */ |
177 | spin_unlock(&sa_manager->lock); | 180 | spin_unlock(&sa_manager->lock); |
181 | kfree(*sa_bo); | ||
182 | *sa_bo = NULL; | ||
178 | return -ENOMEM; | 183 | return -ENOMEM; |
179 | } | 184 | } |
180 | 185 | ||
181 | out: | 186 | out: |
182 | sa_bo->manager = sa_manager; | 187 | (*sa_bo)->manager = sa_manager; |
183 | sa_bo->soffset = offset; | 188 | (*sa_bo)->soffset = offset; |
184 | sa_bo->eoffset = offset + size; | 189 | (*sa_bo)->eoffset = offset + size; |
185 | list_add(&sa_bo->list, head); | 190 | list_add(&(*sa_bo)->list, head); |
186 | spin_unlock(&sa_manager->lock); | 191 | spin_unlock(&sa_manager->lock); |
187 | return 0; | 192 | return 0; |
188 | } | 193 | } |
189 | 194 | ||
190 | void radeon_sa_bo_free(struct radeon_device *rdev, struct radeon_sa_bo *sa_bo) | 195 | void radeon_sa_bo_free(struct radeon_device *rdev, struct radeon_sa_bo **sa_bo) |
191 | { | 196 | { |
192 | spin_lock(&sa_bo->manager->lock); | 197 | if (!sa_bo || !*sa_bo) |
193 | list_del_init(&sa_bo->list); | 198 | return; |
194 | spin_unlock(&sa_bo->manager->lock); | 199 | |
200 | spin_lock(&(*sa_bo)->manager->lock); | ||
201 | list_del_init(&(*sa_bo)->list); | ||
202 | spin_unlock(&(*sa_bo)->manager->lock); | ||
203 | kfree(*sa_bo); | ||
204 | *sa_bo = NULL; | ||
195 | } | 205 | } |
196 | 206 | ||
197 | #if defined(CONFIG_DEBUG_FS) | 207 | #if defined(CONFIG_DEBUG_FS) |
diff --git a/drivers/gpu/drm/radeon/radeon_semaphore.c b/drivers/gpu/drm/radeon/radeon_semaphore.c index f312ba59bbe9..d518d326235d 100644 --- a/drivers/gpu/drm/radeon/radeon_semaphore.c +++ b/drivers/gpu/drm/radeon/radeon_semaphore.c | |||
@@ -53,8 +53,8 @@ static int radeon_semaphore_add_bo(struct radeon_device *rdev) | |||
53 | kfree(bo); | 53 | kfree(bo); |
54 | return r; | 54 | return r; |
55 | } | 55 | } |
56 | gpu_addr = radeon_sa_bo_gpu_addr(&bo->ib->sa_bo); | 56 | gpu_addr = radeon_sa_bo_gpu_addr(bo->ib->sa_bo); |
57 | cpu_ptr = radeon_sa_bo_cpu_addr(&bo->ib->sa_bo); | 57 | cpu_ptr = radeon_sa_bo_cpu_addr(bo->ib->sa_bo); |
58 | for (i = 0; i < (RADEON_SEMAPHORE_BO_SIZE/8); i++) { | 58 | for (i = 0; i < (RADEON_SEMAPHORE_BO_SIZE/8); i++) { |
59 | bo->semaphores[i].gpu_addr = gpu_addr; | 59 | bo->semaphores[i].gpu_addr = gpu_addr; |
60 | bo->semaphores[i].cpu_ptr = cpu_ptr; | 60 | bo->semaphores[i].cpu_ptr = cpu_ptr; |