Skip to contentSkip to conversation

drm/imx: correct order of crtc disable

PATCH Superseded Robert Beckett 3 participants 10 messages Jun 18, 2019 – Jun 21, 2019

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/imx: correct order of crtc disable

Notify drm core before sending pending events during crtc disable. This fixes the first event after disable having an old stale timestamp by having drm_crtc_vblank_off update the timestamp to now.

This was seen while debugging weston log message:
Warning: computed repaint delay is insane: -8212 msec

---
 drivers/gpu/drm/imx/ipuv3-crtc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/imx/ipuv3-crtc.c +3 -3
index 9cc1d678674f..c436a28d50e4 100644
@@ -91,14 +91,14 @@ static void ipu_crtc_atomic_disable(struct drm_crtc *crtc,
 	ipu_dc_disable(ipu);
 	ipu_prg_disable(ipu);
 
+	drm_crtc_vblank_off(crtc);
+
 	spin_lock_irq(&crtc->dev->event_lock);
-	if (crtc->state->event) {
+	if (crtc->state->event && !crtc->state->active) {
 		drm_crtc_send_vblank_event(crtc, crtc->state->event);
 		crtc->state->event = NULL;
 	}
 	spin_unlock_irq(&crtc->dev->event_lock);
-
-	drm_crtc_vblank_off(crtc);
 }
 
 static void imx_drm_crtc_reset(struct drm_crtc *crtc)
Signature · 6 lines
2.18.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw

Hi Robert,

thank you for the patch.

Quoted 7 lines · Robert Beckett

Notify drm core before sending pending events during crtc disable. This fixes the first event after disable having an old stale timestamp by having drm_crtc_vblank_off update the timestamp to now.

This was seen while debugging weston log message:
Warning: computed repaint delay is insane: -8212 msec

Would you say this

Fixes a474478642d5 ("drm/imx: fix crtc vblank state regression")

?

Quoted 10 lines
---
 drivers/gpu/drm/imx/ipuv3-crtc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/imx/ipuv3-crtc.c +0 -0
index 9cc1d678674f..c436a28d50e4 100644

drivers/gpu/drm/imx/ipuv3-crtc.c static void ipu_crtc_atomic_disable(struct drm_crtc *crtc, · line 95

Quoted 5 lines
drivers/gpu/drm/imx/ipuv3-crtc.c +2 -0
@@ -91,14 +91,14 @@ static void ipu_crtc_atomic_disable(struct drm_crtc *crtc,
 	ipu_dc_disable(ipu);
 	ipu_prg_disable(ipu);
 
+	drm_crtc_vblank_off(crtc);
+

This is explained in the commit message and aligns with the drm_crtc_state @event documentation.

drivers/gpu/drm/imx/ipuv3-crtc.c static void ipu_crtc_atomic_disable(struct drm_crtc *crtc, · line 97

Quoted 3 lines
drivers/gpu/drm/imx/ipuv3-crtc.c +1 -1
 	spin_lock_irq(&crtc->dev->event_lock);
-	if (crtc->state->event) {
+	if (crtc->state->event && !crtc->state->active) {

This is not mentioned though.

If the pending event is not sent here, I assume it will be picked up by .atomic_flush and will then be sent after the first EOF interrupt after the modeset is complete. Can you explain this in the commit message?

With that,

drivers/gpu/drm/imx/ipuv3-crtc.c static void ipu_crtc_atomic_disable(struct drm_crtc *crtc, · line 104

Quoted 9 lines
drivers/gpu/drm/imx/ipuv3-crtc.c +0 -2
 		drm_crtc_send_vblank_event(crtc, crtc->state->event);
 		crtc->state->event = NULL;
 	}
 	spin_unlock_irq(&crtc->dev->event_lock);
-
-	drm_crtc_vblank_off(crtc);
 }
 
 static void imx_drm_crtc_reset(struct drm_crtc *crtc)

regards
Philipp
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 31 lines · Philipp Zabel

Hi Robert,

thank you for the patch.

Quoted 7 lines · Robert Beckett

Notify drm core before sending pending events during crtc disable. This fixes the first event after disable having an old stale timestamp by having drm_crtc_vblank_off update the timestamp to now.

This was seen while debugging weston log message:
Warning: computed repaint delay is insane: -8212 msec

Would you say this

Fixes a474478642d5 ("drm/imx: fix crtc vblank state regression")

?

Quoted 13 lines
---
 drivers/gpu/drm/imx/ipuv3-crtc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/imx/ipuv3-crtc.c +0 -0
index 9cc1d678674f..c436a28d50e4 100644
@@ -91,14 +91,14 @@ static void ipu_crtc_atomic_disable(struct drm_crtc *crtc,
      ipu_dc_disable(ipu);
      ipu_prg_disable(ipu);
 
Quoted 5 lines

drivers/gpu/drm/imx/ipuv3-crtc.c static void ipu_crtc_atomic_disable(struct drm_crtc *crtc, · line 95

Quoted 2 lines
drivers/gpu/drm/imx/ipuv3-crtc.c +2 -0
+     drm_crtc_vblank_off(crtc);
+

This is explained in the commit message and aligns with the drm_crtc_state @event documentation.

This part here looks fishy. The drm_vblank.c code is supposed to do the right thing, no matter where or when you ask it to generate an event. It definitely shouldn't generate a timestamp that's a few seconds too early. Bunch of options:
- there's a bug in drm_vblank.c and it's mixing up something and generating a totally bogus value.
- there's a lie in your imx vblank code, which trips the drm_vblank.c counter interpolation and results in a totally bogus value.

drm_vblank.c assumes that if you do claim to have a hw counter and generate timestamps, that those are perfectly accurate. It only falls back to guestimating using the system timer if that's not present.

Either way, this very much smells like papering over a bug if this change indeed fixes your wrong vblank timestamps.

Quoted 9 lines

drivers/gpu/drm/imx/ipuv3-crtc.c static void ipu_crtc_atomic_disable(struct drm_crtc *crtc, · line 97

Quoted 3 lines
drivers/gpu/drm/imx/ipuv3-crtc.c +1 -1
      spin_lock_irq(&crtc->dev->event_lock);
-     if (crtc->state->event) {
+     if (crtc->state->event && !crtc->state->active) {

This is not mentioned though.

If the pending event is not sent here, I assume it will be picked up by .atomic_flush and will then be sent after the first EOF interrupt after the modeset is complete. Can you explain this in the commit message?

Yeah looks correct (you only want to generate the event here when the crtc stays off), if it gets re-enabled the event should only be generated later on once that's all finished. But separate bugfix. -Daniel

Quoted 20 lines

With that,

drivers/gpu/drm/imx/ipuv3-crtc.c static void ipu_crtc_atomic_disable(struct drm_crtc *crtc, · line 104

Quoted 9 lines
drivers/gpu/drm/imx/ipuv3-crtc.c +0 -2
              drm_crtc_send_vblank_event(crtc, crtc->state->event);
              crtc->state->event = NULL;
      }
      spin_unlock_irq(&crtc->dev->event_lock);
-
-     drm_crtc_vblank_off(crtc);
 }
 
 static void imx_drm_crtc_reset(struct drm_crtc *crtc)

regards
Philipp
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw
Quoted 52 lines · Daniel Vetter
Quoted 35 lines · Philipp Zabel

Hi Robert,

thank you for the patch.

Quoted 9 lines · Robert Beckett

Notify drm core before sending pending events during crtc disable.
This fixes the first event after disable having an old stale timestamp
by having drm_crtc_vblank_off update the timestamp to now.

This was seen while debugging weston log message:
Warning: computed repaint delay is insane: -8212 msec

Would you say this

Fixes a474478642d5 ("drm/imx: fix crtc vblank state regression")

?

Quoted 15 lines
---
 drivers/gpu/drm/imx/ipuv3-crtc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/imx/ipuv3-crtc.c +0 -0
index 9cc1d678674f..c436a28d50e4 100644
@@ -91,14 +91,14 @@ static void ipu_crtc_atomic_disable(struct
 drm_crtc *crtc,
      ipu_dc_disable(ipu);
      ipu_prg_disable(ipu);
 
Quoted 5 lines

drivers/gpu/drm/imx/ipuv3-crtc.c static void ipu_crtc_atomic_disable(struct drm_crtc *crtc, · line 95

Quoted 2 lines
drivers/gpu/drm/imx/ipuv3-crtc.c +2 -0
+     drm_crtc_vblank_off(crtc);
+

This is explained in the commit message and aligns with the drm_crtc_state @event documentation.

This part here looks fishy. The drm_vblank.c code is supposed to do the right thing, no matter where or when you ask it to generate an event. It definitely shouldn't generate a timestamp that's a few seconds too early. Bunch of options:
- there's a bug in drm_vblank.c and it's mixing up something and generating a totally bogus value.
- there's a lie in your imx vblank code, which trips the drm_vblank.c counter interpolation and results in a totally bogus value.

Quoted 7 lines

drm_vblank.c assumes that if you do claim to have a hw counter and generate timestamps, that those are perfectly accurate. It only falls back to guestimating using the system timer if that's not present.

Either way, this very much smells like papering over a bug if this change indeed fixes your wrong vblank timestamps.

A quick explaination of where the dodgy timestamp came from:
1. driver starts up
2. fbcon comes along and restores fbdev, enabling vblank
3. vblank_disable_fn fires via timer disabling vblank, keeping vblank seq number and time set at current value
(some time later)
4. weston starts and does a modeset
5. atomic commit disables crtc while it does the modeset
6. ipu_crtc_atomic_disable sends vblank with old seq number and time

It turns out the actual fix for the old vblank is the next change, which stops it being sent at all during the crtc disable as it is is still active, it would then go through drm_crtc_vblank_off, reseting the timestamp, and get delivered during the vblank enable as part of the atomic commit.

So, in theory, we could just have the following change to fix the specific issue of a stale timestamp.

However, given the documentation for the event in
include/drm/drm_crtc.h:

* - The event is for a CRTC which is being disabled through
this
* atomic commit. In that case the event can be send out any
time
* after the hardware has stopped scanning out the current
* framebuffers. It should contain the timestamp and counter
for the
* last vblank before the display pipeline was shut off. The
simplest
* way to achieve that is calling
drm_crtc_send_vblank_event()
* somewhen after drm_crtc_vblank_off() has been called.

This still seems like a sensible change for when the crtc is being disabled.

Quoted 14 lines
Quoted 5 lines

drivers/gpu/drm/imx/ipuv3-crtc.c static void ipu_crtc_atomic_disable(struct drm_crtc *crtc, · line 97

Quoted 4 lines
drivers/gpu/drm/imx/ipuv3-crtc.c +1 -1
      spin_lock_irq(&crtc->dev->event_lock);
-     if (crtc->state->event)
 {
+     if (crtc->state->event && !crtc->state->active) {
Quoted 8 lines

This is not mentioned though.

If the pending event is not sent here, I assume it will be picked up by
.atomic_flush and will then be sent after the first EOF interrupt after
the modeset is complete. Can you explain this in the commit message?

Quoted 5 lines

Yeah looks correct (you only want to generate the event here when the crtc stays off), if it gets re-enabled the event should only be generated later on once that's all finished. But separate bugfix. -Daniel

It looks like this is actually the fix needed to avoid the bogus timestamp.

I can split this patch up in to 2 commits if desired?

Quoted 13 lines
Quoted 13 lines

With that,

Quoted 9 lines
drivers/gpu/drm/imx/ipuv3-crtc.c +0 -2
              drm_crtc_send_vblank_event(crtc, crtc->state-
 >event);
              crtc->state->event = NULL;
      }
      spin_unlock_irq(&crtc->dev->event_lock);
-
-     drm_crtc_vblank_off(crtc);

}

Quoted 11 lines
Quoted 8 lines
Quoted 1 line

static void imx_drm_crtc_reset(struct drm_crtc *crtc)

regards
Philipp
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw

Hi Robert, Daniel,

Quoted 53 lines · Robert Beckett
Quoted 52 lines · Daniel Vetter
Quoted 35 lines · Philipp Zabel

Hi Robert,

thank you for the patch.

Quoted 9 lines · Robert Beckett

Notify drm core before sending pending events during crtc disable.
This fixes the first event after disable having an old stale timestamp
by having drm_crtc_vblank_off update the timestamp to now.

This was seen while debugging weston log message:
Warning: computed repaint delay is insane: -8212 msec

Would you say this

Fixes a474478642d5 ("drm/imx: fix crtc vblank state regression")

?

Quoted 15 lines
---
 drivers/gpu/drm/imx/ipuv3-crtc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/imx/ipuv3-crtc.c +0 -0
index 9cc1d678674f..c436a28d50e4 100644
@@ -91,14 +91,14 @@ static void ipu_crtc_atomic_disable(struct
 drm_crtc *crtc,
      ipu_dc_disable(ipu);
      ipu_prg_disable(ipu);
 
Quoted 5 lines

drivers/gpu/drm/imx/ipuv3-crtc.c static void ipu_crtc_atomic_disable(struct drm_crtc *crtc, · line 95

Quoted 2 lines
drivers/gpu/drm/imx/ipuv3-crtc.c +2 -0
+     drm_crtc_vblank_off(crtc);
+

This is explained in the commit message and aligns with the drm_crtc_state @event documentation.

This part here looks fishy. The drm_vblank.c code is supposed to do the right thing, no matter where or when you ask it to generate an event. It definitely shouldn't generate a timestamp that's a few seconds too early. Bunch of options:
- there's a bug in drm_vblank.c and it's mixing up something and generating a totally bogus value.
- there's a lie in your imx vblank code, which trips the drm_vblank.c counter interpolation and results in a totally bogus value.

Quoted 6 lines
Quoted 6 lines

drm_vblank.c assumes that if you do claim to have a hw counter and generate timestamps, that those are perfectly accurate. It only falls back to guestimating using the system timer if that's not present.

Either way, this very much smells like papering over a bug if this change indeed fixes your wrong vblank timestamps.

Thank you for chiming in, I can confirm that just moving the drm_crtc_vblank_off around does not change anything. I'll drop this patch and wait for v3.

Quoted 9 lines

A quick explaination of where the dodgy timestamp came from:
1. driver starts up
2. fbcon comes along and restores fbdev, enabling vblank
3. vblank_disable_fn fires via timer disabling vblank, keeping vblank seq number and time set at current value
(some time later)
4. weston starts and does a modeset
5. atomic commit disables crtc while it does the modeset
6. ipu_crtc_atomic_disable sends vblank with old seq number and time

It would be great to have this in the commit message for context.

Quoted 5 lines

It turns out the actual fix for the old vblank is the next change, which stops it being sent at all during the crtc disable as it is is still active, it would then go through drm_crtc_vblank_off, reseting the timestamp, and get delivered during the vblank enable as part of the atomic commit.

Which means this patch isn't "Fixes: a474478642d5" after all. The offending code has been there since commit 5f2f911578fb ("drm/imx:
atomic phase 3 step 1: Use atomic configuration").

Quoted 14 lines

So, in theory, we could just have the following change to fix the specific issue of a stale timestamp.

However, given the documentation for the event in
include/drm/drm_crtc.h:

* - The event is for a CRTC which is being disabled through this
* atomic commit. In that case the event can be send out any time
* after the hardware has stopped scanning out the current
* framebuffers. It should contain the timestamp and counter for the
* last vblank before the display pipeline was shut off. The simplest
* way to achieve that is calling drm_crtc_send_vblank_event()
* somewhen after drm_crtc_vblank_off() has been called.

Quoted 2 lines

This still seems like a sensible change for when the crtc is being disabled.

This is what had me confused as well. It doesn't really say, but it seems to imply that drm_crtc_send_vblank_event must only be sent after drm_crtc_vblank_off.
If this is not a hard requirement, maybe this could be mentioned here?

Quoted 20 lines
Quoted 14 lines
Quoted 5 lines

drivers/gpu/drm/imx/ipuv3-crtc.c static void ipu_crtc_atomic_disable(struct drm_crtc *crtc, · line 97

Quoted 4 lines
drivers/gpu/drm/imx/ipuv3-crtc.c +1 -1
      spin_lock_irq(&crtc->dev->event_lock);
-     if (crtc->state->event)
 {
+     if (crtc->state->event && !crtc->state->active) {
Quoted 8 lines

This is not mentioned though.

If the pending event is not sent here, I assume it will be picked up by
.atomic_flush and will then be sent after the first EOF interrupt after
the modeset is complete. Can you explain this in the commit message?

Quoted 5 lines

Yeah looks correct (you only want to generate the event here when the crtc stays off), if it gets re-enabled the event should only be generated later on once that's all finished. But separate bugfix. -Daniel

Quoted 4 lines

It looks like this is actually the fix needed to avoid the bogus timestamp.

I can split this patch up in to 2 commits if desired?

Yes, please. The !state->active fix is stable material, moving drm_crtc_vblank_off around apparently not so much.

regards
Philipp
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#5 lore raw
In reply to Robert Beckett
Quoted 71 lines · Robert Beckett
Quoted 52 lines · Daniel Vetter
Quoted 35 lines · Philipp Zabel

Hi Robert,

thank you for the patch.

Quoted 9 lines · Robert Beckett

Notify drm core before sending pending events during crtc disable.
This fixes the first event after disable having an old stale timestamp
by having drm_crtc_vblank_off update the timestamp to now.

This was seen while debugging weston log message:
Warning: computed repaint delay is insane: -8212 msec

Would you say this

Fixes a474478642d5 ("drm/imx: fix crtc vblank state regression")

?

Quoted 15 lines
---
 drivers/gpu/drm/imx/ipuv3-crtc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/imx/ipuv3-crtc.c +0 -0
index 9cc1d678674f..c436a28d50e4 100644
@@ -91,14 +91,14 @@ static void ipu_crtc_atomic_disable(struct
 drm_crtc *crtc,
      ipu_dc_disable(ipu);
      ipu_prg_disable(ipu);
 
Quoted 5 lines

drivers/gpu/drm/imx/ipuv3-crtc.c static void ipu_crtc_atomic_disable(struct drm_crtc *crtc, · line 95

Quoted 2 lines
drivers/gpu/drm/imx/ipuv3-crtc.c +2 -0
+     drm_crtc_vblank_off(crtc);
+

This is explained in the commit message and aligns with the drm_crtc_state @event documentation.

This part here looks fishy. The drm_vblank.c code is supposed to do the right thing, no matter where or when you ask it to generate an event. It definitely shouldn't generate a timestamp that's a few seconds too early. Bunch of options:
- there's a bug in drm_vblank.c and it's mixing up something and generating a totally bogus value.
- there's a lie in your imx vblank code, which trips the drm_vblank.c counter interpolation and results in a totally bogus value.

Quoted 7 lines

drm_vblank.c assumes that if you do claim to have a hw counter and generate timestamps, that those are perfectly accurate. It only falls back to guestimating using the system timer if that's not present.

Either way, this very much smells like papering over a bug if this change indeed fixes your wrong vblank timestamps.

A quick explaination of where the dodgy timestamp came from:
1. driver starts up
2. fbcon comes along and restores fbdev, enabling vblank
3. vblank_disable_fn fires via timer disabling vblank, keeping vblank seq number and time set at current value
(some time later)
4. weston starts and does a modeset
5. atomic commit disables crtc while it does the modeset
6. ipu_crtc_atomic_disable sends vblank with old seq number and time

Quoted 5 lines

It turns out the actual fix for the old vblank is the next change, which stops it being sent at all during the crtc disable as it is is still active, it would then go through drm_crtc_vblank_off, reseting the timestamp, and get delivered during the vblank enable as part of the atomic commit.

This shouldn't fix your vblank timestamp troubles either. It might mean that the timestamp is slightly too early (because you take it while shutting down the crtc, not while re-enabling), but not by seconds.

Quick experiment: Disable vblank disabling with drm.vblankoffdelay = 0. If that also fixes the timestamps, then I'm pretty sure you have a driver bug somewhere and lie to the vblank core code about something. -Daniel

Quoted 75 lines

So, in theory, we could just have the following change to fix the specific issue of a stale timestamp.

However, given the documentation for the event in
include/drm/drm_crtc.h:

* - The event is for a CRTC which is being disabled through
this
* atomic commit. In that case the event can be send out any
time
* after the hardware has stopped scanning out the current
* framebuffers. It should contain the timestamp and counter
for the
* last vblank before the display pipeline was shut off. The
simplest
* way to achieve that is calling
drm_crtc_send_vblank_event()
* somewhen after drm_crtc_vblank_off() has been called.

This still seems like a sensible change for when the crtc is being disabled.

Quoted 14 lines
Quoted 5 lines

drivers/gpu/drm/imx/ipuv3-crtc.c static void ipu_crtc_atomic_disable(struct drm_crtc *crtc, · line 97

Quoted 4 lines
drivers/gpu/drm/imx/ipuv3-crtc.c +1 -1
      spin_lock_irq(&crtc->dev->event_lock);
-     if (crtc->state->event)
 {
+     if (crtc->state->event && !crtc->state->active) {
Quoted 8 lines

This is not mentioned though.

If the pending event is not sent here, I assume it will be picked up by
.atomic_flush and will then be sent after the first EOF interrupt after
the modeset is complete. Can you explain this in the commit message?

Quoted 5 lines

Yeah looks correct (you only want to generate the event here when the crtc stays off), if it gets re-enabled the event should only be generated later on once that's all finished. But separate bugfix. -Daniel

It looks like this is actually the fix needed to avoid the bogus timestamp.

I can split this patch up in to 2 commits if desired?

Quoted 24 lines
Quoted 21 lines

With that,

Quoted 10 lines
drivers/gpu/drm/imx/ipuv3-crtc.c +0 -2
              drm_crtc_send_vblank_event(crtc, crtc->state-
 >event);
              crtc->state->event = NULL;
      }
      spin_unlock_irq(&crtc->dev->event_lock);
-
-     drm_crtc_vblank_off(crtc);

}

static void imx_drm_crtc_reset(struct drm_crtc *crtc)

regards
Philipp
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#6 lore raw
Quoted 97 lines · Daniel Vetter
Quoted 82 lines · Robert Beckett
Quoted 64 lines · Daniel Vetter
Quoted 37 lines · Philipp Zabel

Hi Robert,

thank you for the patch.

Quoted 9 lines · Robert Beckett

Notify drm core before sending pending events during crtc disable.
This fixes the first event after disable having an old stale timestamp
by having drm_crtc_vblank_off update the timestamp to now.

This was seen while debugging weston log message:
Warning: computed repaint delay is insane: -8212 msec

Would you say this

Fixes a474478642d5 ("drm/imx: fix crtc vblank state

regression")
?

Quoted 16 lines
---
 drivers/gpu/drm/imx/ipuv3-crtc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/imx/ipuv3-crtc.c +0 -0
index 9cc1d678674f..c436a28d50e4 100644
@@ -91,14 +91,14 @@ static void

ipu_crtc_atomic_disable(struct
drm_crtc *crtc,

      ipu_dc_disable(ipu);
      ipu_prg_disable(ipu);
Quoted 5 lines

drivers/gpu/drm/imx/ipuv3-crtc.c static void ipu_crtc_atomic_disable(struct drm_crtc *crtc, · line 95

Quoted 2 lines
drivers/gpu/drm/imx/ipuv3-crtc.c +2 -0
+     drm_crtc_vblank_off(crtc);
+

This is explained in the commit message and aligns with the drm_crtc_state @event documentation.

This part here looks fishy. The drm_vblank.c code is supposed to do
the right thing, no matter where or when you ask it to generate an
event. It definitely shouldn't generate a timestamp that's a few seconds too early. Bunch of options:
- there's a bug in drm_vblank.c and it's mixing up something and generating a totally bogus value.
- there's a lie in your imx vblank code, which trips the drm_vblank.c
counter interpolation and results in a totally bogus value.

drm_vblank.c assumes that if you do claim to have a hw counter and
generate timestamps, that those are perfectly accurate. It only falls
back to guestimating using the system timer if that's not present.

Quoted 4 lines

Either way, this very much smells like papering over a bug if this
change indeed fixes your wrong vblank timestamps.

A quick explaination of where the dodgy timestamp came from:
1. driver starts up
2. fbcon comes along and restores fbdev, enabling vblank
3. vblank_disable_fn fires via timer disabling vblank, keeping vblank
seq number and time set at current value
(some time later)
4. weston starts and does a modeset
5. atomic commit disables crtc while it does the modeset
6. ipu_crtc_atomic_disable sends vblank with old seq number and time

Quoted 8 lines

It turns out the actual fix for the old vblank is the next change, which stops it being sent at all during the crtc disable as it is is
still active, it would then go through drm_crtc_vblank_off, reseting
the timestamp, and get delivered during the vblank enable as part of
the atomic commit.

This shouldn't fix your vblank timestamp troubles either. It might mean
that the timestamp is slightly too early (because you take it while shutting down the crtc, not while re-enabling), but not by seconds.

Quoted 7 lines

Quick experiment: Disable vblank disabling with drm.vblankoffdelay =
0. If
that also fixes the timestamps, then I'm pretty sure you have a driver bug
somewhere and lie to the vblank core code about something. -Daniel

Experiment done. The timestamp is fine, it is the timestamp of the previous vblank update. But, this would fix it because the vblank interrupt was never disabled.

The original issue was that the event got sent after vblank was disabled and before it got re-enabled during the modeset, so nothing had happened to update the timestamp and seq number.

What are you expecting to update the timestamp and seq number while the interrupt is disabled after vblank_disable_fn?

Im struggling to see what this experiment was meant to test/prove.

Quoted 74 lines
Quoted 74 lines

So, in theory, we could just have the following change to fix the specific issue of a stale timestamp.

However, given the documentation for the event in
include/drm/drm_crtc.h:

* - The event is for a CRTC which is being disabled
through
this
* atomic commit. In that case the event can be send out
any
time
* after the hardware has stopped scanning out the
current
* framebuffers. It should contain the timestamp and
counter
for the
* last vblank before the display pipeline was shut off.
The
simplest
* way to achieve that is calling
drm_crtc_send_vblank_event()
* somewhen after drm_crtc_vblank_off() has been called.

This still seems like a sensible change for when the crtc is being disabled.

Quoted 16 lines
Quoted 7 lines
Quoted 4 lines
      spin_lock_irq(&crtc->dev->event_lock);

- if (crtc->state->event)
{
+ if (crtc->state->event && !crtc->state->active) {

This is not mentioned though.

Quoted 8 lines

If the pending event is not sent here, I assume it will be picked
up by
.atomic_flush and will then be sent after the first EOF interrupt
after
the modeset is complete. Can you explain this in the commit message?

Quoted 6 lines

Yeah looks correct (you only want to generate the event here when the
crtc stays off), if it gets re-enabled the event should only be generated later on once that's all finished. But separate bugfix. -Daniel

It looks like this is actually the fix needed to avoid the bogus timestamp.

I can split this patch up in to 2 commits if desired?

Quoted 16 lines
Quoted 16 lines

With that,

Quoted 11 lines
              drm_crtc_send_vblank_event(crtc, crtc->state-
Quoted 1 line

event);

              crtc->state->event = NULL;
      }
      spin_unlock_irq(&crtc->dev->event_lock);
drivers/gpu/drm/imx/ipuv3-crtc.c +0 -2
-
-     drm_crtc_vblank_off(crtc);
 }
 
 static void imx_drm_crtc_reset(struct drm_crtc *crtc)
Quoted 11 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines

regards
Philipp
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw
Quoted 110 lines · Robert Beckett
Quoted 97 lines · Daniel Vetter
Quoted 82 lines · Robert Beckett
Quoted 64 lines · Daniel Vetter
Quoted 37 lines · Philipp Zabel

Hi Robert,

thank you for the patch.

Quoted 9 lines · Robert Beckett

Notify drm core before sending pending events during crtc disable.
This fixes the first event after disable having an old stale timestamp
by having drm_crtc_vblank_off update the timestamp to now.

This was seen while debugging weston log message:
Warning: computed repaint delay is insane: -8212 msec

Would you say this

Fixes a474478642d5 ("drm/imx: fix crtc vblank state

regression")
?

Quoted 16 lines
---
 drivers/gpu/drm/imx/ipuv3-crtc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/imx/ipuv3-crtc.c +0 -0
index 9cc1d678674f..c436a28d50e4 100644
@@ -91,14 +91,14 @@ static void

ipu_crtc_atomic_disable(struct
drm_crtc *crtc,

      ipu_dc_disable(ipu);
      ipu_prg_disable(ipu);
Quoted 5 lines

drivers/gpu/drm/imx/ipuv3-crtc.c static void ipu_crtc_atomic_disable(struct drm_crtc *crtc, · line 95

Quoted 2 lines
drivers/gpu/drm/imx/ipuv3-crtc.c +2 -0
+     drm_crtc_vblank_off(crtc);
+

This is explained in the commit message and aligns with the drm_crtc_state @event documentation.

This part here looks fishy. The drm_vblank.c code is supposed to do
the right thing, no matter where or when you ask it to generate an
event. It definitely shouldn't generate a timestamp that's a few seconds too early. Bunch of options:
- there's a bug in drm_vblank.c and it's mixing up something and generating a totally bogus value.
- there's a lie in your imx vblank code, which trips the drm_vblank.c
counter interpolation and results in a totally bogus value.

drm_vblank.c assumes that if you do claim to have a hw counter and
generate timestamps, that those are perfectly accurate. It only falls
back to guestimating using the system timer if that's not present.

Quoted 4 lines

Either way, this very much smells like papering over a bug if this
change indeed fixes your wrong vblank timestamps.

A quick explaination of where the dodgy timestamp came from:
1. driver starts up
2. fbcon comes along and restores fbdev, enabling vblank
3. vblank_disable_fn fires via timer disabling vblank, keeping vblank
seq number and time set at current value
(some time later)
4. weston starts and does a modeset
5. atomic commit disables crtc while it does the modeset
6. ipu_crtc_atomic_disable sends vblank with old seq number and time

Quoted 8 lines

It turns out the actual fix for the old vblank is the next change, which stops it being sent at all during the crtc disable as it is is
still active, it would then go through drm_crtc_vblank_off, reseting
the timestamp, and get delivered during the vblank enable as part of
the atomic commit.

This shouldn't fix your vblank timestamp troubles either. It might mean
that the timestamp is slightly too early (because you take it while shutting down the crtc, not while re-enabling), but not by seconds.

Quoted 7 lines

Quick experiment: Disable vblank disabling with drm.vblankoffdelay =
0. If
that also fixes the timestamps, then I'm pretty sure you have a driver bug
somewhere and lie to the vblank core code about something. -Daniel

Experiment done. The timestamp is fine, it is the timestamp of the previous vblank update. But, this would fix it because the vblank interrupt was never disabled.

Quoted 6 lines

The original issue was that the event got sent after vblank was disabled and before it got re-enabled during the modeset, so nothing had happened to update the timestamp and seq number.

What are you expecting to update the timestamp and seq number while the interrupt is disabled after vblank_disable_fn?

Hm maybe this indeed needs to be shuffled around a bit, since currently it's indeed not not allowed to call drm_crtc_send_vblank_event if:
- your driver has vblank support (i.e. dev->num_crtcs > 0)
- the vblank irq is off (i.e. no one called drm_crtc_vblank_get)
- from the vblank code's pov the pipe is still running (i.e. not in-between a drm_crtc_vblank_off()/on() pair)

If all of these conditions hold then drm_crtc_send_vblank_event is going to give you a garbage timestamp and and sequence number. If you call drm_crtc_vblank_get/put around it, or after vblank_off, then either of those will have rolled things forward for you.

The other option I was chasing is a get_vblank_counter driver callback which lies, but I think that's only relevant for immediate disabling support.

Anyway, thanks for sticking with me on this. Can I volunteer you to write a patch to improve the documentation of drm_crtc_send_vblank_event, plus add a WARN_ON in there that fires if the above conditions are all true? I expect imx isn't the only one that gets this wrong, would be good to close this trap for real.

Quoted 1 line

Im struggling to see what this experiment was meant to test/prove.

Worked all fine in confirming what I wanted to confirm.

Thanks, Daniel

Quoted 87 lines
Quoted 86 lines
Quoted 84 lines

So, in theory, we could just have the following change to fix the specific issue of a stale timestamp.

However, given the documentation for the event in
include/drm/drm_crtc.h:

* - The event is for a CRTC which is being disabled
through
this
* atomic commit. In that case the event can be send out
any
time
* after the hardware has stopped scanning out the
current
* framebuffers. It should contain the timestamp and
counter
for the
* last vblank before the display pipeline was shut off.
The
simplest
* way to achieve that is calling
drm_crtc_send_vblank_event()
* somewhen after drm_crtc_vblank_off() has been called.

This still seems like a sensible change for when the crtc is being disabled.

Quoted 16 lines
Quoted 7 lines
Quoted 4 lines
      spin_lock_irq(&crtc->dev->event_lock);

- if (crtc->state->event)
{
+ if (crtc->state->event && !crtc->state->active) {

This is not mentioned though.

Quoted 8 lines

If the pending event is not sent here, I assume it will be picked
up by
.atomic_flush and will then be sent after the first EOF interrupt
after
the modeset is complete. Can you explain this in the commit message?

Quoted 6 lines

Yeah looks correct (you only want to generate the event here when the
crtc stays off), if it gets re-enabled the event should only be generated later on once that's all finished. But separate bugfix. -Daniel

It looks like this is actually the fix needed to avoid the bogus timestamp.

I can split this patch up in to 2 commits if desired?

Quoted 25 lines
Quoted 22 lines

With that,

drivers/gpu/drm/imx/ipuv3-crtc.c static void ipu_crtc_atomic_disable(struct drm_crtc *crtc, · line 104

Quoted 11 lines
              drm_crtc_send_vblank_event(crtc, crtc->state-
Quoted 1 line

event);

              crtc->state->event = NULL;
      }
      spin_unlock_irq(&crtc->dev->event_lock);
drivers/gpu/drm/imx/ipuv3-crtc.c +0 -2
-
-     drm_crtc_vblank_off(crtc);
 }
 
 static void imx_drm_crtc_reset(struct drm_crtc *crtc)

regards
Philipp
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#8 lore raw
Quoted 154 lines · Daniel Vetter
Quoted 125 lines · Robert Beckett
Quoted 111 lines · Daniel Vetter
Quoted 90 lines · Robert Beckett
Quoted 72 lines · Daniel Vetter
Quoted 39 lines · Philipp Zabel

Hi Robert,

thank you for the patch.

Quoted 11 lines · Robert Beckett

Notify drm core before sending pending events during crtc disable.
This fixes the first event after disable having an old stale
timestamp
by having drm_crtc_vblank_off update the timestamp to now.

This was seen while debugging weston log message:
Warning: computed repaint delay is insane: -8212 msec

Would you say this

Fixes a474478642d5 ("drm/imx: fix crtc vblank state

regression")
?

Quoted 16 lines
---
 drivers/gpu/drm/imx/ipuv3-crtc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/imx/ipuv3-crtc.c +0 -0
index 9cc1d678674f..c436a28d50e4 100644
@@ -91,14 +91,14 @@ static void

ipu_crtc_atomic_disable(struct
drm_crtc *crtc,

      ipu_dc_disable(ipu);
      ipu_prg_disable(ipu);
Quoted 5 lines

drivers/gpu/drm/imx/ipuv3-crtc.c

Quoted 2 lines
drivers/gpu/drm/imx/ipuv3-crtc.c +2 -0
+     drm_crtc_vblank_off(crtc);
+

This is explained in the commit message and aligns with the drm_crtc_state @event documentation.

This part here looks fishy. The drm_vblank.c code is supposed to
do
the right thing, no matter where or when you ask it to generate
an
event. It definitely shouldn't generate a timestamp that's a few
seconds too early. Bunch of options:
- there's a bug in drm_vblank.c and it's mixing up something and
generating a totally bogus value.
- there's a lie in your imx vblank code, which trips the drm_vblank.c
counter interpolation and results in a totally bogus value.

drm_vblank.c assumes that if you do claim to have a hw counter
and
generate timestamps, that those are perfectly accurate. It only
falls
back to guestimating using the system timer if that's not present.

Quoted 4 lines

Either way, this very much smells like papering over a bug if this
change indeed fixes your wrong vblank timestamps.

A quick explaination of where the dodgy timestamp came from:
1. driver starts up
2. fbcon comes along and restores fbdev, enabling vblank
3. vblank_disable_fn fires via timer disabling vblank, keeping vblank
seq number and time set at current value
(some time later)
4. weston starts and does a modeset
5. atomic commit disables crtc while it does the modeset
6. ipu_crtc_atomic_disable sends vblank with old seq number and time

Quoted 11 lines

It turns out the actual fix for the old vblank is the next change,
which stops it being sent at all during the crtc disable as it is
is
still active, it would then go through drm_crtc_vblank_off, reseting
the timestamp, and get delivered during the vblank enable as part
of
the atomic commit.

This shouldn't fix your vblank timestamp troubles either. It might
mean
that the timestamp is slightly too early (because you take it while
shutting down the crtc, not while re-enabling), but not by seconds.

Quoted 8 lines

Quick experiment: Disable vblank disabling with drm.vblankoffdelay =
0. If
that also fixes the timestamps, then I'm pretty sure you have a driver bug
somewhere and lie to the vblank core code about something. -Daniel

Experiment done. The timestamp is fine, it is the timestamp of the previous vblank update. But, this would fix it because the vblank interrupt was never disabled.

Quoted 8 lines

The original issue was that the event got sent after vblank was disabled and before it got re-enabled during the modeset, so nothing
had happened to update the timestamp and seq number.

What are you expecting to update the timestamp and seq number while the
interrupt is disabled after vblank_disable_fn?

Hm maybe this indeed needs to be shuffled around a bit, since currently it's indeed not not allowed to call drm_crtc_send_vblank_event if:
- your driver has vblank support (i.e. dev->num_crtcs > 0)
- the vblank irq is off (i.e. no one called drm_crtc_vblank_get)
- from the vblank code's pov the pipe is still running (i.e. not in-between a drm_crtc_vblank_off()/on() pair)

If all of these conditions hold then drm_crtc_send_vblank_event is going to give you a garbage timestamp and and sequence number. If you call drm_crtc_vblank_get/put around it, or after vblank_off, then either of those will have rolled things forward for you.

The other option I was chasing is a get_vblank_counter driver callback
which lies, but I think that's only relevant for immediate disabling support.

Quoted 5 lines

Anyway, thanks for sticking with me on this. Can I volunteer you to write a patch to improve the documentation of drm_crtc_send_vblank_event, plus add a WARN_ON in there that fires if the above conditions are all true? I expect imx isn't the only one that gets this wrong, would be good to close this trap for real.

Sure, Ill add it as part of v3 once Ive figured out which combination of state I can use for the WARN_ON, along with the split up of this patch in to 2 separate patches. (Tomorrow)

Quoted 6 lines
Quoted 2 lines

Im struggling to see what this experiment was meant to test/prove.

Worked all fine in confirming what I wanted to confirm.

Thanks, Daniel

No problem. Thanks for the due diligence.

Quoted 86 lines
Quoted 86 lines
Quoted 86 lines
Quoted 86 lines

So, in theory, we could just have the following change to fix the
specific issue of a stale timestamp.

However, given the documentation for the event in
include/drm/drm_crtc.h:

* - The event is for a CRTC which is being disabled
through
this
* atomic commit. In that case the event can be send
out
any
time
* after the hardware has stopped scanning out the
current
* framebuffers. It should contain the timestamp and
counter
for the
* last vblank before the display pipeline was shut
off.
The
simplest
* way to achieve that is calling
drm_crtc_send_vblank_event()
* somewhen after drm_crtc_vblank_off() has been
called.

This still seems like a sensible change for when the crtc is being
disabled.

Quoted 16 lines
Quoted 7 lines
Quoted 4 lines
      spin_lock_irq(&crtc->dev->event_lock);

- if (crtc->state->event)
{
+ if (crtc->state->event && !crtc->state->active) {

This is not mentioned though.

Quoted 8 lines

If the pending event is not sent here, I assume it will be picked
up by
.atomic_flush and will then be sent after the first EOF interrupt
after
the modeset is complete. Can you explain this in the commit message?

Quoted 9 lines

Yeah looks correct (you only want to generate the event here when
the
crtc stays off), if it gets re-enabled the event should only be
generated later on once that's all finished. But separate bugfix.
-Daniel

It looks like this is actually the fix needed to avoid the bogus
timestamp.

I can split this patch up in to 2 commits if desired?

Quoted 17 lines
Quoted 17 lines

With that,

Quoted 12 lines

drm_crtc_send_vblank_event(crtc, crtc-

Quoted 2 lines

state-
event);

              crtc->state->event = NULL;
      }
      spin_unlock_irq(&crtc->dev->event_lock);
drivers/gpu/drm/imx/ipuv3-crtc.c +0 -2
-
-     drm_crtc_vblank_off(crtc);
 }
 
 static void imx_drm_crtc_reset(struct drm_crtc *crtc)
Quoted 13 lines
Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines

regards
Philipp
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#9 lore raw
Quoted 169 lines · Robert Beckett
Quoted 168 lines · Daniel Vetter
Quoted 141 lines · Robert Beckett
Quoted 121 lines · Daniel Vetter
Quoted 99 lines · Robert Beckett
Quoted 78 lines · Daniel Vetter
Quoted 41 lines · Philipp Zabel

Hi Robert,

thank you for the patch.

Quoted 9 lines · Robert Beckett

Notify drm core before sending pending events during crtc
disable.
This fixes the first event after disable having an old stale
timestamp
by having drm_crtc_vblank_off update the timestamp to now.

Quoted 3 lines

This was seen while debugging weston log message:
Warning: computed repaint delay is insane: -8212 msec

Would you say this

Fixes a474478642d5 ("drm/imx: fix crtc vblank state

regression")
?

Quoted 17 lines

Signed-off-by: Robert Beckett <
[email protected]>

---
 drivers/gpu/drm/imx/ipuv3-crtc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/imx/ipuv3-crtc.c +0 -0
index 9cc1d678674f..c436a28d50e4 100644
@@ -91,14 +91,14 @@ static void

ipu_crtc_atomic_disable(struct
drm_crtc *crtc,

      ipu_dc_disable(ipu);
      ipu_prg_disable(ipu);
Quoted 6 lines

drivers/gpu/drm/imx/ipuv3-crtc.c

Quoted 2 lines
drivers/gpu/drm/imx/ipuv3-crtc.c +2 -0
+     drm_crtc_vblank_off(crtc);
+

This is explained in the commit message and aligns with the
drm_crtc_state @event documentation.

This part here looks fishy. The drm_vblank.c code is supposed
to
do
the right thing, no matter where or when you ask it to generate
an
event. It definitely shouldn't generate a timestamp that's a
few
seconds too early. Bunch of options:
- there's a bug in drm_vblank.c and it's mixing up something
and
generating a totally bogus value.
- there's a lie in your imx vblank code, which trips the drm_vblank.c
counter interpolation and results in a totally bogus value.

drm_vblank.c assumes that if you do claim to have a hw counter
and
generate timestamps, that those are perfectly accurate. It only
falls
back to guestimating using the system timer if that's not present.

Quoted 5 lines

Either way, this very much smells like papering over a bug if
this
change indeed fixes your wrong vblank timestamps.

A quick explaination of where the dodgy timestamp came from:
1. driver starts up
2. fbcon comes along and restores fbdev, enabling vblank
3. vblank_disable_fn fires via timer disabling vblank, keeping
vblank
seq number and time set at current value
(some time later)
4. weston starts and does a modeset
5. atomic commit disables crtc while it does the modeset
6. ipu_crtc_atomic_disable sends vblank with old seq number and
time

Quoted 12 lines

It turns out the actual fix for the old vblank is the next change,
which stops it being sent at all during the crtc disable as it
is
is
still active, it would then go through drm_crtc_vblank_off, reseting
the timestamp, and get delivered during the vblank enable as part
of
the atomic commit.

This shouldn't fix your vblank timestamp troubles either. It might
mean
that the timestamp is slightly too early (because you take it while
shutting down the crtc, not while re-enabling), but not by seconds.

Quoted 8 lines

Quick experiment: Disable vblank disabling with drm.vblankoffdelay =
0. If
that also fixes the timestamps, then I'm pretty sure you have a driver bug
somewhere and lie to the vblank core code about something. -Daniel

Experiment done. The timestamp is fine, it is the timestamp of the
previous vblank update. But, this would fix it because the vblank interrupt was never disabled.

The original issue was that the event got sent after vblank was disabled and before it got re-enabled during the modeset, so nothing
had happened to update the timestamp and seq number.

Quoted 4 lines

What are you expecting to update the timestamp and seq number while
the
interrupt is disabled after vblank_disable_fn?

Hm maybe this indeed needs to be shuffled around a bit, since currently it's indeed not not allowed to call drm_crtc_send_vblank_event if:
- your driver has vblank support (i.e. dev->num_crtcs > 0)
- the vblank irq is off (i.e. no one called drm_crtc_vblank_get)
- from the vblank code's pov the pipe is still running (i.e. not in-between a drm_crtc_vblank_off()/on() pair)

If all of these conditions hold then drm_crtc_send_vblank_event is going to give you a garbage timestamp and and sequence number. If you
call drm_crtc_vblank_get/put around it, or after vblank_off, then either of those will have rolled things forward for you.

The other option I was chasing is a get_vblank_counter driver callback
which lies, but I think that's only relevant for immediate disabling
support.

Quoted 6 lines
Quoted 6 lines

Anyway, thanks for sticking with me on this. Can I volunteer you to write a patch to improve the documentation of drm_crtc_send_vblank_event, plus add a WARN_ON in there that fires if
the above conditions are all true? I expect imx isn't the only one that gets this wrong, would be good to close this trap for real.

It turns out it is not as simple as calling drm_crtc_vblank_off() to update the timestamp and seq number before sending the event. drm_crtc_vblank_off() calls drm_vblank_disable_and_save() to update the info, but that doesnt actually do the update if !vblank->enabled for the legit reason that the driver may have runtime disabled the timestamp register HW.

In the situation where interrupts were disabled long ago, and the modeset is disabling the crtc, we would want an up to date timestamp and seq number for signalling the disable of a crtc, but cant get the updated values if interrupts were previously disabled.

Im not sure how to handle this case generically.
We could just set the timestamp to now, but what to do about the seq number? Increment it? keep it the same?

Any thoughts on this?

For the similar case where the crtc is being enabled during the modeset with vblank enabled, the later fix of checking for !crtc->state->active before sending the event still works as it will be delivered during next vblank with an updated stamp.

Quoted 122 lines

Sure, Ill add it as part of v3 once Ive figured out which combination of state I can use for the WARN_ON, along with the split up of this patch in to 2 separate patches. (Tomorrow)

Quoted 7 lines
Quoted 3 lines

Im struggling to see what this experiment was meant to test/prove.

Worked all fine in confirming what I wanted to confirm.

Thanks, Daniel

No problem. Thanks for the due diligence.

Quoted 93 lines
Quoted 93 lines
Quoted 93 lines
Quoted 93 lines

So, in theory, we could just have the following change to fix the
specific issue of a stale timestamp.

However, given the documentation for the event in
include/drm/drm_crtc.h:

* - The event is for a CRTC which is being disabled
through
this
* atomic commit. In that case the event can be
send
out
any
time
* after the hardware has stopped scanning out the
current
* framebuffers. It should contain the timestamp
and
counter
for the
* last vblank before the display pipeline was
shut
off.
The
simplest
* way to achieve that is calling
drm_crtc_send_vblank_event()
* somewhen after drm_crtc_vblank_off() has been
called.

This still seems like a sensible change for when the crtc is being
disabled.

Quoted 18 lines
Quoted 7 lines
Quoted 4 lines
      spin_lock_irq(&crtc->dev->event_lock);

- if (crtc->state->event)
{
+ if (crtc->state->event && !crtc->state->active) {

This is not mentioned though.

Quoted 10 lines

If the pending event is not sent here, I assume it will be
picked
up by
.atomic_flush and will then be sent after the first EOF interrupt
after
the modeset is complete. Can you explain this in the commit
message?

Quoted 11 lines

Yeah looks correct (you only want to generate the event here
when
the
crtc stays off), if it gets re-enabled the event should only
be
generated later on once that's all finished. But separate bugfix.
-Daniel

It looks like this is actually the fix needed to avoid the bogus
timestamp.

I can split this patch up in to 2 commits if desired?

Quoted 17 lines
Quoted 17 lines

With that,

Quoted 12 lines

drm_crtc_send_vblank_event(crtc, crtc-

Quoted 2 lines

state-
event);

              crtc->state->event = NULL;
      }
      spin_unlock_irq(&crtc->dev->event_lock);
drivers/gpu/drm/imx/ipuv3-crtc.c +0 -2
-
-     drm_crtc_vblank_off(crtc);
 }
 
 static void imx_drm_crtc_reset(struct drm_crtc *crtc)
Quoted 13 lines
Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines

regards
Philipp
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel