diff mbox series

[SRU,I/raspi,08/10] Revert "drm/vc4: kms: Wait on previous FIFO users before a commit"

Message ID 20211018155848.334053-9-juergh@canonical.com
State New
Headers show
Series HDMI output freezes under current/proposed impish kernels (LP: #1946368) | expand

Commit Message

Juerg Haefliger Oct. 18, 2021, 3:58 p.m. UTC
BugLink: https://bugs.launchpad.net/bugs/1946368

This reverts commit 9ec03d7f1ed394897891319a4dda75f52c5d292d.

Signed-off-by: Juerg Haefliger <juergh@canonical.com>
---
 drivers/gpu/drm/vc4/vc4_kms.c | 123 +---------------------------------
 1 file changed, 1 insertion(+), 122 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c
index 4103c9bb58ee..d842889f79e7 100644
--- a/drivers/gpu/drm/vc4/vc4_kms.c
+++ b/drivers/gpu/drm/vc4/vc4_kms.c
@@ -40,11 +40,6 @@  static struct vc4_ctm_state *to_vc4_ctm_state(struct drm_private_state *priv)
 struct vc4_hvs_state {
 	struct drm_private_state base;
 	unsigned int unassigned_channels;
-
-	struct {
-		unsigned in_use: 1;
-		struct drm_crtc_commit *pending_commit;
-	} fifo_state[HVS_NUM_CHANNELS];
 };
 
 static struct vc4_hvs_state *
@@ -190,32 +185,6 @@  vc4_ctm_commit(struct vc4_dev *vc4, struct drm_atomic_state *state)
 		  VC4_SET_FIELD(ctm_state->fifo, SCALER_OLEDOFFS_DISPFIFO));
 }
 
-static struct vc4_hvs_state *
-vc4_hvs_get_new_global_state(struct drm_atomic_state *state)
-{
-	struct vc4_dev *vc4 = to_vc4_dev(state->dev);
-	struct drm_private_state *priv_state;
-
-	priv_state = drm_atomic_get_new_private_obj_state(state, &vc4->hvs_channels);
-	if (IS_ERR(priv_state))
-		return ERR_CAST(priv_state);
-
-	return to_vc4_hvs_state(priv_state);
-}
-
-static struct vc4_hvs_state *
-vc4_hvs_get_old_global_state(struct drm_atomic_state *state)
-{
-	struct vc4_dev *vc4 = to_vc4_dev(state->dev);
-	struct drm_private_state *priv_state;
-
-	priv_state = drm_atomic_get_old_private_obj_state(state, &vc4->hvs_channels);
-	if (IS_ERR(priv_state))
-		return ERR_CAST(priv_state);
-
-	return to_vc4_hvs_state(priv_state);
-}
-
 static struct vc4_hvs_state *
 vc4_hvs_get_global_state(struct drm_atomic_state *state)
 {
@@ -342,10 +311,8 @@  vc4_atomic_complete_commit(struct drm_atomic_state *state)
 	struct drm_device *dev = state->dev;
 	struct vc4_dev *vc4 = to_vc4_dev(dev);
 	struct vc4_hvs *hvs = vc4->hvs;
-	struct drm_crtc_state *old_crtc_state;
 	struct drm_crtc_state *new_crtc_state;
 	struct drm_crtc *crtc;
-	struct vc4_hvs_state *old_hvs_state;
 	struct clk_request *core_req;
 	int i;
 
@@ -366,36 +333,6 @@  vc4_atomic_complete_commit(struct drm_atomic_state *state)
 
 	drm_atomic_helper_wait_for_dependencies(state);
 
-	old_hvs_state = vc4_hvs_get_old_global_state(state);
-	if (!old_hvs_state)
-		return;
-
-	for_each_old_crtc_in_state(state, crtc, old_crtc_state, i) {
-		struct vc4_crtc_state *vc4_crtc_state =
-			to_vc4_crtc_state(old_crtc_state);
-		struct drm_crtc_commit *commit;
-		unsigned int channel = vc4_crtc_state->assigned_channel;
-		unsigned long done;
-
-		if (channel == VC4_HVS_CHANNEL_DISABLED)
-			continue;
-
-		if (!old_hvs_state->fifo_state[channel].in_use)
-			continue;
-
-		commit = old_hvs_state->fifo_state[i].pending_commit;
-		if (!commit)
-			continue;
-
-		done = wait_for_completion_timeout(&commit->hw_done, 10 * HZ);
-		if (!done)
-			drm_err(dev, "Timed out waiting for hw_done\n");
-
-		done = wait_for_completion_timeout(&commit->flip_done, 10 * HZ);
-		if (!done)
-			drm_err(dev, "Timed out waiting for flip_done\n");
-	}
-
 	drm_atomic_helper_commit_modeset_disables(dev, state);
 
 	vc4_ctm_commit(vc4, state);
@@ -437,36 +374,6 @@  static void commit_work(struct work_struct *work)
 	vc4_atomic_complete_commit(state);
 }
 
-static int vc4_atomic_commit_setup(struct drm_atomic_state *state)
-{
-	struct drm_crtc_state *crtc_state;
-	struct vc4_hvs_state *hvs_state;
-	struct drm_crtc *crtc;
-	unsigned int i;
-
-	hvs_state = vc4_hvs_get_new_global_state(state);
-	if (!hvs_state)
-		return -EINVAL;
-
-	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
-		struct vc4_crtc_state *vc4_crtc_state =
-			to_vc4_crtc_state(crtc_state);
-		unsigned int channel =
-			vc4_crtc_state->assigned_channel;
-
-		if (channel == VC4_HVS_CHANNEL_DISABLED)
-			continue;
-
-		if (!hvs_state->fifo_state[channel].in_use)
-			continue;
-
-		hvs_state->fifo_state[channel].pending_commit =
-			drm_crtc_commit_get(crtc_state->commit);
-	}
-
-	return 0;
-}
-
 /**
  * vc4_atomic_commit - commit validated state object
  * @dev: DRM device
@@ -788,7 +695,6 @@  vc4_hvs_channels_duplicate_state(struct drm_private_obj *obj)
 {
 	struct vc4_hvs_state *old_state = to_vc4_hvs_state(obj->state);
 	struct vc4_hvs_state *state;
-	unsigned int i;
 
 	state = kzalloc(sizeof(*state), GFP_KERNEL);
 	if (!state)
@@ -798,16 +704,6 @@  vc4_hvs_channels_duplicate_state(struct drm_private_obj *obj)
 
 	state->unassigned_channels = old_state->unassigned_channels;
 
-	for (i = 0; i < HVS_NUM_CHANNELS; i++) {
-		state->fifo_state[i].in_use = old_state->fifo_state[i].in_use;
-
-		if (!old_state->fifo_state[i].pending_commit)
-			continue;
-
-		state->fifo_state[i].pending_commit =
-			drm_crtc_commit_get(old_state->fifo_state[i].pending_commit);
-	}
-
 	return &state->base;
 }
 
@@ -815,14 +711,6 @@  static void vc4_hvs_channels_destroy_state(struct drm_private_obj *obj,
 					   struct drm_private_state *state)
 {
 	struct vc4_hvs_state *hvs_state = to_vc4_hvs_state(state);
-	unsigned int i;
-
-	for (i = 0; i < HVS_NUM_CHANNELS; i++) {
-		if (!hvs_state->fifo_state[i].pending_commit)
-			continue;
-
-		drm_crtc_commit_put(hvs_state->fifo_state[i].pending_commit);
-	}
 
 	kfree(hvs_state);
 }
@@ -919,10 +807,7 @@  static int vc4_pv_muxing_atomic_check(struct drm_device *dev,
 
 		/* If we're disabling our CRTC, we put back our channel */
 		if (!new_crtc_state->enable) {
-			channel = old_vc4_crtc_state->assigned_channel;
-
-			hvs_new_state->unassigned_channels |= BIT(channel);
-			hvs_new_state->fifo_state[channel].in_use = false;
+			hvs_new_state->unassigned_channels |= BIT(old_vc4_crtc_state->assigned_channel);
 			new_vc4_crtc_state->assigned_channel = VC4_HVS_CHANNEL_DISABLED;
 			continue;
 		}
@@ -958,7 +843,6 @@  static int vc4_pv_muxing_atomic_check(struct drm_device *dev,
 		channel = ffs(matching_channels) - 1;
 		new_vc4_crtc_state->assigned_channel = channel;
 		hvs_new_state->unassigned_channels &= ~BIT(channel);
-		hvs_new_state->fifo_state[channel].in_use = true;
 	}
 
 	return 0;
@@ -984,10 +868,6 @@  vc4_atomic_check(struct drm_device *dev, struct drm_atomic_state *state)
 	return vc4_load_tracker_atomic_check(state);
 }
 
-static struct drm_mode_config_helper_funcs vc4_mode_config_helpers = {
-	.atomic_commit_setup	= vc4_atomic_commit_setup,
-};
-
 static const struct drm_mode_config_funcs vc4_mode_funcs = {
 	.atomic_check = vc4_atomic_check,
 	.atomic_commit = vc4_atomic_commit,
@@ -1034,7 +914,6 @@  int vc4_kms_load(struct drm_device *dev)
 	}
 
 	dev->mode_config.funcs = &vc4_mode_funcs;
-	dev->mode_config.helper_private = &vc4_mode_config_helpers;
 	dev->mode_config.preferred_depth = 24;
 	dev->mode_config.async_page_flip = true;
 	dev->mode_config.allow_fb_modifiers = true;