Yet another FBC series, v3 part 2
Subsystems (2)
cover Yet another FBC series, v3 part 2
Hi
Here are other 12 patches from the last series of 26 which I sent two weeks ago. The only things missing are the patch that does the flip optimizations - since it had a bug caught by Ville - and a patch requested by Chris related to getting framebuffer references or proving we don't need them. I'm leaving these to a next patch series, since my plans for them includes multiple patches.
Thanks,
Paulo
Paulo Zanoni (12):
drm/i915: fix the CFB size check
drm/i915: set dev_priv->fbc.crtc before scheduling the enable work drm/i915: pass the crtc as an argument to intel_fbc_update() drm/i915: introduce is_active/activate/deactivate to the FBC
terminology
drm/i915: introduce intel_fbc_{enable,disable} drm/i915: alloc/free the FBC CFB during enable/disable drm/i915: check for FBC planes in the same place as the pipes drm/i915: use a single intel_fbc_work struct
drm/i915: wait for a vblank instead of 50ms when enabling FBC drm/i915: kill fbc.uncompressed_size
drm/i915: get rid of FBC {,de}activation messages drm/i915: only nuke FBC when a drawing operation triggers a flush
drivers/gpu/drm/i915/i915_debugfs.c | 2 +- drivers/gpu/drm/i915/i915_drv.h | 17 +- drivers/gpu/drm/i915/intel_display.c | 23 +- drivers/gpu/drm/i915/intel_drv.h | 6 +- drivers/gpu/drm/i915/intel_fbc.c | 602 +++++++++++++++++++---------------- drivers/gpu/drm/i915/intel_pm.c | 2 +- 6 files changed, 351 insertions(+), 301 deletions(-)
Signature · 6 lines
2.6.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/12 drm/i915: fix the CFB size check
In function find_compression_threshold() we try to over-allocate CFB space in order to reduce reallocations and fragmentation, and we're not considering that at the CFB size check. Consider it.
There is also a longer-term plan to kill dev_priv->fbc.uncompressed_size, but this will come later.
--- drivers/gpu/drm/i915/intel_fbc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_fbc.c +2 -1
@@ -720,7 +720,8 @@ static int intel_fbc_setup_cfb(struct intel_crtc *crtc) size =intel_fbc_calculate_cfb_size (crtc); cpp =drm_format_plane_cpp (fb->pixel_format,0 ); -if (size <= dev_priv->fbc.uncompressed_size) +if (dev_priv->fbc.compressed_fb.allocated && + size <= dev_priv->fbc.compressed_fb.size * dev_priv->fbc.threshold)return 0 ;/* Release any current block */
Signature · 6 lines
2.6.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 01/12] drm/i915: fix the CFB size check
Quoted 17 lines · Paulo Zanoni
In function
find_compression_threshold()we try to over-allocate CFB space in order to reduce reallocations and fragmentation, and we're not considering that at the CFB size check. Consider it.There is also a longer-term plan to kill
dev_priv->fbc.uncompressed_size, but this will come later.Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/intel_fbc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_fbc.c +0
-0
drivers/gpu/drm/i915/intel_fbc.c static int intel_fbc_setup_cfb(struct intel_crtc *crtc) · line 725
Quoted 7 lines
drivers/gpu/drm/i915/intel_fbc.c +2
-1@@ -720,7 +720,8 @@ static int intel_fbc_setup_cfb(struct intel_crtc *crtc) size =intel_fbc_calculate_cfb_size (crtc); cpp =drm_format_plane_cpp (fb->pixel_format,0 ); -if (size <= dev_priv->fbc.uncompressed_size) +if (dev_priv->fbc.compressed_fb.allocated && + size <= dev_priv->fbc.compressed_fb.size * dev_priv->fbc.threshold)return 0 ;
Hmm, not sure if it would be worth just clearing compressed_fb.size after remove.
But at any rate, you want to usedrm_mm_node_allocated(&fbc.compressed_fb).
With that minor change,
-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 2/12 drm/i915: set dev_priv->fbc.crtc before scheduling the enable work
In reply to Paulo ZanoniThis thing where we need to get the crtc either from the work structure or the fbc structure itself is confusing and unnecessary. Set fbc.crtc right when scheduling the enable work so we can always use it.
The problem is not what gets passed and how to retrieve it. The problem is that when we're in the other parts of the code we always have to keep in mind that if FBC is already enabled we have to get the CRTC from place A, if FBC is scheduled we have to get the CRTC from place B, and if it's disabled there's no CRTC. Having a single place to retrieve the CRTC from allows us to treat the "is enabled" and "is scheduled" cases as the same case, reducing the mistake surface. I guess I should add this to the commit message.
Besides the immediate advantages, this is also going to make one of the next commits much simpler. And even later, when we introduce enable/disable + activate/deactivate, this will be even simpler as we'll set the CRTC at enable time. So all the activate/deactivate/update code can just look at the single CRTC variable regardless of the current state.
v2: Improve commit message (Chris).
v3: Rebase after changing the patch order.
--- drivers/gpu/drm/i915/i915_drv.h | 1 - drivers/gpu/drm/i915/intel_fbc.c | 22 +++++++++------------- 2 files changed, 9 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -1
@@ -920,7 +920,6 @@ struct i915_fbc {struct intel_fbc_work {struct delayed_work work; -struct intel_crtc *crtc;struct drm_framebuffer *fb; } *fbc_work;
drivers/gpu/drm/i915/intel_fbc.c +9 -13
@@ -334,14 +334,13 @@ bool intel_fbc_enabled(struct drm_i915_private *dev_priv)return dev_priv->fbc.enabled; } -static void intel_fbc_enable (struct intel_crtc *crtc, -const struct drm_framebuffer *fb) +static void intel_fbc_enable (const struct drm_framebuffer *fb) { -struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; +struct drm_i915_private *dev_priv = fb->dev->dev_private; +struct intel_crtc *crtc = dev_priv->fbc.crtc; 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; }
@@ -351,8 +350,8 @@ static void intel_fbc_work_fn(struct work_struct *__work)struct intel_fbc_work *work =container_of (to_delayed_work (__work), struct intel_fbc_work, work); -struct drm_i915_private *dev_priv = work->crtc->base.dev->dev_private; -struct drm_framebuffer *crtc_fb = work->crtc->base.primary->fb; +struct drm_i915_private *dev_priv = work->fb->dev->dev_private; +struct drm_framebuffer *crtc_fb = dev_priv->fbc.crtc->base.primary->fb;mutex_lock (&dev_priv->fbc.lock);if (work == dev_priv->fbc.fbc_work) {
@@ -360,7 +359,7 @@ static void intel_fbc_work_fn(struct work_struct *__work)* the prior work. */ if (crtc_fb == work->fb) -intel_fbc_enable (work->crtc, work->fb); +intel_fbc_enable (work->fb); dev_priv->fbc.fbc_work =NULL ; }
@@ -400,15 +399,15 @@ static void intel_fbc_schedule_enable(struct intel_crtc *crtc)WARN_ON (!mutex_is_locked (&dev_priv->fbc.lock));intel_fbc_cancel_work (dev_priv); + dev_priv->fbc.crtc = crtc; work =kzalloc (sizeof (*work),GFP_KERNEL );if (work ==NULL ) {DRM_ERROR ("Failed to allocate FBC work structure\n" ); -intel_fbc_enable (crtc, crtc->base.primary->fb); +intel_fbc_enable (crtc->base.primary->fb);return ; } - work->crtc = crtc; work->fb = crtc->base.primary->fb;INIT_DELAYED_WORK (&work->work, intel_fbc_work_fn);
@@ -984,11 +983,8 @@ void intel_fbc_invalidate(struct drm_i915_private *dev_priv,mutex_lock (&dev_priv->fbc.lock); -if (dev_priv->fbc.enabled) +if (dev_priv->fbc.enabled || dev_priv->fbc.fbc_work) fbc_bits =INTEL_FRONTBUFFER_PRIMARY (dev_priv->fbc.crtc->pipe); -else if (dev_priv->fbc.fbc_work) - fbc_bits =INTEL_FRONTBUFFER_PRIMARY ( - dev_priv->fbc.fbc_work->crtc->pipe);else fbc_bits = dev_priv->fbc.possible_framebuffer_bits;
Signature · 6 lines
2.6.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 02/12] drm/i915: set dev_priv->fbc.crtc before scheduling the enable work
Quoted 47 lines · Paulo Zanoni
This thing where we need to get the crtc either from the work structure or the fbc structure itself is confusing and unnecessary. Set fbc.crtc right when scheduling the enable work so we can always use it.
The problem is not what gets passed and how to retrieve it. The problem is that when we're in the other parts of the code we always have to keep in mind that if FBC is already enabled we have to get the CRTC from place A, if FBC is scheduled we have to get the CRTC from place B, and if it's disabled there's no CRTC. Having a single place to retrieve the CRTC from allows us to treat the "is enabled" and "is scheduled" cases as the same case, reducing the mistake surface. I guess I should add this to the commit message.
Besides the immediate advantages, this is also going to make one of the next commits much simpler. And even later, when we introduce enable/disable + activate/deactivate, this will be even simpler as we'll set the CRTC at enable time. So all the activate/deactivate/update code can just look at the single CRTC variable regardless of the current state.
v2: Improve commit message (Chris).
v3: Rebase after changing the patch order.Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 1 - drivers/gpu/drm/i915/intel_fbc.c | 22 +++++++++------------- 2 files changed, 9 insertions(+), 14 deletions(-)drivers/gpu/drm/i915/i915_drv.h +0
-1@@ -920,7 +920,6 @@ struct i915_fbc {struct intel_fbc_work {struct delayed_work work; -struct intel_crtc *crtc;struct drm_framebuffer *fb; } *fbc_work;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 340
Quoted 10 lines
drivers/gpu/drm/i915/intel_fbc.c +3
-3@@ -334,14 +334,13 @@ bool intel_fbc_enabled(struct drm_i915_private *dev_priv)return dev_priv->fbc.enabled; } -static void intel_fbc_enable (struct intel_crtc *crtc, -const struct drm_framebuffer *fb) +static void intel_fbc_enable (const struct drm_framebuffer *fb) { -struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; +struct drm_i915_private *dev_priv = fb->dev->dev_private; +struct intel_crtc *crtc = dev_priv->fbc.crtc;
This is confusing me. I think of FBC in terms of the CRTC/pipe, and the fb just describes the plane currently bound to the primary. You've pushed everywhere else to also work on the CRTC, I think it would be consistent here to pass crtc and then use fbc.fb_id = crtc->primary->fb->id.
Have I missed something in the later patches that explains the choice here?
-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 02/12] drm/i915: set dev_priv->fbc.crtc before scheduling the enable work
2015-11-13 18:56 GMT-02:00 Chris Wilson <[email protected]>:
Quoted 65 lines · Paulo Zanoni
Quoted 47 lines
This thing where we need to get the crtc either from the work structure or the fbc structure itself is confusing and unnecessary. Set fbc.crtc right when scheduling the enable work so we can always use it.
The problem is not what gets passed and how to retrieve it. The problem is that when we're in the other parts of the code we always have to keep in mind that if FBC is already enabled we have to get the CRTC from place A, if FBC is scheduled we have to get the CRTC from place B, and if it's disabled there's no CRTC. Having a single place to retrieve the CRTC from allows us to treat the "is enabled" and "is scheduled" cases as the same case, reducing the mistake surface. I guess I should add this to the commit message.
Besides the immediate advantages, this is also going to make one of the next commits much simpler. And even later, when we introduce enable/disable + activate/deactivate, this will be even simpler as we'll set the CRTC at enable time. So all the activate/deactivate/update code can just look at the single CRTC variable regardless of the current state.
v2: Improve commit message (Chris).
v3: Rebase after changing the patch order.Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 1 - drivers/gpu/drm/i915/intel_fbc.c | 22 +++++++++------------- 2 files changed, 9 insertions(+), 14 deletions(-)drivers/gpu/drm/i915/i915_drv.h +0
-1@@ -920,7 +920,6 @@ struct i915_fbc {struct intel_fbc_work {struct delayed_work work; -struct intel_crtc *crtc;struct drm_framebuffer *fb; } *fbc_work;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 340
Quoted 10 lines
drivers/gpu/drm/i915/intel_fbc.c +3
-3@@ -334,14 +334,13 @@ bool intel_fbc_enabled(struct drm_i915_private *dev_priv)return dev_priv->fbc.enabled; } -static void intel_fbc_enable (struct intel_crtc *crtc, -const struct drm_framebuffer *fb) +static void intel_fbc_enable (const struct drm_framebuffer *fb) { -struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; +struct drm_i915_private *dev_priv = fb->dev->dev_private; +struct intel_crtc *crtc = dev_priv->fbc.crtc;This is confusing me. I think of FBC in terms of the CRTC/pipe, and the fb just describes the plane currently bound to the primary. You've pushed everywhere else to also work on the CRTC, I think it would be consistent here to pass crtc and then use fbc.fb_id =
crtc->primary->fb->id.
Quoted 2 lines
Have I missed something in the later patches that explains the choice here?
You are right that this is confusing. This is basically an artifact from the previous FBC design that I overlooked. I guess during the conversion, my thinking was "well, the arguments are the stuff we store in the work struct, and since we don't store the CRTC anymore, let's remove it and keep passing the FB since it's still part of the work struct". Now that you bring this under a different perspective, I see the problem. We don't even need to pass these things as arguments since we do check that work->fb is equal to crtc->fb.
I just hope you let me address this with follow-up patches. Function intel_fbc_activate() was created because there were 2 callers: one for the case there the work_fn happens, another for the case where we failed to allocate the work_fn. Later in the series there's only one caller because there's no allocation anymore, so the best way to fix is probably to just move those 3 lines to the place of the only caller.
You also requested me to grab references of fbc.fb_id, and I have some evil plans to completely kill it, which would even reduce those 3 lines further.
Thanks,
Paulo
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
Chris Wilson
Reviewed-byRe: [PATCH 02/12] drm/i915: set dev_priv->fbc.crtc before scheduling the enable work
Quoted 86 lines · Paulo Zanoni
2015-11-13 18:56 GMT-02:00 Chris Wilson <[email protected]>:
Quoted 65 lines · Paulo Zanoni
Quoted 47 lines
This thing where we need to get the crtc either from the work structure or the fbc structure itself is confusing and unnecessary. Set fbc.crtc right when scheduling the enable work so we can always use it.
The problem is not what gets passed and how to retrieve it. The problem is that when we're in the other parts of the code we always have to keep in mind that if FBC is already enabled we have to get the CRTC from place A, if FBC is scheduled we have to get the CRTC from place B, and if it's disabled there's no CRTC. Having a single place to retrieve the CRTC from allows us to treat the "is enabled" and "is scheduled" cases as the same case, reducing the mistake surface. I guess I should add this to the commit message.
Besides the immediate advantages, this is also going to make one of the next commits much simpler. And even later, when we introduce enable/disable + activate/deactivate, this will be even simpler as we'll set the CRTC at enable time. So all the activate/deactivate/update code can just look at the single CRTC variable regardless of the current state.
v2: Improve commit message (Chris).
v3: Rebase after changing the patch order.Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 1 - drivers/gpu/drm/i915/intel_fbc.c | 22 +++++++++------------- 2 files changed, 9 insertions(+), 14 deletions(-)drivers/gpu/drm/i915/i915_drv.h +0
-1@@ -920,7 +920,6 @@ struct i915_fbc {struct intel_fbc_work {struct delayed_work work; -struct intel_crtc *crtc;struct drm_framebuffer *fb; } *fbc_work;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 340
Quoted 10 lines
drivers/gpu/drm/i915/intel_fbc.c +3
-3@@ -334,14 +334,13 @@ bool intel_fbc_enabled(struct drm_i915_private *dev_priv)return dev_priv->fbc.enabled; } -static void intel_fbc_enable (struct intel_crtc *crtc, -const struct drm_framebuffer *fb) +static void intel_fbc_enable (const struct drm_framebuffer *fb) { -struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; +struct drm_i915_private *dev_priv = fb->dev->dev_private; +struct intel_crtc *crtc = dev_priv->fbc.crtc;This is confusing me. I think of FBC in terms of the CRTC/pipe, and the fb just describes the plane currently bound to the primary. You've pushed everywhere else to also work on the CRTC, I think it would be consistent here to pass crtc and then use fbc.fb_id =
crtc->primary->fb->id.Quoted 2 lines
Have I missed something in the later patches that explains the choice here?
You are right that this is confusing. This is basically an artifact from the previous FBC design that I overlooked. I guess during the conversion, my thinking was "well, the arguments are the stuff we store in the work struct, and since we don't store the CRTC anymore, let's remove it and keep passing the FB since it's still part of the work struct". Now that you bring this under a different perspective, I see the problem. We don't even need to pass these things as arguments since we do check that
work->fbis equal tocrtc->fb.I just hope you let me address this with follow-up patches. Function
intel_fbc_activate()was created because there were 2 callers: one for the case there thework_fnhappens, another for the case where we failed to allocate thework_fn. Later in the series there's only one caller because there's no allocation anymore, so the best way to fix is probably to just move those 3 lines to the place of the only caller.
Quoted 3 lines
You also requested me to grab references of fbc.fb_id, and I have some evil plans to completely kill it, which would even reduce those 3 lines further.
If you have it in hand, the rest seems fine, so
-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 02/12] drm/i915: set dev_priv->fbc.crtc before scheduling the enable work
In reply to Paulo ZanoniHi,
Quoted 10 lines · Paulo Zanoni
2015-11-13 18:56 GMT-02:00 Chris Wilson <[email protected]>:
Quoted 8 lines
This is confusing me. I think of FBC in terms of the CRTC/pipe, and the fb just describes the plane currently bound to the primary. You've pushed everywhere else to also work on the CRTC, I think it would be consistent here to pass crtc and then use fbc.fb_id =
crtc->primary->fb->id.Have I missed something in the later patches that explains the choice here?
Quoted 8 lines
You are right that this is confusing. This is basically an artifact from the previous FBC design that I overlooked. I guess during the conversion, my thinking was "well, the arguments are the stuff we store in the work struct, and since we don't store the CRTC anymore, let's remove it and keep passing the FB since it's still part of the work struct". Now that you bring this under a different perspective, I see the problem. We don't even need to pass these things as arguments since we do check that
work->fbis equal tocrtc->fb.
With async modesetting on its way, this won't actually hold true for long. Tracking the fb separately, rather than pulling it back out of the CRTC, is the right thing to do here.
Basically, if you ever want to check crtc->primary->fb, and you're not in atomic_check, you're doing it wrong.
Cheers,
Daniel
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/12 drm/i915: pass the crtc as an argument to intel_fbc_update()
In reply to Paulo ZanoniThere's no need to reevaluate the status of every single crtc when a single crtc changes its state.
With this, we're cutting the case where due to a change in pipe B, intel_fbc_update() is called, then intel_fbc_find_crtc() concludes FBC should be enabled on pipe A, then it completely rechecks the state of pipe A only to conclude FBC should remain enabled on pipe A. If any change on pipe A triggers a need to recompute whether FBC is valid on pipe A, then at some point someone is going to call intel_fbc_update(PIPE_A).
The addition of intel_fbc_deactivate() is necessary so we keep track of the previously selected CRTC when we do invalidate/flush. We're also going to continue the enable/disable/activate/deactivate concept in the next patches.
v2: Rebase.
v3: Rebase after changing the patch order.
--- drivers/gpu/drm/i915/intel_display.c | 3 +- drivers/gpu/drm/i915/intel_drv.h | 2 +- drivers/gpu/drm/i915/intel_fbc.c | 68 +++++++++++++++--------------------- 3 files changed, 31 insertions(+), 42 deletions(-)
drivers/gpu/drm/i915/intel_display.c +1 -2
@@ -4761,7 +4761,6 @@ static void intel_post_plane_update(struct intel_crtc *crtc) {struct intel_crtc_atomic_commit *atomic = &crtc->atomic;struct drm_device *dev = crtc->base.dev; -struct drm_i915_private *dev_priv = dev->dev_private;if (atomic->wait_vblank)intel_wait_for_vblank (dev, crtc->pipe);
@@ -4775,7 +4774,7 @@ static void intel_post_plane_update(struct intel_crtc *crtc)intel_update_watermarks (&crtc->base);if (atomic->update_fbc) -intel_fbc_update (dev_priv); +intel_fbc_update (crtc);if (atomic->post_enable_primary)intel_post_enable_primary (&crtc->base);
drivers/gpu/drm/i915/intel_drv.h +1 -1
@@ -1323,7 +1323,7 @@ static inline void intel_fbdev_restore_mode(struct drm_device *dev)/* intel_fbc.c */ bool intel_fbc_enabled (struct drm_i915_private *dev_priv); -void intel_fbc_update (struct drm_i915_private *dev_priv); +void intel_fbc_update (struct intel_crtc *crtc);void intel_fbc_init (struct drm_i915_private *dev_priv);void intel_fbc_disable (struct drm_i915_private *dev_priv);void intel_fbc_disable_crtc (struct intel_crtc *crtc);
drivers/gpu/drm/i915/intel_fbc.c +29 -39
145 lines not on this page · raw message
Signature · 6 lines
2.6.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 03/12] drm/i915: pass the crtc as an argument to intel_fbc_update()
Quoted 16 lines · Paulo Zanoni
There's no need to reevaluate the status of every single crtc when a single crtc changes its state.
With this, we're cutting the case where due to a change in pipe B,
intel_fbc_update()is called, thenintel_fbc_find_crtc()concludes FBC should be enabled on pipe A, then it completely rechecks the state of pipe A only to conclude FBC should remain enabled on pipe A. If any change on pipe A triggers a need to recompute whether FBC is valid on pipe A, then at some point someone is going to callintel_fbc_update(PIPE_A).The addition of
intel_fbc_deactivate()is necessary so we keep track of the previously selected CRTC when we do invalidate/flush. We're also going to continue the enable/disable/activate/deactivate concept in the next patches.
Quoted 4 lines
v2: Rebase.
v3: Rebase after changing the patch order.Signed-off-by Paulo Zanoni <[email protected]>
-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 4/12 drm/i915: introduce is_active/activate/deactivate to the FBC terminology
In reply to Paulo ZanoniThe long term goal is to have enable/disable as the higher level functions and activate/deactivate as the lower level functions, just like we do for PSR and for the CRTC. This way, we'll run enable and disable once per modeset, while update, activate and deactivate will be run many times. With this, we can move the checks and code that need to run only once per modeset to enable(), making the code simpler and possibly a little faster.
This patch is just the first step on the conversion: it starts by converting the current low level functions from enable/disable to activate/deactivate. This patch by itself has no benefits other than making review and rebase easier. Please see the next patches for more details on the conversion.
v2:
- Rebase.
- Improve commit message (Chris).
v3: Rebase after changing the patch order.
--- drivers/gpu/drm/i915/i915_debugfs.c | 2 +- drivers/gpu/drm/i915/i915_drv.h | 10 ++- drivers/gpu/drm/i915/intel_display.c | 4 +- drivers/gpu/drm/i915/intel_drv.h | 2 +- drivers/gpu/drm/i915/intel_fbc.c | 114 +++++++++++++++++------------------ drivers/gpu/drm/i915/intel_pm.c | 2 +- 6 files changed, 66 insertions(+), 68 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -1
@@ -1639,7 +1639,7 @@ static int i915_fbc_status(struct seq_file *m, void *unused)intel_runtime_pm_get (dev_priv);mutex_lock (&dev_priv->fbc.lock); -if (intel_fbc_enabled (dev_priv)) +if (intel_fbc_is_active (dev_priv))seq_puts (m,"FBC enabled\n" );else seq_printf(m, "FBC disabled: %s\n",
drivers/gpu/drm/i915/i915_drv.h +4 -6
@@ -914,9 +914,7 @@ struct i915_fbc {bool false_color; -/* Tracks whether the HW is actually enabled, not whether the feature is -* possible. */ -bool enabled; +bool active;struct intel_fbc_work {struct delayed_work work;
@@ -925,9 +923,9 @@ struct i915_fbc {const char *no_fbc_reason; -bool (*fbc_enabled)(struct drm_i915_private *dev_priv); -void (*enable_fbc)(struct intel_crtc *crtc); -void (*disable_fbc)(struct drm_i915_private *dev_priv); +bool (*is_active)(struct drm_i915_private *dev_priv); +void (*activate)(struct intel_crtc *crtc); +void (*deactivate)(struct drm_i915_private *dev_priv); };/**
drivers/gpu/drm/i915/intel_display.c +2 -2
@@ -3176,8 +3176,8 @@ intel_pipe_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb,struct drm_device *dev = crtc->dev;struct drm_i915_private *dev_priv = dev->dev_private; -if (dev_priv->fbc.disable_fbc) - dev_priv->fbc.disable_fbc (dev_priv); +if (dev_priv->fbc.deactivate) + dev_priv->fbc.deactivate (dev_priv); dev_priv->display.update_primary_plane (crtc, fb, x, y);
drivers/gpu/drm/i915/intel_drv.h +1 -1
@@ -1322,7 +1322,7 @@ static inline void intel_fbdev_restore_mode(struct drm_device *dev)#endif /* intel_fbc.c */ -bool intel_fbc_enabled (struct drm_i915_private *dev_priv); +bool intel_fbc_is_active (struct drm_i915_private *dev_priv);void intel_fbc_update (struct intel_crtc *crtc);void intel_fbc_init (struct drm_i915_private *dev_priv);void intel_fbc_disable (struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/intel_fbc.c +57 -57
314 lines not on this page · raw message
drivers/gpu/drm/i915/intel_pm.c +1 -1
@@ -2422,7 +2422,7 @@ static void ilk_wm_merge(struct drm_device *dev,* enabled sometime later. */ if (IS_GEN5 (dev) && !merged->fbc_wm_enabled && -intel_fbc_enabled (dev_priv)) { +intel_fbc_is_active (dev_priv)) {for (level =2 ; level <= max_level; level++) {struct intel_wm_level *wm = &merged->wm[level];
Signature · 6 lines
2.6.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 04/12] drm/i915: introduce is_active/activate/deactivate to the FBC terminology
Quoted 14 lines · Paulo Zanoni
The long term goal is to have enable/disable as the higher level functions and activate/deactivate as the lower level functions, just like we do for PSR and for the CRTC. This way, we'll run enable and disable once per modeset, while update, activate and deactivate will be run many times. With this, we can move the checks and code that need to run only once per modeset to
enable(), making the code simpler and possibly a little faster.This patch is just the first step on the conversion: it starts by converting the current low level functions from enable/disable to activate/deactivate. This patch by itself has no benefits other than making review and rebase easier. Please see the next patches for more details on the conversion.
Quoted 6 lines
v2:
- Rebase.
- Improve commit message (Chris).
v3: Rebase after changing the patch order.Signed-off-by Paulo Zanoni <[email protected]>
-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 5/12 drm/i915: introduce intel_fbc_{enable, disable}
In reply to Paulo ZanoniThe goal is to call FBC enable/disable only once per modeset, while activate/deactivate/update will be called multiple times.
The enable() function will be responsible for deciding if a CRTC will have FBC on it and then it will "lock" FBC on this CRTC: it won't be possible to change FBC's CRTC until disable(). With this, all checks and resource acquisition that only need to be done once per modeset can be moved from update() to enable(). And then the update(), activate() and deactivate() code will also get simpler since they won't need to worry about the CRTC being changed.
The disable() function will do the reverse operation of enable(). One of its features is that it should only be called while the pipe is already off. This guarantees that FBC is stopped and nothing is using the CFB.
With this, the activate() and deactivate() functions just start and temporarily stop FBC. They are the ones touching the hardware enable bit, so HW state reflects dev_priv->crtc.active.
The last function remaining is update(). A lot of times I thought about renaming update() to activate() or try_to_activate() since it's called when we want to activate FBC. The thing is that update() may not only decide to activate FBC, but also deactivate or keep it on the same state, so I'll leave this name for now.
Moving code to enable() and disable() will also help in case we decide to move FBC to pipe_config or something else later.
The current patch only puts the very basic code on enable() and disable(). The next commits will take care of moving more stuff from update() to the new functions.
v2:
- Rebase.
- Improve commit message (Chris).
v3: Rebase after changing the patch order.
v4: Rebase again after upstream changes.
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_display.c | 16 ++- drivers/gpu/drm/i915/intel_drv.h | 2 + drivers/gpu/drm/i915/intel_fbc.c | 196 +++++++++++++++++++++++++---------- 4 files changed, 157 insertions(+), 58 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -914,6 +914,7 @@ struct i915_fbc {bool false_color; +bool enabled;bool active;struct intel_fbc_work {
drivers/gpu/drm/i915/intel_display.c +14 -2
@@ -4789,7 +4789,7 @@ static void intel_pre_plane_update(struct intel_crtc *crtc)struct intel_crtc_atomic_commit *atomic = &crtc->atomic;if (atomic->disable_fbc) -intel_fbc_disable_crtc (crtc); +intel_fbc_deactivate (crtc);if (crtc->atomic.disable_ips)hsw_disable_ips (crtc);
@@ -4897,6 +4897,8 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc)if (intel_crtc->config->has_pch_encoder)intel_wait_for_vblank (dev, pipe);intel_set_pch_fifo_underrun_reporting (dev_priv, pipe, true); + +intel_fbc_enable (intel_crtc); }/* IPS only exists on ULT machines and is tied to pipe A. */
@@ -5004,6 +5006,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)intel_wait_for_vblank (dev, hsw_workaround_pipe);intel_wait_for_vblank (dev, hsw_workaround_pipe); } + +intel_fbc_enable (intel_crtc); }static void ironlake_pfit_disable (struct intel_crtc *crtc,bool force)
@@ -5072,6 +5076,8 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc) }intel_set_pch_fifo_underrun_reporting (dev_priv, pipe, true); + +intel_fbc_disable_crtc (intel_crtc); }static void haswell_crtc_disable (struct drm_crtc *crtc)
@@ -5123,6 +5129,8 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)if (intel_crtc->config->has_pch_encoder)intel_set_pch_fifo_underrun_reporting (dev_priv,TRANSCODER_A , true); + +intel_fbc_disable_crtc (intel_crtc); }static void i9xx_pfit_enable (struct intel_crtc *crtc)
@@ -6188,6 +6196,8 @@ static void i9xx_crtc_enable(struct drm_crtc *crtc)for_each_encoder_on_crtc (dev, crtc, encoder) encoder->enable (encoder); + +intel_fbc_enable (intel_crtc); }static void i9xx_pfit_disable (struct intel_crtc *crtc)
@@ -6250,6 +6260,8 @@ static void i9xx_crtc_disable(struct drm_crtc *crtc)if (!IS_GEN2 (dev))intel_set_cpu_fifo_underrun_reporting (dev_priv, pipe, false); + +intel_fbc_disable_crtc (intel_crtc); }static void intel_crtc_disable_noatomic (struct drm_crtc *crtc)
@@ -11523,7 +11535,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, to_intel_plane(primary)->frontbuffer_bit);mutex_unlock (&dev->struct_mutex); -intel_fbc_disable_crtc (intel_crtc); +intel_fbc_deactivate (intel_crtc);intel_frontbuffer_flip_prepare (dev,to_intel_plane (primary)->frontbuffer_bit);
drivers/gpu/drm/i915/intel_drv.h +2 -0
@@ -1323,8 +1323,10 @@ static inline void intel_fbdev_restore_mode(struct drm_device *dev)/* intel_fbc.c */ bool intel_fbc_is_active (struct drm_i915_private *dev_priv); +void intel_fbc_deactivate (struct intel_crtc *crtc);void intel_fbc_update (struct intel_crtc *crtc);void intel_fbc_init (struct drm_i915_private *dev_priv); +void intel_fbc_enable (struct intel_crtc *crtc);void intel_fbc_disable (struct drm_i915_private *dev_priv);void intel_fbc_disable_crtc (struct intel_crtc *crtc); void intel_fbc_invalidate(struct drm_i915_private *dev_priv,
drivers/gpu/drm/i915/intel_fbc.c +140 -56
301 lines not on this page · raw message
Signature · 6 lines
2.6.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 05/12] drm/i915: introduce intel_fbc_{enable, disable}
Quoted 33 lines · Paulo Zanoni
The goal is to call FBC enable/disable only once per modeset, while activate/deactivate/update will be called multiple times.
The
enable()function will be responsible for deciding if a CRTC will have FBC on it and then it will "lock" FBC on this CRTC: it won't be possible to change FBC's CRTC untildisable(). With this, all checks and resource acquisition that only need to be done once per modeset can be moved fromupdate()toenable(). And then theupdate(),activate()anddeactivate()code will also get simpler since they won't need to worry about the CRTC being changed.The
disable()function will do the reverse operation ofenable(). One of its features is that it should only be called while the pipe is already off. This guarantees that FBC is stopped and nothing is using the CFB.With this, the
activate()anddeactivate()functions just start and temporarily stop FBC. They are the ones touching the hardware enable bit, so HW state reflectsdev_priv->crtc.active.The last function remaining is
update(). A lot of times I thought about renamingupdate()toactivate()ortry_to_activate()since it's called when we want to activate FBC. The thing is thatupdate()may not only decide to activate FBC, but also deactivate or keep it on the same state, so I'll leave this name for now.Moving code to
enable()anddisable()will also help in case we decide to move FBC topipe_configor something else later.The current patch only puts the very basic code on
enable()anddisable(). The next commits will take care of moving more stuff fromupdate()to the new functions.
Quoted 7 lines
v2:
- Rebase.
- Improve commit message (Chris).
v3: Rebase after changing the patch order.
v4: Rebase again after upstream changes.Signed-off-by Paulo Zanoni <[email protected]>
-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 6/12 drm/i915: alloc/free the FBC CFB during enable/disable
In reply to Paulo ZanoniOne of the problems with the current code is that it frees the CFB and releases its drm_mm node as soon as we flip FBC's enable bit. This is bad because after we disable FBC the hardware may still use the CFB for the rest of the frame, so in theory we should only release the drm_mm node one frame after we disable FBC. Otherwise, a stolen memory allocation done right after an FBC disable may result in either corrupted memory for the new owner of that memory region or corrupted screen/underruns in case the new owner changes it while the hardware is still reading it. This case is not exactly easy to reproduce since we currently don't do a lot of stolen memory allocations, but I see patches on the mailing list trying to expose stolen memory to user space, so races will be possible.
I thought about three different approaches to solve this, and they all have downsides.
The first approach would be to simply use multiple drm_mm nodes and freeing the unused ones only after a frame has passed. The problem with this approach is that since stolen memory is rather small, there's a risk we just won't be able to allocate a new CFB from stolen if the previous one was not freed yet. This could happen in case we quickly disable FBC from pipe A and decide to enable it on pipe B, or just if we change pipe A's fb stride while FBC is enabled.
The second approach would be similar to the first one, but maintaining a single drm_mm node and keeping track of when it can be reused. This would remove the disadvantage of not having enough space for two nodes, but would create the new problem where we may not be able to enable FBC at the point intel_fbc_update() is called, so we would have to add more code to retry updating FBC after the time has passed. And that can quickly get too complex since we can get invalidate, flush, disable and other calls in the middle of the wait.
Both solutions above - and also the current code - have the problem that we unnecessarily free+realloc FBC during invalidate+flush operations even if the CFB size doesn't change.
The third option would be to move the allocation/deallocation to enable/disable. This makes sure that the pipe is always disabled when we allocate/deallocate the CFB, so there's no risk that the FBC hardware may read or write to the memory right after it is freed from drm_mm. The downside is that it is possible for user space to change the buffer stride without triggering a disable/enable - only deactivate/activate -, so we'll have to handle this case somehow, even though it is uncommon - see igt's kms_frontbuffer_tracking test, fbc-stridechange subtest. It could be possible to implement a way to free+alloc the CFB during said stride change, but it would involve a lot of book-keeping - exactly as mentioned above - just for a rare case, so for now I'll keep it simple and just deactivate FBC. Besides, we may not even need to disable FBC since we do CFB over-allocation.
v2: Rebase after changing the patch order.
--- drivers/gpu/drm/i915/intel_fbc.c | 134 ++++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 65 deletions(-)
drivers/gpu/drm/i915/intel_fbc.c +69 -65
@@ -64,6 +64,46 @@ static unsigned int get_crtc_fence_y_offset(struct intel_crtc *crtc)return crtc->base.y - crtc->adjusted_y; } +/* +* For SKL+, the plane source size used by the hardware is based on the value we +* write to the PLANE_SIZE register. For BDW-, the hardware looks at the value +* we wrote to PIPESRC. +*/ +static void intel_fbc_get_plane_source_size (struct intel_crtc *crtc, +int *width,int *height) +{ +struct intel_plane_state *plane_state = +to_intel_plane_state (crtc->base.primary->state); +int w, h; + +if (intel_rotation_90_or_270 (plane_state->base.rotation)) { + w =drm_rect_height (&plane_state->src) >>16 ; + h =drm_rect_width (&plane_state->src) >>16 ; + }else { + w =drm_rect_width (&plane_state->src) >>16 ; + h =drm_rect_height (&plane_state->src) >>16 ; + } + +if (width) + *width = w; +if (height) + *height = h; +} + +static int intel_fbc_calculate_cfb_size (struct intel_crtc *crtc, +struct drm_framebuffer *fb) +{ +struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; +int lines; + +intel_fbc_get_plane_source_size (crtc,NULL , &lines); +if (INTEL_INFO (dev_priv)->gen >=7 ) + lines =min (lines,2048 ); + +/* Hardware needs the full buffer stride, not just the active area. */ +return lines * fb->pitches[0 ]; +} +static void i8xx_fbc_deactivate (struct drm_i915_private *dev_priv) {u32 fbc_ctl;
@@ -558,11 +598,17 @@ again: } } -static int intel_fbc_alloc_cfb (struct drm_i915_private *dev_priv,int size, -int fb_cpp) +static int intel_fbc_alloc_cfb (struct intel_crtc *crtc) { +struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; +struct drm_framebuffer *fb = crtc->base.primary->state->fb;struct drm_mm_node *uninitialized_var (compressed_llb ); -int ret; +int size, fb_cpp, ret; + +WARN_ON (dev_priv->fbc.compressed_fb.allocated); + + size =intel_fbc_calculate_cfb_size (crtc, fb); + fb_cpp =drm_format_plane_cpp (fb->pixel_format,0 ); ret =find_compression_threshold (dev_priv, &dev_priv->fbc.compressed_fb, size, fb_cpp);
@@ -639,65 +685,6 @@ void intel_fbc_cleanup_cfb(struct drm_i915_private *dev_priv)mutex_unlock (&dev_priv->fbc.lock); } -/* -* For SKL+, the plane source size used by the hardware is based on the value we -* write to the PLANE_SIZE register. For BDW-, the hardware looks at the value -* we wrote to PIPESRC. -*/ -static void intel_fbc_get_plane_source_size (struct intel_crtc *crtc, -int *width,int *height) -{ -struct intel_plane_state *plane_state = -to_intel_plane_state (crtc->base.primary->state); -int w, h; - -if (intel_rotation_90_or_270 (plane_state->base.rotation)) { - w =drm_rect_height (&plane_state->src) >>16 ; - h =drm_rect_width (&plane_state->src) >>16 ; - }else { - w =drm_rect_width (&plane_state->src) >>16 ; - h =drm_rect_height (&plane_state->src) >>16 ; - } - -if (width) - *width = w; -if (height) - *height = h; -} - -static int intel_fbc_calculate_cfb_size (struct intel_crtc *crtc) -{ -struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; -struct drm_framebuffer *fb = crtc->base.primary->fb; -int lines; - -intel_fbc_get_plane_source_size (crtc,NULL , &lines); -if (INTEL_INFO (dev_priv)->gen >=7 ) - lines =min (lines,2048 ); - -/* Hardware needs the full buffer stride, not just the active area. */ -return lines * fb->pitches[0 ]; -} - -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, cpp; - - size =intel_fbc_calculate_cfb_size (crtc); - cpp =drm_format_plane_cpp (fb->pixel_format,0 ); - -if (dev_priv->fbc.compressed_fb.allocated && - size <= dev_priv->fbc.compressed_fb.size * dev_priv->fbc.threshold) -return 0 ; - -/* Release any current block */ -__intel_fbc_cleanup_cfb (dev_priv); - -return intel_fbc_alloc_cfb (dev_priv, size, cpp); -} -static bool stride_is_valid (struct drm_i915_private *dev_priv,unsigned int stride) {
@@ -853,8 +840,19 @@ static void __intel_fbc_update(struct intel_crtc *crtc) goto out_disable; } -if (intel_fbc_setup_cfb (crtc)) { -set_no_fbc_reason (dev_priv,"not enough stolen memory" ); +/* It is possible for the required CFB size change without a +* crtc->disable + crtc->enable since it is possible to change the +* stride without triggering a full modeset. Since we try to +* over-allocate the CFB, there's a chance we may keep FBC enabled even +* if this happens, but if we exceed the current CFB size we'll have to +* disable FBC. Notice that it would be possible to disable FBC, wait +* for a frame, free the stolen node, then try to reenable FBC in case +* we didn't get any invalidate/deactivate calls, but this would require +* a lot of tracking just for a case we expect to be uncommon, so we +* just don't have this code for now. */ +if (intel_fbc_calculate_cfb_size (crtc, fb) > + dev_priv->fbc.compressed_fb.size * dev_priv->fbc.threshold) { +set_no_fbc_reason (dev_priv,"CFB requirements changed" ); goto out_disable; }
@@ -907,7 +905,6 @@ out_disable:DRM_DEBUG_KMS ("unsupported config, deactivating FBC\n" );__intel_fbc_deactivate (dev_priv); } -__intel_fbc_cleanup_cfb (dev_priv); }/*
@@ -1020,6 +1017,11 @@ void intel_fbc_enable(struct intel_crtc *crtc) goto out; } +if (intel_fbc_alloc_cfb (crtc)) { +set_no_fbc_reason (dev_priv,"not enough stolen memory" ); + goto out; + } +DRM_DEBUG_KMS ("Enabling FBC on pipe %c\n" ,pipe_name (crtc->pipe)); dev_priv->fbc.no_fbc_reason ="FBC enabled but not active yet\n" ;
@@ -1047,6 +1049,8 @@ static void __intel_fbc_disable(struct drm_i915_private *dev_priv)DRM_DEBUG_KMS ("Disabling FBC on pipe %c\n" ,pipe_name (crtc->pipe)); +__intel_fbc_cleanup_cfb (dev_priv); + dev_priv->fbc.enabled = false; dev_priv->fbc.crtc =NULL ; }
Signature · 6 lines
2.6.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 06/12] drm/i915: alloc/free the FBC CFB during enable/disable
Quoted 37 lines · Paulo Zanoni
One of the problems with the current code is that it frees the CFB and releases its
drm_mmnode as soon as we flip FBC's enable bit. This is bad because after we disable FBC the hardware may still use the CFB for the rest of the frame, so in theory we should only release thedrm_mmnode one frame after we disable FBC. Otherwise, a stolen memory allocation done right after an FBC disable may result in either corrupted memory for the new owner of that memory region or corrupted screen/underruns in case the new owner changes it while the hardware is still reading it. This case is not exactly easy to reproduce since we currently don't do a lot of stolen memory allocations, but I see patches on the mailing list trying to expose stolen memory to user space, so races will be possible.I thought about three different approaches to solve this, and they all have downsides.
The first approach would be to simply use multiple
drm_mmnodes and freeing the unused ones only after a frame has passed. The problem with this approach is that since stolen memory is rather small, there's a risk we just won't be able to allocate a new CFB from stolen if the previous one was not freed yet. This could happen in case we quickly disable FBC from pipe A and decide to enable it on pipe B, or just if we change pipe A's fb stride while FBC is enabled.The second approach would be similar to the first one, but maintaining a single
drm_mmnode and keeping track of when it can be reused. This would remove the disadvantage of not having enough space for two nodes, but would create the new problem where we may not be able to enable FBC at the pointintel_fbc_update()is called, so we would have to add more code to retry updating FBC after the time has passed. And that can quickly get too complex since we can get invalidate, flush, disable and other calls in the middle of the wait.Both solutions above - and also the current code - have the problem that we unnecessarily free+realloc FBC during invalidate+flush operations even if the CFB size doesn't change.
Quoted 13 lines
The third option would be to move the allocation/deallocation to enable/disable. This makes sure that the pipe is always disabled when we allocate/deallocate the CFB, so there's no risk that the FBC hardware may read or write to the memory right after it is freed from
drm_mm. The downside is that it is possible for user space to change the buffer stride without triggering a disable/enable - only deactivate/activate -, so we'll have to handle this case somehow, even though it is uncommon - see igt'skms_frontbuffer_trackingtest, fbc-stridechange subtest. It could be possible to implement a way to free+alloc the CFB during said stride change, but it would involve a lot of book-keeping - exactly as mentioned above - just for a rare case, so for now I'll keep it simple and just deactivate FBC. Besides, we may not even need to disable FBC since we do CFB over-allocation.
It's not really that rare. Starting a fullscreen client that covers a single monitor in a multi-monitor setup will trigger a change in stride on one of the CRTC (the monitors will be flipped independently).
Not that actually affects your argument, just presenting a use-case that exists in the wild today.
-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 6/12 drm/i915: alloc/free the FBC CFB during enable/disable
One of the problems with the current code is that it frees the CFB and releases its drm_mm node as soon as we flip FBC's enable bit. This is bad because after we disable FBC the hardware may still use the CFB for the rest of the frame, so in theory we should only release the drm_mm node one frame after we disable FBC. Otherwise, a stolen memory allocation done right after an FBC disable may result in either corrupted memory for the new owner of that memory region or corrupted screen/underruns in case the new owner changes it while the hardware is still reading it. This case is not exactly easy to reproduce since we currently don't do a lot of stolen memory allocations, but I see patches on the mailing list trying to expose stolen memory to user space, so races will be possible.
I thought about three different approaches to solve this, and they all have downsides.
The first approach would be to simply use multiple drm_mm nodes and freeing the unused ones only after a frame has passed. The problem with this approach is that since stolen memory is rather small, there's a risk we just won't be able to allocate a new CFB from stolen if the previous one was not freed yet. This could happen in case we quickly disable FBC from pipe A and decide to enable it on pipe B, or just if we change pipe A's fb stride while FBC is enabled.
The second approach would be similar to the first one, but maintaining a single drm_mm node and keeping track of when it can be reused. This would remove the disadvantage of not having enough space for two nodes, but would create the new problem where we may not be able to enable FBC at the point intel_fbc_update() is called, so we would have to add more code to retry updating FBC after the time has passed. And that can quickly get too complex since we can get invalidate, flush, disable and other calls in the middle of the wait.
Both solutions above - and also the current code - have the problem that we unnecessarily free+realloc FBC during invalidate+flush operations even if the CFB size doesn't change.
The third option would be to move the allocation/deallocation to enable/disable. This makes sure that the pipe is always disabled when we allocate/deallocate the CFB, so there's no risk that the FBC hardware may read or write to the memory right after it is freed from drm_mm. The downside is that it is possible for user space to change the buffer stride without triggering a disable/enable - only deactivate/activate -, so we'll have to handle this case somehow - see igt's kms_frontbuffer_tracking test, fbc-stridechange subtest. It could be possible to implement a way to free+alloc the CFB during said stride change, but it would involve a lot of book-keeping - exactly as mentioned above - just for on case, so for now I'll keep it simple and just deactivate FBC. Besides, we may not even need to disable FBC since we do CFB over-allocation.
Note from Chris: "Starting a fullscreen client that covers a single monitor in a multi-monitor setup will trigger a change in stride on one of the CRTCs (the monitors will be flipped independently).". It shouldn't be a huge problem if we lose FBC on multi-monitor setups since these setups already have problems reaching deep PC states anyway.
v2: Rebase after changing the patch order.
v3:
- Remove references to the stride change case being "uncommon" and paste Chris' example.
- Rebase after a change in a previous patch.
--- drivers/gpu/drm/i915/intel_fbc.c | 134 ++++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 65 deletions(-)
I didn't want to resend yet the patches that had "do this trivial change then consider it Reviewed-by", so this one won't apply nicely on top of the others currently on the list. This, along with patch 09 are the only ones missing a RB tag, and I'll skip 09 for now due to the vblank_disable_immediate discussion.
drivers/gpu/drm/i915/intel_fbc.c +69 -65
@@ -64,6 +64,46 @@ static unsigned int get_crtc_fence_y_offset(struct intel_crtc *crtc)return crtc->base.y - crtc->adjusted_y; } +/* +* For SKL+, the plane source size used by the hardware is based on the value we +* write to the PLANE_SIZE register. For BDW-, the hardware looks at the value +* we wrote to PIPESRC. +*/ +static void intel_fbc_get_plane_source_size (struct intel_crtc *crtc, +int *width,int *height) +{ +struct intel_plane_state *plane_state = +to_intel_plane_state (crtc->base.primary->state); +int w, h; + +if (intel_rotation_90_or_270 (plane_state->base.rotation)) { + w =drm_rect_height (&plane_state->src) >>16 ; + h =drm_rect_width (&plane_state->src) >>16 ; + }else { + w =drm_rect_width (&plane_state->src) >>16 ; + h =drm_rect_height (&plane_state->src) >>16 ; + } + +if (width) + *width = w; +if (height) + *height = h; +} + +static int intel_fbc_calculate_cfb_size (struct intel_crtc *crtc, +struct drm_framebuffer *fb) +{ +struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; +int lines; + +intel_fbc_get_plane_source_size (crtc,NULL , &lines); +if (INTEL_INFO (dev_priv)->gen >=7 ) + lines =min (lines,2048 ); + +/* Hardware needs the full buffer stride, not just the active area. */ +return lines * fb->pitches[0 ]; +} +static void i8xx_fbc_deactivate (struct drm_i915_private *dev_priv) {u32 fbc_ctl;
@@ -558,11 +598,17 @@ again: } } -static int intel_fbc_alloc_cfb (struct drm_i915_private *dev_priv,int size, -int fb_cpp) +static int intel_fbc_alloc_cfb (struct intel_crtc *crtc) { +struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; +struct drm_framebuffer *fb = crtc->base.primary->state->fb;struct drm_mm_node *uninitialized_var (compressed_llb ); -int ret; +int size, fb_cpp, ret; + +WARN_ON (drm_mm_node_allocated (&dev_priv->fbc.compressed_fb)); + + size =intel_fbc_calculate_cfb_size (crtc, fb); + fb_cpp =drm_format_plane_cpp (fb->pixel_format,0 ); ret =find_compression_threshold (dev_priv, &dev_priv->fbc.compressed_fb, size, fb_cpp);
@@ -639,65 +685,6 @@ void intel_fbc_cleanup_cfb(struct drm_i915_private *dev_priv)mutex_unlock (&dev_priv->fbc.lock); } -/* -* For SKL+, the plane source size used by the hardware is based on the value we -* write to the PLANE_SIZE register. For BDW-, the hardware looks at the value -* we wrote to PIPESRC. -*/ -static void intel_fbc_get_plane_source_size (struct intel_crtc *crtc, -int *width,int *height) -{ -struct intel_plane_state *plane_state = -to_intel_plane_state (crtc->base.primary->state); -int w, h; - -if (intel_rotation_90_or_270 (plane_state->base.rotation)) { - w =drm_rect_height (&plane_state->src) >>16 ; - h =drm_rect_width (&plane_state->src) >>16 ; - }else { - w =drm_rect_width (&plane_state->src) >>16 ; - h =drm_rect_height (&plane_state->src) >>16 ; - } - -if (width) - *width = w; -if (height) - *height = h; -} - -static int intel_fbc_calculate_cfb_size (struct intel_crtc *crtc) -{ -struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; -struct drm_framebuffer *fb = crtc->base.primary->fb; -int lines; - -intel_fbc_get_plane_source_size (crtc,NULL , &lines); -if (INTEL_INFO (dev_priv)->gen >=7 ) - lines =min (lines,2048 ); - -/* Hardware needs the full buffer stride, not just the active area. */ -return lines * fb->pitches[0 ]; -} - -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, cpp; - - size =intel_fbc_calculate_cfb_size (crtc); - cpp =drm_format_plane_cpp (fb->pixel_format,0 ); - -if (drm_mm_node_allocated (&dev_priv->fbc.compressed_fb) && - size <= dev_priv->fbc.compressed_fb.size * dev_priv->fbc.threshold) -return 0 ; - -/* Release any current block */ -__intel_fbc_cleanup_cfb (dev_priv); - -return intel_fbc_alloc_cfb (dev_priv, size, cpp); -} -static bool stride_is_valid (struct drm_i915_private *dev_priv,unsigned int stride) {
@@ -853,8 +840,19 @@ static void __intel_fbc_update(struct intel_crtc *crtc) goto out_disable; } -if (intel_fbc_setup_cfb (crtc)) { -set_no_fbc_reason (dev_priv,"not enough stolen memory" ); +/* It is possible for the required CFB size change without a +* crtc->disable + crtc->enable since it is possible to change the +* stride without triggering a full modeset. Since we try to +* over-allocate the CFB, there's a chance we may keep FBC enabled even +* if this happens, but if we exceed the current CFB size we'll have to +* disable FBC. Notice that it would be possible to disable FBC, wait +* for a frame, free the stolen node, then try to reenable FBC in case +* we didn't get any invalidate/deactivate calls, but this would require +* a lot of tracking just for a specific case. If we conclude it's an +* important case, we can implement it later. */ +if (intel_fbc_calculate_cfb_size (crtc, fb) > + dev_priv->fbc.compressed_fb.size * dev_priv->fbc.threshold) { +set_no_fbc_reason (dev_priv,"CFB requirements changed" ); goto out_disable; }
@@ -907,7 +905,6 @@ out_disable:DRM_DEBUG_KMS ("unsupported config, deactivating FBC\n" );__intel_fbc_deactivate (dev_priv); } -__intel_fbc_cleanup_cfb (dev_priv); }/*
@@ -1020,6 +1017,11 @@ void intel_fbc_enable(struct intel_crtc *crtc) goto out; } +if (intel_fbc_alloc_cfb (crtc)) { +set_no_fbc_reason (dev_priv,"not enough stolen memory" ); + goto out; + } +DRM_DEBUG_KMS ("Enabling FBC on pipe %c\n" ,pipe_name (crtc->pipe)); dev_priv->fbc.no_fbc_reason ="FBC enabled but not active yet\n" ;
@@ -1047,6 +1049,8 @@ static void __intel_fbc_disable(struct drm_i915_private *dev_priv)DRM_DEBUG_KMS ("Disabling FBC on pipe %c\n" ,pipe_name (crtc->pipe)); +__intel_fbc_cleanup_cfb (dev_priv); + dev_priv->fbc.enabled = false; dev_priv->fbc.crtc =NULL ; }
Signature · 6 lines
2.6.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 7/12 drm/i915: check for FBC planes in the same place as the pipes
In reply to Paulo ZanoniThis moves the pre-gen4 check from update() to enable(). The HAS_DDI in the original code is not needed since only gen 2/3 have the plane swapping code.
v2: Rebase.
--- drivers/gpu/drm/i915/intel_fbc.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_fbc.c +3 -6
@@ -514,6 +514,9 @@ static bool crtc_can_fbc(struct intel_crtc *crtc)if (fbc_on_pipe_a_only (dev_priv) && crtc->pipe !=PIPE_A )return false; +if (INTEL_INFO (dev_priv)->gen <4 && crtc->plane !=PLANE_A ) +return false; +return true; }
@@ -802,12 +805,6 @@ static void __intel_fbc_update(struct intel_crtc *crtc) goto out_disable; } -if ((INTEL_INFO (dev_priv)->gen <4 ||HAS_DDI (dev_priv)) && - crtc->plane !=PLANE_A ) { -set_no_fbc_reason (dev_priv,"FBC unsupported on plane" ); - goto out_disable; - } -/* The use of a CPU fence is mandatory in order to detect writes * by the CPU to the scanout and trigger updates to the FBC. */
Signature · 6 lines
2.6.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 07/12] drm/i915: check for FBC planes in the same place as the pipes
Quoted 7 lines · Paulo Zanoni
This moves the pre-gen4 check from
update()toenable(). TheHAS_DDIin the original code is not needed since only gen 2/3 have the plane swapping code.v2: Rebase.
Signed-off-by Paulo Zanoni <[email protected]>
Quoted 9 lines
--- drivers/gpu/drm/i915/intel_fbc.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)drivers/gpu/drm/i915/intel_fbc.c +0
-0
drivers/gpu/drm/i915/intel_fbc.c static bool crtc_can_fbc(struct intel_crtc *crtc) · line 518
Quoted 5 lines
drivers/gpu/drm/i915/intel_fbc.c +2
-0@@ -514,6 +514,9 @@ static bool crtc_can_fbc(struct intel_crtc *crtc)if (fbc_on_pipe_a_only (dev_priv) && crtc->pipe !=PIPE_A )return false; +if (INTEL_INFO (dev_priv)->gen <4 && crtc->plane !=PLANE_A ) +return false;
Nit: you know what would really put the icing on the cake here, if (fbc_on_plane_a_only(dev_priv) && crtc->plane != PLANE_A)
return false;
-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 8/12 drm/i915: use a single intel_fbc_work struct
In reply to Paulo ZanoniThis was already on my TODO list, and was requested both by Chris and Ville, for different reasons. The advantages are avoiding a frequent malloc/free pair, and the locality of having the work structure embedded in dev_priv. The maximum used memory is also smaller since previously we could have multiple allocated intel_fbc_work structs at the same time, and now we'll always have a single one - the one embedded on dev_priv. Of course, we're now using a little more memory on the cases where there's nothing scheduled.
The biggest challenge here is to keep everything synchronized the way it was before.
Currently, when we try to activate FBC, we allocate a new intel_fbc_work structure. Then later when we conclude we must delay the FBC activation a little more, we allocate a new intel_fbc_work struct, and then adjust dev_priv->fbc.fbc_work to point to the new struct. So when the old work runs - at intel_fbc_work_fn() - it will check that dev_priv->fbc.fbc_work points to something else, so it does nothing. Everything is also protected by fbc.lock.
Just cancelling the old delayed work doesn't work because we might just cancel it after the work function already started to run, but while it is still waiting to grab fbc.lock. That's why we use the "dev_priv->fbc.fbc_work == work" check described in the paragraph above.
So now that we have a single work struct we have to introduce a new way to synchronize everything. So we're making the work function a normal work instead of a delayed work, and it will be responsible for sleeping the appropriate amount of time itself. This way, after it wakes up it can grab the lock, ask "were we delayed or cancelled?" and then go back to sleep, enable FBC or give up.
v2:
- Spelling fixes.
- Rebase after changing the patch order.
--- drivers/gpu/drm/i915/i915_drv.h | 6 ++- drivers/gpu/drm/i915/intel_fbc.c | 106 +++++++++++++++++---------------------- 2 files changed, 51 insertions(+), 61 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +4 -2
@@ -918,9 +918,11 @@ struct i915_fbc {bool active;struct intel_fbc_work { -struct delayed_work work; +bool scheduled; +struct work_struct work;struct drm_framebuffer *fb; - } *fbc_work; +unsigned long enable_jiffies; + } work;const char *no_fbc_reason;
drivers/gpu/drm/i915/intel_fbc.c +47 -59
141 lines not on this page · raw message
Signature · 6 lines
2.6.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 9/12 drm/i915: wait for a vblank instead of 50ms when enabling FBC
In reply to Paulo ZanoniInstead of waiting for 50ms, just wait until the next vblank, since it's the minimum requirement.
This moves PC7 residency on my specific BDW machine running Cinnamon from 60-70% to 84-89%. Without FBC, I get 20-25%. I'm using a 3200x1800 eDP panel. Notice: this was the case when the patch was originally proposed, the order of the FBC patches changed since then, so the actual numbers might be slightly different now.
v2:
- Rebase after changing the patch order.
- Update the commit message.
--- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/intel_fbc.c | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
@@ -919,9 +919,9 @@ struct i915_fbc {struct intel_fbc_work {bool scheduled; +u32 scheduled_vblank;struct work_struct work;struct drm_framebuffer *fb; -unsigned long enable_jiffies; } work;const char *no_fbc_reason;
drivers/gpu/drm/i915/intel_fbc.c +3 -9
@@ -391,7 +391,6 @@ static void intel_fbc_work_fn(struct work_struct *__work) container_of(__work, struct drm_i915_private, fbc.work.work);struct intel_fbc_work *work = &dev_priv->fbc.work;struct intel_crtc *crtc = dev_priv->fbc.crtc; -unsigned long delay_jiffies =msecs_to_jiffies (50 ); retry:/* Delay the actual enabling to let pageflipping cease and the
@@ -400,14 +399,9 @@ retry:* vblank to pass after disabling the FBC before we attempt * to modify the control registers. * -* A more complicated solution would involve tracking vblanks -* following the termination of the page-flipping sequence -* and indeed performing the enable as a co-routine and not -* waiting synchronously upon the vblank. -* * WaFbcWaitForVBlankBeforeEnable:ilk,snb */ -wait_remaining_ms_from_jiffies (work->enable_jiffies, delay_jiffies); +intel_wait_for_vblank (dev_priv->dev, crtc->pipe);mutex_lock (&dev_priv->fbc.lock);
@@ -416,7 +410,7 @@ retry: goto out;/* Were we delayed again while this function was sleeping? */ -if (time_after (work->enable_jiffies + delay_jiffies, jiffies)) { +if (drm_crtc_vblank_get (&crtc->base) == work->scheduled_vblank) {mutex_unlock (&dev_priv->fbc.lock); goto retry; }
@@ -449,7 +443,7 @@ static void intel_fbc_schedule_activation(struct intel_crtc *crtc)* jiffy count. */ work->fb = crtc->base.primary->fb; work->scheduled = true; - work->enable_jiffies = jiffies; + work->scheduled_vblank =drm_crtc_vblank_count (&crtc->base);schedule_work (&work->work); }
Signature · 6 lines
2.6.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 09/12] drm/i915: wait for a vblank instead of 50ms when enabling FBC
Quoted 72 lines · Paulo Zanoni
Instead of waiting for 50ms, just wait until the next vblank, since it's the minimum requirement.
This moves PC7 residency on my specific BDW machine running Cinnamon from 60-70% to 84-89%. Without FBC, I get 20-25%. I'm using a 3200x1800 eDP panel. Notice: this was the case when the patch was originally proposed, the order of the FBC patches changed since then, so the actual numbers might be slightly different now.
v2:
- Rebase after changing the patch order.
- Update the commit message.Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/intel_fbc.c | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-)drivers/gpu/drm/i915/i915_drv.h +1
-1@@ -919,9 +919,9 @@ struct i915_fbc {struct intel_fbc_work {bool scheduled; +u32 scheduled_vblank;struct work_struct work;struct drm_framebuffer *fb; -unsigned long enable_jiffies; } work;const char *no_fbc_reason;drivers/gpu/drm/i915/intel_fbc.c +2
-8@@ -391,7 +391,6 @@ static void intel_fbc_work_fn(struct work_struct *__work) container_of(__work, struct drm_i915_private, fbc.work.work);struct intel_fbc_work *work = &dev_priv->fbc.work;struct intel_crtc *crtc = dev_priv->fbc.crtc; -unsigned long delay_jiffies =msecs_to_jiffies (50 ); retry:/* Delay the actual enabling to let pageflipping cease and the @@ -400,14 +399,9 @@ retry:* vblank to pass after disabling the FBC before we attempt * to modify the control registers. * -* A more complicated solution would involve tracking vblanks -* following the termination of the page-flipping sequence -* and indeed performing the enable as a co-routine and not -* waiting synchronously upon the vblank. -* * WaFbcWaitForVBlankBeforeEnable:ilk,snb */ -wait_remaining_ms_from_jiffies (work->enable_jiffies, delay_jiffies); +intel_wait_for_vblank (dev_priv->dev, crtc->pipe);mutex_lock (&dev_priv->fbc.lock);@@ -416,7 +410,7 @@ retry: goto out;/* Were we delayed again while this function was sleeping? */ -if (time_after (work->enable_jiffies + delay_jiffies, jiffies)) { +if (drm_crtc_vblank_get (&crtc->base) == work->scheduled_vblank) {mutex_unlock (&dev_priv->fbc.lock); goto retry; }
drivers/gpu/drm/i915/intel_fbc.c static void intel_fbc_schedule_activation(struct intel_crtc *crtc) · line 446
Quoted 5 lines
drivers/gpu/drm/i915/intel_fbc.c +1
-1@@ -449,7 +443,7 @@ static void intel_fbc_schedule_activation(struct intel_crtc *crtc)* jiffy count. */ work->fb = crtc->base.primary->fb; work->scheduled = true; - work->enable_jiffies = jiffies; + work->scheduled_vblank =drm_crtc_vblank_count (&crtc->base);
Isn't the frame counter only incrementing whilst the vblank IRQ is enabled? Ville?
-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 09/12] drm/i915: wait for a vblank instead of 50ms when enabling FBC
Em Sex, 2015-11-13 às 21:03 +0000, Chris Wilson escreveu:
Quoted 93 lines · Paulo Zanoni
Quoted 92 lines
Instead of waiting for 50ms, just wait until the next vblank, since it's the minimum requirement.
This moves PC7 residency on my specific BDW machine running Cinnamon
from 60-70% to 84-89%. Without FBC, I get 20-25%. I'm using a 3200x1800 eDP panel. Notice: this was the case when the patch was originally proposed, the order of the FBC patches changed since then,
so the actual numbers might be slightly different now.v2:
- Rebase after changing the patch order.
- Update the commit message.Signed-off-by Paulo Zanoni <[email protected]>---
drivers/gpu/drm/i915/i915_drv.h | 2 +-drivers/gpu/drm/i915/intel_fbc.c| 12 +++---------2 files changed, 4 insertions(+), 10 deletions(-)drivers/gpu/drm/i915/i915_drv.h +0
-0@@ -919,9 +919,9 @@ struct i915_fbc {
structintel_fbc_work{
bool scheduled;drivers/gpu/drm/i915/i915_drv.h +1
-0+u32 scheduled_vblank;struct
work_structwork;
structdrm_framebuffer*fb;drivers/gpu/drm/i915/i915_drv.h +0
-1-unsigned long enable_jiffies;} work;
const char*no_fbc_reason;drivers/gpu/drm/i915/intel_fbc.c +0
-1@@ -391,7 +391,6 @@ static void intel_fbc_work_fn(struct work_struct *__work) container_of(__work, struct drm_i915_private, fbc.work.work); struct intel_fbc_work *work = &dev_priv->fbc.work; struct intel_crtc *crtc = dev_priv->fbc.crtc; -unsigned long delay_jiffies =msecs_to_jiffies (50 );
retry:
/* Delay the actual enabling to let pageflipping cease and thedrivers/gpu/drm/i915/intel_fbc.c +0
-0@@ -400,14 +399,9 @@ retry: * vblank to pass after disabling the FBC before weattempt
* to modify the control registers.
*drivers/gpu/drm/i915/intel_fbc.c +0
-1- * A more complicated solution would involve trackingvblanks
drivers/gpu/drm/i915/intel_fbc.c +0
-2- * following the termination of the page-flipping sequence - * and indeed performing the enable as a co-routine andnot
drivers/gpu/drm/i915/intel_fbc.c +0
-2- * waiting synchronously upon the vblank. - ** WaFbcWaitForVBlankBeforeEnable:ilk,snb
*/drivers/gpu/drm/i915/intel_fbc.c +0
-1- wait_remaining_ms_from_jiffies(work->enable_jiffies,
delay_jiffies);drivers/gpu/drm/i915/intel_fbc.c +1
-0+intel_wait_for_vblank (dev_priv->dev, crtc->pipe);
mutex_lock(&dev_priv->fbc.lock);drivers/gpu/drm/i915/intel_fbc.c +0
-0@@ -416,7 +410,7 @@ retry: goto out;
/* Were we delayed again while this function was sleeping? */drivers/gpu/drm/i915/intel_fbc.c +0
-1- if (time_after(work->enable_jiffies + delay_jiffies,jiffies)) {
drivers/gpu/drm/i915/intel_fbc.c +1
-0+ if (drm_crtc_vblank_get(&crtc->base) == work-Quoted 1 line
scheduled_vblank) {
mutex_unlock(&dev_priv->fbc.lock); goto retry;
}drivers/gpu/drm/i915/intel_fbc.c +1
-1@@ -449,7 +443,7 @@ static voidintel_fbc_schedule_activation(struct intel_crtc *crtc) * jiffy count. */ work->fb = crtc->base.primary->fb; work->scheduled = true; - work->enable_jiffies = jiffies; + work->scheduled_vblank = drm_crtc_vblank_count(&crtc-
Quoted 4 lines
drivers/gpu/drm/i915/intel_fbc.c static void · line 448
Quoted 1 line
drivers/gpu/drm/i915/intel_fbc.c +0
-0>base);Isn't the frame counter only incrementing whilst the vblank IRQ is enabled? Ville?
At the work function we call intel_wait_for_vblank(), which calls drm_wait_one_vblank(), which calls drm_vblank_get().
Quoted 2 lines
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 09/12] drm/i915: wait for a vblank instead of 50ms when enabling FBC
Quoted 94 lines · Paulo R
Em Sex, 2015-11-13 às 21:03 +0000, Chris Wilson escreveu:
Quoted 93 lines · Paulo Zanoni
Quoted 92 lines
Instead of waiting for 50ms, just wait until the next vblank, since it's the minimum requirement.
This moves PC7 residency on my specific BDW machine running Cinnamon
from 60-70% to 84-89%. Without FBC, I get 20-25%. I'm using a 3200x1800 eDP panel. Notice: this was the case when the patch was originally proposed, the order of the FBC patches changed since then,
so the actual numbers might be slightly different now.v2:
- Rebase after changing the patch order.
- Update the commit message.Signed-off-by Paulo Zanoni <[email protected]>---
drivers/gpu/drm/i915/i915_drv.h | 2 +-drivers/gpu/drm/i915/intel_fbc.c| 12 +++---------2 files changed, 4 insertions(+), 10 deletions(-)drivers/gpu/drm/i915/i915_drv.h +0
-0@@ -919,9 +919,9 @@ struct i915_fbc {
structintel_fbc_work{
bool scheduled;drivers/gpu/drm/i915/i915_drv.h +1
-0+u32 scheduled_vblank;struct
work_structwork;
structdrm_framebuffer*fb;drivers/gpu/drm/i915/i915_drv.h +0
-1-unsigned long enable_jiffies;} work;
const char*no_fbc_reason;drivers/gpu/drm/i915/intel_fbc.c +0
-1@@ -391,7 +391,6 @@ static void intel_fbc_work_fn(struct work_struct *__work) container_of(__work, struct drm_i915_private, fbc.work.work); struct intel_fbc_work *work = &dev_priv->fbc.work; struct intel_crtc *crtc = dev_priv->fbc.crtc; -unsigned long delay_jiffies =msecs_to_jiffies (50 );
retry:
/* Delay the actual enabling to let pageflipping cease and thedrivers/gpu/drm/i915/intel_fbc.c +0
-0@@ -400,14 +399,9 @@ retry: * vblank to pass after disabling the FBC before weattempt
* to modify the control registers.
*drivers/gpu/drm/i915/intel_fbc.c +0
-1- * A more complicated solution would involve trackingvblanks
drivers/gpu/drm/i915/intel_fbc.c +0
-2- * following the termination of the page-flipping sequence - * and indeed performing the enable as a co-routine andnot
drivers/gpu/drm/i915/intel_fbc.c +0
-2- * waiting synchronously upon the vblank. - ** WaFbcWaitForVBlankBeforeEnable:ilk,snb
*/drivers/gpu/drm/i915/intel_fbc.c +0
-1- wait_remaining_ms_from_jiffies(work->enable_jiffies,
delay_jiffies);drivers/gpu/drm/i915/intel_fbc.c +1
-0+intel_wait_for_vblank (dev_priv->dev, crtc->pipe);
mutex_lock(&dev_priv->fbc.lock);drivers/gpu/drm/i915/intel_fbc.c +0
-0@@ -416,7 +410,7 @@ retry: goto out;
/* Were we delayed again while this function was sleeping? */drivers/gpu/drm/i915/intel_fbc.c +0
-1- if (time_after(work->enable_jiffies + delay_jiffies,jiffies)) {
drivers/gpu/drm/i915/intel_fbc.c +1
-0+ if (drm_crtc_vblank_get(&crtc->base) == work-Quoted 1 line
scheduled_vblank) {
mutex_unlock(&dev_priv->fbc.lock); goto retry;
}drivers/gpu/drm/i915/intel_fbc.c +1
-1@@ -449,7 +443,7 @@ static voidintel_fbc_schedule_activation(struct intel_crtc *crtc) * jiffy count. */ work->fb = crtc->base.primary->fb; work->scheduled = true; - work->enable_jiffies = jiffies; + work->scheduled_vblank = drm_crtc_vblank_count(&crtc-
Quoted 7 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_fbc.c static void · line 448
Quoted 1 line
drivers/gpu/drm/i915/intel_fbc.c +0
-0>base);Isn't the frame counter only incrementing whilst the vblank IRQ is enabled? Ville?
At the work function we call
intel_wait_for_vblank(), which callsdrm_wait_one_vblank(), which callsdrm_vblank_get().
And drm_vblank_put...
-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 09/12] drm/i915: wait for a vblank instead of 50ms when enabling FBC
In reply to Chris WilsonQuoted 66 lines · Chris Wilson
Quoted 65 lines · Paulo Zanoni
Instead of waiting for 50ms, just wait until the next vblank, since it's the minimum requirement.
This moves PC7 residency on my specific BDW machine running Cinnamon from 60-70% to 84-89%. Without FBC, I get 20-25%. I'm using a 3200x1800 eDP panel. Notice: this was the case when the patch was originally proposed, the order of the FBC patches changed since then, so the actual numbers might be slightly different now.
v2:
- Rebase after changing the patch order.
- Update the commit message.Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/intel_fbc.c | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-)drivers/gpu/drm/i915/i915_drv.h +1
-1@@ -919,9 +919,9 @@ struct i915_fbc {struct intel_fbc_work {bool scheduled; +u32 scheduled_vblank;struct work_struct work;struct drm_framebuffer *fb; -unsigned long enable_jiffies; } work;const char *no_fbc_reason;drivers/gpu/drm/i915/intel_fbc.c +1
-7@@ -391,7 +391,6 @@ static void intel_fbc_work_fn(struct work_struct *__work) container_of(__work, struct drm_i915_private, fbc.work.work);struct intel_fbc_work *work = &dev_priv->fbc.work;struct intel_crtc *crtc = dev_priv->fbc.crtc; -unsigned long delay_jiffies =msecs_to_jiffies (50 ); retry:/* Delay the actual enabling to let pageflipping cease and the @@ -400,14 +399,9 @@ retry:* vblank to pass after disabling the FBC before we attempt * to modify the control registers. * -* A more complicated solution would involve tracking vblanks -* following the termination of the page-flipping sequence -* and indeed performing the enable as a co-routine and not -* waiting synchronously upon the vblank. -* * WaFbcWaitForVBlankBeforeEnable:ilk,snb */ -wait_remaining_ms_from_jiffies (work->enable_jiffies, delay_jiffies); +intel_wait_for_vblank (dev_priv->dev, crtc->pipe);mutex_lock (&dev_priv->fbc.lock);@@ -416,7 +410,7 @@ retry: goto out;
Quoted 15 lines
drivers/gpu/drm/i915/intel_fbc.c static void intel_fbc_schedule_activation(struct intel_crtc *crtc) · line 446
Quoted 12 lines
drivers/gpu/drm/i915/intel_fbc.c +2
-2/* Were we delayed again while this function was sleeping? */ -if (time_after (work->enable_jiffies + delay_jiffies, jiffies)) { +if (drm_crtc_vblank_get (&crtc->base) == work->scheduled_vblank) {mutex_unlock (&dev_priv->fbc.lock); goto retry; }@@ -449,7 +443,7 @@ static void intel_fbc_schedule_activation(struct intel_crtc *crtc)* jiffy count. */ work->fb = crtc->base.primary->fb; work->scheduled = true; - work->enable_jiffies = jiffies; + work->scheduled_vblank =drm_crtc_vblank_count (&crtc->base);Isn't the frame counter only incrementing whilst the vblank IRQ is enabled? Ville?
I see a "+ if (drm_crtc_vblank_get(" earlier.
That said, drm_crtc_vblank_count() is racy. The reader may race with the vblank irq handler after the start of vblank has already been passed, thus sampling a stale value, and then actually not waiting until the next vblank.
It's more of a problem on gen2/3 which didn't have the "start of vblank" interrupt and instead rely on the "frame start" interrupt. There's at least one (well, almost) scanline between the two events.
I've been meaning to add another function to the vblank code that could be called between the drm_vblank_get() and drm_crtc_vblank_count() to make sure the sampled count is really up to date. I'd use that on gen2 at least since it lacks the hw counter. For the other platforms, it ought to be easier to just use the hw counter everywhere since that increments atomically with the start of vblank and doesn't suffer from this race.
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 09/12] drm/i915: wait for a vblank instead of 50ms when enabling FBC
Quoted 83 lines · Ville Syrjälä
Quoted 66 lines · Chris Wilson
Quoted 65 lines · Paulo Zanoni
Instead of waiting for 50ms, just wait until the next vblank, since it's the minimum requirement.
This moves PC7 residency on my specific BDW machine running Cinnamon from 60-70% to 84-89%. Without FBC, I get 20-25%. I'm using a 3200x1800 eDP panel. Notice: this was the case when the patch was originally proposed, the order of the FBC patches changed since then, so the actual numbers might be slightly different now.
v2:
- Rebase after changing the patch order.
- Update the commit message.Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/intel_fbc.c | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-)drivers/gpu/drm/i915/i915_drv.h +1
-1@@ -919,9 +919,9 @@ struct i915_fbc {struct intel_fbc_work {bool scheduled; +u32 scheduled_vblank;struct work_struct work;struct drm_framebuffer *fb; -unsigned long enable_jiffies; } work;const char *no_fbc_reason;drivers/gpu/drm/i915/intel_fbc.c +1
-7@@ -391,7 +391,6 @@ static void intel_fbc_work_fn(struct work_struct *__work) container_of(__work, struct drm_i915_private, fbc.work.work);struct intel_fbc_work *work = &dev_priv->fbc.work;struct intel_crtc *crtc = dev_priv->fbc.crtc; -unsigned long delay_jiffies =msecs_to_jiffies (50 ); retry:/* Delay the actual enabling to let pageflipping cease and the @@ -400,14 +399,9 @@ retry:* vblank to pass after disabling the FBC before we attempt * to modify the control registers. * -* A more complicated solution would involve tracking vblanks -* following the termination of the page-flipping sequence -* and indeed performing the enable as a co-routine and not -* waiting synchronously upon the vblank. -* * WaFbcWaitForVBlankBeforeEnable:ilk,snb */ -wait_remaining_ms_from_jiffies (work->enable_jiffies, delay_jiffies); +intel_wait_for_vblank (dev_priv->dev, crtc->pipe);mutex_lock (&dev_priv->fbc.lock);@@ -416,7 +410,7 @@ retry: goto out;Quoted 15 lines
drivers/gpu/drm/i915/intel_fbc.c static void intel_fbc_schedule_activation(struct intel_crtc *crtc) · line 446
Quoted 12 lines
drivers/gpu/drm/i915/intel_fbc.c +2
-2/* Were we delayed again while this function was sleeping? */ -if (time_after (work->enable_jiffies + delay_jiffies, jiffies)) { +if (drm_crtc_vblank_get (&crtc->base) == work->scheduled_vblank) {mutex_unlock (&dev_priv->fbc.lock); goto retry; }@@ -449,7 +443,7 @@ static void intel_fbc_schedule_activation(struct intel_crtc *crtc)* jiffy count. */ work->fb = crtc->base.primary->fb; work->scheduled = true; - work->enable_jiffies = jiffies; + work->scheduled_vblank =drm_crtc_vblank_count (&crtc->base);Isn't the frame counter only incrementing whilst the vblank IRQ is enabled? Ville?
Quoted 1 line
I see a "+ if (drm_crtc_vblank_get(" earlier.
Hmm. Actually it's doing "drm_crtc_vblank_get(&crtc->base) == work->scheduled_vblank)" which looks rather like nonsense.
Not sure what the intention here was...
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 09/12] drm/i915: wait for a vblank instead of 50ms when enabling FBC
Em Sex, 2015-11-13 às 23:26 +0200, Ville Syrjälä escreveu:
Quoted 104 lines · Ville Syrjälä
Quoted 103 lines · Chris Wilson
Quoted 101 lines · Paulo Zanoni
Quoted 89 lines
Instead of waiting for 50ms, just wait until the next vblank, since
it's the minimum requirement.This moves PC7 residency on my specific BDW machine running Cinnamon
from 60-70% to 84-89%. Without FBC, I get 20-25%. I'm using a 3200x1800 eDP panel. Notice: this was the case when the patch was
originally proposed, the order of the FBC patches changed since then,
so the actual numbers might be slightly different now.v2:
- Rebase after changing the patch order.
- Update the commit message.Signed-off-by Paulo Zanoni <[email protected]>---
drivers/gpu/drm/i915/i915_drv.h | 2 +-drivers/gpu/drm/i915/intel_fbc.c| 12 +++---------2 files changed, 4 insertions(+), 10 deletions(-)drivers/gpu/drm/i915/i915_drv.h +0
-0@@ -919,9 +919,9 @@ struct i915_fbc {
structintel_fbc_work{
bool scheduled;drivers/gpu/drm/i915/i915_drv.h +1
-0+u32 scheduled_vblank;struct
work_structwork;
structdrm_framebuffer*fb;drivers/gpu/drm/i915/i915_drv.h +0
-1-unsigned long enable_jiffies;} work;
const char*no_fbc_reason;drivers/gpu/drm/i915/intel_fbc.c +0
-1@@ -391,7 +391,6 @@ static void intel_fbc_work_fn(struct work_struct *__work) container_of(__work, struct drm_i915_private, fbc.work.work); struct intel_fbc_work *work = &dev_priv->fbc.work; struct intel_crtc *crtc = dev_priv->fbc.crtc; -unsigned long delay_jiffies =msecs_to_jiffies (50 );
retry:
/* Delay the actual enabling to let pageflipping cease and thedrivers/gpu/drm/i915/intel_fbc.c +0
-0@@ -400,14 +399,9 @@ retry: * vblank to pass after disabling the FBC before weattempt
* to modify the control registers.
*drivers/gpu/drm/i915/intel_fbc.c +0
-1- * A more complicated solution would involve trackingvblanks
drivers/gpu/drm/i915/intel_fbc.c +0
-1- * following the termination of the page-flippingsequence
drivers/gpu/drm/i915/intel_fbc.c +0
-1- * and indeed performing the enable as a co-routineand not
drivers/gpu/drm/i915/intel_fbc.c +0
-2- * waiting synchronously upon the vblank. - ** WaFbcWaitForVBlankBeforeEnable:ilk,snb
*/drivers/gpu/drm/i915/intel_fbc.c +0
-1- wait_remaining_ms_from_jiffies(work->enable_jiffies,
delay_jiffies);drivers/gpu/drm/i915/intel_fbc.c +1
-0+intel_wait_for_vblank (dev_priv->dev, crtc->pipe);
mutex_lock(&dev_priv->fbc.lock);drivers/gpu/drm/i915/intel_fbc.c +0
-0@@ -416,7 +410,7 @@ retry: goto out;
/* Were we delayed again while this function was sleeping? */drivers/gpu/drm/i915/intel_fbc.c +0
-1- if (time_after(work->enable_jiffies + delay_jiffies,jiffies)) {
drivers/gpu/drm/i915/intel_fbc.c +1
-0+ if (drm_crtc_vblank_get(&crtc->base) == work-Quoted 1 line
scheduled_vblank) {
mutex_unlock(&dev_priv->fbc.lock); goto retry;
}drivers/gpu/drm/i915/intel_fbc.c static void · line 448
Quoted 7 lines
drivers/gpu/drm/i915/intel_fbc.c +1
-1@@ -449,7 +443,7 @@ static voidintel_fbc_schedule_activation(struct intel_crtc *crtc) * jiffy count. */ work->fb = crtc->base.primary->fb; work->scheduled = true; - work->enable_jiffies = jiffies; + work->scheduled_vblank =drm_crtc_vblank_count (&crtc- >base);Isn't the frame counter only incrementing whilst the vblank IRQ is
enabled? Ville?
Quoted 7 lines
Quoted 1 line
I see a "+ if (drm_crtc_vblank_get(" earlier.
Hmm. Actually it's doing "
drm_crtc_vblank_get(&crtc->base)==work->scheduled_vblank)" which looks rather like nonsense.Not sure what the intention here was...
Ouch. The intent was for that to be another call for drm_crtc_vblank_count().
The code in discussion is completely based on the drm_wait_one_vblank()
code: call drm_vblank_count(), then call it again until it returns something different. The difference is that we actually call drm_wait_one_vblank() in the middle of the process, and that scheduled_vblank may also be updated in the meantime, so so may have to call drm_wait_one_vblank() again.
Quoted 1 line
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 09/12] drm/i915: wait for a vblank instead of 50ms when enabling FBC
Quoted 116 lines · Paulo R
Em Sex, 2015-11-13 às 23:26 +0200, Ville Syrjälä escreveu:
Quoted 104 lines · Ville Syrjälä
Quoted 103 lines · Chris Wilson
Quoted 101 lines · Paulo Zanoni
Quoted 89 lines
Instead of waiting for 50ms, just wait until the next vblank, since
it's the minimum requirement.This moves PC7 residency on my specific BDW machine running Cinnamon
from 60-70% to 84-89%. Without FBC, I get 20-25%. I'm using a 3200x1800 eDP panel. Notice: this was the case when the patch was
originally proposed, the order of the FBC patches changed since then,
so the actual numbers might be slightly different now.v2:
- Rebase after changing the patch order.
- Update the commit message.Signed-off-by Paulo Zanoni <[email protected]>---
drivers/gpu/drm/i915/i915_drv.h | 2 +-drivers/gpu/drm/i915/intel_fbc.c| 12 +++---------2 files changed, 4 insertions(+), 10 deletions(-)drivers/gpu/drm/i915/i915_drv.h +0
-0@@ -919,9 +919,9 @@ struct i915_fbc {
structintel_fbc_work{
bool scheduled;drivers/gpu/drm/i915/i915_drv.h +1
-0+u32 scheduled_vblank;struct
work_structwork;
structdrm_framebuffer*fb;drivers/gpu/drm/i915/i915_drv.h +0
-1-unsigned long enable_jiffies;} work;
const char*no_fbc_reason;drivers/gpu/drm/i915/intel_fbc.c +0
-1@@ -391,7 +391,6 @@ static void intel_fbc_work_fn(struct work_struct *__work) container_of(__work, struct drm_i915_private, fbc.work.work); struct intel_fbc_work *work = &dev_priv->fbc.work; struct intel_crtc *crtc = dev_priv->fbc.crtc; -unsigned long delay_jiffies =msecs_to_jiffies (50 );
retry:
/* Delay the actual enabling to let pageflipping cease and thedrivers/gpu/drm/i915/intel_fbc.c +0
-0@@ -400,14 +399,9 @@ retry: * vblank to pass after disabling the FBC before weattempt
* to modify the control registers.
*drivers/gpu/drm/i915/intel_fbc.c +0
-1- * A more complicated solution would involve trackingvblanks
drivers/gpu/drm/i915/intel_fbc.c +0
-1- * following the termination of the page-flippingsequence
drivers/gpu/drm/i915/intel_fbc.c +0
-1- * and indeed performing the enable as a co-routineand not
drivers/gpu/drm/i915/intel_fbc.c +0
-2- * waiting synchronously upon the vblank. - ** WaFbcWaitForVBlankBeforeEnable:ilk,snb
*/drivers/gpu/drm/i915/intel_fbc.c +0
-1- wait_remaining_ms_from_jiffies(work->enable_jiffies,
delay_jiffies);drivers/gpu/drm/i915/intel_fbc.c +1
-0+intel_wait_for_vblank (dev_priv->dev, crtc->pipe);
mutex_lock(&dev_priv->fbc.lock);drivers/gpu/drm/i915/intel_fbc.c +0
-0@@ -416,7 +410,7 @@ retry: goto out;
/* Were we delayed again while this function was sleeping? */drivers/gpu/drm/i915/intel_fbc.c +0
-1- if (time_after(work->enable_jiffies + delay_jiffies,jiffies)) {
drivers/gpu/drm/i915/intel_fbc.c +1
-0+ if (drm_crtc_vblank_get(&crtc->base) == work-Quoted 1 line
scheduled_vblank) {
mutex_unlock(&dev_priv->fbc.lock); goto retry;
}drivers/gpu/drm/i915/intel_fbc.c static void · line 448
Quoted 7 lines
drivers/gpu/drm/i915/intel_fbc.c +1
-1@@ -449,7 +443,7 @@ static voidintel_fbc_schedule_activation(struct intel_crtc *crtc) * jiffy count. */ work->fb = crtc->base.primary->fb; work->scheduled = true; - work->enable_jiffies = jiffies; + work->scheduled_vblank =drm_crtc_vblank_count (&crtc- >base);Isn't the frame counter only incrementing whilst the vblank IRQ is
enabled? Ville?Quoted 7 lines
Quoted 1 line
I see a "+ if (drm_crtc_vblank_get(" earlier.
Hmm. Actually it's doing "
drm_crtc_vblank_get(&crtc->base)==work->scheduled_vblank)" which looks rather like nonsense.Not sure what the intention here was...
Ouch. The intent was for that to be another call for
drm_crtc_vblank_count().
Quoted 6 lines
The code in discussion is completely based on the
drm_wait_one_vblank()
code: calldrm_vblank_count(), then call it again until it returns something different. The difference is that we actually calldrm_wait_one_vblank()in the middle of the process, and thatscheduled_vblankmay also be updated in the meantime, so so may have to calldrm_wait_one_vblank()again.
You have no guarantees that drm_crtc_vblank_count() won't give you something totally stale unless you have a vblank reference when calling it. If you have a reference it's guaranteed to give you something fairly recent, but the race I outlined in the earlier mail still exists. And yes, drm_wait_one_vblank() is no good due to that same race.
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 09/12] drm/i915: wait for a vblank instead of 50ms when enabling FBC
Em Sáb, 2015-11-14 às 01:17 +0200, Ville Syrjälä escreveu:
Quoted 140 lines · Paulo R
Quoted 130 lines
Em Sex, 2015-11-13 às 23:26 +0200, Ville Syrjälä escreveu:
Quoted 118 lines · Ville Syrjälä
Quoted 117 lines · Chris Wilson
Quoted 115 lines · Paulo Zanoni
Quoted 107 lines
Instead of waiting for 50ms, just wait until the next vblank,
since
it's the minimum requirement.This moves PC7 residency on my specific BDW machine running Cinnamon
from 60-70% to 84-89%. Without FBC, I get 20-25%. I'm using a
3200x1800 eDP panel. Notice: this was the case when the patch
was
originally proposed, the order of the FBC patches changed since
then,
so the actual numbers might be slightly different now.v2:
- Rebase after changing the patch order.
- Update the commit message.Signed-off-by Paulo Zanoni <[email protected]>---
drivers/gpu/drm/i915/i915_drv.h | 2 +-drivers/gpu/drm/i915/intel_fbc.c| 12 +++---------2 files changed, 4 insertions(+), 10 deletions(-)drivers/gpu/drm/i915/i915_drv.h +0
-0@@ -919,9 +919,9 @@ struct i915_fbc {
structintel_fbc_work{
bool scheduled;drivers/gpu/drm/i915/i915_drv.h +1
-0+u32 scheduled_vblank;struct
work_structwork;
structdrm_framebuffer*fb;drivers/gpu/drm/i915/i915_drv.h +0
-1-unsigned long enable_jiffies;} work;
const char*no_fbc_reason;drivers/gpu/drm/i915/intel_fbc.c +0
-0@@ -391,7 +391,6 @@ static void intel_fbc_work_fn(struct work_struct *__work)container_of(__work, struct
drm_i915_private,
fbc.work.work);
structintel_fbc_work*work =&dev_priv->fbc.work; structintel_crtc*crtc =dev_priv->fbc.crtc;drivers/gpu/drm/i915/intel_fbc.c +0
-1- unsigned long delay_jiffies =
msecs_to_jiffies(50);
retry:
/* Delay the actual enabling to let pageflipping cease
and thedrivers/gpu/drm/i915/intel_fbc.c +0
-0@@ -400,14 +399,9 @@ retry: * vblank to pass after disabling the FBC beforewe
attempt
* to modify the control registers.
*drivers/gpu/drm/i915/intel_fbc.c +0
-1- * A more complicated solution would involvetracking
vblanksdrivers/gpu/drm/i915/intel_fbc.c +0
-1- * following the termination of the page-flippingsequence
drivers/gpu/drm/i915/intel_fbc.c +0
-1- * and indeed performing the enable as a co-routine
and notdrivers/gpu/drm/i915/intel_fbc.c +0
-2- * waiting synchronously upon the vblank. - ** WaFbcWaitForVBlankBeforeEnable:ilk,snb
*/drivers/gpu/drm/i915/intel_fbc.c +0
-1- wait_remaining_ms_from_jiffies(work-Quoted 1 line
enable_jiffies,
delay_jiffies);drivers/gpu/drm/i915/intel_fbc.c +1
-0+intel_wait_for_vblank (dev_priv->dev, crtc->pipe);
mutex_lock(&dev_priv->fbc.lock);drivers/gpu/drm/i915/intel_fbc.c +0
-0@@ -416,7 +410,7 @@ retry: goto out;
/* Were we delayed again while this function was sleeping? */drivers/gpu/drm/i915/intel_fbc.c +0
-1- if (time_after(work->enable_jiffies +
delay_jiffies,
jiffies)) {drivers/gpu/drm/i915/intel_fbc.c +1
-0+ if (drm_crtc_vblank_get(&crtc->base) == work-Quoted 1 line
scheduled_vblank) {
mutex_unlock(&dev_priv->fbc.lock); goto retry;
}drivers/gpu/drm/i915/intel_fbc.c +1
-1@@ -449,7 +443,7 @@ static voidintel_fbc_schedule_activation(struct intel_crtc *crtc) * jiffy count. */ work->fb = crtc->base.primary->fb; work->scheduled = true; - work->enable_jiffies = jiffies; + work->scheduled_vblank =Quoted 2 lines
drm_crtc_vblank_count(&crtc-
Quoted 1 line
base);
Isn't the frame counter only incrementing whilst the vblank IRQ
is
enabled? Ville?Quoted 7 lines
Quoted 1 line
I see a "+ if (drm_crtc_vblank_get(" earlier.
Hmm. Actually it's doing "
drm_crtc_vblank_get(&crtc->base)==work->scheduled_vblank)" which looks rather like nonsense.Not sure what the intention here was...
Ouch. The intent was for that to be another call for
drm_crtc_vblank_count().Quoted 8 lines
The code in discussion is completely based on the
drm_wait_one_vblank()
code: calldrm_vblank_count(), then call it again until it returns something different. The difference is that we actually calldrm_wait_one_vblank()in the middle of the process, and thatscheduled_vblankmay also be updated in the meantime, so so may have to
calldrm_wait_one_vblank()again.
Quoted 6 lines
You have no guarantees that
drm_crtc_vblank_count()won't give you something totally stale unless you have a vblank reference when calling
it. If you have a reference it's guaranteed to give you something fairly
recent,
All the points mentioned above are easily fixable.
Quoted 1 line
but the race I outlined in the earlier mail still exists.
I've been trying to understand this, and it seems i915_get_vblank_counter() tries to work around that problem with the logic behind the "pixel" and "vbl_start" variables. Isn't that enough? If no, why?
Quoted 2 lines
And yes,
drm_wait_one_vblank()is no good due to that same race.
So shouldn't we stop using intel_wait_for_vblank() on the affected platforms? Or at least add a big comment explaining the problem, or add a WARN(gen == 3 || gen == 4 && !is_g4x), or something else. I got a little surprised when you said the function is unreliable (was the previous implementation based on I915_READ also equally unreliable?).
Also, since we are already running this risk in other parts of the code, I'm not sure what are the conditions for my patch to be acceptable. Just fixing the original implementation, while keeping it based on drm_wait_one_vblank() and maybe adding some TODO comment would do? Or do you see an actual simple solution for the race you mentioned?
Thanks,
Paulo
Quoted 1 line
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 09/12] drm/i915: wait for a vblank instead of 50ms when enabling FBC
Quoted 148 lines · Paulo R
Em Sáb, 2015-11-14 às 01:17 +0200, Ville Syrjälä escreveu:
Quoted 140 lines · Paulo R
Quoted 130 lines
Em Sex, 2015-11-13 às 23:26 +0200, Ville Syrjälä escreveu:
Quoted 118 lines · Ville Syrjälä
Quoted 117 lines · Chris Wilson
Quoted 115 lines · Paulo Zanoni
Quoted 107 lines
Instead of waiting for 50ms, just wait until the next vblank,
since
it's the minimum requirement.This moves PC7 residency on my specific BDW machine running Cinnamon
from 60-70% to 84-89%. Without FBC, I get 20-25%. I'm using a
3200x1800 eDP panel. Notice: this was the case when the patch
was
originally proposed, the order of the FBC patches changed since
then,
so the actual numbers might be slightly different now.v2:
- Rebase after changing the patch order.
- Update the commit message.Signed-off-by Paulo Zanoni <[email protected]>---
drivers/gpu/drm/i915/i915_drv.h | 2 +-drivers/gpu/drm/i915/intel_fbc.c| 12 +++---------2 files changed, 4 insertions(+), 10 deletions(-)drivers/gpu/drm/i915/i915_drv.h +0
-0@@ -919,9 +919,9 @@ struct i915_fbc {
structintel_fbc_work{
bool scheduled;drivers/gpu/drm/i915/i915_drv.h +1
-0+u32 scheduled_vblank;struct
work_structwork;
structdrm_framebuffer*fb;drivers/gpu/drm/i915/i915_drv.h +0
-1-unsigned long enable_jiffies;} work;
const char*no_fbc_reason;drivers/gpu/drm/i915/intel_fbc.c +0
-0@@ -391,7 +391,6 @@ static void intel_fbc_work_fn(struct work_struct *__work)container_of(__work, struct
drm_i915_private,
fbc.work.work);
structintel_fbc_work*work =&dev_priv->fbc.work; structintel_crtc*crtc =dev_priv->fbc.crtc;drivers/gpu/drm/i915/intel_fbc.c +0
-1- unsigned long delay_jiffies =
msecs_to_jiffies(50);
retry:
/* Delay the actual enabling to let pageflipping cease
and thedrivers/gpu/drm/i915/intel_fbc.c +0
-0@@ -400,14 +399,9 @@ retry: * vblank to pass after disabling the FBC beforewe
attempt
* to modify the control registers.
*drivers/gpu/drm/i915/intel_fbc.c +0
-1- * A more complicated solution would involvetracking
vblanksdrivers/gpu/drm/i915/intel_fbc.c +0
-1- * following the termination of the page-flippingsequence
drivers/gpu/drm/i915/intel_fbc.c +0
-1- * and indeed performing the enable as a co-routine
and notdrivers/gpu/drm/i915/intel_fbc.c +0
-2- * waiting synchronously upon the vblank. - ** WaFbcWaitForVBlankBeforeEnable:ilk,snb
*/drivers/gpu/drm/i915/intel_fbc.c +0
-1- wait_remaining_ms_from_jiffies(work-Quoted 1 line
enable_jiffies,
delay_jiffies);drivers/gpu/drm/i915/intel_fbc.c +1
-0+intel_wait_for_vblank (dev_priv->dev, crtc->pipe);
mutex_lock(&dev_priv->fbc.lock);drivers/gpu/drm/i915/intel_fbc.c +0
-0@@ -416,7 +410,7 @@ retry: goto out;
/* Were we delayed again while this function was sleeping? */drivers/gpu/drm/i915/intel_fbc.c +0
-1- if (time_after(work->enable_jiffies +
delay_jiffies,
jiffies)) {drivers/gpu/drm/i915/intel_fbc.c +1
-0+ if (drm_crtc_vblank_get(&crtc->base) == work-Quoted 1 line
scheduled_vblank) {
mutex_unlock(&dev_priv->fbc.lock); goto retry;
}drivers/gpu/drm/i915/intel_fbc.c +1
-1@@ -449,7 +443,7 @@ static voidintel_fbc_schedule_activation(struct intel_crtc *crtc) * jiffy count. */ work->fb = crtc->base.primary->fb; work->scheduled = true; - work->enable_jiffies = jiffies; + work->scheduled_vblank =Quoted 2 lines
drm_crtc_vblank_count(&crtc-
Quoted 1 line
base);
Isn't the frame counter only incrementing whilst the vblank IRQ
is
enabled? Ville?Quoted 7 lines
Quoted 1 line
I see a "+ if (drm_crtc_vblank_get(" earlier.
Hmm. Actually it's doing "
drm_crtc_vblank_get(&crtc->base)==work->scheduled_vblank)" which looks rather like nonsense.Not sure what the intention here was...
Ouch. The intent was for that to be another call for
drm_crtc_vblank_count().Quoted 8 lines
The code in discussion is completely based on the
drm_wait_one_vblank()
code: calldrm_vblank_count(), then call it again until it returns something different. The difference is that we actually calldrm_wait_one_vblank()in the middle of the process, and thatscheduled_vblankmay also be updated in the meantime, so so may have to
calldrm_wait_one_vblank()again.Quoted 6 lines
You have no guarantees that
drm_crtc_vblank_count()won't give you something totally stale unless you have a vblank reference when calling
it. If you have a reference it's guaranteed to give you something fairly
recent,
Quoted 8 lines
All the points mentioned above are easily fixable.
Quoted 1 line
but the race I outlined in the earlier mail still exists.
I've been trying to understand this, and it seems
i915_get_vblank_counter()tries to work around that problem with the logic behind the "pixel" and "vbl_start" variables. Isn't that enough? If no, why?
No i915_get_vblank_counter() is there for another reason; On gen3/4 the hw counter increments at the wrong time, so we have to convert it to look like it incremented at the right time. Fortunately we can read out the hw counter and the pixel counter atomically, so there's no race or anything due to the conversion.
Quoted 5 lines
Quoted 2 lines
And yes,
drm_wait_one_vblank()is no good due to that same race.So shouldn't we stop using
intel_wait_for_vblank()on the affected platforms?
All platforms are affected, just some are more susceptible than others. We should fix intel_wait_for_vblank() to do the right thing.
Quoted 4 lines
Or at least add a big comment explaining the problem, or add a
WARN(gen == 3 || gen == 4 && !is_g4x), or something else. I got a little surprised when you said the function is unreliable (was the previous implementation based onI915_READalso equally unreliable?).
On g4x+ the polling implementation didn't suffer from this issue since it was polling the hw frame counter. But the fact that it was polling was sub-optimal.
On older platforms a similar race was there since it was polling the "frame start" bit and not the "start of vblank" bit. In addition it could also effectively eat the interrupt that someone was waiting for (on gen2/3 since they use the "frame start" as the interrupt as well).
Quoted 3 lines
Also, since we are already running this risk in other parts of the code, I'm not sure what are the conditions for my patch to be acceptable.
The main problem in your patch is using drm_vblank_count() w/o a drm_vblank_get/put(). So that should be fixed somehow.
I guess we can ignore the race with the vblank interrupt handler for now since the same problem exists everywhere else already.
Quoted 8 lines
Just fixing the original implementation, while keeping it based on
drm_wait_one_vblank()and maybe adding some TODO comment would do? Or do you see an actual simple solution for the race you mentioned?Thanks,
PauloQuoted 1 line
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 10/12 drm/i915: kill fbc.uncompressed_size
In reply to Paulo ZanoniDirectly call intel_fbc_calculate_cfb_size() in the only place that actually needs it, and use the proper check before removing the stolen node. IMHO, this change makes our code easier to understand.
--- drivers/gpu/drm/i915/i915_drv.h | 1 - drivers/gpu/drm/i915/intel_fbc.c | 13 ++++--------- 2 files changed, 4 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -1
@@ -901,7 +901,6 @@ struct i915_fbc {/* This is always the inner lock when overlapping with struct_mutex and * it's the outer lock when overlapping with stolen_lock. */ struct mutex lock; -unsigned long uncompressed_size;unsigned threshold;unsigned int fb_id;unsigned int possible_framebuffer_bits;
drivers/gpu/drm/i915/intel_fbc.c +4 -9
@@ -139,7 +139,7 @@ static void i8xx_fbc_activate(struct intel_crtc *crtc) dev_priv->fbc.active = true;/* Note: fbc.threshold == 1 for i8xx */ - cfb_pitch = dev_priv->fbc.uncompressed_size /FBC_LL_SIZE ; + cfb_pitch =intel_fbc_calculate_cfb_size (crtc, fb) /FBC_LL_SIZE ;if (fb->pitches[0 ] < cfb_pitch) cfb_pitch = fb->pitches[0 ];
@@ -626,8 +626,6 @@ static int intel_fbc_alloc_cfb(struct intel_crtc *crtc) dev_priv->mm.stolen_base + compressed_llb->start); } - dev_priv->fbc.uncompressed_size = 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);
@@ -644,18 +642,15 @@ err_llb:static void __intel_fbc_cleanup_cfb (struct drm_i915_private *dev_priv) { -if (dev_priv->fbc.uncompressed_size ==0 ) -return ; - -i915_gem_stolen_remove_node (dev_priv, &dev_priv->fbc.compressed_fb); +if (dev_priv->fbc.compressed_fb.allocated) +i915_gem_stolen_remove_node (dev_priv, + &dev_priv->fbc.compressed_fb);if (dev_priv->fbc.compressed_llb) {i915_gem_stolen_remove_node (dev_priv, dev_priv->fbc.compressed_llb);kfree (dev_priv->fbc.compressed_llb); } - - dev_priv->fbc.uncompressed_size =0 ; }void intel_fbc_cleanup_cfb (struct drm_i915_private *dev_priv)
Signature · 6 lines
2.6.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 10/12] drm/i915: kill fbc.uncompressed_size
Quoted 45 lines · Paulo Zanoni
Directly call
intel_fbc_calculate_cfb_size()in the only place that actually needs it, and use the proper check before removing the stolen node. IMHO, this change makes our code easier to understand.Signed-off-by Paulo Zanoni <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 1 - drivers/gpu/drm/i915/intel_fbc.c | 13 ++++--------- 2 files changed, 4 insertions(+), 10 deletions(-)drivers/gpu/drm/i915/i915_drv.h +0
-1@@ -901,7 +901,6 @@ struct i915_fbc {/* This is always the inner lock when overlapping with struct_mutex and * it's the outer lock when overlapping with stolen_lock. */ struct mutex lock; -unsigned long uncompressed_size;unsigned threshold;unsigned int fb_id;unsigned int possible_framebuffer_bits;drivers/gpu/drm/i915/intel_fbc.c +1
-3@@ -139,7 +139,7 @@ static void i8xx_fbc_activate(struct intel_crtc *crtc) dev_priv->fbc.active = true;/* Note: fbc.threshold == 1 for i8xx */ - cfb_pitch = dev_priv->fbc.uncompressed_size /FBC_LL_SIZE ; + cfb_pitch =intel_fbc_calculate_cfb_size (crtc, fb) /FBC_LL_SIZE ;if (fb->pitches[0 ] < cfb_pitch) cfb_pitch = fb->pitches[0 ];@@ -626,8 +626,6 @@ static int intel_fbc_alloc_cfb(struct intel_crtc *crtc) dev_priv->mm.stolen_base + compressed_llb->start); } - dev_priv->fbc.uncompressed_size = 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);
drivers/gpu/drm/i915/intel_fbc.c err_llb: · line 645
Quoted 8 lines
drivers/gpu/drm/i915/intel_fbc.c +1
-4@@ -644,18 +642,15 @@ err_llb:static void __intel_fbc_cleanup_cfb (struct drm_i915_private *dev_priv) { -if (dev_priv->fbc.uncompressed_size ==0 ) -return ; - -i915_gem_stolen_remove_node (dev_priv, &dev_priv->fbc.compressed_fb); +if (dev_priv->fbc.compressed_fb.allocated)
if (drm_mm_node_allocated(&dev_priv->fb.compressed_fb)) right?
We've been pretty consistent in using drm_mm_node_allocated() so we may as well stick with the rigour.
With that,
-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 11/12 drm/i915: get rid of FBC {, de}activation messages
In reply to Paulo ZanoniWhen running Cinnamon I see way too many pairs of these messages: many per second. Get rid of them as they're just telling us FBC is working as expected. We already have the messages for enable/disable, so we don't really need messages for activation/deactivation.
v2: Rebase after changing the patch order.
--- drivers/gpu/drm/i915/intel_fbc.c | 15 --------------- 1 file changed, 15 deletions(-)
drivers/gpu/drm/i915/intel_fbc.c +0 -15
@@ -123,8 +123,6 @@ static void i8xx_fbc_deactivate(struct drm_i915_private *dev_priv)DRM_DEBUG_KMS ("FBC idle timed out\n" );return ; } - -DRM_DEBUG_KMS ("deactivated FBC\n" ); }static void i8xx_fbc_activate (struct intel_crtc *crtc)
@@ -172,9 +170,6 @@ static void i8xx_fbc_activate(struct intel_crtc *crtc) fbc_ctl |= (cfb_pitch &0xff ) <<FBC_CTL_STRIDE_SHIFT ; fbc_ctl |= obj->fence_reg;I915_WRITE (FBC_CONTROL , fbc_ctl); - -DRM_DEBUG_KMS ("activated FBC, pitch %d, yoff %d, plane %c\n" , - cfb_pitch, crtc->base.y,plane_name (crtc->plane)); }static bool i8xx_fbc_is_active (struct drm_i915_private *dev_priv)
@@ -202,8 +197,6 @@ static void g4x_fbc_activate(struct intel_crtc *crtc)/* enable it... */ I915_WRITE (DPFC_CONTROL , dpfc_ctl |DPFC_CTL_EN ); - -DRM_DEBUG_KMS ("activated fbc on plane %c\n" ,plane_name (crtc->plane)); }static void g4x_fbc_deactivate (struct drm_i915_private *dev_priv)
@@ -217,8 +210,6 @@ static void g4x_fbc_deactivate(struct drm_i915_private *dev_priv)if (dpfc_ctl &DPFC_CTL_EN ) { dpfc_ctl &= ~DPFC_CTL_EN ;I915_WRITE (DPFC_CONTROL , dpfc_ctl); - -DRM_DEBUG_KMS ("deactivated FBC\n" ); } }
@@ -278,8 +269,6 @@ static void ilk_fbc_activate(struct intel_crtc *crtc) }intel_fbc_recompress (dev_priv); - -DRM_DEBUG_KMS ("activated fbc on plane %c\n" ,plane_name (crtc->plane)); }static void ilk_fbc_deactivate (struct drm_i915_private *dev_priv)
@@ -293,8 +282,6 @@ static void ilk_fbc_deactivate(struct drm_i915_private *dev_priv)if (dpfc_ctl &DPFC_CTL_EN ) { dpfc_ctl &= ~DPFC_CTL_EN ;I915_WRITE (ILK_DPFC_CONTROL , dpfc_ctl); - -DRM_DEBUG_KMS ("deactivated FBC\n" ); } }
@@ -357,8 +344,6 @@ static void gen7_fbc_activate(struct intel_crtc *crtc)I915_WRITE (DPFC_CPU_FENCE_OFFSET ,get_crtc_fence_y_offset (crtc));intel_fbc_recompress (dev_priv); - -DRM_DEBUG_KMS ("activated fbc on plane %c\n" ,plane_name (crtc->plane)); }/**
Signature · 6 lines
2.6.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 11/12] drm/i915: get rid of FBC {, de}activation messages
Quoted 8 lines · Paulo Zanoni
When running Cinnamon I see way too many pairs of these messages: many per second. Get rid of them as they're just telling us FBC is working as expected. We already have the messages for enable/disable, so we don't really need messages for activation/deactivation.
v2: Rebase after changing the patch order.
Signed-off-by Paulo Zanoni <[email protected]>
Fair enough, at this granularity logging isn't the best method of evaluating behaviour and the outer enable/disable should give enough hints for debugging.
-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 12/12 drm/i915: only nuke FBC when a drawing operation triggers a flush
In reply to Paulo ZanoniThere's no need to stop and restart FBC: a nuke should be fine.
v2: Make it simpler (Chris).
v3: Rewrite the patch again due to patch order changes.
--- drivers/gpu/drm/i915/intel_fbc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_fbc.c +6 -2
@@ -923,8 +923,12 @@ void intel_fbc_flush(struct drm_i915_private *dev_priv, dev_priv->fbc.busy_bits &= ~frontbuffer_bits;if (!dev_priv->fbc.busy_bits && dev_priv->fbc.enabled) { -__intel_fbc_deactivate (dev_priv); -__intel_fbc_update (dev_priv->fbc.crtc); +if (origin !=ORIGIN_FLIP && dev_priv->fbc.active) { +intel_fbc_recompress (dev_priv); + }else { +__intel_fbc_deactivate (dev_priv); +__intel_fbc_update (dev_priv->fbc.crtc); + } }mutex_unlock (&dev_priv->fbc.lock);
Signature · 6 lines
2.6.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 12/12] drm/i915: only nuke FBC when a drawing operation triggers a flush
On Fri, Nov 13, 2015 at 05:53:44PM -0200, Paulo Zanoni wrote:
drm/i915: Only trigger a FBC recompress after flushing a drawing operation
Quoted 1 line
There's no need to stop and restart FBC: a nuke should be fine.
There's no need to stop and restart FBC, which is quite expensive as we have to revalidate the CRTC state and reallocate resources, after flushing a drawing operation (as the CRTC state hasn't changed). A nuke (recompress) should be fine.
Quoted 4 lines
v2: Make it simpler (Chris).
v3: Rewrite the patch again due to patch order changes.Signed-off-by Paulo Zanoni <[email protected]>
If you can make the changelog understandable,
-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