All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] ASoC: ti: j721e-evm: Small fixes and code cleanup
@ 2021-07-17 12:28 Peter Ujfalusi
  2021-07-17 12:28 ` [PATCH 1/3] ASoC: ti: j721e-evm: Fix unbalanced domain activity tracking during startup Peter Ujfalusi
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Peter Ujfalusi @ 2021-07-17 12:28 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, lgirdwood

Hi,

I have found two issues with the machine driver which for some reason did not
caused errors but they are certainly bugs.

The last patch is just to convert the IDs from define to enum.

Regards,
Peter
---
Peter Ujfalusi (3):
  ASoC: ti: j721e-evm: Fix unbalanced domain activity tracking during
    startup
  ASoC: ti: j721e-evm: Check for not initialized parent_clk_id
  ASoC: ti: j721e-evm: Convert the audio domain IDs to enum

 sound/soc/ti/j721e-evm.c | 48 ++++++++++++++++++++++++----------------
 1 file changed, 29 insertions(+), 19 deletions(-)

-- 
2.32.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] ASoC: ti: j721e-evm: Fix unbalanced domain activity tracking during startup
  2021-07-17 12:28 [PATCH 0/3] ASoC: ti: j721e-evm: Small fixes and code cleanup Peter Ujfalusi
@ 2021-07-17 12:28 ` Peter Ujfalusi
  2021-07-17 12:28 ` [PATCH 2/3] ASoC: ti: j721e-evm: Check for not initialized parent_clk_id Peter Ujfalusi
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Peter Ujfalusi @ 2021-07-17 12:28 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, lgirdwood

In case of an error within j721e_audio_startup() the domain->active must
be decremented to avoid unbalanced counter.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>
---
 sound/soc/ti/j721e-evm.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/sound/soc/ti/j721e-evm.c b/sound/soc/ti/j721e-evm.c
index a7c0484d44ec..017c4ad11ca6 100644
--- a/sound/soc/ti/j721e-evm.c
+++ b/sound/soc/ti/j721e-evm.c
@@ -278,23 +278,29 @@ static int j721e_audio_startup(struct snd_pcm_substream *substream)
 					  j721e_rule_rate, &priv->rate_range,
 					  SNDRV_PCM_HW_PARAM_RATE, -1);
 
-	mutex_unlock(&priv->mutex);
 
 	if (ret)
-		return ret;
+		goto out;
 
 	/* Reset TDM slots to 32 */
 	ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0x3, 0x3, 2, 32);
 	if (ret && ret != -ENOTSUPP)
-		return ret;
+		goto out;
 
 	for_each_rtd_codec_dais(rtd, i, codec_dai) {
 		ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x3, 0x3, 2, 32);
 		if (ret && ret != -ENOTSUPP)
-			return ret;
+			goto out;
 	}
 
-	return 0;
+	if (ret == -ENOTSUPP)
+		ret = 0;
+out:
+	if (ret)
+		domain->active--;
+	mutex_unlock(&priv->mutex);
+
+	return ret;
 }
 
 static int j721e_audio_hw_params(struct snd_pcm_substream *substream,
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] ASoC: ti: j721e-evm: Check for not initialized parent_clk_id
  2021-07-17 12:28 [PATCH 0/3] ASoC: ti: j721e-evm: Small fixes and code cleanup Peter Ujfalusi
  2021-07-17 12:28 ` [PATCH 1/3] ASoC: ti: j721e-evm: Fix unbalanced domain activity tracking during startup Peter Ujfalusi
@ 2021-07-17 12:28 ` Peter Ujfalusi
  2021-07-17 12:28 ` [PATCH 3/3] ASoC: ti: j721e-evm: Convert the audio domain IDs to enum Peter Ujfalusi
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Peter Ujfalusi @ 2021-07-17 12:28 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, lgirdwood

During probe the parent_clk_id is set to -1 which should not be used to
array index within hsdiv_rates[].

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>
---
 sound/soc/ti/j721e-evm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/ti/j721e-evm.c b/sound/soc/ti/j721e-evm.c
index 017c4ad11ca6..265bbc5a2f96 100644
--- a/sound/soc/ti/j721e-evm.c
+++ b/sound/soc/ti/j721e-evm.c
@@ -197,7 +197,7 @@ static int j721e_configure_refclk(struct j721e_priv *priv,
 		return ret;
 	}
 
-	if (priv->hsdiv_rates[domain->parent_clk_id] != scki) {
+	if (domain->parent_clk_id == -1 || priv->hsdiv_rates[domain->parent_clk_id] != scki) {
 		dev_dbg(priv->dev,
 			"%s configuration for %u Hz: %s, %dxFS (SCKI: %u Hz)\n",
 			audio_domain == J721E_AUDIO_DOMAIN_CPB ? "CPB" : "IVI",
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] ASoC: ti: j721e-evm: Convert the audio domain IDs to enum
  2021-07-17 12:28 [PATCH 0/3] ASoC: ti: j721e-evm: Small fixes and code cleanup Peter Ujfalusi
  2021-07-17 12:28 ` [PATCH 1/3] ASoC: ti: j721e-evm: Fix unbalanced domain activity tracking during startup Peter Ujfalusi
  2021-07-17 12:28 ` [PATCH 2/3] ASoC: ti: j721e-evm: Check for not initialized parent_clk_id Peter Ujfalusi
@ 2021-07-17 12:28 ` Peter Ujfalusi
  2021-07-19 14:37 ` (subset) [PATCH 0/3] ASoC: ti: j721e-evm: Small fixes and code cleanup Mark Brown
  2021-07-19 15:42 ` Mark Brown
  4 siblings, 0 replies; 6+ messages in thread
From: Peter Ujfalusi @ 2021-07-17 12:28 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, lgirdwood

Convert the J721E_AUDIO_DOMAIN_* from defines to enum to make it possible
to extend the number of domains in the future.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>
---
 sound/soc/ti/j721e-evm.c | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/sound/soc/ti/j721e-evm.c b/sound/soc/ti/j721e-evm.c
index 265bbc5a2f96..9347f982c3e1 100644
--- a/sound/soc/ti/j721e-evm.c
+++ b/sound/soc/ti/j721e-evm.c
@@ -23,8 +23,11 @@
  */
 #define J721E_CODEC_CONF_COUNT	5
 
-#define J721E_AUDIO_DOMAIN_CPB	0
-#define J721E_AUDIO_DOMAIN_IVI	1
+enum j721e_audio_domain_id {
+	J721E_AUDIO_DOMAIN_CPB = 0,
+	J721E_AUDIO_DOMAIN_IVI,
+	J721E_AUDIO_DOMAIN_LAST,
+};
 
 #define J721E_CLK_PARENT_48000	0
 #define J721E_CLK_PARENT_44100	1
@@ -78,7 +81,7 @@ struct j721e_priv {
 	u32 pll_rates[2];
 	unsigned int hsdiv_rates[2];
 
-	struct j721e_audio_domain audio_domains[2];
+	struct j721e_audio_domain audio_domains[J721E_AUDIO_DOMAIN_LAST];
 
 	struct mutex mutex;
 };
@@ -199,9 +202,8 @@ static int j721e_configure_refclk(struct j721e_priv *priv,
 
 	if (domain->parent_clk_id == -1 || priv->hsdiv_rates[domain->parent_clk_id] != scki) {
 		dev_dbg(priv->dev,
-			"%s configuration for %u Hz: %s, %dxFS (SCKI: %u Hz)\n",
-			audio_domain == J721E_AUDIO_DOMAIN_CPB ? "CPB" : "IVI",
-			rate,
+			"domain%u configuration for %u Hz: %s, %dxFS (SCKI: %u Hz)\n",
+			audio_domain, rate,
 			clk_id == J721E_CLK_PARENT_48000 ? "PLL4" : "PLL15",
 			ratios_for_pcm3168a[i], scki);
 
@@ -263,10 +265,11 @@ static int j721e_audio_startup(struct snd_pcm_substream *substream)
 
 	domain->active++;
 
-	if (priv->audio_domains[J721E_AUDIO_DOMAIN_CPB].rate)
-		active_rate = priv->audio_domains[J721E_AUDIO_DOMAIN_CPB].rate;
-	else
-		active_rate = priv->audio_domains[J721E_AUDIO_DOMAIN_IVI].rate;
+	for (i = 0; i < J721E_AUDIO_DOMAIN_LAST; i++) {
+		active_rate = priv->audio_domains[i].rate;
+		if (active_rate)
+			break;
+	}
 
 	if (active_rate)
 		ret = snd_pcm_hw_constraint_single(substream->runtime,
@@ -825,7 +828,7 @@ static int j721e_soc_probe(struct platform_device *pdev)
 	struct snd_soc_card *card;
 	const struct of_device_id *match;
 	struct j721e_priv *priv;
-	int link_cnt, conf_cnt, ret;
+	int link_cnt, conf_cnt, ret, i;
 
 	if (!node) {
 		dev_err(&pdev->dev, "of node is missing.\n");
@@ -849,8 +852,9 @@ static int j721e_soc_probe(struct platform_device *pdev)
 	if (!priv->dai_links)
 		return -ENOMEM;
 
-	priv->audio_domains[J721E_AUDIO_DOMAIN_CPB].parent_clk_id = -1;
-	priv->audio_domains[J721E_AUDIO_DOMAIN_IVI].parent_clk_id = -1;
+	for (i = 0; i < J721E_AUDIO_DOMAIN_LAST; i++)
+		priv->audio_domains[i].parent_clk_id = -1;
+
 	priv->dev = &pdev->dev;
 	card = &priv->card;
 	card->dev = &pdev->dev;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: (subset) [PATCH 0/3] ASoC: ti: j721e-evm: Small fixes and code cleanup
  2021-07-17 12:28 [PATCH 0/3] ASoC: ti: j721e-evm: Small fixes and code cleanup Peter Ujfalusi
                   ` (2 preceding siblings ...)
  2021-07-17 12:28 ` [PATCH 3/3] ASoC: ti: j721e-evm: Convert the audio domain IDs to enum Peter Ujfalusi
@ 2021-07-19 14:37 ` Mark Brown
  2021-07-19 15:42 ` Mark Brown
  4 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2021-07-19 14:37 UTC (permalink / raw)
  To: Peter Ujfalusi; +Cc: alsa-devel, Mark Brown, lgirdwood

On Sat, 17 Jul 2021 15:28:17 +0300, Peter Ujfalusi wrote:
> I have found two issues with the machine driver which for some reason did not
> caused errors but they are certainly bugs.
> 
> The last patch is just to convert the IDs from define to enum.
> 
> Regards,
> Peter

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/3] ASoC: ti: j721e-evm: Fix unbalanced domain activity tracking during startup
      commit: 78d2a05ef22e7b5863b01e073dd6a06b3979bb00
[2/3] ASoC: ti: j721e-evm: Check for not initialized parent_clk_id
      commit: 82d28b67f780910f816fe1cfb0f676fc38c4cbb3

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: (subset) [PATCH 0/3] ASoC: ti: j721e-evm: Small fixes and code cleanup
  2021-07-17 12:28 [PATCH 0/3] ASoC: ti: j721e-evm: Small fixes and code cleanup Peter Ujfalusi
                   ` (3 preceding siblings ...)
  2021-07-19 14:37 ` (subset) [PATCH 0/3] ASoC: ti: j721e-evm: Small fixes and code cleanup Mark Brown
@ 2021-07-19 15:42 ` Mark Brown
  4 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2021-07-19 15:42 UTC (permalink / raw)
  To: Peter Ujfalusi; +Cc: alsa-devel, Mark Brown, lgirdwood

On Sat, 17 Jul 2021 15:28:17 +0300, Peter Ujfalusi wrote:
> I have found two issues with the machine driver which for some reason did not
> caused errors but they are certainly bugs.
> 
> The last patch is just to convert the IDs from define to enum.
> 
> Regards,
> Peter

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[3/3] ASoC: ti: j721e-evm: Convert the audio domain IDs to enum
      commit: cfc9d37ab79ff19d44a17195e57b2828084d5896

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-19 15:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-17 12:28 [PATCH 0/3] ASoC: ti: j721e-evm: Small fixes and code cleanup Peter Ujfalusi
2021-07-17 12:28 ` [PATCH 1/3] ASoC: ti: j721e-evm: Fix unbalanced domain activity tracking during startup Peter Ujfalusi
2021-07-17 12:28 ` [PATCH 2/3] ASoC: ti: j721e-evm: Check for not initialized parent_clk_id Peter Ujfalusi
2021-07-17 12:28 ` [PATCH 3/3] ASoC: ti: j721e-evm: Convert the audio domain IDs to enum Peter Ujfalusi
2021-07-19 14:37 ` (subset) [PATCH 0/3] ASoC: ti: j721e-evm: Small fixes and code cleanup Mark Brown
2021-07-19 15:42 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.