Skip to contentSkip to conversation

drm/i915: Avoid reading fbc registers in vain when fbc was never enabled.

PATCH NAK Rodrigo Vivi 5 participants 8 messages Sep 17, 2014 – Sep 19, 2014

Subsystems (2)
lore
Share & tools
lore

Rodrigo Vivi

author maintainer
#0 lore raw

PATCH 1/1 drm/i915: Avoid reading fbc registers in vain when fbc was never enabled.

If it wasn't never enabled by kernel parameter or platform default we can avoid reading registers so many times in vain

---
 drivers/gpu/drm/i915/intel_pm.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +6 -0
index a988862..afcc284 100644
@@ -339,6 +339,12 @@ bool intel_fbc_enabled(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
+	/* If it wasn't never enabled by kernel parameter or platform default
+	 * we can avoid reading registers so many times in vain
+	 */
+	if (!i915.enable_fbc)
+		return false;
+
 	if (!dev_priv->display.fbc_enabled)
 		return false;
 
Signature · 1 line
1.9.3
#1 lore raw
Quoted 2 lines · Rodrigo Vivi

If it wasn't never enabled by kernel parameter or platform default we can avoid reading registers so many times in vain

Nak.

Quoted 12 lines
---
 drivers/gpu/drm/i915/intel_pm.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +0 -0
index a988862..afcc284 100644
@@ -339,6 +339,12 @@ bool intel_fbc_enabled(struct drm_device *dev)
 {

drivers/gpu/drm/i915/intel_pm.c bool intel_fbc_enabled(struct drm_device *dev) · line 349

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +6 -0
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
+	/* If it wasn't never enabled by kernel parameter or platform default
+	 * we can avoid reading registers so many times in vain
+	 */
+	if (!i915.enable_fbc)
+		return false;
+
 	if (!dev_priv->display.fbc_enabled)
 		return false;

The correct state to check here is whether we have enabled fbc, not the module parameter which just rules whether we should turn it on. Look at making dev_priv->fbc.no_fbc_reason always correct instead. -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#2 lore raw
Quoted 5 lines · Chris Wilson
Quoted 2 lines · Rodrigo Vivi

If it wasn't never enabled by kernel parameter or platform default we can avoid reading registers so many times in vain

Nak.

Well I've merged this for now to reduce fbc impact.

Quoted 14 lines
Quoted 14 lines
---
 drivers/gpu/drm/i915/intel_pm.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +0 -0
index a988862..afcc284 100644
@@ -339,6 +339,12 @@ bool intel_fbc_enabled(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
Quoted 12 lines

drivers/gpu/drm/i915/intel_pm.c bool intel_fbc_enabled(struct drm_device *dev) · line 349

Quoted 8 lines
drivers/gpu/drm/i915/intel_pm.c +6 -0
+	/* If it wasn't never enabled by kernel parameter or platform default
+	 * we can avoid reading registers so many times in vain
+	 */
+	if (!i915.enable_fbc)
+		return false;
+
 	if (!dev_priv->display.fbc_enabled)
 		return false;

The correct state to check here is whether we have enabled fbc, not the module parameter which just rules whether we should turn it on. Look at making dev_priv->fbc.no_fbc_reason always correct instead.

Well we need to fix this all up anyway, since pretty much everything on the software side of fbc is busted (locking, tracking, piles of rechecks and other hilarious stuff).
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#3 lore raw
Quoted 9 lines · Daniel Vetter
Quoted 5 lines · Chris Wilson
Quoted 2 lines · Rodrigo Vivi

If it wasn't never enabled by kernel parameter or platform default we can avoid reading registers so many times in vain

Nak.

Well I've merged this for now to reduce fbc impact.

Uhm, unfortunatelly I'm afraid Chris was right.
Paulo also nacked it. Because it just helps when it was explicitly disabled by setting i915.enable_fbc=0 while the default is -1.

I though about returning on <= 0, but Paulo is afraid that when enabling back for some platform people would forget to fix this part here and I agree.

Quoted 26 lines
Quoted 8 lines

Review

Quoted 8 lines
---
 drivers/gpu/drm/i915/intel_pm.c | 6 ++++++
 1 file changed, 6 insertions(+)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/intel_pm.c

Quoted 8 lines

drivers/gpu/drm/i915/intel_pm.c bool intel_fbc_enabled(struct drm_device *dev) · line 342

Quoted 8 lines

index a988862..afcc284 100644

drivers/gpu/drm/i915/intel_pm.c +1 -0
@@ -339,6 +339,12 @@ bool intel_fbc_enabled(struct drm_device *dev)
 {
    struct drm_i915_private *dev_priv = dev->dev_private;
 
+   /* If it wasn't never enabled by kernel parameter or platform

default

Quoted 8 lines
Quoted 7 lines
drivers/gpu/drm/i915/intel_pm.c +5 -0
+    * we can avoid reading registers so many times in vain
+    */
+   if (!i915.enable_fbc)
+           return false;
+
    if (!dev_priv->display.fbc_enabled)
            return false;
Quoted 8 lines
Quoted 3 lines

The correct state to check here is whether we have enabled fbc, not the module parameter which just rules whether we should turn it on. Look at making dev_priv->fbc.no_fbc_reason always correct instead.

Well we need to fix this all up anyway, since pretty much everything on the software side of fbc is busted (locking, tracking, piles of rechecks and other hilarious stuff).

I absolutely agree with you Daniel. We need a full fbc rework and simplification.

But for now we need a quick stuff to protect the current code.

Maybe an extra variable dev_priv.fbc_ever_enabled... This is ugly enough that someone wokirng to get fbc enabled by default would never forget as he can forget about i915.enable_fbc <= 0 at some random point of the code.

Quoted 10 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 2 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

2014-09-18 15:42 GMT-03:00 Rodrigo Vivi <[email protected]>:

Quoted 58 lines · Daniel Vetter
Quoted 9 lines · Chris Wilson
Quoted 5 lines · Rodrigo Vivi
Quoted 2 lines

If it wasn't never enabled by kernel parameter or platform default we can avoid reading registers so many times in vain

Nak.

Well I've merged this for now to reduce fbc impact.

Uhm, unfortunatelly I'm afraid Chris was right.
Paulo also nacked it. Because it just helps when it was explicitly disabled by setting i915.enable_fbc=0 while the default is -1.

I though about returning on <= 0, but Paulo is afraid that when enabling back for some platform people would forget to fix this part here and I agree.

Quoted 31 lines
Quoted 17 lines
Quoted 17 lines
---
 drivers/gpu/drm/i915/intel_pm.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +0 -0
index a988862..afcc284 100644
@@ -339,6 +339,12 @@ bool intel_fbc_enabled(struct drm_device *dev)
 {
    struct drm_i915_private *dev_priv = dev->dev_private;
 
Quoted 13 lines

drivers/gpu/drm/i915/intel_pm.c bool intel_fbc_enabled(struct drm_device *dev) · line 349

Quoted 9 lines
drivers/gpu/drm/i915/intel_pm.c +1 -0
+   /* If it wasn't never enabled by kernel parameter or platform

default

drivers/gpu/drm/i915/intel_pm.c +5 -0
+    * we can avoid reading registers so many times in vain
+    */
+   if (!i915.enable_fbc)
+           return false;
+
    if (!dev_priv->display.fbc_enabled)
            return false;

The correct state to check here is whether we have enabled fbc, not the module parameter which just rules whether we should turn it on. Look at making dev_priv->fbc.no_fbc_reason always correct instead.

Quoted 3 lines

Well we need to fix this all up anyway, since pretty much everything on the software side of fbc is busted (locking, tracking, piles of rechecks and other hilarious stuff).

Quoted 8 lines

I absolutely agree with you Daniel. We need a full fbc rework and simplification.

But for now we need a quick stuff to protect the current code.

Maybe an extra variable dev_priv.fbc_ever_enabled... This is ugly enough that someone wokirng to get fbc enabled by default would never forget as he can forget about i915.enable_fbc <= 0 at some random point of the code.

I just spotted another problem with this patch. If i915.enable_fbc is zero but FBC is actually enabled in HW, we won't end up disabling it. This case can be true if the user is playing with /sys/module/i915/parameters/enable_fbc.

That said, if we change i915.enable_fbc so that it _can't_ be changed at runtime, we'd probably be able to simplify a few things.

Quoted 27 lines
Quoted 4 lines
Quoted 9 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

--
Rodrigo Vivi
Blog: http://blog.vivi.eng.br

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 1 line
Paulo Zanoni
#5 lore raw
In reply to Rodrigo Vivi
Quoted 12 lines · Rodrigo Vivi
Quoted 9 lines · Daniel Vetter
Quoted 5 lines · Chris Wilson
Quoted 2 lines · Rodrigo Vivi

If it wasn't never enabled by kernel parameter or platform default we can avoid reading registers so many times in vain

Nak.

Well I've merged this for now to reduce fbc impact.

Quoted 7 lines

Uhm, unfortunatelly I'm afraid Chris was right.
Paulo also nacked it. Because it just helps when it was explicitly disabled by setting i915.enable_fbc=0 while the default is -1.

I though about returning on <= 0, but Paulo is afraid that when enabling back for some platform people would forget to fix this part here and I agree.

Well I guess I should have read mails before pushing out a new -next ;-) So this is now baked in. Should I revert or can we just fix up on top? -Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#6 lore raw
Quoted 16 lines · Daniel Vetter
Quoted 7 lines · Rodrigo Vivi
Quoted 5 lines · Daniel Vetter
Quoted 4 lines · Chris Wilson
Quoted 2 lines · Rodrigo Vivi

If it wasn't never enabled by kernel parameter or platform default we can avoid reading registers so many times in vain

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Nak.

Well I've merged this for now to reduce fbc impact.

Uhm, unfortunatelly I'm afraid Chris was right.
Paulo also nacked it. Because it just helps when it was explicitly

disabled

Quoted 9 lines
Quoted 5 lines

by setting i915.enable_fbc=0 while the default is -1.

I though about returning on <= 0, but Paulo is afraid that when enabling back for some platform people would forget to fix this part here and I agree.

Well I guess I should have read mails before pushing out a new -next ;-) So this is now baked in. Should I revert or can we just fix up on top?

No problem, I can fix this on top.

But what do you prefer:

1. <=0 return and changing parameter permission from 600 to 400
2. dev_priv->fbc_enabled
3. or check if fbc_no_reason was ever set? Although I don't like the fbc_no_reason and would like to clean it up in the future. But anyway, any option here is temporary until a proper rework for cleanup and real fix.

Quoted 6 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

Signature · 2 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#7 lore raw

2014-09-19 15:24 GMT-03:00 Rodrigo Vivi <[email protected]>:

Quoted 30 lines · Daniel Vetter
Quoted 19 lines · Rodrigo Vivi
Quoted 17 lines · Daniel Vetter
Quoted 10 lines · Chris Wilson
Quoted 5 lines · Rodrigo Vivi
Quoted 2 lines

If it wasn't never enabled by kernel parameter or platform default we can avoid reading registers so many times in vain

Nak.

Well I've merged this for now to reduce fbc impact.

Uhm, unfortunatelly I'm afraid Chris was right.
Paulo also nacked it. Because it just helps when it was explicitly disabled
by setting i915.enable_fbc=0 while the default is -1.

Quoted 6 lines
Quoted 3 lines

I though about returning on <= 0, but Paulo is afraid that when enabling back for some platform people would forget to fix this part here and I agree.

Well I guess I should have read mails before pushing out a new -next ;-) So this is now baked in. Should I revert or can we just fix up on top?

Quoted 5 lines

No problem, I can fix this on top.

But what do you prefer:

1. <=0 return and changing parameter permission from 600 to 400

If i915.enable_fbc is -1, you don't know whether it's enabled or not.

Quoted 1 line

2. dev_priv->fbc_enabled

I was just quickly tried to write this patch. It fixes the runtime PM regression I was seeing...

Quoted 3 lines

3. or check if fbc_no_reason was ever set? Although I don't like the fbc_no_reason and would like to clean it up in the future. But anyway, any option here is temporary until a proper rework for cleanup and real fix.

I also tried the fbc_no_reason path but gave up. When no_fbc_reason is FBC_OK, there's no guarantee that FBC is actually enabled: it just mean that we may be enabling/disabling it as part of the normal FBC operation. So to do what we want, we'd have to twist the meaning of no_fbc_reason and add values like FBC_OK_AND_ENABLED and FBC_OK_AND_DISABLED, and I don't think that's a cool solution.

I'll send the patch for item 2 in a few minutes.

Quoted 21 lines
Quoted 7 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

--
Rodrigo Vivi
Blog: http://blog.vivi.eng.br

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 1 line
Paulo Zanoni