drm/vblank: Fix return type for drm_vblank_count()
Subsystems (3)
PATCH 1/5 drm/vblank: Fix return type for drm_vblank_count()
drm_vblank_count() has a u32 type returning what is a 64-bit vblank count. The effect of this is when drm_wait_vblank_ioctl() tries to widen the user space requested vblank sequence using this clipped 32-bit count(when the value is >= 2^32) as reference, the requested sequence remains a 32-bit value and gets queued like that. However, the code that checks if the requested sequence has passed compares this against the 64-bit vblank count.
--- drivers/gpu/drm/drm_vblank.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_vblank.c +1 -1
@@ -271,7 +271,7 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,store_vblank (dev, pipe, diff, t_vblank, cur_vblank); } -static u32 drm_vblank_count (struct drm_device *dev,unsigned int pipe) +static u64 drm_vblank_count (struct drm_device *dev,unsigned int pipe) {struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/5 drm/vblank: Fix data type width for drm_crtc_arm_vblank_event()
Now that drm_vblank_count() returns all bits of the vblank count, update drm_crtc_arm_vblank_event() so that it queues the correct sequence. Otherwise, this leads to prolonged waits for a vblank sequence when the current count is >=2^32.
--- drivers/gpu/drm/drm_vblank.c | 4 ++-- include/drm/drm_vblank.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_vblank.c +2 -2
@@ -292,11 +292,11 @@ static u64 drm_vblank_count(struct drm_device *dev, unsigned int pipe)* This is mostly useful for hardware that can obtain the scanout position, but * doesn't have a hardware frame counter. */ -u32 drm_crtc_accurate_vblank_count (struct drm_crtc *crtc) +u64 drm_crtc_accurate_vblank_count (struct drm_crtc *crtc) {struct drm_device *dev = crtc->dev;unsigned int pipe =drm_crtc_index (crtc); -u32 vblank; +u64 vblank;unsigned long flags; WARN_ONCE(drm_debug & DRM_UT_VBL && !dev->driver->get_vblank_timestamp,
include/drm/drm_vblank.h +1 -1
@@ -179,7 +179,7 @@ void drm_crtc_wait_one_vblank(struct drm_crtc *crtc);void drm_crtc_vblank_off (struct drm_crtc *crtc);void drm_crtc_vblank_reset (struct drm_crtc *crtc);void drm_crtc_vblank_on (struct drm_crtc *crtc); -u32 drm_crtc_accurate_vblank_count (struct drm_crtc *crtc); +u64 drm_crtc_accurate_vblank_count (struct drm_crtc *crtc); bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, unsigned int pipe, int *max_error,
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/5] drm/vblank: Fix data type width for drm_crtc_arm_vblank_event()
Quoted 4 lines · Dhinakaran Pandiyan
Now that
drm_vblank_count()returns all bits of the vblank count, updatedrm_crtc_arm_vblank_event()so that it queues the correct sequence. Otherwise, this leads to prolonged waits for a vblank sequence when the current count is >=2^32.
This could be probably squashed to the previous patch... Specially if you apply the Fixes tag.
Anyways, in case you decide to go with 2 patches:
Quoted 44 lines
Cc Keith Packard <[email protected]>Cc Michel Dänzer <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Dhinakaran Pandiyan <[email protected]>--- drivers/gpu/drm/drm_vblank.c | 4 ++-- include/drm/drm_vblank.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_vblank.c +2
-2@@ -292,11 +292,11 @@ static u64 drm_vblank_count(struct drm_device *dev, unsigned int pipe)* This is mostly useful for hardware that can obtain the scanout position, but * doesn't have a hardware frame counter. */ -u32 drm_crtc_accurate_vblank_count (struct drm_crtc *crtc) +u64 drm_crtc_accurate_vblank_count (struct drm_crtc *crtc) {struct drm_device *dev = crtc->dev;unsigned int pipe =drm_crtc_index (crtc); -u32 vblank; +u64 vblank;unsigned long flags; WARN_ONCE(drm_debug & DRM_UT_VBL && !dev->driver->get_vblank_timestamp,include/drm/drm_vblank.h +1
-1@@ -179,7 +179,7 @@ void drm_crtc_wait_one_vblank(struct drm_crtc *crtc);void drm_crtc_vblank_off (struct drm_crtc *crtc);void drm_crtc_vblank_reset (struct drm_crtc *crtc);void drm_crtc_vblank_on (struct drm_crtc *crtc); -u32 drm_crtc_accurate_vblank_count (struct drm_crtc *crtc); +u64 drm_crtc_accurate_vblank_count (struct drm_crtc *crtc); bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, unsigned int pipe, int *max_error,Signature · 1 line
2.11.0
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/5] drm/vblank: Fix data type width for drm_crtc_arm_vblank_event()
In reply to Dhinakaran PandiyanQuoted 4 lines · Dhinakaran Pandiyan
Now that
drm_vblank_count()returns all bits of the vblank count, updatedrm_crtc_arm_vblank_event()so that it queues the correct sequence. Otherwise, this leads to prolonged waits for a vblank sequence when the current count is >=2^32.
The summary for this patch is incorrect; the function being fixed is drm_crtc_accurate_vblank_event.
And, I'm afraid you've uncovered a rabbit hole here -- there are a couple of users of this function outside of the core, including i915 in a couple of places and nouveau. We should at least review the whole call graph starting here and make sure it does what we think it should.
Thanks for finding these bugs!
Signature · 1 line
-keith
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/5 drm/vblank: Do not update vblank count if interrupts are already disabled.
In reply to Dhinakaran PandiyanUpdating vblank counts requires register reads and these reads may not return meaningful values if the device was in a low power state after vblank interrupts were last disabled. So, update the count only if vblank interrupts are enabled. Secondly, this means the registers should be read before disabling vblank interrupts.
v2: Don't check vblank->enabled outside it's lock (Chris)
--- drivers/gpu/drm/drm_vblank.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/gpu/drm/drm_vblank.c +10 -8
@@ -347,23 +347,25 @@ void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe)spin_lock_irqsave (&dev->vblank_time_lock, irqflags);/* -* Only disable vblank interrupts if they're enabled. This avoids -* calling the ->disable_vblank() operation in atomic context with the -* hardware potentially runtime suspended. +* Update vblank count and disable vblank interrupts only if the +* interrupts were enabled. This avoids calling the ->disable_vblank() +* operation in atomic context with the hardware potentially runtime +* suspended. */ -if (vblank->enabled) { -__disable_vblank (dev, pipe); - vblank->enabled = false; - } +if (!vblank->enabled) + goto out;/* -* Always update the count and timestamp to maintain the +* Update the count and timestamp to maintain the * appearance that the counter has been ticking all along until * this time. This makes the count account for the entire time * between drm_crtc_vblank_on() and drm_crtc_vblank_off(). */ drm_update_vblank_count (dev, pipe, false); +__disable_vblank (dev, pipe); + vblank->enabled = false; +out:spin_unlock_irqrestore (&dev->vblank_time_lock, irqflags); }
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/5] drm/vblank: Do not update vblank count if interrupts are already disabled.
Quoted 36 lines · Dhinakaran Pandiyan
Updating vblank counts requires register reads and these reads may not return meaningful values if the device was in a low power state after vblank interrupts were last disabled. So, update the count only if vblank interrupts are enabled. Secondly, this means the registers should be read before disabling vblank interrupts.
v2: Don't check
vblank->enabledoutside it's lock (Chris)Cc Chris Wilson <[email protected]>Cc Daniel Vetter <[email protected]>Cc Michel Dänzer <[email protected]>Signed-off-by Dhinakaran Pandiyan <[email protected]>--- drivers/gpu/drm/drm_vblank.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)drivers/gpu/drm/drm_vblank.c +4
-7@@ -347,23 +347,25 @@ void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe)spin_lock_irqsave (&dev->vblank_time_lock, irqflags);/* -* Only disable vblank interrupts if they're enabled. This avoids -* calling the ->disable_vblank() operation in atomic context with the -* hardware potentially runtime suspended. +* Update vblank count and disable vblank interrupts only if the +* interrupts were enabled. This avoids calling the ->disable_vblank() +* operation in atomic context with the hardware potentially runtime +* suspended. */ -if (vblank->enabled) { -__disable_vblank (dev, pipe); - vblank->enabled = false; - }
drivers/gpu/drm/drm_vblank.c void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe) · line 363
Quoted 10 lines
drivers/gpu/drm/drm_vblank.c +3
-1+if (!vblank->enabled) + goto out;/* -* Always update the count and timestamp to maintain the +* Update the count and timestamp to maintain the * appearance that the counter has been ticking all along until * this time. This makes the count account for the entire time * between drm_crtc_vblank_on() and drm_crtc_vblank_off(). */
I feel that this entire comment can be simply removed now... The approach looks good and right to me so you can use
but please ping Ville to take a look here since he introduced this approach with 4dfd64862ff8 ("drm: Use vblank timestamps to guesstimate how many vblanks were missed")
Quoted 11 lines
drivers/gpu/drm/drm_vblank.c +3
-0drm_update_vblank_count (dev, pipe, false); +__disable_vblank (dev, pipe); + vblank->enabled = false; +out:spin_unlock_irqrestore (&dev->vblank_time_lock, irqflags); }Signature · 1 line
2.11.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/5 drm/vblank: Restoring vblank counts after device PM events.
In reply to Dhinakaran PandiyanThe HW frame counter can get reset if device enters a low power state after vblank interrupts were disabled. This messes up any following vblank count update as a negative diff (huge unsigned diff) is calculated from the HW frame counter change. We cannot ignore negative diffs altogther as there could be legitimate wrap arounds. So, allow drivers to update vblank->count with missed vblanks for the time interrupts were disabled. This is similar to _crtc_vblank_on() except that vblanks interrupts are not enabled at the end as this function is expected to be called from the driver _enable_vblank() vfunc.
v2: drm_crtc_vblank_restore should take crtc as arg. (Chris)
Add docs and sprinkle some asserts.
--- drivers/gpu/drm/drm_vblank.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_vblank.h | 2 ++ 2 files changed, 61 insertions(+)
drivers/gpu/drm/drm_vblank.c +59 -0
@@ -1237,6 +1237,65 @@ void drm_crtc_vblank_on(struct drm_crtc *crtc) }EXPORT_SYMBOL (drm_crtc_vblank_on); +/** +* drm_vblank_restore - estimated vblanks using timestamps and update it. +* +* Power manamement features can cause frame counter resets between vblank +* disable and enable. Drivers can then use this function in their +* &drm_crtc_funcs.enable_vblank implementation to estimate the vblanks since +* the last &drm_crtc_funcs.disable_vblank. +* +* This function is the legacy version of drm_crtc_vblank_restore(). +*/ +void drm_vblank_restore (struct drm_device *dev,unsigned int pipe) +{ +ktime_t t_vblank; +struct drm_vblank_crtc *vblank; +int framedur_ns; +u64 diff_ns; +u32 cur_vblank, diff =1 ; +int count =DRM_TIMESTAMP_MAXRETRIES ; + +if (WARN_ON (pipe >= dev->num_crtcs)) +return ; + +assert_spin_locked (&dev->vbl_lock); +assert_spin_locked (&dev->vblank_time_lock); + + vblank = &dev->vblank[pipe]; +WARN_ONCE ((drm_debug &DRM_UT_VBL ) && !vblank->framedur_ns, +"Cannot compute missed vblanks without frame duration\n" ); + framedur_ns = vblank->framedur_ns; + +do { + cur_vblank =__get_vblank_counter (dev, pipe); +drm_get_last_vbltimestamp (dev, pipe, &t_vblank, false); + }while (cur_vblank !=__get_vblank_counter (dev, pipe) && --count >0 ); + + diff_ns =ktime_to_ns (ktime_sub (t_vblank, vblank->time)); +if (framedur_ns) + diff =DIV_ROUND_CLOSEST_ULL (diff_ns, framedur_ns); + + +DRM_DEBUG_VBL ("missed %d vblanks in %lld ns, frame duration=%d ns, hw_diff=%d\n" , + diff, diff_ns, framedur_ns, cur_vblank - vblank->last); +store_vblank (dev, pipe, diff, t_vblank, cur_vblank); +} +EXPORT_SYMBOL (drm_vblank_restore); + +/** +* drm_crtc_vblank_restore - estimate vblanks using timestamps and update it. +* Power manamement features can cause frame counter resets between vblank +* disable and enable. Drivers can then use this function in their +* &drm_crtc_funcs.enable_vblank implementation to estimate the vblanks since +* the last &drm_crtc_funcs.disable_vblank. +*/ +void drm_crtc_vblank_restore (struct drm_crtc *crtc) +{ +drm_vblank_restore (crtc->dev,drm_crtc_index (crtc)); +} +EXPORT_SYMBOL (drm_crtc_vblank_restore); +static void drm_legacy_vblank_pre_modeset (struct drm_device *dev,unsigned int pipe) {
include/drm/drm_vblank.h +2 -0
@@ -180,6 +180,8 @@ void drm_crtc_vblank_off(struct drm_crtc *crtc);void drm_crtc_vblank_reset (struct drm_crtc *crtc);void drm_crtc_vblank_on (struct drm_crtc *crtc);u64 drm_crtc_accurate_vblank_count (struct drm_crtc *crtc); +void drm_vblank_restore (struct drm_device *dev,unsigned int pipe); +void drm_crtc_vblank_restore (struct drm_crtc *crtc); bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, unsigned int pipe, int *max_error,
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Rodrigo Vivi
maintainerRe: [PATCH 4/5] drm/vblank: Restoring vblank counts after device PM events.
Quoted 47 lines · Dhinakaran Pandiyan
The HW frame counter can get reset if device enters a low power state after vblank interrupts were disabled. This messes up any following vblank count update as a negative diff (huge unsigned diff) is calculated from the HW frame counter change. We cannot ignore negative diffs altogther as there could be legitimate wrap arounds. So, allow drivers to update
vblank->countwith missed vblanks for the time interrupts were disabled. This is similar to_crtc_vblank_on()except that vblanks interrupts are not enabled at the end as this function is expected to be called from the driver_enable_vblank()vfunc.v2:
drm_crtc_vblank_restoreshould take crtc as arg. (Chris)
Add docs and sprinkle some asserts.Cc Daniel Vetter <[email protected]>Cc Chris Wilson <[email protected]>Cc Michel Dänzer <[email protected]>Signed-off-by Dhinakaran Pandiyan <[email protected]>--- drivers/gpu/drm/drm_vblank.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_vblank.h | 2 ++ 2 files changed, 61 insertions(+)drivers/gpu/drm/drm_vblank.c +17
-0@@ -1237,6 +1237,65 @@ void drm_crtc_vblank_on(struct drm_crtc *crtc) }EXPORT_SYMBOL (drm_crtc_vblank_on); +/** +* drm_vblank_restore - estimated vblanks using timestamps and update it. +* +* Power manamement features can cause frame counter resets between vblank +* disable and enable. Drivers can then use this function in their +* &drm_crtc_funcs.enable_vblank implementation to estimate the vblanks since +* the last &drm_crtc_funcs.disable_vblank. +* +* This function is the legacy version of drm_crtc_vblank_restore(). +*/ +void drm_vblank_restore (struct drm_device *dev,unsigned int pipe) +{ +ktime_t t_vblank; +struct drm_vblank_crtc *vblank; +int framedur_ns; +u64 diff_ns; +u32 cur_vblank, diff =1 ;
drivers/gpu/drm/drm_vblank.c void drm_crtc_vblank_on(struct drm_crtc *crtc) · line 1266
Quoted 10 lines
drivers/gpu/drm/drm_vblank.c +10
-0+int count =DRM_TIMESTAMP_MAXRETRIES ; + +if (WARN_ON (pipe >= dev->num_crtcs)) +return ; + +assert_spin_locked (&dev->vbl_lock); +assert_spin_locked (&dev->vblank_time_lock); + + vblank = &dev->vblank[pipe]; + WARN_ONCE((drm_debug & DRM_UT_VBL) && !vblank->framedur_ns,
do we really only need this warn on debug vlb?
drivers/gpu/drm/drm_vblank.c void drm_crtc_vblank_on(struct drm_crtc *crtc) · line 1267
Quoted 1 line
drivers/gpu/drm/drm_vblank.c +1
-0+ "Cannot compute missed vblanks without frame duration\n");
The message seems hard... if we *cannot* why do we move fwd?
drivers/gpu/drm/drm_vblank.c void drm_crtc_vblank_on(struct drm_crtc *crtc) · line 1273
Quoted 6 lines
drivers/gpu/drm/drm_vblank.c +6
-0+ framedur_ns = vblank->framedur_ns; + +do { + cur_vblank =__get_vblank_counter (dev, pipe); +drm_get_last_vbltimestamp (dev, pipe, &t_vblank, false); + }while (cur_vblank !=__get_vblank_counter (dev, pipe) && --count >0 );
Based on the commend of drm_update_vblank_count I don't feel that we have to do the loop here... And if we have maybe we should re-org things to avoid duplication?
drivers/gpu/drm/drm_vblank.c void drm_crtc_vblank_on(struct drm_crtc *crtc) · line 1282
Quoted 9 lines
drivers/gpu/drm/drm_vblank.c +9
-0+ + diff_ns =ktime_to_ns (ktime_sub (t_vblank, vblank->time)); +if (framedur_ns) + diff =DIV_ROUND_CLOSEST_ULL (diff_ns, framedur_ns); + + +DRM_DEBUG_VBL ("missed %d vblanks in %lld ns, frame duration=%d ns, hw_diff=%d\n" , + diff, diff_ns, framedur_ns, cur_vblank - vblank->last); +store_vblank (dev, pipe, diff, t_vblank, cur_vblank);
hm... I wonder if the simple store_vblank(... __get_vblank_counter(dev, pipe)); wouldn't work here...
Quoted 35 lines
drivers/gpu/drm/drm_vblank.c +16
-0+} +EXPORT_SYMBOL (drm_vblank_restore); + +/** +* drm_crtc_vblank_restore - estimate vblanks using timestamps and update it. +* Power manamement features can cause frame counter resets between vblank +* disable and enable. Drivers can then use this function in their +* &drm_crtc_funcs.enable_vblank implementation to estimate the vblanks since +* the last &drm_crtc_funcs.disable_vblank. +*/ +void drm_crtc_vblank_restore (struct drm_crtc *crtc) +{ +drm_vblank_restore (crtc->dev,drm_crtc_index (crtc)); +} +EXPORT_SYMBOL (drm_crtc_vblank_restore); +static void drm_legacy_vblank_pre_modeset (struct drm_device *dev,unsigned int pipe) {include/drm/drm_vblank.h +2
-0@@ -180,6 +180,8 @@ void drm_crtc_vblank_off(struct drm_crtc *crtc);void drm_crtc_vblank_reset (struct drm_crtc *crtc);void drm_crtc_vblank_on (struct drm_crtc *crtc);u64 drm_crtc_accurate_vblank_count (struct drm_crtc *crtc); +void drm_vblank_restore (struct drm_device *dev,unsigned int pipe); +void drm_crtc_vblank_restore (struct drm_crtc *crtc); bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, unsigned int pipe, int *max_error,Signature · 1 line
2.11.0
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 4/5] drm/vblank: Restoring vblank counts after device PM events.
Quoted 61 lines · Rodrigo Vivi
Quoted 47 lines · Dhinakaran Pandiyan
The HW frame counter can get reset if device enters a low power state after vblank interrupts were disabled. This messes up any following vblank count update as a negative diff (huge unsigned diff) is calculated from the HW frame counter change. We cannot ignore negative diffs altogther as there could be legitimate wrap arounds. So, allow drivers to update
vblank->countwith missed vblanks for the time interrupts were disabled. This is similar to_crtc_vblank_on()except that vblanks interrupts are not enabled at the end as this function is expected to be called from the driver_enable_vblank()vfunc.v2:
drm_crtc_vblank_restoreshould take crtc as arg. (Chris)
Add docs and sprinkle some asserts.Cc Daniel Vetter <[email protected]>Cc Chris Wilson <[email protected]>Cc Michel Dänzer <[email protected]>Signed-off-by Dhinakaran Pandiyan <[email protected]>--- drivers/gpu/drm/drm_vblank.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_vblank.h | 2 ++ 2 files changed, 61 insertions(+)drivers/gpu/drm/drm_vblank.c +17
-0@@ -1237,6 +1237,65 @@ void drm_crtc_vblank_on(struct drm_crtc *crtc) }EXPORT_SYMBOL (drm_crtc_vblank_on); +/** +* drm_vblank_restore - estimated vblanks using timestamps and update it. +* +* Power manamement features can cause frame counter resets between vblank +* disable and enable. Drivers can then use this function in their +* &drm_crtc_funcs.enable_vblank implementation to estimate the vblanks since +* the last &drm_crtc_funcs.disable_vblank. +* +* This function is the legacy version of drm_crtc_vblank_restore(). +*/ +void drm_vblank_restore (struct drm_device *dev,unsigned int pipe) +{ +ktime_t t_vblank; +struct drm_vblank_crtc *vblank; +int framedur_ns; +u64 diff_ns; +u32 cur_vblank, diff =1 ;drivers/gpu/drm/drm_vblank.c void drm_crtc_vblank_on(struct drm_crtc *crtc) · line 1266
Quoted 10 lines
drivers/gpu/drm/drm_vblank.c +10
-0+int count =DRM_TIMESTAMP_MAXRETRIES ; + +if (WARN_ON (pipe >= dev->num_crtcs)) +return ; + +assert_spin_locked (&dev->vbl_lock); +assert_spin_locked (&dev->vblank_time_lock); + + vblank = &dev->vblank[pipe]; + WARN_ONCE((drm_debug & DRM_UT_VBL) && !vblank->framedur_ns,do we really only need this warn on debug vlb?
Quoted 3 lines
drivers/gpu/drm/drm_vblank.c void drm_crtc_vblank_on(struct drm_crtc *crtc) · line 1267
Quoted 1 line
drivers/gpu/drm/drm_vblank.c +1
-0+ "Cannot compute missed vblanks without frame duration\n");The message seems hard... if we *cannot* why do we move fwd?
We assume the diff is 1 and make an update, some kind of a default similar to what is implemented in drm_update_vblank_count()
Quoted 9 lines
drivers/gpu/drm/drm_vblank.c void drm_crtc_vblank_on(struct drm_crtc *crtc) · line 1273
Quoted 7 lines
drivers/gpu/drm/drm_vblank.c +6
-0+ framedur_ns = vblank->framedur_ns; + +do { + cur_vblank =__get_vblank_counter (dev, pipe); +drm_get_last_vbltimestamp (dev, pipe, &t_vblank, false); + }while (cur_vblank !=__get_vblank_counter (dev, pipe) && --count >0 );Based on the commend of
drm_update_vblank_countI don't feel that we have to
This one? -
"* We repeat the hardware vblank counter & timestamp query until
* we get consistent results. This to prevent races between gpu
* updating its hardware counter while we are retrieving the
* corresponding vblank timestamp."
I added the loop based on that comment. If the register if partially updated, we want to discard that and loop until it is stable.
Quoted 3 lines
do the loop here... And if we have maybe we should re-org things to avoid duplication?
I considered that, we need to pass at least four args for three lines of code. Felt it was too small to warrant a separate function.
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/drm_vblank.c +4
-0+ + diff_ns =ktime_to_ns (ktime_sub (t_vblank, vblank->time)); +if (framedur_ns) + diff =DIV_ROUND_CLOSEST_ULL (diff_ns, framedur_ns);
Quoted 8 lines
drivers/gpu/drm/drm_vblank.c void drm_crtc_vblank_on(struct drm_crtc *crtc) · line 1282
Quoted 5 lines
drivers/gpu/drm/drm_vblank.c +5
-0+ + +DRM_DEBUG_VBL ("missed %d vblanks in %lld ns, frame duration=%d ns, hw_diff=%d\n" , + diff, diff_ns, framedur_ns, cur_vblank - vblank->last); +store_vblank (dev, pipe, diff, t_vblank, cur_vblank);hm... I wonder if the simple store_vblank(...
__get_vblank_counter(dev, pipe)); wouldn't work here...
We have to store a stable count.
Quoted 31 lines
Quoted 31 lines
drivers/gpu/drm/drm_vblank.c +16
-0+} +EXPORT_SYMBOL (drm_vblank_restore); + +/** +* drm_crtc_vblank_restore - estimate vblanks using timestamps and update it. +* Power manamement features can cause frame counter resets between vblank +* disable and enable. Drivers can then use this function in their +* &drm_crtc_funcs.enable_vblank implementation to estimate the vblanks since +* the last &drm_crtc_funcs.disable_vblank. +*/ +void drm_crtc_vblank_restore (struct drm_crtc *crtc) +{ +drm_vblank_restore (crtc->dev,drm_crtc_index (crtc)); +} +EXPORT_SYMBOL (drm_crtc_vblank_restore); +static void drm_legacy_vblank_pre_modeset (struct drm_device *dev,unsigned int pipe) {include/drm/drm_vblank.h +2
-0@@ -180,6 +180,8 @@ void drm_crtc_vblank_off(struct drm_crtc *crtc);void drm_crtc_vblank_reset (struct drm_crtc *crtc);void drm_crtc_vblank_on (struct drm_crtc *crtc);u64 drm_crtc_accurate_vblank_count (struct drm_crtc *crtc); +void drm_vblank_restore (struct drm_device *dev,unsigned int pipe); +void drm_crtc_vblank_restore (struct drm_crtc *crtc);
Quoted 9 lines
Quoted 5 lines
include/drm/drm_vblank.h +0
-0bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, unsigned int pipe, int *max_error,Signature · 1 line
2.11.0_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 4/5] drm/vblank: Restoring vblank counts after device PM events.
Quoted 115 lines · Dhinakaran
Quoted 61 lines · Rodrigo Vivi
Quoted 47 lines · Dhinakaran Pandiyan
The HW frame counter can get reset if device enters a low power state after vblank interrupts were disabled. This messes up any following vblank count update as a negative diff (huge unsigned diff) is calculated from the HW frame counter change. We cannot ignore negative diffs altogther as there could be legitimate wrap arounds. So, allow drivers to update
vblank->countwith missed vblanks for the time interrupts were disabled. This is similar to_crtc_vblank_on()except that vblanks interrupts are not enabled at the end as this function is expected to be called from the driver_enable_vblank()vfunc.v2:
drm_crtc_vblank_restoreshould take crtc as arg. (Chris)
Add docs and sprinkle some asserts.Cc Daniel Vetter <[email protected]>Cc Chris Wilson <[email protected]>Cc Michel Dänzer <[email protected]>Signed-off-by Dhinakaran Pandiyan <[email protected]>--- drivers/gpu/drm/drm_vblank.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_vblank.h | 2 ++ 2 files changed, 61 insertions(+)drivers/gpu/drm/drm_vblank.c +17
-0@@ -1237,6 +1237,65 @@ void drm_crtc_vblank_on(struct drm_crtc *crtc) }EXPORT_SYMBOL (drm_crtc_vblank_on); +/** +* drm_vblank_restore - estimated vblanks using timestamps and update it. +* +* Power manamement features can cause frame counter resets between vblank +* disable and enable. Drivers can then use this function in their +* &drm_crtc_funcs.enable_vblank implementation to estimate the vblanks since +* the last &drm_crtc_funcs.disable_vblank. +* +* This function is the legacy version of drm_crtc_vblank_restore(). +*/ +void drm_vblank_restore (struct drm_device *dev,unsigned int pipe) +{ +ktime_t t_vblank; +struct drm_vblank_crtc *vblank; +int framedur_ns; +u64 diff_ns; +u32 cur_vblank, diff =1 ;drivers/gpu/drm/drm_vblank.c void drm_crtc_vblank_on(struct drm_crtc *crtc) · line 1266
Quoted 10 lines
drivers/gpu/drm/drm_vblank.c +10
-0+int count =DRM_TIMESTAMP_MAXRETRIES ; + +if (WARN_ON (pipe >= dev->num_crtcs)) +return ; + +assert_spin_locked (&dev->vbl_lock); +assert_spin_locked (&dev->vblank_time_lock); + + vblank = &dev->vblank[pipe]; + WARN_ONCE((drm_debug & DRM_UT_VBL) && !vblank->framedur_ns,do we really only need this warn on debug vlb?
Quoted 3 lines
drivers/gpu/drm/drm_vblank.c void drm_crtc_vblank_on(struct drm_crtc *crtc) · line 1267
Quoted 1 line
drivers/gpu/drm/drm_vblank.c +1
-0+ "Cannot compute missed vblanks without frame duration\n");The message seems hard... if we *cannot* why do we move fwd?
We assume the diff is 1 and make an update, some kind of a default similar to what is implemented in
drm_update_vblank_count()Quoted 9 lines
drivers/gpu/drm/drm_vblank.c void drm_crtc_vblank_on(struct drm_crtc *crtc) · line 1273
Quoted 7 lines
drivers/gpu/drm/drm_vblank.c +6
-0+ framedur_ns = vblank->framedur_ns; + +do { + cur_vblank =__get_vblank_counter (dev, pipe); +drm_get_last_vbltimestamp (dev, pipe, &t_vblank, false); + }while (cur_vblank !=__get_vblank_counter (dev, pipe) && --count >0 );Based on the commend of
drm_update_vblank_countI don't feel that we have toThis one? -
"* We repeat the hardware vblank counter & timestamp query until
* we get consistent results. This to prevent races between gpu
* updating its hardware counter while we are retrieving the
* corresponding vblank timestamp."I added the loop based on that comment. If the register if partially updated, we want to discard that and loop until it is stable.
Quoted 3 lines
do the loop here... And if we have maybe we should re-org things to avoid duplication?
I considered that, we need to pass at least four args for three lines of code. Felt it was too small to warrant a separate function.
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/drm_vblank.c +4
-0+ + diff_ns =ktime_to_ns (ktime_sub (t_vblank, vblank->time)); +if (framedur_ns) + diff =DIV_ROUND_CLOSEST_ULL (diff_ns, framedur_ns);Quoted 8 lines
drivers/gpu/drm/drm_vblank.c void drm_crtc_vblank_on(struct drm_crtc *crtc) · line 1282
Quoted 5 lines
drivers/gpu/drm/drm_vblank.c +5
-0+ + +DRM_DEBUG_VBL ("missed %d vblanks in %lld ns, frame duration=%d ns, hw_diff=%d\n" , + diff, diff_ns, framedur_ns, cur_vblank - vblank->last); +store_vblank (dev, pipe, diff, t_vblank, cur_vblank);hm... I wonder if the simple store_vblank(...
__get_vblank_counter(dev, pipe)); wouldn't work here...
Quoted 1 line
We have to store a stable count.
I don't see why our counter wouldn't be stable at that point?
Our register is zero or the proper counter. Our frm_counter reg doesn't stop when vblank interrupts are disabled afaik...
But well, I see your point of making something more robust, using the well known and tested methods and preparing for the case where someone start using this call in other platforms as well.... So, whatever you decide..
If you go wit this:
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
drivers/gpu/drm/drm_vblank.c +16
-0+} +EXPORT_SYMBOL (drm_vblank_restore); + +/** +* drm_crtc_vblank_restore - estimate vblanks using timestamps and update it. +* Power manamement features can cause frame counter resets between vblank +* disable and enable. Drivers can then use this function in their +* &drm_crtc_funcs.enable_vblank implementation to estimate the vblanks since +* the last &drm_crtc_funcs.disable_vblank. +*/ +void drm_crtc_vblank_restore (struct drm_crtc *crtc) +{ +drm_vblank_restore (crtc->dev,drm_crtc_index (crtc)); +} +EXPORT_SYMBOL (drm_crtc_vblank_restore); +static void drm_legacy_vblank_pre_modeset (struct drm_device *dev,unsigned int pipe) {include/drm/drm_vblank.h +2
-0@@ -180,6 +180,8 @@ void drm_crtc_vblank_off(struct drm_crtc *crtc);void drm_crtc_vblank_reset (struct drm_crtc *crtc);void drm_crtc_vblank_on (struct drm_crtc *crtc);u64 drm_crtc_accurate_vblank_count (struct drm_crtc *crtc); +void drm_vblank_restore (struct drm_device *dev,unsigned int pipe); +void drm_crtc_vblank_restore (struct drm_crtc *crtc);
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines
include/drm/drm_vblank.h +0
-0bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, unsigned int pipe, int *max_error,Signature · 1 line
2.11.0_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 5/5 drm/i915: Estimate and update missed vblanks.
In reply to Dhinakaran PandiyanThe frame counter may have got reset between disabling and enabling vblank interrupts due to DMC putting the hardware to DC5/6 state if PSR was active. The frame counter also could have stalled if PSR is active in cases where there is no DMC. The frame counter resetting as a user visible impact of screen freezes. Use drm_vblank_restore() to compute missed vblanks in the duration for which vblank interrupts are disabled. There's no need particularly check if PSR was active in the interrupt disabled duration.
Enabling vblank interrupts wakes up the hardware from DC5/6 and prevents it from going back again as long as the there are pending interrupts. So, we don't have to explicity disallow DC5/6 after enabling vblank interrupts to keep the counter running.
Let's not apply this to CHV for now, as enabling interrupts does not prevent the hardware from activating PSR and thereby stalling the counter.
--- drivers/gpu/drm/i915/i915_irq.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/i915_irq.c +6 -0
@@ -2956,6 +2956,9 @@ static int ironlake_enable_vblank(struct drm_device *dev, unsigned int pipe)ilk_enable_display_irq (dev_priv, bit);spin_unlock_irqrestore (&dev_priv->irq_lock, irqflags); +if (HAS_PSR (dev_priv)) +drm_vblank_restore (dev, pipe); +return 0 ; }
@@ -2968,6 +2971,9 @@ static int gen8_enable_vblank(struct drm_device *dev, unsigned int pipe)bdw_enable_pipe_irq (dev_priv, pipe,GEN8_PIPE_VBLANK );spin_unlock_irqrestore (&dev_priv->irq_lock, irqflags); +if (HAS_PSR (dev_priv)) +drm_vblank_restore (dev, pipe); +return 0 ; }
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 5/5] drm/i915: Estimate and update missed vblanks.
Quoted 13 lines · Dhinakaran Pandiyan
The frame counter may have got reset between disabling and enabling vblank interrupts due to DMC putting the hardware to DC5/6 state if PSR was active. The frame counter also could have stalled if PSR is active in cases where there is no DMC. The frame counter resetting as a user visible impact of screen freezes. Use
drm_vblank_restore()to compute missed vblanks in the duration for which vblank interrupts are disabled. There's no need particularly check if PSR was active in the interrupt disabled duration.Enabling vblank interrupts wakes up the hardware from DC5/6 and prevents it from going back again as long as the there are pending interrupts. So, we don't have to explicity disallow DC5/6 after enabling vblank interrupts to keep the counter running.
Quoted 5 lines
Let's not apply this to CHV for now, as enabling interrupts does not prevent the hardware from activating PSR and thereby stalling the counter.
Cc Rodrigo Vivi <[email protected]>Signed-off-by Dhinakaran Pandiyan <[email protected]>
Read this series, and I think compared to all the previous attempts to fix this issue this one here seems the cleanest. Not an expert on the vblank code (Michel or Ville are best for that), but on the series:
Cheers, Daniel
Quoted 35 lines
--- drivers/gpu/drm/i915/i915_irq.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/i915/i915_irq.c +6
-0@@ -2956,6 +2956,9 @@ static int ironlake_enable_vblank(struct drm_device *dev, unsigned int pipe)ilk_enable_display_irq (dev_priv, bit);spin_unlock_irqrestore (&dev_priv->irq_lock, irqflags); +if (HAS_PSR (dev_priv)) +drm_vblank_restore (dev, pipe); +return 0 ; }@@ -2968,6 +2971,9 @@ static int gen8_enable_vblank(struct drm_device *dev, unsigned int pipe)bdw_enable_pipe_irq (dev_priv, pipe,GEN8_PIPE_VBLANK );spin_unlock_irqrestore (&dev_priv->irq_lock, irqflags); +if (HAS_PSR (dev_priv)) +drm_vblank_restore (dev, pipe); +return 0 ; }Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Rodrigo Vivi
maintainerRe: [PATCH 5/5] drm/i915: Estimate and update missed vblanks.
In reply to Dhinakaran PandiyanQuoted 27 lines · Dhinakaran Pandiyan
The frame counter may have got reset between disabling and enabling vblank interrupts due to DMC putting the hardware to DC5/6 state if PSR was active. The frame counter also could have stalled if PSR is active in cases where there is no DMC. The frame counter resetting as a user visible impact of screen freezes. Use
drm_vblank_restore()to compute missed vblanks in the duration for which vblank interrupts are disabled. There's no need particularly check if PSR was active in the interrupt disabled duration.Enabling vblank interrupts wakes up the hardware from DC5/6 and prevents it from going back again as long as the there are pending interrupts. So, we don't have to explicity disallow DC5/6 after enabling vblank interrupts to keep the counter running.
Let's not apply this to CHV for now, as enabling interrupts does not prevent the hardware from activating PSR and thereby stalling the counter.
Cc Rodrigo Vivi <[email protected]>Signed-off-by Dhinakaran Pandiyan <[email protected]>--- drivers/gpu/drm/i915/i915_irq.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/i915/i915_irq.c +0
-0
drivers/gpu/drm/i915/i915_irq.c static int ironlake_enable_vblank(struct drm_device *dev, unsigned int pipe) · line 2961
Quoted 6 lines
drivers/gpu/drm/i915/i915_irq.c +3
-0@@ -2956,6 +2956,9 @@ static int ironlake_enable_vblank(struct drm_device *dev, unsigned int pipe)ilk_enable_display_irq (dev_priv, bit);spin_unlock_irqrestore (&dev_priv->irq_lock, irqflags); +if (HAS_PSR (dev_priv)) +drm_vblank_restore (dev, pipe); +
I don't believe we need this one here.
pre-gen9 platform has psr but not dmc, so the case where we need to restore the counter doesn't exist.
drivers/gpu/drm/i915/i915_irq.c static int gen8_enable_vblank(struct drm_device *dev, unsigned int pipe) · line 2974
Quoted 8 lines
drivers/gpu/drm/i915/i915_irq.c +1
-0return 0 ; }@@ -2968,6 +2971,9 @@ static int gen8_enable_vblank(struct drm_device *dev, unsigned int pipe)bdw_enable_pipe_irq (dev_priv, pipe,GEN8_PIPE_VBLANK );spin_unlock_irqrestore (&dev_priv->irq_lock, irqflags); +if (HAS_PSR (dev_priv))
HAS_PSR(dev_priv) && HAS_CSR(dev_priv)
maybe?
So it gets clear that it is not because PSR that we need to restore the counter, but also don't do it when not needed.
Quoted 8 lines
drivers/gpu/drm/i915/i915_irq.c +2
-0+drm_vblank_restore (dev, pipe); +return 0 ; }Signature · 1 line
2.11.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [Intel-gfx] [PATCH 5/5] drm/i915: Estimate and update missed vblanks.
Quoted 31 lines · Rodrigo Vivi
Quoted 30 lines · Dhinakaran Pandiyan
The frame counter may have got reset between disabling and enabling vblank interrupts due to DMC putting the hardware to DC5/6 state if PSR was active. The frame counter also could have stalled if PSR is active in cases where there is no DMC. The frame counter resetting as a user visible impact of screen freezes. Use
drm_vblank_restore()to compute missed vblanks in the duration for which vblank interrupts are disabled. There's no need particularly check if PSR was active in the interrupt disabled duration.Enabling vblank interrupts wakes up the hardware from DC5/6 and prevents it from going back again as long as the there are pending interrupts. So, we don't have to explicity disallow DC5/6 after enabling vblank interrupts to keep the counter running.
Let's not apply this to CHV for now, as enabling interrupts does not prevent the hardware from activating PSR and thereby stalling the counter.
Cc Rodrigo Vivi <[email protected]>Signed-off-by Dhinakaran Pandiyan <[email protected]>--- drivers/gpu/drm/i915/i915_irq.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/i915/i915_irq.c +0
-0@@ -2956,6 +2956,9 @@ static int ironlake_enable_vblank(struct drm_device *dev, unsigned int pipe)ilk_enable_display_irq (dev_priv, bit);spin_unlock_irqrestore (&dev_priv->irq_lock, irqflags);
Quoted 8 lines
drivers/gpu/drm/i915/i915_irq.c static int ironlake_enable_vblank(struct drm_device *dev, unsigned int pipe) · line 2961
Quoted 3 lines
drivers/gpu/drm/i915/i915_irq.c +3
-0+if (HAS_PSR (dev_priv)) +drm_vblank_restore (dev, pipe); +I don't believe we need this one here.
pre-gen9 platform has psr but not dmc, so the case where we need to restore the counter doesn't exist.
Even without DMC, counter should be stuck when PSR is active as no frames are generated by the pipe. I am using drm_vblank_restore_count() to take care of that.
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/i915_irq.c +0
-0return 0 ; }@@ -2968,6 +2971,9 @@ static int gen8_enable_vblank(struct drm_device *dev, unsigned int pipe)bdw_enable_pipe_irq (dev_priv, pipe,GEN8_PIPE_VBLANK );spin_unlock_irqrestore (&dev_priv->irq_lock, irqflags);
Quoted 6 lines
drivers/gpu/drm/i915/i915_irq.c static int gen8_enable_vblank(struct drm_device *dev, unsigned int pipe) · line 2974
Quoted 1 line
drivers/gpu/drm/i915/i915_irq.c +1
-0+if (HAS_PSR (dev_priv))
HAS_PSR(dev_priv)&&HAS_CSR(dev_priv)
maybe?
So it gets clear that it is not because PSR that we need to restore the counter, but also don't do it when not needed.
Same reason as above, let me test this again by disabling DMC.
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/i915/i915_irq.c +2
-0+drm_vblank_restore (dev, pipe); +return 0 ; }
Quoted 7 lines
Quoted 3 lines
Signature · 1 line
2.11.0_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [Intel-gfx] [PATCH 5/5] drm/i915: Estimate and update missed vblanks.
Quoted 38 lines · Dhinakaran
Quoted 37 lines · Rodrigo Vivi
Quoted 27 lines · Dhinakaran Pandiyan
The frame counter may have got reset between disabling and enabling vblank interrupts due to DMC putting the hardware to DC5/6 state if PSR was active. The frame counter also could have stalled if PSR is active in cases where there is no DMC. The frame counter resetting as a user visible impact of screen freezes. Use
drm_vblank_restore()to compute missed vblanks in the duration for which vblank interrupts are disabled. There's no need particularly check if PSR was active in the interrupt disabled duration.Enabling vblank interrupts wakes up the hardware from DC5/6 and prevents it from going back again as long as the there are pending interrupts. So, we don't have to explicity disallow DC5/6 after enabling vblank interrupts to keep the counter running.
Let's not apply this to CHV for now, as enabling interrupts does not prevent the hardware from activating PSR and thereby stalling the counter.
Cc Rodrigo Vivi <[email protected]>Signed-off-by Dhinakaran Pandiyan <[email protected]>--- drivers/gpu/drm/i915/i915_irq.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/i915/i915_irq.c +0
-0drivers/gpu/drm/i915/i915_irq.c static int ironlake_enable_vblank(struct drm_device *dev, unsigned int pipe) · line 2961
Quoted 6 lines
drivers/gpu/drm/i915/i915_irq.c +3
-0@@ -2956,6 +2956,9 @@ static int ironlake_enable_vblank(struct drm_device *dev, unsigned int pipe)ilk_enable_display_irq (dev_priv, bit);spin_unlock_irqrestore (&dev_priv->irq_lock, irqflags); +if (HAS_PSR (dev_priv)) +drm_vblank_restore (dev, pipe); +I don't believe we need this one here.
Quoted 6 lines
Quoted 2 lines
pre-gen9 platform has psr but not dmc, so the case where we need to restore the counter doesn't exist.
Even without DMC, counter should be stuck when PSR is active as no frames are generated by the pipe. I am using
drm_vblank_restore_count()to take care of that.
Oh oh! Indeed. Now I remember you had told me this here. Can you please add a comment with this info somewhere so I don't ask the same question again ;)
anyways:
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/i915_irq.c +0
-0return 0 ; }@@ -2968,6 +2971,9 @@ static int gen8_enable_vblank(struct drm_device *dev, unsigned int pipe)bdw_enable_pipe_irq (dev_priv, pipe,GEN8_PIPE_VBLANK );spin_unlock_irqrestore (&dev_priv->irq_lock, irqflags);
Quoted 22 lines
Quoted 6 lines
drivers/gpu/drm/i915/i915_irq.c static int gen8_enable_vblank(struct drm_device *dev, unsigned int pipe) · line 2974
Quoted 1 line
drivers/gpu/drm/i915/i915_irq.c +1
-0+if (HAS_PSR (dev_priv))
HAS_PSR(dev_priv)&&HAS_CSR(dev_priv)
maybe?
So it gets clear that it is not because PSR that we need to restore the counter, but also don't do it when not needed.Same reason as above, let me test this again by disabling DMC.
Quoted 13 lines
Quoted 9 lines
drivers/gpu/drm/i915/i915_irq.c +2
-0+drm_vblank_restore (dev, pipe); +return 0 ; }Signature · 1 line
2.11.0_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Patchwork
CI✓ Fi.CI.BAT: success for series starting with [1/5] drm/vblank: Fix return type for drm_vblank_count()
In reply to Dhinakaran Pandiyan== Series Details ==
== Series Details ==
Series: series starting with [1/5] drm/vblank: Fix return type for drm_vblank_count()
URL : https://patchwork.freedesktop.org/series/36435/
State : success
== Summary ==
Series 36435v1 series starting with [1/5] drm/vblank: Fix return type for drm_vblank_count()
https://patchwork.freedesktop.org/api/1.0/series/36435/revisions/1/mbox/
Test gem_exec_suspend:
Subgroup basic-s3:
pass -> INCOMPLETE (fi-skl-6700k2) fdo#104108fdo#104108 https://bugs.freedesktop.org/show_bug.cgi?id=104108
fi-bdw-5557u total:288 pass:267 dwarn:0 dfail:0 fail:0 skip:21 time:424s fi-bdw-gvtdvm total:288 pass:264 dwarn:0 dfail:0 fail:0 skip:24 time:428s fi-blb-e6850 total:288 pass:223 dwarn:1 dfail:0 fail:0 skip:64 time:370s fi-bsw-n3050 total:288 pass:242 dwarn:0 dfail:0 fail:0 skip:46 time:487s fi-bwr-2160 total:288 pass:183 dwarn:0 dfail:0 fail:0 skip:105 time:282s fi-bxt-dsi total:288 pass:258 dwarn:0 dfail:0 fail:0 skip:30 time:482s fi-bxt-j4205 total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:488s fi-byt-j1900 total:288 pass:253 dwarn:0 dfail:0 fail:0 skip:35 time:467s fi-byt-n2820 total:288 pass:249 dwarn:0 dfail:0 fail:0 skip:39 time:461s fi-elk-e7500 total:224 pass:168 dwarn:10 dfail:0 fail:0 skip:45 fi-gdg-551 total:288 pass:179 dwarn:0 dfail:0 fail:1 skip:108 time:273s fi-glk-1 total:288 pass:260 dwarn:0 dfail:0 fail:0 skip:28 time:511s fi-hsw-4770 total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:392s fi-hsw-4770r total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:403s fi-ilk-650 total:288 pass:228 dwarn:0 dfail:0 fail:0 skip:60 time:411s fi-ivb-3520m total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:461s fi-ivb-3770 total:288 pass:255 dwarn:0 dfail:0 fail:0 skip:33 time:416s fi-kbl-7500u total:288 pass:263 dwarn:1 dfail:0 fail:0 skip:24 time:467s fi-kbl-7560u total:288 pass:269 dwarn:0 dfail:0 fail:0 skip:19 time:498s fi-kbl-7567u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:457s fi-kbl-r total:288 pass:260 dwarn:1 dfail:0 fail:0 skip:27 time:503s fi-pnv-d510 total:288 pass:222 dwarn:1 dfail:0 fail:0 skip:65 time:578s fi-skl-6260u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:431s fi-skl-6600u total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:509s fi-skl-6700hq total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:529s fi-skl-6700k2 total:108 pass:96 dwarn:0 dfail:0 fail:0 skip:11 fi-skl-6770hq total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:489s fi-skl-gvtdvm total:288 pass:265 dwarn:0 dfail:0 fail:0 skip:23 time:431s fi-snb-2520m total:288 pass:248 dwarn:0 dfail:0 fail:0 skip:40 time:538s fi-snb-2600 total:288 pass:248 dwarn:0 dfail:0 fail:0 skip:40 time:395s Blacklisted hosts: fi-cfl-s2 total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:573s fi-glk-dsi total:288 pass:258 dwarn:0 dfail:0 fail:0 skip:30 time:472s
fcf7fdfd2db6cfe8e529c79c5822f555a8b38fd4 drm-tip: 2018y-01m-12d-17h-40m-49s UTC integration manifest ef67bfb35c68 drm/i915: Estimate and update missed vblanks.b1edcc47812a drm/vblank: Restoring vblank counts after device PM events. 365390c83462 drm/vblank: Do not update vblank count if interrupts are already disabled. 18e5209cfde5 drm/vblank: Fix data type width for drm_crtc_arm_vblank_event() 60165b22a0be drm/vblank: Fix return type for drm_vblank_count()
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7660/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.IGT: failure for series starting with [1/5] drm/vblank: Fix return type for drm_vblank_count()
In reply to Dhinakaran Pandiyan== Series Details ==
== Series Details ==
Series: series starting with [1/5] drm/vblank: Fix return type for drm_vblank_count()
URL : https://patchwork.freedesktop.org/series/36435/
State : failure
== Summary ==
Test gem_caching:
Subgroup writes:
pass -> INCOMPLETE (shard-snb)
Test kms_frontbuffer_tracking:
Subgroup fbc-1p-pri-indfb-multidraw:
pass -> FAIL (shard-snb) fdo#103167
Subgroup fbc-1p-offscren-pri-shrfb-draw-blt:
pass -> FAIL (shard-snb) fdo#101623 +1
Test kms_flip:
Subgroup vblank-vs-suspend-interruptible:
incomplete -> PASS (shard-hsw) fdo#100368 +1
Subgroup vblank-vs-suspend:
pass -> SKIP (shard-snb) fdo#102365fdo#103167
fdo#101623
fdo#100368
fdo#102365
shard-hsw total:2713 pass:1537 dwarn:1 dfail:0 fail:10 skip:1165 time:9012s shard-snb total:2683 pass:1294 dwarn:1 dfail:0 fail:12 skip:1375 time:7610s Blacklisted hosts: shard-apl total:2713 pass:1687 dwarn:1 dfail:0 fail:24 skip:1001 time:13691s shard-kbl total:2708 pass:1804 dwarn:5 dfail:0 fail:24 skip:874 time:10328s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7660/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 8 lines · Dhinakaran Pandiyan
drm_vblank_count()has a u32 type returning what is a 64-bit vblank count. The effect of this is whendrm_wait_vblank_ioctl()tries to widen the user space requested vblank sequence using this clipped 32-bit count(when the value is >= 2^32) as reference, the requested sequence remains a 32-bit value and gets queued like that. However, the code that checks if the requested sequence has passed compares this against the 64-bit vblank count.
Quoted 4 lines
Cc Keith Packard <[email protected]>Cc Michel Dänzer <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Dhinakaran Pandiyan <[email protected]>
Sounds like the 64bit widening wasn't all that well tested ... do we have an igt for this? Iirc the base igt was merged already. -Daniel
Quoted 20 lines
--- drivers/gpu/drm/drm_vblank.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/drm_vblank.c +1
-1@@ -271,7 +271,7 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,store_vblank (dev, pipe, diff, t_vblank, cur_vblank); } -static u32 drm_vblank_count (struct drm_device *dev,unsigned int pipe) +static u64 drm_vblank_count (struct drm_device *dev,unsigned int pipe) {struct drm_vblank_crtc *vblank = &dev->vblank[pipe];Signature · 1 line
2.11.0
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 9 lines · Daniel Vetter
Quoted 8 lines · Dhinakaran Pandiyan
drm_vblank_count()has a u32 type returning what is a 64-bit vblank count. The effect of this is whendrm_wait_vblank_ioctl()tries to widen the user space requested vblank sequence using this clipped 32-bit count(when the value is >= 2^32) as reference, the requested sequence remains a 32-bit value and gets queued like that. However, the code that checks if the requested sequence has passed compares this against the 64-bit vblank count.
Quoted 7 lines
Quoted 4 lines
Cc Keith Packard <[email protected]>Cc Michel Dänzer <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Dhinakaran Pandiyan <[email protected]>Sounds like the 64bit widening wasn't all that well tested ... do we have an igt for this? Iirc the base igt was merged already.
I don't see anything that would particularly trigger this condition i.e., vblank->count > 2^32 in the IGTs. We'll need to implement something to force set a very large vblank->count and then request a vblank sequence.
Quoted 14 lines
-Daniel
Quoted 12 lines
--- drivers/gpu/drm/drm_vblank.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/drm_vblank.c +0
-0@@ -271,7 +271,7 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,store_vblank (dev, pipe, diff, t_vblank, cur_vblank); }
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/drm_vblank.c +1
-1-static u32 drm_vblank_count (struct drm_device *dev,unsigned int pipe) +static u64 drm_vblank_count (struct drm_device *dev,unsigned int pipe) {struct drm_vblank_crtc *vblank = &dev->vblank[pipe];Signature · 1 line
2.11.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
ping for review.
Let me know if there's anything that needs to be done, thanks!
Quoted 21 lines · Dhinakaran Pandiyan
drm_vblank_count()has a u32 type returning what is a 64-bit vblank count. The effect of this is whendrm_wait_vblank_ioctl()tries to widen the user space requested vblank sequence using this clipped 32-bit count(when the value is >= 2^32) as reference, the requested sequence remains a 32-bit value and gets queued like that. However, the code that checks if the requested sequence has passed compares this against the 64-bit vblank count.Cc Keith Packard <[email protected]>Cc Michel Dänzer <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Dhinakaran Pandiyan <[email protected]>--- drivers/gpu/drm/drm_vblank.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/drm_vblank.c +0
-0
drivers/gpu/drm/drm_vblank.c static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe, · line 277
Quoted 8 lines
drivers/gpu/drm/drm_vblank.c +1
-1@@ -271,7 +271,7 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,store_vblank (dev, pipe, diff, t_vblank, cur_vblank); } -static u32 drm_vblank_count (struct drm_device *dev,unsigned int pipe) +static u64 drm_vblank_count (struct drm_device *dev,unsigned int pipe) {struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Rodrigo Vivi
maintainerQuoted 1 line · Dhinakaran
ping for review.
sorry for not getting back sooner here.
But yey \o/
I finally have dmc and psr working well on my own laptop! so far so good! :)
Quoted 29 lines
Let me know if there's anything that needs to be done, thanks!
Quoted 24 lines · Dhinakaran Pandiyan
drm_vblank_count()has a u32 type returning what is a 64-bit vblank count. The effect of this is whendrm_wait_vblank_ioctl()tries to widen the user space requested vblank sequence using this clipped 32-bit count(when the value is >= 2^32) as reference, the requested sequence remains a 32-bit value and gets queued like that. However, the code that checks if the requested sequence has passed compares this against the 64-bit vblank count.Cc Keith Packard <[email protected]>Cc Michel Dänzer <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Dhinakaran Pandiyan <[email protected]>--- drivers/gpu/drm/drm_vblank.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/drm_vblank.c +0
-0@@ -271,7 +271,7 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,store_vblank (dev, pipe, diff, t_vblank, cur_vblank); }
Quoted 5 lines
drivers/gpu/drm/drm_vblank.c static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe, · line 277
Quoted 5 lines
drivers/gpu/drm/drm_vblank.c +1
-1-static u32 drm_vblank_count (struct drm_device *dev,unsigned int pipe) +static u64 drm_vblank_count (struct drm_device *dev,unsigned int pipe) {struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 7 lines · Dhinakaran Pandiyan
drm_vblank_count()has a u32 type returning what is a 64-bit vblank count. The effect of this is whendrm_wait_vblank_ioctl()tries to widen the user space requested vblank sequence using this clipped 32-bit count(when the value is >= 2^32) as reference, the requested sequence remains a 32-bit value and gets queued like that. However, the code that checks if the requested sequence has passed compares this against the 64-bit vblank count.
Worth to mention and probably
btw, I spotted at least one more place even with the series applied. 32 current_vblank; at drm_mode_page_flip_ioctl...
so, probably worth to do a deeper check down to all paths...
anayway, for this patch:
Quoted 25 lines
Cc Keith Packard <[email protected]>Cc Michel Dänzer <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Dhinakaran Pandiyan <[email protected]>--- drivers/gpu/drm/drm_vblank.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/drm_vblank.c +1
-1@@ -271,7 +271,7 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,store_vblank (dev, pipe, diff, t_vblank, cur_vblank); } -static u32 drm_vblank_count (struct drm_device *dev,unsigned int pipe) +static u64 drm_vblank_count (struct drm_device *dev,unsigned int pipe) {struct drm_vblank_crtc *vblank = &dev->vblank[pipe];Signature · 1 line
2.11.0
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 9 lines · Rodrigo Vivi
Quoted 7 lines · Dhinakaran Pandiyan
drm_vblank_count()has a u32 type returning what is a 64-bit vblank count. The effect of this is whendrm_wait_vblank_ioctl()tries to widen the user space requested vblank sequence using this clipped 32-bit count(when the value is >= 2^32) as reference, the requested sequence remains a 32-bit value and gets queued like that. However, the code that checks if the requested sequence has passed compares this against the 64-bit vblank count.
Quoted 6 lines
Worth to mention and probably
Fixes 570e86963a51 ("drm: Widen vblank count to 64-bits [v3]")btw, I spotted at least one more place even with the series applied. 32
current_vblank; atdrm_mode_page_flip_ioctl...
There seem to be several such callers for drm_crtc_vblank_count(). I can fix it up as a follow-up series.
Quoted 27 lines
so, probably worth to do a deeper check down to all paths...
anayway, for this patch:
Reviewed-by Rodrigo Vivi <[email protected]>Quoted 22 lines
Cc Keith Packard <[email protected]>Cc Michel Dänzer <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Dhinakaran Pandiyan <[email protected]>--- drivers/gpu/drm/drm_vblank.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/drm_vblank.c +1
-1@@ -271,7 +271,7 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,store_vblank (dev, pipe, diff, t_vblank, cur_vblank); } -static u32 drm_vblank_count (struct drm_device *dev,unsigned int pipe) +static u64 drm_vblank_count (struct drm_device *dev,unsigned int pipe) {struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
Quoted 7 lines
Quoted 3 lines
Signature · 1 line
2.11.0_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 2 lines · Dhinakaran Pandiyan
drm_vblank_count()has a u32 type returning what is a 64-bit vblank count.
It looks like a general review of the 64-bit widening patch is needed.
* drm_crtc_accurate_vblank_count has a 32-bit return, and uses a 32-bit temporary
* drm_wait_one_vblank uses a 32-bit temporary.
I looked at every 'u32' in drm_vblank.c; it would be good to have more eyes check this.
Thanks for finding the first one.
Signature · 1 line
-keith
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel