linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/komeda: Fix FLIP_COMPLETE timestamp on CRTC enable
@ 2019-09-19 13:30 Mihail Atanassov
  2019-09-19 14:43 ` Mihail Atanassov
  2019-09-23 10:10 ` [PATCH v2] drm/komeda: Workaround for broken FLIP_COMPLETE timestamps Mihail Atanassov
  0 siblings, 2 replies; 6+ messages in thread
From: Mihail Atanassov @ 2019-09-19 13:30 UTC (permalink / raw)
  To: dri-devel
  Cc: Mihail Atanassov, nd, Daniel Vetter, Liviu Dudau,
	james qian wang (Arm Technology China),
	Liviu Dudau, Brian Starkey, David Airlie, linux-kernel

When initially turning a crtc on, drm_reset_vblank_timestamp will
set the vblank timestamp to 0 for any driver that doesn't provide
a ->get_vblank_timestamp() hook.

Unfortunately, the FLIP_COMPLETE event depends on that timestamp,
and the only way to regenerate a valid one is to have vblank
interrupts enabled and have a valid in-ISR call to
drm_crtc_handle_vblank.

Wrap the call to komeda_crtc_do_flush in ->atomic_enable() with a
drm_crtc_vblank_{get,put} pair so we can have a vblank ISR prior to
the FLIP_COMPLETE ISR (or more likely, they'll get handled in the same
ISR, which is equally valid).

Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Mihail Atanassov <mihail.atanassov@arm.com>
---
 drivers/gpu/drm/arm/display/komeda/komeda_crtc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
index f4400788ab94..87420a767bc4 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
@@ -258,7 +258,9 @@ komeda_crtc_atomic_enable(struct drm_crtc *crtc,
 {
 	komeda_crtc_prepare(to_kcrtc(crtc));
 	drm_crtc_vblank_on(crtc);
+	WARN_ON(drm_crtc_vblank_get(crtc));
 	komeda_crtc_do_flush(crtc, old);
+	drm_crtc_vblank_put(crtc);
 }
 
 static void
-- 
2.23.0


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

* Re: [PATCH] drm/komeda: Fix FLIP_COMPLETE timestamp on CRTC enable
  2019-09-19 13:30 [PATCH] drm/komeda: Fix FLIP_COMPLETE timestamp on CRTC enable Mihail Atanassov
@ 2019-09-19 14:43 ` Mihail Atanassov
  2019-09-23 10:10 ` [PATCH v2] drm/komeda: Workaround for broken FLIP_COMPLETE timestamps Mihail Atanassov
  1 sibling, 0 replies; 6+ messages in thread
From: Mihail Atanassov @ 2019-09-19 14:43 UTC (permalink / raw)
  To: dri-devel
  Cc: nd, Daniel Vetter, Liviu Dudau,
	james qian wang (Arm Technology China),
	Brian Starkey, David Airlie, linux-kernel

On Thursday, 19 September 2019 14:30:02 BST Mihail Atanassov wrote:
> When initially turning a crtc on, drm_reset_vblank_timestamp will
> set the vblank timestamp to 0 for any driver that doesn't provide
> a ->get_vblank_timestamp() hook.
> 
> Unfortunately, the FLIP_COMPLETE event depends on that timestamp,
> and the only way to regenerate a valid one is to have vblank
> interrupts enabled and have a valid in-ISR call to
> drm_crtc_handle_vblank.
> 
> Wrap the call to komeda_crtc_do_flush in ->atomic_enable() with a
> drm_crtc_vblank_{get,put} pair so we can have a vblank ISR prior to
> the FLIP_COMPLETE ISR (or more likely, they'll get handled in the same
> ISR, which is equally valid).
> 
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Liviu Dudau <Liviu.Dudau@arm.com>
> Signed-off-by: Mihail Atanassov <mihail.atanassov@arm.com>
> ---
>  drivers/gpu/drm/arm/display/komeda/komeda_crtc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> index f4400788ab94..87420a767bc4 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> @@ -258,7 +258,9 @@ komeda_crtc_atomic_enable(struct drm_crtc *crtc,
>  {
>  	komeda_crtc_prepare(to_kcrtc(crtc));
>  	drm_crtc_vblank_on(crtc);
> +	WARN_ON(drm_crtc_vblank_get(crtc));
>  	komeda_crtc_do_flush(crtc, old);
> +	drm_crtc_vblank_put(crtc);
>  }
>  
>  static void
> 

Please ignore, this doesn't work (page flips after 5 seconds don't get
an updated timestamp because of the delayed vsync disable). I'll push
a v2 soon where vsync on/off tracks crtc enable/disable.

-- 
Mihail




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

* [PATCH v2] drm/komeda: Workaround for broken FLIP_COMPLETE timestamps
  2019-09-19 13:30 [PATCH] drm/komeda: Fix FLIP_COMPLETE timestamp on CRTC enable Mihail Atanassov
  2019-09-19 14:43 ` Mihail Atanassov
@ 2019-09-23 10:10 ` Mihail Atanassov
  2019-09-29  6:18   ` [v2] " james qian wang (Arm Technology China)
  2019-10-01 14:21   ` [PATCH v2 RESEND] " Mihail Atanassov
  1 sibling, 2 replies; 6+ messages in thread
From: Mihail Atanassov @ 2019-09-23 10:10 UTC (permalink / raw)
  To: dri-devel
  Cc: Mihail Atanassov, nd, Maarten Lankhorst, Maxime Ripard,
	Sean Paul, Daniel Vetter, Liviu Dudau,
	james qian wang (Arm Technology China),
	Liviu Dudau, Brian Starkey, David Airlie, linux-kernel

When initially turning a crtc on, drm_reset_vblank_timestamp will
set the vblank timestamp to 0 for any driver that doesn't provide
a ->get_vblank_timestamp() hook.

Unfortunately, the FLIP_COMPLETE event depends on that timestamp,
and the only way to regenerate a valid one is to have vblank
interrupts enabled and have a valid in-ISR call to
drm_crtc_handle_vblank.

Additionally, if the user doesn't request vblanks but _does_ request
FLIP_COMPLETE events, we still don't have a good timestamp: it'll be the
same stamp as the last vblank one.

Work around the issue by always enabling vblanks when the CRTC is on.
Reducing the amount of time that PL0 has to be unmasked would be nice to
fix at a later time.

Changes since v1 [https://patchwork.freedesktop.org/patch/331727/]:
 - moved drm_crtc_vblank_put call to the ->atomic_disable() hook

Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Mihail Atanassov <mihail.atanassov@arm.com>
---
 drivers/gpu/drm/arm/display/komeda/komeda_crtc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
index 34bc73ca18bc..d06679afb228 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
@@ -489,6 +489,7 @@ komeda_crtc_atomic_enable(struct drm_crtc *crtc,
 	pm_runtime_get_sync(crtc->dev->dev);
 	komeda_crtc_prepare(to_kcrtc(crtc));
 	drm_crtc_vblank_on(crtc);
+	WARN_ON(drm_crtc_vblank_get(crtc));
 	komeda_crtc_do_flush(crtc, old);
 }
 
@@ -581,6 +582,7 @@ komeda_crtc_atomic_disable(struct drm_crtc *crtc,
 		komeda_crtc_flush_and_wait_for_flip_done(kcrtc, disable_done);
 	}
 
+	drm_crtc_vblank_put(crtc);
 	drm_crtc_vblank_off(crtc);
 	komeda_crtc_unprepare(kcrtc);
 	pm_runtime_put(crtc->dev->dev);
-- 
2.23.0


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

* Re: [v2] drm/komeda: Workaround for broken FLIP_COMPLETE timestamps
  2019-09-23 10:10 ` [PATCH v2] drm/komeda: Workaround for broken FLIP_COMPLETE timestamps Mihail Atanassov
@ 2019-09-29  6:18   ` james qian wang (Arm Technology China)
  2019-10-01 14:21   ` [PATCH v2 RESEND] " Mihail Atanassov
  1 sibling, 0 replies; 6+ messages in thread
From: james qian wang (Arm Technology China) @ 2019-09-29  6:18 UTC (permalink / raw)
  To: Mihail Atanassov
  Cc: dri-devel, Maxime Ripard, Liviu Dudau, linux-kernel,
	David Airlie, nd, Sean Paul

On Mon, Sep 23, 2019 at 10:10:26AM +0000, Mihail Atanassov wrote:
> When initially turning a crtc on, drm_reset_vblank_timestamp will
> set the vblank timestamp to 0 for any driver that doesn't provide
> a ->get_vblank_timestamp() hook.
> 
> Unfortunately, the FLIP_COMPLETE event depends on that timestamp,
> and the only way to regenerate a valid one is to have vblank
> interrupts enabled and have a valid in-ISR call to
> drm_crtc_handle_vblank.
> 
> Additionally, if the user doesn't request vblanks but _does_ request
> FLIP_COMPLETE events, we still don't have a good timestamp: it'll be the
> same stamp as the last vblank one.
> 
> Work around the issue by always enabling vblanks when the CRTC is on.
> Reducing the amount of time that PL0 has to be unmasked would be nice to
> fix at a later time.
> 
> Changes since v1 [https://patchwork.freedesktop.org/patch/331727/]:
>  - moved drm_crtc_vblank_put call to the ->atomic_disable() hook
> 
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Liviu Dudau <Liviu.Dudau@arm.com>
> Signed-off-by: Mihail Atanassov <mihail.atanassov@arm.com>
> ---
>  drivers/gpu/drm/arm/display/komeda/komeda_crtc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> index 34bc73ca18bc..d06679afb228 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> @@ -489,6 +489,7 @@ komeda_crtc_atomic_enable(struct drm_crtc *crtc,
>  	pm_runtime_get_sync(crtc->dev->dev);
>  	komeda_crtc_prepare(to_kcrtc(crtc));
>  	drm_crtc_vblank_on(crtc);
> +	WARN_ON(drm_crtc_vblank_get(crtc));
>  	komeda_crtc_do_flush(crtc, old);
>  }
>  
> @@ -581,6 +582,7 @@ komeda_crtc_atomic_disable(struct drm_crtc *crtc,
>  		komeda_crtc_flush_and_wait_for_flip_done(kcrtc, disable_done);
>  	}
>  
> +	drm_crtc_vblank_put(crtc);
>  	drm_crtc_vblank_off(crtc);
>  	komeda_crtc_unprepare(kcrtc);
>  	pm_runtime_put(crtc->dev->dev);

Looks good to me.

Reviewed-by: James Qian Wang (Arm Technology China) <james.qian.wang@arm.com>



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

* [PATCH v2 RESEND] drm/komeda: Workaround for broken FLIP_COMPLETE timestamps
  2019-09-23 10:10 ` [PATCH v2] drm/komeda: Workaround for broken FLIP_COMPLETE timestamps Mihail Atanassov
  2019-09-29  6:18   ` [v2] " james qian wang (Arm Technology China)
@ 2019-10-01 14:21   ` Mihail Atanassov
  2019-10-01 14:42     ` Ayan Halder
  1 sibling, 1 reply; 6+ messages in thread
From: Mihail Atanassov @ 2019-10-01 14:21 UTC (permalink / raw)
  To: dri-devel
  Cc: Mihail Atanassov, nd, Daniel Vetter, Liviu Dudau,
	james qian wang (Arm Technology China),
	Liviu Dudau, Brian Starkey, David Airlie, linux-kernel

When initially turning a crtc on, drm_reset_vblank_timestamp will
set the vblank timestamp to 0 for any driver that doesn't provide
a ->get_vblank_timestamp() hook.

Unfortunately, the FLIP_COMPLETE event depends on that timestamp,
and the only way to regenerate a valid one is to have vblank
interrupts enabled and have a valid in-ISR call to
drm_crtc_handle_vblank.

Additionally, if the user doesn't request vblanks but _does_ request
FLIP_COMPLETE events, we still don't have a good timestamp: it'll be the
same stamp as the last vblank one.

Work around the issue by always enabling vblanks when the CRTC is on.
Reducing the amount of time that PL0 has to be unmasked would be nice to
fix at a later time.

Changes since v1 [https://patchwork.freedesktop.org/patch/331727/]:
 - moved drm_crtc_vblank_put call to the ->atomic_disable() hook

Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Mihail Atanassov <mihail.atanassov@arm.com>
Reviewed-by: James Qian Wang (Arm Technology China) <james.qian.wang@arm.com>
---
 drivers/gpu/drm/arm/display/komeda/komeda_crtc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
index 9ca5dbfd0723..75263d8cd0bd 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
@@ -249,6 +249,7 @@ komeda_crtc_atomic_enable(struct drm_crtc *crtc,
 {
 	komeda_crtc_prepare(to_kcrtc(crtc));
 	drm_crtc_vblank_on(crtc);
+	WARN_ON(drm_crtc_vblank_get(crtc));
 	komeda_crtc_do_flush(crtc, old);
 }
 
@@ -341,6 +342,7 @@ komeda_crtc_atomic_disable(struct drm_crtc *crtc,
 		komeda_crtc_flush_and_wait_for_flip_done(kcrtc, disable_done);
 	}
 
+	drm_crtc_vblank_put(crtc);
 	drm_crtc_vblank_off(crtc);
 	komeda_crtc_unprepare(kcrtc);
 }
-- 
2.23.0


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

* Re: [PATCH v2 RESEND] drm/komeda: Workaround for broken FLIP_COMPLETE timestamps
  2019-10-01 14:21   ` [PATCH v2 RESEND] " Mihail Atanassov
@ 2019-10-01 14:42     ` Ayan Halder
  0 siblings, 0 replies; 6+ messages in thread
From: Ayan Halder @ 2019-10-01 14:42 UTC (permalink / raw)
  To: Mihail Atanassov
  Cc: dri-devel, David Airlie, Liviu Dudau, linux-kernel,
	james qian wang (Arm Technology China),
	nd

On Tue, Oct 01, 2019 at 02:21:40PM +0000, Mihail Atanassov wrote:
> When initially turning a crtc on, drm_reset_vblank_timestamp will
> set the vblank timestamp to 0 for any driver that doesn't provide
> a ->get_vblank_timestamp() hook.
> 
> Unfortunately, the FLIP_COMPLETE event depends on that timestamp,
> and the only way to regenerate a valid one is to have vblank
> interrupts enabled and have a valid in-ISR call to
> drm_crtc_handle_vblank.
> 
> Additionally, if the user doesn't request vblanks but _does_ request
> FLIP_COMPLETE events, we still don't have a good timestamp: it'll be the
> same stamp as the last vblank one.
> 
> Work around the issue by always enabling vblanks when the CRTC is on.
> Reducing the amount of time that PL0 has to be unmasked would be nice to
> fix at a later time.
> 
> Changes since v1 [https://patchwork.freedesktop.org/patch/331727/]:
>  - moved drm_crtc_vblank_put call to the ->atomic_disable() hook
> 
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Liviu Dudau <Liviu.Dudau@arm.com>
> Signed-off-by: Mihail Atanassov <mihail.atanassov@arm.com>
> Reviewed-by: James Qian Wang (Arm Technology China) <james.qian.wang@arm.com>

Pushed to drm-misc-next f59769c52cd7d158df53487ec2936f5592073340

Thanks,
Ayan
> ---
>  drivers/gpu/drm/arm/display/komeda/komeda_crtc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> index 9ca5dbfd0723..75263d8cd0bd 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> @@ -249,6 +249,7 @@ komeda_crtc_atomic_enable(struct drm_crtc *crtc,
>  {
>  	komeda_crtc_prepare(to_kcrtc(crtc));
>  	drm_crtc_vblank_on(crtc);
> +	WARN_ON(drm_crtc_vblank_get(crtc));
>  	komeda_crtc_do_flush(crtc, old);
>  }
>  
> @@ -341,6 +342,7 @@ komeda_crtc_atomic_disable(struct drm_crtc *crtc,
>  		komeda_crtc_flush_and_wait_for_flip_done(kcrtc, disable_done);
>  	}
>  
> +	drm_crtc_vblank_put(crtc);
>  	drm_crtc_vblank_off(crtc);
>  	komeda_crtc_unprepare(kcrtc);
>  }
> -- 
> 2.23.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2019-10-01 14:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-19 13:30 [PATCH] drm/komeda: Fix FLIP_COMPLETE timestamp on CRTC enable Mihail Atanassov
2019-09-19 14:43 ` Mihail Atanassov
2019-09-23 10:10 ` [PATCH v2] drm/komeda: Workaround for broken FLIP_COMPLETE timestamps Mihail Atanassov
2019-09-29  6:18   ` [v2] " james qian wang (Arm Technology China)
2019-10-01 14:21   ` [PATCH v2 RESEND] " Mihail Atanassov
2019-10-01 14:42     ` Ayan Halder

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).