diff options
author | Christian König <christian.koenig@amd.com> | 2015-10-22 05:29:33 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2015-10-30 01:54:07 -0400 |
commit | 8120b61fdf3d3aa31d6b7e4a4f633bec1d2edd38 (patch) | |
tree | cb7589068dbd04cc0031dcbd15a5f83858e81342 /drivers/gpu/drm/amd/amdgpu | |
parent | ee327caf1a2cdba9313167c36db2d7ff02d534bc (diff) |
drm/amdgpu: move ring_from_fence to common code
Going to need that elsewhere as well.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 24 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c | 23 |
3 files changed, 27 insertions, 21 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index dd7d2ce2355c..6d9c929e6d51 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -1231,6 +1231,7 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, | |||
1231 | struct amdgpu_irq_src *irq_src, unsigned irq_type, | 1231 | struct amdgpu_irq_src *irq_src, unsigned irq_type, |
1232 | enum amdgpu_ring_type ring_type); | 1232 | enum amdgpu_ring_type ring_type); |
1233 | void amdgpu_ring_fini(struct amdgpu_ring *ring); | 1233 | void amdgpu_ring_fini(struct amdgpu_ring *ring); |
1234 | struct amdgpu_ring *amdgpu_ring_from_fence(struct fence *f); | ||
1234 | 1235 | ||
1235 | /* | 1236 | /* |
1236 | * CS. | 1237 | * CS. |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c index b2df348aa223..78e9b0f14661 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | |||
@@ -436,6 +436,30 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring) | |||
436 | } | 436 | } |
437 | } | 437 | } |
438 | 438 | ||
439 | /** | ||
440 | * amdgpu_ring_from_fence - get ring from fence | ||
441 | * | ||
442 | * @f: fence structure | ||
443 | * | ||
444 | * Extract the ring a fence belongs to. Handles both scheduler as | ||
445 | * well as hardware fences. | ||
446 | */ | ||
447 | struct amdgpu_ring *amdgpu_ring_from_fence(struct fence *f) | ||
448 | { | ||
449 | struct amdgpu_fence *a_fence; | ||
450 | struct amd_sched_fence *s_fence; | ||
451 | |||
452 | s_fence = to_amd_sched_fence(f); | ||
453 | if (s_fence) | ||
454 | return container_of(s_fence->sched, struct amdgpu_ring, sched); | ||
455 | |||
456 | a_fence = to_amdgpu_fence(f); | ||
457 | if (a_fence) | ||
458 | return a_fence->ring; | ||
459 | |||
460 | return NULL; | ||
461 | } | ||
462 | |||
439 | /* | 463 | /* |
440 | * Debugfs info | 464 | * Debugfs info |
441 | */ | 465 | */ |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c index 3f48759793de..0212b31dc194 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c | |||
@@ -139,25 +139,6 @@ int amdgpu_sa_bo_manager_suspend(struct amdgpu_device *adev, | |||
139 | return r; | 139 | return r; |
140 | } | 140 | } |
141 | 141 | ||
142 | static uint32_t amdgpu_sa_get_ring_from_fence(struct fence *f) | ||
143 | { | ||
144 | struct amdgpu_fence *a_fence; | ||
145 | struct amd_sched_fence *s_fence; | ||
146 | |||
147 | s_fence = to_amd_sched_fence(f); | ||
148 | if (s_fence) { | ||
149 | struct amdgpu_ring *ring; | ||
150 | |||
151 | ring = container_of(s_fence->sched, struct amdgpu_ring, sched); | ||
152 | return ring->idx; | ||
153 | } | ||
154 | |||
155 | a_fence = to_amdgpu_fence(f); | ||
156 | if (a_fence) | ||
157 | return a_fence->ring->idx; | ||
158 | return 0; | ||
159 | } | ||
160 | |||
161 | static void amdgpu_sa_bo_remove_locked(struct amdgpu_sa_bo *sa_bo) | 142 | static void amdgpu_sa_bo_remove_locked(struct amdgpu_sa_bo *sa_bo) |
162 | { | 143 | { |
163 | struct amdgpu_sa_manager *sa_manager = sa_bo->manager; | 144 | struct amdgpu_sa_manager *sa_manager = sa_bo->manager; |
@@ -318,7 +299,7 @@ static bool amdgpu_sa_bo_next_hole(struct amdgpu_sa_manager *sa_manager, | |||
318 | } | 299 | } |
319 | 300 | ||
320 | if (best_bo) { | 301 | if (best_bo) { |
321 | uint32_t idx = amdgpu_sa_get_ring_from_fence(best_bo->fence); | 302 | uint32_t idx = amdgpu_ring_from_fence(best_bo->fence)->idx; |
322 | ++tries[idx]; | 303 | ++tries[idx]; |
323 | sa_manager->hole = best_bo->olist.prev; | 304 | sa_manager->hole = best_bo->olist.prev; |
324 | 305 | ||
@@ -412,7 +393,7 @@ void amdgpu_sa_bo_free(struct amdgpu_device *adev, struct amdgpu_sa_bo **sa_bo, | |||
412 | if (fence && !fence_is_signaled(fence)) { | 393 | if (fence && !fence_is_signaled(fence)) { |
413 | uint32_t idx; | 394 | uint32_t idx; |
414 | (*sa_bo)->fence = fence_get(fence); | 395 | (*sa_bo)->fence = fence_get(fence); |
415 | idx = amdgpu_sa_get_ring_from_fence(fence); | 396 | idx = amdgpu_ring_from_fence(fence)->idx; |
416 | list_add_tail(&(*sa_bo)->flist, &sa_manager->flist[idx]); | 397 | list_add_tail(&(*sa_bo)->flist, &sa_manager->flist[idx]); |
417 | } else { | 398 | } else { |
418 | amdgpu_sa_bo_remove_locked(*sa_bo); | 399 | amdgpu_sa_bo_remove_locked(*sa_bo); |