Skip to contentSkip to conversation

Power-well API implementation for Haswell

PATCH Superseded Wang Xingchao 3 participants 7 messages May 16, 2013 – May 20, 2013

Subsystems (3)

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v3 cover Power-well API implementation for Haswell

Hi all,

This is V3 and some fixes after Takashi's review. change between V2-->V3:
- make SND_HDA_I915 selectable
- use snd_printdd to output message
- add return error code check
- use symbol_request to replace symbol_get
- release power_well at azx_free
- some typo fixes

changes between V1-->V2:
- use reference count to track power-well usage
- remove external module, compiled into snd-hda-intel instead
- manage symbols and module loading properly
- remove IS_HSW macro, use flag instead
- remove audio callback for gfx driver to avoid dependency
- split whole patch into two pieces for easy review
- more typo fixes

Wang Xingchao (2):
drm/915: Add private api for power well usage
ALSA: hda - Add power-welll support for haswell HDA

 drivers/gpu/drm/i915/intel_pm.c |   76 +++++++++++++++++++++++++++++++++++----
 include/drm/i915_powerwell.h    |   36 +++++++++++++++++++
 sound/pci/hda/Kconfig           |   10 ++++++
 sound/pci/hda/Makefile          |    3 ++
 sound/pci/hda/hda_i915.c        |   75 ++++++++++++++++++++++++++++++++++++++
 sound/pci/hda/hda_i915.h        |   35 ++++++++++++++++++
 sound/pci/hda/hda_intel.c       |   41 +++++++++++++++++++--
 7 files changed, 262 insertions(+), 10 deletions(-)
 create mode 100644 include/drm/i915_powerwell.h
 create mode 100644 sound/pci/hda/hda_i915.c
 create mode 100644 sound/pci/hda/hda_i915.h
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v3 1/2 drm/915: Add private api for power well usage

Haswell Display audio depends on power well in graphic side, it should request power well before use it and release power well after use. I915 will not shutdown power well if it detects audio is using. This patch protects display audio crash for Intel Haswell C3 stepping board.

---
 drivers/gpu/drm/i915/intel_pm.c |   75 +++++++++++++++++++++++++++++++++++----
 include/drm/i915_powerwell.h    |   36 +++++++++++++++++++
 2 files changed, 104 insertions(+), 7 deletions(-)
 create mode 100644 include/drm/i915_powerwell.h
drivers/gpu/drm/i915/intel_pm.c +68 -7
index 0f4b46e..88820e1 100644
@@ -4344,18 +4344,12 @@ bool intel_using_power_well(struct drm_device *dev)
 		return true;
 }
 
-void intel_set_power_well(struct drm_device *dev, bool enable)
+static void enable_power_well(struct drm_device *dev, bool enable)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	bool is_enabled, enable_requested;
 	uint32_t tmp;
 
-	if (!HAS_POWER_WELL(dev))
-		return;
-
-	if (!i915_disable_power_well && !enable)
-		return;
-
 	tmp = I915_READ(HSW_PWR_WELL_DRIVER);
 	is_enabled = tmp & HSW_PWR_WELL_STATE;
 	enable_requested = tmp & HSW_PWR_WELL_ENABLE;
@@ -4378,6 +4372,73 @@ void intel_set_power_well(struct drm_device *dev, bool enable)
 	}
 }
 
+/* Global drm_device for display audio drvier usage */
+static struct drm_device *power_well_device;
+/* Lock protecting power well setting */
+static DEFINE_SPINLOCK(powerwell_lock);
+static bool i915_power_well_using;
+static int hsw_power_count;
+
+void i915_request_power_well(void)
+{
+	if (!power_well_device)
+		return;
+
+	if (!IS_HASWELL(power_well_device))
+		return;
+
+	spin_lock_irq(&powerwell_lock);
+	if (!hsw_power_count++ && !i915_power_well_using)
+		enable_power_well(power_well_device, true);
+	spin_unlock_irq(&powerwell_lock);
+}
+EXPORT_SYMBOL_GPL(i915_request_power_well);
+
+void i915_release_power_well(void)
+{
+	if (!power_well_device)
+		return;
+
+	if (!IS_HASWELL(power_well_device))
+		return;
+
+	spin_lock_irq(&powerwell_lock);
+	WARN_ON(!hsw_power_count);
+	if (!--hsw_power_count
+			&& !i915_power_well_using)
+		enable_power_well(power_well_device, false);
+	spin_unlock_irq(&powerwell_lock);
+}
+EXPORT_SYMBOL_GPL(i915_release_power_well);
+
+/* TODO: Call this when i915 module unload */
+void i915_remove_power_well(void)
+{
+	i915_power_well_using = false;
+	power_well_device = NULL;
+}
+
+void intel_set_power_well(struct drm_device *dev, bool enable)
+{
+	if (!HAS_POWER_WELL(dev))
+		return;
+
+	power_well_device = dev;
+	spin_lock_irq(&powerwell_lock);
+	i915_power_well_using = enable;
+	if (!enable && hsw_power_count) {
+		DRM_DEBUG_KMS("Display audio power well busy using now\n");
+		goto out;
+	}
+
+	if (!i915_disable_power_well && !enable)
+		goto out;
+
+	enable_power_well(dev, enable);
+out:
+	spin_unlock_irq(&powerwell_lock);
+}
+
 /*
  * Starting with Haswell, we have a "Power Down Well" that can be turned off
  * when not needed anymore. We have 4 registers that can request the power well
include/drm/i915_powerwell.h new file +36 -0
new file mode 100644
index 0000000..cfdc884
@@ -0,0 +1,36 @@
+/**************************************************************************
+ *
+ * Copyright 2013 Intel Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ **************************************************************************/
+
+#ifndef _I915_POWERWELL_H_
+#define _I915_POWERWELL_H_
+
+/* For use by hda_i915 driver */
+extern void i915_request_power_well(void);
+extern void i915_release_power_well(void);
+
+#endif				/* _I915_POWERWELL_H_ */
Signature · 1 line
1.7.9.5
#2 lore raw

Re: [PATCH 1/2 V3] drm/915: Add private api for power well usage

A few comments and questions below.

Quoted 17 lines · On Thu, 16 May 2013 15:52:36 +0800 Wang Xingchao…

Haswell Display audio depends on power well in graphic side, it should request power well before use it and release power well after use. I915 will not shutdown power well if it detects audio is using. This patch protects display audio crash for Intel Haswell C3 stepping board.

---
 drivers/gpu/drm/i915/intel_pm.c |   75 +++++++++++++++++++++++++++++++++++----
 include/drm/i915_powerwell.h    |   36 +++++++++++++++++++
 2 files changed, 104 insertions(+), 7 deletions(-)
 create mode 100644 include/drm/i915_powerwell.h
drivers/gpu/drm/i915/intel_pm.c +0 -0
index 0f4b46e..88820e1 100644

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

Quoted 5 lines
drivers/gpu/drm/i915/intel_pm.c +1 -1
@@ -4344,18 +4344,12 @@ bool intel_using_power_well(struct drm_device *dev)
 		return true;
 }
 
-void intel_set_power_well(struct drm_device *dev, bool enable)
+static void enable_power_well(struct drm_device *dev, bool enable)

We can leave the name of this function alone; even for static stuff we tend to use the intel_ prefix. Plus it's a set function, not an enable function... so maybe just put a __ in front of it to indicate it's for internal use only.

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

Quoted 12 lines
drivers/gpu/drm/i915/intel_pm.c +5 -0
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	bool is_enabled, enable_requested;
 	uint32_t tmp;
 
 
 
+/* Global drm_device for display audio drvier usage */
+static struct drm_device *power_well_device;
+/* Lock protecting power well setting */
+static DEFINE_SPINLOCK(powerwell_lock);
+static bool i915_power_well_using;

What does this mean? If it's just for making sure we don't use bogus power_well_device, it seems like we can just use a NULL check against power_well_device for that instead.

Quoted 51 lines
drivers/gpu/drm/i915/intel_pm.c +51 -0
+static int hsw_power_count;
+
+void i915_request_power_well(void)
+{
+	if (!power_well_device)
+		return;
+
+	if (!IS_HASWELL(power_well_device))
+		return;
+
+	spin_lock_irq(&powerwell_lock);
+	if (!hsw_power_count++ && !i915_power_well_using)
+		enable_power_well(power_well_device, true);
+	spin_unlock_irq(&powerwell_lock);
+}
+EXPORT_SYMBOL_GPL(i915_request_power_well);
+
+void i915_release_power_well(void)
+{
+	if (!power_well_device)
+		return;
+
+	if (!IS_HASWELL(power_well_device))
+		return;
+
+	spin_lock_irq(&powerwell_lock);
+	WARN_ON(!hsw_power_count);
+	if (!--hsw_power_count
+			&& !i915_power_well_using)
+		enable_power_well(power_well_device, false);
+	spin_unlock_irq(&powerwell_lock);
+}
+EXPORT_SYMBOL_GPL(i915_release_power_well);
+
+/* TODO: Call this when i915 module unload */
+void i915_remove_power_well(void)
+{
+	i915_power_well_using = false;
+	power_well_device = NULL;
+}
+
+void intel_set_power_well(struct drm_device *dev, bool enable)
+{
+	if (!HAS_POWER_WELL(dev))
+		return;
+
+	power_well_device = dev;
+	spin_lock_irq(&powerwell_lock);
+	i915_power_well_using = enable;
+	if (!enable && hsw_power_count) {
+		DRM_DEBUG_KMS("Display audio power well busy using now\n");

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

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10 -0
+		goto out;
+	}
+
+	if (!i915_disable_power_well && !enable)
+		goto out;
+
+	enable_power_well(dev, enable);
+out:
+	spin_unlock_irq(&powerwell_lock);
+}

I think we should just set the power_well_device at module init time, then ou wouldn't need to check/set it here.

Also, the existing i915 code could just use the request/release functions too (internal versions taking a drm_device *), then you wouldn't need this special case.

drivers/gpu/drm/i915/intel_pm.c

Quoted 3 lines
drivers/gpu/drm/i915/intel_pm.c +3 -0
+/* For use by hda_i915 driver */
+extern void i915_request_power_well(void);
+extern void i915_release_power_well(void);

For future proofing, it might be good if these took an enum for the power well being requested. Then we could track an array of refcounts later when we need the additional controls.

But I suppose that could be added later when we have a better idea of what future chips will look like.

Jesse

#3 lore raw

Re: [PATCH 1/2 V3] drm/915: Add private api for power well usage

Hi Jesse,

Quoted 37 lines

-----Original Message-----
From: Barnes, Jesse
Sent: Friday, May 17, 2013 11:44 PM
To: Wang Xingchao
Cc: [email protected]; [email protected]; Girdwood, Liam R; [email protected]; Lin, Mengdong; Li, Jocelyn; [email protected]; [email protected]; Zanoni, Paulo R; Wang, Xingchao
Subject: Re: [PATCH 1/2 V3] drm/915: Add private api for power well usage

A few comments and questions below.

Quoted 8 lines · On Thu, 16 May 2013 15:52:36 +0800 Wang Xingchao…

Haswell Display audio depends on power well in graphic side, it should request power well before use it and release power well after use. I915 will not shutdown power well if it detects audio is using. This patch protects display audio crash for Intel Haswell C3 stepping board.

---
 drivers/gpu/drm/i915/intel_pm.c |   75

+++++++++++++++++++++++++++++++++++----

drivers/gpu/drm/i915/intel_pm.c bool intel_using_power_well(struct drm_device

Quoted 9 lines
 include/drm/i915_powerwell.h    |   36 +++++++++++++++++++
 2 files changed, 104 insertions(+), 7 deletions(-)  create mode

100644 include/drm/i915_powerwell.h

(quoted diff) +0 -0

b/drivers/gpu/drm/i915/intel_pm.c index 0f4b46e..88820e1 100644

drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -4344,18 +4344,12 @@ bool intel_using_power_well(struct drm_device

*dev)

Quoted 3 lines
drivers/gpu/drm/i915/intel_pm.c +0 -0
 		return true;
 }
 
Quoted 6 lines

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

Quoted 2 lines
drivers/gpu/drm/i915/intel_pm.c +1 -1
-void intel_set_power_well(struct drm_device *dev, bool enable)
+static void enable_power_well(struct drm_device *dev, bool enable)

We can leave the name of this function alone; even for static stuff we tend to use the intel_ prefix. Plus it's a set function, not an enable function... so maybe just put a __ in front of it to indicate it's for internal use only.

Changed in next version patch.

Quoted 8 lines
Quoted 6 lines
drivers/gpu/drm/i915/intel_pm.c +0 -0
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	bool is_enabled, enable_requested;
 	uint32_t tmp;
 
Quoted 8 lines

drivers/gpu/drm/i915/intel_pm.c bool intel_using_power_well(struct drm_device

Quoted 4 lines
drivers/gpu/drm/i915/intel_pm.c +4 -0
+/* Global drm_device for display audio drvier usage */ static struct
+drm_device *power_well_device;
+/* Lock protecting power well setting */ static
+DEFINE_SPINLOCK(powerwell_lock); static bool i915_power_well_using;

What does this mean? If it's just for making sure we don't use bogus power_well_device, it seems like we can just use a NULL check against power_well_device for that instead.

I915_power_well_using is used to track whether i915 module using power well.
If i915 module had "disable" request, audio driver would shut down power well at its release caller.

Quoted 64 lines
Quoted 50 lines
drivers/gpu/drm/i915/intel_pm.c +49 -0
+static int hsw_power_count;
+
+void i915_request_power_well(void)
+{
+	if (!power_well_device)
+		return;
+
+	if (!IS_HASWELL(power_well_device))
+		return;
+
+	spin_lock_irq(&powerwell_lock);
+	if (!hsw_power_count++ && !i915_power_well_using)
+		enable_power_well(power_well_device, true);
+	spin_unlock_irq(&powerwell_lock);
+}
+EXPORT_SYMBOL_GPL(i915_request_power_well);
+
+void i915_release_power_well(void)
+{
+	if (!power_well_device)
+		return;
+
+	if (!IS_HASWELL(power_well_device))
+		return;
+
+	spin_lock_irq(&powerwell_lock);
+	WARN_ON(!hsw_power_count);
+	if (!--hsw_power_count
+			&& !i915_power_well_using)
+		enable_power_well(power_well_device, false);
+	spin_unlock_irq(&powerwell_lock);
+}
+EXPORT_SYMBOL_GPL(i915_release_power_well);
+
+/* TODO: Call this when i915 module unload */ void
+i915_remove_power_well(void) {
+	i915_power_well_using = false;
+	power_well_device = NULL;
+}
+
+void intel_set_power_well(struct drm_device *dev, bool enable) {
+	if (!HAS_POWER_WELL(dev))
+		return;
+
+	power_well_device = dev;
+	spin_lock_irq(&powerwell_lock);
+	i915_power_well_using = enable;
+	if (!enable && hsw_power_count) {
+		DRM_DEBUG_KMS("Display audio power well busy using now\n");

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

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10 -0
+		goto out;
+	}
+
+	if (!i915_disable_power_well && !enable)
+		goto out;
+
+	enable_power_well(dev, enable);
+out:
+	spin_unlock_irq(&powerwell_lock);
+}

I think we should just set the power_well_device at module init time, then ou wouldn't need to check/set it here.

Quoted 3 lines

Also, the existing i915 code could just use the request/release functions too (internal versions taking a drm_device *), then you wouldn't need this special case.

It's good that if i915 module could use such request/release function, then the power_count could be used to track the both audio driver and i915 driver. I've reworked a new version patch to let i915 use power_count too. But in fact it would introduce new issue: i915 may call intel_wet_power_well() several times to enable power well, but only disable once. That makes conflicts to use the single power_count.

I'm thinking to solve it by:
- use different count number for i915 driver.
- filter useless enable request from i915.

I'm testing the new patchset and would send it out after everything works for me.

Quoted 9 lines

drivers/gpu/drm/i915/intel_pm.c

Quoted 4 lines
drivers/gpu/drm/i915/intel_pm.c +3 -0
+/* For use by hda_i915 driver */
+extern void i915_request_power_well(void); extern void
+i915_release_power_well(void);

For future proofing, it might be good if these took an enum for the power well being requested. Then we could track an array of refcounts later when we need the additional controls.

Quoted 4 lines

But I suppose that could be added later when we have a better idea of what future chips will look like.

Jesse

Thanks
--xingchao

#4 lore raw

Re: [PATCH 1/2 V3] drm/915: Add private api for power well usage

In reply to Jesse Barnes

Hi Jesse,

Quoted 123 lines

-----Original Message-----
From: Barnes, Jesse
Sent: Friday, May 17, 2013 11:44 PM
To: Wang Xingchao
Cc: [email protected]; [email protected]; Girdwood, Liam R; [email protected]; Lin, Mengdong; Li, Jocelyn; [email protected]; [email protected]; Zanoni, Paulo R; Wang, Xingchao
Subject: Re: [PATCH 1/2 V3] drm/915: Add private api for power well usage

A few comments and questions below.

Quoted 8 lines · On Thu, 16 May 2013 15:52:36 +0800 Wang Xingchao…

Haswell Display audio depends on power well in graphic side, it should request power well before use it and release power well after use. I915 will not shutdown power well if it detects audio is using. This patch protects display audio crash for Intel Haswell C3 stepping board.

---
 drivers/gpu/drm/i915/intel_pm.c |   75

+++++++++++++++++++++++++++++++++++----

drivers/gpu/drm/i915/intel_pm.c bool intel_using_power_well(struct drm_device

Quoted 9 lines
 include/drm/i915_powerwell.h    |   36 +++++++++++++++++++
 2 files changed, 104 insertions(+), 7 deletions(-)  create mode

100644 include/drm/i915_powerwell.h

(quoted diff) +0 -0

b/drivers/gpu/drm/i915/intel_pm.c index 0f4b46e..88820e1 100644

drivers/gpu/drm/i915/intel_pm.c +0 -0
@@ -4344,18 +4344,12 @@ bool intel_using_power_well(struct drm_device

*dev)

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

Quoted 5 lines
drivers/gpu/drm/i915/intel_pm.c +1 -1
 		return true;
 }
 
-void intel_set_power_well(struct drm_device *dev, bool enable)
+static void enable_power_well(struct drm_device *dev, bool enable)

We can leave the name of this function alone; even for static stuff we tend to use the intel_ prefix. Plus it's a set function, not an enable function... so maybe just put a __ in front of it to indicate it's for internal use only.

drivers/gpu/drm/i915/intel_pm.c bool intel_using_power_well(struct drm_device

Quoted 11 lines
drivers/gpu/drm/i915/intel_pm.c +4 -0
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	bool is_enabled, enable_requested;
 	uint32_t tmp;
 
 
 
+/* Global drm_device for display audio drvier usage */ static struct
+drm_device *power_well_device;
+/* Lock protecting power well setting */ static
+DEFINE_SPINLOCK(powerwell_lock); static bool i915_power_well_using;

What does this mean? If it's just for making sure we don't use bogus power_well_device, it seems like we can just use a NULL check against power_well_device for that instead.

Quoted 49 lines
drivers/gpu/drm/i915/intel_pm.c +49 -0
+static int hsw_power_count;
+
+void i915_request_power_well(void)
+{
+	if (!power_well_device)
+		return;
+
+	if (!IS_HASWELL(power_well_device))
+		return;
+
+	spin_lock_irq(&powerwell_lock);
+	if (!hsw_power_count++ && !i915_power_well_using)
+		enable_power_well(power_well_device, true);
+	spin_unlock_irq(&powerwell_lock);
+}
+EXPORT_SYMBOL_GPL(i915_request_power_well);
+
+void i915_release_power_well(void)
+{
+	if (!power_well_device)
+		return;
+
+	if (!IS_HASWELL(power_well_device))
+		return;
+
+	spin_lock_irq(&powerwell_lock);
+	WARN_ON(!hsw_power_count);
+	if (!--hsw_power_count
+			&& !i915_power_well_using)
+		enable_power_well(power_well_device, false);
+	spin_unlock_irq(&powerwell_lock);
+}
+EXPORT_SYMBOL_GPL(i915_release_power_well);
+
+/* TODO: Call this when i915 module unload */ void
+i915_remove_power_well(void) {
+	i915_power_well_using = false;
+	power_well_device = NULL;
+}
+
+void intel_set_power_well(struct drm_device *dev, bool enable) {
+	if (!HAS_POWER_WELL(dev))
+		return;
+
+	power_well_device = dev;
+	spin_lock_irq(&powerwell_lock);
+	i915_power_well_using = enable;
+	if (!enable && hsw_power_count) {
+		DRM_DEBUG_KMS("Display audio power well busy using now\n");

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

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10 -0
+		goto out;
+	}
+
+	if (!i915_disable_power_well && !enable)
+		goto out;
+
+	enable_power_well(dev, enable);
+out:
+	spin_unlock_irq(&powerwell_lock);
+}

I think we should just set the power_well_device at module init time, then ou wouldn't need to check/set it here.

Quoted 3 lines

Also, the existing i915 code could just use the request/release functions too (internal versions taking a drm_device *), then you wouldn't need this special case.

It's not a good idea to use the same reference count to track power-well calling for both audio and i915 driver. For audio driver the calling request/release are symmetrical, but for i915 driver it's not.
In my test, i915 request power-well 3 times, but release power-well 5 times. That obviously caused conflicts.

Quoted 9 lines

drivers/gpu/drm/i915/intel_pm.c

Quoted 4 lines
drivers/gpu/drm/i915/intel_pm.c +3 -0
+/* For use by hda_i915 driver */
+extern void i915_request_power_well(void); extern void
+i915_release_power_well(void);

For future proofing, it might be good if these took an enum for the power well being requested. Then we could track an array of refcounts later when we need the additional controls.

Quoted 4 lines

But I suppose that could be added later when we have a better idea of what future chips will look like.

Jesse

thanks
--xingchao

#5 lore raw

PATCH v3 2/2 ALSA: hda - Add power-welll support for haswell HDA

In reply to Wang Xingchao

For Intel Haswell chip, HDA controller and codec have power well dependency from GPU side. This patch added support to request/release power well in audio driver. Power save feature should be enabled to get runtime power saving.

---
 sound/pci/hda/Kconfig     |   10 ++++++
 sound/pci/hda/Makefile    |    3 ++
 sound/pci/hda/hda_i915.c  |   75 +++++++++++++++++++++++++++++++++++++++++++++
 sound/pci/hda/hda_i915.h  |   35 +++++++++++++++++++++
 sound/pci/hda/hda_intel.c |   41 +++++++++++++++++++++++--
 5 files changed, 161 insertions(+), 3 deletions(-)
 create mode 100644 sound/pci/hda/hda_i915.c
 create mode 100644 sound/pci/hda/hda_i915.h
sound/pci/hda/Kconfig +10 -0
index 80a7d44..c5a872c 100644
@@ -152,6 +152,16 @@ config SND_HDA_CODEC_HDMI
 	  snd-hda-codec-hdmi.
 	  This module is automatically loaded at probing.
 
+config SND_HDA_I915
+	bool "Build Display HD-audio controller/codec power well support for i915 cards"
+	depends on DRM_I915
+	help
+	  Say Y here to include full HDMI and DisplayPort HD-audio controller/codec
+	  power-well support for Intel Haswell graphics cards based on the i915 driver.
+
+	  Note that this option must be enabled for Intel Haswell C+ stepping machines, otherwise
+	  the GPU audio controller/codecs will not be initialized or damaged when exit from S3 mode.
+
 config SND_HDA_CODEC_CIRRUS
 	bool "Build Cirrus Logic codec support"
 	default y
sound/pci/hda/Makefile +3 -0
index 24a2514..4b0a4bc 100644
@@ -6,6 +6,9 @@ snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o
 snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o
 snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o
 
+# for haswell power well
+snd-hda-intel-$(CONFIG_SND_HDA_I915) +=	hda_i915.o
+
 # for trace-points
 CFLAGS_hda_codec.o := -I$(src)
 CFLAGS_hda_intel.o := -I$(src)
sound/pci/hda/hda_i915.c new file +75 -0

75 lines not on this page · raw message

sound/pci/hda/hda_i915.h new file +35 -0
new file mode 100644
index 0000000..4b89dfc
@@ -0,0 +1,35 @@
+/*
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  This program is distributed in the hope that it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ *  more details.
+ *
+ *  You should have received a copy of the GNU General Public License along with
+ *  this program; if not, write to the Free Software Foundation, Inc., 59
+ *  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+#ifndef __SOUND_HDA_I915_H
+#define __SOUND_HDA_I915_H
+
+#ifdef CONFIG_SND_HDA_I915
+void hda_display_power(bool enable);
+int hda_i915_init(void);
+int hda_i915_exit(void);
+#else
+static inline void hda_display_power(bool enable) {}
+static inline int hda_i915_init(void)
+{
+	return -ENODEV;
+}
+static inline int hda_i915_exit(void)
+{
+	return 0;
+}
+#endif
+
+#endif
sound/pci/hda/hda_intel.c +38 -3

109 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#6 lore raw
In reply to Wang Xingchao

Hi Daniel,

Do you have further comments on this patchset?

thanks
--xingchao

Quoted 48 lines

-----Original Message-----
From: Wang Xingchao [mailto:[email protected]]
Sent: Thursday, May 16, 2013 3:53 PM
To: [email protected]; [email protected]; Girdwood, Liam R
Cc: [email protected]; Lin, Mengdong; Li, Jocelyn; [email protected]; [email protected]; Barnes, Jesse; Zanoni, Paulo R; Wang, Xingchao; Wang Xingchao
Subject: [PATCH 0/2 V3] Power-well API implementation for Haswell

Hi all,

This is V3 and some fixes after Takashi's review. change between V2-->V3:
- make SND_HDA_I915 selectable
- use snd_printdd to output message
- add return error code check
- use symbol_request to replace symbol_get
- release power_well at azx_free
- some typo fixes

changes between V1-->V2:
- use reference count to track power-well usage
- remove external module, compiled into snd-hda-intel instead
- manage symbols and module loading properly
- remove IS_HSW macro, use flag instead
- remove audio callback for gfx driver to avoid dependency
- split whole patch into two pieces for easy review
- more typo fixes

Wang Xingchao (2):
drm/915: Add private api for power well usage
ALSA: hda - Add power-welll support for haswell HDA

 drivers/gpu/drm/i915/intel_pm.c |   76
+++++++++++++++++++++++++++++++++++----
 include/drm/i915_powerwell.h    |   36 +++++++++++++++++++
 sound/pci/hda/Kconfig           |   10 ++++++
 sound/pci/hda/Makefile          |    3 ++
 sound/pci/hda/hda_i915.c        |   75
++++++++++++++++++++++++++++++++++++++
 sound/pci/hda/hda_i915.h        |   35 ++++++++++++++++++
 sound/pci/hda/hda_intel.c       |   41 +++++++++++++++++++--
 7 files changed, 262 insertions(+), 10 deletions(-)  create mode 100644

include/drm/i915_powerwell.h create mode 100644 sound/pci/hda/hda_i915.c create mode 100644 sound/pci/hda/hda_i915.h

--
1.7.9.5