aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2016-02-16 10:23:02 -0500
committerAlex Deucher <alexander.deucher@amd.com>2016-03-08 11:01:46 -0500
commitbcc634f4a8f10a851dd3d8429ea28998351ca843 (patch)
treebb445fa5dfab32b0547db6c3a6601549c03c64cb /drivers/gpu/drm
parent637dd3b5ca9e0d38b046f04e97a1d2f7523e7e25 (diff)
drm/amdgpu: cleanup the sync code
No need for two functions doing the same, remove one and add comments what those functions actually do. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
index c15be00de904..87690cc57206 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
@@ -50,6 +50,14 @@ void amdgpu_sync_create(struct amdgpu_sync *sync)
50 sync->last_vm_update = NULL; 50 sync->last_vm_update = NULL;
51} 51}
52 52
53/**
54 * amdgpu_sync_same_dev - test if fence belong to us
55 *
56 * @adev: amdgpu device to use for the test
57 * @f: fence to test
58 *
59 * Test if the fence was issued by us.
60 */
53static bool amdgpu_sync_same_dev(struct amdgpu_device *adev, struct fence *f) 61static bool amdgpu_sync_same_dev(struct amdgpu_device *adev, struct fence *f)
54{ 62{
55 struct amdgpu_fence *a_fence = to_amdgpu_fence(f); 63 struct amdgpu_fence *a_fence = to_amdgpu_fence(f);
@@ -68,17 +76,33 @@ static bool amdgpu_sync_same_dev(struct amdgpu_device *adev, struct fence *f)
68 return false; 76 return false;
69} 77}
70 78
71static bool amdgpu_sync_test_owner(struct fence *f, void *owner) 79/**
80 * amdgpu_sync_get_owner - extract the owner of a fence
81 *
82 * @fence: fence get the owner from
83 *
84 * Extract who originally created the fence.
85 */
86static void *amdgpu_sync_get_owner(struct fence *f)
72{ 87{
73 struct amdgpu_fence *a_fence = to_amdgpu_fence(f); 88 struct amdgpu_fence *a_fence = to_amdgpu_fence(f);
74 struct amd_sched_fence *s_fence = to_amd_sched_fence(f); 89 struct amd_sched_fence *s_fence = to_amd_sched_fence(f);
90
75 if (s_fence) 91 if (s_fence)
76 return s_fence->owner == owner; 92 return s_fence->owner;
77 if (a_fence) 93 else if (a_fence)
78 return a_fence->owner == owner; 94 return a_fence->owner;
79 return false; 95 return AMDGPU_FENCE_OWNER_UNDEFINED;
80} 96}
81 97
98/**
99 * amdgpu_sync_keep_later - Keep the later fence
100 *
101 * @keep: existing fence to test
102 * @fence: new fence
103 *
104 * Either keep the existing fence or the new one, depending which one is later.
105 */
82static void amdgpu_sync_keep_later(struct fence **keep, struct fence *fence) 106static void amdgpu_sync_keep_later(struct fence **keep, struct fence *fence)
83{ 107{
84 if (*keep && fence_is_later(*keep, fence)) 108 if (*keep && fence_is_later(*keep, fence))
@@ -104,7 +128,7 @@ int amdgpu_sync_fence(struct amdgpu_device *adev, struct amdgpu_sync *sync,
104 return 0; 128 return 0;
105 129
106 if (amdgpu_sync_same_dev(adev, f) && 130 if (amdgpu_sync_same_dev(adev, f) &&
107 amdgpu_sync_test_owner(f, AMDGPU_FENCE_OWNER_VM)) 131 amdgpu_sync_get_owner(f) == AMDGPU_FENCE_OWNER_VM)
108 amdgpu_sync_keep_later(&sync->last_vm_update, f); 132 amdgpu_sync_keep_later(&sync->last_vm_update, f);
109 133
110 hash_for_each_possible(sync->fences, e, node, f->context) { 134 hash_for_each_possible(sync->fences, e, node, f->context) {
@@ -124,18 +148,6 @@ int amdgpu_sync_fence(struct amdgpu_device *adev, struct amdgpu_sync *sync,
124 return 0; 148 return 0;
125} 149}
126 150
127static void *amdgpu_sync_get_owner(struct fence *f)
128{
129 struct amdgpu_fence *a_fence = to_amdgpu_fence(f);
130 struct amd_sched_fence *s_fence = to_amd_sched_fence(f);
131
132 if (s_fence)
133 return s_fence->owner;
134 else if (a_fence)
135 return a_fence->owner;
136 return AMDGPU_FENCE_OWNER_UNDEFINED;
137}
138
139/** 151/**
140 * amdgpu_sync_resv - sync to a reservation object 152 * amdgpu_sync_resv - sync to a reservation object
141 * 153 *