Skip to content

Commit f3c420f

Browse files
committed
drm/vc4: kms: Convert to atomic helpers
Now that the semaphore is gone, our atomic_commit implementation is basically drm_atomic_helper_commit with a somewhat custom commit_tail, the main difference being that we're using wait_for_flip_done instead of wait_for_vblanks used in the drm_atomic_helper_commit_tail helper. Let's switch to using drm_atomic_helper_commit. Acked-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Maxime Ripard <maxime@cerno.tech> Link: https://patchwork.freedesktop.org/patch/msgid/20201204151138.1739736-8-maxime@cerno.tech
1 parent 82faa32 commit f3c420f

File tree

1 file changed

+3
-107
lines changed

1 file changed

+3
-107
lines changed

drivers/gpu/drm/vc4/vc4_kms.c

Lines changed: 3 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,7 @@ static void vc5_hvs_pv_muxing_commit(struct vc4_dev *vc4,
332332
}
333333
}
334334

335-
static void
336-
vc4_atomic_complete_commit(struct drm_atomic_state *state)
335+
static void vc4_atomic_commit_tail(struct drm_atomic_state *state)
337336
{
338337
struct drm_device *dev = state->dev;
339338
struct vc4_dev *vc4 = to_vc4_dev(dev);
@@ -357,10 +356,6 @@ vc4_atomic_complete_commit(struct drm_atomic_state *state)
357356
if (vc4->hvs->hvs5)
358357
clk_set_min_rate(hvs->core_clk, 500000000);
359358

360-
drm_atomic_helper_wait_for_fences(dev, state, false);
361-
362-
drm_atomic_helper_wait_for_dependencies(state);
363-
364359
old_hvs_state = vc4_hvs_get_old_global_state(state);
365360
if (!old_hvs_state)
366361
return;
@@ -412,20 +407,8 @@ vc4_atomic_complete_commit(struct drm_atomic_state *state)
412407

413408
drm_atomic_helper_cleanup_planes(dev, state);
414409

415-
drm_atomic_helper_commit_cleanup_done(state);
416-
417410
if (vc4->hvs->hvs5)
418411
clk_set_min_rate(hvs->core_clk, 0);
419-
420-
drm_atomic_state_put(state);
421-
}
422-
423-
static void commit_work(struct work_struct *work)
424-
{
425-
struct drm_atomic_state *state = container_of(work,
426-
struct drm_atomic_state,
427-
commit_work);
428-
vc4_atomic_complete_commit(state);
429412
}
430413

431414
static int vc4_atomic_commit_setup(struct drm_atomic_state *state)
@@ -458,94 +441,6 @@ static int vc4_atomic_commit_setup(struct drm_atomic_state *state)
458441
return 0;
459442
}
460443

461-
/**
462-
* vc4_atomic_commit - commit validated state object
463-
* @dev: DRM device
464-
* @state: the driver state object
465-
* @nonblock: nonblocking commit
466-
*
467-
* This function commits a with drm_atomic_helper_check() pre-validated state
468-
* object. This can still fail when e.g. the framebuffer reservation fails. For
469-
* now this doesn't implement asynchronous commits.
470-
*
471-
* RETURNS
472-
* Zero for success or -errno.
473-
*/
474-
static int vc4_atomic_commit(struct drm_device *dev,
475-
struct drm_atomic_state *state,
476-
bool nonblock)
477-
{
478-
int ret;
479-
480-
if (state->async_update) {
481-
ret = drm_atomic_helper_prepare_planes(dev, state);
482-
if (ret)
483-
return ret;
484-
485-
drm_atomic_helper_async_commit(dev, state);
486-
487-
drm_atomic_helper_cleanup_planes(dev, state);
488-
489-
return 0;
490-
}
491-
492-
/* We know for sure we don't want an async update here. Set
493-
* state->legacy_cursor_update to false to prevent
494-
* drm_atomic_helper_setup_commit() from auto-completing
495-
* commit->flip_done.
496-
*/
497-
state->legacy_cursor_update = false;
498-
ret = drm_atomic_helper_setup_commit(state, nonblock);
499-
if (ret)
500-
return ret;
501-
502-
INIT_WORK(&state->commit_work, commit_work);
503-
504-
ret = drm_atomic_helper_prepare_planes(dev, state);
505-
if (ret)
506-
return ret;
507-
508-
if (!nonblock) {
509-
ret = drm_atomic_helper_wait_for_fences(dev, state, true);
510-
if (ret) {
511-
drm_atomic_helper_cleanup_planes(dev, state);
512-
return ret;
513-
}
514-
}
515-
516-
/*
517-
* This is the point of no return - everything below never fails except
518-
* when the hw goes bonghits. Which means we can commit the new state on
519-
* the software side now.
520-
*/
521-
522-
BUG_ON(drm_atomic_helper_swap_state(state, false) < 0);
523-
524-
/*
525-
* Everything below can be run asynchronously without the need to grab
526-
* any modeset locks at all under one condition: It must be guaranteed
527-
* that the asynchronous work has either been cancelled (if the driver
528-
* supports it, which at least requires that the framebuffers get
529-
* cleaned up with drm_atomic_helper_cleanup_planes()) or completed
530-
* before the new state gets committed on the software side with
531-
* drm_atomic_helper_swap_state().
532-
*
533-
* This scheme allows new atomic state updates to be prepared and
534-
* checked in parallel to the asynchronous completion of the previous
535-
* update. Which is important since compositors need to figure out the
536-
* composition of the next frame right after having submitted the
537-
* current layout.
538-
*/
539-
540-
drm_atomic_state_get(state);
541-
if (nonblock)
542-
queue_work(system_unbound_wq, &state->commit_work);
543-
else
544-
vc4_atomic_complete_commit(state);
545-
546-
return 0;
547-
}
548-
549444
static struct drm_framebuffer *vc4_fb_create(struct drm_device *dev,
550445
struct drm_file *file_priv,
551446
const struct drm_mode_fb_cmd2 *mode_cmd)
@@ -966,11 +861,12 @@ vc4_atomic_check(struct drm_device *dev, struct drm_atomic_state *state)
966861

967862
static struct drm_mode_config_helper_funcs vc4_mode_config_helpers = {
968863
.atomic_commit_setup = vc4_atomic_commit_setup,
864+
.atomic_commit_tail = vc4_atomic_commit_tail,
969865
};
970866

971867
static const struct drm_mode_config_funcs vc4_mode_funcs = {
972868
.atomic_check = vc4_atomic_check,
973-
.atomic_commit = vc4_atomic_commit,
869+
.atomic_commit = drm_atomic_helper_commit,
974870
.fb_create = vc4_fb_create,
975871
};
976872

0 commit comments

Comments
 (0)