Skip to contentSkip to conversation

drm/i915: VGA vs. power well

PATCH In review [email protected] 3 participants 16 messages Sep 12, 2013 – Sep 13, 2013

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

cover drm/i915: VGA vs. power well

Match of a lifetime! In the red corner VGA, the underdog. In the blue corner, the killer of registers, the bane of memory access, the POWER WELL! Who will win?

This series eliminates the unclaimed register access warning introduced by the delayed VGA memory disable. And now we actually disable VGA memory decode on machines where we turn the power well off during init, making it slightly more probable that vga arbitration will work.

Fixing pc8 entry when the last power well reference disappears is left as an exercise for the reader.

#1 lore raw

PATCH 1/5 drm/i915: Add intel_display_power_{get, put} to request power for specific domains

From: Ville Syrjälä <[email protected]>

Add APIs to get/put power well references for specific purposes.

Also reorganize the internal i915_request power well handling to use the reference count just like everyone else. This way all we need to do is check the reference count and we know whether the power well needs to be enabled of disabled.

---
 drivers/gpu/drm/i915/intel_drv.h |  4 ++
 drivers/gpu/drm/i915/intel_pm.c  | 92 ++++++++++++++++++++++++++++++++++++----
 2 files changed, 87 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +4 -0
index 774ebb6..2ecd3d2 100644
@@ -763,6 +763,10 @@ extern void i915_remove_power_well(struct drm_device *dev);
 
 extern bool intel_display_power_enabled(struct drm_device *dev,
 					enum intel_display_power_domain domain);
+extern void intel_display_power_get(struct drm_device *dev,
+				    enum intel_display_power_domain domain);
+extern void intel_display_power_put(struct drm_device *dev,
+				    enum intel_display_power_domain domain);
 extern void intel_init_power_well(struct drm_device *dev);
 extern void intel_set_power_well(struct drm_device *dev, bool enable);
 extern void intel_enable_gt_powersave(struct drm_device *dev);
drivers/gpu/drm/i915/intel_pm.c +83 -9

120 lines not on this page · raw message

Signature · 6 lines
1.8.1.5

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

Re: [PATCH 1/5] drm/i915: Add intel_display_power_{get, put} to request power for specific domains

Hi

2013/9/12 <[email protected]>:

Quoted 49 lines

From: Ville Syrjälä <[email protected]>

Add APIs to get/put power well references for specific purposes.

Also reorganize the internal i915_request power well handling to use the reference count just like everyone else. This way all we need to do is check the reference count and we know whether the power well needs to be enabled of disabled.

---
 drivers/gpu/drm/i915/intel_drv.h |  4 ++
 drivers/gpu/drm/i915/intel_pm.c  | 92 ++++++++++++++++++++++++++++++++++++----
 2 files changed, 87 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +4 -0
index 774ebb6..2ecd3d2 100644
@@ -763,6 +763,10 @@ extern void i915_remove_power_well(struct drm_device *dev);
 
 extern bool intel_display_power_enabled(struct drm_device *dev,
                                        enum intel_display_power_domain domain);
+extern void intel_display_power_get(struct drm_device *dev,
+                                   enum intel_display_power_domain domain);
+extern void intel_display_power_put(struct drm_device *dev,
+                                   enum intel_display_power_domain domain);
 extern void intel_init_power_well(struct drm_device *dev);
 extern void intel_set_power_well(struct drm_device *dev, bool enable);
 extern void intel_enable_gt_powersave(struct drm_device *dev);
drivers/gpu/drm/i915/intel_pm.c +11 -0
index 8cffef4..4962303 100644
@@ -5333,6 +5333,69 @@ static void __intel_set_power_well(struct drm_device *dev, bool enable)
        }
 }
 
+void intel_display_power_get(struct drm_device *dev,
+                            enum intel_display_power_domain domain)
+{
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       struct i915_power_well *power_well = &dev_priv->power_well;
+
+       if (!HAS_POWER_WELL(dev))
+               return;
+
+       switch (domain) {
+       case POWER_DOMAIN_PIPE_A:

drivers/gpu/drm/i915/intel_pm.c static void __intel_set_power_well(struct drm_device *dev, bool enable) · line 5356

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10 -0
+       case POWER_DOMAIN_TRANSCODER_EDP:
+               return;
+       case POWER_DOMAIN_PIPE_B:
+       case POWER_DOMAIN_PIPE_C:
+       case POWER_DOMAIN_PIPE_A_PANEL_FITTER:
+       case POWER_DOMAIN_PIPE_B_PANEL_FITTER:
+       case POWER_DOMAIN_PIPE_C_PANEL_FITTER:
+       case POWER_DOMAIN_TRANSCODER_A:
+       case POWER_DOMAIN_TRANSCODER_B:
+       case POWER_DOMAIN_TRANSCODER_C:

I know I'm the one who added all these domains, but I have to say I only did this because of the reviewers, I don't really like the interface. With your addition there's a new problem: you can get the POWER_DOMAIN_PIPE_B interface and then put the POWER_COMAIN_PIPE_C_PANEL_FITTER and no one will notice. I really think the power well itself should be the domain. Also, in cases like the suspend/resume code we don't have any domain that makes sense. But what's *not* ugly about the power well code?

I'm not suggesting you to fix that, I'm more kinda asking for ideas, I may want to reorganize this code yet again when doing the D3 feature. (Just because every single time we touch the power well code we have to refactor it!)

Quoted 75 lines
drivers/gpu/drm/i915/intel_pm.c +50 -4
+               spin_lock_irq(&power_well->lock);
+               if (!power_well->count++)
+                       __intel_set_power_well(power_well->device, true);
+               spin_unlock_irq(&power_well->lock);
+               return;
+       default:
+               BUG();
+       }
+}
+
+void intel_display_power_put(struct drm_device *dev,
+                            enum intel_display_power_domain domain)
+{
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       struct i915_power_well *power_well = &dev_priv->power_well;
+
+       if (!HAS_POWER_WELL(dev))
+               return;
+
+       switch (domain) {
+       case POWER_DOMAIN_PIPE_A:
+       case POWER_DOMAIN_TRANSCODER_EDP:
+               return;
+       case POWER_DOMAIN_PIPE_B:
+       case POWER_DOMAIN_PIPE_C:
+       case POWER_DOMAIN_PIPE_A_PANEL_FITTER:
+       case POWER_DOMAIN_PIPE_B_PANEL_FITTER:
+       case POWER_DOMAIN_PIPE_C_PANEL_FITTER:
+       case POWER_DOMAIN_TRANSCODER_A:
+       case POWER_DOMAIN_TRANSCODER_B:
+       case POWER_DOMAIN_TRANSCODER_C:
+               spin_lock_irq(&power_well->lock);
+               WARN_ON(!power_well->count);
+               if (!--power_well->count)
+                       __intel_set_power_well(power_well->device, false);
+               spin_unlock_irq(&power_well->lock);
+               return;
+       default:
+               BUG();
+       }
+}
+
 static struct i915_power_well *hsw_pwr;
 
 /* Display audio driver power well request */
@@ -5342,8 +5405,7 @@ void i915_request_power_well(void)
                return;
 
        spin_lock_irq(&hsw_pwr->lock);
-       if (!hsw_pwr->count++ &&
-                       !hsw_pwr->i915_request)
+       if (!hsw_pwr->count++)
                __intel_set_power_well(hsw_pwr->device, true);
        spin_unlock_irq(&hsw_pwr->lock);
 }
@@ -5357,8 +5419,7 @@ void i915_release_power_well(void)
 
        spin_lock_irq(&hsw_pwr->lock);
        WARN_ON(!hsw_pwr->count);
-       if (!--hsw_pwr->count &&
-                      !hsw_pwr->i915_request)
+       if (!--hsw_pwr->count)
                __intel_set_power_well(hsw_pwr->device, false);
        spin_unlock_irq(&hsw_pwr->lock);
 }
@@ -5394,15 +5455,28 @@ void intel_set_power_well(struct drm_device *dev, bool enable)
                return;
 
        spin_lock_irq(&power_well->lock);
+
+       /*
+        * This function will only ever contribute one
+        * to the power well reference count. i915_request
+        * is what tracks whether we have or have not
+        * added the one to the reference count.

drivers/gpu/drm/i915/intel_pm.c void intel_set_power_well(struct drm_device *dev, bool enable) · line 5402

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +4 -4
+        */
+       if (power_well->i915_request == enable)
+               goto out;
+
        power_well->i915_request = enable;
 
-       /* only reject "disable" power well request */
-       if (power_well->count && !enable) {
-               spin_unlock_irq(&power_well->lock);
-               return;

And now to the real problem of the patch: previously whenever we got a call to "enable" we'd call __intel_set_power_well and certainly write the register. Now with this patch we may not do this due to i915_request and the count. This breaks suspend/resume where just after we resume we call intel_set_power_well(dev, true) but then the new code doesn't really writes the register since i915_request is already true. As a consequence, we see "unclaimed register" messages complaining about registers 70008, 71008 and 72008. Perhaps in the resume path we should fix our tracking and force the "enable" somehow.

Quoted 21 lines
drivers/gpu/drm/i915/intel_pm.c +8 -2
+       if (enable) {
+               if (!power_well->count++)
+                       __intel_set_power_well(dev, true);
+       } else {
+               WARN_ON(!power_well->count);
+               if (!--power_well->count)
+                       __intel_set_power_well(dev, false);
        }
 
-       __intel_set_power_well(dev, enable);
+ out:
        spin_unlock_irq(&power_well->lock);
 }
 
--

1.8.1.5

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

Signature · 1 line
Paulo Zanoni
#3 lore raw

Re: [PATCH 1/5] drm/i915: Add intel_display_power_{get, put} to request power for specific domains

Quoted 72 lines · Paulo Zanoni

Hi

2013/9/12 <[email protected]>:

Quoted 49 lines

From: Ville Syrjälä <[email protected]>

Add APIs to get/put power well references for specific purposes.

Also reorganize the internal i915_request power well handling to use the reference count just like everyone else. This way all we need to do is check the reference count and we know whether the power well needs to be enabled of disabled.

---
 drivers/gpu/drm/i915/intel_drv.h |  4 ++
 drivers/gpu/drm/i915/intel_pm.c  | 92 ++++++++++++++++++++++++++++++++++++----
 2 files changed, 87 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +4 -0
index 774ebb6..2ecd3d2 100644
@@ -763,6 +763,10 @@ extern void i915_remove_power_well(struct drm_device *dev);
 
 extern bool intel_display_power_enabled(struct drm_device *dev,
                                        enum intel_display_power_domain domain);
+extern void intel_display_power_get(struct drm_device *dev,
+                                   enum intel_display_power_domain domain);
+extern void intel_display_power_put(struct drm_device *dev,
+                                   enum intel_display_power_domain domain);
 extern void intel_init_power_well(struct drm_device *dev);
 extern void intel_set_power_well(struct drm_device *dev, bool enable);
 extern void intel_enable_gt_powersave(struct drm_device *dev);
drivers/gpu/drm/i915/intel_pm.c +11 -0
index 8cffef4..4962303 100644
@@ -5333,6 +5333,69 @@ static void __intel_set_power_well(struct drm_device *dev, bool enable)
        }
 }
 
+void intel_display_power_get(struct drm_device *dev,
+                            enum intel_display_power_domain domain)
+{
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       struct i915_power_well *power_well = &dev_priv->power_well;
+
+       if (!HAS_POWER_WELL(dev))
+               return;
+
+       switch (domain) {
+       case POWER_DOMAIN_PIPE_A:

drivers/gpu/drm/i915/intel_pm.c static void __intel_set_power_well(struct drm_device *dev, bool enable) · line 5356

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10 -0
+       case POWER_DOMAIN_TRANSCODER_EDP:
+               return;
+       case POWER_DOMAIN_PIPE_B:
+       case POWER_DOMAIN_PIPE_C:
+       case POWER_DOMAIN_PIPE_A_PANEL_FITTER:
+       case POWER_DOMAIN_PIPE_B_PANEL_FITTER:
+       case POWER_DOMAIN_PIPE_C_PANEL_FITTER:
+       case POWER_DOMAIN_TRANSCODER_A:
+       case POWER_DOMAIN_TRANSCODER_B:
+       case POWER_DOMAIN_TRANSCODER_C:

I know I'm the one who added all these domains, but I have to say I only did this because of the reviewers, I don't really like the interface. With your addition there's a new problem: you can get the POWER_DOMAIN_PIPE_B interface and then put the POWER_COMAIN_PIPE_C_PANEL_FITTER and no one will notice. I really think the power well itself should be the domain. Also, in cases like the suspend/resume code we don't have any domain that makes sense. But what's *not* ugly about the power well code?

Quoted 4 lines

I'm not suggesting you to fix that, I'm more kinda asking for ideas, I may want to reorganize this code yet again when doing the D3 feature. (Just because every single time we touch the power well code we have to refactor it!)

In other platforms we're going to have totally different mix of functional blocks vs. power wells. So assuming we want to deal with those using a unified API we do need something like this. But maybe there's a better way to go, haven't really thought about it.

Quoted 83 lines
Quoted 83 lines
drivers/gpu/drm/i915/intel_pm.c +54 -4
+               spin_lock_irq(&power_well->lock);
+               if (!power_well->count++)
+                       __intel_set_power_well(power_well->device, true);
+               spin_unlock_irq(&power_well->lock);
+               return;
+       default:
+               BUG();
+       }
+}
+
+void intel_display_power_put(struct drm_device *dev,
+                            enum intel_display_power_domain domain)
+{
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       struct i915_power_well *power_well = &dev_priv->power_well;
+
+       if (!HAS_POWER_WELL(dev))
+               return;
+
+       switch (domain) {
+       case POWER_DOMAIN_PIPE_A:
+       case POWER_DOMAIN_TRANSCODER_EDP:
+               return;
+       case POWER_DOMAIN_PIPE_B:
+       case POWER_DOMAIN_PIPE_C:
+       case POWER_DOMAIN_PIPE_A_PANEL_FITTER:
+       case POWER_DOMAIN_PIPE_B_PANEL_FITTER:
+       case POWER_DOMAIN_PIPE_C_PANEL_FITTER:
+       case POWER_DOMAIN_TRANSCODER_A:
+       case POWER_DOMAIN_TRANSCODER_B:
+       case POWER_DOMAIN_TRANSCODER_C:
+               spin_lock_irq(&power_well->lock);
+               WARN_ON(!power_well->count);
+               if (!--power_well->count)
+                       __intel_set_power_well(power_well->device, false);
+               spin_unlock_irq(&power_well->lock);
+               return;
+       default:
+               BUG();
+       }
+}
+
 static struct i915_power_well *hsw_pwr;
 
 /* Display audio driver power well request */
@@ -5342,8 +5405,7 @@ void i915_request_power_well(void)
                return;
 
        spin_lock_irq(&hsw_pwr->lock);
-       if (!hsw_pwr->count++ &&
-                       !hsw_pwr->i915_request)
+       if (!hsw_pwr->count++)
                __intel_set_power_well(hsw_pwr->device, true);
        spin_unlock_irq(&hsw_pwr->lock);
 }
@@ -5357,8 +5419,7 @@ void i915_release_power_well(void)
 
        spin_lock_irq(&hsw_pwr->lock);
        WARN_ON(!hsw_pwr->count);
-       if (!--hsw_pwr->count &&
-                      !hsw_pwr->i915_request)
+       if (!--hsw_pwr->count)
                __intel_set_power_well(hsw_pwr->device, false);
        spin_unlock_irq(&hsw_pwr->lock);
 }
@@ -5394,15 +5455,28 @@ void intel_set_power_well(struct drm_device *dev, bool enable)
                return;
 
        spin_lock_irq(&power_well->lock);
+
+       /*
+        * This function will only ever contribute one
+        * to the power well reference count. i915_request
+        * is what tracks whether we have or have not
+        * added the one to the reference count.
+        */
+       if (power_well->i915_request == enable)
+               goto out;
+
        power_well->i915_request = enable;
 
Quoted 14 lines

drivers/gpu/drm/i915/intel_pm.c void intel_set_power_well(struct drm_device *dev, bool enable) · line 5402

Quoted 4 lines
drivers/gpu/drm/i915/intel_pm.c +0 -4
-       /* only reject "disable" power well request */
-       if (power_well->count && !enable) {
-               spin_unlock_irq(&power_well->lock);
-               return;

And now to the real problem of the patch: previously whenever we got a call to "enable" we'd call __intel_set_power_well and certainly write the register. Now with this patch we may not do this due to i915_request and the count. This breaks suspend/resume where just after we resume we call intel_set_power_well(dev, true) but then the new code doesn't really writes the register since i915_request is already true. As a consequence, we see "unclaimed register" messages complaining about registers 70008, 71008 and 72008. Perhaps in the resume path we should fix our tracking and force the "enable" somehow.

Hmm. I guess we anyway want to force the power well to be active during resume regardless of where the refcount was left.

So maybe just a resume power well func or something:

intel_resume_power_well()

{
	if (!i915_request) {
		i915_request = true;
		count++;
	}
	__set_power_well(true);
}
Quoted 28 lines
Quoted 23 lines
drivers/gpu/drm/i915/intel_pm.c +8 -2
+       if (enable) {
+               if (!power_well->count++)
+                       __intel_set_power_well(dev, true);
+       } else {
+               WARN_ON(!power_well->count);
+               if (!--power_well->count)
+                       __intel_set_power_well(dev, false);
        }
 
-       __intel_set_power_well(dev, enable);
+ out:
        spin_unlock_irq(&power_well->lock);
 }
 
--

1.8.1.5

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

Signature · 1 line
Paulo Zanoni
Signature · 2 lines
Ville Syrjälä
Intel OTC
#4 lore raw

Re: [PATCH 1/5] drm/i915: Add intel_display_power_{get, put} to request power for specific domains

2013/9/13 Ville Syrjälä <[email protected]>:

Quoted 186 lines · Paulo Zanoni
Quoted 72 lines

Hi

2013/9/12 <[email protected]>:

Quoted 49 lines

From: Ville Syrjälä <[email protected]>

Add APIs to get/put power well references for specific purposes.

Also reorganize the internal i915_request power well handling to use the reference count just like everyone else. This way all we need to do is check the reference count and we know whether the power well needs to be enabled of disabled.

---
 drivers/gpu/drm/i915/intel_drv.h |  4 ++
 drivers/gpu/drm/i915/intel_pm.c  | 92 ++++++++++++++++++++++++++++++++++++----
 2 files changed, 87 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +4 -0
index 774ebb6..2ecd3d2 100644
@@ -763,6 +763,10 @@ extern void i915_remove_power_well(struct drm_device *dev);
 
 extern bool intel_display_power_enabled(struct drm_device *dev,
                                        enum intel_display_power_domain domain);
+extern void intel_display_power_get(struct drm_device *dev,
+                                   enum intel_display_power_domain domain);
+extern void intel_display_power_put(struct drm_device *dev,
+                                   enum intel_display_power_domain domain);
 extern void intel_init_power_well(struct drm_device *dev);
 extern void intel_set_power_well(struct drm_device *dev, bool enable);
 extern void intel_enable_gt_powersave(struct drm_device *dev);
drivers/gpu/drm/i915/intel_pm.c +11 -0
index 8cffef4..4962303 100644
@@ -5333,6 +5333,69 @@ static void __intel_set_power_well(struct drm_device *dev, bool enable)
        }
 }
 
+void intel_display_power_get(struct drm_device *dev,
+                            enum intel_display_power_domain domain)
+{
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       struct i915_power_well *power_well = &dev_priv->power_well;
+
+       if (!HAS_POWER_WELL(dev))
+               return;
+
+       switch (domain) {
+       case POWER_DOMAIN_PIPE_A:

drivers/gpu/drm/i915/intel_pm.c static void __intel_set_power_well(struct drm_device *dev, bool enable) · line 5356

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10 -0
+       case POWER_DOMAIN_TRANSCODER_EDP:
+               return;
+       case POWER_DOMAIN_PIPE_B:
+       case POWER_DOMAIN_PIPE_C:
+       case POWER_DOMAIN_PIPE_A_PANEL_FITTER:
+       case POWER_DOMAIN_PIPE_B_PANEL_FITTER:
+       case POWER_DOMAIN_PIPE_C_PANEL_FITTER:
+       case POWER_DOMAIN_TRANSCODER_A:
+       case POWER_DOMAIN_TRANSCODER_B:
+       case POWER_DOMAIN_TRANSCODER_C:

I know I'm the one who added all these domains, but I have to say I only did this because of the reviewers, I don't really like the interface. With your addition there's a new problem: you can get the POWER_DOMAIN_PIPE_B interface and then put the POWER_COMAIN_PIPE_C_PANEL_FITTER and no one will notice. I really think the power well itself should be the domain. Also, in cases like the suspend/resume code we don't have any domain that makes sense. But what's *not* ugly about the power well code?

Quoted 4 lines

I'm not suggesting you to fix that, I'm more kinda asking for ideas, I may want to reorganize this code yet again when doing the D3 feature. (Just because every single time we touch the power well code we have to refactor it!)

In other platforms we're going to have totally different mix of functional blocks vs. power wells. So assuming we want to deal with those using a unified API we do need something like this. But maybe there's a better way to go, haven't really thought about it.

Quoted 83 lines
Quoted 83 lines
drivers/gpu/drm/i915/intel_pm.c +54 -4
+               spin_lock_irq(&power_well->lock);
+               if (!power_well->count++)
+                       __intel_set_power_well(power_well->device, true);
+               spin_unlock_irq(&power_well->lock);
+               return;
+       default:
+               BUG();
+       }
+}
+
+void intel_display_power_put(struct drm_device *dev,
+                            enum intel_display_power_domain domain)
+{
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       struct i915_power_well *power_well = &dev_priv->power_well;
+
+       if (!HAS_POWER_WELL(dev))
+               return;
+
+       switch (domain) {
+       case POWER_DOMAIN_PIPE_A:
+       case POWER_DOMAIN_TRANSCODER_EDP:
+               return;
+       case POWER_DOMAIN_PIPE_B:
+       case POWER_DOMAIN_PIPE_C:
+       case POWER_DOMAIN_PIPE_A_PANEL_FITTER:
+       case POWER_DOMAIN_PIPE_B_PANEL_FITTER:
+       case POWER_DOMAIN_PIPE_C_PANEL_FITTER:
+       case POWER_DOMAIN_TRANSCODER_A:
+       case POWER_DOMAIN_TRANSCODER_B:
+       case POWER_DOMAIN_TRANSCODER_C:
+               spin_lock_irq(&power_well->lock);
+               WARN_ON(!power_well->count);
+               if (!--power_well->count)
+                       __intel_set_power_well(power_well->device, false);
+               spin_unlock_irq(&power_well->lock);
+               return;
+       default:
+               BUG();
+       }
+}
+
 static struct i915_power_well *hsw_pwr;
 
 /* Display audio driver power well request */
@@ -5342,8 +5405,7 @@ void i915_request_power_well(void)
                return;
 
        spin_lock_irq(&hsw_pwr->lock);
-       if (!hsw_pwr->count++ &&
-                       !hsw_pwr->i915_request)
+       if (!hsw_pwr->count++)
                __intel_set_power_well(hsw_pwr->device, true);
        spin_unlock_irq(&hsw_pwr->lock);
 }
@@ -5357,8 +5419,7 @@ void i915_release_power_well(void)
 
        spin_lock_irq(&hsw_pwr->lock);
        WARN_ON(!hsw_pwr->count);
-       if (!--hsw_pwr->count &&
-                      !hsw_pwr->i915_request)
+       if (!--hsw_pwr->count)
                __intel_set_power_well(hsw_pwr->device, false);
        spin_unlock_irq(&hsw_pwr->lock);
 }
@@ -5394,15 +5455,28 @@ void intel_set_power_well(struct drm_device *dev, bool enable)
                return;
 
        spin_lock_irq(&power_well->lock);
+
+       /*
+        * This function will only ever contribute one
+        * to the power well reference count. i915_request
+        * is what tracks whether we have or have not
+        * added the one to the reference count.
+        */
+       if (power_well->i915_request == enable)
+               goto out;
+
        power_well->i915_request = enable;
 
Quoted 14 lines

drivers/gpu/drm/i915/intel_pm.c void intel_set_power_well(struct drm_device *dev, bool enable) · line 5402

Quoted 4 lines
drivers/gpu/drm/i915/intel_pm.c +0 -4
-       /* only reject "disable" power well request */
-       if (power_well->count && !enable) {
-               spin_unlock_irq(&power_well->lock);
-               return;

And now to the real problem of the patch: previously whenever we got a call to "enable" we'd call __intel_set_power_well and certainly write the register. Now with this patch we may not do this due to i915_request and the count. This breaks suspend/resume where just after we resume we call intel_set_power_well(dev, true) but then the new code doesn't really writes the register since i915_request is already true. As a consequence, we see "unclaimed register" messages complaining about registers 70008, 71008 and 72008. Perhaps in the resume path we should fix our tracking and force the "enable" somehow.

Hmm. I guess we anyway want to force the power well to be active during resume regardless of where the refcount was left.

So maybe just a resume power well func or something:

Quoted 8 lines

intel_resume_power_well()

{
        if (!i915_request) {
                i915_request = true;
                count++;
        }
        __set_power_well(true);
}

Yes, looks good.

Quoted 33 lines
Quoted 27 lines
Quoted 20 lines
drivers/gpu/drm/i915/intel_pm.c +8 -2
+       if (enable) {
+               if (!power_well->count++)
+                       __intel_set_power_well(dev, true);
+       } else {
+               WARN_ON(!power_well->count);
+               if (!--power_well->count)
+                       __intel_set_power_well(dev, false);
        }
 
-       __intel_set_power_well(dev, enable);
+ out:
        spin_unlock_irq(&power_well->lock);
 }
 
--

1.8.1.5

Quoted 4 lines

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

Quoted 2 lines

--
Paulo Zanoni

--
Ville Syrjälä
Intel OTC

Signature · 1 line
Paulo Zanoni
#5 lore raw

PATCH 2/5 drm/i915: Refactor power well refcount inc/dec operations

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

We increase/decrease the power well refcount in several places now, and all of those places need to do the same thing, so pull that code into a few small helper functions.

---
 drivers/gpu/drm/i915/intel_pm.c | 39 +++++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +21 -18
index 4962303..1aa604c 100644
@@ -5333,6 +5333,19 @@ static void __intel_set_power_well(struct drm_device *dev, bool enable)
 	}
 }
 
+static void __intel_inc_power_well_refcount(struct i915_power_well *power_well)
+{
+	if (!power_well->count++)
+		__intel_set_power_well(power_well->device, true);
+}
+
+static void __intel_dec_power_well_refcount(struct i915_power_well *power_well)
+{
+	WARN_ON(!power_well->count);
+	if (!--power_well->count)
+		__intel_set_power_well(power_well->device, false);
+}
+
 void intel_display_power_get(struct drm_device *dev,
 			     enum intel_display_power_domain domain)
 {
@@ -5355,8 +5368,7 @@ void intel_display_power_get(struct drm_device *dev,
 	case POWER_DOMAIN_TRANSCODER_B:
 	case POWER_DOMAIN_TRANSCODER_C:
 		spin_lock_irq(&power_well->lock);
-		if (!power_well->count++)
-			__intel_set_power_well(power_well->device, true);
+		__intel_inc_power_well_refcount(power_well);
 		spin_unlock_irq(&power_well->lock);
 		return;
 	default:
@@ -5386,9 +5398,7 @@ void intel_display_power_put(struct drm_device *dev,
 	case POWER_DOMAIN_TRANSCODER_B:
 	case POWER_DOMAIN_TRANSCODER_C:
 		spin_lock_irq(&power_well->lock);
-		WARN_ON(!power_well->count);
-		if (!--power_well->count)
-			__intel_set_power_well(power_well->device, false);
+		__intel_dec_power_well_refcount(power_well);
 		spin_unlock_irq(&power_well->lock);
 		return;
 	default:
@@ -5405,8 +5415,7 @@ void i915_request_power_well(void)
 		return;
 
 	spin_lock_irq(&hsw_pwr->lock);
-	if (!hsw_pwr->count++)
-		__intel_set_power_well(hsw_pwr->device, true);
+	__intel_inc_power_well_refcount(hsw_pwr);
 	spin_unlock_irq(&hsw_pwr->lock);
 }
 EXPORT_SYMBOL_GPL(i915_request_power_well);
@@ -5418,9 +5427,7 @@ void i915_release_power_well(void)
 		return;
 
 	spin_lock_irq(&hsw_pwr->lock);
-	WARN_ON(!hsw_pwr->count);
-	if (!--hsw_pwr->count)
-		__intel_set_power_well(hsw_pwr->device, false);
+	__intel_dec_power_well_refcount(hsw_pwr);
 	spin_unlock_irq(&hsw_pwr->lock);
 }
 EXPORT_SYMBOL_GPL(i915_release_power_well);
@@ -5467,14 +5474,10 @@ void intel_set_power_well(struct drm_device *dev, bool enable)
 
 	power_well->i915_request = enable;
 
-	if (enable) {
-		if (!power_well->count++)
-			__intel_set_power_well(dev, true);
-	} else {
-		WARN_ON(!power_well->count);
-		if (!--power_well->count)
-			__intel_set_power_well(dev, false);
-	}
+	if (enable)
+		__intel_inc_power_well_refcount(power_well);
+	else
+		__intel_dec_power_well_refcount(power_well);
 
  out:
 	spin_unlock_irq(&power_well->lock);
Signature · 6 lines
1.8.1.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 2/5
#6 lore raw

Re: [PATCH 2/5] drm/i915: Refactor power well refcount inc/dec operations

2013/9/12 <[email protected]>:

Quoted 7 lines

From: Ville Syrjälä <[email protected]>

We increase/decrease the power well refcount in several places now, and all of those places need to do the same thing, so pull that code into a few small helper functions.

<bikeshed> I don't think we need those "__" in the beginning. </bikeshed>

Quoted 96 lines
---
 drivers/gpu/drm/i915/intel_pm.c | 39 +++++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +21 -19
index 4962303..1aa604c 100644
@@ -5333,6 +5333,19 @@ static void __intel_set_power_well(struct drm_device *dev, bool enable)
        }
 }
 
+static void __intel_inc_power_well_refcount(struct i915_power_well *power_well)
+{
+       if (!power_well->count++)
+               __intel_set_power_well(power_well->device, true);
+}
+
+static void __intel_dec_power_well_refcount(struct i915_power_well *power_well)
+{
+       WARN_ON(!power_well->count);
+       if (!--power_well->count)
+               __intel_set_power_well(power_well->device, false);
+}
+
 void intel_display_power_get(struct drm_device *dev,
                             enum intel_display_power_domain domain)
 {
@@ -5355,8 +5368,7 @@ void intel_display_power_get(struct drm_device *dev,
        case POWER_DOMAIN_TRANSCODER_B:
        case POWER_DOMAIN_TRANSCODER_C:
                spin_lock_irq(&power_well->lock);
-               if (!power_well->count++)
-                       __intel_set_power_well(power_well->device, true);
+               __intel_inc_power_well_refcount(power_well);
                spin_unlock_irq(&power_well->lock);
                return;
        default:
@@ -5386,9 +5398,7 @@ void intel_display_power_put(struct drm_device *dev,
        case POWER_DOMAIN_TRANSCODER_B:
        case POWER_DOMAIN_TRANSCODER_C:
                spin_lock_irq(&power_well->lock);
-               WARN_ON(!power_well->count);
-               if (!--power_well->count)
-                       __intel_set_power_well(power_well->device, false);
+               __intel_dec_power_well_refcount(power_well);
                spin_unlock_irq(&power_well->lock);
                return;
        default:
@@ -5405,8 +5415,7 @@ void i915_request_power_well(void)
                return;
 
        spin_lock_irq(&hsw_pwr->lock);
-       if (!hsw_pwr->count++)
-               __intel_set_power_well(hsw_pwr->device, true);
+       __intel_inc_power_well_refcount(hsw_pwr);
        spin_unlock_irq(&hsw_pwr->lock);
 }
 EXPORT_SYMBOL_GPL(i915_request_power_well);
@@ -5418,9 +5427,7 @@ void i915_release_power_well(void)
                return;
 
        spin_lock_irq(&hsw_pwr->lock);
-       WARN_ON(!hsw_pwr->count);
-       if (!--hsw_pwr->count)
-               __intel_set_power_well(hsw_pwr->device, false);
+       __intel_dec_power_well_refcount(hsw_pwr);
        spin_unlock_irq(&hsw_pwr->lock);
 }
 EXPORT_SYMBOL_GPL(i915_release_power_well);
@@ -5467,14 +5474,10 @@ void intel_set_power_well(struct drm_device *dev, bool enable)
 
        power_well->i915_request = enable;
 
-       if (enable) {
-               if (!power_well->count++)
-                       __intel_set_power_well(dev, true);
-       } else {
-               WARN_ON(!power_well->count);
-               if (!--power_well->count)
-                       __intel_set_power_well(dev, false);
-       }
+       if (enable)
+               __intel_inc_power_well_refcount(power_well);
+       else
+               __intel_dec_power_well_refcount(power_well);
 
  out:
        spin_unlock_irq(&power_well->lock);
--

1.8.1.5

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

Signature · 1 line
Paulo Zanoni
#7 lore raw

Re: [PATCH 2/5] drm/i915: Refactor power well refcount inc/dec operations

Quoted 10 lines · Paulo Zanoni

2013/9/12 <[email protected]>:

Quoted 7 lines

From: Ville Syrjälä <[email protected]>

We increase/decrease the power well refcount in several places now, and all of those places need to do the same thing, so pull that code into a few small helper functions.

<bikeshed> I don't think we need those "__" in the beginning. </bikeshed>

It would work better as __intel_power_well_get/put. Then it follows the convention that you have a wrapper that does some sanity checks, takes a locks and calls the core locked (unsafe) function, before unwrapping. -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#8 lore raw

PATCH 3/5 drm/i915: Add POWER_DOMAIN_VGA

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

VGA registers/memory live inside the the display power well. Add a power domain for VGA.

---
 drivers/gpu/drm/i915/i915_drv.h | 1 +
 drivers/gpu/drm/i915/intel_pm.c | 3 +++
 2 files changed, 4 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 152291c..54b1966 100644
@@ -99,6 +99,7 @@ enum intel_display_power_domain {
 	POWER_DOMAIN_TRANSCODER_B,
 	POWER_DOMAIN_TRANSCODER_C,
 	POWER_DOMAIN_TRANSCODER_EDP = POWER_DOMAIN_TRANSCODER_A + 0xF,
+	POWER_DOMAIN_VGA,
 };
 
 #define POWER_DOMAIN_PIPE(pipe) ((pipe) + POWER_DOMAIN_PIPE_A)
drivers/gpu/drm/i915/intel_pm.c +3 -0
index 1aa604c..f08fe52 100644
@@ -5271,6 +5271,7 @@ bool intel_display_power_enabled(struct drm_device *dev,
 	case POWER_DOMAIN_PIPE_A:
 	case POWER_DOMAIN_TRANSCODER_EDP:
 		return true;
+	case POWER_DOMAIN_VGA:
 	case POWER_DOMAIN_PIPE_B:
 	case POWER_DOMAIN_PIPE_C:
 	case POWER_DOMAIN_PIPE_A_PANEL_FITTER:
@@ -5359,6 +5360,7 @@ void intel_display_power_get(struct drm_device *dev,
 	case POWER_DOMAIN_PIPE_A:
 	case POWER_DOMAIN_TRANSCODER_EDP:
 		return;
+	case POWER_DOMAIN_VGA:
 	case POWER_DOMAIN_PIPE_B:
 	case POWER_DOMAIN_PIPE_C:
 	case POWER_DOMAIN_PIPE_A_PANEL_FITTER:
@@ -5389,6 +5391,7 @@ void intel_display_power_put(struct drm_device *dev,
 	case POWER_DOMAIN_PIPE_A:
 	case POWER_DOMAIN_TRANSCODER_EDP:
 		return;
+	case POWER_DOMAIN_VGA:
 	case POWER_DOMAIN_PIPE_B:
 	case POWER_DOMAIN_PIPE_C:
 	case POWER_DOMAIN_PIPE_A_PANEL_FITTER:
Signature · 6 lines
1.8.1.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 3/5
#9 lore raw

Re: [PATCH 3/5] drm/i915: Add POWER_DOMAIN_VGA

2013/9/12 <[email protected]>:

Quoted 6 lines

From: Ville Syrjälä <[email protected]>

VGA registers/memory live inside the the display power well. Add a power domain for VGA.

(see comments in patch 1/5)

Quoted 52 lines
---
 drivers/gpu/drm/i915/i915_drv.h | 1 +
 drivers/gpu/drm/i915/intel_pm.c | 3 +++
 2 files changed, 4 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 152291c..54b1966 100644
@@ -99,6 +99,7 @@ enum intel_display_power_domain {
        POWER_DOMAIN_TRANSCODER_B,
        POWER_DOMAIN_TRANSCODER_C,
        POWER_DOMAIN_TRANSCODER_EDP = POWER_DOMAIN_TRANSCODER_A + 0xF,
+       POWER_DOMAIN_VGA,
 };
 
 #define POWER_DOMAIN_PIPE(pipe) ((pipe) + POWER_DOMAIN_PIPE_A)
drivers/gpu/drm/i915/intel_pm.c +3 -1
index 1aa604c..f08fe52 100644
@@ -5271,6 +5271,7 @@ bool intel_display_power_enabled(struct drm_device *dev,
        case POWER_DOMAIN_PIPE_A:
        case POWER_DOMAIN_TRANSCODER_EDP:
                return true;
+       case POWER_DOMAIN_VGA:
        case POWER_DOMAIN_PIPE_B:
        case POWER_DOMAIN_PIPE_C:
        case POWER_DOMAIN_PIPE_A_PANEL_FITTER:
@@ -5359,6 +5360,7 @@ void intel_display_power_get(struct drm_device *dev,
        case POWER_DOMAIN_PIPE_A:
        case POWER_DOMAIN_TRANSCODER_EDP:
                return;
+       case POWER_DOMAIN_VGA:
        case POWER_DOMAIN_PIPE_B:
        case POWER_DOMAIN_PIPE_C:
        case POWER_DOMAIN_PIPE_A_PANEL_FITTER:
@@ -5389,6 +5391,7 @@ void intel_display_power_put(struct drm_device *dev,
        case POWER_DOMAIN_PIPE_A:
        case POWER_DOMAIN_TRANSCODER_EDP:
                return;
+       case POWER_DOMAIN_VGA:
        case POWER_DOMAIN_PIPE_B:
        case POWER_DOMAIN_PIPE_C:
        case POWER_DOMAIN_PIPE_A_PANEL_FITTER:
--

1.8.1.5

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

Signature · 1 line
Paulo Zanoni
#10 lore raw

PATCH 4/5 drm/i915: Pull intel_init_power_well() out of intel_modeset_init_hw()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

The init and resume codepaths want to handel the power well in slightly different ways, so pull the power well init out from intel_modeset_init_hw() which gets called in both cases.

---
 drivers/gpu/drm/i915/i915_dma.c      | 2 ++
 drivers/gpu/drm/i915/i915_drv.c      | 2 ++
 drivers/gpu/drm/i915/intel_display.c | 2 --
 3 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +2 -0
index 9b265a4..e5c7b10 100644
@@ -1324,6 +1324,8 @@ static int i915_load_modeset_init(struct drm_device *dev)
 
 	INIT_WORK(&dev_priv->console_resume_work, intel_console_resume);
 
+	intel_init_power_well(dev);
+
 	intel_modeset_gem_init(dev);
 
 	/* Always safe in the mode setting case. */
drivers/gpu/drm/i915/i915_drv.c +2 -0
index ec690ca..cd5a66d 100644
@@ -596,6 +596,8 @@ static int __i915_drm_thaw(struct drm_device *dev)
 		/* We need working interrupts for modeset enabling ... */
 		drm_irq_install(dev);
 
+		intel_init_power_well(dev);
+
 		intel_modeset_init_hw(dev);
 
 		drm_modeset_lock_all(dev);
drivers/gpu/drm/i915/intel_display.c +0 -2
index d06e3b4..53f5a1f 100644
@@ -10343,8 +10343,6 @@ void i915_disable_vga_mem(struct drm_device *dev)
 
 void intel_modeset_init_hw(struct drm_device *dev)
 {
-	intel_init_power_well(dev);
-
 	intel_prepare_ddi(dev);
 
 	intel_init_clock_gating(dev);
Signature · 6 lines
1.8.1.5

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

Re: [PATCH 4/5] drm/i915: Pull intel_init_power_well() out of intel_modeset_init_hw()

2013/9/12 <[email protected]>:

Quoted 5 lines

From: Ville Syrjälä <[email protected]>

The init and resume codepaths want to handel the power well in slightly different ways, so pull the power well init out from intel_modeset_init_hw() which gets called in both cases.

Can you please explain more? Where's the slight difference?

(also, I'm not sure if this code will change due to my comment in patch 1/5)

Quoted 54 lines
---
 drivers/gpu/drm/i915/i915_dma.c      | 2 ++
 drivers/gpu/drm/i915/i915_drv.c      | 2 ++
 drivers/gpu/drm/i915/intel_display.c | 2 --
 3 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +2 -0
index 9b265a4..e5c7b10 100644
@@ -1324,6 +1324,8 @@ static int i915_load_modeset_init(struct drm_device *dev)
 
        INIT_WORK(&dev_priv->console_resume_work, intel_console_resume);
 
+       intel_init_power_well(dev);
+
        intel_modeset_gem_init(dev);
 
        /* Always safe in the mode setting case. */
drivers/gpu/drm/i915/i915_drv.c +2 -0
index ec690ca..cd5a66d 100644
@@ -596,6 +596,8 @@ static int __i915_drm_thaw(struct drm_device *dev)
                /* We need working interrupts for modeset enabling ... */
                drm_irq_install(dev);
 
+               intel_init_power_well(dev);
+
                intel_modeset_init_hw(dev);
 
                drm_modeset_lock_all(dev);
drivers/gpu/drm/i915/intel_display.c +0 -3
index d06e3b4..53f5a1f 100644
@@ -10343,8 +10343,6 @@ void i915_disable_vga_mem(struct drm_device *dev)
 
 void intel_modeset_init_hw(struct drm_device *dev)
 {
-       intel_init_power_well(dev);
-
        intel_prepare_ddi(dev);
 
        intel_init_clock_gating(dev);
--

1.8.1.5

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

Signature · 1 line
Paulo Zanoni
#12 lore raw

Re: [PATCH 4/5] drm/i915: Pull intel_init_power_well() out of intel_modeset_init_hw()

Quoted 8 lines · Paulo Zanoni

2013/9/12 <[email protected]>:

Quoted 5 lines

From: Ville Syrjälä <[email protected]>

The init and resume codepaths want to handel the power well in slightly different ways, so pull the power well init out from intel_modeset_init_hw() which gets called in both cases.

Can you please explain more? Where's the slight difference?

See patch 5. We want to keep the power well powered until we've finished the vgacon->fbcon handoff, so we need to grab an extra power well reference between intel_init_power_well() and first ->global_resources() which would otherwise disable the power well.

Quoted 62 lines

(also, I'm not sure if this code will change due to my comment in patch 1/5)

Quoted 54 lines
---
 drivers/gpu/drm/i915/i915_dma.c      | 2 ++
 drivers/gpu/drm/i915/i915_drv.c      | 2 ++
 drivers/gpu/drm/i915/intel_display.c | 2 --
 3 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +2 -0
index 9b265a4..e5c7b10 100644
@@ -1324,6 +1324,8 @@ static int i915_load_modeset_init(struct drm_device *dev)
 
        INIT_WORK(&dev_priv->console_resume_work, intel_console_resume);
 
+       intel_init_power_well(dev);
+
        intel_modeset_gem_init(dev);
 
        /* Always safe in the mode setting case. */
drivers/gpu/drm/i915/i915_drv.c +2 -0
index ec690ca..cd5a66d 100644
@@ -596,6 +596,8 @@ static int __i915_drm_thaw(struct drm_device *dev)
                /* We need working interrupts for modeset enabling ... */
                drm_irq_install(dev);
 
+               intel_init_power_well(dev);
+
                intel_modeset_init_hw(dev);
 
                drm_modeset_lock_all(dev);
drivers/gpu/drm/i915/intel_display.c +0 -3
index d06e3b4..53f5a1f 100644
@@ -10343,8 +10343,6 @@ void i915_disable_vga_mem(struct drm_device *dev)
 
 void intel_modeset_init_hw(struct drm_device *dev)
 {
-       intel_init_power_well(dev);
-
        intel_prepare_ddi(dev);
 
        intel_init_clock_gating(dev);
--

1.8.1.5

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

Signature · 1 line
Paulo Zanoni
Signature · 2 lines
Ville Syrjälä
Intel OTC
#13 lore raw

PATCH 5/5 drm/i915: Fix unclaimed register access due to delayed VGA memroy disable

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

VGA registers live inside the power well on HSW, so in order to write the VGA MSR register we need the power well to be on.

We really must write to the register to properly clear the VGA_MSR_MEM_EN enable bit, even if all VGA registers get zeroed when the power well is down. It seems that the implicit zeroing done by the power well is not enough to propagate the VGA_MSR_MEM_EN bit to whomever is actually responsible for the memory decode ranges.

If we leave VGA memory decode enabled, and then turn off the power well, all VGA memory reads will return zeroes. But if we first disable VGA memory deocde and then turn off the power well, VGA memory reads return all ones, indicating that the access wasn't claimed by anyone. For the vga arbiter to function correctly the IGD must not claim the VGA memory accesses.

Previously we were doing the VGA_MSR register access while the power well was excplicitly powered up during driver init. But ever since

commit 6e1b4fdad5157bb9e88777d525704aba24389bee
Author: Ville Syrjälä <[email protected]>
Date: Thu Sep 5 20:40:52 2013 +0300

    drm/i915: Delay disabling of VGA memory until vgacon->fbcon handoff is done

we delay the VGA memory disable until fbcon has initialized, and so there's a possibility that the power well got turned off during the fbcon modeset. Also vgacon_save_screen() will need the power well to be on to be able to read the VGA memory.

So immediately after enabling the power well during init grab a refence for VGA purposes, and after all the VGA handling is done, release it.

---
 drivers/gpu/drm/i915/i915_dma.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/i915/i915_dma.c +4 -0
index e5c7b10..23f965d 100644
@@ -1326,6 +1326,9 @@ static int i915_load_modeset_init(struct drm_device *dev)
 
 	intel_init_power_well(dev);
 
+	/* Keep VGA alive until i915_disable_vga_mem() */
+	intel_display_power_get(dev, POWER_DOMAIN_VGA);
+
 	intel_modeset_gem_init(dev);
 
 	/* Always safe in the mode setting case. */
@@ -1358,6 +1361,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
 	 * vgacon_save_screen() works during the handover.
 	 */
 	i915_disable_vga_mem(dev);
+	intel_display_power_put(dev, POWER_DOMAIN_VGA);
 
 	/* Only enable hotplug handling once the fbdev is fully set up. */
 	dev_priv->enable_hotplug_processing = true;
Signature · 6 lines
1.8.1.5

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

Re: [PATCH 5/5] drm/i915: Fix unclaimed register access due to delayed VGA memroy disable

2013/9/12 <[email protected]>:

Quoted 10 lines

From: Ville Syrjälä <[email protected]>

VGA registers live inside the power well on HSW, so in order to write the VGA MSR register we need the power well to be on.

We really must write to the register to properly clear the VGA_MSR_MEM_EN enable bit, even if all VGA registers get zeroed when the power well is down. It seems that the implicit zeroing done by the power well is not enough to propagate the VGA_MSR_MEM_EN bit to whomever is actually responsible for the memory decode ranges.

Due to the paragraph above, don't we also need to fix i915_redisable_vga() ? If not, please explain why on the commit message.

Don't we also need to do something about i915_enable_vga_mem()?

Quoted 35 lines

If we leave VGA memory decode enabled, and then turn off the power well, all VGA memory reads will return zeroes. But if we first disable VGA memory deocde and then turn off the power well, VGA memory reads return all ones, indicating that the access wasn't claimed by anyone. For the vga arbiter to function correctly the IGD must not claim the VGA memory accesses.

Previously we were doing the VGA_MSR register access while the power well was excplicitly powered up during driver init. But ever since

commit 6e1b4fdad5157bb9e88777d525704aba24389bee
Author: Ville Syrjälä <[email protected]>
Date: Thu Sep 5 20:40:52 2013 +0300

    drm/i915: Delay disabling of VGA memory until vgacon->fbcon handoff is done

we delay the VGA memory disable until fbcon has initialized, and so there's a possibility that the power well got turned off during the fbcon modeset. Also vgacon_save_screen() will need the power well to be on to be able to read the VGA memory.

So immediately after enabling the power well during init grab a refence for VGA purposes, and after all the VGA handling is done, release it.

---
 drivers/gpu/drm/i915/i915_dma.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/i915/i915_dma.c +0 -0
index e5c7b10..23f965d 100644

drivers/gpu/drm/i915/i915_dma.c static int i915_load_modeset_init(struct drm_device *dev) · line 1329

Quoted 4 lines
drivers/gpu/drm/i915/i915_dma.c +1 -0
@@ -1326,6 +1326,9 @@ static int i915_load_modeset_init(struct drm_device *dev)
 
        intel_init_power_well(dev);
 
+       /* Keep VGA alive until i915_disable_vga_mem() */

I'd write more here. Maybe copy the paragraph in the commit message. This seems like an important thing and people won't really get the idea if they don't git-blame.

Quoted 20 lines
drivers/gpu/drm/i915/i915_dma.c +3 -1
+       intel_display_power_get(dev, POWER_DOMAIN_VGA);
+
        intel_modeset_gem_init(dev);
 
        /* Always safe in the mode setting case. */
@@ -1358,6 +1361,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
         * vgacon_save_screen() works during the handover.
         */
        i915_disable_vga_mem(dev);
+       intel_display_power_put(dev, POWER_DOMAIN_VGA);
 
        /* Only enable hotplug handling once the fbdev is fully set up. */
        dev_priv->enable_hotplug_processing = true;
--

1.8.1.5

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

Signature · 1 line
Paulo Zanoni
#15 lore raw

Re: [PATCH 5/5] drm/i915: Fix unclaimed register access due to delayed VGA memroy disable

Quoted 12 lines · Paulo Zanoni

2013/9/12 <[email protected]>:

Quoted 10 lines

From: Ville Syrjälä <[email protected]>

VGA registers live inside the power well on HSW, so in order to write the VGA MSR register we need the power well to be on.

We really must write to the register to properly clear the VGA_MSR_MEM_EN enable bit, even if all VGA registers get zeroed when the power well is down. It seems that the implicit zeroing done by the power well is not enough to propagate the VGA_MSR_MEM_EN bit to whomever is actually responsible for the memory decode ranges.

Quoted 5 lines

Due to the paragraph above, don't we also need to fix i915_redisable_vga() ? If not, please explain why on the commit message.

Don't we also need to do something about i915_enable_vga_mem()?

Yeah probably we should. For i915_enable_vga_mem() we could just power the well back around the access if it's not already up.

The rediable_vga case is somewhat more problematic since we call it during lid events. We'd always need to power the well back up just to check if the BIOS was an idiot and re-enabled VGA. Maybe we can assume that on HSW the BIOS isn't that stupid. For resume I guess we may want to power it back up and do the redisable_vga thing. I'll take a closer look at it next week.

Quoted 72 lines
Quoted 37 lines

If we leave VGA memory decode enabled, and then turn off the power well, all VGA memory reads will return zeroes. But if we first disable VGA memory deocde and then turn off the power well, VGA memory reads return all ones, indicating that the access wasn't claimed by anyone. For the vga arbiter to function correctly the IGD must not claim the VGA memory accesses.

Previously we were doing the VGA_MSR register access while the power well was excplicitly powered up during driver init. But ever since

commit 6e1b4fdad5157bb9e88777d525704aba24389bee
Author: Ville Syrjälä <[email protected]>
Date: Thu Sep 5 20:40:52 2013 +0300

    drm/i915: Delay disabling of VGA memory until vgacon->fbcon handoff is done

we delay the VGA memory disable until fbcon has initialized, and so there's a possibility that the power well got turned off during the fbcon modeset. Also vgacon_save_screen() will need the power well to be on to be able to read the VGA memory.

So immediately after enabling the power well during init grab a refence for VGA purposes, and after all the VGA handling is done, release it.

---
 drivers/gpu/drm/i915/i915_dma.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/i915/i915_dma.c +0 -0
index e5c7b10..23f965d 100644

drivers/gpu/drm/i915/i915_dma.c static int i915_load_modeset_init(struct drm_device *dev) · line 1329

Quoted 4 lines
drivers/gpu/drm/i915/i915_dma.c +1 -0
@@ -1326,6 +1326,9 @@ static int i915_load_modeset_init(struct drm_device *dev)
 
        intel_init_power_well(dev);
 
+       /* Keep VGA alive until i915_disable_vga_mem() */

I'd write more here. Maybe copy the paragraph in the commit message. This seems like an important thing and people won't really get the idea if they don't git-blame.

Quoted 20 lines
drivers/gpu/drm/i915/i915_dma.c +3 -1
+       intel_display_power_get(dev, POWER_DOMAIN_VGA);
+
        intel_modeset_gem_init(dev);
 
        /* Always safe in the mode setting case. */
@@ -1358,6 +1361,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
         * vgacon_save_screen() works during the handover.
         */
        i915_disable_vga_mem(dev);
+       intel_display_power_put(dev, POWER_DOMAIN_VGA);
 
        /* Only enable hotplug handling once the fbdev is fully set up. */
        dev_priv->enable_hotplug_processing = true;
--

1.8.1.5

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

Signature · 1 line
Paulo Zanoni
Signature · 2 lines
Ville Syrjälä
Intel OTC