Skip to contentSkip to conversation

hda - bug fix on references without checking CONFIG_SND_HDA_POWER_SAVE

PATCH In review [email protected] 2 participants 2 messages Aug 24, 2012 Sound

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 hda - bug fix on references without checking CONFIG_SND_HDA_POWER_SAVE

From: Mengdong Lin <[email protected]>

The patch to support runtime PM introduced a bug:
Module parameter 'power_save_controller', and the codec flag 'd3_stop_clk' 'd3_stop_clk_ok' are defined only when HDA power save is enabled in config. But there are references to them without checking macro CONFIG_SND_HDA_POWER_SAVE.

This patch is to fix the bug.

---
 sound/pci/hda/hda_codec.c |    6 ++++++
 sound/pci/hda/hda_intel.c |    2 ++
 2 files changed, 8 insertions(+)
sound/pci/hda/hda_codec.c +6 -0
index d6b3a6d..e618394 100644
@@ -1320,11 +1320,13 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus,
 					   AC_VERB_GET_SUBSYSTEM_ID, 0);
 	}
 
+#ifdef CONFIG_SND_HDA_POWER_SAVE
 	codec->d3_stop_clk = snd_hda_codec_get_supported_ps(codec,
 					codec->afg ? codec->afg : codec->mfg,
 					AC_PWRST_CLKSTOP);
 	if (!codec->d3_stop_clk)
 		bus->power_keep_link_on = 1;
+#endif
 
 	/* power-up all before initialization */
 	hda_set_power_state(codec,
@@ -3523,7 +3525,9 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
 	int count;
 	unsigned int state;
 
+#ifdef CONFIG_SND_HDA_POWER_SAVE
 	codec->d3_stop_clk_ok = 0;
+#endif
 
 	if (codec->patch_ops.set_power_state) {
 		codec->patch_ops.set_power_state(codec, fg, power_state);
@@ -3548,9 +3552,11 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
 			break;
 	}
 
+#ifdef CONFIG_SND_HDA_POWER_SAVE
 	if ((power_state == AC_PWRST_D3)
 		&& codec->d3_stop_clk && (state & AC_PWRST_CLK_STOP_OK))
 		codec->d3_stop_clk_ok = 1;
+#endif
 }
 
 #ifdef CONFIG_SND_HDA_HWDEP
sound/pci/hda/hda_intel.c +2 -0
index 2baa3ee..97307df 100644
@@ -2515,8 +2515,10 @@ static int azx_runtime_suspend(struct device *dev)
 	struct snd_card *card = dev_get_drvdata(dev);
 	struct azx *chip = card->private_data;
 
+#ifdef CONFIG_SND_HDA_POWER_SAVE
 	if (!power_save_controller)
 		return -EAGAIN;
+#endif
 
 	azx_stop_chip(chip);
 	azx_clear_irq_pending(chip);
Signature · 1 line
1.7.9.5
#1 lore raw

At Fri, 24 Aug 2012 12:06:30 +0800,

Quoted 11 lines · [email protected] wrote:

From: Mengdong Lin <[email protected]>

The patch to support runtime PM introduced a bug:
Module parameter 'power_save_controller', and the codec flag 'd3_stop_clk' 'd3_stop_clk_ok' are defined only when HDA power save is enabled in config. But there are references to them without checking macro CONFIG_SND_HDA_POWER_SAVE.

This patch is to fix the bug.

Applied now. Thanks.

Takashi

Quoted 63 lines
---
 sound/pci/hda/hda_codec.c |    6 ++++++
 sound/pci/hda/hda_intel.c |    2 ++
 2 files changed, 8 insertions(+)
sound/pci/hda/hda_codec.c +6 -0
index d6b3a6d..e618394 100644
@@ -1320,11 +1320,13 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus,
 					   AC_VERB_GET_SUBSYSTEM_ID, 0);
 	}
 
+#ifdef CONFIG_SND_HDA_POWER_SAVE
 	codec->d3_stop_clk = snd_hda_codec_get_supported_ps(codec,
 					codec->afg ? codec->afg : codec->mfg,
 					AC_PWRST_CLKSTOP);
 	if (!codec->d3_stop_clk)
 		bus->power_keep_link_on = 1;
+#endif
 
 	/* power-up all before initialization */
 	hda_set_power_state(codec,
@@ -3523,7 +3525,9 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
 	int count;
 	unsigned int state;
 
+#ifdef CONFIG_SND_HDA_POWER_SAVE
 	codec->d3_stop_clk_ok = 0;
+#endif
 
 	if (codec->patch_ops.set_power_state) {
 		codec->patch_ops.set_power_state(codec, fg, power_state);
@@ -3548,9 +3552,11 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
 			break;
 	}
 
+#ifdef CONFIG_SND_HDA_POWER_SAVE
 	if ((power_state == AC_PWRST_D3)
 		&& codec->d3_stop_clk && (state & AC_PWRST_CLK_STOP_OK))
 		codec->d3_stop_clk_ok = 1;
+#endif
 }
 
 #ifdef CONFIG_SND_HDA_HWDEP
sound/pci/hda/hda_intel.c +2 -0
index 2baa3ee..97307df 100644
@@ -2515,8 +2515,10 @@ static int azx_runtime_suspend(struct device *dev)
 	struct snd_card *card = dev_get_drvdata(dev);
 	struct azx *chip = card->private_data;
 
+#ifdef CONFIG_SND_HDA_POWER_SAVE
 	if (!power_save_controller)
 		return -EAGAIN;
+#endif
 
 	azx_stop_chip(chip);
 	azx_clear_irq_pending(chip);
Signature · 1 line
1.7.9.5