Skip to contentSkip to conversation

drm: send vblank event with the attached sequence rather than current

PATCH In review Mark Yacoub 4 participants 5 messages Dec 2, 2021 – Dec 3, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: send vblank event with the attached sequence rather than current

From: Mark Yacoub <[email protected]>

[Why]
drm_handle_vblank_events loops over vblank_event_list to send any event that is current or has passed.
More than 1 event could be pending with past sequence time that need to be send. This can be a side effect of drivers without hardware vblank counter and they depend on the difference in the timestamps and the frame/field duration calculated in drm_update_vblank_count. This can lead to 1 vblirq being ignored due to very small diff, resulting in a subsequent vblank with 2 pending vblank events to be sent, each with a unique sequence expected by user space.

[How]
Send each pending vblank event with the sequence it's waiting on instead of assigning the current sequence to all of them.

Fixes igt@kms_flip "Unexpected frame sequence"
Tested on Jacuzzi (MT8183)

---
 drivers/gpu/drm/drm_vblank.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_vblank.c +1 -1
index 3417e1ac79185..47da8056abc14 100644
@@ -1902,7 +1902,7 @@ static void drm_handle_vblank_events(struct drm_device *dev, unsigned int pipe)
 
 		list_del(&e->base.link);
 		drm_vblank_put(dev, pipe);
-		send_vblank_event(dev, e, seq, now);
+		send_vblank_event(dev, e, e->sequence, now);
 	}
 
 	if (crtc && crtc->funcs->get_vblank_timestamp)
Signature · 1 line
2.34.0.rc2.393.gf8c9666880-goog
#1 lore raw
Quoted 30 lines · Mark Yacoub

From: Mark Yacoub <[email protected]>

[Why]
drm_handle_vblank_events loops over vblank_event_list to send any event that is current or has passed.
More than 1 event could be pending with past sequence time that need to be send. This can be a side effect of drivers without hardware vblank counter and they depend on the difference in the timestamps and the frame/field duration calculated in drm_update_vblank_count. This can lead to 1 vblirq being ignored due to very small diff, resulting in a subsequent vblank with 2 pending vblank events to be sent, each with a unique sequence expected by user space.

[How]
Send each pending vblank event with the sequence it's waiting on instead of assigning the current sequence to all of them.

Fixes igt@kms_flip "Unexpected frame sequence"
Tested on Jacuzzi (MT8183)

---
 drivers/gpu/drm/drm_vblank.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_vblank.c +0 -0
index 3417e1ac79185..47da8056abc14 100644

drivers/gpu/drm/drm_vblank.c static void drm_handle_vblank_events(struct drm_device *dev, unsigned int pipe) · line 1905

Quoted 5 lines
drivers/gpu/drm/drm_vblank.c +1 -1
@@ -1902,7 +1902,7 @@ static void drm_handle_vblank_events(struct drm_device *dev, unsigned int pipe)
 
 		list_del(&e->base.link);
 		drm_vblank_put(dev, pipe);
-		send_vblank_event(dev, e, seq, now);
+		send_vblank_event(dev, e, e->sequence, now);

This doesn't look right. The timestamp corresponds to 'seq' not e->sequence (ie. whatever sequqnece number the user asked to wait for).

Quoted 5 lines
drivers/gpu/drm/drm_vblank.c +0 -0
 	}
 
 	if (crtc && crtc->funcs->get_vblank_timestamp)
Signature · 1 line
2.34.0.rc2.393.gf8c9666880-goog
Signature · 2 lines
Ville Syrjälä
Intel
#2 lore raw
In reply to Mark Yacoub

Hi Mark,

Quoted 2 lines · Mark Yacoub

From: Mark Yacoub <[email protected]>

please make sure to add the linux-mediatek mailinglist in any follow-up communication.

Regards,
Matthias

Quoted 37 lines

[Why]
drm_handle_vblank_events loops over vblank_event_list to send any event that is current or has passed.
More than 1 event could be pending with past sequence time that need to be send. This can be a side effect of drivers without hardware vblank counter and they depend on the difference in the timestamps and the frame/field duration calculated in drm_update_vblank_count. This can lead to 1 vblirq being ignored due to very small diff, resulting in a subsequent vblank with 2 pending vblank events to be sent, each with a unique sequence expected by user space.

[How]
Send each pending vblank event with the sequence it's waiting on instead of assigning the current sequence to all of them.

Fixes igt@kms_flip "Unexpected frame sequence"
Tested on Jacuzzi (MT8183)

---
  drivers/gpu/drm/drm_vblank.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_vblank.c +1 -1
index 3417e1ac79185..47da8056abc14 100644
@@ -1902,7 +1902,7 @@ static void drm_handle_vblank_events(struct drm_device *dev, unsigned int pipe)
 
  		list_del(&e->base.link);
  		drm_vblank_put(dev, pipe);
-		send_vblank_event(dev, e, seq, now);
+		send_vblank_event(dev, e, e->sequence, now);
  	}
 
  	if (crtc && crtc->funcs->get_vblank_timestamp)
#3 lore raw
Quoted 19 lines · Matthias Brugger

Hi Mark,

Quoted 2 lines · Mark Yacoub

From: Mark Yacoub <[email protected]>

please make sure to add the linux-mediatek mailinglist in any follow-up communication.

Regards,
Matthias

Quoted 8 lines

[Why]
drm_handle_vblank_events loops over vblank_event_list to send any event that is current or has passed.
More than 1 event could be pending with past sequence time that need to be send. This can be a side effect of drivers without hardware vblank counter and they depend on the difference in the timestamps and the frame/field duration calculated in drm_update_vblank_count. This can lead to 1 vblirq being ignored due to very small diff,

That sounds like the real issue which needs to be addressed. As Ville wrote, the sequence value in the event is supposed to be the current sequence, not the one which was specified originally by user space. So this change would basically break the universe. ;)

Quoted 27 lines
Quoted 27 lines

resulting in a subsequent vblank with 2 pending vblank events to be sent, each with a unique sequence expected by user space.

[How]
Send each pending vblank event with the sequence it's waiting on instead of assigning the current sequence to all of them.

Fixes igt@kms_flip "Unexpected frame sequence"
Tested on Jacuzzi (MT8183)

---
  drivers/gpu/drm/drm_vblank.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_vblank.c +1 -1
index 3417e1ac79185..47da8056abc14 100644
@@ -1902,7 +1902,7 @@ static void drm_handle_vblank_events(struct drm_device *dev, unsigned int pipe)
             list_del(&e->base.link);
           drm_vblank_put(dev, pipe);
-        send_vblank_event(dev, e, seq, now);
+        send_vblank_event(dev, e, e->sequence, now);
       }
         if (crtc && crtc->funcs->get_vblank_timestamp)
 
Signature · 2 lines
Earthling Michel Dänzer            |                  https://redhat.com
Libre software enthusiast          |         Mesa and Xwayland developer
#4 lore raw
Quoted 22 lines · Michel Dänzer
Quoted 19 lines · Matthias Brugger

Hi Mark,

Quoted 2 lines · Mark Yacoub

From: Mark Yacoub <[email protected]>

please make sure to add the linux-mediatek mailinglist in any follow-up communication.

Regards,
Matthias

Quoted 8 lines

[Why]
drm_handle_vblank_events loops over vblank_event_list to send any event that is current or has passed.
More than 1 event could be pending with past sequence time that need to be send. This can be a side effect of drivers without hardware vblank counter and they depend on the difference in the timestamps and the frame/field duration calculated in drm_update_vblank_count. This can lead to 1 vblirq being ignored due to very small diff,

Quoted 2 lines

That sounds like the real issue which needs to be addressed. As Ville wrote, the sequence value in the event is supposed to be the current sequence, not the one which was specified originally by user space. So this change would basically break the universe. ;)

I don't wanna be the reason to break the universe :)) I guess I misunderstood what the call does, will look into the real issue more. Thanks everyone!

Quoted 34 lines
Quoted 16 lines
Quoted 16 lines

resulting in a subsequent vblank with 2 pending vblank events to be sent, each with a unique sequence expected by user space.

[How]
Send each pending vblank event with the sequence it's waiting on instead of assigning the current sequence to all of them.

Fixes igt@kms_flip "Unexpected frame sequence"
Tested on Jacuzzi (MT8183)

---
  drivers/gpu/drm/drm_vblank.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

drivers/gpu/drm/drm_vblank.c static void drm_handle_vblank_events(struct drm_device *dev, unsigned int pipe) · line 1907

Quoted 12 lines
drivers/gpu/drm/drm_vblank.c +1 -1
index 3417e1ac79185..47da8056abc14 100644
@@ -1902,7 +1902,7 @@ static void drm_handle_vblank_events(struct drm_device *dev, unsigned int pipe)
            list_del(&e->base.link);
          drm_vblank_put(dev, pipe);
-        send_vblank_event(dev, e, seq, now);
+        send_vblank_event(dev, e, e->sequence, now);
      }
        if (crtc && crtc->funcs->get_vblank_timestamp)
 

--
Earthling Michel Dänzer | https://redhat.com
Libre software enthusiast | Mesa and Xwayland developer