Power-well API implementation for Haswell
Subsystems (3)
v4 cover Power-well API implementation for Haswell
Hi all,
This is V4 and here're some changes notes:
change between V3-->V4:
- add new structure i915_power_well
- initialize drm_device pointer at module init time
- change function name
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):
i915/drm: Add private api for power well usage
ALSA: hda - Add power-welll support for haswell HDA
drivers/gpu/drm/i915/i915_dma.c | 6 +++ drivers/gpu/drm/i915/i915_drv.h | 12 +++++ drivers/gpu/drm/i915/intel_drv.h | 4 ++ drivers/gpu/drm/i915/intel_pm.c | 98 +++++++++++++++++++++++++++++++++++--- 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 ++++++++++++++-- 10 files changed, 310 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
PATCH v4 1/2 i915/drm: 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/i915_dma.c | 6 +++ drivers/gpu/drm/i915/i915_drv.h | 12 +++++ drivers/gpu/drm/i915/intel_drv.h | 4 ++ drivers/gpu/drm/i915/intel_pm.c | 98 +++++++++++++++++++++++++++++++++++--- include/drm/i915_powerwell.h | 36 ++++++++++++++ 5 files changed, 149 insertions(+), 7 deletions(-) create mode 100644 include/drm/i915_powerwell.h
drivers/gpu/drm/i915/i915_dma.c +6 -0
@@ -1652,6 +1652,9 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)/* Start out suspended */ dev_priv->mm.suspended =1 ; +if (IS_HASWELL (dev)) +i915_init_power_well (dev); +if (drm_core_check_feature (dev,DRIVER_MODESET )) { ret =i915_load_modeset_init (dev);if (ret <0 ) {
@@ -1708,6 +1711,9 @@ int i915_driver_unload(struct drm_device *dev)intel_gpu_ips_teardown (); +if (IS_HASWELL (dev)) +i915_remove_power_well (dev); +i915_teardown_sysfs (dev);if (dev_priv->mm.inactive_shrinker.shrink)
drivers/gpu/drm/i915/i915_drv.h +12 -0
@@ -702,6 +702,15 @@ struct intel_ilk_power_mgmt {struct drm_i915_gem_object *renderctx; }; +/* Power well structure for haswell */ +struct i915_power_well { +struct drm_device *device; +spinlock_t lock; +/* power well enable/disable usage count */ +int count; +int i915_request; +}; +struct i915_dri1_state {unsigned allow_batchbuffer :1 ;u32 __iomem *gfx_hws_cpu_addr;
@@ -1048,6 +1057,9 @@ typedef struct drm_i915_private {* mchdev_lock in intel_pm.c */ struct intel_ilk_power_mgmt ips; +/* Haswell power well */ +struct i915_power_well *hsw_pwr; +enum no_fbc_reason no_fbc_reason;struct drm_mm_node *compressed_fb;
drivers/gpu/drm/i915/intel_drv.h +4 -0
@@ -759,6 +759,10 @@ extern void intel_update_fbc(struct drm_device *dev);extern void intel_gpu_ips_init (struct drm_i915_private *dev_priv);extern void intel_gpu_ips_teardown (void ); +/* Power well */ +extern int i915_init_power_well (struct drm_device *dev); +extern void i915_remove_power_well (struct drm_device *dev); +extern bool intel_using_power_well (struct drm_device *dev);extern void intel_init_power_well (struct drm_device *dev);extern void intel_set_power_well (struct drm_device *dev,bool enable);
drivers/gpu/drm/i915/intel_pm.c +91 -7
115 lines not on this page · raw message
include/drm/i915_powerwell.h new file +36 -0
@@ -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
Re: [PATCH 1/2 V4] i915/drm: Add private api for power well usage
At Mon, 20 May 2013 19:26:57 +0800,
Quoted 139 lines · 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.
Signed-off-by Wang Xingchao <[email protected]>--- drivers/gpu/drm/i915/i915_dma.c | 6 +++ drivers/gpu/drm/i915/i915_drv.h | 12 +++++ drivers/gpu/drm/i915/intel_drv.h | 4 ++ drivers/gpu/drm/i915/intel_pm.c | 98 +++++++++++++++++++++++++++++++++++--- include/drm/i915_powerwell.h | 36 ++++++++++++++ 5 files changed, 149 insertions(+), 7 deletions(-) create mode 100644 include/drm/i915_powerwell.hdrivers/gpu/drm/i915/i915_dma.c +6
-0@@ -1652,6 +1652,9 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)/* Start out suspended */ dev_priv->mm.suspended =1 ; +if (IS_HASWELL (dev)) +i915_init_power_well (dev); +if (drm_core_check_feature (dev,DRIVER_MODESET )) { ret =i915_load_modeset_init (dev);if (ret <0 ) {@@ -1708,6 +1711,9 @@ int i915_driver_unload(struct drm_device *dev)intel_gpu_ips_teardown (); +if (IS_HASWELL (dev)) +i915_remove_power_well (dev); +i915_teardown_sysfs (dev);if (dev_priv->mm.inactive_shrinker.shrink)drivers/gpu/drm/i915/i915_drv.h +12
-0@@ -702,6 +702,15 @@ struct intel_ilk_power_mgmt {struct drm_i915_gem_object *renderctx; }; +/* Power well structure for haswell */ +struct i915_power_well { +struct drm_device *device; +spinlock_t lock; +/* power well enable/disable usage count */ +int count; +int i915_request; +}; +struct i915_dri1_state {unsigned allow_batchbuffer :1 ;u32 __iomem *gfx_hws_cpu_addr;@@ -1048,6 +1057,9 @@ typedef struct drm_i915_private {* mchdev_lock in intel_pm.c */ struct intel_ilk_power_mgmt ips; +/* Haswell power well */ +struct i915_power_well *hsw_pwr; +enum no_fbc_reason no_fbc_reason;struct drm_mm_node *compressed_fb;drivers/gpu/drm/i915/intel_drv.h +4
-0@@ -759,6 +759,10 @@ extern void intel_update_fbc(struct drm_device *dev);extern void intel_gpu_ips_init (struct drm_i915_private *dev_priv);extern void intel_gpu_ips_teardown (void ); +/* Power well */ +extern int i915_init_power_well (struct drm_device *dev); +extern void i915_remove_power_well (struct drm_device *dev); +extern bool intel_using_power_well (struct drm_device *dev);extern void intel_init_power_well (struct drm_device *dev);extern void intel_set_power_well (struct drm_device *dev,bool enable);drivers/gpu/drm/i915/intel_pm.c +27
-7@@ -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 __intel_set_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,96 @@ void intel_set_power_well(struct drm_device *dev, bool enable) } } +static struct i915_power_well *hsw_pwr; + +/* Display audio driver power well request */ +void i915_request_power_well (void ) +{ +if (hsw_pwr ==NULL ) +return ; + +spin_lock_irq (&hsw_pwr->lock); +if (!hsw_pwr->count++ && + !hsw_pwr->i915_request) +__intel_set_power_well (hsw_pwr->device, true); +spin_unlock_irq (&hsw_pwr->lock); +} +EXPORT_SYMBOL_GPL (i915_request_power_well); + +/* Display audio driver power well release */ +void i915_release_power_well (void ) +{ +if (hsw_pwr ==NULL ) +return ; + +spin_lock_irq (&hsw_pwr->lock); + +/* i915 using power well */ +if (hsw_pwr->i915_request) {
drivers/gpu/drm/i915/intel_pm.c void intel_set_power_well(struct drm_device *dev, bool enable) · line 4410
Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10
-0+spin_unlock_irq (&hsw_pwr->lock); +return ; + } + +WARN_ON (!hsw_pwr->count); +if (!--hsw_pwr->count) +__intel_set_power_well (hsw_pwr->device, false); +spin_unlock_irq (&hsw_pwr->lock); +} +EXPORT_SYMBOL_GPL (i915_release_power_well);
This will result in unbalanced refcount.
When i915_request is true, the count will be never decreased.
Takashi
Quoted 102 lines
drivers/gpu/drm/i915/intel_pm.c +54
-0+ +int i915_init_power_well (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv = dev->dev_private; + + hsw_pwr =kzalloc (sizeof *hsw_pwr,GFP_KERNEL ); +if (hsw_pwr ==NULL ) +return -ENOMEM ; + + dev_priv->hsw_pwr = hsw_pwr; + + hsw_pwr->device = dev; +spin_lock_init (&hsw_pwr->lock); + hsw_pwr->count =0 ; + +return 0 ; +} + +void i915_remove_power_well (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv = dev->dev_private; + +kfree (dev_priv->hsw_pwr); + dev_priv->hsw_pwr =NULL ; + 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->hsw_pwr; + +if (!HAS_POWER_WELL (dev)) +return ; + +if (!i915_disable_power_well && !enable) +return ; + +if (!power_well) +return ; + +spin_lock_irq (&power_well->lock); + power_well->i915_request = enable; + +/* only reject "disable" power well request */ +if (power_well->count && !enable) { +spin_unlock_irq (&power_well->lock); +return ; + } + +__intel_set_power_well (dev, enable); +spin_unlock_irq (&power_well->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@@ -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
Re: [PATCH 1/2 V4] i915/drm: Add private api for power well usage
Quoted 159 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Tuesday, May 21, 2013 3:18 PM
To: Wang Xingchao
Cc: [email protected]; Girdwood, Liam R; [email protected]; Lin, Mengdong; Li, Jocelyn; [email protected]; [email protected]; Barnes, Jesse; Zanoni, Paulo R; Wang, Xingchao
Subject: Re: [PATCH 1/2 V4] i915/drm: Add private api for power well usageAt Mon, 20 May 2013 19:26:57 +0800,
Quoted 6 lines · 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.
Quoted 6 lines
Signed-off-by Wang Xingchao <[email protected]>--- drivers/gpu/drm/i915/i915_dma.c | 6 +++ drivers/gpu/drm/i915/i915_drv.h | 12 +++++ drivers/gpu/drm/i915/intel_drv.h | 4 ++ drivers/gpu/drm/i915/intel_pm.c | 98+++++++++++++++++++++++++++++++++++---
drivers/gpu/drm/i915/i915_dma.c int i915_driver_load(struct drm_device *dev,
Quoted 9 lines
include/drm/i915_powerwell.h | 36 ++++++++++++++ 5 files changed, 149 insertions(+), 7 deletions(-) create mode100644
include/drm/i915_powerwell.h(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_dma.cindex a1648eb..2b9010a 100644drivers/gpu/drm/i915/i915_dma.c +0
-0@@ -1652,6 +1652,9 @@ int i915_driver_load(struct drm_device *dev,unsigned long flags)
drivers/gpu/drm/i915/intel_pm.c bool intel_using_power_well(struct drm_device
Quoted 68 lines
drivers/gpu/drm/i915/i915_dma.c +6
-0/* Start out suspended */ dev_priv->mm.suspended =1 ; +if (IS_HASWELL (dev)) +i915_init_power_well (dev); +if (drm_core_check_feature (dev,DRIVER_MODESET )) { ret =i915_load_modeset_init (dev);if (ret <0 ) {@@ -1708,6 +1711,9 @@ int i915_driver_unload(struct drm_device *dev)intel_gpu_ips_teardown (); +if (IS_HASWELL (dev)) +i915_remove_power_well (dev); +i915_teardown_sysfs (dev);if (dev_priv->mm.inactive_shrinker.shrink)(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_drv.hindex 3ac71db..a0f1a6d 100644drivers/gpu/drm/i915/i915_drv.h +11
-0@@ -702,6 +702,15 @@ struct intel_ilk_power_mgmt {struct drm_i915_gem_object *renderctx; }; +/* Power well structure for haswell */ struct i915_power_well { +struct drm_device *device; +spinlock_t lock; +/* power well enable/disable usage count */ +int count; +int i915_request; +}; +struct i915_dri1_state {unsigned allow_batchbuffer :1 ;u32 __iomem *gfx_hws_cpu_addr;@@ -1048,6 +1057,9 @@ typedef struct drm_i915_private {* mchdev_lock in intel_pm.c */ struct intel_ilk_power_mgmt ips; +/* Haswell power well */ +struct i915_power_well *hsw_pwr; +enum no_fbc_reason no_fbc_reason;struct drm_mm_node *compressed_fb;drivers/gpu/drm/i915/intel_drv.h +4
-0@@ -759,6 +759,10 @@ extern void intel_update_fbc(struct drm_device *dev); extern void intel_gpu_ips_init(struct drm_i915_private *dev_priv);extern void intel_gpu_ips_teardown (void ); +/* Power well */ +extern int i915_init_power_well (struct drm_device *dev);extern void +i915_remove_power_well (struct drm_device *dev); + extern bool intel_using_power_well(struct drm_device *dev); externvoid
intel_init_power_well(struct drm_device *dev); extern voidintel_set_power_well(struct drm_device *dev, bool enable); diff --gita/drivers/gpu/drm/i915/intel_pm.cb/drivers/gpu/drm/i915/intel_pm.cindex 0f4b46e..eec7aa8 100644drivers/gpu/drm/i915/intel_pm.c +0
-0@@ -4344,18 +4344,12 @@ bool intel_using_power_well(struct drm_device*dev)
Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +2
-1return true; } -void intel_set_power_well (struct drm_device *dev,bool enable) +static void __intel_set_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;drivers/gpu/drm/i915/intel_pm.c bool intel_using_power_well(struct drm_device *dev)
Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +0
-6-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,96 @@
Quoted 33 lines
void
intel_set_power_well(struct drm_device *dev, bool enable)drivers/gpu/drm/i915/intel_pm.c +29
-0} } +static struct i915_power_well *hsw_pwr; + +/* Display audio driver power well request */ void +i915_request_power_well (void ) { +if (hsw_pwr ==NULL ) +return ; + +spin_lock_irq (&hsw_pwr->lock); +if (!hsw_pwr->count++ && + !hsw_pwr->i915_request) +__intel_set_power_well (hsw_pwr->device, true); +spin_unlock_irq (&hsw_pwr->lock); +} +EXPORT_SYMBOL_GPL (i915_request_power_well); + +/* Display audio driver power well release */ void +i915_release_power_well (void ) { +if (hsw_pwr ==NULL ) +return ; + +spin_lock_irq (&hsw_pwr->lock); + +/* i915 using power well */ +if (hsw_pwr->i915_request) { +spin_unlock_irq (&hsw_pwr->lock); +return ; + } + +WARN_ON (!hsw_pwr->count);
Quoted 9 lines
drivers/gpu/drm/i915/intel_pm.c void intel_set_power_well(struct drm_device *dev, bool enable) · line 4410
Quoted 5 lines
drivers/gpu/drm/i915/intel_pm.c +5
-0+if (!--hsw_pwr->count) +__intel_set_power_well (hsw_pwr->device, false); +spin_unlock_irq (&hsw_pwr->lock); +} +EXPORT_SYMBOL_GPL (i915_release_power_well);This will result in unbalanced refcount.
Wheni915_requestis true, the count will be never decreased.
Thanks for pointing out this mistake. Will fix it for next version.
--xingchao
Quoted 127 lines
Takashi
Quoted 43 lines
drivers/gpu/drm/i915/intel_pm.c +43
-0+ +int i915_init_power_well (struct drm_device *dev) { +struct drm_i915_private *dev_priv = dev->dev_private; + + hsw_pwr =kzalloc (sizeof *hsw_pwr,GFP_KERNEL ); +if (hsw_pwr ==NULL ) +return -ENOMEM ; + + dev_priv->hsw_pwr = hsw_pwr; + + hsw_pwr->device = dev; +spin_lock_init (&hsw_pwr->lock); + hsw_pwr->count =0 ; + +return 0 ; +} + +void i915_remove_power_well (struct drm_device *dev) { +struct drm_i915_private *dev_priv = dev->dev_private; + +kfree (dev_priv->hsw_pwr); + dev_priv->hsw_pwr =NULL ; + 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->hsw_pwr; + +if (!HAS_POWER_WELL (dev)) +return ; + +if (!i915_disable_power_well && !enable) +return ; + +if (!power_well) +return ; + +spin_lock_irq (&power_well->lock); + power_well->i915_request = enable; + +/* only reject "disable" power well request */ +if (power_well->count && !enable) {drivers/gpu/drm/i915/intel_pm.c void intel_set_power_well(struct drm_device *dev, bool enable)
Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +8
-0+spin_unlock_irq (&power_well->lock); +return ; + } + +__intel_set_power_well (dev, enable); +spin_unlock_irq (&power_well->lock); +} +/* * Starting with Haswell, we have a "Power Down Well" that can be turned off
include/drm/i915_powerwell.h
Quoted 8 lines
* when not needed anymore. We have 4 registers that can request the
power well diff --gita/include/drm/i915_powerwell.hb/include/drm/i915_powerwell.hnew file mode 100644 index 0000000..cfdc884include/drm/i915_powerwell.h new file +0
-0@@ -0,0 +1,36 @@+/**************************************************************
******Quoted 15 lines
include/drm/i915_powerwell.h new file +15
-0+****** + * + * 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, subjectinclude/drm/i915_powerwell.h line 25
Quoted 10 lines
include/drm/i915_powerwell.h new file +10
-0+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 ANYKIND,
include/drm/i915_powerwell.h line 29
Quoted 4 lines
include/drm/i915_powerwell.h new file +4
-0+EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY , + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NOEVENT
include/drm/i915_powerwell.h line 31
Quoted 2 lines
include/drm/i915_powerwell.h new file +2
-0+SHALL + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLEFOR
include/drm/i915_powerwell.h line 33
Quoted 2 lines
include/drm/i915_powerwell.h new file +2
-0+ANY CLAIM , + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,TORT
include/drm/i915_powerwell.h line 35
Quoted 2 lines
include/drm/i915_powerwell.h new file +2
-0+OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THESOFTWARE
include/drm/i915_powerwell.h line 28
Quoted 6 lines
include/drm/i915_powerwell.h new file +5
-0+OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * ++***************************************************************
******Quoted 13 lines
include/drm/i915_powerwell.h new file +10
-1+*****/ + +#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_ */ --1.7.9.5
PATCH v4 2/2 ALSA: hda - Add power-welll support for haswell HDA
In reply to Wang XingchaoFor 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
@@ -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
@@ -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
@@ -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
Re: [PATCH 2/2 V4] ALSA: hda - Add power-welll support for haswell HDA
At Mon, 20 May 2013 19:26:58 +0800,
Quoted 270 lines · 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.
Signed-off-by Wang Xingchao <[email protected]>--- 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.hsound/pci/hda/Kconfig +10
-0@@ -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 ysound/pci/hda/Makefile +3
-0@@ -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@@ -0,0 +1,75 @@ +/* +* hda_i915.c - routines for Haswell HDA controller power well support +* +* 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. +*/ + +#include <linux/init.h> +#include <linux/module.h> +#include <sound/core.h> +#include <drm/i915_powerwell.h> +#include "hda_i915.h" + +static void (*get_power)(void ); +static void (*put_power)(void ); + +void hda_display_power (bool enable) +{ +if (!get_power || !put_power) +return ; + +snd_printdd ("HDA display power %s \n" , + enable ?"Enable" :"Disable" ); +if (enable) +get_power (); +else +put_power (); +} + +int hda_i915_init (void ) +{ +int err =0 ; + + get_power =symbol_request (i915_request_power_well); +if (!get_power) { +snd_printk (KERN_WARNING "hda-i915: get_power symbol get fail\n" ); +return -ENODEV ; + } + + put_power =symbol_request (i915_release_power_well); +if (!put_power) { +symbol_put (i915_request_power_well); + get_power =NULL ; +return -ENODEV ; + } + +snd_printd ("HDA driver get symbol successfully from i915 module\n" ); + +return err; +} + +int hda_i915_exit (void ) +{ +if (get_power) { +symbol_put (i915_request_power_well); + get_power =NULL ; + } +if (put_power) { +symbol_put (i915_release_power_well); + put_power =NULL ; + } + +return 0 ; +}sound/pci/hda/hda_i915.h new file +35
-0@@ -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 +28
-0@@ -62,6 +62,7 @@#include <linux/vga_switcheroo.h> #include <linux/firmware.h> #include "hda_codec.h" +#include "hda_i915.h" static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;@@ -594,6 +595,7 @@ enum {#define AZX_DCAPS_4K_BDLE_BOUNDARY (1 << 23)/* BDLE in 4k boundary */ #define AZX_DCAPS_COUNT_LPIB_DELAY (1 << 25)/* Take LPIB as delay */ #define AZX_DCAPS_PM_RUNTIME (1 << 26)/* runtime PM support */ +#define AZX_DCAPS_I915_POWERWELL (1 << 27)/* HSW i915 power well support */ /* quirks for Intel PCH */ #define AZX_DCAPS_INTEL_PCH_NOPM \@@ -2869,6 +2871,8 @@ static int azx_suspend(struct device *dev)pci_disable_device (pci);pci_save_state (pci);pci_set_power_state (pci, PCI_D3hot); +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL ) +hda_display_power (false);return 0 ; }@@ -2881,6 +2885,8 @@ static int azx_resume(struct device *dev)if (chip->disabled)return 0 ; +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL ) +hda_display_power (true);pci_set_power_state (pci,PCI_D0 );pci_restore_state (pci);if (pci_enable_device (pci) <0 ) {@@ -2913,6 +2919,8 @@ static int azx_runtime_suspend(struct device *dev)azx_stop_chip (chip);azx_clear_irq_pending (chip); +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL ) +hda_display_power (false);return 0 ; }@@ -2921,6 +2929,8 @@ static int azx_runtime_resume(struct device *dev)struct snd_card *card =dev_get_drvdata (dev);struct azx *chip = card->private_data; +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL ) +hda_display_power (true);azx_init_pci (chip);azx_init_chip (chip,1 );return 0 ;@@ -3144,6 +3154,10 @@ static int azx_free(struct azx *chip)if (chip->fw)release_firmware (chip->fw);#endif +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL ) { +hda_display_power (false); +hda_i915_exit (); + }kfree (chip);return 0 ;@@ -3700,6 +3714,19 @@ static int azx_probe(struct pci_dev *pci, chip->disabled = true; } +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL ) { +#ifdef CONFIG_SND_HDA_I915 + err =hda_i915_init (); +if (err <0 ) { + snd_printk(KERN_ERR SFX "Error request power-well from i915\n"); + goto out_free; + } +hda_display_power (true); +#else + snd_printk(KERN_ERR SFX "Haswell must build in CONFIG_SND_HDA_I915\n"); +#endif + } + probe_now = !chip->disabled;if (probe_now) { err =azx_first_init (chip);@@ -3799,6 +3826,7 @@ out_free:static void azx_remove (struct pci_dev *pci) {struct snd_card *card =pci_get_drvdata (pci); +struct azx *chip = card->private_data;if (pci_dev_run_wake (pci))pm_runtime_get_noresume (&pci->dev);
sound/pci/hda/hda_intel.c static void azx_remove(struct pci_dev *pci) · line 3840
Quoted 7 lines
sound/pci/hda/hda_intel.c +4
-0@@ -3806,6 +3834,10 @@ static void azx_remove(struct pci_dev *pci)if (card)snd_card_free (card);pci_set_drvdata (pci,NULL ); +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL ) { +hda_display_power (false); +hda_i915_exit (); + }
As mentioned in the previous post, you can't refer to chip instance at this point. It's been already freed in snd_card_free().
Takashi
Quoted 24 lines
sound/pci/hda/hda_intel.c +6
-3}/* PCI IDs */ @@ -3835,11 +3867,14 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = { .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH },/* Haswell */ { PCI_DEVICE(0x8086, 0x0a0c), - .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH }, + .driver_data =AZX_DRIVER_SCH |AZX_DCAPS_INTEL_PCH | + AZX_DCAPS_I915_POWERWELL }, { PCI_DEVICE(0x8086, 0x0c0c), - .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH }, + .driver_data =AZX_DRIVER_SCH |AZX_DCAPS_INTEL_PCH | + AZX_DCAPS_I915_POWERWELL }, { PCI_DEVICE(0x8086, 0x0d0c), - .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH }, + .driver_data =AZX_DRIVER_SCH |AZX_DCAPS_INTEL_PCH | + AZX_DCAPS_I915_POWERWELL }, /* 5 Series/3400 */ { PCI_DEVICE(0x8086, 0x3b56), .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH_NOPM },Signature · 1 line
1.7.9.5
Re: [PATCH 2/2 V4] ALSA: hda - Add power-welll support for haswell HDA
Quoted 304 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Tuesday, May 21, 2013 3:19 PM
To: Wang Xingchao
Cc: [email protected]; Girdwood, Liam R; [email protected]; Lin, Mengdong; Li, Jocelyn; [email protected]; [email protected]; Barnes, Jesse; Zanoni, Paulo R; Wang, Xingchao
Subject: Re: [PATCH 2/2 V4] ALSA: hda - Add power-welll support for haswell HDAAt Mon, 20 May 2013 19:26:58 +0800,
Quoted 11 lines · 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.
Signed-off-by Wang Xingchao <[email protected]>--- sound/pci/hda/Kconfig | 10 ++++++ sound/pci/hda/Makefile | 3 ++ sound/pci/hda/hda_i915.c | 75+++++++++++++++++++++++++++++++++++++++++++++
Quoted 11 lines
sound/pci/hda/hda_i915.h | 35 +++++++++++++++++++++ sound/pci/hda/hda_intel.c | 41 +++++++++++++++++++++++-- 5 files changed, 161 insertions(+), 3 deletions(-) create mode100644
sound/pci/hda/hda_i915.ccreate mode 100644sound/pci/hda/hda_i915.hsound/pci/hda/Kconfig index renamed from sound/pci/hda/Kconfig +0
-080a7d44..c5a872c 100644
sound/pci/hda/Kconfig config SND_HDA_CODEC_HDMI · line 156
Quoted 5 lines
sound/pci/hda/Kconfig +2
-0@@ -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 i915cards"
sound/pci/hda/Kconfig config SND_HDA_CODEC_HDMI · line 159
Quoted 3 lines
sound/pci/hda/Kconfig +3
-0+ depends on DRM_I915 + help + Say Y here to include full HDMI and DisplayPort HD-audiocontroller/codec
sound/pci/hda/Kconfig config SND_HDA_CODEC_HDMI · line 160
Quoted 1 line
sound/pci/hda/Kconfig +1
-0+ power-well support for Intel Haswell graphics cards based on the i915driver.
sound/pci/hda/Kconfig config SND_HDA_CODEC_HDMI · line 162
Quoted 2 lines
sound/pci/hda/Kconfig +2
-0+ + Note that this option must be enabled for Intel Haswell C+ steppingmachines, otherwise
sound/pci/hda/Kconfig config SND_HDA_CODEC_HDMI · line 163
Quoted 1 line
sound/pci/hda/Kconfig +1
-0+ the GPU audio controller/codecs will not be initialized or damaged whenexit from S3 mode.
Quoted 68 lines
sound/pci/hda/Kconfig +1
-0+ config SND_HDA_CODEC_CIRRUS bool "Build Cirrus Logic codec support" default ysound/pci/hda/Makefile index renamed from sound/pci/hda/Makefile +0
-024a2514..4b0a4bc 100644
sound/pci/hda/Makefile +3
-0@@ -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 renamed from sound/pci/hda/hda_i915.c +0
-0file mode 100644 index 0000000..76c13d5
sound/pci/hda/hda_i915.c new file +45
-0@@ -0,0 +1,75 @@ +/* +* hda_i915.c - routines for Haswell HDA controller power well +support +* +* 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. +*/ + +#include <linux/init.h> +#include <linux/module.h> +#include <sound/core.h> +#include <drm/i915_powerwell.h> +#include "hda_i915.h" + +static void (*get_power)(void ); +static void (*put_power)(void ); + +void hda_display_power (bool enable) +{ +if (!get_power || !put_power) +return ; + +snd_printdd ("HDA display power %s \n" , + enable ?"Enable" :"Disable" ); +if (enable) +get_power (); +else sound/pci/hda/hda_i915.c line 55
Quoted 10 lines
sound/pci/hda/hda_i915.c new file +10
-0+put_power (); +} + +int hda_i915_init(void) +{ + int err = 0; + + get_power = symbol_request(i915_request_power_well); + if (!get_power) { + snd_printk(KERN_WARNING "hda-i915: get_power symbol getfail\n");
Quoted 86 lines
sound/pci/hda/hda_i915.c new file +28
-0+return -ENODEV ; + } + + put_power =symbol_request (i915_release_power_well); +if (!put_power) { +symbol_put (i915_request_power_well); + get_power =NULL ; +return -ENODEV ; + } + +snd_printd ("HDA driver get symbol successfully from i915 module\n" ); + +return err; +} + +int hda_i915_exit (void ) +{ +if (get_power) { +symbol_put (i915_request_power_well); + get_power =NULL ; + } +if (put_power) { +symbol_put (i915_release_power_well); + put_power =NULL ; + } + +return 0 ; +}sound/pci/hda/hda_i915.h new renamed from sound/pci/hda/hda_i915.h +0
-0file mode 100644 index 0000000..5a63da2
sound/pci/hda/hda_i915.h new file +41
-0@@ -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 +1
-0@@ -62,6 +62,7 @@#include <linux/vga_switcheroo.h> #include <linux/firmware.h> #include "hda_codec.h" +#include "hda_i915.h" static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; @@ -594,6 +595,7Quoted 2 lines
@@ enum {
#defineAZX_DCAPS_4K_BDLE_BOUNDARY(1 << 23) /* BDLE in 4kboundary */
Quoted 1 line
#define
AZX_DCAPS_COUNT_LPIB_DELAY(1 << 25) /* Take LPIB asdelay */
Quoted 2 lines
#define
AZX_DCAPS_PM_RUNTIME(1 << 26) /* runtime PM support */
+#defineAZX_DCAPS_I915_POWERWELL(1 << 27) /* HSW i915 power wellsupport */
Quoted 52 lines
/* quirks for Intel PCH */
#defineAZX_DCAPS_INTEL_PCH_NOPM\sound/pci/hda/hda_intel.c +12
-0@@ -2869,6 +2871,8 @@ static int azx_suspend(struct device *dev)pci_disable_device (pci);pci_save_state (pci);pci_set_power_state (pci, PCI_D3hot); +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL ) +hda_display_power (false);return 0 ; }@@ -2881,6 +2885,8 @@ static int azx_resume(struct device *dev)if (chip->disabled)return 0 ; +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL ) +hda_display_power (true);pci_set_power_state (pci,PCI_D0 );pci_restore_state (pci);if (pci_enable_device (pci) <0 ) {@@ -2913,6 +2919,8 @@ static int azx_runtime_suspend(struct device *dev)azx_stop_chip (chip);azx_clear_irq_pending (chip); +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL ) +hda_display_power (false);return 0 ; }@@ -2921,6 +2929,8 @@ static int azx_runtime_resume(struct device *dev)struct snd_card *card =dev_get_drvdata (dev);struct azx *chip = card->private_data; +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL ) +hda_display_power (true);azx_init_pci (chip);azx_init_chip (chip,1 );return 0 ;@@ -3144,6 +3154,10 @@ static int azx_free(struct azx *chip)if (chip->fw)release_firmware (chip->fw);#endif +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL ) { +hda_display_power (false); +hda_i915_exit (); + }kfree (chip);return 0 ;sound/pci/hda/hda_intel.c static int azx_probe(struct pci_dev *pci, · line 3721
Quoted 8 lines
sound/pci/hda/hda_intel.c +5
-0@@ -3700,6 +3714,19 @@ static int azx_probe(struct pci_dev *pci, chip->disabled = true; } +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL ) {#ifdef +CONFIG_SND_HDA_I915 + err =hda_i915_init (); +if (err <0 ) { + snd_printk(KERN_ERR SFX "Error request power-well fromi915\n");
Quoted 16 lines
sound/pci/hda/hda_intel.c +9
-0+ goto out_free; + } +hda_display_power (true); +#else + snd_printk(KERN_ERR SFX "Haswell must build in +CONFIG_SND_HDA_I915\n"); #endif + } + probe_now = !chip->disabled;if (probe_now) { err =azx_first_init (chip);@@ -3799,6 +3826,7 @@ out_free:static void azx_remove (struct pci_dev *pci) {struct snd_card *card =pci_get_drvdata (pci); +struct azx *chip = card->private_data;
Quoted 13 lines
sound/pci/hda/hda_intel.c static void azx_remove(struct pci_dev *pci) · line 3840
Quoted 10 lines
sound/pci/hda/hda_intel.c +4
-0if (pci_dev_run_wake (pci))pm_runtime_get_noresume (&pci->dev);@@ -3806,6 +3834,10 @@ static void azx_remove(struct pci_dev *pci)if (card)snd_card_free (card);pci_set_drvdata (pci,NULL ); +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL ) { +hda_display_power (false); +hda_i915_exit (); + }As mentioned in the previous post, you can't refer to chip instance at this point. It's been already freed in
snd_card_free().
Oh sorry I misunderstand your point, the code should be put before snd_card_free():
sound/pci/hda/hda_intel.c +4 -3
@@ -3837,13 +3837,14 @@ static void azx_remove(struct pci_dev *pci)if (pci_dev_run_wake (pci))pm_runtime_get_noresume (&pci->dev); -if (card) -snd_card_free (card); -pci_set_drvdata (pci,NULL );if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL ) {hda_display_power (false);hda_i915_exit (); } + +if (card) +snd_card_free (card); +pci_set_drvdata (pci,NULL ); }/* PCI IDs */
But I'm thinking it can be removed totally as azx_dev_free() always do that.
Thanks
--xingchao
Quoted 29 lines
Takashi
Quoted 24 lines
sound/pci/hda/hda_intel.c +6
-4}/* PCI IDs */ @@ -3835,11 +3867,14 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = { .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH },/* Haswell */ { PCI_DEVICE(0x8086, 0x0a0c), - .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH }, + .driver_data =AZX_DRIVER_SCH |AZX_DCAPS_INTEL_PCH | + AZX_DCAPS_I915_POWERWELL }, { PCI_DEVICE(0x8086, 0x0c0c), - .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH }, + .driver_data =AZX_DRIVER_SCH |AZX_DCAPS_INTEL_PCH | + AZX_DCAPS_I915_POWERWELL }, { PCI_DEVICE(0x8086, 0x0d0c), - .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH }, + .driver_data =AZX_DRIVER_SCH |AZX_DCAPS_INTEL_PCH | + AZX_DCAPS_I915_POWERWELL }, /* 5 Series/3400 */ { PCI_DEVICE(0x8086, 0x3b56), .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH_NOPM }, --1.7.9.5
Re: [PATCH 2/2 V4] ALSA: hda - Add power-welll support for haswell HDA
At Tue, 21 May 2013 10:58:36 +0000,
Quoted 343 lines · Xingchao
Quoted 305 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Tuesday, May 21, 2013 3:19 PM
To: Wang Xingchao
Cc: [email protected]; Girdwood, Liam R; [email protected]; Lin, Mengdong; Li, Jocelyn; [email protected]; [email protected]; Barnes, Jesse; Zanoni, Paulo R; Wang, Xingchao
Subject: Re: [PATCH 2/2 V4] ALSA: hda - Add power-welll support for haswell HDAAt Mon, 20 May 2013 19:26:58 +0800,
Quoted 11 lines · 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.
Signed-off-by Wang Xingchao <[email protected]>--- sound/pci/hda/Kconfig | 10 ++++++ sound/pci/hda/Makefile | 3 ++ sound/pci/hda/hda_i915.c | 75+++++++++++++++++++++++++++++++++++++++++++++
Quoted 11 lines
sound/pci/hda/hda_i915.h | 35 +++++++++++++++++++++ sound/pci/hda/hda_intel.c | 41 +++++++++++++++++++++++-- 5 files changed, 161 insertions(+), 3 deletions(-) create mode100644
sound/pci/hda/hda_i915.ccreate mode 100644sound/pci/hda/hda_i915.hsound/pci/hda/Kconfig index renamed from sound/pci/hda/Kconfig +0
-080a7d44..c5a872c 100644
sound/pci/hda/Kconfig config SND_HDA_CODEC_HDMI · line 156
Quoted 5 lines
sound/pci/hda/Kconfig +2
-0@@ -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 i915cards"
sound/pci/hda/Kconfig config SND_HDA_CODEC_HDMI · line 159
Quoted 3 lines
sound/pci/hda/Kconfig +3
-0+ depends on DRM_I915 + help + Say Y here to include full HDMI and DisplayPort HD-audiocontroller/codec
sound/pci/hda/Kconfig config SND_HDA_CODEC_HDMI · line 160
Quoted 1 line
sound/pci/hda/Kconfig +1
-0+ power-well support for Intel Haswell graphics cards based on the i915driver.
sound/pci/hda/Kconfig config SND_HDA_CODEC_HDMI · line 162
Quoted 2 lines
sound/pci/hda/Kconfig +2
-0+ + Note that this option must be enabled for Intel Haswell C+ steppingmachines, otherwise
sound/pci/hda/Kconfig config SND_HDA_CODEC_HDMI · line 163
Quoted 1 line
sound/pci/hda/Kconfig +1
-0+ the GPU audio controller/codecs will not be initialized or damaged whenexit from S3 mode.
Quoted 68 lines
sound/pci/hda/Kconfig +1
-0+ config SND_HDA_CODEC_CIRRUS bool "Build Cirrus Logic codec support" default ysound/pci/hda/Makefile index renamed from sound/pci/hda/Makefile +0
-024a2514..4b0a4bc 100644
sound/pci/hda/Makefile +3
-0@@ -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 renamed from sound/pci/hda/hda_i915.c +0
-0file mode 100644 index 0000000..76c13d5
sound/pci/hda/hda_i915.c new file +45
-0@@ -0,0 +1,75 @@ +/* +* hda_i915.c - routines for Haswell HDA controller power well +support +* +* 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. +*/ + +#include <linux/init.h> +#include <linux/module.h> +#include <sound/core.h> +#include <drm/i915_powerwell.h> +#include "hda_i915.h" + +static void (*get_power)(void ); +static void (*put_power)(void ); + +void hda_display_power (bool enable) +{ +if (!get_power || !put_power) +return ; + +snd_printdd ("HDA display power %s \n" , + enable ?"Enable" :"Disable" ); +if (enable) +get_power (); +else sound/pci/hda/hda_i915.c line 55
Quoted 10 lines
sound/pci/hda/hda_i915.c new file +10
-0+put_power (); +} + +int hda_i915_init(void) +{ + int err = 0; + + get_power = symbol_request(i915_request_power_well); + if (!get_power) { + snd_printk(KERN_WARNING "hda-i915: get_power symbol getfail\n");
Quoted 86 lines
sound/pci/hda/hda_i915.c new file +28
-0+return -ENODEV ; + } + + put_power =symbol_request (i915_release_power_well); +if (!put_power) { +symbol_put (i915_request_power_well); + get_power =NULL ; +return -ENODEV ; + } + +snd_printd ("HDA driver get symbol successfully from i915 module\n" ); + +return err; +} + +int hda_i915_exit (void ) +{ +if (get_power) { +symbol_put (i915_request_power_well); + get_power =NULL ; + } +if (put_power) { +symbol_put (i915_release_power_well); + put_power =NULL ; + } + +return 0 ; +}sound/pci/hda/hda_i915.h new renamed from sound/pci/hda/hda_i915.h +0
-0file mode 100644 index 0000000..5a63da2
sound/pci/hda/hda_i915.h new file +41
-0@@ -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 +1
-0@@ -62,6 +62,7 @@#include <linux/vga_switcheroo.h> #include <linux/firmware.h> #include "hda_codec.h" +#include "hda_i915.h" static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; @@ -594,6 +595,7Quoted 2 lines
@@ enum {
#defineAZX_DCAPS_4K_BDLE_BOUNDARY(1 << 23) /* BDLE in 4kboundary */
Quoted 1 line
#define
AZX_DCAPS_COUNT_LPIB_DELAY(1 << 25) /* Take LPIB asdelay */
Quoted 2 lines
#define
AZX_DCAPS_PM_RUNTIME(1 << 26) /* runtime PM support */
+#defineAZX_DCAPS_I915_POWERWELL(1 << 27) /* HSW i915 power wellsupport */
Quoted 52 lines
/* quirks for Intel PCH */
#defineAZX_DCAPS_INTEL_PCH_NOPM\sound/pci/hda/hda_intel.c +12
-0@@ -2869,6 +2871,8 @@ static int azx_suspend(struct device *dev)pci_disable_device (pci);pci_save_state (pci);pci_set_power_state (pci, PCI_D3hot); +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL ) +hda_display_power (false);return 0 ; }@@ -2881,6 +2885,8 @@ static int azx_resume(struct device *dev)if (chip->disabled)return 0 ; +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL ) +hda_display_power (true);pci_set_power_state (pci,PCI_D0 );pci_restore_state (pci);if (pci_enable_device (pci) <0 ) {@@ -2913,6 +2919,8 @@ static int azx_runtime_suspend(struct device *dev)azx_stop_chip (chip);azx_clear_irq_pending (chip); +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL ) +hda_display_power (false);return 0 ; }@@ -2921,6 +2929,8 @@ static int azx_runtime_resume(struct device *dev)struct snd_card *card =dev_get_drvdata (dev);struct azx *chip = card->private_data; +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL ) +hda_display_power (true);azx_init_pci (chip);azx_init_chip (chip,1 );return 0 ;@@ -3144,6 +3154,10 @@ static int azx_free(struct azx *chip)if (chip->fw)release_firmware (chip->fw);#endif +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL ) { +hda_display_power (false); +hda_i915_exit (); + }kfree (chip);return 0 ;sound/pci/hda/hda_intel.c static int azx_probe(struct pci_dev *pci, · line 3721
Quoted 8 lines
sound/pci/hda/hda_intel.c +5
-0@@ -3700,6 +3714,19 @@ static int azx_probe(struct pci_dev *pci, chip->disabled = true; } +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL ) {#ifdef +CONFIG_SND_HDA_I915 + err =hda_i915_init (); +if (err <0 ) { + snd_printk(KERN_ERR SFX "Error request power-well fromi915\n");
Quoted 16 lines
sound/pci/hda/hda_intel.c +9
-0+ goto out_free; + } +hda_display_power (true); +#else + snd_printk(KERN_ERR SFX "Haswell must build in +CONFIG_SND_HDA_I915\n"); #endif + } + probe_now = !chip->disabled;if (probe_now) { err =azx_first_init (chip);@@ -3799,6 +3826,7 @@ out_free:static void azx_remove (struct pci_dev *pci) {struct snd_card *card =pci_get_drvdata (pci); +struct azx *chip = card->private_data;Quoted 13 lines
sound/pci/hda/hda_intel.c static void azx_remove(struct pci_dev *pci) · line 3840
Quoted 10 lines
sound/pci/hda/hda_intel.c +4
-0if (pci_dev_run_wake (pci))pm_runtime_get_noresume (&pci->dev);@@ -3806,6 +3834,10 @@ static void azx_remove(struct pci_dev *pci)if (card)snd_card_free (card);pci_set_drvdata (pci,NULL ); +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL ) { +hda_display_power (false); +hda_i915_exit (); + }As mentioned in the previous post, you can't refer to chip instance at this point. It's been already freed in
snd_card_free().Oh sorry I misunderstand your point, the code should be put before
snd_card_free():sound/pci/hda/hda_intel.c +4
-3@@ -3837,13 +3837,14 @@ static void azx_remove(struct pci_dev *pci)if (pci_dev_run_wake (pci))pm_runtime_get_noresume (&pci->dev); -if (card) -snd_card_free (card); -pci_set_drvdata (pci,NULL );if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL ) {hda_display_power (false);hda_i915_exit (); } + +if (card) +snd_card_free (card); +pci_set_drvdata (pci,NULL ); }/* PCI IDs */
Quoted 1 line
But I'm thinking it can be removed totally as
azx_dev_free()always do that.
Yeah, the right place to call this is azx_free().
But make sure that this won't be called in the case of error path before hda_i915_init().
Takashi