aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu
diff options
context:
space:
mode:
authorHarry Wentland <harry.wentland@amd.com>2017-09-13 10:03:31 -0400
committerAlex Deucher <alexander.deucher@amd.com>2017-09-26 17:00:31 -0400
commit9c5b2b0d409304c2e3c1f4d1c9bb4958e1d46f8f (patch)
tree4ecde893fda73524aa8e5cd0cf59ead89640826a /drivers/gpu/drm/amd/amdgpu
parent6f87a895709eecc1542fe947e349364ad061ac00 (diff)
drm/amdgpu: Pulling old prepare and submit for flip back
This is needed to ensure every single DC commit builds. Reverting this again when it's no longer needed by DC. This reverts commit 98da65d5e32583d89a1b1c760293b601816a98d3. Signed-off-by: Harry Wentland <harry.wentland@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_display.c138
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h15
2 files changed, 124 insertions, 29 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 6ad243293a78..e23b89cc6636 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -138,11 +138,52 @@ static void amdgpu_unpin_work_func(struct work_struct *__work)
138 kfree(work); 138 kfree(work);
139} 139}
140 140
141int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc, 141
142 struct drm_framebuffer *fb, 142static void amdgpu_flip_work_cleanup(struct amdgpu_flip_work *work)
143 struct drm_pending_vblank_event *event, 143{
144 uint32_t page_flip_flags, uint32_t target, 144 int i;
145 struct drm_modeset_acquire_ctx *ctx) 145
146 amdgpu_bo_unref(&work->old_abo);
147 dma_fence_put(work->excl);
148 for (i = 0; i < work->shared_count; ++i)
149 dma_fence_put(work->shared[i]);
150 kfree(work->shared);
151 kfree(work);
152}
153
154static void amdgpu_flip_cleanup_unreserve(struct amdgpu_flip_work *work,
155 struct amdgpu_bo *new_abo)
156{
157 amdgpu_bo_unreserve(new_abo);
158 amdgpu_flip_work_cleanup(work);
159}
160
161static void amdgpu_flip_cleanup_unpin(struct amdgpu_flip_work *work,
162 struct amdgpu_bo *new_abo)
163{
164 if (unlikely(amdgpu_bo_unpin(new_abo) != 0))
165 DRM_ERROR("failed to unpin new abo in error path\n");
166 amdgpu_flip_cleanup_unreserve(work, new_abo);
167}
168
169void amdgpu_crtc_cleanup_flip_ctx(struct amdgpu_flip_work *work,
170 struct amdgpu_bo *new_abo)
171{
172 if (unlikely(amdgpu_bo_reserve(new_abo, true) != 0)) {
173 DRM_ERROR("failed to reserve new abo in error path\n");
174 amdgpu_flip_work_cleanup(work);
175 return;
176 }
177 amdgpu_flip_cleanup_unpin(work, new_abo);
178}
179
180int amdgpu_crtc_prepare_flip(struct drm_crtc *crtc,
181 struct drm_framebuffer *fb,
182 struct drm_pending_vblank_event *event,
183 uint32_t page_flip_flags,
184 uint32_t target,
185 struct amdgpu_flip_work **work_p,
186 struct amdgpu_bo **new_abo_p)
146{ 187{
147 struct drm_device *dev = crtc->dev; 188 struct drm_device *dev = crtc->dev;
148 struct amdgpu_device *adev = dev->dev_private; 189 struct amdgpu_device *adev = dev->dev_private;
@@ -155,7 +196,7 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
155 unsigned long flags; 196 unsigned long flags;
156 u64 tiling_flags; 197 u64 tiling_flags;
157 u64 base; 198 u64 base;
158 int i, r; 199 int r;
159 200
160 work = kzalloc(sizeof *work, GFP_KERNEL); 201 work = kzalloc(sizeof *work, GFP_KERNEL);
161 if (work == NULL) 202 if (work == NULL)
@@ -216,41 +257,80 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
216 spin_unlock_irqrestore(&crtc->dev->event_lock, flags); 257 spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
217 r = -EBUSY; 258 r = -EBUSY;
218 goto pflip_cleanup; 259 goto pflip_cleanup;
260
219 } 261 }
262 spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
263
264 *work_p = work;
265 *new_abo_p = new_abo;
266
267 return 0;
268
269pflip_cleanup:
270 amdgpu_crtc_cleanup_flip_ctx(work, new_abo);
271 return r;
272
273unpin:
274 amdgpu_flip_cleanup_unpin(work, new_abo);
275 return r;
276
277unreserve:
278 amdgpu_flip_cleanup_unreserve(work, new_abo);
279 return r;
220 280
281cleanup:
282 amdgpu_flip_work_cleanup(work);
283 return r;
284
285}
286
287void amdgpu_crtc_submit_flip(struct drm_crtc *crtc,
288 struct drm_framebuffer *fb,
289 struct amdgpu_flip_work *work,
290 struct amdgpu_bo *new_abo)
291{
292 unsigned long flags;
293 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
294
295 spin_lock_irqsave(&crtc->dev->event_lock, flags);
221 amdgpu_crtc->pflip_status = AMDGPU_FLIP_PENDING; 296 amdgpu_crtc->pflip_status = AMDGPU_FLIP_PENDING;
222 amdgpu_crtc->pflip_works = work; 297 amdgpu_crtc->pflip_works = work;
223 298
224
225 DRM_DEBUG_DRIVER("crtc:%d[%p], pflip_stat:AMDGPU_FLIP_PENDING, work: %p,\n",
226 amdgpu_crtc->crtc_id, amdgpu_crtc, work);
227 /* update crtc fb */ 299 /* update crtc fb */
228 crtc->primary->fb = fb; 300 crtc->primary->fb = fb;
229 spin_unlock_irqrestore(&crtc->dev->event_lock, flags); 301 spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
302
303 DRM_DEBUG_DRIVER(
304 "crtc:%d[%p], pflip_stat:AMDGPU_FLIP_PENDING, work: %p,\n",
305 amdgpu_crtc->crtc_id, amdgpu_crtc, work);
306
230 amdgpu_flip_work_func(&work->flip_work.work); 307 amdgpu_flip_work_func(&work->flip_work.work);
231 return 0; 308}
232 309
233pflip_cleanup: 310int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
234 if (unlikely(amdgpu_bo_reserve(new_abo, false) != 0)) { 311 struct drm_framebuffer *fb,
235 DRM_ERROR("failed to reserve new abo in error path\n"); 312 struct drm_pending_vblank_event *event,
236 goto cleanup; 313 uint32_t page_flip_flags,
237 } 314 uint32_t target,
238unpin: 315 struct drm_modeset_acquire_ctx *ctx)
239 if (unlikely(amdgpu_bo_unpin(new_abo) != 0)) { 316{
240 DRM_ERROR("failed to unpin new abo in error path\n"); 317 struct amdgpu_bo *new_abo;
241 } 318 struct amdgpu_flip_work *work;
242unreserve: 319 int r;
243 amdgpu_bo_unreserve(new_abo);
244 320
245cleanup: 321 r = amdgpu_crtc_prepare_flip(crtc,
246 amdgpu_bo_unref(&work->old_abo); 322 fb,
247 dma_fence_put(work->excl); 323 event,
248 for (i = 0; i < work->shared_count; ++i) 324 page_flip_flags,
249 dma_fence_put(work->shared[i]); 325 target,
250 kfree(work->shared); 326 &work,
251 kfree(work); 327 &new_abo);
328 if (r)
329 return r;
252 330
253 return r; 331 amdgpu_crtc_submit_flip(crtc, fb, work, new_abo);
332
333 return 0;
254} 334}
255 335
256int amdgpu_crtc_set_config(struct drm_mode_set *set, 336int amdgpu_crtc_set_config(struct drm_mode_set *set,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
index 2af2678ddaf6..109a3833c3a8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
@@ -587,6 +587,21 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
587 struct drm_pending_vblank_event *event, 587 struct drm_pending_vblank_event *event,
588 uint32_t page_flip_flags, uint32_t target, 588 uint32_t page_flip_flags, uint32_t target,
589 struct drm_modeset_acquire_ctx *ctx); 589 struct drm_modeset_acquire_ctx *ctx);
590void amdgpu_crtc_cleanup_flip_ctx(struct amdgpu_flip_work *work,
591 struct amdgpu_bo *new_abo);
592int amdgpu_crtc_prepare_flip(struct drm_crtc *crtc,
593 struct drm_framebuffer *fb,
594 struct drm_pending_vblank_event *event,
595 uint32_t page_flip_flags,
596 uint32_t target,
597 struct amdgpu_flip_work **work,
598 struct amdgpu_bo **new_abo);
599
600void amdgpu_crtc_submit_flip(struct drm_crtc *crtc,
601 struct drm_framebuffer *fb,
602 struct amdgpu_flip_work *work,
603 struct amdgpu_bo *new_abo);
604
590extern const struct drm_mode_config_funcs amdgpu_mode_funcs; 605extern const struct drm_mode_config_funcs amdgpu_mode_funcs;
591 606
592#endif 607#endif