drm/msm/sde: check for missed irqs in command encoder

Modify the way that the waiting for previous kickoffs is handled
for the command encoder case. Instead of doing waiting in the
virtual encoder, do the waiting in the command encoder directly.
That way we can check whether we have missed the IRQ. Also
allows waiting for idle before disabling the encoder.

Change-Id: I6cdb9c961a0ffd8e9ea2aaf1ad9686757edd7142
Signed-off-by: Lloyd Atkinson <latkinso@codeaurora.org>
diff --git a/drivers/gpu/drm/msm/sde/sde_encoder_phys_wb.c b/drivers/gpu/drm/msm/sde/sde_encoder_phys_wb.c
index 970969b..65524ea 100644
--- a/drivers/gpu/drm/msm/sde/sde_encoder_phys_wb.c
+++ b/drivers/gpu/drm/msm/sde/sde_encoder_phys_wb.c
@@ -13,8 +13,6 @@
  */
 
 #define pr_fmt(fmt)	"[drm:%s:%d] " fmt, __func__, __LINE__
-
-#include <linux/jiffies.h>
 #include <linux/debugfs.h>
 
 #include "sde_encoder_phys.h"
@@ -25,9 +23,6 @@
 #include "sde_wb.h"
 #include "sde_vbif.h"
 
-/* wait for at most 2 vsync for lowest refresh rate (24hz) */
-#define WAIT_TIMEOUT_MSEC			84
-
 #define to_sde_encoder_phys_wb(x) \
 	container_of(x, struct sde_encoder_phys_wb, base)
 
@@ -679,7 +674,7 @@
 	SDE_EVT32(DRMID(phys_enc->parent), WBID(wb_enc), wb_enc->frame_count);
 
 	ret = wait_for_completion_timeout(&wb_enc->wbdone_complete,
-			msecs_to_jiffies(wb_enc->wbdone_timeout));
+			KICKOFF_TIMEOUT_JIFFIES);
 
 	if (!ret) {
 		SDE_EVT32(DRMID(phys_enc->parent), WBID(wb_enc),
@@ -730,11 +725,9 @@
 /**
  * sde_encoder_phys_wb_prepare_for_kickoff - pre-kickoff processing
  * @phys_enc:	Pointer to physical encoder
- * @need_to_wait:	 Wait for next submission
  */
 static void sde_encoder_phys_wb_prepare_for_kickoff(
-		struct sde_encoder_phys *phys_enc,
-		bool *need_to_wait)
+		struct sde_encoder_phys *phys_enc)
 {
 	struct sde_encoder_phys_wb *wb_enc = to_sde_encoder_phys_wb(phys_enc);
 	int ret;
@@ -742,8 +735,6 @@
 	SDE_DEBUG("[wb:%d,%u]\n", wb_enc->hw_wb->idx - WB_0,
 			wb_enc->kickoff_count);
 
-	*need_to_wait = false;
-
 	reinit_completion(&wb_enc->wbdone_complete);
 
 	ret = sde_encoder_phys_wb_register_irq(phys_enc);
@@ -762,8 +753,7 @@
 	/* vote for iommu/clk/bus */
 	wb_enc->start_time = ktime_get();
 
-	SDE_EVT32(DRMID(phys_enc->parent), WBID(wb_enc), *need_to_wait,
-			wb_enc->kickoff_count);
+	SDE_EVT32(DRMID(phys_enc->parent), WBID(wb_enc), wb_enc->kickoff_count);
 }
 
 /**
@@ -1013,7 +1003,7 @@
 		goto fail_alloc;
 	}
 	wb_enc->irq_idx = -EINVAL;
-	wb_enc->wbdone_timeout = WAIT_TIMEOUT_MSEC;
+	wb_enc->wbdone_timeout = KICKOFF_TIMEOUT_MS;
 	init_completion(&wb_enc->wbdone_complete);
 
 	phys_enc = &wb_enc->base;