linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/msm: Read frame_count and line_count even when disabled.
@ 2021-08-11 18:08 Mark Yacoub
  2021-08-11 18:43 ` Rob Clark
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Yacoub @ 2021-08-11 18:08 UTC (permalink / raw)
  To: seanpaul, abhinavk, robdclark, linux-arm-msm; +Cc: Mark Yacoub, Mark Yacoub

From: Mark Yacoub <markyacoub@google.com>

[why]
Reading frame count register used to get the vblank counter, which calls
dpu_encoder_phys to get the frame count. Even when it's disabled, the
vblank counter (through frame count) should return a valid value for the
count. An invalid value of 0, when compared to vblank->last (in
drm_vblank.c::drm_update_vblank_count()) returns an invalid number that
throws off the vblank counter for the lifetime of the process.

Rationale:
In drm_vblank.c::drm_update_vblank_count(), the new diff is calculated
through:
diff = (cur_vblank - vblank->last) & max_vblank_count;
cur_vblank comes from: cur_vblank = __get_vblank_counter(dev, pipe);
When the value is 0, diff results in a negative number (a very large
number as it's unsigned), which inflates the vblank count when the diff
is added to the current vblank->count.

[How]
Read frame_count register whether interface timing engine is enabled or
not.

Fixes: IGT:kms_flip::modeset-vs-vblank-race-interruptible
Tested on ChromeOS Trogdor(msm)

Signed-off-by: Mark Yacoub <markyacoub@chromium.org>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c | 9 ++-------
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h | 2 +-
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c
index 116e2b5b1a90f..c436d901629f3 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c
@@ -266,13 +266,8 @@ static void dpu_hw_intf_get_status(
 
 	s->is_en = DPU_REG_READ(c, INTF_TIMING_ENGINE_EN);
 	s->is_prog_fetch_en = !!(DPU_REG_READ(c, INTF_CONFIG) & BIT(31));
-	if (s->is_en) {
-		s->frame_count = DPU_REG_READ(c, INTF_FRAME_COUNT);
-		s->line_count = DPU_REG_READ(c, INTF_LINE_COUNT);
-	} else {
-		s->line_count = 0;
-		s->frame_count = 0;
-	}
+	s->frame_count = DPU_REG_READ(c, INTF_FRAME_COUNT);
+	s->line_count = DPU_REG_READ(c, INTF_LINE_COUNT);
 }
 
 static u32 dpu_hw_intf_get_line_count(struct dpu_hw_intf *intf)
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h
index 3568be80dab51..877ff48bfef04 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h
@@ -41,7 +41,7 @@ struct intf_prog_fetch {
 struct intf_status {
 	u8 is_en;		/* interface timing engine is enabled or not */
 	u8 is_prog_fetch_en;	/* interface prog fetch counter is enabled or not */
-	u32 frame_count;	/* frame count since timing engine enabled */
+	u32 frame_count; /* frame count since timing engine first enabled */
 	u32 line_count;		/* current line count including blanking */
 };
 
-- 
2.33.0.rc1.237.g0d66db33f3-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-08-12 20:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-11 18:08 [PATCH] drm/msm: Read frame_count and line_count even when disabled Mark Yacoub
2021-08-11 18:43 ` Rob Clark
2021-08-11 23:11   ` [Freedreno] " abhinavk
2021-08-11 23:28     ` Rob Clark
2021-08-11 23:36       ` abhinavk
2021-08-12 20:16         ` Mark Yacoub

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).