Skip to contentSkip to conversation

preparation for multiple power-wells

PATCH In review Imre Deak 4 participants 38 messages Oct 16, 2013 – Oct 29, 2013

Subsystems (2)
lore
Share & tools
lore

Imre Deak

author
#0 lore raw

cover preparation for multiple power-wells

This is a prepration for adding support for multiple power-wells needed by future HW platforms. I pushed the rest of the enabling patches to [1]. I'd like to post the generic parts of those once we agreed how to do the power-well abstraction.

Except a spinlock->mutex change these patches shouldn't cause any functional change. I tested it on VLV/HSW VGA by doing a manual DPMS on/off and checking that the power-well indeed toggles. Also on HSW I checked that the audio power well release/request still works by doing a rmmod/insmod snd_hda_intel.

[1] https://github.com/ideak/linux/commits/powerwells

Imre Deak (6):
drm/i915: make the intel_display_power_domain enum compact drm/i915: factor out is_always_on_domain
drm/i915: change power_well->lock to be mutex
drm/i915: factor out modeset_update_power_wells drm/i915: enable only the needed power domains during modeset drm/i915: use power get/put instead of set for power on after init

 drivers/gpu/drm/i915/i915_dma.c      |   2 +-
 drivers/gpu/drm/i915/i915_drv.c      |   2 +-
 drivers/gpu/drm/i915/i915_drv.h      |  23 ++++--
 drivers/gpu/drm/i915/intel_display.c |  69 ++++++++++++++++--
 drivers/gpu/drm/i915/intel_drv.h     |   2 +
 drivers/gpu/drm/i915/intel_pm.c      | 133 ++++++++++-------------------------
 6 files changed, 124 insertions(+), 107 deletions(-)
Signature · 1 line
1.8.4
author
#1 lore raw

PATCH 1/6 drm/i915: make the intel_display_power_domain enum compact

Upcoming patches will add tracking for a set of power domains via a bitmask; to make things simple there remove the current gap in the enum values.

---
 drivers/gpu/drm/i915/i915_drv.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +4 -2
index 2ea66f2..9b04d05 100644
@@ -98,14 +98,16 @@ enum intel_display_power_domain {
 	POWER_DOMAIN_TRANSCODER_A,
 	POWER_DOMAIN_TRANSCODER_B,
 	POWER_DOMAIN_TRANSCODER_C,
-	POWER_DOMAIN_TRANSCODER_EDP = POWER_DOMAIN_TRANSCODER_A + 0xF,
+	POWER_DOMAIN_TRANSCODER_EDP,
 	POWER_DOMAIN_VGA,
 };
 
 #define POWER_DOMAIN_PIPE(pipe) ((pipe) + POWER_DOMAIN_PIPE_A)
 #define POWER_DOMAIN_PIPE_PANEL_FITTER(pipe) \
 		((pipe) + POWER_DOMAIN_PIPE_A_PANEL_FITTER)
-#define POWER_DOMAIN_TRANSCODER(tran) ((tran) + POWER_DOMAIN_TRANSCODER_A)
+#define POWER_DOMAIN_TRANSCODER(tran) \
+	((tran) == TRANSCODER_EDP ? POWER_DOMAIN_TRANSCODER_EDP : \
+	 (tran) + POWER_DOMAIN_TRANSCODER_A)
 
 enum hpd_pin {
 	HPD_NONE = 0,
Signature · 1 line
1.8.4
Reviewed-by on v1 1/6
#2 lore raw

Re: [PATCH 1/6] drm/i915: make the intel_display_power_domain enum compact

Quoted 22 lines · On Wed, 16 Oct 2013 17:25:48 +0300 Imre Deak <[email protected]> wrote:

Upcoming patches will add tracking for a set of power domains via a bitmask; to make things simple there remove the current gap in the enum values.

---
 drivers/gpu/drm/i915/i915_drv.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index 2ea66f2..9b04d05 100644
@@ -98,14 +98,16 @@ enum intel_display_power_domain {
 	POWER_DOMAIN_TRANSCODER_A,
 	POWER_DOMAIN_TRANSCODER_B,
 	POWER_DOMAIN_TRANSCODER_C,
-	POWER_DOMAIN_TRANSCODER_EDP = POWER_DOMAIN_TRANSCODER_A + 0xF,
+	POWER_DOMAIN_TRANSCODER_EDP,
 	POWER_DOMAIN_VGA,
 };
 

drivers/gpu/drm/i915/i915_drv.h enum intel_display_power_domain { · line 113

Quoted 10 lines
drivers/gpu/drm/i915/i915_drv.h +3 -1
 #define POWER_DOMAIN_PIPE(pipe) ((pipe) + POWER_DOMAIN_PIPE_A)
 #define POWER_DOMAIN_PIPE_PANEL_FITTER(pipe) \
 		((pipe) + POWER_DOMAIN_PIPE_A_PANEL_FITTER)
-#define POWER_DOMAIN_TRANSCODER(tran) ((tran) + POWER_DOMAIN_TRANSCODER_A)
+#define POWER_DOMAIN_TRANSCODER(tran) \
+	((tran) == TRANSCODER_EDP ? POWER_DOMAIN_TRANSCODER_EDP : \
+	 (tran) + POWER_DOMAIN_TRANSCODER_A)
 
 enum hpd_pin {
 	HPD_NONE = 0,
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
author
#3 lore raw

PATCH 2/6 drm/i915: factor out is_always_on_domain

In reply to Imre Deak

It is just cleaner this way and makes it easier to add support for other HW generations with always-on power wells powering a different set of domains.

---
 drivers/gpu/drm/i915/i915_drv.h |  8 ++++
 drivers/gpu/drm/i915/intel_pm.c | 84 +++++++++++++++--------------------------
 2 files changed, 38 insertions(+), 54 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +8 -0
index 9b04d05..ca05f3a 100644
@@ -100,8 +100,12 @@ enum intel_display_power_domain {
 	POWER_DOMAIN_TRANSCODER_C,
 	POWER_DOMAIN_TRANSCODER_EDP,
 	POWER_DOMAIN_VGA,
+
+	POWER_DOMAIN_NUM,
 };
 
+#define POWER_DOMAIN_MASK (BIT(POWER_DOMAIN_NUM) - 1)
+
 #define POWER_DOMAIN_PIPE(pipe) ((pipe) + POWER_DOMAIN_PIPE_A)
 #define POWER_DOMAIN_PIPE_PANEL_FITTER(pipe) \
 		((pipe) + POWER_DOMAIN_PIPE_A_PANEL_FITTER)
@@ -109,6 +113,10 @@ enum intel_display_power_domain {
 	((tran) == TRANSCODER_EDP ? POWER_DOMAIN_TRANSCODER_EDP : \
 	 (tran) + POWER_DOMAIN_TRANSCODER_A)
 
+#define HSW_ALWAYS_ON_POWER_DOMAINS (		\
+	BIT(POWER_DOMAIN_PIPE_A) |		\
+	BIT(POWER_DOMAIN_TRANSCODER_EDP))
+
 enum hpd_pin {
 	HPD_NONE = 0,
 	HPD_PORT_A = HPD_NONE, /* PORT_A is internal */
drivers/gpu/drm/i915/intel_pm.c +30 -54

112 lines not on this page · raw message

Signature · 1 line
1.8.4
Reviewed-by on v1 2/6
#4 lore raw

Re: [PATCH 2/6] drm/i915: factor out is_always_on_domain

Quoted 148 lines · On Wed, 16 Oct 2013 17:25:49 +0300 Imre Deak <[email protected]> wrote:

It is just cleaner this way and makes it easier to add support for other HW generations with always-on power wells powering a different set of domains.

---
 drivers/gpu/drm/i915/i915_drv.h |  8 ++++
 drivers/gpu/drm/i915/intel_pm.c | 84 +++++++++++++++--------------------------
 2 files changed, 38 insertions(+), 54 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +8 -0
index 9b04d05..ca05f3a 100644
@@ -100,8 +100,12 @@ enum intel_display_power_domain {
 	POWER_DOMAIN_TRANSCODER_C,
 	POWER_DOMAIN_TRANSCODER_EDP,
 	POWER_DOMAIN_VGA,
+
+	POWER_DOMAIN_NUM,
 };
 
+#define POWER_DOMAIN_MASK (BIT(POWER_DOMAIN_NUM) - 1)
+
 #define POWER_DOMAIN_PIPE(pipe) ((pipe) + POWER_DOMAIN_PIPE_A)
 #define POWER_DOMAIN_PIPE_PANEL_FITTER(pipe) \
 		((pipe) + POWER_DOMAIN_PIPE_A_PANEL_FITTER)
@@ -109,6 +113,10 @@ enum intel_display_power_domain {
 	((tran) == TRANSCODER_EDP ? POWER_DOMAIN_TRANSCODER_EDP : \
 	 (tran) + POWER_DOMAIN_TRANSCODER_A)
 
+#define HSW_ALWAYS_ON_POWER_DOMAINS (		\
+	BIT(POWER_DOMAIN_PIPE_A) |		\
+	BIT(POWER_DOMAIN_TRANSCODER_EDP))
+
 enum hpd_pin {
 	HPD_NONE = 0,
 	HPD_PORT_A = HPD_NONE, /* PORT_A is internal */
drivers/gpu/drm/i915/intel_pm.c +26 -51
index 3d3658c..57d08a2 100644
@@ -5367,6 +5367,23 @@ void intel_suspend_hw(struct drm_device *dev)
 		lpt_suspend_hw(dev);
 }
 
+static bool is_always_on_power_domain(struct drm_device *dev,
+				      enum intel_display_power_domain domain)
+{
+	unsigned long always_on_domains;
+
+	BUG_ON(BIT(domain) & ~POWER_DOMAIN_MASK);
+
+	if (IS_HASWELL(dev)) {
+		always_on_domains = HSW_ALWAYS_ON_POWER_DOMAINS;
+	} else {
+		WARN_ON(1);
+		return true;
+	}
+
+	return BIT(domain) & always_on_domains;
+}
+
 /**
  * We should only use the power well if we explicitly asked the hardware to
  * enable it, so check if it's enabled and also check if we've requested it to
@@ -5380,24 +5397,11 @@ bool intel_display_power_enabled(struct drm_device *dev,
 	if (!HAS_POWER_WELL(dev))
 		return true;
 
-	switch (domain) {
-	case POWER_DOMAIN_PIPE_A:
-	case POWER_DOMAIN_TRANSCODER_EDP:
+	if (is_always_on_power_domain(dev, domain))
 		return true;
-	case POWER_DOMAIN_VGA:
-	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:
-		return I915_READ(HSW_PWR_WELL_DRIVER) ==
+
+	return I915_READ(HSW_PWR_WELL_DRIVER) ==
 		     (HSW_PWR_WELL_ENABLE_REQUEST | HSW_PWR_WELL_STATE_ENABLED);
-	default:
-		BUG();
-	}
 }
 
 static void __intel_set_power_well(struct drm_device *dev, bool enable)
@@ -5469,26 +5473,12 @@ void intel_display_power_get(struct drm_device *dev,
 	if (!HAS_POWER_WELL(dev))
 		return;
 
-	switch (domain) {
-	case POWER_DOMAIN_PIPE_A:
-	case POWER_DOMAIN_TRANSCODER_EDP:
+	if (is_always_on_power_domain(dev, domain))
 		return;
-	case POWER_DOMAIN_VGA:
-	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);
-		__intel_power_well_get(power_well);
-		spin_unlock_irq(&power_well->lock);
-		return;
-	default:
-		BUG();
-	}
+
+	spin_lock_irq(&power_well->lock);
+	__intel_power_well_get(power_well);
+	spin_unlock_irq(&power_well->lock);
 }
 
 void intel_display_power_put(struct drm_device *dev,
@@ -5500,26 +5490,12 @@ void intel_display_power_put(struct drm_device *dev,
 	if (!HAS_POWER_WELL(dev))
 		return;
 
-	switch (domain) {
-	case POWER_DOMAIN_PIPE_A:
-	case POWER_DOMAIN_TRANSCODER_EDP:
+	if (is_always_on_power_domain(dev, domain))
 		return;
-	case POWER_DOMAIN_VGA:
-	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);
-		__intel_power_well_put(power_well);
-		spin_unlock_irq(&power_well->lock);
-		return;

drivers/gpu/drm/i915/intel_pm.c void intel_display_power_put(struct drm_device *dev, · line 5501

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +4 -3
-	default:
-		BUG();
-	}
+
+	spin_lock_irq(&power_well->lock);
+	__intel_power_well_put(power_well);
+	spin_unlock_irq(&power_well->lock);
 }
 
 static struct i915_power_well *hsw_pwr;
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
author
#5 lore raw

PATCH 3/6 drm/i915: change power_well->lock to be mutex

In reply to Imre Deak

There is no hard need for this to be a spin lock, as we don't take these locks in irq context from anywhere. An upcoming patch will add calls to punit read/write functions from within regions protected by this lock and those functions need a mutex in turn. As a solution for that convert the spin lock to be a mutex.

---
 drivers/gpu/drm/i915/i915_drv.h |  2 +-
 drivers/gpu/drm/i915/intel_pm.c | 26 +++++++++++++-------------
 2 files changed, 14 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index ca05f3a..e4354dd 100644
@@ -910,7 +910,7 @@ struct intel_ilk_power_mgmt {
 /* Power well structure for haswell */
 struct i915_power_well {
 	struct drm_device *device;
-	spinlock_t lock;
+	struct mutex lock;
 	/* power well enable/disable usage count */
 	int count;
 	int i915_request;
drivers/gpu/drm/i915/intel_pm.c +13 -13
index 57d08a2..f7363a8 100644
@@ -5476,9 +5476,9 @@ void intel_display_power_get(struct drm_device *dev,
 	if (is_always_on_power_domain(dev, domain))
 		return;
 
-	spin_lock_irq(&power_well->lock);
+	mutex_lock(&power_well->lock);
 	__intel_power_well_get(power_well);
-	spin_unlock_irq(&power_well->lock);
+	mutex_unlock(&power_well->lock);
 }
 
 void intel_display_power_put(struct drm_device *dev,
@@ -5493,9 +5493,9 @@ void intel_display_power_put(struct drm_device *dev,
 	if (is_always_on_power_domain(dev, domain))
 		return;
 
-	spin_lock_irq(&power_well->lock);
+	mutex_lock(&power_well->lock);
 	__intel_power_well_put(power_well);
-	spin_unlock_irq(&power_well->lock);
+	mutex_unlock(&power_well->lock);
 }
 
 static struct i915_power_well *hsw_pwr;
@@ -5506,9 +5506,9 @@ void i915_request_power_well(void)
 	if (WARN_ON(!hsw_pwr))
 		return;
 
-	spin_lock_irq(&hsw_pwr->lock);
+	mutex_lock(&hsw_pwr->lock);
 	__intel_power_well_get(hsw_pwr);
-	spin_unlock_irq(&hsw_pwr->lock);
+	mutex_unlock(&hsw_pwr->lock);
 }
 EXPORT_SYMBOL_GPL(i915_request_power_well);
 
@@ -5518,9 +5518,9 @@ void i915_release_power_well(void)
 	if (WARN_ON(!hsw_pwr))
 		return;
 
-	spin_lock_irq(&hsw_pwr->lock);
+	mutex_lock(&hsw_pwr->lock);
 	__intel_power_well_put(hsw_pwr);
-	spin_unlock_irq(&hsw_pwr->lock);
+	mutex_unlock(&hsw_pwr->lock);
 }
 EXPORT_SYMBOL_GPL(i915_release_power_well);
 
@@ -5531,7 +5531,7 @@ int i915_init_power_well(struct drm_device *dev)
 	hsw_pwr = &dev_priv->power_well;
 
 	hsw_pwr->device = dev;
-	spin_lock_init(&hsw_pwr->lock);
+	mutex_init(&hsw_pwr->lock);
 	hsw_pwr->count = 0;
 
 	return 0;
@@ -5553,7 +5553,7 @@ void intel_set_power_well(struct drm_device *dev, bool enable)
 	if (!i915_disable_power_well && !enable)
 		return;
 
-	spin_lock_irq(&power_well->lock);
+	mutex_lock(&power_well->lock);
 
 	/*
 	 * This function will only ever contribute one
@@ -5572,7 +5572,7 @@ void intel_set_power_well(struct drm_device *dev, bool enable)
 		__intel_power_well_put(power_well);
 
  out:
-	spin_unlock_irq(&power_well->lock);
+	mutex_unlock(&power_well->lock);
 }
 
 static void intel_resume_power_well(struct drm_device *dev)
@@ -5583,9 +5583,9 @@ static void intel_resume_power_well(struct drm_device *dev)
 	if (!HAS_POWER_WELL(dev))
 		return;
 
-	spin_lock_irq(&power_well->lock);
+	mutex_lock(&power_well->lock);
 	__intel_set_power_well(dev, power_well->count > 0);
-	spin_unlock_irq(&power_well->lock);
+	mutex_unlock(&power_well->lock);
 }
 
 /*
Signature · 1 line
1.8.4
#6 lore raw

Re: [PATCH 3/6] drm/i915: change power_well->lock to be mutex

2013/10/16 Imre Deak <[email protected]>:

Quoted 5 lines

There is no hard need for this to be a spin lock, as we don't take these locks in irq context from anywhere. An upcoming patch will add calls to punit read/write functions from within regions protected by this lock and those functions need a mutex in turn. As a solution for that convert the spin lock to be a mutex.

Not even from snd_hda_intel? Did we check this?

Quoted 118 lines
---
 drivers/gpu/drm/i915/i915_drv.h |  2 +-
 drivers/gpu/drm/i915/intel_pm.c | 26 +++++++++++++-------------
 2 files changed, 14 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index ca05f3a..e4354dd 100644
@@ -910,7 +910,7 @@ struct intel_ilk_power_mgmt {
 /* Power well structure for haswell */
 struct i915_power_well {
        struct drm_device *device;
-       spinlock_t lock;
+       struct mutex lock;
        /* power well enable/disable usage count */
        int count;
        int i915_request;
drivers/gpu/drm/i915/intel_pm.c +13 -14
index 57d08a2..f7363a8 100644
@@ -5476,9 +5476,9 @@ void intel_display_power_get(struct drm_device *dev,
        if (is_always_on_power_domain(dev, domain))
                return;
 
-       spin_lock_irq(&power_well->lock);
+       mutex_lock(&power_well->lock);
        __intel_power_well_get(power_well);
-       spin_unlock_irq(&power_well->lock);
+       mutex_unlock(&power_well->lock);
 }
 
 void intel_display_power_put(struct drm_device *dev,
@@ -5493,9 +5493,9 @@ void intel_display_power_put(struct drm_device *dev,
        if (is_always_on_power_domain(dev, domain))
                return;
 
-       spin_lock_irq(&power_well->lock);
+       mutex_lock(&power_well->lock);
        __intel_power_well_put(power_well);
-       spin_unlock_irq(&power_well->lock);
+       mutex_unlock(&power_well->lock);
 }
 
 static struct i915_power_well *hsw_pwr;
@@ -5506,9 +5506,9 @@ void i915_request_power_well(void)
        if (WARN_ON(!hsw_pwr))
                return;
 
-       spin_lock_irq(&hsw_pwr->lock);
+       mutex_lock(&hsw_pwr->lock);
        __intel_power_well_get(hsw_pwr);
-       spin_unlock_irq(&hsw_pwr->lock);
+       mutex_unlock(&hsw_pwr->lock);
 }
 EXPORT_SYMBOL_GPL(i915_request_power_well);
 
@@ -5518,9 +5518,9 @@ void i915_release_power_well(void)
        if (WARN_ON(!hsw_pwr))
                return;
 
-       spin_lock_irq(&hsw_pwr->lock);
+       mutex_lock(&hsw_pwr->lock);
        __intel_power_well_put(hsw_pwr);
-       spin_unlock_irq(&hsw_pwr->lock);
+       mutex_unlock(&hsw_pwr->lock);
 }
 EXPORT_SYMBOL_GPL(i915_release_power_well);
 
@@ -5531,7 +5531,7 @@ int i915_init_power_well(struct drm_device *dev)
        hsw_pwr = &dev_priv->power_well;
 
        hsw_pwr->device = dev;
-       spin_lock_init(&hsw_pwr->lock);
+       mutex_init(&hsw_pwr->lock);
        hsw_pwr->count = 0;
 
        return 0;
@@ -5553,7 +5553,7 @@ void intel_set_power_well(struct drm_device *dev, bool enable)
        if (!i915_disable_power_well && !enable)
                return;
 
-       spin_lock_irq(&power_well->lock);
+       mutex_lock(&power_well->lock);
 
        /*
         * This function will only ever contribute one
@@ -5572,7 +5572,7 @@ void intel_set_power_well(struct drm_device *dev, bool enable)
                __intel_power_well_put(power_well);
 
  out:
-       spin_unlock_irq(&power_well->lock);
+       mutex_unlock(&power_well->lock);
 }
 
 static void intel_resume_power_well(struct drm_device *dev)
@@ -5583,9 +5583,9 @@ static void intel_resume_power_well(struct drm_device *dev)
        if (!HAS_POWER_WELL(dev))
                return;
 
-       spin_lock_irq(&power_well->lock);
+       mutex_lock(&power_well->lock);
        __intel_set_power_well(dev, power_well->count > 0);
-       spin_unlock_irq(&power_well->lock);
+       mutex_unlock(&power_well->lock);
 }
 
 /*
--

1.8.4

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

Signature · 1 line
Paulo Zanoni
author
#7 lore raw

Re: [PATCH 3/6] drm/i915: change power_well->lock to be mutex

Quoted 8 lines · Paulo Zanoni

2013/10/16 Imre Deak <[email protected]>:

Quoted 5 lines

There is no hard need for this to be a spin lock, as we don't take these locks in irq context from anywhere. An upcoming patch will add calls to punit read/write functions from within regions protected by this lock and those functions need a mutex in turn. As a solution for that convert the spin lock to be a mutex.

Not even from snd_hda_intel? Did we check this?

Yea, at least I tried to check this at all call sites and haven't found any place where they request the power well in atomic context. In any case I think it's a design problem if they do ..

--Imre

Quoted 111 lines
Quoted 111 lines
---
 drivers/gpu/drm/i915/i915_drv.h |  2 +-
 drivers/gpu/drm/i915/intel_pm.c | 26 +++++++++++++-------------
 2 files changed, 14 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index ca05f3a..e4354dd 100644
@@ -910,7 +910,7 @@ struct intel_ilk_power_mgmt {
 /* Power well structure for haswell */
 struct i915_power_well {
        struct drm_device *device;
-       spinlock_t lock;
+       struct mutex lock;
        /* power well enable/disable usage count */
        int count;
        int i915_request;
drivers/gpu/drm/i915/intel_pm.c +13 -13
index 57d08a2..f7363a8 100644
@@ -5476,9 +5476,9 @@ void intel_display_power_get(struct drm_device *dev,
        if (is_always_on_power_domain(dev, domain))
                return;
 
-       spin_lock_irq(&power_well->lock);
+       mutex_lock(&power_well->lock);
        __intel_power_well_get(power_well);
-       spin_unlock_irq(&power_well->lock);
+       mutex_unlock(&power_well->lock);
 }
 
 void intel_display_power_put(struct drm_device *dev,
@@ -5493,9 +5493,9 @@ void intel_display_power_put(struct drm_device *dev,
        if (is_always_on_power_domain(dev, domain))
                return;
 
-       spin_lock_irq(&power_well->lock);
+       mutex_lock(&power_well->lock);
        __intel_power_well_put(power_well);
-       spin_unlock_irq(&power_well->lock);
+       mutex_unlock(&power_well->lock);
 }
 
 static struct i915_power_well *hsw_pwr;
@@ -5506,9 +5506,9 @@ void i915_request_power_well(void)
        if (WARN_ON(!hsw_pwr))
                return;
 
-       spin_lock_irq(&hsw_pwr->lock);
+       mutex_lock(&hsw_pwr->lock);
        __intel_power_well_get(hsw_pwr);
-       spin_unlock_irq(&hsw_pwr->lock);
+       mutex_unlock(&hsw_pwr->lock);
 }
 EXPORT_SYMBOL_GPL(i915_request_power_well);
 
@@ -5518,9 +5518,9 @@ void i915_release_power_well(void)
        if (WARN_ON(!hsw_pwr))
                return;
 
-       spin_lock_irq(&hsw_pwr->lock);
+       mutex_lock(&hsw_pwr->lock);
        __intel_power_well_put(hsw_pwr);
-       spin_unlock_irq(&hsw_pwr->lock);
+       mutex_unlock(&hsw_pwr->lock);
 }
 EXPORT_SYMBOL_GPL(i915_release_power_well);
 
@@ -5531,7 +5531,7 @@ int i915_init_power_well(struct drm_device *dev)
        hsw_pwr = &dev_priv->power_well;
 
        hsw_pwr->device = dev;
-       spin_lock_init(&hsw_pwr->lock);
+       mutex_init(&hsw_pwr->lock);
        hsw_pwr->count = 0;
 
        return 0;
@@ -5553,7 +5553,7 @@ void intel_set_power_well(struct drm_device *dev, bool enable)
        if (!i915_disable_power_well && !enable)
                return;
 
-       spin_lock_irq(&power_well->lock);
+       mutex_lock(&power_well->lock);
 
        /*
         * This function will only ever contribute one
@@ -5572,7 +5572,7 @@ void intel_set_power_well(struct drm_device *dev, bool enable)
                __intel_power_well_put(power_well);
 
  out:
-       spin_unlock_irq(&power_well->lock);
+       mutex_unlock(&power_well->lock);
 }
 
 static void intel_resume_power_well(struct drm_device *dev)
@@ -5583,9 +5583,9 @@ static void intel_resume_power_well(struct drm_device *dev)
        if (!HAS_POWER_WELL(dev))
                return;
 
-       spin_lock_irq(&power_well->lock);
+       mutex_lock(&power_well->lock);
        __intel_set_power_well(dev, power_well->count > 0);
-       spin_unlock_irq(&power_well->lock);
+       mutex_unlock(&power_well->lock);
 }
 
Quoted 11 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_pm.c +0 -1
 /*
--

1.8.4

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

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

Reviewed-by on v1 3/6
#8 lore raw

Re: [PATCH 3/6] drm/i915: change power_well->lock to be mutex

In reply to Imre Deak
Quoted 106 lines · On Wed, 16 Oct 2013 17:25:50 +0300 Imre Deak <[email protected]> wrote:

There is no hard need for this to be a spin lock, as we don't take these locks in irq context from anywhere. An upcoming patch will add calls to punit read/write functions from within regions protected by this lock and those functions need a mutex in turn. As a solution for that convert the spin lock to be a mutex.

---
 drivers/gpu/drm/i915/i915_drv.h |  2 +-
 drivers/gpu/drm/i915/intel_pm.c | 26 +++++++++++++-------------
 2 files changed, 14 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index ca05f3a..e4354dd 100644
@@ -910,7 +910,7 @@ struct intel_ilk_power_mgmt {
 /* Power well structure for haswell */
 struct i915_power_well {
 	struct drm_device *device;
-	spinlock_t lock;
+	struct mutex lock;
 	/* power well enable/disable usage count */
 	int count;
 	int i915_request;
drivers/gpu/drm/i915/intel_pm.c +11 -11
index 57d08a2..f7363a8 100644
@@ -5476,9 +5476,9 @@ void intel_display_power_get(struct drm_device *dev,
 	if (is_always_on_power_domain(dev, domain))
 		return;
 
-	spin_lock_irq(&power_well->lock);
+	mutex_lock(&power_well->lock);
 	__intel_power_well_get(power_well);
-	spin_unlock_irq(&power_well->lock);
+	mutex_unlock(&power_well->lock);
 }
 
 void intel_display_power_put(struct drm_device *dev,
@@ -5493,9 +5493,9 @@ void intel_display_power_put(struct drm_device *dev,
 	if (is_always_on_power_domain(dev, domain))
 		return;
 
-	spin_lock_irq(&power_well->lock);
+	mutex_lock(&power_well->lock);
 	__intel_power_well_put(power_well);
-	spin_unlock_irq(&power_well->lock);
+	mutex_unlock(&power_well->lock);
 }
 
 static struct i915_power_well *hsw_pwr;
@@ -5506,9 +5506,9 @@ void i915_request_power_well(void)
 	if (WARN_ON(!hsw_pwr))
 		return;
 
-	spin_lock_irq(&hsw_pwr->lock);
+	mutex_lock(&hsw_pwr->lock);
 	__intel_power_well_get(hsw_pwr);
-	spin_unlock_irq(&hsw_pwr->lock);
+	mutex_unlock(&hsw_pwr->lock);
 }
 EXPORT_SYMBOL_GPL(i915_request_power_well);
 
@@ -5518,9 +5518,9 @@ void i915_release_power_well(void)
 	if (WARN_ON(!hsw_pwr))
 		return;
 
-	spin_lock_irq(&hsw_pwr->lock);
+	mutex_lock(&hsw_pwr->lock);
 	__intel_power_well_put(hsw_pwr);
-	spin_unlock_irq(&hsw_pwr->lock);
+	mutex_unlock(&hsw_pwr->lock);
 }
 EXPORT_SYMBOL_GPL(i915_release_power_well);
 
@@ -5531,7 +5531,7 @@ int i915_init_power_well(struct drm_device *dev)
 	hsw_pwr = &dev_priv->power_well;
 
 	hsw_pwr->device = dev;
-	spin_lock_init(&hsw_pwr->lock);
+	mutex_init(&hsw_pwr->lock);
 	hsw_pwr->count = 0;
 
 	return 0;
@@ -5553,7 +5553,7 @@ void intel_set_power_well(struct drm_device *dev, bool enable)
 	if (!i915_disable_power_well && !enable)
 		return;
 
-	spin_lock_irq(&power_well->lock);
+	mutex_lock(&power_well->lock);
 
 	/*
 	 * This function will only ever contribute one
@@ -5572,7 +5572,7 @@ void intel_set_power_well(struct drm_device *dev, bool enable)
 		__intel_power_well_put(power_well);
 
  out:
-	spin_unlock_irq(&power_well->lock);
+	mutex_unlock(&power_well->lock);
 }
 
 static void intel_resume_power_well(struct drm_device *dev)
@@ -5583,9 +5583,9 @@ static void intel_resume_power_well(struct drm_device *dev)
 	if (!HAS_POWER_WELL(dev))

drivers/gpu/drm/i915/intel_pm.c static void intel_resume_power_well(struct drm_device *dev) · line 5591

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +2 -2
 		return;
 
-	spin_lock_irq(&power_well->lock);
+	mutex_lock(&power_well->lock);
 	__intel_set_power_well(dev, power_well->count > 0);
-	spin_unlock_irq(&power_well->lock);
+	mutex_unlock(&power_well->lock);
 }
 
 /*

Are there ordering requirements we should document? E.g. always take this after the mode config lock or something?

Otherwise:

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#9 lore raw

Re: [PATCH 3/6] drm/i915: change power_well->lock to be mutex

Quoted 2 lines · Jesse Barnes

Are there ordering requirements we should document? E.g. always take this after the mode config lock or something?

The mode_config lock is pretty much the outermost thing, and for getting it right we have lockdpe. As long as we ensure that we have full coverage with our tests and as long as QA doesn't fumble running the debug kernel builds we should be fine. So imo no need to document the locking. -Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
author
#10 lore raw

PATCH 4/6 drm/i915: factor out modeset_update_power_wells

In reply to Imre Deak

We'll need the same functionality for other HW generations. The support for these will be added by upcoming patches.

---
 drivers/gpu/drm/i915/intel_display.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_display.c +5 -1
index b334c50..8e734f2 100644
@@ -6561,7 +6561,7 @@ static void hsw_package_c8_gpu_busy(struct drm_i915_private *dev_priv)
 	}
 }
 
-static void haswell_modeset_global_resources(struct drm_device *dev)
+static void modeset_update_power_wells(struct drm_device *dev)
 {
 	bool enable = false;
 	struct intel_crtc *crtc;
@@ -6576,7 +6576,11 @@ static void haswell_modeset_global_resources(struct drm_device *dev)
 	}
 
 	intel_set_power_well(dev, enable);
+}
 
+static void haswell_modeset_global_resources(struct drm_device *dev)
+{
+	modeset_update_power_wells(dev);
 	hsw_update_package_c8(dev);
 }
 
Signature · 1 line
1.8.4
Reviewed-by on v1 4/6
#11 lore raw

Re: [PATCH 4/6] drm/i915: factor out modeset_update_power_wells

Quoted 23 lines · On Wed, 16 Oct 2013 17:25:51 +0300 Imre Deak <[email protected]> wrote:

We'll need the same functionality for other HW generations. The support for these will be added by upcoming patches.

---
 drivers/gpu/drm/i915/intel_display.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_display.c +1 -1
index b334c50..8e734f2 100644
@@ -6561,7 +6561,7 @@ static void hsw_package_c8_gpu_busy(struct drm_i915_private *dev_priv)
 	}
 }
 
-static void haswell_modeset_global_resources(struct drm_device *dev)
+static void modeset_update_power_wells(struct drm_device *dev)
 {
 	bool enable = false;
 	struct intel_crtc *crtc;
@@ -6576,7 +6576,11 @@ static void haswell_modeset_global_resources(struct drm_device *dev)
 	}

drivers/gpu/drm/i915/intel_display.c static void haswell_modeset_global_resources(struct drm_device *dev) · line 6586

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +4 -0
 
 	intel_set_power_well(dev, enable);
+}
 
+static void haswell_modeset_global_resources(struct drm_device *dev)
+{
+	modeset_update_power_wells(dev);
 	hsw_update_package_c8(dev);
 }
 
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
author
#12 lore raw

PATCH 5/6 drm/i915: enable only the needed power domains during modeset

In reply to Imre Deak

So far the modeset code enabled all power domains if it needed any. It wasn't a problem since HW generations so far only had one always-on power well and one dynamic power well that can be enabled/disabled. For domains powered by always-on power wells (panel fitter on pipe A and the eDP transcoder) we didn't do anything, for all other domains we just enabled the single dynamic power well.

Future HW generations will change this, as they add multiple dynamic power wells. Support for these will be added later, this patch prepares for those by making sure we only enable the required domains.

Note that after this change on HSW we'll enable all power domains even if it was the domain for the panel fitter on pipe A or the eDP transcoder. This isn't a problem since the power domain framework already checks if the domain is on an always-on power well and doesn't do anything in this case.

---
 drivers/gpu/drm/i915/intel_display.c | 46 ++++++++++++++++++++++++++++++++----
 drivers/gpu/drm/i915/intel_drv.h     |  1 +
 2 files changed, 42 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_display.c +41 -5
index 8e734f2..e2a4f3b 100644
@@ -6561,21 +6561,57 @@ static void hsw_package_c8_gpu_busy(struct drm_i915_private *dev_priv)
 	}
 }
 
+#define for_each_power_domain(domain, mask)				\
+	for ((domain) = 0; (domain) < POWER_DOMAIN_NUM; (domain)++)	\
+		if ((1 << (domain)) & (mask))
+
+static unsigned long get_pipe_power_domains(struct drm_device *dev,
+					    enum pipe pipe, bool pfit_enabled)
+{
+	unsigned long mask;
+	enum transcoder transcoder;
+
+	transcoder = intel_pipe_to_cpu_transcoder(dev->dev_private, pipe);
+
+	mask = BIT(POWER_DOMAIN_PIPE(pipe));
+	mask |= BIT(POWER_DOMAIN_TRANSCODER(transcoder));
+	if (pfit_enabled)
+		mask |= BIT(POWER_DOMAIN_PIPE_PANEL_FITTER(pipe));
+
+	return mask;
+}
+
 static void modeset_update_power_wells(struct drm_device *dev)
 {
-	bool enable = false;
+	unsigned long pipe_domains[I915_MAX_PIPES] = { 0, };
 	struct intel_crtc *crtc;
 
+	/*
+	 * First get all needed power domains, then put all unneeded, to avoid
+	 * any unnecessary toggling of the power wells.
+	 */
 	list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
+		enum intel_display_power_domain domain;
+
 		if (!crtc->base.enabled)
 			continue;
 
-		if (crtc->pipe != PIPE_A || crtc->config.pch_pfit.enabled ||
-		    crtc->config.cpu_transcoder != TRANSCODER_EDP)
-			enable = true;
+		pipe_domains[crtc->pipe] = get_pipe_power_domains(dev,
+						crtc->pipe,
+						crtc->config.pch_pfit.enabled);
+
+		for_each_power_domain(domain, pipe_domains[crtc->pipe])
+			intel_display_power_get(dev, domain);
 	}
 
-	intel_set_power_well(dev, enable);
+	list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
+		enum intel_display_power_domain domain;
+
+		for_each_power_domain(domain, crtc->enabled_power_domains)
+			intel_display_power_put(dev, domain);
+
+		crtc->enabled_power_domains = pipe_domains[crtc->pipe];
+	}
 }
 
 static void haswell_modeset_global_resources(struct drm_device *dev)
drivers/gpu/drm/i915/intel_drv.h +1 -0
index 189257d..63a5bfd 100644
@@ -320,6 +320,7 @@ struct intel_crtc {
 	 * some outputs connected to this crtc.
 	 */
 	bool active;
+	unsigned long enabled_power_domains;
 	bool eld_vld;
 	bool primary_enabled; /* is the primary plane (partially) visible? */
 	bool lowfreq_avail;
Signature · 1 line
1.8.4
Reviewed-by on v1 5/6
#13 lore raw

Re: [PATCH 5/6] drm/i915: enable only the needed power domains during modeset

Quoted 95 lines · On Wed, 16 Oct 2013 17:25:52 +0300 Imre Deak <[email protected]> wrote:

So far the modeset code enabled all power domains if it needed any. It wasn't a problem since HW generations so far only had one always-on power well and one dynamic power well that can be enabled/disabled. For domains powered by always-on power wells (panel fitter on pipe A and the eDP transcoder) we didn't do anything, for all other domains we just enabled the single dynamic power well.

Future HW generations will change this, as they add multiple dynamic power wells. Support for these will be added later, this patch prepares for those by making sure we only enable the required domains.

Note that after this change on HSW we'll enable all power domains even if it was the domain for the panel fitter on pipe A or the eDP transcoder. This isn't a problem since the power domain framework already checks if the domain is on an always-on power well and doesn't do anything in this case.

---
 drivers/gpu/drm/i915/intel_display.c | 46 ++++++++++++++++++++++++++++++++----
 drivers/gpu/drm/i915/intel_drv.h     |  1 +
 2 files changed, 42 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_display.c +41 -5
index 8e734f2..e2a4f3b 100644
@@ -6561,21 +6561,57 @@ static void hsw_package_c8_gpu_busy(struct drm_i915_private *dev_priv)
 	}
 }
 
+#define for_each_power_domain(domain, mask)				\
+	for ((domain) = 0; (domain) < POWER_DOMAIN_NUM; (domain)++)	\
+		if ((1 << (domain)) & (mask))
+
+static unsigned long get_pipe_power_domains(struct drm_device *dev,
+					    enum pipe pipe, bool pfit_enabled)
+{
+	unsigned long mask;
+	enum transcoder transcoder;
+
+	transcoder = intel_pipe_to_cpu_transcoder(dev->dev_private, pipe);
+
+	mask = BIT(POWER_DOMAIN_PIPE(pipe));
+	mask |= BIT(POWER_DOMAIN_TRANSCODER(transcoder));
+	if (pfit_enabled)
+		mask |= BIT(POWER_DOMAIN_PIPE_PANEL_FITTER(pipe));
+
+	return mask;
+}
+
 static void modeset_update_power_wells(struct drm_device *dev)
 {
-	bool enable = false;
+	unsigned long pipe_domains[I915_MAX_PIPES] = { 0, };
 	struct intel_crtc *crtc;
 
+	/*
+	 * First get all needed power domains, then put all unneeded, to avoid
+	 * any unnecessary toggling of the power wells.
+	 */
 	list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
+		enum intel_display_power_domain domain;
+
 		if (!crtc->base.enabled)
 			continue;
 
-		if (crtc->pipe != PIPE_A || crtc->config.pch_pfit.enabled ||
-		    crtc->config.cpu_transcoder != TRANSCODER_EDP)
-			enable = true;
+		pipe_domains[crtc->pipe] = get_pipe_power_domains(dev,
+						crtc->pipe,
+						crtc->config.pch_pfit.enabled);
+
+		for_each_power_domain(domain, pipe_domains[crtc->pipe])
+			intel_display_power_get(dev, domain);
 	}
 
-	intel_set_power_well(dev, enable);
+	list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
+		enum intel_display_power_domain domain;
+
+		for_each_power_domain(domain, crtc->enabled_power_domains)
+			intel_display_power_put(dev, domain);
+
+		crtc->enabled_power_domains = pipe_domains[crtc->pipe];
+	}
 }
 
 static void haswell_modeset_global_resources(struct drm_device *dev)
drivers/gpu/drm/i915/intel_drv.h +0 -0
index 189257d..63a5bfd 100644

drivers/gpu/drm/i915/intel_drv.h struct intel_crtc { · line 326

Quoted 7 lines
drivers/gpu/drm/i915/intel_drv.h +1 -0
@@ -320,6 +320,7 @@ struct intel_crtc {
 	 * some outputs connected to this crtc.
 	 */
 	bool active;
+	unsigned long enabled_power_domains;
 	bool eld_vld;
 	bool primary_enabled; /* is the primary plane (partially) visible? */
 	bool lowfreq_avail;

Hope we can get rid of the set_power_well() function soon...

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#14 lore raw

Re: [PATCH 5/6] drm/i915: enable only the needed power domains during modeset

2013/10/18 Jesse Barnes <[email protected]>:

Quoted 14 lines
Quoted 11 lines · On Wed, 16 Oct 2013 17:25:52 +0300 Imre Deak <[email protected]> wrote:

So far the modeset code enabled all power domains if it needed any. It wasn't a problem since HW generations so far only had one always-on power well and one dynamic power well that can be enabled/disabled. For domains powered by always-on power wells (panel fitter on pipe A and the eDP transcoder) we didn't do anything, for all other domains we just enabled the single dynamic power well.

Future HW generations will change this, as they add multiple dynamic power wells. Support for these will be added later, this patch prepares for those by making sure we only enable the required domains.

Quoted 7 lines
Quoted 7 lines

Note that after this change on HSW we'll enable all power domains even if it was the domain for the panel fitter on pipe A or the eDP transcoder. This isn't a problem since the power domain framework already checks if the domain is on an always-on power well and doesn't do anything in this case.

I updated drm-intel-nightly and now when I boot Haswell with eDP-only, the power well is enabled, where it should be disabled. Reverting this patch fixes the problem for me.

Quoted 95 lines
Quoted 77 lines
---
 drivers/gpu/drm/i915/intel_display.c | 46 ++++++++++++++++++++++++++++++++----
 drivers/gpu/drm/i915/intel_drv.h     |  1 +
 2 files changed, 42 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_display.c +41 -5
index 8e734f2..e2a4f3b 100644
@@ -6561,21 +6561,57 @@ static void hsw_package_c8_gpu_busy(struct drm_i915_private *dev_priv)
      }
 }
 
+#define for_each_power_domain(domain, mask)                          \
+     for ((domain) = 0; (domain) < POWER_DOMAIN_NUM; (domain)++)     \
+             if ((1 << (domain)) & (mask))
+
+static unsigned long get_pipe_power_domains(struct drm_device *dev,
+                                         enum pipe pipe, bool pfit_enabled)
+{
+     unsigned long mask;
+     enum transcoder transcoder;
+
+     transcoder = intel_pipe_to_cpu_transcoder(dev->dev_private, pipe);
+
+     mask = BIT(POWER_DOMAIN_PIPE(pipe));
+     mask |= BIT(POWER_DOMAIN_TRANSCODER(transcoder));
+     if (pfit_enabled)
+             mask |= BIT(POWER_DOMAIN_PIPE_PANEL_FITTER(pipe));
+
+     return mask;
+}
+
 static void modeset_update_power_wells(struct drm_device *dev)
 {
-     bool enable = false;
+     unsigned long pipe_domains[I915_MAX_PIPES] = { 0, };
      struct intel_crtc *crtc;
 
+     /*
+      * First get all needed power domains, then put all unneeded, to avoid
+      * any unnecessary toggling of the power wells.
+      */
      list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
+             enum intel_display_power_domain domain;
+
              if (!crtc->base.enabled)
                      continue;
 
-             if (crtc->pipe != PIPE_A || crtc->config.pch_pfit.enabled ||
-                 crtc->config.cpu_transcoder != TRANSCODER_EDP)
-                     enable = true;
+             pipe_domains[crtc->pipe] = get_pipe_power_domains(dev,
+                                             crtc->pipe,
+                                             crtc->config.pch_pfit.enabled);
+
+             for_each_power_domain(domain, pipe_domains[crtc->pipe])
+                     intel_display_power_get(dev, domain);
      }
 
-     intel_set_power_well(dev, enable);
+     list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
+             enum intel_display_power_domain domain;
+
+             for_each_power_domain(domain, crtc->enabled_power_domains)
+                     intel_display_power_put(dev, domain);
+
+             crtc->enabled_power_domains = pipe_domains[crtc->pipe];
+     }
 }
 
 static void haswell_modeset_global_resources(struct drm_device *dev)
drivers/gpu/drm/i915/intel_drv.h +0 -0
index 189257d..63a5bfd 100644

drivers/gpu/drm/i915/intel_drv.h struct intel_crtc { · line 326

Quoted 7 lines
drivers/gpu/drm/i915/intel_drv.h +1 -0
@@ -320,6 +320,7 @@ struct intel_crtc {
       * some outputs connected to this crtc.
       */
      bool active;
+     unsigned long enabled_power_domains;
      bool eld_vld;
      bool primary_enabled; /* is the primary plane (partially) visible? */
      bool lowfreq_avail;

Hope we can get rid of the set_power_well() function soon...

--
Jesse Barnes, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 1 line
Paulo Zanoni
author
#15 lore raw

Re: [PATCH 5/6] drm/i915: enable only the needed power domains during modeset

Quoted 21 lines · Paulo Zanoni

2013/10/18 Jesse Barnes <[email protected]>:

Quoted 20 lines
Quoted 17 lines · On Wed, 16 Oct 2013 17:25:52 +0300 Imre Deak <[email protected]> wrote:

So far the modeset code enabled all power domains if it needed any. It wasn't a problem since HW generations so far only had one always-on power well and one dynamic power well that can be enabled/disabled. For domains powered by always-on power wells (panel fitter on pipe A and the eDP transcoder) we didn't do anything, for all other domains we just enabled the single dynamic power well.

Future HW generations will change this, as they add multiple dynamic power wells. Support for these will be added later, this patch prepares for those by making sure we only enable the required domains.

Note that after this change on HSW we'll enable all power domains even if it was the domain for the panel fitter on pipe A or the eDP transcoder. This isn't a problem since the power domain framework already checks if the domain is on an always-on power well and doesn't do anything in this case.

Quoted 5 lines
Quoted 1 line
Quoted 1 line

I updated drm-intel-nightly and now when I boot Haswell with eDP-only, the power well is enabled, where it should be disabled. Reverting this patch fixes the problem for me.

As discussed on IRC, this broke b/c of a missing call to intel_display_set_init_power() in modeset_update_power_wells(). I added it only in patch 6/6, but that isn't applied yet since I had to rework it. I've posted a v2 for this patch already, it should fix the issue.

Thanks for catching this.

--Imre

Quoted 100 lines
Quoted 97 lines
Quoted 79 lines

---
 drivers/gpu/drm/i915/intel_display.c | 46 ++++++++++++++++++++++++++++++++----
 drivers/gpu/drm/i915/intel_drv.h     |  1 +
 2 files changed, 42 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_display.c +41 -5
index 8e734f2..e2a4f3b 100644
@@ -6561,21 +6561,57 @@ static void hsw_package_c8_gpu_busy(struct drm_i915_private *dev_priv)
      }
 }
 
+#define for_each_power_domain(domain, mask)                          \
+     for ((domain) = 0; (domain) < POWER_DOMAIN_NUM; (domain)++)     \
+             if ((1 << (domain)) & (mask))
+
+static unsigned long get_pipe_power_domains(struct drm_device *dev,
+                                         enum pipe pipe, bool pfit_enabled)
+{
+     unsigned long mask;
+     enum transcoder transcoder;
+
+     transcoder = intel_pipe_to_cpu_transcoder(dev->dev_private, pipe);
+
+     mask = BIT(POWER_DOMAIN_PIPE(pipe));
+     mask |= BIT(POWER_DOMAIN_TRANSCODER(transcoder));
+     if (pfit_enabled)
+             mask |= BIT(POWER_DOMAIN_PIPE_PANEL_FITTER(pipe));
+
+     return mask;
+}
+
 static void modeset_update_power_wells(struct drm_device *dev)
 {
-     bool enable = false;
+     unsigned long pipe_domains[I915_MAX_PIPES] = { 0, };
      struct intel_crtc *crtc;
 
+     /*
+      * First get all needed power domains, then put all unneeded, to avoid
+      * any unnecessary toggling of the power wells.
+      */
      list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
+             enum intel_display_power_domain domain;
+
              if (!crtc->base.enabled)
                      continue;
 
-             if (crtc->pipe != PIPE_A || crtc->config.pch_pfit.enabled ||
-                 crtc->config.cpu_transcoder != TRANSCODER_EDP)
-                     enable = true;
+             pipe_domains[crtc->pipe] = get_pipe_power_domains(dev,
+                                             crtc->pipe,
+                                             crtc->config.pch_pfit.enabled);
+
+             for_each_power_domain(domain, pipe_domains[crtc->pipe])
+                     intel_display_power_get(dev, domain);
      }
 
-     intel_set_power_well(dev, enable);
+     list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
+             enum intel_display_power_domain domain;
+
+             for_each_power_domain(domain, crtc->enabled_power_domains)
+                     intel_display_power_put(dev, domain);
+
+             crtc->enabled_power_domains = pipe_domains[crtc->pipe];
+     }
 }
 
 static void haswell_modeset_global_resources(struct drm_device *dev)
drivers/gpu/drm/i915/intel_drv.h +0 -0
index 189257d..63a5bfd 100644

drivers/gpu/drm/i915/intel_drv.h struct intel_crtc { · line 326

Quoted 7 lines
drivers/gpu/drm/i915/intel_drv.h +1 -0
@@ -320,6 +320,7 @@ struct intel_crtc {
       * some outputs connected to this crtc.
       */
      bool active;
+     unsigned long enabled_power_domains;
      bool eld_vld;
      bool primary_enabled; /* is the primary plane (partially) visible? */
      bool lowfreq_avail;

Hope we can get rid of the set_power_well() function soon...

--
Jesse Barnes, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

author
#16 lore raw

PATCH 6/6 drm/i915: use power get/put instead of set for power on after init

In reply to Imre Deak

Currently we make sure that all power domains are enabled during driver init and turn off unneded ones only after the first modeset. Similarly during suspend we enable all power domains, which will remain on through the following resume until the first modeset.

This logic is supported by intel_set_power_well() in the power domain framework. It would be nice to simplify the API, so that we only have get/put functions and make it more explicit on the higher level how this "power well on during init" logic works. This will make it also easier if in the future we want to shorten the time the power wells are on.

For this add a new device private flag tracking whether we have the power wells on because of init/suspend and use only intel_display_power_get()/put(). As nothing else uses intel_set_power_well() we can remove it.

---
 drivers/gpu/drm/i915/i915_dma.c      |  2 +-
 drivers/gpu/drm/i915/i915_drv.c      |  2 +-
 drivers/gpu/drm/i915/i915_drv.h      |  7 ++++++-
 drivers/gpu/drm/i915/intel_display.c | 17 +++++++++++++++++
 drivers/gpu/drm/i915/intel_drv.h     |  1 +
 drivers/gpu/drm/i915/intel_pm.c      | 35 +----------------------------------
 6 files changed, 27 insertions(+), 37 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +1 -1
index b8bc887..dd7f1f6 100644
@@ -1708,7 +1708,7 @@ int i915_driver_unload(struct drm_device *dev)
 		/* The i915.ko module is still not prepared to be loaded when
 		 * the power well is not enabled, so just enable it in case
 		 * we're going to unload/reload. */
-		intel_set_power_well(dev, true);
+		intel_display_set_init_power(dev, true);
 		i915_remove_power_well(dev);
 	}
 
drivers/gpu/drm/i915/i915_drv.c +1 -1
index 59649c0..7299a96 100644
@@ -469,7 +469,7 @@ static int i915_drm_freeze(struct drm_device *dev)
 	/* We do a lot of poking in a lot of registers, make sure they work
 	 * properly. */
 	hsw_disable_package_c8(dev_priv);
-	intel_set_power_well(dev, true);
+	intel_display_set_init_power(dev, true);
 
 	drm_kms_helper_poll_disable(dev);
 
drivers/gpu/drm/i915/i915_drv.h +6 -1
index e4354dd..0557c6b 100644
@@ -100,6 +100,7 @@ enum intel_display_power_domain {
 	POWER_DOMAIN_TRANSCODER_C,
 	POWER_DOMAIN_TRANSCODER_EDP,
 	POWER_DOMAIN_VGA,
+	POWER_DOMAIN_INIT,
 
 	POWER_DOMAIN_NUM,
 };
@@ -913,7 +914,6 @@ struct i915_power_well {
 	struct mutex lock;
 	/* power well enable/disable usage count */
 	int count;
-	int i915_request;
 };
 
 struct i915_dri1_state {
@@ -1369,6 +1369,11 @@ typedef struct drm_i915_private {
 	 * mchdev_lock in intel_pm.c */
 	struct intel_ilk_power_mgmt ips;
 
+	/*
+	 * Power wells needed for initialization at driver init and suspend
+	 * time are on. They are kept on until after the first modeset.
+	 */
+	bool init_power_on;
 	/* Haswell power well */
 	struct i915_power_well power_well;
 
drivers/gpu/drm/i915/intel_display.c +17 -0
index e2a4f3b..e30db91 100644
@@ -6581,6 +6581,21 @@ static unsigned long get_pipe_power_domains(struct drm_device *dev,
 	return mask;
 }
 
+void intel_display_set_init_power(struct drm_device *dev, bool enable)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	if (dev_priv->init_power_on == enable)
+		return;
+
+	if (enable)
+		intel_display_power_get(dev, POWER_DOMAIN_INIT);
+	else
+		intel_display_power_put(dev, POWER_DOMAIN_INIT);
+
+	dev_priv->init_power_on = enable;
+}
+
 static void modeset_update_power_wells(struct drm_device *dev)
 {
 	unsigned long pipe_domains[I915_MAX_PIPES] = { 0, };
@@ -6612,6 +6627,8 @@ static void modeset_update_power_wells(struct drm_device *dev)
 
 		crtc->enabled_power_domains = pipe_domains[crtc->pipe];
 	}
+
+	intel_display_set_init_power(dev, false);
 }
 
 static void haswell_modeset_global_resources(struct drm_device *dev)
drivers/gpu/drm/i915/intel_drv.h +1 -0
index 63a5bfd..e6306f5 100644
@@ -680,6 +680,7 @@ bool intel_crtc_active(struct drm_crtc *crtc);
 void i915_disable_vga_mem(struct drm_device *dev);
 void hsw_enable_ips(struct intel_crtc *crtc);
 void hsw_disable_ips(struct intel_crtc *crtc);
+void intel_display_set_init_power(struct drm_device *dev, bool enable);
 
 
 /* intel_dp.c */
drivers/gpu/drm/i915/intel_pm.c +1 -34
index f7363a8..9291a2e 100644
@@ -5542,39 +5542,6 @@ void i915_remove_power_well(struct drm_device *dev)
 	hsw_pwr = NULL;
 }
 
-void intel_set_power_well(struct drm_device *dev, bool enable)
-{
-	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;
-
-	if (!i915_disable_power_well && !enable)
-		return;
-
-	mutex_lock(&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;
-
-	if (enable)
-		__intel_power_well_get(power_well);
-	else
-		__intel_power_well_put(power_well);
-
- out:
-	mutex_unlock(&power_well->lock);
-}
-
 static void intel_resume_power_well(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -5602,7 +5569,7 @@ void intel_init_power_well(struct drm_device *dev)
 		return;
 
 	/* For now, we need the power well to be always enabled. */
-	intel_set_power_well(dev, true);
+	intel_display_set_init_power(dev, true);
 	intel_resume_power_well(dev);
 
 	/* We're taking over the BIOS, so clear any requests made by it since
Signature · 1 line
1.8.4
Reviewed-by on v1 6/6
#17 lore raw

Re: [PATCH 6/6] drm/i915: use power get/put instead of set for power on after init

Quoted 176 lines · On Wed, 16 Oct 2013 17:25:53 +0300 Imre Deak <[email protected]> wrote:

Currently we make sure that all power domains are enabled during driver init and turn off unneded ones only after the first modeset. Similarly during suspend we enable all power domains, which will remain on through the following resume until the first modeset.

This logic is supported by intel_set_power_well() in the power domain framework. It would be nice to simplify the API, so that we only have get/put functions and make it more explicit on the higher level how this "power well on during init" logic works. This will make it also easier if in the future we want to shorten the time the power wells are on.

For this add a new device private flag tracking whether we have the power wells on because of init/suspend and use only intel_display_power_get()/put(). As nothing else uses intel_set_power_well() we can remove it.

---
 drivers/gpu/drm/i915/i915_dma.c      |  2 +-
 drivers/gpu/drm/i915/i915_drv.c      |  2 +-
 drivers/gpu/drm/i915/i915_drv.h      |  7 ++++++-
 drivers/gpu/drm/i915/intel_display.c | 17 +++++++++++++++++
 drivers/gpu/drm/i915/intel_drv.h     |  1 +
 drivers/gpu/drm/i915/intel_pm.c      | 35 +----------------------------------
 6 files changed, 27 insertions(+), 37 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +1 -1
index b8bc887..dd7f1f6 100644
@@ -1708,7 +1708,7 @@ int i915_driver_unload(struct drm_device *dev)
 		/* The i915.ko module is still not prepared to be loaded when
 		 * the power well is not enabled, so just enable it in case
 		 * we're going to unload/reload. */
-		intel_set_power_well(dev, true);
+		intel_display_set_init_power(dev, true);
 		i915_remove_power_well(dev);
 	}
 
drivers/gpu/drm/i915/i915_drv.c +1 -1
index 59649c0..7299a96 100644
@@ -469,7 +469,7 @@ static int i915_drm_freeze(struct drm_device *dev)
 	/* We do a lot of poking in a lot of registers, make sure they work
 	 * properly. */
 	hsw_disable_package_c8(dev_priv);
-	intel_set_power_well(dev, true);
+	intel_display_set_init_power(dev, true);
 
 	drm_kms_helper_poll_disable(dev);
 
drivers/gpu/drm/i915/i915_drv.h +6 -1
index e4354dd..0557c6b 100644
@@ -100,6 +100,7 @@ enum intel_display_power_domain {
 	POWER_DOMAIN_TRANSCODER_C,
 	POWER_DOMAIN_TRANSCODER_EDP,
 	POWER_DOMAIN_VGA,
+	POWER_DOMAIN_INIT,
 
 	POWER_DOMAIN_NUM,
 };
@@ -913,7 +914,6 @@ struct i915_power_well {
 	struct mutex lock;
 	/* power well enable/disable usage count */
 	int count;
-	int i915_request;
 };
 
 struct i915_dri1_state {
@@ -1369,6 +1369,11 @@ typedef struct drm_i915_private {
 	 * mchdev_lock in intel_pm.c */
 	struct intel_ilk_power_mgmt ips;
 
+	/*
+	 * Power wells needed for initialization at driver init and suspend
+	 * time are on. They are kept on until after the first modeset.
+	 */
+	bool init_power_on;
 	/* Haswell power well */
 	struct i915_power_well power_well;
 
drivers/gpu/drm/i915/intel_display.c +17 -0
index e2a4f3b..e30db91 100644
@@ -6581,6 +6581,21 @@ static unsigned long get_pipe_power_domains(struct drm_device *dev,
 	return mask;
 }
 
+void intel_display_set_init_power(struct drm_device *dev, bool enable)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	if (dev_priv->init_power_on == enable)
+		return;
+
+	if (enable)
+		intel_display_power_get(dev, POWER_DOMAIN_INIT);
+	else
+		intel_display_power_put(dev, POWER_DOMAIN_INIT);
+
+	dev_priv->init_power_on = enable;
+}
+
 static void modeset_update_power_wells(struct drm_device *dev)
 {
 	unsigned long pipe_domains[I915_MAX_PIPES] = { 0, };
@@ -6612,6 +6627,8 @@ static void modeset_update_power_wells(struct drm_device *dev)
 
 		crtc->enabled_power_domains = pipe_domains[crtc->pipe];
 	}
+
+	intel_display_set_init_power(dev, false);
 }
 
 static void haswell_modeset_global_resources(struct drm_device *dev)
drivers/gpu/drm/i915/intel_drv.h +1 -0
index 63a5bfd..e6306f5 100644
@@ -680,6 +680,7 @@ bool intel_crtc_active(struct drm_crtc *crtc);
 void i915_disable_vga_mem(struct drm_device *dev);
 void hsw_enable_ips(struct intel_crtc *crtc);
 void hsw_disable_ips(struct intel_crtc *crtc);
+void intel_display_set_init_power(struct drm_device *dev, bool enable);
 
 
 /* intel_dp.c */
drivers/gpu/drm/i915/intel_pm.c +0 -33
index f7363a8..9291a2e 100644
@@ -5542,39 +5542,6 @@ void i915_remove_power_well(struct drm_device *dev)
 	hsw_pwr = NULL;
 }
 
-void intel_set_power_well(struct drm_device *dev, bool enable)
-{
-	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;
-
-	if (!i915_disable_power_well && !enable)
-		return;
-
-	mutex_lock(&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;
-
-	if (enable)
-		__intel_power_well_get(power_well);
-	else
-		__intel_power_well_put(power_well);
-
- out:
-	mutex_unlock(&power_well->lock);
-}
-
 static void intel_resume_power_well(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;

drivers/gpu/drm/i915/intel_pm.c void intel_init_power_well(struct drm_device *dev) · line 5575

Quoted 8 lines
drivers/gpu/drm/i915/intel_pm.c +1 -1
@@ -5602,7 +5569,7 @@ void intel_init_power_well(struct drm_device *dev)
 		return;
 
 	/* For now, we need the power well to be always enabled. */
-	intel_set_power_well(dev, true);
+	intel_display_set_init_power(dev, true);
 	intel_resume_power_well(dev);
 
 	/* We're taking over the BIOS, so clear any requests made by it since

And there it goes, yay! :) Now we just have to get rid of the _INIT domain and actually shut things down before the first mode set if nothing is in use (maybe with a delayed shutdown to avoid toggling too fast).

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#18 lore raw

Re: [PATCH 6/6] drm/i915: use power get/put instead of set for power on after init

In reply to Imre Deak
Quoted 18 lines · Imre Deak

Currently we make sure that all power domains are enabled during driver init and turn off unneded ones only after the first modeset. Similarly during suspend we enable all power domains, which will remain on through the following resume until the first modeset.

This logic is supported by intel_set_power_well() in the power domain framework. It would be nice to simplify the API, so that we only have get/put functions and make it more explicit on the higher level how this "power well on during init" logic works. This will make it also easier if in the future we want to shorten the time the power wells are on.

For this add a new device private flag tracking whether we have the power wells on because of init/suspend and use only intel_display_power_get()/put(). As nothing else uses intel_set_power_well() we can remove it.

---

[snip]

Quoted 21 lines
drivers/gpu/drm/i915/i915_drv.h +1 -1
index e4354dd..0557c6b 100644
@@ -100,6 +100,7 @@ enum intel_display_power_domain {
 	POWER_DOMAIN_TRANSCODER_C,
 	POWER_DOMAIN_TRANSCODER_EDP,
 	POWER_DOMAIN_VGA,
+	POWER_DOMAIN_INIT,
 
 	POWER_DOMAIN_NUM,
 };
@@ -913,7 +914,6 @@ struct i915_power_well {
 	struct mutex lock;
 	/* power well enable/disable usage count */
 	int count;
-	int i915_request;
 };
 
 struct i915_dri1_state {

drivers/gpu/drm/i915/i915_drv.h typedef struct drm_i915_private { · line 1376

Quoted 8 lines
drivers/gpu/drm/i915/i915_drv.h +5 -0
@@ -1369,6 +1369,11 @@ typedef struct drm_i915_private {
 	 * mchdev_lock in intel_pm.c */
 	struct intel_ilk_power_mgmt ips;
 
+	/*
+	 * Power wells needed for initialization at driver init and suspend
+	 * time are on. They are kept on until after the first modeset.
+	 */
+	bool init_power_on;

Please move this into the nice power_well structure we have to avoid overtly polluting our i915_driver_private thing ... All patches up to this one merged, thanks.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
author
#19 lore raw

PATCH 1/2 drm/i915: prepare for multiple power wells

In reply to Imre Deak

In the future we'll need to support multiple power wells, so prepare for that here. Create a new power domains struct which contains all power domain/well specific fields. Since we'll have one lock protecting all power wells, move power_well->lock to the new struct too.

No functional change.

---
 drivers/gpu/drm/i915/i915_drv.h | 11 ++++++---
 drivers/gpu/drm/i915/intel_pm.c | 55 +++++++++++++++++++++++++----------------
 2 files changed, 42 insertions(+), 24 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +8 -3
index 80957ca..7315095 100644
@@ -911,12 +911,18 @@ struct intel_ilk_power_mgmt {
 /* Power well structure for haswell */
 struct i915_power_well {
 	struct drm_device *device;
-	struct mutex lock;
 	/* power well enable/disable usage count */
 	int count;
 	int i915_request;
 };
 
+#define I915_MAX_POWER_WELLS 1
+
+struct i915_power_domains {
+	struct mutex lock;
+	struct i915_power_well power_wells[I915_MAX_POWER_WELLS];
+};
+
 struct i915_dri1_state {
 	unsigned allow_batchbuffer : 1;
 	u32 __iomem *gfx_hws_cpu_addr;
@@ -1412,8 +1418,7 @@ typedef struct drm_i915_private {
 	 * mchdev_lock in intel_pm.c */
 	struct intel_ilk_power_mgmt ips;
 
-	/* Haswell power well */
-	struct i915_power_well power_well;
+	struct i915_power_domains power_domains;
 
 	struct i915_psr psr;
 
drivers/gpu/drm/i915/intel_pm.c +34 -21

130 lines not on this page · raw message

Signature · 1 line
1.8.4
author
#20 lore raw

PATCH v2 2/2 drm/i915: use power get/put instead of set for power on after init

Currently we make sure that all power domains are enabled during driver init and turn off unneded ones only after the first modeset. Similarly during suspend we enable all power domains, which will remain on through the following resume until the first modeset.

This logic is supported by intel_set_power_well() in the power domain framework. It would be nice to simplify the API, so that we only have get/put functions and make it more explicit on the higher level how this "power well on during init" logic works. This will make it also easier if in the future we want to shorten the time the power wells are on.

For this add a new device private flag tracking whether we have the power wells on because of init/suspend and use only intel_display_power_get()/put(). As nothing else uses intel_set_power_well() we can remove it.

v2:
- move the init_power_on flag to the power_domains struct (Daniel)

---
 drivers/gpu/drm/i915/i915_dma.c      |  2 +-
 drivers/gpu/drm/i915/i915_drv.c      |  2 +-
 drivers/gpu/drm/i915/i915_drv.h      |  8 +++++++-
 drivers/gpu/drm/i915/intel_display.c | 17 +++++++++++++++++
 drivers/gpu/drm/i915/intel_drv.h     |  1 +
 drivers/gpu/drm/i915/intel_pm.c      | 37 +-----------------------------------
 6 files changed, 28 insertions(+), 39 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +1 -1
index fd848ef..b722b35 100644
@@ -1710,7 +1710,7 @@ int i915_driver_unload(struct drm_device *dev)
 		/* The i915.ko module is still not prepared to be loaded when
 		 * the power well is not enabled, so just enable it in case
 		 * we're going to unload/reload. */
-		intel_set_power_well(dev, true);
+		intel_display_set_init_power(dev, true);
 		i915_remove_power_well(dev);
 	}
 
drivers/gpu/drm/i915/i915_drv.c +1 -1
index 85ae0dc..770c9f8 100644
@@ -477,7 +477,7 @@ static int i915_drm_freeze(struct drm_device *dev)
 	/* We do a lot of poking in a lot of registers, make sure they work
 	 * properly. */
 	hsw_disable_package_c8(dev_priv);
-	intel_set_power_well(dev, true);
+	intel_display_set_init_power(dev, true);
 
 	drm_kms_helper_poll_disable(dev);
 
drivers/gpu/drm/i915/i915_drv.h +7 -1
index 7315095..3565db2 100644
@@ -100,6 +100,7 @@ enum intel_display_power_domain {
 	POWER_DOMAIN_TRANSCODER_C,
 	POWER_DOMAIN_TRANSCODER_EDP,
 	POWER_DOMAIN_VGA,
+	POWER_DOMAIN_INIT,
 
 	POWER_DOMAIN_NUM,
 };
@@ -913,12 +914,17 @@ struct i915_power_well {
 	struct drm_device *device;
 	/* power well enable/disable usage count */
 	int count;
-	int i915_request;
 };
 
 #define I915_MAX_POWER_WELLS 1
 
 struct i915_power_domains {
+	/*
+	 * Power wells needed for initialization at driver init and suspend
+	 * time are on. They are kept on until after the first modeset.
+	 */
+	bool init_power_on;
+
 	struct mutex lock;
 	struct i915_power_well power_wells[I915_MAX_POWER_WELLS];
 };
drivers/gpu/drm/i915/intel_display.c +17 -0
index 3e79a2a..0c2e83c 100644
@@ -6573,6 +6573,21 @@ static unsigned long get_pipe_power_domains(struct drm_device *dev,
 	return mask;
 }
 
+void intel_display_set_init_power(struct drm_device *dev, bool enable)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	if (dev_priv->power_domains.init_power_on == enable)
+		return;
+
+	if (enable)
+		intel_display_power_get(dev, POWER_DOMAIN_INIT);
+	else
+		intel_display_power_put(dev, POWER_DOMAIN_INIT);
+
+	dev_priv->power_domains.init_power_on = enable;
+}
+
 static void modeset_update_power_wells(struct drm_device *dev)
 {
 	unsigned long pipe_domains[I915_MAX_PIPES] = { 0, };
@@ -6604,6 +6619,8 @@ static void modeset_update_power_wells(struct drm_device *dev)
 
 		crtc->enabled_power_domains = pipe_domains[crtc->pipe];
 	}
+
+	intel_display_set_init_power(dev, false);
 }
 
 static void haswell_modeset_global_resources(struct drm_device *dev)
drivers/gpu/drm/i915/intel_drv.h +1 -0
index af1553c..bf4394a 100644
@@ -692,6 +692,7 @@ bool intel_crtc_active(struct drm_crtc *crtc);
 void i915_disable_vga_mem(struct drm_device *dev);
 void hsw_enable_ips(struct intel_crtc *crtc);
 void hsw_disable_ips(struct intel_crtc *crtc);
+void intel_display_set_init_power(struct drm_device *dev, bool enable);
 
 
 /* intel_dp.c */
drivers/gpu/drm/i915/intel_pm.c +1 -36
index 09ca6f9..4c38e28 100644
@@ -5706,41 +5706,6 @@ void i915_remove_power_well(struct drm_device *dev)
 	hsw_pwr = NULL;
 }
 
-void intel_set_power_well(struct drm_device *dev, bool enable)
-{
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct i915_power_domains *power_domains = &dev_priv->power_domains;
-	struct i915_power_well *power_well;
-
-	if (!HAS_POWER_WELL(dev))
-		return;
-
-	if (!i915_disable_power_well && !enable)
-		return;
-
-	mutex_lock(&power_domains->lock);
-
-	power_well = &power_domains->power_wells[0];
-	/*
-	 * 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;
-
-	if (enable)
-		__intel_power_well_get(power_well);
-	else
-		__intel_power_well_put(power_well);
-
- out:
-	mutex_unlock(&power_domains->lock);
-}
-
 static void intel_resume_power_well(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -5772,7 +5737,7 @@ void intel_init_power_well(struct drm_device *dev)
 		return;
 
 	/* For now, we need the power well to be always enabled. */
-	intel_set_power_well(dev, true);
+	intel_display_set_init_power(dev, true);
 	intel_resume_power_well(dev);
 
 	/* We're taking over the BIOS, so clear any requests made by it since
Signature · 1 line
1.8.4
Reviewed-by on v1 1/2
#21 lore raw

Re: [PATCH 1/2] drm/i915: prepare for multiple power wells

In reply to Imre Deak

2013/10/22 Imre Deak <[email protected]>:

Quoted 18 lines

In the future we'll need to support multiple power wells, so prepare for that here. Create a new power domains struct which contains all power domain/well specific fields. Since we'll have one lock protecting all power wells, move power_well->lock to the new struct too.

No functional change.

---
 drivers/gpu/drm/i915/i915_drv.h | 11 ++++++---
 drivers/gpu/drm/i915/intel_pm.c | 55 +++++++++++++++++++++++++----------------
 2 files changed, 42 insertions(+), 24 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -0
index 80957ca..7315095 100644

drivers/gpu/drm/i915/i915_drv.h struct intel_ilk_power_mgmt { · line 913

Quoted 3 lines
drivers/gpu/drm/i915/i915_drv.h +0 -0
@@ -911,12 +911,18 @@ struct intel_ilk_power_mgmt {
 /* Power well structure for haswell */
 struct i915_power_well {
        struct drm_device *device;

Can't we also move "device" to i915_power_domains?

drivers/gpu/drm/i915/i915_drv.h struct intel_ilk_power_mgmt { · line 919

Quoted 7 lines
drivers/gpu/drm/i915/i915_drv.h +1 -1
-       struct mutex lock;
        /* power well enable/disable usage count */
        int count;
        int i915_request;
 };
 
+#define I915_MAX_POWER_WELLS 1

How about this?

enum intel_power_wells {
HASWELL_POWER_WELL = 0, /* Or any other more creative name,
since I guess we'll have an equivalent power well on other gens */

        I915_MAX_POWER_WELLS,
};

And then you switch all the code below that uses index zero for the actual enum name.

Maybe "NON_LPSP_POWER_WELL = 0" since the docs describe LPSP (Low Power Single Pipe) as a feature that is enabled when the power well is disabled. Feel free to invent better names :)

Quoted 99 lines
drivers/gpu/drm/i915/i915_drv.h +7 -2
+
+struct i915_power_domains {
+       struct mutex lock;
+       struct i915_power_well power_wells[I915_MAX_POWER_WELLS];
+};
+
 struct i915_dri1_state {
        unsigned allow_batchbuffer : 1;
        u32 __iomem *gfx_hws_cpu_addr;
@@ -1412,8 +1418,7 @@ typedef struct drm_i915_private {
         * mchdev_lock in intel_pm.c */
        struct intel_ilk_power_mgmt ips;
 
-       /* Haswell power well */
-       struct i915_power_well power_well;
+       struct i915_power_domains power_domains;
 
        struct i915_psr psr;
 
drivers/gpu/drm/i915/intel_pm.c +17 -11
index 3e140ab..09ca6f9 100644
@@ -5625,7 +5625,7 @@ 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;
+       struct i915_power_domains *power_domains;
 
        if (!HAS_POWER_WELL(dev))
                return;
@@ -5633,16 +5633,18 @@ void intel_display_power_get(struct drm_device *dev,
        if (is_always_on_power_domain(dev, domain))
                return;
 
-       mutex_lock(&power_well->lock);
-       __intel_power_well_get(power_well);
-       mutex_unlock(&power_well->lock);
+       power_domains = &dev_priv->power_domains;
+
+       mutex_lock(&power_domains->lock);
+       __intel_power_well_get(&power_domains->power_wells[0]);
+       mutex_unlock(&power_domains->lock);
 }
 
 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;
+       struct i915_power_domains *power_domains;
 
        if (!HAS_POWER_WELL(dev))
                return;
@@ -5650,12 +5652,14 @@ void intel_display_power_put(struct drm_device *dev,
        if (is_always_on_power_domain(dev, domain))
                return;
 
-       mutex_lock(&power_well->lock);
-       __intel_power_well_put(power_well);
-       mutex_unlock(&power_well->lock);
+       power_domains = &dev_priv->power_domains;
+
+       mutex_lock(&power_domains->lock);
+       __intel_power_well_put(&power_domains->power_wells[0]);
+       mutex_unlock(&power_domains->lock);
 }
 
-static struct i915_power_well *hsw_pwr;
+static struct i915_power_domains *hsw_pwr;
 
 /* Display audio driver power well request */
 void i915_request_power_well(void)
@@ -5664,7 +5668,7 @@ void i915_request_power_well(void)
                return;
 
        mutex_lock(&hsw_pwr->lock);
-       __intel_power_well_get(hsw_pwr);
+       __intel_power_well_get(&hsw_pwr->power_wells[0]);
        mutex_unlock(&hsw_pwr->lock);
 }
 EXPORT_SYMBOL_GPL(i915_request_power_well);
@@ -5676,7 +5680,7 @@ void i915_release_power_well(void)
                return;
 
        mutex_lock(&hsw_pwr->lock);
-       __intel_power_well_put(hsw_pwr);
+       __intel_power_well_put(&hsw_pwr->power_wells[0]);
        mutex_unlock(&hsw_pwr->lock);
 }
 EXPORT_SYMBOL_GPL(i915_release_power_well);
@@ -5684,12 +5688,15 @@ EXPORT_SYMBOL_GPL(i915_release_power_well);
 int i915_init_power_well(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
+       struct i915_power_domains *power_domains = &dev_priv->power_domains;
+       struct i915_power_well *power_well;
 

drivers/gpu/drm/i915/intel_pm.c EXPORT_SYMBOL_GPL(i915_release_power_well); · line 5699

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +5 -4
-       hsw_pwr = &dev_priv->power_well;
+       mutex_init(&power_domains->lock);
+       hsw_pwr = power_domains;
 
-       hsw_pwr->device = dev;
-       mutex_init(&hsw_pwr->lock);
-       hsw_pwr->count = 0;
+       power_well = &power_domains->power_wells[0];
+       power_well->device = dev;
+       power_well->count = 0;

How about this?

for (i = 0; i < I915_MAX_POWER_WELLS; i++) {
        power_well = &power_domains->power_wells[0];
        power_well->device = dev; /* If you don't move this to the
power_domains struct. */
        power_well->count = 0;
}

Then we'll always be safe :)

With or without my 3 bikesheds (although I would really like to see them):

By the way, do you also plan to change some functions so they take struct i915_power_well (or an index representing the power well number) as a parameter? E.g., intel_set_power_well.

Quoted 60 lines
drivers/gpu/drm/i915/intel_pm.c +12 -7
        return 0;
 }
@@ -5702,7 +5709,8 @@ void i915_remove_power_well(struct drm_device *dev)
 void intel_set_power_well(struct drm_device *dev, bool enable)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
-       struct i915_power_well *power_well = &dev_priv->power_well;
+       struct i915_power_domains *power_domains = &dev_priv->power_domains;
+       struct i915_power_well *power_well;
 
        if (!HAS_POWER_WELL(dev))
                return;
@@ -5710,8 +5718,9 @@ void intel_set_power_well(struct drm_device *dev, bool enable)
        if (!i915_disable_power_well && !enable)
                return;
 
-       mutex_lock(&power_well->lock);
+       mutex_lock(&power_domains->lock);
 
+       power_well = &power_domains->power_wells[0];
        /*
         * This function will only ever contribute one
         * to the power well reference count. i915_request
@@ -5729,20 +5738,24 @@ void intel_set_power_well(struct drm_device *dev, bool enable)
                __intel_power_well_put(power_well);
 
  out:
-       mutex_unlock(&power_well->lock);
+       mutex_unlock(&power_domains->lock);
 }
 
 static void intel_resume_power_well(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
-       struct i915_power_well *power_well = &dev_priv->power_well;
+       struct i915_power_domains *power_domains = &dev_priv->power_domains;
+       struct i915_power_well *power_well;
 
        if (!HAS_POWER_WELL(dev))
                return;
 
-       mutex_lock(&power_well->lock);
+       mutex_lock(&power_domains->lock);
+
+       power_well = &power_domains->power_wells[0];
        __intel_set_power_well(dev, power_well->count > 0);
-       mutex_unlock(&power_well->lock);
+
+       mutex_unlock(&power_domains->lock);
 }
 
 /*
--

1.8.4

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

Signature · 1 line
Paulo Zanoni
author
#22 lore raw

Re: [PATCH 1/2] drm/i915: prepare for multiple power wells

Quoted 14 lines · Paulo Zanoni

2013/10/22 Imre Deak <[email protected]>:

Quoted 13 lines

In the future we'll need to support multiple power wells, so prepare for that here. Create a new power domains struct which contains all power domain/well specific fields. Since we'll have one lock protecting all power wells, move power_well->lock to the new struct too.

No functional change.

---
 drivers/gpu/drm/i915/i915_drv.h | 11 ++++++---
 drivers/gpu/drm/i915/intel_pm.c | 55 +++++++++++++++++++++++++----------------
 2 files changed, 42 insertions(+), 24 deletions(-)
Quoted 10 lines

drivers/gpu/drm/i915/i915_drv.h struct intel_ilk_power_mgmt { · line 913

Quoted 8 lines
drivers/gpu/drm/i915/i915_drv.h +0 -0
index 80957ca..7315095 100644
@@ -911,12 +911,18 @@ struct intel_ilk_power_mgmt {
 /* Power well structure for haswell */
 struct i915_power_well {
        struct drm_device *device;

Can't we also move "device" to i915_power_domains?

Yes, that's a better place for it, especially since there is no point in duplicating it in every instance of the power well struct. Afaics the only real reason we need to store device is i915_{request,release}_power_well, but those could take it from power_domains and pass it to __intel_power_well_{get,put}. This is a somewhat bigger/independent change, so I'd follow up with a separate patch for it.

Quoted 8 lines

drivers/gpu/drm/i915/i915_drv.h struct intel_ilk_power_mgmt { · line 919

Quoted 7 lines
drivers/gpu/drm/i915/i915_drv.h +1 -1
-       struct mutex lock;
        /* power well enable/disable usage count */
        int count;
        int i915_request;
 };
 
+#define I915_MAX_POWER_WELLS 1
Quoted 7 lines

How about this?

enum intel_power_wells {
HASWELL_POWER_WELL = 0, /* Or any other more creative name,
since I guess we'll have an equivalent power well on other gens */

        I915_MAX_POWER_WELLS,
};

I was also thinking about naming the power wells somehow. They are different on different platforms, so the above enum would have the same values with different names, stg like:

enum intel_power_wells {
	HASWELL_POWER_WELL = 0,

	VALLEYVIEW_POWER_WELL = 0,

	XX_POWER_WELL0 = 0,
	XX_POWER_WELL1 = 1,
	XX_POWER_WELL2 = 2,

	I915_MAX_POWER_WELLS,
};

Which would work, but is a bit messy imo. Atm I don't see the point of having these names, since we will only reference them in terms of the power domains they support.

Quoted 2 lines

And then you switch all the code below that uses index zero for the actual enum name.

Yea, that's not so nice, but it would vanish as soon as we switch to reference the power wells in the above way. I have a preliminary patch for this see: https://github.com/ideak/linux/commit/5be8b8b4

Quoted 3 lines

Maybe "NON_LPSP_POWER_WELL = 0" since the docs describe LPSP (Low Power Single Pipe) as a feature that is enabled when the power well is disabled. Feel free to invent better names :)

See above, but perhaps for debugging purposes we could add a char *name, and make the state of power wells available through debugfs.

Quoted 112 lines
Quoted 99 lines
drivers/gpu/drm/i915/i915_drv.h +7 -2
+
+struct i915_power_domains {
+       struct mutex lock;
+       struct i915_power_well power_wells[I915_MAX_POWER_WELLS];
+};
+
 struct i915_dri1_state {
        unsigned allow_batchbuffer : 1;
        u32 __iomem *gfx_hws_cpu_addr;
@@ -1412,8 +1418,7 @@ typedef struct drm_i915_private {
         * mchdev_lock in intel_pm.c */
        struct intel_ilk_power_mgmt ips;
 
-       /* Haswell power well */
-       struct i915_power_well power_well;
+       struct i915_power_domains power_domains;
 
        struct i915_psr psr;
 
drivers/gpu/drm/i915/intel_pm.c +17 -11
index 3e140ab..09ca6f9 100644
@@ -5625,7 +5625,7 @@ 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;
+       struct i915_power_domains *power_domains;
 
        if (!HAS_POWER_WELL(dev))
                return;
@@ -5633,16 +5633,18 @@ void intel_display_power_get(struct drm_device *dev,
        if (is_always_on_power_domain(dev, domain))
                return;
 
-       mutex_lock(&power_well->lock);
-       __intel_power_well_get(power_well);
-       mutex_unlock(&power_well->lock);
+       power_domains = &dev_priv->power_domains;
+
+       mutex_lock(&power_domains->lock);
+       __intel_power_well_get(&power_domains->power_wells[0]);
+       mutex_unlock(&power_domains->lock);
 }
 
 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;
+       struct i915_power_domains *power_domains;
 
        if (!HAS_POWER_WELL(dev))
                return;
@@ -5650,12 +5652,14 @@ void intel_display_power_put(struct drm_device *dev,
        if (is_always_on_power_domain(dev, domain))
                return;
 
-       mutex_lock(&power_well->lock);
-       __intel_power_well_put(power_well);
-       mutex_unlock(&power_well->lock);
+       power_domains = &dev_priv->power_domains;
+
+       mutex_lock(&power_domains->lock);
+       __intel_power_well_put(&power_domains->power_wells[0]);
+       mutex_unlock(&power_domains->lock);
 }
 
-static struct i915_power_well *hsw_pwr;
+static struct i915_power_domains *hsw_pwr;
 
 /* Display audio driver power well request */
 void i915_request_power_well(void)
@@ -5664,7 +5668,7 @@ void i915_request_power_well(void)
                return;
 
        mutex_lock(&hsw_pwr->lock);
-       __intel_power_well_get(hsw_pwr);
+       __intel_power_well_get(&hsw_pwr->power_wells[0]);
        mutex_unlock(&hsw_pwr->lock);
 }
 EXPORT_SYMBOL_GPL(i915_request_power_well);
@@ -5676,7 +5680,7 @@ void i915_release_power_well(void)
                return;
 
        mutex_lock(&hsw_pwr->lock);
-       __intel_power_well_put(hsw_pwr);
+       __intel_power_well_put(&hsw_pwr->power_wells[0]);
        mutex_unlock(&hsw_pwr->lock);
 }
 EXPORT_SYMBOL_GPL(i915_release_power_well);
@@ -5684,12 +5688,15 @@ EXPORT_SYMBOL_GPL(i915_release_power_well);
 int i915_init_power_well(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
+       struct i915_power_domains *power_domains = &dev_priv->power_domains;
+       struct i915_power_well *power_well;
 

drivers/gpu/drm/i915/intel_pm.c EXPORT_SYMBOL_GPL(i915_release_power_well); · line 5699

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +5 -4
-       hsw_pwr = &dev_priv->power_well;
+       mutex_init(&power_domains->lock);
+       hsw_pwr = power_domains;
 
-       hsw_pwr->device = dev;
-       mutex_init(&hsw_pwr->lock);
-       hsw_pwr->count = 0;
+       power_well = &power_domains->power_wells[0];
+       power_well->device = dev;
+       power_well->count = 0;

How about this?

Quoted 8 lines
for (i = 0; i < I915_MAX_POWER_WELLS; i++) {
        power_well = &power_domains->power_wells[0];
        power_well->device = dev; /* If you don't move this to the
power_domains struct. */
        power_well->count = 0;
}

Then we'll always be safe :)

Imo, this is safe now, since we only have a single power well. But the above preliminary patch has something similar to what you suggest, so if that's ok I'd address it there.

Quoted 6 lines

With or without my 3 bikesheds (although I would really like to see them):

By the way, do you also plan to change some functions so they take struct i915_power_well (or an index representing the power well number) as a parameter? E.g., intel_set_power_well.

See the above patch. But basically yes, I would find the power well(s) based on the requested power domain and call __intel_power_well_{get,put} for each, and these would in turn call a platform dependent .set hook if needed.

Thanks for the review,
Imre

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

author
#23 lore raw

v3 cover prepare for multiple power wells

In reply to Imre Deak

This patchset replaces
"[PATCH 6/6] drm/i915: use power get/put instead of set for power on after init" from my previous patchset. I addressed the feedback from Daniel and Paulo (patch 1-3) and included a related cleanup (patch 4).

Imre Deak (4):
drm/i915: prepare for multiple power wells
drm/i915: use power get/put instead of set for power on after init drm/i915: remove device field from struct power_well drm/i915: rename i915_init_power_well to i915_init_power_domains

 drivers/gpu/drm/i915/i915_dma.c      |  10 ++--
 drivers/gpu/drm/i915/i915_drv.c      |   4 +-
 drivers/gpu/drm/i915/i915_drv.h      |  20 +++++--
 drivers/gpu/drm/i915/intel_display.c |  17 ++++++
 drivers/gpu/drm/i915/intel_drv.h     |   7 ++-
 drivers/gpu/drm/i915/intel_pm.c      | 109 ++++++++++++++++-------------------
 6 files changed, 92 insertions(+), 75 deletions(-)
Signature · 1 line
1.8.4
author
#24 lore raw

PATCH v3 1/4 drm/i915: prepare for multiple power wells

In the future we'll need to support multiple power wells, so prepare for that here. Create a new power domains struct which contains all power domain/well specific fields. Since we'll have one lock protecting all power wells, move power_well->lock to the new struct too.

No functional change.

---
 drivers/gpu/drm/i915/i915_drv.h | 11 ++++++---
 drivers/gpu/drm/i915/intel_pm.c | 55 +++++++++++++++++++++++++----------------
 2 files changed, 42 insertions(+), 24 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +8 -3
index 80957ca..7315095 100644
@@ -911,12 +911,18 @@ struct intel_ilk_power_mgmt {
 /* Power well structure for haswell */
 struct i915_power_well {
 	struct drm_device *device;
-	struct mutex lock;
 	/* power well enable/disable usage count */
 	int count;
 	int i915_request;
 };
 
+#define I915_MAX_POWER_WELLS 1
+
+struct i915_power_domains {
+	struct mutex lock;
+	struct i915_power_well power_wells[I915_MAX_POWER_WELLS];
+};
+
 struct i915_dri1_state {
 	unsigned allow_batchbuffer : 1;
 	u32 __iomem *gfx_hws_cpu_addr;
@@ -1412,8 +1418,7 @@ typedef struct drm_i915_private {
 	 * mchdev_lock in intel_pm.c */
 	struct intel_ilk_power_mgmt ips;
 
-	/* Haswell power well */
-	struct i915_power_well power_well;
+	struct i915_power_domains power_domains;
 
 	struct i915_psr psr;
 
drivers/gpu/drm/i915/intel_pm.c +34 -21

130 lines not on this page · raw message

Signature · 1 line
1.8.4
author
#25 lore raw

PATCH v3 2/4 drm/i915: use power get/put instead of set for power on after init

In reply to Imre Deak

Currently we make sure that all power domains are enabled during driver init and turn off unneded ones only after the first modeset. Similarly during suspend we enable all power domains, which will remain on through the following resume until the first modeset.

This logic is supported by intel_set_power_well() in the power domain framework. It would be nice to simplify the API, so that we only have get/put functions and make it more explicit on the higher level how this "power well on during init" logic works. This will make it also easier if in the future we want to shorten the time the power wells are on.

For this add a new device private flag tracking whether we have the power wells on because of init/suspend and use only intel_display_power_get()/put(). As nothing else uses intel_set_power_well() we can remove it.

This also fixes

commit 6efdf354ddb186c6604d1692075421e8d2c740e9

Author: Imre Deak <[email protected]>
Date:   Wed Oct 16 17:25:52 2013 +0300

drm/i915: enable only the needed power domains during modeset

where removing intel_set_power_well() resulted in not releasing the reference on the power well that was taken during init and thus leaving the power well on all the time. Regression reported by Paulo.

v2:
- move the init_power_on flag to the power_domains struct (Daniel)

v3:
- add note about this being a regression fix too (Paulo)

---
 drivers/gpu/drm/i915/i915_dma.c      |  2 +-
 drivers/gpu/drm/i915/i915_drv.c      |  2 +-
 drivers/gpu/drm/i915/i915_drv.h      |  8 +++++++-
 drivers/gpu/drm/i915/intel_display.c | 17 +++++++++++++++++
 drivers/gpu/drm/i915/intel_drv.h     |  1 +
 drivers/gpu/drm/i915/intel_pm.c      | 37 +-----------------------------------
 6 files changed, 28 insertions(+), 39 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +1 -1
index fd848ef..b722b35 100644
@@ -1710,7 +1710,7 @@ int i915_driver_unload(struct drm_device *dev)
 		/* The i915.ko module is still not prepared to be loaded when
 		 * the power well is not enabled, so just enable it in case
 		 * we're going to unload/reload. */
-		intel_set_power_well(dev, true);
+		intel_display_set_init_power(dev, true);
 		i915_remove_power_well(dev);
 	}
 
drivers/gpu/drm/i915/i915_drv.c +1 -1
index 85ae0dc..770c9f8 100644
@@ -477,7 +477,7 @@ static int i915_drm_freeze(struct drm_device *dev)
 	/* We do a lot of poking in a lot of registers, make sure they work
 	 * properly. */
 	hsw_disable_package_c8(dev_priv);
-	intel_set_power_well(dev, true);
+	intel_display_set_init_power(dev, true);
 
 	drm_kms_helper_poll_disable(dev);
 
drivers/gpu/drm/i915/i915_drv.h +7 -1
index 7315095..3565db2 100644
@@ -100,6 +100,7 @@ enum intel_display_power_domain {
 	POWER_DOMAIN_TRANSCODER_C,
 	POWER_DOMAIN_TRANSCODER_EDP,
 	POWER_DOMAIN_VGA,
+	POWER_DOMAIN_INIT,
 
 	POWER_DOMAIN_NUM,
 };
@@ -913,12 +914,17 @@ struct i915_power_well {
 	struct drm_device *device;
 	/* power well enable/disable usage count */
 	int count;
-	int i915_request;
 };
 
 #define I915_MAX_POWER_WELLS 1
 
 struct i915_power_domains {
+	/*
+	 * Power wells needed for initialization at driver init and suspend
+	 * time are on. They are kept on until after the first modeset.
+	 */
+	bool init_power_on;
+
 	struct mutex lock;
 	struct i915_power_well power_wells[I915_MAX_POWER_WELLS];
 };
drivers/gpu/drm/i915/intel_display.c +17 -0
index 3e79a2a..0c2e83c 100644
@@ -6573,6 +6573,21 @@ static unsigned long get_pipe_power_domains(struct drm_device *dev,
 	return mask;
 }
 
+void intel_display_set_init_power(struct drm_device *dev, bool enable)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	if (dev_priv->power_domains.init_power_on == enable)
+		return;
+
+	if (enable)
+		intel_display_power_get(dev, POWER_DOMAIN_INIT);
+	else
+		intel_display_power_put(dev, POWER_DOMAIN_INIT);
+
+	dev_priv->power_domains.init_power_on = enable;
+}
+
 static void modeset_update_power_wells(struct drm_device *dev)
 {
 	unsigned long pipe_domains[I915_MAX_PIPES] = { 0, };
@@ -6604,6 +6619,8 @@ static void modeset_update_power_wells(struct drm_device *dev)
 
 		crtc->enabled_power_domains = pipe_domains[crtc->pipe];
 	}
+
+	intel_display_set_init_power(dev, false);
 }
 
 static void haswell_modeset_global_resources(struct drm_device *dev)
drivers/gpu/drm/i915/intel_drv.h +1 -0
index af1553c..bf4394a 100644
@@ -692,6 +692,7 @@ bool intel_crtc_active(struct drm_crtc *crtc);
 void i915_disable_vga_mem(struct drm_device *dev);
 void hsw_enable_ips(struct intel_crtc *crtc);
 void hsw_disable_ips(struct intel_crtc *crtc);
+void intel_display_set_init_power(struct drm_device *dev, bool enable);
 
 
 /* intel_dp.c */
drivers/gpu/drm/i915/intel_pm.c +1 -36
index 09ca6f9..4c38e28 100644
@@ -5706,41 +5706,6 @@ void i915_remove_power_well(struct drm_device *dev)
 	hsw_pwr = NULL;
 }
 
-void intel_set_power_well(struct drm_device *dev, bool enable)
-{
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct i915_power_domains *power_domains = &dev_priv->power_domains;
-	struct i915_power_well *power_well;
-
-	if (!HAS_POWER_WELL(dev))
-		return;
-
-	if (!i915_disable_power_well && !enable)
-		return;
-
-	mutex_lock(&power_domains->lock);
-
-	power_well = &power_domains->power_wells[0];
-	/*
-	 * 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;
-
-	if (enable)
-		__intel_power_well_get(power_well);
-	else
-		__intel_power_well_put(power_well);
-
- out:
-	mutex_unlock(&power_domains->lock);
-}
-
 static void intel_resume_power_well(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -5772,7 +5737,7 @@ void intel_init_power_well(struct drm_device *dev)
 		return;
 
 	/* For now, we need the power well to be always enabled. */
-	intel_set_power_well(dev, true);
+	intel_display_set_init_power(dev, true);
 	intel_resume_power_well(dev);
 
 	/* We're taking over the BIOS, so clear any requests made by it since
Signature · 1 line
1.8.4
Reviewed-by on v3 2/4
#26 lore raw

Re: [PATCH v3 2/4] drm/i915: use power get/put instead of set for power on after init

2013/10/25 Imre Deak <[email protected]>:

Quoted 28 lines

Currently we make sure that all power domains are enabled during driver init and turn off unneded ones only after the first modeset. Similarly during suspend we enable all power domains, which will remain on through the following resume until the first modeset.

This logic is supported by intel_set_power_well() in the power domain framework. It would be nice to simplify the API, so that we only have get/put functions and make it more explicit on the higher level how this "power well on during init" logic works. This will make it also easier if in the future we want to shorten the time the power wells are on.

For this add a new device private flag tracking whether we have the power wells on because of init/suspend and use only intel_display_power_get()/put(). As nothing else uses intel_set_power_well() we can remove it.

This also fixes

commit 6efdf354ddb186c6604d1692075421e8d2c740e9

Author: Imre Deak <[email protected]>
Date:   Wed Oct 16 17:25:52 2013 +0300

drm/i915: enable only the needed power domains during modeset

where removing intel_set_power_well() resulted in not releasing the reference on the power well that was taken during init and thus leaving the power well on all the time. Regression reported by Paulo.

Quoted 5 lines

v2:
- move the init_power_on flag to the power_domains struct (Daniel)

v3:
- add note about this being a regression fix too (Paulo)

I didn't closely follow the first 5 patches, but this one makes sense.

Quoted 177 lines
---
 drivers/gpu/drm/i915/i915_dma.c      |  2 +-
 drivers/gpu/drm/i915/i915_drv.c      |  2 +-
 drivers/gpu/drm/i915/i915_drv.h      |  8 +++++++-
 drivers/gpu/drm/i915/intel_display.c | 17 +++++++++++++++++
 drivers/gpu/drm/i915/intel_drv.h     |  1 +
 drivers/gpu/drm/i915/intel_pm.c      | 37 +-----------------------------------
 6 files changed, 28 insertions(+), 39 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +1 -1
index fd848ef..b722b35 100644
@@ -1710,7 +1710,7 @@ int i915_driver_unload(struct drm_device *dev)
                /* The i915.ko module is still not prepared to be loaded when
                 * the power well is not enabled, so just enable it in case
                 * we're going to unload/reload. */
-               intel_set_power_well(dev, true);
+               intel_display_set_init_power(dev, true);
                i915_remove_power_well(dev);
        }
 
drivers/gpu/drm/i915/i915_drv.c +1 -1
index 85ae0dc..770c9f8 100644
@@ -477,7 +477,7 @@ static int i915_drm_freeze(struct drm_device *dev)
        /* We do a lot of poking in a lot of registers, make sure they work
         * properly. */
        hsw_disable_package_c8(dev_priv);
-       intel_set_power_well(dev, true);
+       intel_display_set_init_power(dev, true);
 
        drm_kms_helper_poll_disable(dev);
 
drivers/gpu/drm/i915/i915_drv.h +7 -1
index 7315095..3565db2 100644
@@ -100,6 +100,7 @@ enum intel_display_power_domain {
        POWER_DOMAIN_TRANSCODER_C,
        POWER_DOMAIN_TRANSCODER_EDP,
        POWER_DOMAIN_VGA,
+       POWER_DOMAIN_INIT,
 
        POWER_DOMAIN_NUM,
 };
@@ -913,12 +914,17 @@ struct i915_power_well {
        struct drm_device *device;
        /* power well enable/disable usage count */
        int count;
-       int i915_request;
 };
 
 #define I915_MAX_POWER_WELLS 1
 
 struct i915_power_domains {
+       /*
+        * Power wells needed for initialization at driver init and suspend
+        * time are on. They are kept on until after the first modeset.
+        */
+       bool init_power_on;
+
        struct mutex lock;
        struct i915_power_well power_wells[I915_MAX_POWER_WELLS];
 };
drivers/gpu/drm/i915/intel_display.c +17 -0
index 3e79a2a..0c2e83c 100644
@@ -6573,6 +6573,21 @@ static unsigned long get_pipe_power_domains(struct drm_device *dev,
        return mask;
 }
 
+void intel_display_set_init_power(struct drm_device *dev, bool enable)
+{
+       struct drm_i915_private *dev_priv = dev->dev_private;
+
+       if (dev_priv->power_domains.init_power_on == enable)
+               return;
+
+       if (enable)
+               intel_display_power_get(dev, POWER_DOMAIN_INIT);
+       else
+               intel_display_power_put(dev, POWER_DOMAIN_INIT);
+
+       dev_priv->power_domains.init_power_on = enable;
+}
+
 static void modeset_update_power_wells(struct drm_device *dev)
 {
        unsigned long pipe_domains[I915_MAX_PIPES] = { 0, };
@@ -6604,6 +6619,8 @@ static void modeset_update_power_wells(struct drm_device *dev)
 
                crtc->enabled_power_domains = pipe_domains[crtc->pipe];
        }
+
+       intel_display_set_init_power(dev, false);
 }
 
 static void haswell_modeset_global_resources(struct drm_device *dev)
drivers/gpu/drm/i915/intel_drv.h +1 -0
index af1553c..bf4394a 100644
@@ -692,6 +692,7 @@ bool intel_crtc_active(struct drm_crtc *crtc);
 void i915_disable_vga_mem(struct drm_device *dev);
 void hsw_enable_ips(struct intel_crtc *crtc);
 void hsw_disable_ips(struct intel_crtc *crtc);
+void intel_display_set_init_power(struct drm_device *dev, bool enable);
 
 
 /* intel_dp.c */
drivers/gpu/drm/i915/intel_pm.c +1 -37
index 09ca6f9..4c38e28 100644
@@ -5706,41 +5706,6 @@ void i915_remove_power_well(struct drm_device *dev)
        hsw_pwr = NULL;
 }
 
-void intel_set_power_well(struct drm_device *dev, bool enable)
-{
-       struct drm_i915_private *dev_priv = dev->dev_private;
-       struct i915_power_domains *power_domains = &dev_priv->power_domains;
-       struct i915_power_well *power_well;
-
-       if (!HAS_POWER_WELL(dev))
-               return;
-
-       if (!i915_disable_power_well && !enable)
-               return;
-
-       mutex_lock(&power_domains->lock);
-
-       power_well = &power_domains->power_wells[0];
-       /*
-        * 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;
-
-       if (enable)
-               __intel_power_well_get(power_well);
-       else
-               __intel_power_well_put(power_well);
-
- out:
-       mutex_unlock(&power_domains->lock);
-}
-
 static void intel_resume_power_well(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
@@ -5772,7 +5737,7 @@ void intel_init_power_well(struct drm_device *dev)
                return;
 
        /* For now, we need the power well to be always enabled. */
-       intel_set_power_well(dev, true);
+       intel_display_set_init_power(dev, true);
        intel_resume_power_well(dev);
 
        /* We're taking over the BIOS, so clear any requests made by it since
--

1.8.4

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

Signature · 1 line
Paulo Zanoni
author
#27 lore raw

PATCH v3 3/4 drm/i915: remove device field from struct power_well

In reply to Imre Deak

The only real need for this field was in i915_{request,release}_power_well, but there we can get at it by a container_of magic. Also since in the future we'll have multiple power wells each with its own power_well struct it makes sense to remove the field from there where it'd be just redundancy.

---
 drivers/gpu/drm/i915/i915_drv.h |  1 -
 drivers/gpu/drm/i915/intel_pm.c | 29 ++++++++++++++++++++---------
 2 files changed, 20 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -1
index 3565db2..2731fbb 100644
@@ -911,7 +911,6 @@ struct intel_ilk_power_mgmt {
 
 /* Power well structure for haswell */
 struct i915_power_well {
-	struct drm_device *device;
 	/* power well enable/disable usage count */
 	int count;
 };
drivers/gpu/drm/i915/intel_pm.c +20 -9
index 4c38e28..4f84a4b 100644
@@ -5608,17 +5608,19 @@ static void __intel_set_power_well(struct drm_device *dev, bool enable)
 	}
 }
 
-static void __intel_power_well_get(struct i915_power_well *power_well)
+static void __intel_power_well_get(struct drm_device *dev,
+				   struct i915_power_well *power_well)
 {
 	if (!power_well->count++)
-		__intel_set_power_well(power_well->device, true);
+		__intel_set_power_well(dev, true);
 }
 
-static void __intel_power_well_put(struct i915_power_well *power_well)
+static void __intel_power_well_put(struct drm_device *dev,
+				   struct i915_power_well *power_well)
 {
 	WARN_ON(!power_well->count);
 	if (!--power_well->count)
-		__intel_set_power_well(power_well->device, false);
+		__intel_set_power_well(dev, false);
 }
 
 void intel_display_power_get(struct drm_device *dev,
@@ -5636,7 +5638,7 @@ void intel_display_power_get(struct drm_device *dev,
 	power_domains = &dev_priv->power_domains;
 
 	mutex_lock(&power_domains->lock);
-	__intel_power_well_get(&power_domains->power_wells[0]);
+	__intel_power_well_get(dev, &power_domains->power_wells[0]);
 	mutex_unlock(&power_domains->lock);
 }
 
@@ -5655,7 +5657,7 @@ void intel_display_power_put(struct drm_device *dev,
 	power_domains = &dev_priv->power_domains;
 
 	mutex_lock(&power_domains->lock);
-	__intel_power_well_put(&power_domains->power_wells[0]);
+	__intel_power_well_put(dev, &power_domains->power_wells[0]);
 	mutex_unlock(&power_domains->lock);
 }
 
@@ -5664,11 +5666,16 @@ static struct i915_power_domains *hsw_pwr;
 /* Display audio driver power well request */
 void i915_request_power_well(void)
 {
+	struct drm_i915_private *dev_priv;
+
 	if (WARN_ON(!hsw_pwr))
 		return;
 
+	dev_priv = container_of(hsw_pwr, struct drm_i915_private,
+				power_domains);
+
 	mutex_lock(&hsw_pwr->lock);
-	__intel_power_well_get(&hsw_pwr->power_wells[0]);
+	__intel_power_well_get(dev_priv->dev, &hsw_pwr->power_wells[0]);
 	mutex_unlock(&hsw_pwr->lock);
 }
 EXPORT_SYMBOL_GPL(i915_request_power_well);
@@ -5676,11 +5683,16 @@ EXPORT_SYMBOL_GPL(i915_request_power_well);
 /* Display audio driver power well release */
 void i915_release_power_well(void)
 {
+	struct drm_i915_private *dev_priv;
+
 	if (WARN_ON(!hsw_pwr))
 		return;
 
+	dev_priv = container_of(hsw_pwr, struct drm_i915_private,
+				power_domains);
+
 	mutex_lock(&hsw_pwr->lock);
-	__intel_power_well_put(&hsw_pwr->power_wells[0]);
+	__intel_power_well_put(dev_priv->dev, &hsw_pwr->power_wells[0]);
 	mutex_unlock(&hsw_pwr->lock);
 }
 EXPORT_SYMBOL_GPL(i915_release_power_well);
@@ -5695,7 +5707,6 @@ int i915_init_power_well(struct drm_device *dev)
 	hsw_pwr = power_domains;
 
 	power_well = &power_domains->power_wells[0];
-	power_well->device = dev;
 	power_well->count = 0;
 
 	return 0;
Signature · 1 line
1.8.4
Reviewed-by on v3 3/4
#28 lore raw

Re: [PATCH v3 3/4] drm/i915: remove device field from struct power_well

2013/10/25 Imre Deak <[email protected]>:

Quoted 7 lines

The only real need for this field was in i915_{request,release}_power_well, but there we can get at it by a container_of magic. Also since in the future we'll have multiple power wells each with its own power_well struct it makes sense to remove the field from there where it'd be just redundancy.

My original idea was to just move it from i915_power_well to i915_power_domains, so hsw_pwr (which is the new external static thing) would still have a pointer to our driver. This way we wouldn't need the container_of magic. But your solution works too, and saves 4/8 bytes :)

Quoted 115 lines
---
 drivers/gpu/drm/i915/i915_drv.h |  1 -
 drivers/gpu/drm/i915/intel_pm.c | 29 ++++++++++++++++++++---------
 2 files changed, 20 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -1
index 3565db2..2731fbb 100644
@@ -911,7 +911,6 @@ struct intel_ilk_power_mgmt {
 
 /* Power well structure for haswell */
 struct i915_power_well {
-       struct drm_device *device;
        /* power well enable/disable usage count */
        int count;
 };
drivers/gpu/drm/i915/intel_pm.c +20 -10
index 4c38e28..4f84a4b 100644
@@ -5608,17 +5608,19 @@ static void __intel_set_power_well(struct drm_device *dev, bool enable)
        }
 }
 
-static void __intel_power_well_get(struct i915_power_well *power_well)
+static void __intel_power_well_get(struct drm_device *dev,
+                                  struct i915_power_well *power_well)
 {
        if (!power_well->count++)
-               __intel_set_power_well(power_well->device, true);
+               __intel_set_power_well(dev, true);
 }
 
-static void __intel_power_well_put(struct i915_power_well *power_well)
+static void __intel_power_well_put(struct drm_device *dev,
+                                  struct i915_power_well *power_well)
 {
        WARN_ON(!power_well->count);
        if (!--power_well->count)
-               __intel_set_power_well(power_well->device, false);
+               __intel_set_power_well(dev, false);
 }
 
 void intel_display_power_get(struct drm_device *dev,
@@ -5636,7 +5638,7 @@ void intel_display_power_get(struct drm_device *dev,
        power_domains = &dev_priv->power_domains;
 
        mutex_lock(&power_domains->lock);
-       __intel_power_well_get(&power_domains->power_wells[0]);
+       __intel_power_well_get(dev, &power_domains->power_wells[0]);
        mutex_unlock(&power_domains->lock);
 }
 
@@ -5655,7 +5657,7 @@ void intel_display_power_put(struct drm_device *dev,
        power_domains = &dev_priv->power_domains;
 
        mutex_lock(&power_domains->lock);
-       __intel_power_well_put(&power_domains->power_wells[0]);
+       __intel_power_well_put(dev, &power_domains->power_wells[0]);
        mutex_unlock(&power_domains->lock);
 }
 
@@ -5664,11 +5666,16 @@ static struct i915_power_domains *hsw_pwr;
 /* Display audio driver power well request */
 void i915_request_power_well(void)
 {
+       struct drm_i915_private *dev_priv;
+
        if (WARN_ON(!hsw_pwr))
                return;
 
+       dev_priv = container_of(hsw_pwr, struct drm_i915_private,
+                               power_domains);
+
        mutex_lock(&hsw_pwr->lock);
-       __intel_power_well_get(&hsw_pwr->power_wells[0]);
+       __intel_power_well_get(dev_priv->dev, &hsw_pwr->power_wells[0]);
        mutex_unlock(&hsw_pwr->lock);
 }
 EXPORT_SYMBOL_GPL(i915_request_power_well);
@@ -5676,11 +5683,16 @@ EXPORT_SYMBOL_GPL(i915_request_power_well);
 /* Display audio driver power well release */
 void i915_release_power_well(void)
 {
+       struct drm_i915_private *dev_priv;
+
        if (WARN_ON(!hsw_pwr))
                return;
 
+       dev_priv = container_of(hsw_pwr, struct drm_i915_private,
+                               power_domains);
+
        mutex_lock(&hsw_pwr->lock);
-       __intel_power_well_put(&hsw_pwr->power_wells[0]);
+       __intel_power_well_put(dev_priv->dev, &hsw_pwr->power_wells[0]);
        mutex_unlock(&hsw_pwr->lock);
 }
 EXPORT_SYMBOL_GPL(i915_release_power_well);
@@ -5695,7 +5707,6 @@ int i915_init_power_well(struct drm_device *dev)
        hsw_pwr = power_domains;
 
        power_well = &power_domains->power_wells[0];
-       power_well->device = dev;
        power_well->count = 0;
 
        return 0;
--

1.8.4

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

Signature · 1 line
Paulo Zanoni
#29 lore raw

Re: [PATCH v3 3/4] drm/i915: remove device field from struct power_well

Quoted 9 lines · Paulo Zanoni

2013/10/25 Imre Deak <[email protected]>:

Quoted 7 lines

The only real need for this field was in i915_{request,release}_power_well, but there we can get at it by a container_of magic. Also since in the future we'll have multiple power wells each with its own power_well struct it makes sense to remove the field from there where it'd be just redundancy.

Quoted 7 lines

My original idea was to just move it from i915_power_well to i915_power_domains, so hsw_pwr (which is the new external static thing) would still have a pointer to our driver. This way we wouldn't need the container_of magic. But your solution works too, and saves 4/8 bytes :)

First 3 patches merged, thanks.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#30 lore raw

Re: [PATCH v3 3/4] drm/i915: remove device field from struct power_well

2013/10/27 Daniel Vetter <[email protected]>:

Quoted 16 lines · Paulo Zanoni
Quoted 15 lines

2013/10/25 Imre Deak <[email protected]>:

Quoted 7 lines

The only real need for this field was in i915_{request,release}_power_well, but there we can get at it by a container_of magic. Also since in the future we'll have multiple power wells each with its own power_well struct it makes sense to remove the field from there where it'd be just redundancy.

My original idea was to just move it from i915_power_well to i915_power_domains, so hsw_pwr (which is the new external static thing) would still have a pointer to our driver. This way we wouldn't need the container_of magic. But your solution works too, and saves 4/8 bytes :)

Quoted 3 lines
Quoted 1 line

First 3 patches merged, thanks.

I just realized that at some point we accidentally killed the i915.disable_power_well option... I see the i915_disable_power_well variable is not being used anywhere. Imre, can you please investigate that?

Thanks,
Paulo

Quoted 5 lines

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

Signature · 1 line
Paulo Zanoni
author
#31 lore raw

Re: [PATCH v3 3/4] drm/i915: remove device field from struct power_well

Quoted 17 lines · Paulo Zanoni

2013/10/27 Daniel Vetter <[email protected]>:

Quoted 16 lines · Paulo Zanoni
Quoted 15 lines

2013/10/25 Imre Deak <[email protected]>:

Quoted 7 lines

The only real need for this field was in i915_{request,release}_power_well, but there we can get at it by a container_of magic. Also since in the future we'll have multiple power wells each with its own power_well struct it makes sense to remove the field from there where it'd be just redundancy.

My original idea was to just move it from i915_power_well to i915_power_domains, so hsw_pwr (which is the new external static thing) would still have a pointer to our driver. This way we wouldn't need the container_of magic. But your solution works too, and saves 4/8 bytes :)

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

First 3 patches merged, thanks.

I just realized that at some point we accidentally killed the i915.disable_power_well option... I see the i915_disable_power_well variable is not being used anywhere. Imre, can you please investigate that?

Yep, that got removed by mistake in

commit 6efdf354ddb186c6604d1692075421e8d2c740e9

Author: Imre Deak <[email protected]>
Date:   Wed Oct 16 17:25:52 2013 +0300

drm/i915: enable only the needed power domains during modeset

I'll follow up with a fix.

--Imre

author
#32 lore raw

PATCH v3 4/4 drm/i915: rename i915_init_power_well to i915_init_power_domains

In reply to Imre Deak

Similarly rename the other related functions in the power domain interface.

Higher level driver code calling these functions knows only about power domains, not the underlying power wells which may be different on different platforms. Also these functions really init/cleanup/resume power domains and only through that all related power wells, so rename them accordingly.

---
 drivers/gpu/drm/i915/i915_dma.c  |  8 ++++----
 drivers/gpu/drm/i915/i915_drv.c  |  2 +-
 drivers/gpu/drm/i915/intel_drv.h |  6 +++---
 drivers/gpu/drm/i915/intel_pm.c  | 10 +++++-----
 4 files changed, 13 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +4 -4
index b722b35..75f02e4 100644
@@ -1311,7 +1311,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
 	if (ret)
 		goto cleanup_gem_stolen;
 
-	intel_init_power_well(dev);
+	intel_init_power_domains(dev);
 
 	/* Important: The output setup functions called by modeset_init need
 	 * working irqs for e.g. gmbus and dp aux transfers. */
@@ -1640,7 +1640,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 	}
 
 	if (HAS_POWER_WELL(dev))
-		i915_init_power_well(dev);
+		i915_init_power_domains(dev);
 
 	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
 		ret = i915_load_modeset_init(dev);
@@ -1668,7 +1668,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 
 out_power_well:
 	if (HAS_POWER_WELL(dev))
-		i915_remove_power_well(dev);
+		i915_remove_power_domains(dev);
 	drm_vblank_cleanup(dev);
 out_gem_unload:
 	if (dev_priv->mm.inactive_shrinker.scan_objects)
@@ -1711,7 +1711,7 @@ int i915_driver_unload(struct drm_device *dev)
 		 * the power well is not enabled, so just enable it in case
 		 * we're going to unload/reload. */
 		intel_display_set_init_power(dev, true);
-		i915_remove_power_well(dev);
+		i915_remove_power_domains(dev);
 	}
 
 	i915_teardown_sysfs(dev);
drivers/gpu/drm/i915/i915_drv.c +1 -1
index 770c9f8..e4474c6 100644
@@ -597,7 +597,7 @@ static int __i915_drm_thaw(struct drm_device *dev, bool restore_gtt_mappings)
 		mutex_unlock(&dev->struct_mutex);
 	}
 
-	intel_init_power_well(dev);
+	intel_init_power_domains(dev);
 
 	i915_restore_state(dev);
 	intel_opregion_setup(dev);
drivers/gpu/drm/i915/intel_drv.h +3 -3
index bf4394a..ae6d362 100644
@@ -823,15 +823,15 @@ bool intel_fbc_enabled(struct drm_device *dev);
 void intel_update_fbc(struct drm_device *dev);
 void intel_gpu_ips_init(struct drm_i915_private *dev_priv);
 void intel_gpu_ips_teardown(void);
-int i915_init_power_well(struct drm_device *dev);
-void i915_remove_power_well(struct drm_device *dev);
+int i915_init_power_domains(struct drm_device *dev);
+void i915_remove_power_domains(struct drm_device *dev);
 bool intel_display_power_enabled(struct drm_device *dev,
 				 enum intel_display_power_domain domain);
 void intel_display_power_get(struct drm_device *dev,
 			     enum intel_display_power_domain domain);
 void intel_display_power_put(struct drm_device *dev,
 			     enum intel_display_power_domain domain);
-void intel_init_power_well(struct drm_device *dev);
+void intel_init_power_domains(struct drm_device *dev);
 void intel_set_power_well(struct drm_device *dev, bool enable);
 void intel_enable_gt_powersave(struct drm_device *dev);
 void intel_disable_gt_powersave(struct drm_device *dev);
drivers/gpu/drm/i915/intel_pm.c +5 -5
index 4f84a4b..9afec23 100644
@@ -5697,7 +5697,7 @@ void i915_release_power_well(void)
 }
 EXPORT_SYMBOL_GPL(i915_release_power_well);
 
-int i915_init_power_well(struct drm_device *dev)
+int i915_init_power_domains(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct i915_power_domains *power_domains = &dev_priv->power_domains;
@@ -5712,12 +5712,12 @@ int i915_init_power_well(struct drm_device *dev)
 	return 0;
 }
 
-void i915_remove_power_well(struct drm_device *dev)
+void i915_remove_power_domains(struct drm_device *dev)
 {
 	hsw_pwr = NULL;
 }
 
-static void intel_resume_power_well(struct drm_device *dev)
+static void intel_resume_power_domains(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct i915_power_domains *power_domains = &dev_priv->power_domains;
@@ -5740,7 +5740,7 @@ static void intel_resume_power_well(struct drm_device *dev)
  * to be enabled, and it will only be disabled if none of the registers is
  * requesting it to be enabled.
  */
-void intel_init_power_well(struct drm_device *dev)
+void intel_init_power_domains(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
@@ -5749,7 +5749,7 @@ void intel_init_power_well(struct drm_device *dev)
 
 	/* For now, we need the power well to be always enabled. */
 	intel_display_set_init_power(dev, true);
-	intel_resume_power_well(dev);
+	intel_resume_power_domains(dev);
 
 	/* We're taking over the BIOS, so clear any requests made by it since
 	 * the driver is in charge now. */
Signature · 1 line
1.8.4
#33 lore raw

Re: [PATCH v3 4/4] drm/i915: rename i915_init_power_well to i915_init_power_domains

2013/10/25 Imre Deak <[email protected]>:

Quoted 10 lines

Similarly rename the other related functions in the power domain interface.

Higher level driver code calling these functions knows only about power domains, not the underlying power wells which may be different on different platforms. Also these functions really init/cleanup/resume power domains and only through that all related power wells, so rename them accordingly.

I agree with the "_domains" rename, I think it's an improvement, but since you're already renaming things, I have to drop my bikeshed: we have intel_init_power_{well,domains} and i915_init_power_{well,domains}. IMHO this is really super annoyingly confusing, because they sound like they do the same thing. I know it's not your fault, but while you're at it, could you please propose names to unconfuse this?

i915_init_power_well takes care of initializing the structs and pointers, while intel_init_power_well is the only one that touches hardware. A possible suggestion:

- i915_init_power_well becomes intel_init_power_domains (just because I don't like the "i915_" prefix, since the PM code uses "intel_" for everything).
- i915_remove_power_well becomes intel_remove_power_domains (to match the one above)
- intel_init_power_well becomes intel_init_power_domains_hardware or intel_init_power_wells (since on the HW these things are actually called "power wells") or intel_init_hw_power_wells (to combine both suggestions)

Thanks,
Paulo

Quoted 136 lines
---
 drivers/gpu/drm/i915/i915_dma.c  |  8 ++++----
 drivers/gpu/drm/i915/i915_drv.c  |  2 +-
 drivers/gpu/drm/i915/intel_drv.h |  6 +++---
 drivers/gpu/drm/i915/intel_pm.c  | 10 +++++-----
 4 files changed, 13 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +4 -4
index b722b35..75f02e4 100644
@@ -1311,7 +1311,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
        if (ret)
                goto cleanup_gem_stolen;
 
-       intel_init_power_well(dev);
+       intel_init_power_domains(dev);
 
        /* Important: The output setup functions called by modeset_init need
         * working irqs for e.g. gmbus and dp aux transfers. */
@@ -1640,7 +1640,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
        }
 
        if (HAS_POWER_WELL(dev))
-               i915_init_power_well(dev);
+               i915_init_power_domains(dev);
 
        if (drm_core_check_feature(dev, DRIVER_MODESET)) {
                ret = i915_load_modeset_init(dev);
@@ -1668,7 +1668,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 
 out_power_well:
        if (HAS_POWER_WELL(dev))
-               i915_remove_power_well(dev);
+               i915_remove_power_domains(dev);
        drm_vblank_cleanup(dev);
 out_gem_unload:
        if (dev_priv->mm.inactive_shrinker.scan_objects)
@@ -1711,7 +1711,7 @@ int i915_driver_unload(struct drm_device *dev)
                 * the power well is not enabled, so just enable it in case
                 * we're going to unload/reload. */
                intel_display_set_init_power(dev, true);
-               i915_remove_power_well(dev);
+               i915_remove_power_domains(dev);
        }
 
        i915_teardown_sysfs(dev);
drivers/gpu/drm/i915/i915_drv.c +1 -1
index 770c9f8..e4474c6 100644
@@ -597,7 +597,7 @@ static int __i915_drm_thaw(struct drm_device *dev, bool restore_gtt_mappings)
                mutex_unlock(&dev->struct_mutex);
        }
 
-       intel_init_power_well(dev);
+       intel_init_power_domains(dev);
 
        i915_restore_state(dev);
        intel_opregion_setup(dev);
drivers/gpu/drm/i915/intel_drv.h +3 -3
index bf4394a..ae6d362 100644
@@ -823,15 +823,15 @@ bool intel_fbc_enabled(struct drm_device *dev);
 void intel_update_fbc(struct drm_device *dev);
 void intel_gpu_ips_init(struct drm_i915_private *dev_priv);
 void intel_gpu_ips_teardown(void);
-int i915_init_power_well(struct drm_device *dev);
-void i915_remove_power_well(struct drm_device *dev);
+int i915_init_power_domains(struct drm_device *dev);
+void i915_remove_power_domains(struct drm_device *dev);
 bool intel_display_power_enabled(struct drm_device *dev,
                                 enum intel_display_power_domain domain);
 void intel_display_power_get(struct drm_device *dev,
                             enum intel_display_power_domain domain);
 void intel_display_power_put(struct drm_device *dev,
                             enum intel_display_power_domain domain);
-void intel_init_power_well(struct drm_device *dev);
+void intel_init_power_domains(struct drm_device *dev);
 void intel_set_power_well(struct drm_device *dev, bool enable);
 void intel_enable_gt_powersave(struct drm_device *dev);
 void intel_disable_gt_powersave(struct drm_device *dev);
drivers/gpu/drm/i915/intel_pm.c +5 -6
index 4f84a4b..9afec23 100644
@@ -5697,7 +5697,7 @@ void i915_release_power_well(void)
 }
 EXPORT_SYMBOL_GPL(i915_release_power_well);
 
-int i915_init_power_well(struct drm_device *dev)
+int i915_init_power_domains(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
        struct i915_power_domains *power_domains = &dev_priv->power_domains;
@@ -5712,12 +5712,12 @@ int i915_init_power_well(struct drm_device *dev)
        return 0;
 }
 
-void i915_remove_power_well(struct drm_device *dev)
+void i915_remove_power_domains(struct drm_device *dev)
 {
        hsw_pwr = NULL;
 }
 
-static void intel_resume_power_well(struct drm_device *dev)
+static void intel_resume_power_domains(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
        struct i915_power_domains *power_domains = &dev_priv->power_domains;
@@ -5740,7 +5740,7 @@ static void intel_resume_power_well(struct drm_device *dev)
  * to be enabled, and it will only be disabled if none of the registers is
  * requesting it to be enabled.
  */
-void intel_init_power_well(struct drm_device *dev)
+void intel_init_power_domains(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
 
@@ -5749,7 +5749,7 @@ void intel_init_power_well(struct drm_device *dev)
 
        /* For now, we need the power well to be always enabled. */
        intel_display_set_init_power(dev, true);
-       intel_resume_power_well(dev);
+       intel_resume_power_domains(dev);
 
        /* We're taking over the BIOS, so clear any requests made by it since
         * the driver is in charge now. */
--

1.8.4

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

Signature · 1 line
Paulo Zanoni
#34 lore raw

Re: [PATCH v3 4/4] drm/i915: rename i915_init_power_well to i915_init_power_domains

Quoted 24 lines · Paulo Zanoni

2013/10/25 Imre Deak <[email protected]>:

Quoted 10 lines

Similarly rename the other related functions in the power domain interface.

Higher level driver code calling these functions knows only about power domains, not the underlying power wells which may be different on different platforms. Also these functions really init/cleanup/resume power domains and only through that all related power wells, so rename them accordingly.

I agree with the "_domains" rename, I think it's an improvement, but since you're already renaming things, I have to drop my bikeshed: we have intel_init_power_{well,domains} and i915_init_power_{well,domains}. IMHO this is really super annoyingly confusing, because they sound like they do the same thing. I know it's not your fault, but while you're at it, could you please propose names to unconfuse this?

i915_init_power_well takes care of initializing the structs and pointers, while intel_init_power_well is the only one that touches hardware. A possible suggestion:

Quoted 9 lines

- i915_init_power_well becomes intel_init_power_domains (just because I don't like the "i915_" prefix, since the PM code uses "intel_" for everything).
- i915_remove_power_well becomes intel_remove_power_domains (to match the one above)
- intel_init_power_well becomes intel_init_power_domains_hardware or intel_init_power_wells (since on the HW these things are actually called "power wells") or intel_init_hw_power_wells (to combine both suggestions)

The pattern we have thus far is $prefix_$block_init and $prefix_$block_init_hw. Occasionally the $block is at the end, but for cases where we have both an init and an init_hw function I think putting the init[_hw] at the end to make it stick out more is better.

Just my 2 bikesheds ;-)
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
author
#35 lore raw

PATCH v4 1/1 drm/i915: rename i915_init_power_well to init_power_domains_init

In reply to Imre Deak

Similarly rename the other related functions in the power domain interface.

Higher level driver code calling these functions knows only about power domains, not the underlying power wells which may be different on different platforms. Also these functions really init/cleanup/resume power domains and only through that all related power wells, so rename them accordingly.

Note that I left i915_{request,release}_power_well as is, since that really changes the state only of a single power well (and is HSW specific). It should also get a better name once we make it more generic by controlling things through a new audio power domain.

v4:
- use intel prefix instead of i915 everywhere (Paulo)
- use a $prefix_$block_$action format (Daniel)

---
 drivers/gpu/drm/i915/i915_dma.c  |  8 ++++----
 drivers/gpu/drm/i915/i915_drv.c  |  2 +-
 drivers/gpu/drm/i915/intel_drv.h |  6 +++---
 drivers/gpu/drm/i915/intel_pm.c  | 10 +++++-----
 4 files changed, 13 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +4 -4
index b722b35..0cab2d0 100644
@@ -1311,7 +1311,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
 	if (ret)
 		goto cleanup_gem_stolen;
 
-	intel_init_power_well(dev);
+	intel_power_domains_init_hw(dev);
 
 	/* Important: The output setup functions called by modeset_init need
 	 * working irqs for e.g. gmbus and dp aux transfers. */
@@ -1640,7 +1640,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 	}
 
 	if (HAS_POWER_WELL(dev))
-		i915_init_power_well(dev);
+		intel_power_domains_init(dev);
 
 	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
 		ret = i915_load_modeset_init(dev);
@@ -1668,7 +1668,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 
 out_power_well:
 	if (HAS_POWER_WELL(dev))
-		i915_remove_power_well(dev);
+		intel_power_domains_remove(dev);
 	drm_vblank_cleanup(dev);
 out_gem_unload:
 	if (dev_priv->mm.inactive_shrinker.scan_objects)
@@ -1711,7 +1711,7 @@ int i915_driver_unload(struct drm_device *dev)
 		 * the power well is not enabled, so just enable it in case
 		 * we're going to unload/reload. */
 		intel_display_set_init_power(dev, true);
-		i915_remove_power_well(dev);
+		intel_power_domains_remove(dev);
 	}
 
 	i915_teardown_sysfs(dev);
drivers/gpu/drm/i915/i915_drv.c +1 -1
index 770c9f8..a0804fa 100644
@@ -597,7 +597,7 @@ static int __i915_drm_thaw(struct drm_device *dev, bool restore_gtt_mappings)
 		mutex_unlock(&dev->struct_mutex);
 	}
 
-	intel_init_power_well(dev);
+	intel_power_domains_init_hw(dev);
 
 	i915_restore_state(dev);
 	intel_opregion_setup(dev);
drivers/gpu/drm/i915/intel_drv.h +3 -3
index bf4394a..9d2624f 100644
@@ -823,15 +823,15 @@ bool intel_fbc_enabled(struct drm_device *dev);
 void intel_update_fbc(struct drm_device *dev);
 void intel_gpu_ips_init(struct drm_i915_private *dev_priv);
 void intel_gpu_ips_teardown(void);
-int i915_init_power_well(struct drm_device *dev);
-void i915_remove_power_well(struct drm_device *dev);
+int intel_power_domains_init(struct drm_device *dev);
+void intel_power_domains_remove(struct drm_device *dev);
 bool intel_display_power_enabled(struct drm_device *dev,
 				 enum intel_display_power_domain domain);
 void intel_display_power_get(struct drm_device *dev,
 			     enum intel_display_power_domain domain);
 void intel_display_power_put(struct drm_device *dev,
 			     enum intel_display_power_domain domain);
-void intel_init_power_well(struct drm_device *dev);
+void intel_power_domains_init_hw(struct drm_device *dev);
 void intel_set_power_well(struct drm_device *dev, bool enable);
 void intel_enable_gt_powersave(struct drm_device *dev);
 void intel_disable_gt_powersave(struct drm_device *dev);
drivers/gpu/drm/i915/intel_pm.c +5 -5
index d2a640c..a0c907f 100644
@@ -5677,7 +5677,7 @@ void i915_release_power_well(void)
 }
 EXPORT_SYMBOL_GPL(i915_release_power_well);
 
-int i915_init_power_well(struct drm_device *dev)
+int intel_power_domains_init(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct i915_power_domains *power_domains = &dev_priv->power_domains;
@@ -5692,12 +5692,12 @@ int i915_init_power_well(struct drm_device *dev)
 	return 0;
 }
 
-void i915_remove_power_well(struct drm_device *dev)
+void intel_power_domains_remove(struct drm_device *dev)
 {
 	hsw_pwr = NULL;
 }
 
-static void intel_resume_power_well(struct drm_device *dev)
+static void intel_power_domains_resume(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct i915_power_domains *power_domains = &dev_priv->power_domains;
@@ -5720,7 +5720,7 @@ static void intel_resume_power_well(struct drm_device *dev)
  * to be enabled, and it will only be disabled if none of the registers is
  * requesting it to be enabled.
  */
-void intel_init_power_well(struct drm_device *dev)
+void intel_power_domains_init_hw(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
@@ -5729,7 +5729,7 @@ void intel_init_power_well(struct drm_device *dev)
 
 	/* For now, we need the power well to be always enabled. */
 	intel_display_set_init_power(dev, true);
-	intel_resume_power_well(dev);
+	intel_power_domains_resume(dev);
 
 	/* We're taking over the BIOS, so clear any requests made by it since
 	 * the driver is in charge now. */
Signature · 1 line
1.8.4
Reviewed-by on v4 1/1
#36 lore raw

Re: [PATCH v4] drm/i915: rename i915_init_power_well to init_power_domains_init

2013/10/28 Imre Deak <[email protected]>:

Quoted 9 lines

Similarly rename the other related functions in the power domain interface.

Higher level driver code calling these functions knows only about power domains, not the underlying power wells which may be different on different platforms. Also these functions really init/cleanup/resume power domains and only through that all related power wells, so rename them accordingly.

Quoted 8 lines

Note that I left i915_{request,release}_power_well as is, since that really changes the state only of a single power well (and is HSW specific). It should also get a better name once we make it more generic by controlling things through a new audio power domain.

v4:
- use intel prefix instead of i915 everywhere (Paulo)
- use a $prefix_$block_$action format (Daniel)

Quoted 138 lines
---
 drivers/gpu/drm/i915/i915_dma.c  |  8 ++++----
 drivers/gpu/drm/i915/i915_drv.c  |  2 +-
 drivers/gpu/drm/i915/intel_drv.h |  6 +++---
 drivers/gpu/drm/i915/intel_pm.c  | 10 +++++-----
 4 files changed, 13 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +4 -4
index b722b35..0cab2d0 100644
@@ -1311,7 +1311,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
        if (ret)
                goto cleanup_gem_stolen;
 
-       intel_init_power_well(dev);
+       intel_power_domains_init_hw(dev);
 
        /* Important: The output setup functions called by modeset_init need
         * working irqs for e.g. gmbus and dp aux transfers. */
@@ -1640,7 +1640,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
        }
 
        if (HAS_POWER_WELL(dev))
-               i915_init_power_well(dev);
+               intel_power_domains_init(dev);
 
        if (drm_core_check_feature(dev, DRIVER_MODESET)) {
                ret = i915_load_modeset_init(dev);
@@ -1668,7 +1668,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 
 out_power_well:
        if (HAS_POWER_WELL(dev))
-               i915_remove_power_well(dev);
+               intel_power_domains_remove(dev);
        drm_vblank_cleanup(dev);
 out_gem_unload:
        if (dev_priv->mm.inactive_shrinker.scan_objects)
@@ -1711,7 +1711,7 @@ int i915_driver_unload(struct drm_device *dev)
                 * the power well is not enabled, so just enable it in case
                 * we're going to unload/reload. */
                intel_display_set_init_power(dev, true);
-               i915_remove_power_well(dev);
+               intel_power_domains_remove(dev);
        }
 
        i915_teardown_sysfs(dev);
drivers/gpu/drm/i915/i915_drv.c +1 -1
index 770c9f8..a0804fa 100644
@@ -597,7 +597,7 @@ static int __i915_drm_thaw(struct drm_device *dev, bool restore_gtt_mappings)
                mutex_unlock(&dev->struct_mutex);
        }
 
-       intel_init_power_well(dev);
+       intel_power_domains_init_hw(dev);
 
        i915_restore_state(dev);
        intel_opregion_setup(dev);
drivers/gpu/drm/i915/intel_drv.h +3 -3
index bf4394a..9d2624f 100644
@@ -823,15 +823,15 @@ bool intel_fbc_enabled(struct drm_device *dev);
 void intel_update_fbc(struct drm_device *dev);
 void intel_gpu_ips_init(struct drm_i915_private *dev_priv);
 void intel_gpu_ips_teardown(void);
-int i915_init_power_well(struct drm_device *dev);
-void i915_remove_power_well(struct drm_device *dev);
+int intel_power_domains_init(struct drm_device *dev);
+void intel_power_domains_remove(struct drm_device *dev);
 bool intel_display_power_enabled(struct drm_device *dev,
                                 enum intel_display_power_domain domain);
 void intel_display_power_get(struct drm_device *dev,
                             enum intel_display_power_domain domain);
 void intel_display_power_put(struct drm_device *dev,
                             enum intel_display_power_domain domain);
-void intel_init_power_well(struct drm_device *dev);
+void intel_power_domains_init_hw(struct drm_device *dev);
 void intel_set_power_well(struct drm_device *dev, bool enable);
 void intel_enable_gt_powersave(struct drm_device *dev);
 void intel_disable_gt_powersave(struct drm_device *dev);
drivers/gpu/drm/i915/intel_pm.c +5 -6
index d2a640c..a0c907f 100644
@@ -5677,7 +5677,7 @@ void i915_release_power_well(void)
 }
 EXPORT_SYMBOL_GPL(i915_release_power_well);
 
-int i915_init_power_well(struct drm_device *dev)
+int intel_power_domains_init(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
        struct i915_power_domains *power_domains = &dev_priv->power_domains;
@@ -5692,12 +5692,12 @@ int i915_init_power_well(struct drm_device *dev)
        return 0;
 }
 
-void i915_remove_power_well(struct drm_device *dev)
+void intel_power_domains_remove(struct drm_device *dev)
 {
        hsw_pwr = NULL;
 }
 
-static void intel_resume_power_well(struct drm_device *dev)
+static void intel_power_domains_resume(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
        struct i915_power_domains *power_domains = &dev_priv->power_domains;
@@ -5720,7 +5720,7 @@ static void intel_resume_power_well(struct drm_device *dev)
  * to be enabled, and it will only be disabled if none of the registers is
  * requesting it to be enabled.
  */
-void intel_init_power_well(struct drm_device *dev)
+void intel_power_domains_init_hw(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
 
@@ -5729,7 +5729,7 @@ void intel_init_power_well(struct drm_device *dev)
 
        /* For now, we need the power well to be always enabled. */
        intel_display_set_init_power(dev, true);
-       intel_resume_power_well(dev);
+       intel_power_domains_resume(dev);
 
        /* We're taking over the BIOS, so clear any requests made by it since
         * the driver is in charge now. */
--

1.8.4

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

Signature · 1 line
Paulo Zanoni
#37 lore raw

Re: [PATCH v4] drm/i915: rename i915_init_power_well to init_power_domains_init

Quoted 15 lines · Paulo Zanoni

2013/10/28 Imre Deak <[email protected]>:

Quoted 14 lines

Similarly rename the other related functions in the power domain interface.

Higher level driver code calling these functions knows only about power domains, not the underlying power wells which may be different on different platforms. Also these functions really init/cleanup/resume power domains and only through that all related power wells, so rename them accordingly.

Note that I left i915_{request,release}_power_well as is, since that really changes the state only of a single power well (and is HSW specific). It should also get a better name once we make it more generic by controlling things through a new audio power domain.

Quoted 5 lines
Quoted 3 lines

v4:
- use intel prefix instead of i915 everywhere (Paulo)
- use a $prefix_$block_$action format (Daniel)

Queued for -next, thanks for the patch.
-Daniel

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