[Freedreno] [DPU PATCH 08/11] drm/msm: Remove hand-rolled out fences

Sean Paul seanpaul at chromium.org
Wed Feb 28 19:19:03 UTC 2018


Remove release/output/retire fences from the dpu driver. These are
already available via drm core's OUT_FENCE property.

Change-Id: Id4238d0b5457f2c8ee2e87bb7814e1850a573623
Signed-off-by: Sean Paul <seanpaul at chromium.org>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_connector.c |  66 +------
 drivers/gpu/drm/msm/disp/dpu1/dpu_connector.h |  23 ---
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c      | 178 +++---------------
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h      |  28 ---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c   |   3 -
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h   |   4 +-
 .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h  |   8 -
 .../drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c  |  73 +------
 .../drm/msm/disp/dpu1/dpu_encoder_phys_vid.c  |  19 --
 .../drm/msm/disp/dpu1/dpu_encoder_phys_wb.c   |  12 +-
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c       |  30 ---
 drivers/gpu/drm/msm/msm_drv.h                 |   3 -
 12 files changed, 36 insertions(+), 411 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_connector.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_connector.c
index 57b8627ef418..cc5bfa862cb7 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_connector.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_connector.c
@@ -521,7 +521,6 @@ static void dpu_connector_destroy(struct drm_connector *connector)
 		backlight_device_unregister(c_conn->bl_device);
 	drm_connector_unregister(connector);
 	mutex_destroy(&c_conn->lock);
-	dpu_fence_deinit(&c_conn->retire_fence);
 	drm_connector_cleanup(connector);
 	kfree(c_conn);
 }
@@ -906,12 +905,9 @@ static int dpu_connector_atomic_get_property(struct drm_connector *connector,
 	c_state = to_dpu_connector_state(state);
 
 	idx = msm_property_index(&c_conn->property_info, property);
-	if (idx == CONNECTOR_PROP_RETIRE_FENCE)
-		rc = dpu_fence_create(&c_conn->retire_fence, val, 0);
-	else
-		/* get cached property value */
-		rc = msm_property_atomic_get(&c_conn->property_info,
-				&c_state->property_state, property, val);
+	/* get cached property value */
+	rc = msm_property_atomic_get(&c_conn->property_info,
+			&c_state->property_state, property, val);
 
 	/* allow for custom override */
 	if (c_conn->ops.get_property)
@@ -923,39 +919,6 @@ static int dpu_connector_atomic_get_property(struct drm_connector *connector,
 	return rc;
 }
 
-void dpu_connector_prepare_fence(struct drm_connector *connector)
-{
-	if (!connector) {
-		DPU_ERROR("invalid connector\n");
-		return;
-	}
-
-	dpu_fence_prepare(&to_dpu_connector(connector)->retire_fence);
-}
-
-void dpu_connector_complete_commit(struct drm_connector *connector,
-		ktime_t ts)
-{
-	if (!connector) {
-		DPU_ERROR("invalid connector\n");
-		return;
-	}
-
-	/* signal connector's retire fence */
-	dpu_fence_signal(&to_dpu_connector(connector)->retire_fence, ts, false);
-}
-
-void dpu_connector_commit_reset(struct drm_connector *connector, ktime_t ts)
-{
-	if (!connector) {
-		DPU_ERROR("invalid connector\n");
-		return;
-	}
-
-	/* signal connector's retire fence */
-	dpu_fence_signal(&to_dpu_connector(connector)->retire_fence, ts, true);
-}
-
 static enum drm_connector_status
 dpu_connector_detect(struct drm_connector *connector, bool force)
 {
@@ -1214,26 +1177,19 @@ struct drm_connector *dpu_connector_init(struct drm_device *dev,
 			"conn%u",
 			c_conn->base.base.id);
 
-	rc = dpu_fence_init(&c_conn->retire_fence, c_conn->name,
-			c_conn->base.base.id);
-	if (rc) {
-		DPU_ERROR("failed to init fence, %d\n", rc);
-		goto error_cleanup_conn;
-	}
-
 	mutex_init(&c_conn->lock);
 
 	rc = drm_mode_connector_attach_encoder(&c_conn->base, encoder);
 	if (rc) {
 		DPU_ERROR("failed to attach encoder to connector, %d\n", rc);
-		goto error_cleanup_fence;
+		goto error_cleanup_conn;
 	}
 
 #ifdef CONFIG_DRM_MSM_DSI_STAGING
 	rc = dpu_backlight_setup(c_conn, dev);
 	if (rc) {
 		DPU_ERROR("failed to setup backlight, rc=%d\n", rc);
-		goto error_cleanup_fence;
+		goto error_cleanup_conn;
 	}
 #endif
 
@@ -1248,7 +1204,7 @@ struct drm_connector *dpu_connector_init(struct drm_device *dev,
 		if (!info) {
 			DPU_ERROR("failed to allocate info buffer\n");
 			rc = -ENOMEM;
-			goto error_cleanup_fence;
+			goto error_cleanup_conn;
 		}
 
 		dpu_kms_info_reset(info);
@@ -1256,7 +1212,7 @@ struct drm_connector *dpu_connector_init(struct drm_device *dev,
 		if (rc) {
 			DPU_ERROR("post-init failed, %d\n", rc);
 			kfree(info);
-			goto error_cleanup_fence;
+			goto error_cleanup_conn;
 		}
 
 		msm_property_install_blob(&c_conn->property_info,
@@ -1310,10 +1266,6 @@ struct drm_connector *dpu_connector_init(struct drm_device *dev,
 				&c_conn->property_info, "dpu_drm_roi_v1", 0x0,
 				0, ~0, 0, CONNECTOR_PROP_ROI_V1);
 	}
-
-	msm_property_install_range(&c_conn->property_info, "RETIRE_FENCE",
-			0x0, 0, INR_OPEN_MAX, 0, CONNECTOR_PROP_RETIRE_FENCE);
-
 	msm_property_install_range(&c_conn->property_info, "autorefresh",
 			0x0, 0, AUTOREFRESH_MAX_FRAME_CNT, 0,
 			CONNECTOR_PROP_AUTOREFRESH);
@@ -1354,10 +1306,8 @@ struct drm_connector *dpu_connector_init(struct drm_device *dev,
 		drm_property_blob_put(c_conn->blob_dither);
 
 	msm_property_destroy(&c_conn->property_info);
-error_cleanup_fence:
-	mutex_destroy(&c_conn->lock);
-	dpu_fence_deinit(&c_conn->retire_fence);
 error_cleanup_conn:
+	mutex_destroy(&c_conn->lock);
 	drm_connector_cleanup(&c_conn->base);
 error_free_conn:
 	kfree(c_conn);
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_connector.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_connector.h
index f6f4837d1359..fdb4d8766549 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_connector.h
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_connector.h
@@ -21,7 +21,6 @@
 #include "msm_drv.h"
 #include "msm_prop.h"
 #include "dpu_kms.h"
-#include "dpu_fence.h"
 
 #define DPU_CONNECTOR_NAME_SIZE	16
 
@@ -247,7 +246,6 @@ struct dpu_connector_evt {
  * @mmu_unsecure: MMU id for unsecure buffers
  * @name: ASCII name of connector
  * @lock: Mutex lock object for this structure
- * @retire_fence: Retire fence context reference
  * @ops: Local callback function pointer table
  * @dpms_mode: DPMS property setting from user space
  * @lp_mode: LP property setting from user space
@@ -274,7 +272,6 @@ struct dpu_connector {
 	char name[DPU_CONNECTOR_NAME_SIZE];
 
 	struct mutex lock;
-	struct dpu_fence_context retire_fence;
 	struct dpu_connector_ops ops;
 	int dpms_mode;
 	int lp_mode;
@@ -447,26 +444,6 @@ struct drm_connector *dpu_connector_init(struct drm_device *dev,
 		int connector_poll,
 		int connector_type);
 
-/**
- * dpu_connector_prepare_fence - prepare fence support for current commit
- * @connector: Pointer to drm connector object
- */
-void dpu_connector_prepare_fence(struct drm_connector *connector);
-
-/**
- * dpu_connector_complete_commit - signal completion of current commit
- * @connector: Pointer to drm connector object
- * @ts: timestamp to be updated in the fence signalling
- */
-void dpu_connector_complete_commit(struct drm_connector *connector, ktime_t ts);
-
-/**
- * dpu_connector_commit_reset - reset the completion signal
- * @connector: Pointer to drm connector object
- * @ts: timestamp to be updated in the fence signalling
- */
-void dpu_connector_commit_reset(struct drm_connector *connector, ktime_t ts);
-
 /**
  * dpu_connector_get_info - query display specific information
  * @connector: Pointer to drm connector object
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
index a261021e5deb..2d44989ade7a 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
@@ -629,7 +629,6 @@ static void dpu_crtc_destroy(struct drm_crtc *crtc)
 	dpu_cp_crtc_destroy_properties(crtc);
 	_dpu_crtc_destroy_dest_scaler(dpu_crtc);
 
-	dpu_fence_deinit(&dpu_crtc->output_fence);
 	_dpu_crtc_deinit_events(dpu_crtc);
 
 	drm_crtc_cleanup(crtc);
@@ -1671,65 +1670,6 @@ static void _dpu_crtc_dest_scaler_setup(struct drm_crtc *crtc)
 	}
 }
 
-void dpu_crtc_prepare_commit(struct drm_crtc *crtc,
-		struct drm_crtc_state *old_state)
-{
-	struct drm_device *dev;
-	struct dpu_crtc *dpu_crtc;
-	struct dpu_crtc_state *cstate;
-	struct drm_connector *conn;
-	struct drm_connector_list_iter conn_iter;
-	struct dpu_crtc_retire_event *retire_event = NULL;
-	unsigned long flags;
-	int i;
-
-	if (!crtc || !crtc->state) {
-		DPU_ERROR("invalid crtc\n");
-		return;
-	}
-
-	dev = crtc->dev;
-	dpu_crtc = to_dpu_crtc(crtc);
-	cstate = to_dpu_crtc_state(crtc->state);
-	DPU_EVT32_VERBOSE(DRMID(crtc));
-
-	/* identify connectors attached to this crtc */
-	cstate->num_connectors = 0;
-
-	drm_connector_list_iter_begin(dev, &conn_iter);
-	drm_for_each_connector_iter(conn, &conn_iter)
-		if (conn->state && conn->state->crtc == crtc &&
-				cstate->num_connectors < MAX_CONNECTORS) {
-			cstate->connectors[cstate->num_connectors++] = conn;
-			dpu_connector_prepare_fence(conn);
-		}
-	drm_connector_list_iter_end(&conn_iter);
-
-	for (i = 0; i < DPU_CRTC_FRAME_EVENT_SIZE; i++) {
-		retire_event = &dpu_crtc->retire_events[i];
-		if (list_empty(&retire_event->list))
-			break;
-		retire_event = NULL;
-	}
-
-	if (retire_event) {
-		retire_event->num_connectors = cstate->num_connectors;
-		for (i = 0; i < cstate->num_connectors; i++)
-			retire_event->connectors[i] = cstate->connectors[i];
-
-		spin_lock_irqsave(&dpu_crtc->spin_lock, flags);
-		list_add_tail(&retire_event->list,
-						&dpu_crtc->retire_event_list);
-		spin_unlock_irqrestore(&dpu_crtc->spin_lock, flags);
-	} else {
-		DPU_ERROR("crtc%d retire event overflow\n", crtc->base.id);
-		DPU_EVT32(DRMID(crtc), DPU_EVTLOG_ERROR);
-	}
-
-	/* prepare main output fence */
-	dpu_fence_prepare(&dpu_crtc->output_fence);
-}
-
 /**
  *  _dpu_crtc_complete_flip - signal pending page_flip events
  * Any pending vblank events are added to the vblank_event_list
@@ -1799,41 +1739,6 @@ static void dpu_crtc_vblank_cb(void *data)
 	DPU_EVT32_VERBOSE(DRMID(crtc));
 }
 
-static void _dpu_crtc_retire_event(struct drm_crtc *crtc, ktime_t ts)
-{
-	struct dpu_crtc_retire_event *retire_event;
-	struct dpu_crtc *dpu_crtc;
-	unsigned long flags;
-	int i;
-
-	if (!crtc) {
-		DPU_ERROR("invalid param\n");
-		return;
-	}
-
-	dpu_crtc = to_dpu_crtc(crtc);
-	spin_lock_irqsave(&dpu_crtc->spin_lock, flags);
-	retire_event = list_first_entry_or_null(&dpu_crtc->retire_event_list,
-				struct dpu_crtc_retire_event, list);
-	if (retire_event)
-		list_del_init(&retire_event->list);
-	spin_unlock_irqrestore(&dpu_crtc->spin_lock, flags);
-
-	if (!retire_event) {
-		DPU_ERROR("crtc%d retire event without kickoff\n",
-								crtc->base.id);
-		DPU_EVT32(DRMID(crtc), DPU_EVTLOG_ERROR);
-		return;
-	}
-
-	DPU_ATRACE_BEGIN("signal_retire_fence");
-	for (i = 0; (i < retire_event->num_connectors) &&
-					retire_event->connectors[i]; ++i)
-		dpu_connector_complete_commit(
-					retire_event->connectors[i], ts);
-	DPU_ATRACE_END("signal_retire_fence");
-}
-
 /* _dpu_crtc_idle_notify - signal idle timeout to client */
 static void _dpu_crtc_idle_notify(struct dpu_crtc *dpu_crtc)
 {
@@ -1945,16 +1850,6 @@ static void dpu_crtc_frame_event_work(struct kthread_work *work)
 			frame_done = true;
 	}
 
-	if (fevent->event & DPU_ENCODER_FRAME_EVENT_SIGNAL_RELEASE_FENCE) {
-		DPU_ATRACE_BEGIN("signal_release_fence");
-		dpu_fence_signal(&dpu_crtc->output_fence, fevent->ts, false);
-		DPU_ATRACE_END("signal_release_fence");
-	}
-
-	if (fevent->event & DPU_ENCODER_FRAME_EVENT_SIGNAL_RETIRE_FENCE)
-		/* this api should be called without spin_lock */
-		_dpu_crtc_retire_event(crtc, fevent->ts);
-
 	if (fevent->event & DPU_ENCODER_FRAME_EVENT_PANEL_DEAD)
 		DPU_ERROR("crtc%d ts:%lld received panel dead event\n",
 				crtc->base.id, ktime_to_ns(fevent->ts));
@@ -1971,11 +1866,11 @@ static void dpu_crtc_frame_event_work(struct kthread_work *work)
 /*
  * dpu_crtc_frame_event_cb - crtc frame event callback API. CRTC module
  * registers this API to encoder for all frame event callbacks like
- * release_fence, retire_fence, frame_error, frame_done, idle_timeout,
- * etc. Encoder may call different events from different context - IRQ,
- * user thread, commit_thread, etc. Each event should be carefully
- * reviewed and should be processed in proper task context to avoid scheduling
- * delay or properly manage the irq context's bottom half processing.
+ * frame_error, frame_done, idle_timeout, etc. Encoder may call different events
+ * from different context - IRQ, user thread, commit_thread, etc. Each event
+ * should be carefully reviewed and should be processed in proper task context
+ * to avoid schedulin delay or properly manage the irq context's bottom half
+ * processing.
  */
 static void dpu_crtc_frame_event_cb(void *data, u32 event)
 {
@@ -3484,14 +3379,6 @@ static void dpu_crtc_disable(struct drm_crtc *crtc)
 		dpu_power_handle_unregister_event(&priv->phandle,
 				dpu_crtc->power_event);
 
-	/**
-	 * All callbacks are unregistered and frame done waits are complete
-	 * at this point. No buffers are accessed by hardware.
-	 * reset the fence timeline if there is any issue.
-	 */
-	dpu_fence_signal(&dpu_crtc->output_fence, ktime_get(), true);
-	for (i = 0; i < cstate->num_connectors; ++i)
-		dpu_connector_commit_reset(cstate->connectors[i], ktime_get());
 
 	memset(dpu_crtc->mixers, 0, sizeof(dpu_crtc->mixers));
 	dpu_crtc->num_mixers = 0;
@@ -3703,6 +3590,8 @@ static int dpu_crtc_atomic_check(struct drm_crtc *crtc,
 	int multirect_count = 0;
 	const struct drm_plane_state *pipe_staged[SSPP_MAX];
 	int left_zpos_cnt = 0, right_zpos_cnt = 0;
+	struct drm_connector_list_iter conn_iter;
+	struct drm_connector *conn;
 
 	if (!crtc) {
 		DPU_ERROR("invalid crtc\n");
@@ -3956,6 +3845,16 @@ static int dpu_crtc_atomic_check(struct drm_crtc *crtc,
 		goto end;
 	}
 
+	/* identify connectors attached to this crtc */
+	cstate->num_connectors = 0;
+	drm_connector_list_iter_begin(crtc->dev, &conn_iter);
+	drm_for_each_connector_iter(conn, &conn_iter)
+		if (conn->state && conn->state->crtc == crtc &&
+				cstate->num_connectors < MAX_CONNECTORS) {
+			cstate->connectors[cstate->num_connectors++] = conn;
+		}
+	drm_connector_list_iter_end(&conn_iter);
+
 end:
 	_dpu_crtc_rp_free_unused(&cstate->rp);
 	return rc;
@@ -4034,13 +3933,6 @@ static void dpu_crtc_install_properties(struct drm_crtc *crtc,
 		"input_fence_timeout", 0x0, 0, DPU_CRTC_MAX_INPUT_FENCE_TIMEOUT,
 		DPU_CRTC_INPUT_FENCE_TIMEOUT, CRTC_PROP_INPUT_FENCE_TIMEOUT);
 
-	msm_property_install_range(&dpu_crtc->property_info, "output_fence",
-			0x0, 0, INR_OPEN_MAX, 0x0, CRTC_PROP_OUTPUT_FENCE);
-
-	msm_property_install_range(&dpu_crtc->property_info,
-			"output_fence_offset", 0x0, 0, 1, 0,
-			CRTC_PROP_OUTPUT_FENCE_OFFSET);
-
 	msm_property_install_range(&dpu_crtc->property_info,
 			"core_clk", 0x0, 0, U64_MAX,
 			dpu_kms->perf.max_core_clk_rate,
@@ -4342,29 +4234,12 @@ static int dpu_crtc_atomic_get_property(struct drm_crtc *crtc,
 		}
 
 		i = msm_property_index(&dpu_crtc->property_info, property);
-		if (i == CRTC_PROP_OUTPUT_FENCE) {
-			uint32_t offset = dpu_crtc_get_property(cstate,
-					CRTC_PROP_OUTPUT_FENCE_OFFSET);
-
-			/**
-			 * set the offset to 0 only for cmd mode panels, so
-			 * the release fence for the current frame can be
-			 * triggered right after PP_DONE interrupt.
-			 */
-			offset = is_cmd ? 0 : (offset + conn_offset);
-
-			ret = dpu_fence_create(&dpu_crtc->output_fence, val,
-								offset);
-			if (ret)
-				DPU_ERROR("fence create failed\n");
-		} else {
-			ret = msm_property_atomic_get(&dpu_crtc->property_info,
-					&cstate->property_state,
-					property, val);
-			if (ret)
-				ret = dpu_cp_crtc_get_property(crtc,
-					property, val);
-		}
+		ret = msm_property_atomic_get(&dpu_crtc->property_info,
+				&cstate->property_state,
+				property, val);
+		if (ret)
+			ret = dpu_cp_crtc_get_property(crtc,
+				property, val);
 		if (ret)
 			DRM_ERROR("get property failed\n");
 	}
@@ -4858,10 +4733,6 @@ static int _dpu_crtc_init_events(struct dpu_crtc *dpu_crtc)
 		list_add_tail(&dpu_crtc->event_cache[i].list,
 				&dpu_crtc->event_free_list);
 
-	INIT_LIST_HEAD(&dpu_crtc->retire_event_list);
-	for (i = 0; i < ARRAY_SIZE(dpu_crtc->retire_events); i++)
-		INIT_LIST_HEAD(&dpu_crtc->retire_events[i].list);
-
 	return rc;
 }
 
@@ -4920,9 +4791,6 @@ struct drm_crtc *dpu_crtc_init(struct drm_device *dev, struct drm_plane *plane)
 		return ERR_PTR(rc);
 	}
 
-	/* initialize output fence support */
-	dpu_fence_init(&dpu_crtc->output_fence, dpu_crtc->name, crtc->base.id);
-
 	/* create CRTC properties */
 	msm_property_init(&dpu_crtc->property_info, &crtc->base, dev,
 			priv->crtc_property, dpu_crtc->property_data,
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h
index b63df243be33..727a3434a4f6 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h
@@ -22,7 +22,6 @@
 #include <linux/kthread.h>
 #include <drm/drm_crtc.h>
 #include "msm_prop.h"
-#include "dpu_fence.h"
 #include "dpu_kms.h"
 #include "dpu_core_perf.h"
 #include "dpu_hw_blk.h"
@@ -85,17 +84,6 @@ struct dpu_crtc_smmu_state_data {
 	uint32_t transition_error;
 };
 
-/**
- * @connectors    : Currently associated drm connectors for retire event
- * @num_connectors: Number of associated drm connectors for retire event
- * @list:	event list
- */
-struct dpu_crtc_retire_event {
-	struct drm_connector *connectors[MAX_CONNECTORS];
-	int num_connectors;
-	struct list_head list;
-};
-
 /**
  * struct dpu_crtc_mixer: stores the map for each virtual pipeline in the CRTC
  * @hw_lm:	LM HW Driver context
@@ -169,7 +157,6 @@ struct dpu_crtc_event {
  * @drm_requested_vblank : Whether vblanks have been enabled in the encoder
  * @property_info : Opaque structure for generic property support
  * @property_defaults : Array of default values for generic property support
- * @output_fence  : output release fence context
  * @stage_cfg     : H/w mixer stage configuration
  * @debugfs_root  : Parent of debugfs node
  * @vblank_cb_count : count of vblank callback since last reset
@@ -190,8 +177,6 @@ struct dpu_crtc_event {
  * @frame_events  : static allocation of in-flight frame events
  * @frame_event_list : available frame event list
  * @spin_lock     : spin lock for frame event, transaction status, etc...
- * @retire_events  : static allocation of retire fence connector
- * @retire_event_list : available retire fence connector list
  * @frame_done_comp    : for frame_event_done synchronization
  * @event_thread  : Pointer to event handler thread
  * @event_worker  : Event worker queue
@@ -227,9 +212,6 @@ struct dpu_crtc {
 	struct msm_property_data property_data[CRTC_PROP_COUNT];
 	struct drm_property_blob *blob_info;
 
-	/* output fence support */
-	struct dpu_fence_context output_fence;
-
 	struct dpu_hw_stage_cfg stage_cfg;
 	struct dentry *debugfs_root;
 
@@ -253,8 +235,6 @@ struct dpu_crtc {
 	struct dpu_crtc_frame_event frame_events[DPU_CRTC_FRAME_EVENT_SIZE];
 	struct list_head frame_event_list;
 	spinlock_t spin_lock;
-	struct dpu_crtc_retire_event retire_events[DPU_CRTC_FRAME_EVENT_SIZE];
-	struct list_head retire_event_list;
 	struct completion frame_done_comp;
 
 	/* for handling internal event thread */
@@ -475,14 +455,6 @@ int dpu_crtc_vblank(struct drm_crtc *crtc, bool en);
  */
 void dpu_crtc_commit_kickoff(struct drm_crtc *crtc);
 
-/**
- * dpu_crtc_prepare_commit - callback to prepare for output fences
- * @crtc: Pointer to drm crtc object
- * @old_state: Pointer to drm crtc old state object
- */
-void dpu_crtc_prepare_commit(struct drm_crtc *crtc,
-		struct drm_crtc_state *old_state);
-
 /**
  * dpu_crtc_complete_commit - callback signalling completion of current commit
  * @crtc: Pointer to drm crtc object
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
index 4d1e3652dbf4..a54ad2cd5856 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
@@ -2465,9 +2465,6 @@ static inline void _dpu_encoder_trigger_flush(struct drm_encoder *drm_enc,
 
 	pending_kickoff_cnt = dpu_encoder_phys_inc_pending(phys);
 
-	if (phys->ops.is_master && phys->ops.is_master(phys))
-		atomic_inc(&phys->pending_retire_fence_cnt);
-
 	if (extra_flush_bits && ctl->ops.update_pending_flush)
 		ctl->ops.update_pending_flush(ctl, extra_flush_bits);
 
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
index 69fb26cb43ab..86a3800af673 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
@@ -27,9 +27,7 @@
 #define DPU_ENCODER_FRAME_EVENT_DONE			BIT(0)
 #define DPU_ENCODER_FRAME_EVENT_ERROR			BIT(1)
 #define DPU_ENCODER_FRAME_EVENT_PANEL_DEAD		BIT(2)
-#define DPU_ENCODER_FRAME_EVENT_SIGNAL_RELEASE_FENCE	BIT(3)
-#define DPU_ENCODER_FRAME_EVENT_SIGNAL_RETIRE_FENCE	BIT(4)
-#define DPU_ENCODER_FRAME_EVENT_IDLE			BIT(5)
+#define DPU_ENCODER_FRAME_EVENT_IDLE			BIT(3)
 
 #define IDLE_TIMEOUT	(66 - 16/2)
 
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h
index 3b05569007d2..71cd2f258994 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h
@@ -245,8 +245,6 @@ struct dpu_encoder_irq {
  *				scheduled. Decremented in irq handler
  * @pending_ctlstart_cnt:	Atomic counter tracking the number of ctl start
  *                              pending.
- * @pending_retire_fence_cnt:   Atomic counter tracking the pending retire
- *                              fences that have to be signalled.
  * @pending_kickoff_wq:		Wait queue for blocking until kickoff completes
  * @irq:			IRQ tracking structures
  */
@@ -273,7 +271,6 @@ struct dpu_encoder_phys {
 	atomic_t underrun_cnt;
 	atomic_t pending_ctlstart_cnt;
 	atomic_t pending_kickoff_cnt;
-	atomic_t pending_retire_fence_cnt;
 	wait_queue_head_t pending_kickoff_wq;
 	struct dpu_encoder_irq irq[INTR_IDX_MAX];
 };
@@ -323,9 +320,6 @@ struct dpu_encoder_phys_cmd_autorefresh {
  *			after ctl_start instead of before next frame kickoff
  * @pp_timeout_report_cnt: number of pingpong done irq timeout errors
  * @autorefresh: autorefresh feature state
- * @pending_rd_ptr_cnt: atomic counter to indicate if retire fence can be
- *                      signaled at the next rd_ptr_irq
- * @rd_ptr_timestamp: last rd_ptr_irq timestamp
  * @pending_vblank_cnt: Atomic counter tracking pending wait for VBLANK
  * @pending_vblank_wq: Wait queue for blocking until VBLANK received
  */
@@ -335,8 +329,6 @@ struct dpu_encoder_phys_cmd {
 	bool serialize_wait4pp;
 	int pp_timeout_report_cnt;
 	struct dpu_encoder_phys_cmd_autorefresh autorefresh;
-	atomic_t pending_rd_ptr_cnt;
-	ktime_t rd_ptr_timestamp;
 	atomic_t pending_vblank_cnt;
 	wait_queue_head_t pending_vblank_wq;
 };
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
index e92380a1d5a4..6ccf37820aa2 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
@@ -44,12 +44,6 @@
 
 #define DPU_ENC_WR_PTR_START_TIMEOUT_US 20000
 
-/*
- * Threshold for signalling retire fences in cases where
- * CTL_START_IRQ is received just after RD_PTR_IRQ
- */
-#define DPU_ENC_CTL_START_THRESHOLD_US 500
-
 static inline int _dpu_encoder_phys_cmd_get_idle_timeout(
 		struct dpu_encoder_phys_cmd *cmd_enc)
 {
@@ -170,8 +164,7 @@ static void dpu_encoder_phys_cmd_pp_tx_done_irq(void *arg, int irq_idx)
 	struct dpu_encoder_phys *phys_enc = arg;
 	unsigned long lock_flags;
 	int new_cnt;
-	u32 event = DPU_ENCODER_FRAME_EVENT_DONE |
-			DPU_ENCODER_FRAME_EVENT_SIGNAL_RELEASE_FENCE;
+	u32 event = DPU_ENCODER_FRAME_EVENT_DONE;
 
 	if (!phys_enc || !phys_enc->hw_pp)
 		return;
@@ -221,7 +214,6 @@ static void dpu_encoder_phys_cmd_pp_rd_ptr_irq(void *arg, int irq_idx)
 {
 	struct dpu_encoder_phys *phys_enc = arg;
 	struct dpu_encoder_phys_cmd *cmd_enc;
-	u32 event = 0;
 
 	if (!phys_enc || !phys_enc->hw_pp)
 		return;
@@ -229,30 +221,10 @@ static void dpu_encoder_phys_cmd_pp_rd_ptr_irq(void *arg, int irq_idx)
 	DPU_ATRACE_BEGIN("rd_ptr_irq");
 	cmd_enc = to_dpu_encoder_phys_cmd(phys_enc);
 
-	/**
-	 * signal only for master, when the ctl_start irq is
-	 * done and incremented the pending_rd_ptr_cnt.
-	 */
-	if (dpu_encoder_phys_cmd_is_master(phys_enc)
-		    && atomic_add_unless(&cmd_enc->pending_rd_ptr_cnt, -1, 0)
-		    && atomic_add_unless(
-				&phys_enc->pending_retire_fence_cnt, -1, 0)) {
-
-		event = DPU_ENCODER_FRAME_EVENT_SIGNAL_RETIRE_FENCE;
-		if (phys_enc->parent_ops.handle_frame_done)
-			phys_enc->parent_ops.handle_frame_done(
-				phys_enc->parent, phys_enc, event);
-	}
-
-	DPU_EVT32_IRQ(DRMID(phys_enc->parent),
-			phys_enc->hw_pp->idx - PINGPONG_0, event, 0xfff);
-
 	if (phys_enc->parent_ops.handle_vblank_virt)
 		phys_enc->parent_ops.handle_vblank_virt(phys_enc->parent,
 			phys_enc);
 
-	cmd_enc->rd_ptr_timestamp = ktime_get();
-
 	atomic_add_unless(&cmd_enc->pending_vblank_cnt, -1, 0);
 	wake_up_all(&cmd_enc->pending_vblank_wq);
 	DPU_ATRACE_END("rd_ptr_irq");
@@ -262,9 +234,6 @@ static void dpu_encoder_phys_cmd_ctl_start_irq(void *arg, int irq_idx)
 {
 	struct dpu_encoder_phys *phys_enc = arg;
 	struct dpu_encoder_phys_cmd *cmd_enc;
-	struct dpu_hw_ctl *ctl;
-	u32 event = 0;
-	s64 time_diff_us;
 
 	if (!phys_enc || !phys_enc->hw_ctl)
 		return;
@@ -272,43 +241,8 @@ static void dpu_encoder_phys_cmd_ctl_start_irq(void *arg, int irq_idx)
 	DPU_ATRACE_BEGIN("ctl_start_irq");
 	cmd_enc = to_dpu_encoder_phys_cmd(phys_enc);
 
-	ctl = phys_enc->hw_ctl;
 	atomic_add_unless(&phys_enc->pending_ctlstart_cnt, -1, 0);
 
-	time_diff_us = ktime_us_delta(ktime_get(), cmd_enc->rd_ptr_timestamp);
-
-	/* handle retire fence based on only master */
-	if (dpu_encoder_phys_cmd_is_master(phys_enc)
-			&& atomic_read(&phys_enc->pending_retire_fence_cnt)) {
-		/**
-		 * Handle rare cases where the ctl_start_irq is received
-		 * after rd_ptr_irq. If it falls within a threshold, it is
-		 * guaranteed the frame would be picked up in the current TE.
-		 * Signal retire fence immediately in such case.
-		 */
-		if ((time_diff_us <= DPU_ENC_CTL_START_THRESHOLD_US)
-			    && atomic_add_unless(
-				&phys_enc->pending_retire_fence_cnt, -1, 0)) {
-
-			event = DPU_ENCODER_FRAME_EVENT_SIGNAL_RETIRE_FENCE;
-
-			if (phys_enc->parent_ops.handle_frame_done)
-				phys_enc->parent_ops.handle_frame_done(
-					phys_enc->parent, phys_enc, event);
-
-		/**
-		 * In ideal cases, ctl_start_irq is received before the
-		 * rd_ptr_irq, so set the atomic flag to indicate the event
-		 * and rd_ptr_irq will handle signalling the retire fence
-		 */
-		} else {
-			atomic_inc(&cmd_enc->pending_rd_ptr_cnt);
-		}
-	}
-
-	DPU_EVT32_IRQ(DRMID(phys_enc->parent), ctl->idx - CTL_0,
-				time_diff_us, event, 0xfff);
-
 	/* Signal any waiting ctl start interrupt */
 	wake_up_all(&phys_enc->pending_kickoff_wq);
 	DPU_ATRACE_END("ctl_start_irq");
@@ -409,8 +343,7 @@ static int _dpu_encoder_phys_cmd_handle_ppdone_timeout(
 {
 	struct dpu_encoder_phys_cmd *cmd_enc =
 			to_dpu_encoder_phys_cmd(phys_enc);
-	u32 frame_event = DPU_ENCODER_FRAME_EVENT_ERROR
-				| DPU_ENCODER_FRAME_EVENT_SIGNAL_RELEASE_FENCE;
+	u32 frame_event = DPU_ENCODER_FRAME_EVENT_ERROR;
 	bool do_log = false;
 
 	if (!phys_enc || !phys_enc->hw_pp || !phys_enc->hw_ctl)
@@ -1346,8 +1279,6 @@ struct dpu_encoder_phys *dpu_encoder_phys_cmd_init(
 	atomic_set(&phys_enc->vblank_refcount, 0);
 	atomic_set(&phys_enc->pending_kickoff_cnt, 0);
 	atomic_set(&phys_enc->pending_ctlstart_cnt, 0);
-	atomic_set(&phys_enc->pending_retire_fence_cnt, 0);
-	atomic_set(&cmd_enc->pending_rd_ptr_cnt, 0);
 	atomic_set(&cmd_enc->pending_vblank_cnt, 0);
 	init_waitqueue_head(&phys_enc->pending_kickoff_wq);
 	init_waitqueue_head(&cmd_enc->pending_vblank_wq);
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
index 62c6f5c3547a..edaad0413987 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
@@ -373,13 +373,10 @@ static void dpu_encoder_phys_vid_setup_timing_engine(
 static void dpu_encoder_phys_vid_vblank_irq(void *arg, int irq_idx)
 {
 	struct dpu_encoder_phys *phys_enc = arg;
-	struct dpu_encoder_phys_vid *vid_enc =
-			to_dpu_encoder_phys_vid(phys_enc);
 	struct dpu_hw_ctl *hw_ctl;
 	unsigned long lock_flags;
 	u32 flush_register = 0;
 	int new_cnt = -1, old_cnt = -1;
-	u32 event = 0;
 
 	if (!phys_enc)
 		return;
@@ -390,18 +387,6 @@ static void dpu_encoder_phys_vid_vblank_irq(void *arg, int irq_idx)
 
 	DPU_ATRACE_BEGIN("vblank_irq");
 
-	/* signal only for master, where there is a pending kickoff */
-	if (dpu_encoder_phys_vid_is_master(phys_enc)
-			&& atomic_add_unless(
-				&phys_enc->pending_retire_fence_cnt, -1, 0)) {
-		event = DPU_ENCODER_FRAME_EVENT_SIGNAL_RELEASE_FENCE
-				| DPU_ENCODER_FRAME_EVENT_SIGNAL_RETIRE_FENCE;
-
-		if (phys_enc->parent_ops.handle_frame_done)
-			phys_enc->parent_ops.handle_frame_done(phys_enc->parent,
-				phys_enc, event);
-	}
-
 	if (phys_enc->parent_ops.handle_vblank_virt)
 		phys_enc->parent_ops.handle_vblank_virt(phys_enc->parent,
 				phys_enc);
@@ -422,9 +407,6 @@ static void dpu_encoder_phys_vid_vblank_irq(void *arg, int irq_idx)
 				-1, 0);
 	spin_unlock_irqrestore(phys_enc->enc_spinlock, lock_flags);
 
-	DPU_EVT32_IRQ(DRMID(phys_enc->parent), vid_enc->hw_intf->idx - INTF_0,
-			old_cnt, new_cnt, flush_register, event);
-
 	/* Signal any waiting atomic commit thread */
 	wake_up_all(&phys_enc->pending_kickoff_wq);
 	DPU_ATRACE_END("vblank_irq");
@@ -1028,7 +1010,6 @@ struct dpu_encoder_phys *dpu_encoder_phys_vid_init(
 
 	atomic_set(&phys_enc->vblank_refcount, 0);
 	atomic_set(&phys_enc->pending_kickoff_cnt, 0);
-	atomic_set(&phys_enc->pending_retire_fence_cnt, 0);
 	init_waitqueue_head(&phys_enc->pending_kickoff_wq);
 	phys_enc->enable_state = DPU_ENC_DISABLED;
 
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
index 9a6fa3e1e8b4..2bc5894839c4 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
@@ -680,11 +680,8 @@ static void dpu_encoder_phys_wb_done_irq(void *arg, int irq_idx)
 	if (phys_enc->enable_state == DPU_ENC_DISABLING)
 		goto complete;
 
-	event = DPU_ENCODER_FRAME_EVENT_SIGNAL_RELEASE_FENCE
-			| DPU_ENCODER_FRAME_EVENT_SIGNAL_RETIRE_FENCE
-			| DPU_ENCODER_FRAME_EVENT_DONE;
+	event = DPU_ENCODER_FRAME_EVENT_DONE;
 
-	atomic_add_unless(&phys_enc->pending_retire_fence_cnt, -1, 0);
 	if (phys_enc->parent_ops.handle_frame_done)
 		phys_enc->parent_ops.handle_frame_done(phys_enc->parent,
 				phys_enc, event);
@@ -847,12 +844,8 @@ static int dpu_encoder_phys_wb_wait_for_commit_done(
 		} else {
 			DPU_ERROR("wb:%d kickoff timed out\n",
 					wb_enc->wb_dev->wb_idx - WB_0);
-			atomic_add_unless(
-				&phys_enc->pending_retire_fence_cnt, -1, 0);
 
-			event = DPU_ENCODER_FRAME_EVENT_SIGNAL_RELEASE_FENCE
-				| DPU_ENCODER_FRAME_EVENT_SIGNAL_RETIRE_FENCE
-				| DPU_ENCODER_FRAME_EVENT_ERROR;
+			event = DPU_ENCODER_FRAME_EVENT_ERROR;
 			if (phys_enc->parent_ops.handle_frame_done)
 				phys_enc->parent_ops.handle_frame_done(
 					phys_enc->parent, phys_enc, event);
@@ -1333,7 +1326,6 @@ struct dpu_encoder_phys *dpu_encoder_phys_wb_init(
 	phys_enc->intf_mode = INTF_MODE_WB_LINE;
 	phys_enc->intf_idx = p->intf_idx;
 	phys_enc->enc_spinlock = p->enc_spinlock;
-	atomic_set(&phys_enc->pending_retire_fence_cnt, 0);
 	INIT_LIST_HEAD(&wb_enc->irq_cb.list);
 
 	/* create internal buffer for disable logic */
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index 3d83037e8305..9d68030378a7 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -545,35 +545,6 @@ static void dpu_kms_wait_for_commit_done(struct msm_kms *kms,
 	}
 }
 
-static void dpu_kms_prepare_fence(struct msm_kms *kms,
-		struct drm_atomic_state *old_state)
-{
-	struct drm_crtc *crtc;
-	struct drm_crtc_state *old_crtc_state;
-	int i, rc;
-
-	if (!kms || !old_state || !old_state->dev || !old_state->acquire_ctx) {
-		DPU_ERROR("invalid argument(s)\n");
-		return;
-	}
-
-retry:
-	/* attempt to acquire ww mutex for connection */
-	rc = drm_modeset_lock(&old_state->dev->mode_config.connection_mutex,
-			       old_state->acquire_ctx);
-
-	if (rc == -EDEADLK) {
-		drm_modeset_backoff(old_state->acquire_ctx);
-		goto retry;
-	}
-
-	/* old_state actually contains updated crtc pointers */
-	for_each_old_crtc_in_state(old_state, crtc, old_crtc_state, i) {
-		if (crtc->state->active)
-			dpu_crtc_prepare_commit(crtc, old_crtc_state);
-	}
-}
-
 /**
  * _dpu_kms_get_displays - query for underlying display handles and cache them
  * @dpu_kms:    Pointer to dpu kms structure
@@ -1734,7 +1705,6 @@ static const struct msm_kms_funcs kms_funcs = {
 	.irq_uninstall   = dpu_irq_uninstall,
 	.irq             = dpu_irq,
 	.preclose        = dpu_kms_preclose,
-	.prepare_fence   = dpu_kms_prepare_fence,
 	.prepare_commit  = dpu_kms_prepare_commit,
 	.commit          = dpu_kms_commit,
 	.complete_commit = dpu_kms_complete_commit,
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index 8cab333df717..e92376acbcfe 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -132,8 +132,6 @@ enum msm_mdp_crtc_property {
 
 	/* range properties */
 	CRTC_PROP_INPUT_FENCE_TIMEOUT = CRTC_PROP_BLOBCOUNT,
-	CRTC_PROP_OUTPUT_FENCE,
-	CRTC_PROP_OUTPUT_FENCE_OFFSET,
 	CRTC_PROP_DIM_LAYER_V1,
 	CRTC_PROP_CORE_CLK,
 	CRTC_PROP_CORE_AB,
@@ -163,7 +161,6 @@ enum msm_mdp_conn_property {
 
 	/* range properties */
 	CONNECTOR_PROP_OUT_FB = CONNECTOR_PROP_BLOBCOUNT,
-	CONNECTOR_PROP_RETIRE_FENCE,
 	CONNECTOR_PROP_DST_X,
 	CONNECTOR_PROP_DST_Y,
 	CONNECTOR_PROP_DST_W,
-- 
Sean Paul, Software Engineer, Google / Chromium OS



More information about the Freedreno mailing list