Skip to contentSkip to conversation

ASoC: tlv320aic32x4: Kernel OOPS while entering DAPM standby mode

PATCH Superseded b-ak 2 participants 8 messages Jan 2, 2019 – Jan 7, 2019

Subsystems (3)
lore
Share & tools
lore

b-ak

author
#0 lore raw

PATCH 1/1 ASoC: tlv320aic32x4: Kernel OOPS while entering DAPM standby mode

During the bootup of the kernel, as soon as the DAPM framework kicks in it pushes the codec into standy mode.

The existing TVL320AIC32x4 codec driver doesn't prepare the clock in the probe function.
This leads to an OOPS when the DAPM tries to put it into standy by calling clk_disable_unprepare()

This patch fixes that problem.

---
 sound/soc/codecs/tlv320aic32x4.c | 6 ++++++
 1 file changed, 6 insertions(+)
sound/soc/codecs/tlv320aic32x4.c +6 -0
index e2b5a11b16d1..7cf363595abd 100644
@@ -1167,6 +1167,12 @@ int aic32x4_probe(struct device *dev, struct regmap *regmap)
 	if (IS_ERR(aic32x4->mclk)) {
 		dev_err(dev, "Failed getting the mclk. The current implementation does not support the usage of this codec without mclk\n");
 		return PTR_ERR(aic32x4->mclk);
+	} else {
+		ret = clk_prepare_enable(aic32x4->mclk);
+		if (ret != 0) {
+			dev_err(dev, "Failed to enable MCLK: %d\n", ret);
+			return ret;
+		}
 	}
 
 	if (gpio_is_valid(aic32x4->rstn_gpio)) {
Signature · 1 line
2.19.1
maintainer
#1 lore raw
Quoted 9 lines · b-ak

During the bootup of the kernel, as soon as the DAPM framework kicks in it pushes the codec into standy mode.

The existing TVL320AIC32x4 codec driver doesn't prepare the clock in the probe function.
This leads to an OOPS when the DAPM tries to put it into standy by calling clk_disable_unprepare()

This patch fixes that problem.

This isn't the best way of fixing this because it makes it look like there's a missing disable in the removal process. What would be better would be to do what other drivers do and check to see what state we're transitioning from before we disable the clock in set_bias_level(). See drivers like wm8903.c for examples.

author
#2 lore raw
Quoted 9 lines · Mark Brown
Quoted 8 lines · b-ak

During the bootup of the kernel, as soon as the DAPM framework kicks in it pushes the codec into standy mode.

The existing TVL320AIC32x4 codec driver doesn't prepare the clock in the probe function.
This leads to an OOPS when the DAPM tries to put it into standy by calling clk_disable_unprepare()

Quoted 7 lines
Quoted 1 line

This patch fixes that problem.

This isn't the best way of fixing this because it makes it look like there's a missing disable in the removal process. What would be better would be to do what other drivers do and check to see what state we're transitioning from before we disable the clock in set_bias_level(). See drivers like wm8903.c for examples.

Hello Mark,

I will test the change and update the patch.

Thanks,
Bhargav

author
#3 lore raw
Quoted 18 lines · b-ak
Quoted 9 lines · Mark Brown
Quoted 8 lines · b-ak

During the bootup of the kernel, as soon as the DAPM framework kicks in it pushes the codec into standy mode.

The existing TVL320AIC32x4 codec driver doesn't prepare the clock in the probe function.
This leads to an OOPS when the DAPM tries to put it into standy by calling clk_disable_unprepare()

Quoted 7 lines
Quoted 1 line

This patch fixes that problem.

This isn't the best way of fixing this because it makes it look like there's a missing disable in the removal process. What would be better would be to do what other drivers do and check to see what state we're transitioning from before we disable the clock in set_bias_level(). See drivers like wm8903.c for examples.

Quoted 7 lines

Hello Mark,

I will test the change and update the patch.

Thanks,
Bhargav

Hi Mark,

I have updated the patch with the changes.

Regards,
Bhargav

From 5c0530506bd6d167db4f40d5af5bb82b14debad5 Mon Sep 17 00:00:00 2001
From: b-ak <[email protected]>
Date: Tue, 1 Jan 2019 22:52:40 +0530
Subject: [PATCH] ASoC: tlv320aic32x4: Kernel OOPS while entering DAPM standby
mode

During the bootup of the kernel, the DAPM bias level is in the OFF state. As soon as the DAPM framework kicks in it pushes the codec into STANDBY state.

The probe function doesn't prepare the clock, and STANDBY state does a clk_disable_unprepare() without checking the previous state. This leads to an OOPS.

Not transitioning from an OFF state to the STANDBY state fixes the problem.

---
 sound/soc/codecs/tlv320aic32x4.c | 4 ++++
 1 file changed, 4 insertions(+)
sound/soc/codecs/tlv320aic32x4.c +4 -0
index e2b5a11b16d1..395f892776cd 100644
@@ -822,6 +822,10 @@ static int aic32x4_set_bias_level(struct snd_soc_component *component,
 	case SND_SOC_BIAS_PREPARE:
 		break;
 	case SND_SOC_BIAS_STANDBY:
+		/* Initial cold start */
+		if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF)
+			break;
+
 		/* Switch off BCLK_N Divider */
 		snd_soc_component_update_bits(component, AIC32X4_BCLKN,
 				    AIC32X4_BCLKEN, 0);
Signature · 1 line
2.19.1
author
#4 lore raw
Quoted 27 lines · b-ak
Quoted 18 lines · b-ak
Quoted 9 lines · Mark Brown
Quoted 8 lines · b-ak

During the bootup of the kernel, as soon as the DAPM framework kicks in it pushes the codec into standy mode.

The existing TVL320AIC32x4 codec driver doesn't prepare the clock in the probe function.
This leads to an OOPS when the DAPM tries to put it into standy by calling clk_disable_unprepare()

Quoted 7 lines
Quoted 1 line

This patch fixes that problem.

This isn't the best way of fixing this because it makes it look like there's a missing disable in the removal process. What would be better would be to do what other drivers do and check to see what state we're transitioning from before we disable the clock in set_bias_level(). See drivers like wm8903.c for examples.

Quoted 7 lines

Hello Mark,

I will test the change and update the patch.

Thanks,
Bhargav

Quoted 7 lines

Hi Mark,

I have updated the patch with the changes.

Regards,
Bhargav

Hi Mark,

Fixed the build error.

Thanks,
Bhargav

From 5854c8b48e6c2367d391cc760939538ac8f624f7 Mon Sep 17 00:00:00 2001
From: b-ak <[email protected]>
Date: Tue, 1 Jan 2019 22:52:40 +0530
Subject: [PATCH] ASoC: tlv320aic32x4: Kernel OOPS while entering DAPM standby
mode

During the bootup of the kernel, the DAPM bias level is in the OFF state. As soon as the DAPM framework kicks in it pushes the codec into STANDBY state.

The probe function doesn't prepare the clock, and STANDBY state does a clk_disable_unprepare() without checking the previous state. This leads to an OOPS.

Not transitioning from an OFF state to the STANDBY state fixes the problem.

---
 sound/soc/codecs/tlv320aic32x4.c | 4 ++++
 1 file changed, 4 insertions(+)
sound/soc/codecs/tlv320aic32x4.c +4 -0
index e2b5a11b16d1..f03195d2ab2e 100644
@@ -822,6 +822,10 @@ static int aic32x4_set_bias_level(struct snd_soc_component *component,
 	case SND_SOC_BIAS_PREPARE:
 		break;
 	case SND_SOC_BIAS_STANDBY:
+		/* Initial cold start */
+		if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF)
+			break;
+
 		/* Switch off BCLK_N Divider */
 		snd_soc_component_update_bits(component, AIC32X4_BCLKN,
 				    AIC32X4_BCLKEN, 0);
Signature · 1 line
2.19.1
maintainer
#5 lore raw
Quoted 8 lines · b-ak

Hi Mark,

Fixed the build error.

Thanks,
Bhargav

Please submit patches following the process covered in submitting-patches.rst, don't send them as attachments to replies in the middle of threads. Doing that confuses all the tooling for handling patches.

author
#6 lore raw
Quoted 7 lines · Mark Brown
Quoted 5 lines · b-ak

Hi Mark,

Fixed the build error.

Quoted 8 lines
Quoted 3 lines

Thanks,
Bhargav

Please submit patches following the process covered in submitting-patches.rst, don't send them as attachments to replies in the middle of threads. Doing that confuses all the tooling for handling patches.

Ok. I made a mistake while sending it with Mutt.
Will be sending it inline now.

author
#7 lore raw

PATCH v2 1/1 ASoC: tlv320aic32x4: Kernel OOPS while entering DAPM standby mode

In reply to Mark Brown

During the bootup of the kernel, the DAPM bias level is in the OFF state. As soon as the DAPM framework kicks in it pushes the codec into STANDBY state.

The probe function doesn't prepare the clock, and STANDBY state does a clk_disable_unprepare() without checking the previous state. This leads to an OOPS.

Not transitioning from an OFF state to the STANDBY state fixes the problem.

---
 sound/soc/codecs/tlv320aic32x4.c | 4 ++++
 1 file changed, 4 insertions(+)
sound/soc/codecs/tlv320aic32x4.c +4 -0
index e2b5a11b16d1..f03195d2ab2e 100644
@@ -822,6 +822,10 @@ static int aic32x4_set_bias_level(struct snd_soc_component *component,
 	case SND_SOC_BIAS_PREPARE:
 		break;
 	case SND_SOC_BIAS_STANDBY:
+		/* Initial cold start */
+		if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF)
+			break;
+
 		/* Switch off BCLK_N Divider */
 		snd_soc_component_update_bits(component, AIC32X4_BCLKN,
 				    AIC32X4_BCLKEN, 0);
Signature · 1 line
2.19.1