FBC bug fixes
Subsystems (2)
cover FBC bug fixes
Hello
This series contains tons of bug fixes for FBC. Some of the patches on this series have seen the mailing list a few times already. With this series applied, my BDW machine passes all the FBC tests that are on IGT.
This means we could even try to enable FBC on BDW by default, but I won't put this patch as part of the series since I want QA to confirm everything passes before we make this move. In the meantime, there are some optimizations I want to do, and SKL to fix.
Thanks,
Paulo
Paulo Zanoni (16):
drm/i915: make sure we're not changing the FBC CFB with FBC enabled drm/i915: fix the FBC work allocation failure path drm/i915: fix FBC for cases where crtc->base.y is non-zero drm/i915: set ILK_DPFC_FENCE_YOFF to 0 on SNB
drm/i915: check for the supported strides on HSW+ FBC drm/i915: try a little harder to find an FBC CRTC drm/i915: disable FBC on FIFO underruns
drm/i915: avoid the last 8mb of stolen on BDW/SKL drm/i915: print the correct amount of bytes allocated for the CFB drm/i915: fix CFB size calculation
drm/i915/bdw: don't enable FBC when pixel rate exceeds 95% drm/i915: apply WaFbcAsynchFlipDisableFbcQueue earlier drm/i915: don't use the first stolen page on Broadwell drm/i915: don't apply WaFbcAsynchFlipDisableFbcQueue on SKL Revert "drm/i915: Allocate fbcon from stolen memory" drm/i915: reject invalid formats for FBC
drivers/gpu/drm/i915/i915_drv.h | 12 ++ drivers/gpu/drm/i915/i915_gem_gtt.h | 1 + drivers/gpu/drm/i915/i915_gem_stolen.c | 29 +++- drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_fbc.c | 233 +++++++++++++++++++++++++---- drivers/gpu/drm/i915/intel_fbdev.c | 4 +- drivers/gpu/drm/i915/intel_fifo_underrun.c | 2 + 7 files changed, 242 insertions(+), 40 deletions(-)
Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/16 drm/i915: make sure we're not changing the FBC CFB with FBC enabled
We used to have this bug in the past, but now that we properly track the size of the CFB, we don't have it anymore. Still, add the WARN just to make sure we don't go back to the bad state.
--- drivers/gpu/drm/i915/intel_fbc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/intel_fbc.c +2 -0
@@ -589,6 +589,8 @@ static int intel_fbc_alloc_cfb(struct drm_i915_private *dev_priv, int size, dev_priv->fbc.threshold = ret; +WARN_ON (dev_priv->fbc.enabled); +if (INTEL_INFO (dev_priv)->gen >=5 )I915_WRITE (ILK_DPFC_CB_BASE , dev_priv->fbc.compressed_fb.start);else if (IS_GM45 (dev_priv)) {
Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 01/16] drm/i915: make sure we're not changing the FBC CFB with FBC enabled
Quoted 14 lines · Paulo Zanoni
We used to have this bug in the past, but now that we properly track the size of the CFB, we don't have it anymore. Still, add the WARN just to make sure we don't go back to the bad state.
Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/intel_fbc.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/i915/intel_fbc.c +0
-0
drivers/gpu/drm/i915/intel_fbc.c static int intel_fbc_alloc_cfb(struct drm_i915_private *dev_priv, int size, · line 593
Quoted 5 lines
drivers/gpu/drm/i915/intel_fbc.c +2
-0@@ -589,6 +589,8 @@ static int intel_fbc_alloc_cfb(struct drm_i915_private *dev_priv, int size, dev_priv->fbc.threshold = ret; +WARN_ON (dev_priv->fbc.enabled); +
We should really check it already before we free the stolen memory (or maybe sprinkle it to both places?), and we should make sure FBC really got disabled, ie. at last one vblank must have occured since the enable bit was cleared.
Since we lack the vblank workers, I think having this WARN before the stolen is freed, with a FIXME about the disable vs. vblank issue would be acceptable.
Quoted 10 lines
drivers/gpu/drm/i915/intel_fbc.c +0
-0if (INTEL_INFO (dev_priv)->gen >=5 )I915_WRITE (ILK_DPFC_CB_BASE , dev_priv->fbc.compressed_fb.start);else if (IS_GM45 (dev_priv)) {Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/16 drm/i915: fix the FBC work allocation failure path
In reply to Paulo ZanoniAlways update the currrent crtc, fb and vertical offset after calling enable_fbc. We were forgetting to do so along the failure paths when enabling fbc synchronously. Fix this with a new helper to enable_fbc() and update the state simultaneously.
v2: Improve commit message (Chris).
--- drivers/gpu/drm/i915/intel_fbc.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/intel_fbc.c +17 -10
@@ -308,6 +308,18 @@ bool intel_fbc_enabled(struct drm_i915_private *dev_priv)return dev_priv->fbc.enabled; } +static void intel_fbc_enable (struct intel_crtc *crtc, +struct drm_framebuffer *fb) +{ +struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; + + dev_priv->fbc.enable_fbc (crtc); + + dev_priv->fbc.crtc = crtc; + dev_priv->fbc.fb_id = fb->base.id; + dev_priv->fbc.y = crtc->base.y; +} +static void intel_fbc_work_fn (struct work_struct *__work) { struct intel_fbc_work *work =
@@ -321,13 +333,8 @@ static void intel_fbc_work_fn(struct work_struct *__work)/* Double check that we haven't switched fb without cancelling * the prior work. */ -if (crtc_fb == work->fb) { - dev_priv->fbc.enable_fbc (work->crtc); - - dev_priv->fbc.crtc = work->crtc; - dev_priv->fbc.fb_id = crtc_fb->base.id; - dev_priv->fbc.y = work->crtc->base.y; - } +if (crtc_fb == work->fb) +intel_fbc_enable (work->crtc, work->fb); dev_priv->fbc.fbc_work =NULL ; }
@@ -361,7 +368,7 @@ static void intel_fbc_cancel_work(struct drm_i915_private *dev_priv) dev_priv->fbc.fbc_work =NULL ; } -static void intel_fbc_enable (struct intel_crtc *crtc) +static void intel_fbc_schedule_enable (struct intel_crtc *crtc) {struct intel_fbc_work *work;struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
@@ -373,7 +380,7 @@ static void intel_fbc_enable(struct intel_crtc *crtc) work =kzalloc (sizeof (*work),GFP_KERNEL );if (work ==NULL ) {DRM_ERROR ("Failed to allocate FBC work structure\n" ); - dev_priv->fbc.enable_fbc (crtc); +intel_fbc_enable (crtc, crtc->base.primary->fb);return ; }
@@ -826,7 +833,7 @@ static void __intel_fbc_update(struct drm_i915_private *dev_priv)__intel_fbc_disable (dev_priv); } -intel_fbc_enable (intel_crtc); +intel_fbc_schedule_enable (intel_crtc); dev_priv->fbc.no_fbc_reason =FBC_OK ;return ;
Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 02/16] drm/i915: fix the FBC work allocation failure path
Quoted 17 lines · Paulo Zanoni
Always update the currrent crtc, fb and vertical offset after calling
enable_fbc. We were forgetting to do so along the failure paths when enabling fbc synchronously. Fix this with a new helper toenable_fbc()and update the state simultaneously.v2: Improve commit message (Chris).
Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/intel_fbc.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)drivers/gpu/drm/i915/intel_fbc.c +0
-0
drivers/gpu/drm/i915/intel_fbc.c bool intel_fbc_enabled(struct drm_i915_private *dev_priv) · line 312
Quoted 5 lines
drivers/gpu/drm/i915/intel_fbc.c +2
-0@@ -308,6 +308,18 @@ bool intel_fbc_enabled(struct drm_i915_private *dev_priv)return dev_priv->fbc.enabled; } +static void intel_fbc_enable (struct intel_crtc *crtc, +struct drm_framebuffer *fb)
fb could be const
Quoted 16 lines
drivers/gpu/drm/i915/intel_fbc.c +10
-0+{ +struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; + + dev_priv->fbc.enable_fbc (crtc); + + dev_priv->fbc.crtc = crtc; + dev_priv->fbc.fb_id = fb->base.id; + dev_priv->fbc.y = crtc->base.y; +} +static void intel_fbc_work_fn (struct work_struct *__work) { struct intel_fbc_work *work =@@ -321,13 +333,8 @@ static void intel_fbc_work_fn(struct work_struct *__work)/* Double check that we haven't switched fb without cancelling * the prior work.
drivers/gpu/drm/i915/intel_fbc.c static void intel_fbc_work_fn(struct work_struct *__work) · line 337
Quoted 10 lines
drivers/gpu/drm/i915/intel_fbc.c +2
-7*/ -if (crtc_fb == work->fb) { - dev_priv->fbc.enable_fbc (work->crtc); - - dev_priv->fbc.crtc = work->crtc; - dev_priv->fbc.fb_id = crtc_fb->base.id; - dev_priv->fbc.y = work->crtc->base.y; - } +if (crtc_fb == work->fb) +intel_fbc_enable (work->crtc, work->fb);
The no locking or refcounts nature of this scares me, and should be dealt with eventually.
But in the meantime it makes things nicer, so
Quoted 13 lines
drivers/gpu/drm/i915/intel_fbc.c +1
-1dev_priv->fbc.fbc_work =NULL ; }@@ -361,7 +368,7 @@ static void intel_fbc_cancel_work(struct drm_i915_private *dev_priv) dev_priv->fbc.fbc_work =NULL ; } -static void intel_fbc_enable (struct intel_crtc *crtc) +static void intel_fbc_schedule_enable (struct intel_crtc *crtc) {struct intel_fbc_work *work;struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
drivers/gpu/drm/i915/intel_fbc.c static void intel_fbc_enable(struct intel_crtc *crtc) · line 385
Quoted 7 lines
drivers/gpu/drm/i915/intel_fbc.c +1
-1@@ -373,7 +380,7 @@ static void intel_fbc_enable(struct intel_crtc *crtc) work =kzalloc (sizeof (*work),GFP_KERNEL );if (work ==NULL ) {DRM_ERROR ("Failed to allocate FBC work structure\n" ); - dev_priv->fbc.enable_fbc (crtc); +intel_fbc_enable (crtc, crtc->base.primary->fb);return ; }
BTW getting rid of this allocation would be nice. Would be one less thing that can fail...
Quoted 17 lines
drivers/gpu/drm/i915/intel_fbc.c +1
-1@@ -826,7 +833,7 @@ static void __intel_fbc_update(struct drm_i915_private *dev_priv)__intel_fbc_disable (dev_priv); } -intel_fbc_enable (intel_crtc); +intel_fbc_schedule_enable (intel_crtc); dev_priv->fbc.no_fbc_reason =FBC_OK ;return ;Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 02/16] drm/i915: fix the FBC work allocation failure path
2015-08-28 11:20 GMT-03:00 Ville Syrjälä <[email protected]>:
Quoted 21 lines · Paulo Zanoni
Quoted 20 lines
Always update the currrent crtc, fb and vertical offset after calling
enable_fbc. We were forgetting to do so along the failure paths when enabling fbc synchronously. Fix this with a new helper toenable_fbc()and update the state simultaneously.v2: Improve commit message (Chris).
Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/intel_fbc.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)drivers/gpu/drm/i915/intel_fbc.c +0
-0@@ -308,6 +308,18 @@ bool intel_fbc_enabled(struct drm_i915_private *dev_priv)return dev_priv->fbc.enabled; }
Quoted 4 lines
drivers/gpu/drm/i915/intel_fbc.c bool intel_fbc_enabled(struct drm_i915_private *dev_priv) · line 312
Quoted 2 lines
drivers/gpu/drm/i915/intel_fbc.c +2
-0+static void intel_fbc_enable (struct intel_crtc *crtc, +struct drm_framebuffer *fb)fb could be const
I guess a lot of things could be constified, if we decide to do this.
Quoted 41 lines
Quoted 17 lines
drivers/gpu/drm/i915/intel_fbc.c +10
-0+{ +struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; + + dev_priv->fbc.enable_fbc (crtc); + + dev_priv->fbc.crtc = crtc; + dev_priv->fbc.fb_id = fb->base.id; + dev_priv->fbc.y = crtc->base.y; +} +static void intel_fbc_work_fn (struct work_struct *__work) { struct intel_fbc_work *work =@@ -321,13 +333,8 @@ static void intel_fbc_work_fn(struct work_struct *__work)/* Double check that we haven't switched fb without cancelling * the prior work. drivers/gpu/drm/i915/intel_fbc.c static void intel_fbc_work_fn(struct work_struct *__work) · line 337
Quoted 10 lines
drivers/gpu/drm/i915/intel_fbc.c +2
-7*/ -if (crtc_fb == work->fb) { - dev_priv->fbc.enable_fbc (work->crtc); - - dev_priv->fbc.crtc = work->crtc; - dev_priv->fbc.fb_id = crtc_fb->base.id; - dev_priv->fbc.y = work->crtc->base.y; - } +if (crtc_fb == work->fb) +intel_fbc_enable (work->crtc, work->fb);The no locking or refcounts nature of this scares me, and should be dealt with eventually.
But in the meantime it makes things nicer, so
Reviewed-by Ville Syrjälä <[email protected]>Quoted 7 lines
drivers/gpu/drm/i915/intel_fbc.c +0
-0dev_priv->fbc.fbc_work =NULL ; }@@ -361,7 +368,7 @@ static void intel_fbc_cancel_work(struct drm_i915_private *dev_priv) dev_priv->fbc.fbc_work =NULL ; }
Quoted 16 lines
drivers/gpu/drm/i915/intel_fbc.c static void intel_fbc_enable(struct intel_crtc *crtc) · line 385
Quoted 13 lines
drivers/gpu/drm/i915/intel_fbc.c +2
-2-static void intel_fbc_enable (struct intel_crtc *crtc) +static void intel_fbc_schedule_enable (struct intel_crtc *crtc) {struct intel_fbc_work *work;struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;@@ -373,7 +380,7 @@ static void intel_fbc_enable(struct intel_crtc *crtc) work =kzalloc (sizeof (*work),GFP_KERNEL );if (work ==NULL ) {DRM_ERROR ("Failed to allocate FBC work structure\n" ); - dev_priv->fbc.enable_fbc (crtc); +intel_fbc_enable (crtc, crtc->base.primary->fb);return ; }BTW getting rid of this allocation would be nice. Would be one less thing that can fail...
Chris disagrees :)
Quoted 26 lines
Quoted 14 lines
drivers/gpu/drm/i915/intel_fbc.c +1
-2@@ -826,7 +833,7 @@ static void __intel_fbc_update(struct drm_i915_private *dev_priv)__intel_fbc_disable (dev_priv); } -intel_fbc_enable (intel_crtc); +intel_fbc_schedule_enable (intel_crtc); dev_priv->fbc.no_fbc_reason =FBC_OK ;return ; --2.4.6
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx--
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 5 lines
Paulo Zanoni _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 02/16] drm/i915: fix the FBC work allocation failure path
Quoted 87 lines · Paulo Zanoni
2015-08-28 11:20 GMT-03:00 Ville Syrjälä <[email protected]>:
Quoted 21 lines · Paulo Zanoni
Quoted 20 lines
Always update the currrent crtc, fb and vertical offset after calling
enable_fbc. We were forgetting to do so along the failure paths when enabling fbc synchronously. Fix this with a new helper toenable_fbc()and update the state simultaneously.v2: Improve commit message (Chris).
Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/intel_fbc.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)drivers/gpu/drm/i915/intel_fbc.c +0
-0@@ -308,6 +308,18 @@ bool intel_fbc_enabled(struct drm_i915_private *dev_priv)return dev_priv->fbc.enabled; }Quoted 4 lines
drivers/gpu/drm/i915/intel_fbc.c bool intel_fbc_enabled(struct drm_i915_private *dev_priv) · line 312
Quoted 2 lines
drivers/gpu/drm/i915/intel_fbc.c +2
-0+static void intel_fbc_enable (struct intel_crtc *crtc, +struct drm_framebuffer *fb)fb could be const
I guess a lot of things could be constified, if we decide to do this.
Quoted 41 lines
Quoted 17 lines
drivers/gpu/drm/i915/intel_fbc.c +10
-0+{ +struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; + + dev_priv->fbc.enable_fbc (crtc); + + dev_priv->fbc.crtc = crtc; + dev_priv->fbc.fb_id = fb->base.id; + dev_priv->fbc.y = crtc->base.y; +} +static void intel_fbc_work_fn (struct work_struct *__work) { struct intel_fbc_work *work =@@ -321,13 +333,8 @@ static void intel_fbc_work_fn(struct work_struct *__work)/* Double check that we haven't switched fb without cancelling * the prior work. drivers/gpu/drm/i915/intel_fbc.c static void intel_fbc_work_fn(struct work_struct *__work) · line 337
Quoted 10 lines
drivers/gpu/drm/i915/intel_fbc.c +2
-7*/ -if (crtc_fb == work->fb) { - dev_priv->fbc.enable_fbc (work->crtc); - - dev_priv->fbc.crtc = work->crtc; - dev_priv->fbc.fb_id = crtc_fb->base.id; - dev_priv->fbc.y = work->crtc->base.y; - } +if (crtc_fb == work->fb) +intel_fbc_enable (work->crtc, work->fb);The no locking or refcounts nature of this scares me, and should be dealt with eventually.
But in the meantime it makes things nicer, so
Reviewed-by Ville Syrjälä <[email protected]>Quoted 7 lines
drivers/gpu/drm/i915/intel_fbc.c +0
-0dev_priv->fbc.fbc_work =NULL ; }@@ -361,7 +368,7 @@ static void intel_fbc_cancel_work(struct drm_i915_private *dev_priv) dev_priv->fbc.fbc_work =NULL ; }Quoted 16 lines
drivers/gpu/drm/i915/intel_fbc.c static void intel_fbc_enable(struct intel_crtc *crtc) · line 385
Quoted 13 lines
drivers/gpu/drm/i915/intel_fbc.c +2
-2-static void intel_fbc_enable (struct intel_crtc *crtc) +static void intel_fbc_schedule_enable (struct intel_crtc *crtc) {struct intel_fbc_work *work;struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;@@ -373,7 +380,7 @@ static void intel_fbc_enable(struct intel_crtc *crtc) work =kzalloc (sizeof (*work),GFP_KERNEL );if (work ==NULL ) {DRM_ERROR ("Failed to allocate FBC work structure\n" ); - dev_priv->fbc.enable_fbc (crtc); +intel_fbc_enable (crtc, crtc->base.primary->fb);return ; }BTW getting rid of this allocation would be nice. Would be one less thing that can fail...
Quoted 1 line
Chris disagrees :)
He's wrong ;)
Quoted 33 lines
Quoted 28 lines
Quoted 16 lines
drivers/gpu/drm/i915/intel_fbc.c +1
-2@@ -826,7 +833,7 @@ static void __intel_fbc_update(struct drm_i915_private *dev_priv)__intel_fbc_disable (dev_priv); } -intel_fbc_enable (intel_crtc); +intel_fbc_schedule_enable (intel_crtc); dev_priv->fbc.no_fbc_reason =FBC_OK ;return ; --2.4.6
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx--
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfxSignature · 1 line
Paulo Zanoni
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 02/16] drm/i915: fix the FBC work allocation failure path
In reply to Paulo ZanoniQuoted 22 lines · Paulo Zanoni
2015-08-28 11:20 GMT-03:00 Ville Syrjälä <[email protected]>:
Quoted 21 lines · Paulo Zanoni
Quoted 20 lines
Always update the currrent crtc, fb and vertical offset after calling
enable_fbc. We were forgetting to do so along the failure paths when enabling fbc synchronously. Fix this with a new helper toenable_fbc()and update the state simultaneously.v2: Improve commit message (Chris).
Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/intel_fbc.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)drivers/gpu/drm/i915/intel_fbc.c +0
-0@@ -308,6 +308,18 @@ bool intel_fbc_enabled(struct drm_i915_private *dev_priv)return dev_priv->fbc.enabled; }
Quoted 6 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_fbc.c bool intel_fbc_enabled(struct drm_i915_private *dev_priv) · line 312
Quoted 2 lines
drivers/gpu/drm/i915/intel_fbc.c +2
-0+static void intel_fbc_enable (struct intel_crtc *crtc, +struct drm_framebuffer *fb)fb could be const
I guess a lot of things could be constified, if we decide to do this.
Personally I like const on .data (especially vfunc tables since those are nice to create exploits if they're writable and you can get at them). And for core functions/vfuncs where the const has a semantic meaning. Otherwise I personally don't see to much value in sprinkling const all over.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 02/16] drm/i915: fix the FBC work allocation failure path
Quoted 28 lines · Daniel Vetter
Quoted 27 lines · Paulo Zanoni
2015-08-28 11:20 GMT-03:00 Ville Syrjälä <[email protected]>:
Quoted 25 lines · Paulo Zanoni
Quoted 17 lines
Always update the currrent crtc, fb and vertical offset after calling
enable_fbc. We were forgetting to do so along the failure paths when enabling fbc synchronously. Fix this with a new helper toenable_fbc()and update the state simultaneously.v2: Improve commit message (Chris).
Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/intel_fbc.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)drivers/gpu/drm/i915/intel_fbc.c +0
-0drivers/gpu/drm/i915/intel_fbc.c bool intel_fbc_enabled(struct drm_i915_private *dev_priv) · line 312
Quoted 5 lines
drivers/gpu/drm/i915/intel_fbc.c +2
-0@@ -308,6 +308,18 @@ bool intel_fbc_enabled(struct drm_i915_private *dev_priv)return dev_priv->fbc.enabled; } +static void intel_fbc_enable (struct intel_crtc *crtc, +struct drm_framebuffer *fb)fb could be const
Quoted 7 lines
Quoted 1 line
I guess a lot of things could be constified, if we decide to do this.
Personally I like const on .data (especially vfunc tables since those are nice to create exploits if they're writable and you can get at them). And for core functions/vfuncs where the const has a semantic meaning. Otherwise I personally don't see to much value in sprinkling const all over.
I especially like making display mode, state, etc. structs const to make it clear which functions can change them and which can't. IMO drm_framebuffer could use the same treatment.
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 02/16] drm/i915: fix the FBC work allocation failure path
Quoted 37 lines · Ville Syrjälä
Quoted 28 lines · Daniel Vetter
Quoted 27 lines · Paulo Zanoni
2015-08-28 11:20 GMT-03:00 Ville Syrjälä <[email protected]>:
Quoted 25 lines · Paulo Zanoni
Quoted 17 lines
Always update the currrent crtc, fb and vertical offset after calling
enable_fbc. We were forgetting to do so along the failure paths when enabling fbc synchronously. Fix this with a new helper toenable_fbc()and update the state simultaneously.v2: Improve commit message (Chris).
Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/intel_fbc.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)drivers/gpu/drm/i915/intel_fbc.c +0
-0drivers/gpu/drm/i915/intel_fbc.c bool intel_fbc_enabled(struct drm_i915_private *dev_priv) · line 312
Quoted 5 lines
drivers/gpu/drm/i915/intel_fbc.c +2
-0@@ -308,6 +308,18 @@ bool intel_fbc_enabled(struct drm_i915_private *dev_priv)return dev_priv->fbc.enabled; } +static void intel_fbc_enable (struct intel_crtc *crtc, +struct drm_framebuffer *fb)fb could be const
Quoted 7 lines
Quoted 1 line
I guess a lot of things could be constified, if we decide to do this.
Personally I like const on .data (especially vfunc tables since those are nice to create exploits if they're writable and you can get at them). And for core functions/vfuncs where the const has a semantic meaning. Otherwise I personally don't see to much value in sprinkling const all over.
Quoted 3 lines
I especially like making display mode, state, etc. structs const to make it clear which functions can change them and which can't. IMO
drm_framebuffercould use the same treatment.
Yeah I guess making a few things in the drm core static could be useful indeed, for example plane_state->fb reall should be static, or crtc_state->mode_blob (or any other fb or blob pointer in state structures). Same for all the {plane, connector, crtc}->state pointers (although that would need some casts in swap_states()). I'm not too sure how much benefit there is if we do this just in i915, since if the top-level entry points called from drm core aren't enforcing constness trying to do it in i915 only will probably be an endless effort of fixing things up all the time.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/16 drm/i915: fix FBC for cases where crtc->base.y is non-zero
In reply to Paulo ZanoniI only tested this on BDW, but since the register description is the same ever since gen4, let's assume that all gens take the same register format. If that's not true, then hopefully someone will bisect a bug to this patch and we'll fix it.
Notice that the wrong fence offset register just means that the hardware tracking will be wrong.
Testcases:
- igt/kms_frontbuffer_tracking/fbc-1p-primscrn-pri-shrfb-draw-mmap-gtt
- igt/kms_frontbuffer_tracking/fbc-2p-primscrn-pri-shrfb-draw-mmap-gtt
--- drivers/gpu/drm/i915/intel_fbc.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_fbc.c +21 -5
@@ -64,6 +64,20 @@ static void i8xx_fbc_disable(struct drm_i915_private *dev_priv)DRM_DEBUG_KMS ("disabled FBC\n" ); } +static unsigned int get_crtc_fence_y_offset (struct intel_crtc *crtc) +{ +struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; +struct drm_framebuffer *fb = crtc->base.primary->fb; +unsigned int tile_height; + + tile_height =intel_tile_height (dev_priv->dev, fb->pixel_format, + fb->modifier[0 ]); + +/* The value we want is the line number of the first tile that contains +* the first vertical line of the CRTC. */ +return crtc->base.y - (crtc->base.y % tile_height); +} +static void i8xx_fbc_enable (struct intel_crtc *crtc) {struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
@@ -97,7 +111,7 @@ static void i8xx_fbc_enable(struct intel_crtc *crtc) fbc_ctl2 =FBC_CTL_FENCE_DBL |FBC_CTL_IDLE_IMM |FBC_CTL_CPU_FENCE ; fbc_ctl2 |=FBC_CTL_PLANE (crtc->plane);I915_WRITE (FBC_CONTROL2 , fbc_ctl2); -I915_WRITE (FBC_FENCE_OFF , crtc->base.y); +I915_WRITE (FBC_FENCE_OFF ,get_crtc_fence_y_offset (crtc)); }/* enable it... */
@@ -135,7 +149,7 @@ static void g4x_fbc_enable(struct intel_crtc *crtc) dpfc_ctl |=DPFC_CTL_LIMIT_1X ; dpfc_ctl |=DPFC_CTL_FENCE_EN | obj->fence_reg; -I915_WRITE (DPFC_FENCE_YOFF , crtc->base.y); +I915_WRITE (DPFC_FENCE_YOFF ,get_crtc_fence_y_offset (crtc));/* enable it... */ I915_WRITE (DPFC_CONTROL , dpfc_ctl |DPFC_CTL_EN );
@@ -177,6 +191,7 @@ static void ilk_fbc_enable(struct intel_crtc *crtc)struct drm_i915_gem_object *obj =intel_fb_obj (fb);u32 dpfc_ctl;int threshold = dev_priv->fbc.threshold; +unsigned int y_offset; dev_priv->fbc.enabled = true;
@@ -200,7 +215,8 @@ static void ilk_fbc_enable(struct intel_crtc *crtc)if (IS_GEN5 (dev_priv)) dpfc_ctl |= obj->fence_reg; -I915_WRITE (ILK_DPFC_FENCE_YOFF , crtc->base.y); + y_offset =get_crtc_fence_y_offset (crtc); +I915_WRITE (ILK_DPFC_FENCE_YOFF , y_offset);I915_WRITE (ILK_FBC_RT_BASE ,i915_gem_obj_ggtt_offset (obj) |ILK_FBC_RT_VALID );/* enable it... */ I915_WRITE (ILK_DPFC_CONTROL , dpfc_ctl |DPFC_CTL_EN );
@@ -208,7 +224,7 @@ static void ilk_fbc_enable(struct intel_crtc *crtc)if (IS_GEN6 (dev_priv)) {I915_WRITE (SNB_DPFC_CTL_SA ,SNB_CPU_FENCE_ENABLE | obj->fence_reg); -I915_WRITE (DPFC_CPU_FENCE_OFFSET , crtc->base.y); +I915_WRITE (DPFC_CPU_FENCE_OFFSET , y_offset); }intel_fbc_nuke (dev_priv);
@@ -288,7 +304,7 @@ static void gen7_fbc_enable(struct intel_crtc *crtc)I915_WRITE (SNB_DPFC_CTL_SA ,SNB_CPU_FENCE_ENABLE | obj->fence_reg); -I915_WRITE (DPFC_CPU_FENCE_OFFSET , crtc->base.y); +I915_WRITE (DPFC_CPU_FENCE_OFFSET ,get_crtc_fence_y_offset (crtc));intel_fbc_nuke (dev_priv);
Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 03/16] drm/i915: fix FBC for cases where crtc->base.y is non-zero
Quoted 27 lines · Paulo Zanoni
I only tested this on BDW, but since the register description is the same ever since gen4, let's assume that all gens take the same register format. If that's not true, then hopefully someone will bisect a bug to this patch and we'll fix it.
Notice that the wrong fence offset register just means that the hardware tracking will be wrong.
Testcases:
- igt/kms_frontbuffer_tracking/fbc-1p-primscrn-pri-shrfb-draw-mmap-gtt
- igt/kms_frontbuffer_tracking/fbc-2p-primscrn-pri-shrfb-draw-mmap-gttSigned-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/intel_fbc.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)drivers/gpu/drm/i915/intel_fbc.c +2
-0@@ -64,6 +64,20 @@ static void i8xx_fbc_disable(struct drm_i915_private *dev_priv)DRM_DEBUG_KMS ("disabled FBC\n" ); } +static unsigned int get_crtc_fence_y_offset (struct intel_crtc *crtc) +{
drivers/gpu/drm/i915/intel_fbc.c static void i8xx_fbc_disable(struct drm_i915_private *dev_priv) · line 78
Quoted 10 lines
drivers/gpu/drm/i915/intel_fbc.c +10
-0+struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; +struct drm_framebuffer *fb = crtc->base.primary->fb; +unsigned int tile_height; + + tile_height =intel_tile_height (dev_priv->dev, fb->pixel_format, + fb->modifier[0 ]); + +/* The value we want is the line number of the first tile that contains +* the first vertical line of the CRTC. */ +return crtc->base.y - (crtc->base.y % tile_height);
As mentioned before, I believe this depends on an implementtion detail of intel_gen4_compute_page_offset(). I think it would be nicer if the callers of intel_gen4_compute_page_offset() would store the correct fbc y offset already somewhere under intel_crtc, so that you could just look it up here. That would safeguard this code from any changes in intel_gen4_compute_page_offset().
Quoted 66 lines
drivers/gpu/drm/i915/intel_fbc.c +9
-5+} +static void i8xx_fbc_enable (struct intel_crtc *crtc) {struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;@@ -97,7 +111,7 @@ static void i8xx_fbc_enable(struct intel_crtc *crtc) fbc_ctl2 =FBC_CTL_FENCE_DBL |FBC_CTL_IDLE_IMM |FBC_CTL_CPU_FENCE ; fbc_ctl2 |=FBC_CTL_PLANE (crtc->plane);I915_WRITE (FBC_CONTROL2 , fbc_ctl2); -I915_WRITE (FBC_FENCE_OFF , crtc->base.y); +I915_WRITE (FBC_FENCE_OFF ,get_crtc_fence_y_offset (crtc)); }/* enable it... */ @@ -135,7 +149,7 @@ static void g4x_fbc_enable(struct intel_crtc *crtc) dpfc_ctl |=DPFC_CTL_LIMIT_1X ; dpfc_ctl |=DPFC_CTL_FENCE_EN | obj->fence_reg; -I915_WRITE (DPFC_FENCE_YOFF , crtc->base.y); +I915_WRITE (DPFC_FENCE_YOFF ,get_crtc_fence_y_offset (crtc));/* enable it... */ I915_WRITE (DPFC_CONTROL , dpfc_ctl |DPFC_CTL_EN );@@ -177,6 +191,7 @@ static void ilk_fbc_enable(struct intel_crtc *crtc)struct drm_i915_gem_object *obj =intel_fb_obj (fb);u32 dpfc_ctl;int threshold = dev_priv->fbc.threshold; +unsigned int y_offset; dev_priv->fbc.enabled = true;@@ -200,7 +215,8 @@ static void ilk_fbc_enable(struct intel_crtc *crtc)if (IS_GEN5 (dev_priv)) dpfc_ctl |= obj->fence_reg; -I915_WRITE (ILK_DPFC_FENCE_YOFF , crtc->base.y); + y_offset =get_crtc_fence_y_offset (crtc); +I915_WRITE (ILK_DPFC_FENCE_YOFF , y_offset);I915_WRITE (ILK_FBC_RT_BASE ,i915_gem_obj_ggtt_offset (obj) |ILK_FBC_RT_VALID );/* enable it... */ I915_WRITE (ILK_DPFC_CONTROL , dpfc_ctl |DPFC_CTL_EN );@@ -208,7 +224,7 @@ static void ilk_fbc_enable(struct intel_crtc *crtc)if (IS_GEN6 (dev_priv)) {I915_WRITE (SNB_DPFC_CTL_SA ,SNB_CPU_FENCE_ENABLE | obj->fence_reg); -I915_WRITE (DPFC_CPU_FENCE_OFFSET , crtc->base.y); +I915_WRITE (DPFC_CPU_FENCE_OFFSET , y_offset); }intel_fbc_nuke (dev_priv);@@ -288,7 +304,7 @@ static void gen7_fbc_enable(struct intel_crtc *crtc)I915_WRITE (SNB_DPFC_CTL_SA ,SNB_CPU_FENCE_ENABLE | obj->fence_reg); -I915_WRITE (DPFC_CPU_FENCE_OFFSET , crtc->base.y); +I915_WRITE (DPFC_CPU_FENCE_OFFSET ,get_crtc_fence_y_offset (crtc));intel_fbc_nuke (dev_priv);Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/16 drm/i915: set ILK_DPFC_FENCE_YOFF to 0 on SNB
In reply to Paulo ZanoniThe doc is pretty clear that this register should be set to 0 on SNB. We already write y_offset to DPFC_CPU_FENCE_OFFSET a few lines below.
--- drivers/gpu/drm/i915/intel_fbc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_fbc.c +6 -1
@@ -216,7 +216,12 @@ static void ilk_fbc_enable(struct intel_crtc *crtc) dpfc_ctl |= obj->fence_reg; y_offset =get_crtc_fence_y_offset (crtc); -I915_WRITE (ILK_DPFC_FENCE_YOFF , y_offset); + +if (IS_GEN5 (dev_priv)) +I915_WRITE (ILK_DPFC_FENCE_YOFF , y_offset); +else +I915_WRITE (ILK_DPFC_FENCE_YOFF ,0 ); +I915_WRITE (ILK_FBC_RT_BASE ,i915_gem_obj_ggtt_offset (obj) |ILK_FBC_RT_VALID );/* enable it... */ I915_WRITE (ILK_DPFC_CONTROL , dpfc_ctl |DPFC_CTL_EN );
Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 04/16] drm/i915: set ILK_DPFC_FENCE_YOFF to 0 on SNB
Quoted 2 lines · Paulo Zanoni
The doc is pretty clear that this register should be set to 0 on SNB. We already write
y_offsettoDPFC_CPU_FENCE_OFFSETa few lines below.
Bspec says:
"Restriction : The CPU fence is always programmed to match the Display
Buffer base, so this offset must be programmed to 0 to match. DevSNB"
We definitely don't program the fence to match DSPSURF, so it's not very clear that this is really the right thing to do. I suppose it depends on how the Y offset in the SA register interacts with this one. I never got around to fixing the Y offset stuff in my FBC efforts, so I've not tried it on real hardware and so I have no sure answer here.
Quoted 31 lines
Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/intel_fbc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_fbc.c +6
-1@@ -216,7 +216,12 @@ static void ilk_fbc_enable(struct intel_crtc *crtc) dpfc_ctl |= obj->fence_reg; y_offset =get_crtc_fence_y_offset (crtc); -I915_WRITE (ILK_DPFC_FENCE_YOFF , y_offset); + +if (IS_GEN5 (dev_priv)) +I915_WRITE (ILK_DPFC_FENCE_YOFF , y_offset); +else +I915_WRITE (ILK_DPFC_FENCE_YOFF ,0 ); +I915_WRITE (ILK_FBC_RT_BASE ,i915_gem_obj_ggtt_offset (obj) |ILK_FBC_RT_VALID );/* enable it... */ I915_WRITE (ILK_DPFC_CONTROL , dpfc_ctl |DPFC_CTL_EN );Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 04/16] drm/i915: set ILK_DPFC_FENCE_YOFF to 0 on SNB
Em Sex, 2015-08-28 às 17:46 +0300, Ville Syrjälä escreveu:
Quoted 12 lines · Paulo Zanoni
Quoted 4 lines
The doc is pretty clear that this register should be set to 0 on SNB.
We already writey_offsettoDPFC_CPU_FENCE_OFFSETa few lines below.Bspec says:
"Restriction : The CPU fence is always programmed to match the Display
Buffer base, so this offset must be programmed to 0 to match.
DevSNB"
Quoted 9 lines
We definitely don't program the fence to match DSPSURF, so it's not very
clear that this is really the right thing to do. I suppose it depends on
how the Y offset in the SA register interacts with this one. I never got
around to fixing the Y offset stuff in my FBC efforts, so I've not tried
it on real hardware and so I have no sure answer here.
The BSpec page for DPFC Control on SNB says:
8<---------------------
Project :DEVSNB
iMPH will only send the host modify message when modifications are in the fence selected in the DPFC_CONTROL_SA register CPUFNCNUM field. The fence field in the FBC Host Modification message will always be 0 and this field must be programmed to 0 to match. 8<---------------------
(and DPFC_CONTROL_SA is register 0x100100)
Quoted 31 lines
Quoted 31 lines
Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/intel_fbc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_fbc.c +6
-1@@ -216,7 +216,12 @@ static void ilk_fbc_enable(struct intel_crtc *crtc) dpfc_ctl |= obj->fence_reg; y_offset =get_crtc_fence_y_offset (crtc); -I915_WRITE (ILK_DPFC_FENCE_YOFF , y_offset); + +if (IS_GEN5 (dev_priv)) +I915_WRITE (ILK_DPFC_FENCE_YOFF , y_offset); +else +I915_WRITE (ILK_DPFC_FENCE_YOFF ,0 ); +I915_WRITE (ILK_FBC_RT_BASE ,i915_gem_obj_ggtt_offset (obj) |ILK_FBC_RT_VALID );drivers/gpu/drm/i915/intel_fbc.c +0
-0/* enable it... */ I915_WRITE (ILK_DPFC_CONTROL , dpfc_ctl |DPFC_CTL_EN );Signature · 1 line
2.4.6
Quoted 5 lines
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 04/16] drm/i915: set ILK_DPFC_FENCE_YOFF to 0 on SNB
Quoted 25 lines · Paulo R
Em Sex, 2015-08-28 às 17:46 +0300, Ville Syrjälä escreveu:
Quoted 12 lines · Paulo Zanoni
Quoted 4 lines
The doc is pretty clear that this register should be set to 0 on SNB.
We already writey_offsettoDPFC_CPU_FENCE_OFFSETa few lines below.Bspec says:
"Restriction : The CPU fence is always programmed to match the Display
Buffer base, so this offset must be programmed to 0 to match.
DevSNB"Quoted 9 lines
We definitely don't program the fence to match DSPSURF, so it's not very
clear that this is really the right thing to do. I suppose it depends on
how the Y offset in the SA register interacts with this one. I never got
around to fixing the Y offset stuff in my FBC efforts, so I've not tried
it on real hardware and so I have no sure answer here.The BSpec page for DPFC Control on SNB says:
Quoted 7 lines
8<---------------------
Project :DEVSNB
iMPH will only send the host modify message when modifications are in the fence selected in theDPFC_CONTROL_SAregister CPUFNCNUM field. The fence field in the FBC Host Modification message will always be 0 and this field must be programmed to 0 to match. 8<---------------------
That's about the fence number, it doesn't say anything about the offset IIRC.
I guess it could be tested by, say:
- set the SA fence offset to some high number and leave this one low
- do the opposite
and in each case see if GTT tracking still works.
And to make sure were testin the right thing, probably repeat with both offsets set high and make sure the tracking really does not work.
Quoted 39 lines
(and
DPFC_CONTROL_SAis register0x100100)Quoted 36 lines
Quoted 35 lines
Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/intel_fbc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_fbc.c +6
-1@@ -216,7 +216,12 @@ static void ilk_fbc_enable(struct intel_crtc *crtc) dpfc_ctl |= obj->fence_reg; y_offset =get_crtc_fence_y_offset (crtc); -I915_WRITE (ILK_DPFC_FENCE_YOFF , y_offset); + +if (IS_GEN5 (dev_priv)) +I915_WRITE (ILK_DPFC_FENCE_YOFF , y_offset); +else +I915_WRITE (ILK_DPFC_FENCE_YOFF ,0 ); +I915_WRITE (ILK_FBC_RT_BASE ,i915_gem_obj_ggtt_offset (obj) |ILK_FBC_RT_VALID );drivers/gpu/drm/i915/intel_fbc.c +0
-0/* enable it... */ I915_WRITE (ILK_DPFC_CONTROL , dpfc_ctl |DPFC_CTL_EN );Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 5/16 drm/i915: check for the supported strides on HSW+ FBC
In reply to Paulo ZanoniI could only find the restrictions for HSW+, but I think it's safe to assume that the older platforms also can't support the configurations HSW can't support. The older platforms probably have additional restrictions, so we need to figure out those and implement them later. Let's not block HSW+ FBC based on missing information for the older platforms.
v2:
- Just WARN_ON() the strides that should have been caught earlier (Daniel)
- Make it a new function since I expect this to grow more.
v3:
- Document which IGT test is exercised by this.
Testcase: igt/kms_frontbuffer_tracking/fbc-badstride
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_fbc.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -940,6 +940,7 @@ struct i915_fbc {FBC_CHIP_DEFAULT ,/* disabled by default on this chip */ FBC_ROTATION ,/* rotation is not supported */ FBC_IN_DBG_MASTER ,/* kernel debugger is active */ +FBC_BAD_STRIDE ,/* stride is not supported */ } no_fbc_reason;bool (*fbc_enabled)(struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/intel_fbc.c +23 -0
@@ -501,6 +501,8 @@ const char *intel_no_fbc_reason_str(enum no_fbc_reason reason)return "rotation unsupported" ;case FBC_IN_DBG_MASTER :return "Kernel debugger is active" ; +case FBC_BAD_STRIDE : +return "framebuffer stride not supported" ;default :MISSING_CASE (reason);return "unknown reason" ;
@@ -694,6 +696,22 @@ static int intel_fbc_setup_cfb(struct drm_i915_private *dev_priv, int size,return intel_fbc_alloc_cfb (dev_priv, size, fb_cpp); } +static bool stride_is_valid (unsigned int stride) +{ +/* TODO: we need to figure out what are the stride restrictions for the +* older platforms. */ + +/* These should have been caught earlier. */ +WARN_ON (stride <512 ); +WARN_ON ((stride & (64 -1 )) !=0 ); + +/* These are additional FBC restrictions. */ +if (stride >16385 ) +return false; + +return true; +} +/** * __intel_fbc_update - enable/disable FBC as needed, unlocked * @dev_priv: i915 device instance
@@ -804,6 +822,11 @@ static void __intel_fbc_update(struct drm_i915_private *dev_priv) goto out_disable; } +if (!stride_is_valid (fb->pitches[0 ])) { +set_no_fbc_reason (dev_priv,FBC_BAD_STRIDE ); + goto out_disable; + } +/* If the kernel debugger is active, always disable compression */ if (in_dbg_master ()) {set_no_fbc_reason (dev_priv,FBC_IN_DBG_MASTER );
Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 05/16] drm/i915: check for the supported strides on HSW+ FBC
Quoted 6 lines · Paulo Zanoni
I could only find the restrictions for HSW+, but I think it's safe to assume that the older platforms also can't support the configurations HSW can't support. The older platforms probably have additional restrictions, so we need to figure out those and implement them later. Let's not block HSW+ FBC based on missing information for the older platforms.
gen2/3 4K or 8K
gen4 2K - 16K
g4x/ilk not really documented, I'd just go with gen6+ limits since it's fbc2 already
gen5+ 512 - 16K
Which means we don't really need another upper limit besides 16K since all the older platforms are already limited at that or below for tiled buffers. But on old platforms we do need to check the lower limits.
Quoted 42 lines
v2:
- JustWARN_ON()the strides that should have been caught earlier (Daniel)
- Make it a new function since I expect this to grow more.
v3:
- Document which IGT test is exercised by this.Testcase: igt/kms_frontbuffer_tracking/fbc-badstride
Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_fbc.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+)drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -940,6 +940,7 @@ struct i915_fbc {FBC_CHIP_DEFAULT ,/* disabled by default on this chip */ FBC_ROTATION ,/* rotation is not supported */ FBC_IN_DBG_MASTER ,/* kernel debugger is active */ +FBC_BAD_STRIDE ,/* stride is not supported */ } no_fbc_reason;bool (*fbc_enabled)(struct drm_i915_private *dev_priv);drivers/gpu/drm/i915/intel_fbc.c +2
-0@@ -501,6 +501,8 @@ const char *intel_no_fbc_reason_str(enum no_fbc_reason reason)return "rotation unsupported" ;case FBC_IN_DBG_MASTER :return "Kernel debugger is active" ; +case FBC_BAD_STRIDE : +return "framebuffer stride not supported" ;default :MISSING_CASE (reason);return "unknown reason" ;@@ -694,6 +696,22 @@ static int intel_fbc_setup_cfb(struct drm_i915_private *dev_priv, int size,return intel_fbc_alloc_cfb (dev_priv, size, fb_cpp);
drivers/gpu/drm/i915/intel_fbc.c static int intel_fbc_setup_cfb(struct drm_i915_private *dev_priv, int size, · line 706
Quoted 10 lines
drivers/gpu/drm/i915/intel_fbc.c +8
-0} +static bool stride_is_valid (unsigned int stride) +{ +/* TODO: we need to figure out what are the stride restrictions for the +* older platforms. */ + +/* These should have been caught earlier. */ +WARN_ON (stride <512 ); +WARN_ON ((stride & (64 -1 )) !=0 );
This is rather weird thing to check since we need an X-tiled buffer. I do see it mentioned in the SNB+ PM guides though.
drivers/gpu/drm/i915/intel_fbc.c static int intel_fbc_setup_cfb(struct drm_i915_private *dev_priv, int size, · line 709
Quoted 3 lines
drivers/gpu/drm/i915/intel_fbc.c +3
-0+ +/* These are additional FBC restrictions. */ +if (stride >16385 )
Off by one?
Quoted 27 lines
drivers/gpu/drm/i915/intel_fbc.c +10
-0+return false; + +return true; +} +/** * __intel_fbc_update - enable/disable FBC as needed, unlocked * @dev_priv: i915 device instance @@ -804,6 +822,11 @@ static void __intel_fbc_update(struct drm_i915_private *dev_priv) goto out_disable; } +if (!stride_is_valid (fb->pitches[0 ])) { +set_no_fbc_reason (dev_priv,FBC_BAD_STRIDE ); + goto out_disable; + } +/* If the kernel debugger is active, always disable compression */ if (in_dbg_master ()) {set_no_fbc_reason (dev_priv,FBC_IN_DBG_MASTER );Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 6/16 drm/i915: try a little harder to find an FBC CRTC
In reply to Paulo ZanoniKeep searching in case the candidate has a NULL primary fb. This is only relevant for the platforms that don't have the pipe_a_only restriction.
--- drivers/gpu/drm/i915/intel_fbc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/intel_fbc.c +2 -4
@@ -532,16 +532,14 @@ static struct drm_crtc *intel_fbc_find_crtc(struct drm_i915_private *dev_priv) tmp_crtc = dev_priv->pipe_to_crtc_mapping[pipe];if (intel_crtc_active (tmp_crtc) && -to_intel_plane_state (tmp_crtc->primary->state)->visible) +to_intel_plane_state (tmp_crtc->primary->state)->visible && + tmp_crtc->primary->fb !=NULL ) crtc = tmp_crtc;if (pipe_a_only)break ; } -if (!crtc || crtc->primary->fb ==NULL ) -return NULL ; -return crtc; }
Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 06/16] drm/i915: try a little harder to find an FBC CRTC
Quoted 14 lines · Paulo Zanoni
Keep searching in case the candidate has a NULL primary fb. This is only relevant for the platforms that don't have the
pipe_a_onlyrestriction.Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/intel_fbc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/gpu/drm/i915/intel_fbc.c +0
-0
drivers/gpu/drm/i915/intel_fbc.c static struct drm_crtc *intel_fbc_find_crtc(struct drm_i915_private *dev_priv) · line 536
Quoted 6 lines
drivers/gpu/drm/i915/intel_fbc.c +2
-1@@ -532,16 +532,14 @@ static struct drm_crtc *intel_fbc_find_crtc(struct drm_i915_private *dev_priv) tmp_crtc = dev_priv->pipe_to_crtc_mapping[pipe];if (intel_crtc_active (tmp_crtc) && -to_intel_plane_state (tmp_crtc->primary->state)->visible) +to_intel_plane_state (tmp_crtc->primary->state)->visible && + tmp_crtc->primary->fb !=NULL )
I'd hoped we'd gotten past these plane is supposedly visible but doesn't have an fb bugs. Does this actually happen in real life still?
Quoted 19 lines
drivers/gpu/drm/i915/intel_fbc.c +0
-3crtc = tmp_crtc;if (pipe_a_only)break ; } -if (!crtc || crtc->primary->fb ==NULL ) -return NULL ; -return crtc; }Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 7/16 drm/i915: disable FBC on FIFO underruns
In reply to Paulo ZanoniIf we want to try to enable FBC by default on any platform we need to be on the safe side and disable it in case we get an underrun while FBC is enabled on the corresponding pipe. We currently already have other reasons for FIFO underruns on our driver, but the ones I saw with FBC lead to black screens that only go away when you disable FBC.
The current FIFO underrun I see happens when the CFB is using the top 8mb of stolen memory. This is reproducible with a 2560x1440 DP Monitor on a system with 32mb of stolen memory. On this case, all the IGT tests fail while checking the screen CRC. A later patch on this series will fix this problem for real.
With this patch, the tests will start failing while checking if FBC is enabled instead of failing while comparing the CRC of the black screen against the correct CRC. So this patch is not hiding any IGT bugs: the tests still fail, but now they fail with a different reason.
--- drivers/gpu/drm/i915/i915_drv.h | 5 +++ drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_fbc.c | 61 ++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_fifo_underrun.c | 2 + 4 files changed, 69 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +5 -0
@@ -926,6 +926,11 @@ struct i915_fbc {struct drm_framebuffer *fb; } *fbc_work; +struct intel_fbc_underrun_work { +struct work_struct work; +struct intel_crtc *crtc; + } underrun_work; +enum no_fbc_reason {FBC_OK ,/* FBC is enabled */ FBC_UNSUPPORTED ,/* FBC is not supported by this chipset */
drivers/gpu/drm/i915/intel_drv.h +1 -0
@@ -1247,6 +1247,7 @@ void intel_fbc_flush(struct drm_i915_private *dev_priv, unsigned int frontbuffer_bits, enum fb_op_origin origin);const char *intel_no_fbc_reason_str (enum no_fbc_reason reason);void intel_fbc_cleanup_cfb (struct drm_i915_private *dev_priv); +void intel_fbc_handle_fifo_underrun (struct intel_crtc *crtc);/* intel_hdmi.c */ void intel_hdmi_init (struct drm_device *dev,int hdmi_reg,enum port port);
drivers/gpu/drm/i915/intel_fbc.c +61 -0
73 lines not on this page · raw message
drivers/gpu/drm/i915/intel_fifo_underrun.c +2 -0
@@ -356,6 +356,8 @@ void intel_cpu_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,if (intel_set_cpu_fifo_underrun_reporting (dev_priv, pipe, false))DRM_ERROR ("CPU pipe %c FIFO underrun\n" ,pipe_name (pipe)); + +intel_fbc_handle_fifo_underrun (to_intel_crtc (crtc)); }/**
Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 07/16] drm/i915: disable FBC on FIFO underruns
Quoted 30 lines · Paulo Zanoni
If we want to try to enable FBC by default on any platform we need to be on the safe side and disable it in case we get an underrun while FBC is enabled on the corresponding pipe. We currently already have other reasons for FIFO underruns on our driver, but the ones I saw with FBC lead to black screens that only go away when you disable FBC.
The current FIFO underrun I see happens when the CFB is using the top 8mb of stolen memory. This is reproducible with a 2560x1440 DP Monitor on a system with 32mb of stolen memory. On this case, all the IGT tests fail while checking the screen CRC. A later patch on this series will fix this problem for real.
With this patch, the tests will start failing while checking if FBC is enabled instead of failing while comparing the CRC of the black screen against the correct CRC. So this patch is not hiding any IGT bugs: the tests still fail, but now they fail with a different reason.
Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 5 +++ drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_fbc.c | 61 ++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_fifo_underrun.c | 2 + 4 files changed, 69 insertions(+)drivers/gpu/drm/i915/i915_drv.h +0
-0
drivers/gpu/drm/i915/i915_drv.h struct i915_fbc { · line 932
Quoted 7 lines
drivers/gpu/drm/i915/i915_drv.h +4
-0@@ -926,6 +926,11 @@ struct i915_fbc {struct drm_framebuffer *fb; } *fbc_work; +struct intel_fbc_underrun_work { +struct work_struct work; +struct intel_crtc *crtc; + } underrun_work;
It's a singleshot (perhaps a couple in flight during the switch off), so there's no need for a permanent allocation. Fight the bloat! -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 07/16] drm/i915: disable FBC on FIFO underruns
In reply to Paulo ZanoniQuoted 5 lines · Paulo Zanoni
If we want to try to enable FBC by default on any platform we need to be on the safe side and disable it in case we get an underrun while FBC is enabled on the corresponding pipe. We currently already have other reasons for FIFO underruns on our driver, but the ones I saw with FBC lead to black screens that only go away when you disable FBC.
We don't try to deal with underruns on other platforms either, and yes on some, cough, chv, cough, they can definitely blank out the screen until the next modeset. On even older platforms it's even worse and an underrun can kill the display engine until display reset/reboot :( Especially annoying on gen2 where we have no reset support. So I'm not entirely convinced FBC deserves special treatment here.
Quoted 147 lines
The current FIFO underrun I see happens when the CFB is using the top 8mb of stolen memory. This is reproducible with a 2560x1440 DP Monitor on a system with 32mb of stolen memory. On this case, all the IGT tests fail while checking the screen CRC. A later patch on this series will fix this problem for real.
With this patch, the tests will start failing while checking if FBC is enabled instead of failing while comparing the CRC of the black screen against the correct CRC. So this patch is not hiding any IGT bugs: the tests still fail, but now they fail with a different reason.
Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 5 +++ drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_fbc.c | 61 ++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_fifo_underrun.c | 2 + 4 files changed, 69 insertions(+)drivers/gpu/drm/i915/i915_drv.h +5
-0@@ -926,6 +926,11 @@ struct i915_fbc {struct drm_framebuffer *fb; } *fbc_work; +struct intel_fbc_underrun_work { +struct work_struct work; +struct intel_crtc *crtc; + } underrun_work; +enum no_fbc_reason {FBC_OK ,/* FBC is enabled */ FBC_UNSUPPORTED ,/* FBC is not supported by this chipset */ drivers/gpu/drm/i915/intel_drv.h +1
-0@@ -1247,6 +1247,7 @@ void intel_fbc_flush(struct drm_i915_private *dev_priv, unsigned int frontbuffer_bits, enum fb_op_origin origin);const char *intel_no_fbc_reason_str (enum no_fbc_reason reason);void intel_fbc_cleanup_cfb (struct drm_i915_private *dev_priv); +void intel_fbc_handle_fifo_underrun (struct intel_crtc *crtc);/* intel_hdmi.c */ void intel_hdmi_init (struct drm_device *dev,int hdmi_reg,enum port port);drivers/gpu/drm/i915/intel_fbc.c +61
-0@@ -955,6 +955,65 @@ void intel_fbc_flush(struct drm_i915_private *dev_priv,mutex_unlock (&dev_priv->fbc.lock); } +static void intel_fbc_underrun_work_fn (struct work_struct *__work) +{ +struct intel_fbc_underrun_work *work = + container_of(__work, struct intel_fbc_underrun_work, work); +struct intel_crtc *crtc = work->crtc; +struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; + +mutex_lock (&dev_priv->fbc.lock); +if (!intel_fbc_enabled (dev_priv) || dev_priv->fbc.crtc != crtc) + goto out; + +DRM_DEBUG_KMS ("Disabling FBC due to FIFO underrun.\n" ); + i915.enable_fbc =0 ; +__intel_fbc_disable (dev_priv); + +out: + work->crtc =NULL ; +mutex_unlock (&dev_priv->fbc.lock); +} + +/** +* intel_fbc_handle_fifo_underrun - handle FIFO underruns if FBC is enabled +* @crtc: the CRTC that caused the underrun +* +* Although we can't know for sure what caused an underrun, one of the possible +* reasons is FBC. And on the FBC case, the user may have a black screen until +* FBC is disabled. So whenever a FIFO underrun happens while FBC is enabled, +* disable FBC just because it may help. +* +* We disable FBC by changing the i915 param, so FBC won't come back on the next +* frame just to cause another underrun. Test suites can force FBC back by +* changing the module parameter again through sysfs. +*/ +void intel_fbc_handle_fifo_underrun (struct intel_crtc *crtc) +{ +struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; +struct intel_fbc_underrun_work *work = &dev_priv->fbc.underrun_work; + +if (!dev_priv->fbc.enable_fbc) +return ; + +/* These checks are unlocked. We can't grab the lock since we're in the +* IRQ handler. OTOH, grabbing it wouldn't help much since the underrun +* interrupt is asynchronous. Still, this a "try to recover because we +* have already failed" function, so let's at least try, and if we fail, +* we'll probably be able to try again next frame when another underrun +* happens. We'll also do the checks again in the work function, where +* we can grab the lock. */ +if (!intel_fbc_enabled (dev_priv) || dev_priv->fbc.crtc != crtc) +return ; + +/* Something already scheduled it. */ +if (work->crtc !=NULL ) +return ; + + work->crtc = crtc; +schedule_work (&work->work); +} +/** * intel_fbc_init - Initialize FBC * @dev_priv: the i915 device @@ -966,6 +1025,8 @@ void intel_fbc_init(struct drm_i915_private *dev_priv)enum pipe pipe;mutex_init (&dev_priv->fbc.lock); +INIT_WORK (&dev_priv->fbc.underrun_work.work, + intel_fbc_underrun_work_fn);if (!HAS_FBC (dev_priv)) { dev_priv->fbc.enabled = false;drivers/gpu/drm/i915/intel_fifo_underrun.c +2
-0@@ -356,6 +356,8 @@ void intel_cpu_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,if (intel_set_cpu_fifo_underrun_reporting (dev_priv, pipe, false))DRM_ERROR ("CPU pipe %c FIFO underrun\n" ,pipe_name (pipe)); + +intel_fbc_handle_fifo_underrun (to_intel_crtc (crtc)); }/** Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 07/16] drm/i915: disable FBC on FIFO underruns
2015-08-19 9:06 GMT-03:00 Ville Syrjälä <[email protected]>:
Quoted 7 lines · Paulo Zanoni
Quoted 5 lines
If we want to try to enable FBC by default on any platform we need to be on the safe side and disable it in case we get an underrun while FBC is enabled on the corresponding pipe. We currently already have other reasons for FIFO underruns on our driver, but the ones I saw with FBC lead to black screens that only go away when you disable FBC.
Quoted 6 lines
We don't try to deal with underruns on other platforms either, and yes on some, cough, chv, cough, they can definitely blank out the screen until the next modeset. On even older platforms it's even worse and an underrun can kill the display engine until display reset/reboot :( Especially annoying on gen2 where we have no reset support. So I'm not entirely convinced FBC deserves special treatment here.
I don't understand your logic. To me, it sounds like "you're proposing adding airbags to new cars, but that is not going to protect against every type of accident, and it's also not going to help the cars that are already manufactured, so I don't think front-collisions of new cars deserve special treatment".
Quoted 156 lines
Quoted 144 lines
The current FIFO underrun I see happens when the CFB is using the top 8mb of stolen memory. This is reproducible with a 2560x1440 DP Monitor on a system with 32mb of stolen memory. On this case, all the IGT tests fail while checking the screen CRC. A later patch on this series will fix this problem for real.
With this patch, the tests will start failing while checking if FBC is enabled instead of failing while comparing the CRC of the black screen against the correct CRC. So this patch is not hiding any IGT bugs: the tests still fail, but now they fail with a different reason.
Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 5 +++ drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_fbc.c | 61 ++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_fifo_underrun.c | 2 + 4 files changed, 69 insertions(+)drivers/gpu/drm/i915/i915_drv.h +5
-0@@ -926,6 +926,11 @@ struct i915_fbc {struct drm_framebuffer *fb; } *fbc_work; +struct intel_fbc_underrun_work { +struct work_struct work; +struct intel_crtc *crtc; + } underrun_work; +enum no_fbc_reason {FBC_OK ,/* FBC is enabled */ FBC_UNSUPPORTED ,/* FBC is not supported by this chipset */ drivers/gpu/drm/i915/intel_drv.h +1
-0@@ -1247,6 +1247,7 @@ void intel_fbc_flush(struct drm_i915_private *dev_priv, unsigned int frontbuffer_bits, enum fb_op_origin origin);const char *intel_no_fbc_reason_str (enum no_fbc_reason reason);void intel_fbc_cleanup_cfb (struct drm_i915_private *dev_priv); +void intel_fbc_handle_fifo_underrun (struct intel_crtc *crtc);/* intel_hdmi.c */ void intel_hdmi_init (struct drm_device *dev,int hdmi_reg,enum port port);drivers/gpu/drm/i915/intel_fbc.c +61
-0@@ -955,6 +955,65 @@ void intel_fbc_flush(struct drm_i915_private *dev_priv,mutex_unlock (&dev_priv->fbc.lock); } +static void intel_fbc_underrun_work_fn (struct work_struct *__work) +{ +struct intel_fbc_underrun_work *work = + container_of(__work, struct intel_fbc_underrun_work, work); +struct intel_crtc *crtc = work->crtc; +struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; + +mutex_lock (&dev_priv->fbc.lock); +if (!intel_fbc_enabled (dev_priv) || dev_priv->fbc.crtc != crtc) + goto out; + +DRM_DEBUG_KMS ("Disabling FBC due to FIFO underrun.\n" ); + i915.enable_fbc =0 ; +__intel_fbc_disable (dev_priv); + +out: + work->crtc =NULL ; +mutex_unlock (&dev_priv->fbc.lock); +} + +/** +* intel_fbc_handle_fifo_underrun - handle FIFO underruns if FBC is enabled +* @crtc: the CRTC that caused the underrun +* +* Although we can't know for sure what caused an underrun, one of the possible +* reasons is FBC. And on the FBC case, the user may have a black screen until +* FBC is disabled. So whenever a FIFO underrun happens while FBC is enabled, +* disable FBC just because it may help. +* +* We disable FBC by changing the i915 param, so FBC won't come back on the next +* frame just to cause another underrun. Test suites can force FBC back by +* changing the module parameter again through sysfs. +*/ +void intel_fbc_handle_fifo_underrun (struct intel_crtc *crtc) +{ +struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; +struct intel_fbc_underrun_work *work = &dev_priv->fbc.underrun_work; + +if (!dev_priv->fbc.enable_fbc) +return ; + +/* These checks are unlocked. We can't grab the lock since we're in the +* IRQ handler. OTOH, grabbing it wouldn't help much since the underrun +* interrupt is asynchronous. Still, this a "try to recover because we +* have already failed" function, so let's at least try, and if we fail, +* we'll probably be able to try again next frame when another underrun +* happens. We'll also do the checks again in the work function, where +* we can grab the lock. */ +if (!intel_fbc_enabled (dev_priv) || dev_priv->fbc.crtc != crtc) +return ; + +/* Something already scheduled it. */ +if (work->crtc !=NULL ) +return ; + + work->crtc = crtc; +schedule_work (&work->work); +} +/** * intel_fbc_init - Initialize FBC * @dev_priv: the i915 device @@ -966,6 +1025,8 @@ void intel_fbc_init(struct drm_i915_private *dev_priv)enum pipe pipe;mutex_init (&dev_priv->fbc.lock); +INIT_WORK (&dev_priv->fbc.underrun_work.work, + intel_fbc_underrun_work_fn);if (!HAS_FBC (dev_priv)) { dev_priv->fbc.enabled = false;drivers/gpu/drm/i915/intel_fifo_underrun.c +2
-1@@ -356,6 +356,8 @@ void intel_cpu_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,if (intel_set_cpu_fifo_underrun_reporting (dev_priv, pipe, false))DRM_ERROR ("CPU pipe %c FIFO underrun\n" ,pipe_name (pipe)); + +intel_fbc_handle_fifo_underrun (to_intel_crtc (crtc)); }/** -- 2.4.6
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx--
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 5 lines
Paulo Zanoni _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 07/16] drm/i915: disable FBC on FIFO underruns
Quoted 15 lines · Paulo Zanoni
2015-08-19 9:06 GMT-03:00 Ville Syrjälä <[email protected]>:
Quoted 7 lines · Paulo Zanoni
Quoted 5 lines
If we want to try to enable FBC by default on any platform we need to be on the safe side and disable it in case we get an underrun while FBC is enabled on the corresponding pipe. We currently already have other reasons for FIFO underruns on our driver, but the ones I saw with FBC lead to black screens that only go away when you disable FBC.
Quoted 6 lines
We don't try to deal with underruns on other platforms either, and yes on some, cough, chv, cough, they can definitely blank out the screen until the next modeset. On even older platforms it's even worse and an underrun can kill the display engine until display reset/reboot :( Especially annoying on gen2 where we have no reset support. So I'm not entirely convinced FBC deserves special treatment here.
Quoted 5 lines
I don't understand your logic. To me, it sounds like "you're proposing adding airbags to new cars, but that is not going to protect against every type of accident, and it's also not going to help the cars that are already manufactured, so I don't think front-collisions of new cars deserve special treatment".
Currently FBC is more like like "driving backwards on one wheel". I'm not sure there's much point in trying to make it fault tolerant while we know the code is still broken. Once it's otherwise known to be solid, then it might make sense, although a much cooler thing would be if we could actually detect when the display has failed entirely and recover it somehow.
Oh and to make the protection mechanism actually kick in reliably you would somehow need to address the problems with the underrun interrupts. At the moment, to continue your car analogy, it's like the airbags would refuse to deploy in a real crash if you happened to ding the mailbox while pulling out of your driveway.
Quoted 162 lines
Quoted 157 lines
Quoted 145 lines
The current FIFO underrun I see happens when the CFB is using the top 8mb of stolen memory. This is reproducible with a 2560x1440 DP Monitor on a system with 32mb of stolen memory. On this case, all the IGT tests fail while checking the screen CRC. A later patch on this series will fix this problem for real.
With this patch, the tests will start failing while checking if FBC is enabled instead of failing while comparing the CRC of the black screen against the correct CRC. So this patch is not hiding any IGT bugs: the tests still fail, but now they fail with a different reason.
Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 5 +++ drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_fbc.c | 61 ++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_fifo_underrun.c | 2 + 4 files changed, 69 insertions(+)drivers/gpu/drm/i915/i915_drv.h +5
-0@@ -926,6 +926,11 @@ struct i915_fbc {struct drm_framebuffer *fb; } *fbc_work; +struct intel_fbc_underrun_work { +struct work_struct work; +struct intel_crtc *crtc; + } underrun_work; +enum no_fbc_reason {FBC_OK ,/* FBC is enabled */ FBC_UNSUPPORTED ,/* FBC is not supported by this chipset */ drivers/gpu/drm/i915/intel_drv.h +1
-0@@ -1247,6 +1247,7 @@ void intel_fbc_flush(struct drm_i915_private *dev_priv, unsigned int frontbuffer_bits, enum fb_op_origin origin);const char *intel_no_fbc_reason_str (enum no_fbc_reason reason);void intel_fbc_cleanup_cfb (struct drm_i915_private *dev_priv); +void intel_fbc_handle_fifo_underrun (struct intel_crtc *crtc);/* intel_hdmi.c */ void intel_hdmi_init (struct drm_device *dev,int hdmi_reg,enum port port);drivers/gpu/drm/i915/intel_fbc.c +61
-0@@ -955,6 +955,65 @@ void intel_fbc_flush(struct drm_i915_private *dev_priv,mutex_unlock (&dev_priv->fbc.lock); } +static void intel_fbc_underrun_work_fn (struct work_struct *__work) +{ +struct intel_fbc_underrun_work *work = + container_of(__work, struct intel_fbc_underrun_work, work); +struct intel_crtc *crtc = work->crtc; +struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; + +mutex_lock (&dev_priv->fbc.lock); +if (!intel_fbc_enabled (dev_priv) || dev_priv->fbc.crtc != crtc) + goto out; + +DRM_DEBUG_KMS ("Disabling FBC due to FIFO underrun.\n" ); + i915.enable_fbc =0 ; +__intel_fbc_disable (dev_priv); + +out: + work->crtc =NULL ; +mutex_unlock (&dev_priv->fbc.lock); +} + +/** +* intel_fbc_handle_fifo_underrun - handle FIFO underruns if FBC is enabled +* @crtc: the CRTC that caused the underrun +* +* Although we can't know for sure what caused an underrun, one of the possible +* reasons is FBC. And on the FBC case, the user may have a black screen until +* FBC is disabled. So whenever a FIFO underrun happens while FBC is enabled, +* disable FBC just because it may help. +* +* We disable FBC by changing the i915 param, so FBC won't come back on the next +* frame just to cause another underrun. Test suites can force FBC back by +* changing the module parameter again through sysfs. +*/ +void intel_fbc_handle_fifo_underrun (struct intel_crtc *crtc) +{ +struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; +struct intel_fbc_underrun_work *work = &dev_priv->fbc.underrun_work; + +if (!dev_priv->fbc.enable_fbc) +return ; + +/* These checks are unlocked. We can't grab the lock since we're in the +* IRQ handler. OTOH, grabbing it wouldn't help much since the underrun +* interrupt is asynchronous. Still, this a "try to recover because we +* have already failed" function, so let's at least try, and if we fail, +* we'll probably be able to try again next frame when another underrun +* happens. We'll also do the checks again in the work function, where +* we can grab the lock. */ +if (!intel_fbc_enabled (dev_priv) || dev_priv->fbc.crtc != crtc) +return ; + +/* Something already scheduled it. */ +if (work->crtc !=NULL ) +return ; + + work->crtc = crtc; +schedule_work (&work->work); +} +/** * intel_fbc_init - Initialize FBC * @dev_priv: the i915 device @@ -966,6 +1025,8 @@ void intel_fbc_init(struct drm_i915_private *dev_priv)enum pipe pipe;mutex_init (&dev_priv->fbc.lock); +INIT_WORK (&dev_priv->fbc.underrun_work.work, + intel_fbc_underrun_work_fn);if (!HAS_FBC (dev_priv)) { dev_priv->fbc.enabled = false;drivers/gpu/drm/i915/intel_fifo_underrun.c +2
-1@@ -356,6 +356,8 @@ void intel_cpu_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,if (intel_set_cpu_fifo_underrun_reporting (dev_priv, pipe, false))DRM_ERROR ("CPU pipe %c FIFO underrun\n" ,pipe_name (pipe)); + +intel_fbc_handle_fifo_underrun (to_intel_crtc (crtc)); }/** -- 2.4.6
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx--
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfxSignature · 1 line
Paulo Zanoni
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 07/16] drm/i915: disable FBC on FIFO underruns
2015-08-20 10:58 GMT-03:00 Ville Syrjälä <[email protected]>:
Quoted 22 lines · Paulo Zanoni
Quoted 15 lines
2015-08-19 9:06 GMT-03:00 Ville Syrjälä <[email protected]>:
Quoted 7 lines · Paulo Zanoni
Quoted 5 lines
If we want to try to enable FBC by default on any platform we need to be on the safe side and disable it in case we get an underrun while FBC is enabled on the corresponding pipe. We currently already have other reasons for FIFO underruns on our driver, but the ones I saw with FBC lead to black screens that only go away when you disable FBC.
Quoted 6 lines
We don't try to deal with underruns on other platforms either, and yes on some, cough, chv, cough, they can definitely blank out the screen until the next modeset. On even older platforms it's even worse and an underrun can kill the display engine until display reset/reboot :( Especially annoying on gen2 where we have no reset support. So I'm not entirely convinced FBC deserves special treatment here.
Quoted 5 lines
I don't understand your logic. To me, it sounds like "you're proposing adding airbags to new cars, but that is not going to protect against every type of accident, and it's also not going to help the cars that are already manufactured, so I don't think front-collisions of new cars deserve special treatment".
Quoted 3 lines
Currently FBC is more like like "driving backwards on one wheel". I'm not sure there's much point in trying to make it fault tolerant while we know the code is still broken.
That's why this series contains other patches fixing the other problems. That's also why I recently added a few thousands of lines of code to IGT. Besides, no one is proposing to enable FBC by default on every single platform. I don't think "feature X doesn't work at the moment" is a reason to reject a patch that improves feature X.
Quoted 7 lines
Once it's otherwise known to be solid,
then it might make sense, although a much cooler thing would be if we could actually detect when the display has failed entirely and recover it somehow.Oh and to make the protection mechanism actually kick in reliably you would somehow need to address the problems with the underrun interrupts.
Which problems?
When I tested this patch, it was working very reliably: we detected the underrun and disabled FBC 100% of the time.
It's also worth noticing that the cause of the underrun is actually fixed by a later patch of this series, so we don't really need this patch as part of the whole "fix FBC" task, but I really think it's better to have it than not have it, just in case we regress somehow.
Quoted 170 lines
At the moment, to continue your car analogy, it's like the airbags would refuse to deploy in a real crash if you happened to ding the mailbox while pulling out of your driveway.
Quoted 160 lines
Quoted 145 lines
Quoted 145 lines
The current FIFO underrun I see happens when the CFB is using the top 8mb of stolen memory. This is reproducible with a 2560x1440 DP Monitor on a system with 32mb of stolen memory. On this case, all the IGT tests fail while checking the screen CRC. A later patch on this series will fix this problem for real.
With this patch, the tests will start failing while checking if FBC is enabled instead of failing while comparing the CRC of the black screen against the correct CRC. So this patch is not hiding any IGT bugs: the tests still fail, but now they fail with a different reason.
Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 5 +++ drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_fbc.c | 61 ++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_fifo_underrun.c | 2 + 4 files changed, 69 insertions(+)drivers/gpu/drm/i915/i915_drv.h +5
-0@@ -926,6 +926,11 @@ struct i915_fbc {struct drm_framebuffer *fb; } *fbc_work; +struct intel_fbc_underrun_work { +struct work_struct work; +struct intel_crtc *crtc; + } underrun_work; +enum no_fbc_reason {FBC_OK ,/* FBC is enabled */ FBC_UNSUPPORTED ,/* FBC is not supported by this chipset */ drivers/gpu/drm/i915/intel_drv.h +1
-0@@ -1247,6 +1247,7 @@ void intel_fbc_flush(struct drm_i915_private *dev_priv, unsigned int frontbuffer_bits, enum fb_op_origin origin);const char *intel_no_fbc_reason_str (enum no_fbc_reason reason);void intel_fbc_cleanup_cfb (struct drm_i915_private *dev_priv); +void intel_fbc_handle_fifo_underrun (struct intel_crtc *crtc);/* intel_hdmi.c */ void intel_hdmi_init (struct drm_device *dev,int hdmi_reg,enum port port);drivers/gpu/drm/i915/intel_fbc.c +61
-0@@ -955,6 +955,65 @@ void intel_fbc_flush(struct drm_i915_private *dev_priv,mutex_unlock (&dev_priv->fbc.lock); } +static void intel_fbc_underrun_work_fn (struct work_struct *__work) +{ +struct intel_fbc_underrun_work *work = + container_of(__work, struct intel_fbc_underrun_work, work); +struct intel_crtc *crtc = work->crtc; +struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; + +mutex_lock (&dev_priv->fbc.lock); +if (!intel_fbc_enabled (dev_priv) || dev_priv->fbc.crtc != crtc) + goto out; + +DRM_DEBUG_KMS ("Disabling FBC due to FIFO underrun.\n" ); + i915.enable_fbc =0 ; +__intel_fbc_disable (dev_priv); + +out: + work->crtc =NULL ; +mutex_unlock (&dev_priv->fbc.lock); +} + +/** +* intel_fbc_handle_fifo_underrun - handle FIFO underruns if FBC is enabled +* @crtc: the CRTC that caused the underrun +* +* Although we can't know for sure what caused an underrun, one of the possible +* reasons is FBC. And on the FBC case, the user may have a black screen until +* FBC is disabled. So whenever a FIFO underrun happens while FBC is enabled, +* disable FBC just because it may help. +* +* We disable FBC by changing the i915 param, so FBC won't come back on the next +* frame just to cause another underrun. Test suites can force FBC back by +* changing the module parameter again through sysfs. +*/ +void intel_fbc_handle_fifo_underrun (struct intel_crtc *crtc) +{ +struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; +struct intel_fbc_underrun_work *work = &dev_priv->fbc.underrun_work; + +if (!dev_priv->fbc.enable_fbc) +return ; + +/* These checks are unlocked. We can't grab the lock since we're in the +* IRQ handler. OTOH, grabbing it wouldn't help much since the underrun +* interrupt is asynchronous. Still, this a "try to recover because we +* have already failed" function, so let's at least try, and if we fail, +* we'll probably be able to try again next frame when another underrun +* happens. We'll also do the checks again in the work function, where +* we can grab the lock. */ +if (!intel_fbc_enabled (dev_priv) || dev_priv->fbc.crtc != crtc) +return ; + +/* Something already scheduled it. */ +if (work->crtc !=NULL ) +return ; + + work->crtc = crtc; +schedule_work (&work->work); +} +/** * intel_fbc_init - Initialize FBC * @dev_priv: the i915 device @@ -966,6 +1025,8 @@ void intel_fbc_init(struct drm_i915_private *dev_priv)enum pipe pipe;mutex_init (&dev_priv->fbc.lock); +INIT_WORK (&dev_priv->fbc.underrun_work.work, + intel_fbc_underrun_work_fn);if (!HAS_FBC (dev_priv)) { dev_priv->fbc.enabled = false;drivers/gpu/drm/i915/intel_fifo_underrun.c +2
-1@@ -356,6 +356,8 @@ void intel_cpu_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,if (intel_set_cpu_fifo_underrun_reporting (dev_priv, pipe, false))DRM_ERROR ("CPU pipe %c FIFO underrun\n" ,pipe_name (pipe)); + +intel_fbc_handle_fifo_underrun (to_intel_crtc (crtc)); }/** -- 2.4.6
Quoted 12 lines
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx--
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfxQuoted 2 lines
--
Paulo Zanoni--
Ville Syrjälä
Intel OTC
Signature · 5 lines
Paulo Zanoni _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 07/16] drm/i915: disable FBC on FIFO underruns
Quoted 23 lines · Paulo Zanoni
2015-08-20 10:58 GMT-03:00 Ville Syrjälä <[email protected]>:
Quoted 22 lines · Paulo Zanoni
Quoted 20 lines
2015-08-19 9:06 GMT-03:00 Ville Syrjälä <[email protected]>:
Quoted 7 lines · Paulo Zanoni
Quoted 5 lines
If we want to try to enable FBC by default on any platform we need to be on the safe side and disable it in case we get an underrun while FBC is enabled on the corresponding pipe. We currently already have other reasons for FIFO underruns on our driver, but the ones I saw with FBC lead to black screens that only go away when you disable FBC.
Quoted 6 lines
We don't try to deal with underruns on other platforms either, and yes on some, cough, chv, cough, they can definitely blank out the screen until the next modeset. On even older platforms it's even worse and an underrun can kill the display engine until display reset/reboot :( Especially annoying on gen2 where we have no reset support. So I'm not entirely convinced FBC deserves special treatment here.
I don't understand your logic. To me, it sounds like "you're proposing adding airbags to new cars, but that is not going to protect against every type of accident, and it's also not going to help the cars that are already manufactured, so I don't think front-collisions of new cars deserve special treatment".
Quoted 6 lines
Quoted 3 lines
Currently FBC is more like like "driving backwards on one wheel". I'm not sure there's much point in trying to make it fault tolerant while we know the code is still broken.
That's why this series contains other patches fixing the other problems.
Well the whole intel_update_fbc() thing is still very much a fail wrt. locking. But maybe you're planning on resurrecting my fbc_score idea?
Also now I that I glanced at the code, intel_fbc_flush() looks busted. To actually nuke the FBC state you need to wait at least until the next vblank before re-enabling FBC. That was one reason I had the vblank notify thingy in my "fix FBC" series.
Quoted 10 lines
That's also why I recently added a few thousands of lines of code to IGT. Besides, no one is proposing to enable FBC by default on every single platform. I don't think "feature X doesn't work at the moment" is a reason to reject a patch that improves feature X.
Quoted 5 lines
Once it's otherwise known to be solid,
then it might make sense, although a much cooler thing would be if we could actually detect when the display has failed entirely and recover it somehow.
Quoted 4 lines
Quoted 2 lines
Oh and to make the protection mechanism actually kick in reliably you would somehow need to address the problems with the underrun interrupts.
Which problems?
The fact that we disable them as soon as one occurs, and even worse the error interrupt is a shared one on many platforms, so one underrun any pipe or some other unrelated error kills underrun detection everywhere.
Quoted 184 lines
When I tested this patch, it was working very reliably: we detected the underrun and disabled FBC 100% of the time.
It's also worth noticing that the cause of the underrun is actually fixed by a later patch of this series, so we don't really need this patch as part of the whole "fix FBC" task, but I really think it's better to have it than not have it, just in case we regress somehow.
Quoted 170 lines
At the moment, to continue your car analogy, it's like the airbags would refuse to deploy in a real crash if you happened to ding the mailbox while pulling out of your driveway.
Quoted 160 lines
Quoted 145 lines
Quoted 145 lines
The current FIFO underrun I see happens when the CFB is using the top 8mb of stolen memory. This is reproducible with a 2560x1440 DP Monitor on a system with 32mb of stolen memory. On this case, all the IGT tests fail while checking the screen CRC. A later patch on this series will fix this problem for real.
With this patch, the tests will start failing while checking if FBC is enabled instead of failing while comparing the CRC of the black screen against the correct CRC. So this patch is not hiding any IGT bugs: the tests still fail, but now they fail with a different reason.
Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 5 +++ drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_fbc.c | 61 ++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_fifo_underrun.c | 2 + 4 files changed, 69 insertions(+)drivers/gpu/drm/i915/i915_drv.h +5
-0@@ -926,6 +926,11 @@ struct i915_fbc {struct drm_framebuffer *fb; } *fbc_work; +struct intel_fbc_underrun_work { +struct work_struct work; +struct intel_crtc *crtc; + } underrun_work; +enum no_fbc_reason {FBC_OK ,/* FBC is enabled */ FBC_UNSUPPORTED ,/* FBC is not supported by this chipset */ drivers/gpu/drm/i915/intel_drv.h +1
-0@@ -1247,6 +1247,7 @@ void intel_fbc_flush(struct drm_i915_private *dev_priv, unsigned int frontbuffer_bits, enum fb_op_origin origin);const char *intel_no_fbc_reason_str (enum no_fbc_reason reason);void intel_fbc_cleanup_cfb (struct drm_i915_private *dev_priv); +void intel_fbc_handle_fifo_underrun (struct intel_crtc *crtc);/* intel_hdmi.c */ void intel_hdmi_init (struct drm_device *dev,int hdmi_reg,enum port port);drivers/gpu/drm/i915/intel_fbc.c +61
-0@@ -955,6 +955,65 @@ void intel_fbc_flush(struct drm_i915_private *dev_priv,mutex_unlock (&dev_priv->fbc.lock); } +static void intel_fbc_underrun_work_fn (struct work_struct *__work) +{ +struct intel_fbc_underrun_work *work = + container_of(__work, struct intel_fbc_underrun_work, work); +struct intel_crtc *crtc = work->crtc; +struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; + +mutex_lock (&dev_priv->fbc.lock); +if (!intel_fbc_enabled (dev_priv) || dev_priv->fbc.crtc != crtc) + goto out; + +DRM_DEBUG_KMS ("Disabling FBC due to FIFO underrun.\n" ); + i915.enable_fbc =0 ; +__intel_fbc_disable (dev_priv); + +out: + work->crtc =NULL ; +mutex_unlock (&dev_priv->fbc.lock); +} + +/** +* intel_fbc_handle_fifo_underrun - handle FIFO underruns if FBC is enabled +* @crtc: the CRTC that caused the underrun +* +* Although we can't know for sure what caused an underrun, one of the possible +* reasons is FBC. And on the FBC case, the user may have a black screen until +* FBC is disabled. So whenever a FIFO underrun happens while FBC is enabled, +* disable FBC just because it may help. +* +* We disable FBC by changing the i915 param, so FBC won't come back on the next +* frame just to cause another underrun. Test suites can force FBC back by +* changing the module parameter again through sysfs. +*/ +void intel_fbc_handle_fifo_underrun (struct intel_crtc *crtc) +{ +struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; +struct intel_fbc_underrun_work *work = &dev_priv->fbc.underrun_work; + +if (!dev_priv->fbc.enable_fbc) +return ; + +/* These checks are unlocked. We can't grab the lock since we're in the +* IRQ handler. OTOH, grabbing it wouldn't help much since the underrun +* interrupt is asynchronous. Still, this a "try to recover because we +* have already failed" function, so let's at least try, and if we fail, +* we'll probably be able to try again next frame when another underrun +* happens. We'll also do the checks again in the work function, where +* we can grab the lock. */ +if (!intel_fbc_enabled (dev_priv) || dev_priv->fbc.crtc != crtc) +return ; + +/* Something already scheduled it. */ +if (work->crtc !=NULL ) +return ; + + work->crtc = crtc; +schedule_work (&work->work); +} +/** * intel_fbc_init - Initialize FBC * @dev_priv: the i915 device @@ -966,6 +1025,8 @@ void intel_fbc_init(struct drm_i915_private *dev_priv)enum pipe pipe;mutex_init (&dev_priv->fbc.lock); +INIT_WORK (&dev_priv->fbc.underrun_work.work, + intel_fbc_underrun_work_fn);if (!HAS_FBC (dev_priv)) { dev_priv->fbc.enabled = false;drivers/gpu/drm/i915/intel_fifo_underrun.c +2
-1@@ -356,6 +356,8 @@ void intel_cpu_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,if (intel_set_cpu_fifo_underrun_reporting (dev_priv, pipe, false))DRM_ERROR ("CPU pipe %c FIFO underrun\n" ,pipe_name (pipe)); + +intel_fbc_handle_fifo_underrun (to_intel_crtc (crtc)); }/** -- 2.4.6
Quoted 12 lines
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx--
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfxQuoted 2 lines
--
Paulo Zanoni--
Ville Syrjälä
Intel OTCSignature · 1 line
Paulo Zanoni
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 07/16] drm/i915: disable FBC on FIFO underruns
Quoted 7 lines · Ville Syrjälä
Quoted 6 lines · Paulo Zanoni
2015-08-20 10:58 GMT-03:00 Ville Syrjälä <[email protected]>:
Quoted 5 lines
Once it's otherwise known to be solid,
then it might make sense, although a much cooler thing would be if we could actually detect when the display has failed entirely and recover it somehow.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Oh and to make the protection mechanism actually kick in reliably you would somehow need to address the problems with the underrun interrupts.
Which problems?
The fact that we disable them as soon as one occurs, and even worse the error interrupt is a shared one on many platforms, so one underrun any pipe or some other unrelated error kills underrun detection everywhere.
E.g. on hsw with vga + hdmi/dp (which now happens easily since igt creates a fake vga output, just run kms_pipe_crc_basic) underruns happen reliably on modeset and then don't work anywhere. We also seem to fail to restore them somehow :(
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 8/16 drm/i915: avoid the last 8mb of stolen on BDW/SKL
In reply to Paulo ZanoniThe FBC hardware for these platforms doesn't have access to the bios_reserved range, so it always assumes the maximum (8mb) is used. So avoid this range while allocating.
This solves a bunch of FIFO underruns that happen if you end up putting the CFB in that memory range. On my machine, with 32mb of stolen, I need a 2560x1440 mode for that.
Testcase: igt/kms_frontbuffer_tracking/fbc-* (given the right setup)
--- drivers/gpu/drm/i915/i915_drv.h | 4 ++++ drivers/gpu/drm/i915/i915_gem_gtt.h | 1 + drivers/gpu/drm/i915/i915_gem_stolen.c | 26 +++++++++++++++++++------- drivers/gpu/drm/i915/intel_fbc.c | 16 ++++++++++++++-- 4 files changed, 38 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +4 -0
@@ -3159,6 +3159,10 @@ static inline void i915_gem_chipset_flush(struct drm_device *dev)int i915_gem_stolen_insert_node (struct drm_i915_private *dev_priv,struct drm_mm_node *node,u64 size,unsigned alignment); +int i915_gem_stolen_insert_node_in_range (struct drm_i915_private *dev_priv, +struct drm_mm_node *node,u64 size, +unsigned alignment,u64 start, +u64 end);void i915_gem_stolen_remove_node (struct drm_i915_private *dev_priv,struct drm_mm_node *node);int i915_gem_init_stolen (struct drm_device *dev);
drivers/gpu/drm/i915/i915_gem_gtt.h +1 -0
@@ -341,6 +341,7 @@ struct i915_gtt {struct i915_address_space base;size_t stolen_size;/* Total size of stolen memory */ +size_t stolen_usable_size;/* Total size minus BIOS reserved */ u64 mappable_end;/* End offset that we can CPU map */ struct io_mapping *mappable;/* Mapping to our CPU mappable region */ phys_addr_t mappable_base;/* PA of our GMADR */
drivers/gpu/drm/i915/i915_gem_stolen.c +19 -7
@@ -42,9 +42,9 @@* for is a boon. */ -int i915_gem_stolen_insert_node (struct drm_i915_private *dev_priv, -struct drm_mm_node *node,u64 size, -unsigned alignment) +int i915_gem_stolen_insert_node_in_range (struct drm_i915_private *dev_priv, +struct drm_mm_node *node,u64 size, +unsigned alignment,u64 start,u64 end) {int ret;
@@ -52,13 +52,23 @@ int i915_gem_stolen_insert_node(struct drm_i915_private *dev_priv,return -ENODEV ;mutex_lock (&dev_priv->mm.stolen_lock); - ret =drm_mm_insert_node (&dev_priv->mm.stolen, node, size, alignment, -DRM_MM_SEARCH_DEFAULT ); + ret =drm_mm_insert_node_in_range (&dev_priv->mm.stolen, node, size, + alignment, start, end, +DRM_MM_SEARCH_DEFAULT );mutex_unlock (&dev_priv->mm.stolen_lock);return ret; } +int i915_gem_stolen_insert_node (struct drm_i915_private *dev_priv, +struct drm_mm_node *node,u64 size, +unsigned alignment) +{ +return i915_gem_stolen_insert_node_in_range (dev_priv, node, size, + alignment,0 , + dev_priv->gtt.stolen_usable_size); +} +void i915_gem_stolen_remove_node (struct drm_i915_private *dev_priv,struct drm_mm_node *node) {
@@ -352,9 +362,11 @@ int i915_gem_init_stolen(struct drm_device *dev) dev_priv->gtt.stolen_size >>10 , (dev_priv->gtt.stolen_size - reserved_total) >> 10); + dev_priv->gtt.stolen_usable_size = dev_priv->gtt.stolen_size - + reserved_total; +/* Basic memrange allocator for stolen space */ -drm_mm_init (&dev_priv->mm.stolen,0 , dev_priv->gtt.stolen_size - - reserved_total); +drm_mm_init (&dev_priv->mm.stolen,0 , dev_priv->gtt.stolen_usable_size);return 0 ; }
drivers/gpu/drm/i915/intel_fbc.c +14 -2
@@ -570,6 +570,16 @@ static int find_compression_threshold(struct drm_i915_private *dev_priv, {int compression_threshold =1 ;int ret; +u64 end; + +/* The FBC hardware for BDW/SKL doesn't have access to the stolen +* reserved range size, so it always assumes the maximum (8mb) is used. +* If we enable FBC using a CFB on that memory range we'll get FIFO +* underruns, even if that range is not reserved by the BIOS. */ +if (IS_BROADWELL (dev_priv) ||IS_SKYLAKE (dev_priv)) + end = dev_priv->gtt.stolen_size -8 *1024 *1024 ; +else + end = dev_priv->gtt.stolen_usable_size;/* HACK: This code depends on what we will do in *_enable_fbc. If that * code changes, this code needs to change as well.
@@ -579,7 +589,8 @@ static int find_compression_threshold(struct drm_i915_private *dev_priv,*/ /* Try to over-allocate to reduce reallocations and fragmentation. */ - ret =i915_gem_stolen_insert_node (dev_priv, node, size <<=1 ,4096 ); + ret =i915_gem_stolen_insert_node_in_range (dev_priv, node, size <<=1 , +4096 ,0 , end);if (ret ==0 )return compression_threshold;
@@ -589,7 +600,8 @@ again: (fb_cpp == 2 && compression_threshold == 2))return 0 ; - ret =i915_gem_stolen_insert_node (dev_priv, node, size >>=1 ,4096 ); + ret =i915_gem_stolen_insert_node_in_range (dev_priv, node, size >>=1 , +4096 ,0 , end);if (ret &&INTEL_INFO (dev_priv)->gen <=4 ) {return 0 ; }else if (ret) {
Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 08/16] drm/i915: avoid the last 8mb of stolen on BDW/SKL
Quoted 7 lines · Paulo Zanoni
The FBC hardware for these platforms doesn't have access to the
bios_reservedrange, so it always assumes the maximum (8mb) is used. So avoid this range while allocating.This solves a bunch of FIFO underruns that happen if you end up putting the CFB in that memory range. On my machine, with 32mb of stolen, I need a 2560x1440 mode for that.
If the restriction applies only to FBC, apply it to only fbc. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 08/16] drm/i915: avoid the last 8mb of stolen on BDW/SKL
Em Sáb, 2015-08-15 às 09:29 +0100, Chris Wilson escreveu:
Quoted 11 lines · Paulo Zanoni
Quoted 8 lines
The FBC hardware for these platforms doesn't have access to the
bios_reservedrange, so it always assumes the maximum (8mb) is used.
So avoid this range while allocating.This solves a bunch of FIFO underruns that happen if you end up putting the CFB in that memory range. On my machine, with 32mb of stolen, I need a 2560x1440 mode for that.
If the restriction applies only to FBC, apply it to only fbc.
That's what the patch is doing. The part where we set the unusual start/end is at intel_fbc.c:find_compression_threshold(). Everything else should be behaving just as before.
Maybe you're being confused by the addition of the stolen_usable_size variable.
Quoted 2 lines
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 08/16] drm/i915: avoid the last 8mb of stolen on BDW/SKL
Quoted 11 lines · Paulo R
Em Sáb, 2015-08-15 às 09:29 +0100, Chris Wilson escreveu:
Quoted 10 lines · Paulo Zanoni
Quoted 8 lines
The FBC hardware for these platforms doesn't have access to the
bios_reservedrange, so it always assumes the maximum (8mb) is used.
So avoid this range while allocating.This solves a bunch of FIFO underruns that happen if you end up putting the CFB in that memory range. On my machine, with 32mb of stolen, I need a 2560x1440 mode for that.
Quoted 8 lines
Quoted 1 line
If the restriction applies only to FBC, apply it to only fbc.
That's what the patch is doing. The part where we set the unusual start/end is at intel_fbc.c:find_compression_threshold(). Everything else should be behaving just as before.
Maybe you're being confused by the addition of the
stolen_usable_sizevariable.
Hmm, I expected to see the constaint being passed into the search routine.a It looked like you were adjusting the stolen_size probably the root of my confusion.
Anyway we have a quandary. You want to reserve stolen space, and I want to make sure as much of it gets used as possible (especially for long lived objects).
What I have in mind is adding a priority to the search and allow us to evict anything of lower priority. We can use a page replacement algorithm even for the pinned fbcon (since only the GGTT itself is pinned and we can swap the pages underneath). This of course requires a callback for low priority evictable objects. I have 3 priorities in mind plus the evictable flag: USER, KERNEL, POWER (with FBC taking the highest priority of POWER). That will allow us to do the BIOS takeover and only if we run out of space force the copy.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 08/16] drm/i915: avoid the last 8mb of stolen on BDW/SKL
2015-08-19 5:24 GMT-03:00 [email protected] <[email protected]>:
Quoted 29 lines · Paulo R
Quoted 11 lines
Em Sáb, 2015-08-15 às 09:29 +0100, Chris Wilson escreveu:
Quoted 10 lines · Paulo Zanoni
Quoted 8 lines
The FBC hardware for these platforms doesn't have access to the
bios_reservedrange, so it always assumes the maximum (8mb) is used.
So avoid this range while allocating.This solves a bunch of FIFO underruns that happen if you end up putting the CFB in that memory range. On my machine, with 32mb of stolen, I need a 2560x1440 mode for that.
Quoted 8 lines
Quoted 1 line
If the restriction applies only to FBC, apply it to only fbc.
That's what the patch is doing. The part where we set the unusual start/end is at intel_fbc.c:find_compression_threshold(). Everything else should be behaving just as before.
Maybe you're being confused by the addition of the
stolen_usable_sizevariable.Hmm, I expected to see the constaint being passed into the search routine.a It looked like you were adjusting the
stolen_sizeprobably the root of my confusion.Anyway we have a quandary. You want to reserve stolen space, and I want to make sure as much of it gets used as possible (especially for long lived objects).
Quoted 8 lines
What I have in mind is adding a priority to the search and allow us to evict anything of lower priority. We can use a page replacement algorithm even for the pinned fbcon (since only the GGTT itself is pinned and we can swap the pages underneath). This of course requires a callback for low priority evictable objects. I have 3 priorities in mind plus the evictable flag: USER, KERNEL, POWER (with FBC taking the highest priority of POWER). That will allow us to do the BIOS takeover and only if we run out of space force the copy.
While I understand your idea, I just want to clarify one thing: it does not apply to _this_ patch, right? I suppose we're discussing about "[PATCH 15/16] Revert "drm/i915: Allocate fbcon from stolen memory" here. The memory avoided by this patch (08/16) can still be used by the other stolen memory users.
For the fbcon patch, can't we adopt a simpler "if FBC is enabled by default on this platform, don't alloc fbcon from stolen"?.
Quoted 8 lines
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 5 lines
Paulo Zanoni _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 9/16 drm/i915: print the correct amount of bytes allocated for the CFB
In reply to Paulo ZanoniAnd also print the threshold. I was surprised to see a log message claiming the CFB size was 32mb when there was less than 24mb available for it.
--- drivers/gpu/drm/i915/intel_fbc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_fbc.c +3 -2
@@ -655,8 +655,9 @@ static int intel_fbc_alloc_cfb(struct drm_i915_private *dev_priv, int size, dev_priv->fbc.uncompressed_size = size; -DRM_DEBUG_KMS ("reserved %d bytes of contiguous stolen space for FBC\n" , - size); +DRM_DEBUG_KMS ("reserved %llu bytes of contiguous stolen space for FBC, threshold: %d\n" , + dev_priv->fbc.compressed_fb.size, + dev_priv->fbc.threshold);return 0 ;
Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 09/16] drm/i915: print the correct amount of bytes allocated for the CFB
Quoted 14 lines · Paulo Zanoni
And also print the threshold. I was surprised to see a log message claiming the CFB size was 32mb when there was less than 24mb available for it.
Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/intel_fbc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/intel_fbc.c +0
-0
drivers/gpu/drm/i915/intel_fbc.c static int intel_fbc_alloc_cfb(struct drm_i915_private *dev_priv, int size, · line 660
Quoted 8 lines
drivers/gpu/drm/i915/intel_fbc.c +3
-2@@ -655,8 +655,9 @@ static int intel_fbc_alloc_cfb(struct drm_i915_private *dev_priv, int size, dev_priv->fbc.uncompressed_size = size; -DRM_DEBUG_KMS ("reserved %d bytes of contiguous stolen space for FBC\n" , - size); +DRM_DEBUG_KMS ("reserved %llu bytes of contiguous stolen space for FBC, threshold: %d\n" , + dev_priv->fbc.compressed_fb.size, + dev_priv->fbc.threshold);
Quoted 10 lines
drivers/gpu/drm/i915/intel_fbc.c +0
-0return 0 ;Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 10/16 drm/i915: fix CFB size calculation
In reply to Paulo ZanoniWe were considering the whole framebuffer height, but the spec clearly says that we should only consider the active display height size.
On my current testing machine, this moves us from 124 successes and 502 skips to 209 successes and 417 skips on "kms_frontbuffer_tracking --fbc-only". The high amount of skips is due to the --fbc-only argument. We had those skips due to not enough stolen memory for the tests. We're now passing the maximum possible amount: 209.
Note: when this patch was written, the amount of tests we had for FBC was different than what we have now.
Testcase: igt/kms_frontbuffer_tracking/fbc-*
--- drivers/gpu/drm/i915/intel_fbc.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/intel_fbc.c +9 -4
@@ -695,9 +695,15 @@ void intel_fbc_cleanup_cfb(struct drm_i915_private *dev_priv)mutex_unlock (&dev_priv->fbc.lock); } -static int intel_fbc_setup_cfb (struct drm_i915_private *dev_priv,int size, -int fb_cpp) +static int intel_fbc_setup_cfb (struct intel_crtc *crtc) { +struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; +struct drm_framebuffer *fb = crtc->base.primary->fb; +int size, fb_cpp; + + size = crtc->config->pipe_src_h * fb->pitches[0 ]; + fb_cpp =drm_format_plane_cpp (fb->pixel_format,0 ); +if (size <= dev_priv->fbc.uncompressed_size)return 0 ;
@@ -844,8 +850,7 @@ static void __intel_fbc_update(struct drm_i915_private *dev_priv) goto out_disable; } -if (intel_fbc_setup_cfb (dev_priv, obj->base.size, -drm_format_plane_cpp (fb->pixel_format,0 ))) { +if (intel_fbc_setup_cfb (intel_crtc)) {set_no_fbc_reason (dev_priv,FBC_STOLEN_TOO_SMALL ); goto out_disable; }
Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 10/16] drm/i915: fix CFB size calculation
Quoted 27 lines · Paulo Zanoni
We were considering the whole framebuffer height, but the spec clearly says that we should only consider the active display height size.
On my current testing machine, this moves us from 124 successes and 502 skips to 209 successes and 417 skips on "
kms_frontbuffer_tracking--fbc-only". The high amount of skips is due to the --fbc-only argument. We had those skips due to not enough stolen memory for the tests. We're now passing the maximum possible amount: 209.Note: when this patch was written, the amount of tests we had for FBC was different than what we have now.
Testcase: igt/kms_frontbuffer_tracking/fbc-*
Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/intel_fbc.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)drivers/gpu/drm/i915/intel_fbc.c +0
-1@@ -695,9 +695,15 @@ void intel_fbc_cleanup_cfb(struct drm_i915_private *dev_priv)mutex_unlock (&dev_priv->fbc.lock); } -static int intel_fbc_setup_cfb(struct drm_i915_private *dev_priv, int size,
drivers/gpu/drm/i915/intel_fbc.c void intel_fbc_cleanup_cfb(struct drm_i915_private *dev_priv) · line 706
Quoted 10 lines
drivers/gpu/drm/i915/intel_fbc.c +8
-1- int fb_cpp) +static int intel_fbc_setup_cfb (struct intel_crtc *crtc) { +struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; +struct drm_framebuffer *fb = crtc->base.primary->fb; +int size, fb_cpp; + + size = crtc->config->pipe_src_h * fb->pitches[0 ]; + fb_cpp =drm_format_plane_cpp (fb->pixel_format,0 ); +
From the looks of it SKL ought to be able to use FBC even with a non-fullscreen plane, so this should look up the size from the plane state. What I don't know is whether FBC would still work when plane scaling is enabled. But I suppose it if can, it would deal with the data before scaling, so using the clipped src size would be the right thing here I think.
Quoted 20 lines
drivers/gpu/drm/i915/intel_fbc.c +1
-2if (size <= dev_priv->fbc.uncompressed_size)return 0 ;@@ -844,8 +850,7 @@ static void __intel_fbc_update(struct drm_i915_private *dev_priv) goto out_disable; } -if (intel_fbc_setup_cfb (dev_priv, obj->base.size, -drm_format_plane_cpp (fb->pixel_format,0 ))) { +if (intel_fbc_setup_cfb (intel_crtc)) {set_no_fbc_reason (dev_priv,FBC_STOLEN_TOO_SMALL ); goto out_disable; }Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 11/16 drm/i915/bdw: don't enable FBC when pixel rate exceeds 95%
In reply to Paulo ZanoniBSpec says we shouldn't enable FBC on BDW when the pipe pixel rate exceeds 95% of the core display clock.
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_fbc.c | 8 ++++++++ 2 files changed, 9 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -946,6 +946,7 @@ struct i915_fbc {FBC_ROTATION ,/* rotation is not supported */ FBC_IN_DBG_MASTER ,/* kernel debugger is active */ FBC_BAD_STRIDE ,/* stride is not supported */ +FBC_PIXEL_RATE ,/* pixel rate is too big */ } no_fbc_reason;bool (*fbc_enabled)(struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/intel_fbc.c +8 -0
@@ -503,6 +503,8 @@ const char *intel_no_fbc_reason_str(enum no_fbc_reason reason)return "Kernel debugger is active" ;case FBC_BAD_STRIDE :return "framebuffer stride not supported" ; +case FBC_PIXEL_RATE : +return "pixel rate is too big" ;default :MISSING_CASE (reason);return "unknown reason" ;
@@ -850,6 +852,12 @@ static void __intel_fbc_update(struct drm_i915_private *dev_priv) goto out_disable; } +if (IS_BROADWELL (dev_priv) &&ilk_pipe_pixel_rate (intel_crtc->config) >= + dev_priv->max_cdclk_freq *95 /100 ) { +set_no_fbc_reason (dev_priv,FBC_PIXEL_RATE ); + goto out_disable; + } +if (intel_fbc_setup_cfb (intel_crtc)) {set_no_fbc_reason (dev_priv,FBC_STOLEN_TOO_SMALL ); goto out_disable;
Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 11/16] drm/i915/bdw: don't enable FBC when pixel rate exceeds 95%
Quoted 2 lines · Paulo Zanoni
BSpec says we shouldn't enable FBC on BDW when the pipe pixel rate exceeds 95% of the core display clock.
w/a db says HSW has the same issue, apparently it was found on HSW originally. Actually it says BDW G0 would have it fixed. Bspec says G1 in the w/a section. Not sure what to believe here. Better safe than sorry probably and just do the w/a for BDW.
Also this has a name 'WaFbcExceedCdClockThreshold'
Quoted 33 lines
Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_fbc.c | 8 ++++++++ 2 files changed, 9 insertions(+)drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -946,6 +946,7 @@ struct i915_fbc {FBC_ROTATION ,/* rotation is not supported */ FBC_IN_DBG_MASTER ,/* kernel debugger is active */ FBC_BAD_STRIDE ,/* stride is not supported */ +FBC_PIXEL_RATE ,/* pixel rate is too big */ } no_fbc_reason;bool (*fbc_enabled)(struct drm_i915_private *dev_priv);drivers/gpu/drm/i915/intel_fbc.c +2
-0@@ -503,6 +503,8 @@ const char *intel_no_fbc_reason_str(enum no_fbc_reason reason)return "Kernel debugger is active" ;case FBC_BAD_STRIDE :return "framebuffer stride not supported" ; +case FBC_PIXEL_RATE : +return "pixel rate is too big" ;default :MISSING_CASE (reason);return "unknown reason" ;
drivers/gpu/drm/i915/intel_fbc.c static void __intel_fbc_update(struct drm_i915_private *dev_priv) · line 856
Quoted 5 lines
drivers/gpu/drm/i915/intel_fbc.c +2
-0@@ -850,6 +852,12 @@ static void __intel_fbc_update(struct drm_i915_private *dev_priv) goto out_disable; } +if (IS_BROADWELL (dev_priv) &&ilk_pipe_pixel_rate (intel_crtc->config) >= + dev_priv->max_cdclk_freq *95 /100 ) {
That should be looking at the current cdclk, not the max. We should probablt change our cdclk computations to include some headroom for FBC/IPS when there aren't other factors that would preclude their use.
Quoted 14 lines
drivers/gpu/drm/i915/intel_fbc.c +4
-0+set_no_fbc_reason (dev_priv,FBC_PIXEL_RATE ); + goto out_disable; + } +if (intel_fbc_setup_cfb (intel_crtc)) {set_no_fbc_reason (dev_priv,FBC_STOLEN_TOO_SMALL ); goto out_disable;Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 12/16 drm/i915: apply WaFbcAsynchFlipDisableFbcQueue earlier
In reply to Paulo ZanoniThe spec says the register should have that value for the entire time that FBC is enabled, so apply the WA before we enable FBC.
Notice that we also have this WA for ILK/SNB, but it is implemented at init_clock_gating(). I could move the IVB/HSW/BDW WA code to init_clock_gating() too, but since we recently had some complaints about WAs not staying after being set, I'm going to play safe and keep this here for now.
--- drivers/gpu/drm/i915/intel_fbc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_fbc.c +2 -2
@@ -293,8 +293,6 @@ static void gen7_fbc_enable(struct intel_crtc *crtc)if (dev_priv->fbc.false_color) dpfc_ctl |=FBC_CTL_FALSE_COLOR ; -I915_WRITE (ILK_DPFC_CONTROL , dpfc_ctl |DPFC_CTL_EN ); -if (IS_IVYBRIDGE (dev_priv)) {/* WaFbcAsynchFlipDisableFbcQueue:ivb */ I915_WRITE(ILK_DISPLAY_CHICKEN1,
@@ -307,6 +305,8 @@ static void gen7_fbc_enable(struct intel_crtc *crtc) HSW_FBCQ_DIS); } +I915_WRITE (ILK_DPFC_CONTROL , dpfc_ctl |DPFC_CTL_EN ); +I915_WRITE (SNB_DPFC_CTL_SA ,SNB_CPU_FENCE_ENABLE | obj->fence_reg);I915_WRITE (DPFC_CPU_FENCE_OFFSET ,get_crtc_fence_y_offset (crtc));
Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 12/16] drm/i915: apply WaFbcAsynchFlipDisableFbcQueue earlier
Quoted 8 lines · Paulo Zanoni
The spec says the register should have that value for the entire time that FBC is enabled, so apply the WA before we enable FBC.
Notice that we also have this WA for ILK/SNB, but it is implemented at
init_clock_gating(). I could move the IVB/HSW/BDW WA code toinit_clock_gating()too, but since we recently had some complaints about WAs not staying after being set, I'm going to play safe and keep this here for now.
Yeah I think we tried to optimize things by applying the w/a only when absolutely needed, on the theory that it might save some power when FBC is disabled. But I have no idea if that's true or not. Oh and we don't actually undo the w/a after disalbing FBC which pretty mucch defeats the purpose of the optimizaton.
Would be better to do it the same way for all platforms I think. Either in init_clock_gating, or we should do and undo the w/a around FBC enable/disable.
In the meantime this patch seems fine, so
Quoted 35 lines
Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/intel_fbc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/intel_fbc.c +2
-2@@ -293,8 +293,6 @@ static void gen7_fbc_enable(struct intel_crtc *crtc)if (dev_priv->fbc.false_color) dpfc_ctl |=FBC_CTL_FALSE_COLOR ; -I915_WRITE (ILK_DPFC_CONTROL , dpfc_ctl |DPFC_CTL_EN ); -if (IS_IVYBRIDGE (dev_priv)) {/* WaFbcAsynchFlipDisableFbcQueue:ivb */ I915_WRITE(ILK_DISPLAY_CHICKEN1,@@ -307,6 +305,8 @@ static void gen7_fbc_enable(struct intel_crtc *crtc) HSW_FBCQ_DIS); } +I915_WRITE (ILK_DPFC_CONTROL , dpfc_ctl |DPFC_CTL_EN ); +I915_WRITE (SNB_DPFC_CTL_SA ,SNB_CPU_FENCE_ENABLE | obj->fence_reg);I915_WRITE (DPFC_CPU_FENCE_OFFSET ,get_crtc_fence_y_offset (crtc));Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 13/16 drm/i915: don't use the first stolen page on Broadwell
In reply to Paulo ZanoniThe spec says we just can't use it.
--- drivers/gpu/drm/i915/i915_gem_stolen.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/i915/i915_gem_stolen.c +3 -0
@@ -51,6 +51,9 @@ int i915_gem_stolen_insert_node_in_range(struct drm_i915_private *dev_priv,if (!drm_mm_initialized (&dev_priv->mm.stolen))return -ENODEV ; +if (IS_BROADWELL (dev_priv) && start <4096 ) + start =4096 ; +mutex_lock (&dev_priv->mm.stolen_lock); ret = drm_mm_insert_node_in_range(&dev_priv->mm.stolen, node, size, alignment, start, end,
Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 13/16] drm/i915: don't use the first stolen page on Broadwell
Quoted 1 line · Paulo Zanoni
The spec says we just can't use it.
But what about when we inherit a framebuffer at that address? -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 13/16] drm/i915: don't use the first stolen page on Broadwell
Quoted 4 lines · Chris Wilson
Quoted 1 line · Paulo Zanoni
The spec says we just can't use it.
But what about when we inherit a framebuffer at that address?
Indeed. I asked the same question several times during the past attempts at this, and even tried to outline a potential solution at least once [1]
Also limiting it to BDW is insufficient. CHV needs it too.
[1] http://lists.freedesktop.org/archives/intel-gfx/2014-July/049924.html
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 13/16] drm/i915: don't use the first stolen page on Broadwell
Quoted 8 lines · Ville Syrjälä
Quoted 4 lines · Chris Wilson
Quoted 1 line · Paulo Zanoni
The spec says we just can't use it.
But what about when we inherit a framebuffer at that address?
Indeed. I asked the same question several times during the past attempts at this, and even tried to outline a potential solution at least once [1]
Paulo's only patching the insert_node_in_range allocator, for fbcon takeover we use reserve_node. I think this patch seems to do what you want it to do, no need for fancier schemes.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 13/16] drm/i915: don't use the first stolen page on Broadwell
Quoted 5 lines · Daniel Vetter
Quoted 4 lines · Ville Syrjälä
Quoted 3 lines · Chris Wilson
Quoted 1 line · Paulo Zanoni
The spec says we just can't use it.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
But what about when we inherit a framebuffer at that address?
Indeed. I asked the same question several times during the past attempts at this, and even tried to outline a potential solution at least once [1]
Paulo's only patching the
insert_node_in_rangeallocator, for fbcon takeover we usereserve_node. I think this patch seems to do what you want it to do, no need for fancier schemes.
Hmm. Indeed. It's a somewhat surprising place to find such a check, but it does solve the preallocated vs. normal issue. It does mean we may end up with some corruption in the fbdev bo but I suppose that's short lived enough that we can ignore it.
It could use a comment as to why we put the check there instead of totally removing the first page from the stolen mm. Otherwise someone might decide to clean it up and break things. Also lacking the w/a name and some explanation why it's needed. And as I mentioned before, CHV needs to be included. SKL/BXT only have it listed for early steppings, so I think we can ignore those.
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 14/16 drm/i915: don't apply WaFbcAsynchFlipDisableFbcQueue on SKL
In reply to Paulo ZanoniThis WA is only for HSW/BDW.
--- drivers/gpu/drm/i915/intel_fbc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_fbc.c +1 -1
@@ -298,7 +298,7 @@ static void gen7_fbc_enable(struct intel_crtc *crtc)I915_WRITE (ILK_DISPLAY_CHICKEN1 ,I915_READ (ILK_DISPLAY_CHICKEN1 ) |ILK_FBCQ_DIS ); - }else { + }else if (IS_HASWELL (dev_priv) ||IS_BROADWELL (dev_priv)) {/* WaFbcAsynchFlipDisableFbcQueue:hsw,bdw */ I915_WRITE(CHICKEN_PIPESL_1(crtc->pipe), I915_READ(CHICKEN_PIPESL_1(crtc->pipe)) |
Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 14/16] drm/i915: don't apply WaFbcAsynchFlipDisableFbcQueue on SKL
Quoted 1 line · Paulo Zanoni
This WA is only for HSW/BDW.
w/a db says it was needed for early SKL, but we can ignore it. w/a db still has it for BXT. I guess we can hope BXT would be fixed too if SKL is.
Quoted 26 lines
Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/intel_fbc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/i915/intel_fbc.c +1
-1@@ -298,7 +298,7 @@ static void gen7_fbc_enable(struct intel_crtc *crtc)I915_WRITE (ILK_DISPLAY_CHICKEN1 ,I915_READ (ILK_DISPLAY_CHICKEN1 ) |ILK_FBCQ_DIS ); - }else { + }else if (IS_HASWELL (dev_priv) ||IS_BROADWELL (dev_priv)) {/* WaFbcAsynchFlipDisableFbcQueue:hsw,bdw */ I915_WRITE(CHICKEN_PIPESL_1(crtc->pipe), I915_READ(CHICKEN_PIPESL_1(crtc->pipe)) |Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 15/16 Revert "drm/i915: Allocate fbcon from stolen memory"
In reply to Paulo ZanoniThis reverts commit 0ffb0ff283cca16f72caf29c44496d83b0c291fb.
Technology has evolved and now we have eDP panels with 3200x1800 resolution. In the meantime, the BIOS guys didn't change the default 32mb for stolen memory. And we can't assume our users will be able to increase the default stolen memory size to more than 32mb - I'm not even sure all BIOSes allow that.
So just the fbcon buffer alone eats 22mb of my stolen memroy, and due to the BDW/SKL restriction of not using the last 8mb of stolen memory, all that's left for FBC is 2mb! Since fbcon is not the coolest feature ever, I think it's better to save our precious stolen resource to FBC and the other guys.
Besides, neither the original commit message nor the review comments showed any arguments in favor of actually allocating fbcon from stolen.
--- drivers/gpu/drm/i915/intel_fbdev.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_fbdev.c +1 -3
@@ -139,9 +139,7 @@ static int intelfb_alloc(struct drm_fb_helper *helper, size = mode_cmd.pitches[0 ] * mode_cmd.height; size =PAGE_ALIGN (size); - obj =i915_gem_object_create_stolen (dev, size); -if (obj ==NULL ) - obj =i915_gem_alloc_object (dev, size); + obj =i915_gem_alloc_object (dev, size);if (!obj) {DRM_ERROR ("failed to allocate framebuffer\n" ); ret = -ENOMEM ;
Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 15/16] Revert "drm/i915: Allocate fbcon from stolen memory"
Quoted 14 lines · Paulo Zanoni
This reverts commit
0ffb0ff283cca16f72caf29c44496d83b0c291fb.Technology has evolved and now we have eDP panels with 3200x1800 resolution. In the meantime, the BIOS guys didn't change the default 32mb for stolen memory. And we can't assume our users will be able to increase the default stolen memory size to more than 32mb - I'm not even sure all BIOSes allow that.
So just the fbcon buffer alone eats 22mb of my stolen memroy, and due to the BDW/SKL restriction of not using the last 8mb of stolen memory, all that's left for FBC is 2mb! Since fbcon is not the coolest feature ever, I think it's better to save our precious stolen resource to FBC and the other guys.
Quoted 3 lines
Besides, neither the original commit message nor the review comments showed any arguments in favor of actually allocating fbcon from stolen.
Pardon?
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 15/16] Revert "drm/i915: Allocate fbcon from stolen memory"
Em Sáb, 2015-08-15 às 09:24 +0100, Chris Wilson escreveu:
Quoted 21 lines · Paulo Zanoni
Quoted 20 lines
This reverts commit
0ffb0ff283cca16f72caf29c44496d83b0c291fb.Technology has evolved and now we have eDP panels with 3200x1800 resolution. In the meantime, the BIOS guys didn't change the default
32mb for stolen memory. And we can't assume our users will be able to
increase the default stolen memory size to more than 32mb - I'm not even sure all BIOSes allow that.So just the fbcon buffer alone eats 22mb of my stolen memroy, and due
to the BDW/SKL restriction of not using the last 8mb of stolen memory,
all that's left for FBC is 2mb! Since fbcon is not the coolest feature
ever, I think it's better to save our precious stolen resource to FBC
and the other guys.
Quoted 6 lines
Quoted 4 lines
Besides, neither the original commit message nor the review comments
showed any arguments in favor of actually allocating fbcon from stolen.Pardon?
pzanoni@panetone:~/git/kernel/kernel$ git show 0ffb0ff283cca16f72caf29c44496d83b0c291fb | head -n 12 commit 0ffb0ff283cca16f72caf29c44496d83b0c291fb Author: Chris Wilson <[email protected]> Date: Thu Nov 15 11:32:27 2012 +0000
drm/i915: Allocate fbcon from stolen memory
(quoted diff) +0 -0
b/drivers/gpu/drm/i915/intel_fb.c
pzanoni@panetone:~/git/kernel/kernel$
And the only review I could find was:
http://lists.freedesktop.org/archives/intel-gfx/2012
-October/021025.html
Quoted 2 lines
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 15/16] Revert "drm/i915: Allocate fbcon from stolen memory"
Quoted 45 lines · Paulo R
Em Sáb, 2015-08-15 às 09:24 +0100, Chris Wilson escreveu:
Quoted 21 lines · Paulo Zanoni
Quoted 20 lines
This reverts commit
0ffb0ff283cca16f72caf29c44496d83b0c291fb.Technology has evolved and now we have eDP panels with 3200x1800 resolution. In the meantime, the BIOS guys didn't change the default
32mb for stolen memory. And we can't assume our users will be able to
increase the default stolen memory size to more than 32mb - I'm not even sure all BIOSes allow that.So just the fbcon buffer alone eats 22mb of my stolen memroy, and due
to the BDW/SKL restriction of not using the last 8mb of stolen memory,
all that's left for FBC is 2mb! Since fbcon is not the coolest feature
ever, I think it's better to save our precious stolen resource to FBC
and the other guys.Quoted 6 lines
Quoted 4 lines
Besides, neither the original commit message nor the review comments
showed any arguments in favor of actually allocating fbcon from stolen.Pardon?
pzanoni@panetone:~/git/kernel/kernel$ git show 0ffb0ff283cca16f72caf29c44496d83b0c291fb | head -n 12 commit 0ffb0ff283cca16f72caf29c44496d83b0c291fb Author: Chris Wilson <[email protected]> Date: Thu Nov 15 11:32:27 2012 +0000drm/i915: Allocate fbcon from stolen memory
Signed-off-by Chris Wilson <[email protected]>Reviewed-by Jesse Barnes <[email protected]>Acked-by Ben Widawsky <[email protected]>Signed-off-by Daniel Vetter <[email protected]>drivers/gpu/drm/i915/intel_fb.c +0
-0
Quoted 1 line
pzanoni@panetone:~/git/kernel/kernel$
Sorry, I though it was pretty self explanatory that we want to reuse as much as stolen as is possible on all machines, epecially those where even 8MiB reserved is about 10% of available memory. So not using it for pinned memory is a double whammy.
That would have been said in the preceeding patches to enable stolen memory.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 16/16 drm/i915: reject invalid formats for FBC
In reply to Paulo ZanoniThis commit is essentially a rewrite of "drm/i915: Check pixel format for fbc" from Ville Syrjälä. The idea is the same, but the code is different due to all the changes that happened since his original patch. So any bugs are due to my bad rewrite.
Testcases: igt/kms_frontbuffer_tracking/*fbc*-${format_name}-draw-*
Credits-to: Ville Syrjälä <[email protected]>
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_fbc.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -947,6 +947,7 @@ struct i915_fbc {FBC_IN_DBG_MASTER ,/* kernel debugger is active */ FBC_BAD_STRIDE ,/* stride is not supported */ FBC_PIXEL_RATE ,/* pixel rate is too big */ + FBC_PIXEL_FORMAT /* pixel format is invalid */ } no_fbc_reason;bool (*fbc_enabled)(struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/intel_fbc.c +35 -0
@@ -505,6 +505,8 @@ const char *intel_no_fbc_reason_str(enum no_fbc_reason reason)return "framebuffer stride not supported" ;case FBC_PIXEL_RATE :return "pixel rate is too big" ; +case FBC_PIXEL_FORMAT : +return "pixel format is invalid" ;default :MISSING_CASE (reason);return "unknown reason" ;
@@ -731,6 +733,34 @@ static bool stride_is_valid(unsigned int stride)return true; } +static bool pixel_format_is_valid (struct drm_framebuffer *fb) +{ +struct drm_device *dev = fb->dev; +struct drm_i915_private *dev_priv = dev->dev_private; + +/* Primary planes don't support alpha, so the "A" formats and "X" +* formats are one and the same. */ +switch (fb->pixel_format) { +case DRM_FORMAT_XRGB8888 : +case DRM_FORMAT_ARGB8888 : +case DRM_FORMAT_XBGR8888 : +case DRM_FORMAT_ABGR8888 : +return true; +case DRM_FORMAT_XRGB1555 : +case DRM_FORMAT_ARGB1555 : +case DRM_FORMAT_RGB565 : +/* 16bpp not supported on gen2 */ +if (IS_GEN2 (dev)) +return false; +/* WaFbcOnly1to1Ratio:ctg */ +if (IS_G4X (dev_priv)) +return false; +return true; +default : +return false; + } +} +/** * __intel_fbc_update - enable/disable FBC as needed, unlocked * @dev_priv: i915 device instance
@@ -846,6 +876,11 @@ static void __intel_fbc_update(struct drm_i915_private *dev_priv) goto out_disable; } +if (!pixel_format_is_valid (fb)) { +set_no_fbc_reason (dev_priv,FBC_PIXEL_FORMAT ); + goto out_disable; + } +/* If the kernel debugger is active, always disable compression */ if (in_dbg_master ()) {set_no_fbc_reason (dev_priv,FBC_IN_DBG_MASTER );
Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 16/16] drm/i915: reject invalid formats for FBC
Quoted 48 lines · Paulo Zanoni
This commit is essentially a rewrite of "drm/i915: Check pixel format for fbc" from Ville Syrjälä. The idea is the same, but the code is different due to all the changes that happened since his original patch. So any bugs are due to my bad rewrite.
Testcases: igt/kms_frontbuffer_tracking/*fbc*-${format_name}-draw-*
Credits-to: Ville Syrjälä <[email protected]>Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_fbc.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -947,6 +947,7 @@ struct i915_fbc {FBC_IN_DBG_MASTER ,/* kernel debugger is active */ FBC_BAD_STRIDE ,/* stride is not supported */ FBC_PIXEL_RATE ,/* pixel rate is too big */ + FBC_PIXEL_FORMAT /* pixel format is invalid */ } no_fbc_reason;bool (*fbc_enabled)(struct drm_i915_private *dev_priv);drivers/gpu/drm/i915/intel_fbc.c +8
-0@@ -505,6 +505,8 @@ const char *intel_no_fbc_reason_str(enum no_fbc_reason reason)return "framebuffer stride not supported" ;case FBC_PIXEL_RATE :return "pixel rate is too big" ; +case FBC_PIXEL_FORMAT : +return "pixel format is invalid" ;default :MISSING_CASE (reason);return "unknown reason" ;@@ -731,6 +733,34 @@ static bool stride_is_valid(unsigned int stride)return true; } +static bool pixel_format_is_valid (struct drm_framebuffer *fb) +{ +struct drm_device *dev = fb->dev; +struct drm_i915_private *dev_priv = dev->dev_private; + +/* Primary planes don't support alpha, so the "A" formats and "X"
drivers/gpu/drm/i915/intel_fbc.c static bool stride_is_valid(unsigned int stride) · line 751
Quoted 10 lines
drivers/gpu/drm/i915/intel_fbc.c +10
-0+* formats are one and the same. */ +switch (fb->pixel_format) { +case DRM_FORMAT_XRGB8888 : +case DRM_FORMAT_ARGB8888 : +case DRM_FORMAT_XBGR8888 : +case DRM_FORMAT_ABGR8888 : +return true; +case DRM_FORMAT_XRGB1555 : +case DRM_FORMAT_ARGB1555 : +case DRM_FORMAT_RGB565 :
I think we've since concluded that ARGB format implies alpha blending, and removed the ARGB formats for most platforms from the list of supported formats. However SKL includes ARGB in it's list of formats, and I think it enables alpha blending when encountering it. Since FBC is not compatible with alpha blending we should drop the alpha formats from this list.
Quoted 34 lines
drivers/gpu/drm/i915/intel_fbc.c +17
-0+/* 16bpp not supported on gen2 */ +if (IS_GEN2 (dev)) +return false; +/* WaFbcOnly1to1Ratio:ctg */ +if (IS_G4X (dev_priv)) +return false; +return true; +default : +return false; + } +} +/** * __intel_fbc_update - enable/disable FBC as needed, unlocked * @dev_priv: i915 device instance @@ -846,6 +876,11 @@ static void __intel_fbc_update(struct drm_i915_private *dev_priv) goto out_disable; } +if (!pixel_format_is_valid (fb)) { +set_no_fbc_reason (dev_priv,FBC_PIXEL_FORMAT ); + goto out_disable; + } +/* If the kernel debugger is active, always disable compression */ if (in_dbg_master ()) {set_no_fbc_reason (dev_priv,FBC_IN_DBG_MASTER );Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx