alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ASoC: fix pcm-creation regression
@ 2017-07-12 15:55 Johan Hovold
  2017-07-12 15:55 ` [PATCH 2/2] Revert "ASoC: ux500: drop platform DAI assignments" Johan Hovold
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Johan Hovold @ 2017-07-12 15:55 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown
  Cc: alsa-devel, Kuninori Morimoto, Linus Walleij, Brian Norris,
	linux-kernel, stable, Takashi Iwai, Johan Hovold

This reverts commit 99b04f4c4051 ("ASoC: add Component level
pcm_new/pcm_free"), which started calling the pcm_new callback for every
component in a *card* when creating a new pcm, something which does not
seem to make any sense.

This specifically led to memory leaks in systems with more than one
platform component and where DMA memory is allocated in the
platform-driver callback. For example, when both mcasp devices are being
used on an am335x board, DMA memory would be allocated twice for every
DAI link during probe.

When CONFIG_SND_VERBOSE_PROCFS was set this fortunately also led to
warnings such as:

WARNING: CPU: 0 PID: 565 at ../fs/proc/generic.c:346 proc_register+0x110/0x154
proc_dir_entry 'sub0/prealloc' already registered

Since there seems to be no users of the new component callbacks, and the
current implementation introduced a regression, let's revert the
offending commit for now.

Fixes: 99b04f4c4051 ("ASoC: add Component level pcm_new/pcm_free")
Cc: stable <stable@vger.kernel.org>	# 4.10
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Brian Norris <briannorris@chromium.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 include/sound/soc.h  |  6 ------
 sound/soc/soc-core.c | 25 -------------------------
 sound/soc/soc-pcm.c  | 32 +++++++++-----------------------
 3 files changed, 9 insertions(+), 54 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 9c94b97c17f8..c4a8b1947566 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -795,10 +795,6 @@ struct snd_soc_component_driver {
 	int (*suspend)(struct snd_soc_component *);
 	int (*resume)(struct snd_soc_component *);
 
-	/* pcm creation and destruction */
-	int (*pcm_new)(struct snd_soc_pcm_runtime *);
-	void (*pcm_free)(struct snd_pcm *);
-
 	/* DT */
 	int (*of_xlate_dai_name)(struct snd_soc_component *component,
 				 struct of_phandle_args *args,
@@ -874,8 +870,6 @@ struct snd_soc_component {
 	void (*remove)(struct snd_soc_component *);
 	int (*suspend)(struct snd_soc_component *);
 	int (*resume)(struct snd_soc_component *);
-	int (*pcm_new)(struct snd_soc_pcm_runtime *);
-	void (*pcm_free)(struct snd_pcm *);
 
 	/* machine specific init */
 	int (*init)(struct snd_soc_component *component);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 921622a01944..c240e13ba057 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3171,8 +3171,6 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
 	component->remove = component->driver->remove;
 	component->suspend = component->driver->suspend;
 	component->resume = component->driver->resume;
-	component->pcm_new = component->driver->pcm_new;
-	component->pcm_free = component->driver->pcm_free;
 
 	dapm = &component->dapm;
 	dapm->dev = dev;
@@ -3360,25 +3358,6 @@ static void snd_soc_platform_drv_remove(struct snd_soc_component *component)
 	platform->driver->remove(platform);
 }
 
-static int snd_soc_platform_drv_pcm_new(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_soc_platform *platform = rtd->platform;
-
-	if (platform->driver->pcm_new)
-		return platform->driver->pcm_new(rtd);
-	else
-		return 0;
-}
-
-static void snd_soc_platform_drv_pcm_free(struct snd_pcm *pcm)
-{
-	struct snd_soc_pcm_runtime *rtd = pcm->private_data;
-	struct snd_soc_platform *platform = rtd->platform;
-
-	if (platform->driver->pcm_free)
-		platform->driver->pcm_free(pcm);
-}
-
 /**
  * snd_soc_add_platform - Add a platform to the ASoC core
  * @dev: The parent device for the platform
@@ -3402,10 +3381,6 @@ int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform,
 		platform->component.probe = snd_soc_platform_drv_probe;
 	if (platform_drv->remove)
 		platform->component.remove = snd_soc_platform_drv_remove;
-	if (platform_drv->pcm_new)
-		platform->component.pcm_new = snd_soc_platform_drv_pcm_new;
-	if (platform_drv->pcm_free)
-		platform->component.pcm_free = snd_soc_platform_drv_pcm_free;
 
 #ifdef CONFIG_DEBUG_FS
 	platform->component.debugfs_prefix = "platform";
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index dcc5ece08668..553f7a76743c 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2628,25 +2628,12 @@ static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream)
 	return ret;
 }
 
-static void soc_pcm_free(struct snd_pcm *pcm)
-{
-	struct snd_soc_pcm_runtime *rtd = pcm->private_data;
-	struct snd_soc_component *component;
-
-	list_for_each_entry(component, &rtd->card->component_dev_list,
-			    card_list) {
-		if (component->pcm_free)
-			component->pcm_free(pcm);
-	}
-}
-
 /* create a new pcm */
 int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
 {
 	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_dai *codec_dai;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	struct snd_soc_component *component;
 	struct snd_pcm *pcm;
 	char new_name[64];
 	int ret = 0, playback = 0, capture = 0;
@@ -2756,18 +2743,17 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
 	if (capture)
 		snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &rtd->ops);
 
-	list_for_each_entry(component, &rtd->card->component_dev_list, card_list) {
-		if (component->pcm_new) {
-			ret = component->pcm_new(rtd);
-			if (ret < 0) {
-				dev_err(component->dev,
-					"ASoC: pcm constructor failed: %d\n",
-					ret);
-				return ret;
-			}
+	if (platform->driver->pcm_new) {
+		ret = platform->driver->pcm_new(rtd);
+		if (ret < 0) {
+			dev_err(platform->dev,
+				"ASoC: pcm constructor failed: %d\n",
+				ret);
+			return ret;
 		}
 	}
-	pcm->private_free = soc_pcm_free;
+
+	pcm->private_free = platform->driver->pcm_free;
 out:
 	dev_info(rtd->card->dev, "%s <-> %s mapping ok\n",
 		 (rtd->num_codecs > 1) ? "multicodec" : rtd->codec_dai->name,
-- 
2.13.2

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

* [PATCH 2/2] Revert "ASoC: ux500: drop platform DAI assignments"
  2017-07-12 15:55 [PATCH 1/2] ASoC: fix pcm-creation regression Johan Hovold
@ 2017-07-12 15:55 ` Johan Hovold
  2017-07-14 13:36   ` Linus Walleij
                     ` (2 more replies)
  2017-07-14 13:35 ` [PATCH 1/2] ASoC: fix pcm-creation regression Linus Walleij
  2017-07-17 16:05 ` Applied "ASoC: fix pcm-creation regression" to the asoc tree Mark Brown
  2 siblings, 3 replies; 13+ messages in thread
From: Johan Hovold @ 2017-07-12 15:55 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown
  Cc: alsa-devel, Kuninori Morimoto, Linus Walleij, linux-kernel,
	stable, Takashi Iwai, Johan Hovold

This reverts commit f1013cdeeeb9 ("ASoC: ux500: drop platform DAI
assignments"), which seems to have been based on a misunderstanding and
prevents the platform driver callbacks from being made (e.g. to
preallocate DMA memory).

The real culprit for the warnings about attempts to create duplicate
procfs entries was commit 99b04f4c4051 ("ASoC: add Component level
pcm_new/pcm_free" that broke PCM creation on systems that use more than
one platform component.

Fixes: f1013cdeeeb9 ("ASoC: ux500: drop platform DAI assignments")
Cc: stable <stable@vger.kernel.org>	# 4.11
Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 sound/soc/ux500/mop500.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sound/soc/ux500/mop500.c b/sound/soc/ux500/mop500.c
index b50f68a439ce..ba9fc099cf67 100644
--- a/sound/soc/ux500/mop500.c
+++ b/sound/soc/ux500/mop500.c
@@ -33,6 +33,7 @@ static struct snd_soc_dai_link mop500_dai_links[] = {
 		.stream_name = "ab8500_0",
 		.cpu_dai_name = "ux500-msp-i2s.1",
 		.codec_dai_name = "ab8500-codec-dai.0",
+		.platform_name = "ux500-msp-i2s.1",
 		.codec_name = "ab8500-codec.0",
 		.init = mop500_ab8500_machine_init,
 		.ops = mop500_ab8500_ops,
@@ -42,6 +43,7 @@ static struct snd_soc_dai_link mop500_dai_links[] = {
 		.stream_name = "ab8500_1",
 		.cpu_dai_name = "ux500-msp-i2s.3",
 		.codec_dai_name = "ab8500-codec-dai.1",
+		.platform_name = "ux500-msp-i2s.3",
 		.codec_name = "ab8500-codec.0",
 		.init = NULL,
 		.ops = mop500_ab8500_ops,
@@ -85,6 +87,8 @@ static int mop500_of_probe(struct platform_device *pdev,
 	for (i = 0; i < 2; i++) {
 		mop500_dai_links[i].cpu_of_node = msp_np[i];
 		mop500_dai_links[i].cpu_dai_name = NULL;
+		mop500_dai_links[i].platform_of_node = msp_np[i];
+		mop500_dai_links[i].platform_name = NULL;
 		mop500_dai_links[i].codec_of_node = codec_np;
 		mop500_dai_links[i].codec_name = NULL;
 	}
-- 
2.13.2

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

* Re: [PATCH 1/2] ASoC: fix pcm-creation regression
  2017-07-12 15:55 [PATCH 1/2] ASoC: fix pcm-creation regression Johan Hovold
  2017-07-12 15:55 ` [PATCH 2/2] Revert "ASoC: ux500: drop platform DAI assignments" Johan Hovold
@ 2017-07-14 13:35 ` Linus Walleij
  2017-07-17  8:03   ` Johan Hovold
  2017-07-17 16:05 ` Applied "ASoC: fix pcm-creation regression" to the asoc tree Mark Brown
  2 siblings, 1 reply; 13+ messages in thread
From: Linus Walleij @ 2017-07-14 13:35 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	alsa-devel@alsa-project.org, Kuninori Morimoto,
	linux-kernel@vger.kernel.org, stable, Brian Norris

On Wed, Jul 12, 2017 at 5:55 PM, Johan Hovold <johan@kernel.org> wrote:

> This reverts commit 99b04f4c4051 ("ASoC: add Component level
> pcm_new/pcm_free"), which started calling the pcm_new callback for every
> component in a *card* when creating a new pcm, something which does not
> seem to make any sense.
>
> This specifically led to memory leaks in systems with more than one
> platform component and where DMA memory is allocated in the
> platform-driver callback. For example, when both mcasp devices are being
> used on an am335x board, DMA memory would be allocated twice for every
> DAI link during probe.
>
> When CONFIG_SND_VERBOSE_PROCFS was set this fortunately also led to
> warnings such as:
>
> WARNING: CPU: 0 PID: 565 at ../fs/proc/generic.c:346 proc_register+0x110/0x154
> proc_dir_entry 'sub0/prealloc' already registered
>
> Since there seems to be no users of the new component callbacks, and the
> current implementation introduced a regression, let's revert the
> offending commit for now.
>
> Fixes: 99b04f4c4051 ("ASoC: add Component level pcm_new/pcm_free")
> Cc: stable <stable@vger.kernel.org>     # 4.10
> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> Cc: Brian Norris <briannorris@chromium.org>
> Signed-off-by: Johan Hovold <johan@kernel.org>

I have repeatedly ran into this bug, thanks a *lot* for fixing it.
It solves a problem not only on this old code but also in my
development tree where I try to move the Ux500 audio to DT-only
instantiation and this was a blocker that I just ran my head into
the last month or two.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH 2/2] Revert "ASoC: ux500: drop platform DAI assignments"
  2017-07-12 15:55 ` [PATCH 2/2] Revert "ASoC: ux500: drop platform DAI assignments" Johan Hovold
@ 2017-07-14 13:36   ` Linus Walleij
  2017-07-17  8:07     ` Johan Hovold
  2017-07-17 14:51   ` Mark Brown
  2017-07-17 16:05   ` Applied "ASoC: ux500: Restore platform DAI assignments" to the asoc tree Mark Brown
  2 siblings, 1 reply; 13+ messages in thread
From: Linus Walleij @ 2017-07-14 13:36 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	alsa-devel@alsa-project.org, Kuninori Morimoto,
	linux-kernel@vger.kernel.org, stable

On Wed, Jul 12, 2017 at 5:55 PM, Johan Hovold <johan@kernel.org> wrote:

> This reverts commit f1013cdeeeb9 ("ASoC: ux500: drop platform DAI
> assignments"), which seems to have been based on a misunderstanding and
> prevents the platform driver callbacks from being made (e.g. to
> preallocate DMA memory).
>
> The real culprit for the warnings about attempts to create duplicate
> procfs entries was commit 99b04f4c4051 ("ASoC: add Component level
> pcm_new/pcm_free" that broke PCM creation on systems that use more than
> one platform component.
>
> Fixes: f1013cdeeeb9 ("ASoC: ux500: drop platform DAI assignments")
> Cc: stable <stable@vger.kernel.org>     # 4.11
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Johan Hovold <johan@kernel.org>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>

These static assignments should go away, but not for the wrong reason.
So this patch is fully in order given the source of the bug.

Yours,
Linus Walleij

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

* Re: [PATCH 1/2] ASoC: fix pcm-creation regression
  2017-07-14 13:35 ` [PATCH 1/2] ASoC: fix pcm-creation regression Linus Walleij
@ 2017-07-17  8:03   ` Johan Hovold
  0 siblings, 0 replies; 13+ messages in thread
From: Johan Hovold @ 2017-07-17  8:03 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Johan Hovold, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, alsa-devel@alsa-project.org, Kuninori Morimoto,
	linux-kernel@vger.kernel.org, stable, Brian Norris

On Fri, Jul 14, 2017 at 03:35:46PM +0200, Linus Walleij wrote:
> On Wed, Jul 12, 2017 at 5:55 PM, Johan Hovold <johan@kernel.org> wrote:
> 
> > This reverts commit 99b04f4c4051 ("ASoC: add Component level
> > pcm_new/pcm_free"), which started calling the pcm_new callback for every
> > component in a *card* when creating a new pcm, something which does not
> > seem to make any sense.
> >
> > This specifically led to memory leaks in systems with more than one
> > platform component and where DMA memory is allocated in the
> > platform-driver callback. For example, when both mcasp devices are being
> > used on an am335x board, DMA memory would be allocated twice for every
> > DAI link during probe.
> >
> > When CONFIG_SND_VERBOSE_PROCFS was set this fortunately also led to
> > warnings such as:
> >
> > WARNING: CPU: 0 PID: 565 at ../fs/proc/generic.c:346 proc_register+0x110/0x154
> > proc_dir_entry 'sub0/prealloc' already registered
> >
> > Since there seems to be no users of the new component callbacks, and the
> > current implementation introduced a regression, let's revert the
> > offending commit for now.
> >
> > Fixes: 99b04f4c4051 ("ASoC: add Component level pcm_new/pcm_free")
> > Cc: stable <stable@vger.kernel.org>     # 4.10
> > Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > Cc: Brian Norris <briannorris@chromium.org>
> > Signed-off-by: Johan Hovold <johan@kernel.org>
> 
> I have repeatedly ran into this bug, thanks a *lot* for fixing it.
> It solves a problem not only on this old code but also in my
> development tree where I try to move the Ux500 audio to DT-only
> instantiation and this was a blocker that I just ran my head into
> the last month or two.
> 
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> Tested-by: Linus Walleij <linus.walleij@linaro.org>

Thanks for testing these, Linus.

Johan

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

* Re: [PATCH 2/2] Revert "ASoC: ux500: drop platform DAI assignments"
  2017-07-14 13:36   ` Linus Walleij
@ 2017-07-17  8:07     ` Johan Hovold
  0 siblings, 0 replies; 13+ messages in thread
From: Johan Hovold @ 2017-07-17  8:07 UTC (permalink / raw)
  To: Linus Walleij
  Cc: alsa-devel@alsa-project.org, Kuninori Morimoto, Liam Girdwood,
	linux-kernel@vger.kernel.org, Takashi Iwai, stable, Mark Brown,
	Johan Hovold

On Fri, Jul 14, 2017 at 03:36:57PM +0200, Linus Walleij wrote:
> On Wed, Jul 12, 2017 at 5:55 PM, Johan Hovold <johan@kernel.org> wrote:
> 
> > This reverts commit f1013cdeeeb9 ("ASoC: ux500: drop platform DAI
> > assignments"), which seems to have been based on a misunderstanding and
> > prevents the platform driver callbacks from being made (e.g. to
> > preallocate DMA memory).
> >
> > The real culprit for the warnings about attempts to create duplicate
> > procfs entries was commit 99b04f4c4051 ("ASoC: add Component level
> > pcm_new/pcm_free" that broke PCM creation on systems that use more than
> > one platform component.
> >
> > Fixes: f1013cdeeeb9 ("ASoC: ux500: drop platform DAI assignments")
> > Cc: stable <stable@vger.kernel.org>     # 4.11
> > Cc: Linus Walleij <linus.walleij@linaro.org>
> > Signed-off-by: Johan Hovold <johan@kernel.org>
> 
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> Tested-by: Linus Walleij <linus.walleij@linaro.org>
> 
> These static assignments should go away, but not for the wrong reason.
> So this patch is fully in order given the source of the bug.

I assume you'll still need the of-related bits though (platform_of_node)
even if you eventually make this driver use DT-instantiation only.

Thanks again,
Johan

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

* Re: [PATCH 2/2] Revert "ASoC: ux500: drop platform DAI assignments"
  2017-07-12 15:55 ` [PATCH 2/2] Revert "ASoC: ux500: drop platform DAI assignments" Johan Hovold
  2017-07-14 13:36   ` Linus Walleij
@ 2017-07-17 14:51   ` Mark Brown
  2017-07-18  8:21     ` Johan Hovold
  2017-07-17 16:05   ` Applied "ASoC: ux500: Restore platform DAI assignments" to the asoc tree Mark Brown
  2 siblings, 1 reply; 13+ messages in thread
From: Mark Brown @ 2017-07-17 14:51 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Linus Walleij,
	alsa-devel, Kuninori Morimoto, linux-kernel, stable

[-- Attachment #1: Type: text/plain, Size: 583 bytes --]

On Wed, Jul 12, 2017 at 05:55:30PM +0200, Johan Hovold wrote:
> This reverts commit f1013cdeeeb9 ("ASoC: ux500: drop platform DAI
> assignments"), which seems to have been based on a misunderstanding and
> prevents the platform driver callbacks from being made (e.g. to
> preallocate DMA memory).

Please submit patches using subject lines reflecting the style for the
subsystem.  This makes it easier for people to identify relevant
patches.  Look at what existing commits in the area you're changing are
doing and make sure your subject lines visually resemble what they're
doing.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Applied "ASoC: ux500: Restore platform DAI assignments" to the asoc tree
  2017-07-12 15:55 ` [PATCH 2/2] Revert "ASoC: ux500: drop platform DAI assignments" Johan Hovold
  2017-07-14 13:36   ` Linus Walleij
  2017-07-17 14:51   ` Mark Brown
@ 2017-07-17 16:05   ` Mark Brown
  2 siblings, 0 replies; 13+ messages in thread
From: Mark Brown @ 2017-07-17 16:05 UTC (permalink / raw)
  To: Johan Hovold; +Cc: Linus Walleij, Mark Brown, stable, Liam Girdwood

The patch

   ASoC: ux500: Restore platform DAI assignments

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

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

>From 651e9268fb9b9944e063d731b09c0d2ad339bedb Mon Sep 17 00:00:00 2001
From: Johan Hovold <johan@kernel.org>
Date: Wed, 12 Jul 2017 17:55:30 +0200
Subject: [PATCH] ASoC: ux500: Restore platform DAI assignments

This reverts commit f1013cdeeeb9 ("ASoC: ux500: drop platform DAI
assignments"), which seems to have been based on a misunderstanding and
prevents the platform driver callbacks from being made (e.g. to
preallocate DMA memory).

The real culprit for the warnings about attempts to create duplicate
procfs entries was commit 99b04f4c4051 ("ASoC: add Component level
pcm_new/pcm_free" that broke PCM creation on systems that use more than
one platform component.

Fixes: f1013cdeeeb9 ("ASoC: ux500: drop platform DAI assignments")
Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable <stable@vger.kernel.org>	# 4.11
---
 sound/soc/ux500/mop500.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sound/soc/ux500/mop500.c b/sound/soc/ux500/mop500.c
index b50f68a439ce..ba9fc099cf67 100644
--- a/sound/soc/ux500/mop500.c
+++ b/sound/soc/ux500/mop500.c
@@ -33,6 +33,7 @@ static struct snd_soc_dai_link mop500_dai_links[] = {
 		.stream_name = "ab8500_0",
 		.cpu_dai_name = "ux500-msp-i2s.1",
 		.codec_dai_name = "ab8500-codec-dai.0",
+		.platform_name = "ux500-msp-i2s.1",
 		.codec_name = "ab8500-codec.0",
 		.init = mop500_ab8500_machine_init,
 		.ops = mop500_ab8500_ops,
@@ -42,6 +43,7 @@ static struct snd_soc_dai_link mop500_dai_links[] = {
 		.stream_name = "ab8500_1",
 		.cpu_dai_name = "ux500-msp-i2s.3",
 		.codec_dai_name = "ab8500-codec-dai.1",
+		.platform_name = "ux500-msp-i2s.3",
 		.codec_name = "ab8500-codec.0",
 		.init = NULL,
 		.ops = mop500_ab8500_ops,
@@ -85,6 +87,8 @@ static int mop500_of_probe(struct platform_device *pdev,
 	for (i = 0; i < 2; i++) {
 		mop500_dai_links[i].cpu_of_node = msp_np[i];
 		mop500_dai_links[i].cpu_dai_name = NULL;
+		mop500_dai_links[i].platform_of_node = msp_np[i];
+		mop500_dai_links[i].platform_name = NULL;
 		mop500_dai_links[i].codec_of_node = codec_np;
 		mop500_dai_links[i].codec_name = NULL;
 	}
-- 
2.13.2

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

* Applied "ASoC: fix pcm-creation regression" to the asoc tree
  2017-07-12 15:55 [PATCH 1/2] ASoC: fix pcm-creation regression Johan Hovold
  2017-07-12 15:55 ` [PATCH 2/2] Revert "ASoC: ux500: drop platform DAI assignments" Johan Hovold
  2017-07-14 13:35 ` [PATCH 1/2] ASoC: fix pcm-creation regression Linus Walleij
@ 2017-07-17 16:05 ` Mark Brown
  2 siblings, 0 replies; 13+ messages in thread
From: Mark Brown @ 2017-07-17 16:05 UTC (permalink / raw)
  To: Johan Hovold; +Cc: Linus Walleij, Mark Brown, stable, Liam Girdwood

The patch

   ASoC: fix pcm-creation regression

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

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

>From c641e5b207ed7dfaa692820aeb5b6dde3de3e9b0 Mon Sep 17 00:00:00 2001
From: Johan Hovold <johan@kernel.org>
Date: Wed, 12 Jul 2017 17:55:29 +0200
Subject: [PATCH] ASoC: fix pcm-creation regression

This reverts commit 99b04f4c4051 ("ASoC: add Component level
pcm_new/pcm_free"), which started calling the pcm_new callback for every
component in a *card* when creating a new pcm, something which does not
seem to make any sense.

This specifically led to memory leaks in systems with more than one
platform component and where DMA memory is allocated in the
platform-driver callback. For example, when both mcasp devices are being
used on an am335x board, DMA memory would be allocated twice for every
DAI link during probe.

When CONFIG_SND_VERBOSE_PROCFS was set this fortunately also led to
warnings such as:

WARNING: CPU: 0 PID: 565 at ../fs/proc/generic.c:346 proc_register+0x110/0x154
proc_dir_entry 'sub0/prealloc' already registered

Since there seems to be no users of the new component callbacks, and the
current implementation introduced a regression, let's revert the
offending commit for now.

Fixes: 99b04f4c4051 ("ASoC: add Component level pcm_new/pcm_free")
Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable <stable@vger.kernel.org>	# 4.10
---
 include/sound/soc.h  |  6 ------
 sound/soc/soc-core.c | 25 -------------------------
 sound/soc/soc-pcm.c  | 32 +++++++++-----------------------
 3 files changed, 9 insertions(+), 54 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 9c94b97c17f8..c4a8b1947566 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -795,10 +795,6 @@ struct snd_soc_component_driver {
 	int (*suspend)(struct snd_soc_component *);
 	int (*resume)(struct snd_soc_component *);
 
-	/* pcm creation and destruction */
-	int (*pcm_new)(struct snd_soc_pcm_runtime *);
-	void (*pcm_free)(struct snd_pcm *);
-
 	/* DT */
 	int (*of_xlate_dai_name)(struct snd_soc_component *component,
 				 struct of_phandle_args *args,
@@ -874,8 +870,6 @@ struct snd_soc_component {
 	void (*remove)(struct snd_soc_component *);
 	int (*suspend)(struct snd_soc_component *);
 	int (*resume)(struct snd_soc_component *);
-	int (*pcm_new)(struct snd_soc_pcm_runtime *);
-	void (*pcm_free)(struct snd_pcm *);
 
 	/* machine specific init */
 	int (*init)(struct snd_soc_component *component);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 921622a01944..c240e13ba057 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3171,8 +3171,6 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
 	component->remove = component->driver->remove;
 	component->suspend = component->driver->suspend;
 	component->resume = component->driver->resume;
-	component->pcm_new = component->driver->pcm_new;
-	component->pcm_free = component->driver->pcm_free;
 
 	dapm = &component->dapm;
 	dapm->dev = dev;
@@ -3360,25 +3358,6 @@ static void snd_soc_platform_drv_remove(struct snd_soc_component *component)
 	platform->driver->remove(platform);
 }
 
-static int snd_soc_platform_drv_pcm_new(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_soc_platform *platform = rtd->platform;
-
-	if (platform->driver->pcm_new)
-		return platform->driver->pcm_new(rtd);
-	else
-		return 0;
-}
-
-static void snd_soc_platform_drv_pcm_free(struct snd_pcm *pcm)
-{
-	struct snd_soc_pcm_runtime *rtd = pcm->private_data;
-	struct snd_soc_platform *platform = rtd->platform;
-
-	if (platform->driver->pcm_free)
-		platform->driver->pcm_free(pcm);
-}
-
 /**
  * snd_soc_add_platform - Add a platform to the ASoC core
  * @dev: The parent device for the platform
@@ -3402,10 +3381,6 @@ int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform,
 		platform->component.probe = snd_soc_platform_drv_probe;
 	if (platform_drv->remove)
 		platform->component.remove = snd_soc_platform_drv_remove;
-	if (platform_drv->pcm_new)
-		platform->component.pcm_new = snd_soc_platform_drv_pcm_new;
-	if (platform_drv->pcm_free)
-		platform->component.pcm_free = snd_soc_platform_drv_pcm_free;
 
 #ifdef CONFIG_DEBUG_FS
 	platform->component.debugfs_prefix = "platform";
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index dcc5ece08668..553f7a76743c 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2628,25 +2628,12 @@ static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream)
 	return ret;
 }
 
-static void soc_pcm_free(struct snd_pcm *pcm)
-{
-	struct snd_soc_pcm_runtime *rtd = pcm->private_data;
-	struct snd_soc_component *component;
-
-	list_for_each_entry(component, &rtd->card->component_dev_list,
-			    card_list) {
-		if (component->pcm_free)
-			component->pcm_free(pcm);
-	}
-}
-
 /* create a new pcm */
 int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
 {
 	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_dai *codec_dai;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	struct snd_soc_component *component;
 	struct snd_pcm *pcm;
 	char new_name[64];
 	int ret = 0, playback = 0, capture = 0;
@@ -2756,18 +2743,17 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
 	if (capture)
 		snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &rtd->ops);
 
-	list_for_each_entry(component, &rtd->card->component_dev_list, card_list) {
-		if (component->pcm_new) {
-			ret = component->pcm_new(rtd);
-			if (ret < 0) {
-				dev_err(component->dev,
-					"ASoC: pcm constructor failed: %d\n",
-					ret);
-				return ret;
-			}
+	if (platform->driver->pcm_new) {
+		ret = platform->driver->pcm_new(rtd);
+		if (ret < 0) {
+			dev_err(platform->dev,
+				"ASoC: pcm constructor failed: %d\n",
+				ret);
+			return ret;
 		}
 	}
-	pcm->private_free = soc_pcm_free;
+
+	pcm->private_free = platform->driver->pcm_free;
 out:
 	dev_info(rtd->card->dev, "%s <-> %s mapping ok\n",
 		 (rtd->num_codecs > 1) ? "multicodec" : rtd->codec_dai->name,
-- 
2.13.2

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

* Re: [PATCH 2/2] Revert "ASoC: ux500: drop platform DAI assignments"
  2017-07-17 14:51   ` Mark Brown
@ 2017-07-18  8:21     ` Johan Hovold
  2017-07-18 10:06       ` Mark Brown
  0 siblings, 1 reply; 13+ messages in thread
From: Johan Hovold @ 2017-07-18  8:21 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, Kuninori Morimoto, Liam Girdwood, linux-kernel,
	Linus Walleij, Takashi Iwai, stable, Johan Hovold

On Mon, Jul 17, 2017 at 03:51:27PM +0100, Mark Brown wrote:
> On Wed, Jul 12, 2017 at 05:55:30PM +0200, Johan Hovold wrote:
> > This reverts commit f1013cdeeeb9 ("ASoC: ux500: drop platform DAI
> > assignments"), which seems to have been based on a misunderstanding and
> > prevents the platform driver callbacks from being made (e.g. to
> > preallocate DMA memory).
> 
> Please submit patches using subject lines reflecting the style for the
> subsystem.  This makes it easier for people to identify relevant
> patches.  Look at what existing commits in the area you're changing are
> doing and make sure your subject lines visually resemble what they're
> doing.

I try to, but reverts are special as the default commit summary tend to
already contain the subsystem prefix and some maintainers find that
sufficient (or even preferred as this also makes reverts stand out more
clearly).

But now I know your preference, and thanks for fixing it up this time
before applying.

Johan

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

* Re: [PATCH 2/2] Revert "ASoC: ux500: drop platform DAI assignments"
  2017-07-18  8:21     ` Johan Hovold
@ 2017-07-18 10:06       ` Mark Brown
  2017-07-18 10:36         ` Johan Hovold
  0 siblings, 1 reply; 13+ messages in thread
From: Mark Brown @ 2017-07-18 10:06 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Linus Walleij,
	alsa-devel, Kuninori Morimoto, linux-kernel, stable

[-- Attachment #1: Type: text/plain, Size: 775 bytes --]

On Tue, Jul 18, 2017 at 10:21:18AM +0200, Johan Hovold wrote:
> On Mon, Jul 17, 2017 at 03:51:27PM +0100, Mark Brown wrote:

> > Please submit patches using subject lines reflecting the style for the
> > subsystem.  This makes it easier for people to identify relevant
> > patches.  Look at what existing commits in the area you're changing are
> > doing and make sure your subject lines visually resemble what they're
> > doing.

> I try to, but reverts are special as the default commit summary tend to
> already contain the subsystem prefix and some maintainers find that
> sufficient (or even preferred as this also makes reverts stand out more
> clearly).

Reverts shouldn't be special - they're just regular patches and should
have sensible changelogs like any others.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 2/2] Revert "ASoC: ux500: drop platform DAI assignments"
  2017-07-18 10:06       ` Mark Brown
@ 2017-07-18 10:36         ` Johan Hovold
  2017-07-18 12:59           ` Mark Brown
  0 siblings, 1 reply; 13+ messages in thread
From: Johan Hovold @ 2017-07-18 10:36 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, Kuninori Morimoto, Liam Girdwood, linux-kernel,
	Linus Walleij, Takashi Iwai, stable, Johan Hovold

On Tue, Jul 18, 2017 at 11:06:55AM +0100, Mark Brown wrote:
> On Tue, Jul 18, 2017 at 10:21:18AM +0200, Johan Hovold wrote:
> > On Mon, Jul 17, 2017 at 03:51:27PM +0100, Mark Brown wrote:
> 
> > > Please submit patches using subject lines reflecting the style for the
> > > subsystem.  This makes it easier for people to identify relevant
> > > patches.  Look at what existing commits in the area you're changing are
> > > doing and make sure your subject lines visually resemble what they're
> > > doing.
> 
> > I try to, but reverts are special as the default commit summary tend to
> > already contain the subsystem prefix and some maintainers find that
> > sufficient (or even preferred as this also makes reverts stand out more
> > clearly).
> 
> Reverts shouldn't be special - they're just regular patches and should
> have sensible changelogs like any others.

Stating that you're reverting a commit and which commit that is is in
the summary is arguable sensible (of course, you still also need further
details in the commit message body itself describing why it was needed).

Check the logs and you'll see that we have a ton of "Revert <reverted
commit summary>" for various subsystems. In fact, it seems to be by far
the most common summary for direct reverts.

But again, now I know your preference.

Johan

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

* Re: [PATCH 2/2] Revert "ASoC: ux500: drop platform DAI assignments"
  2017-07-18 10:36         ` Johan Hovold
@ 2017-07-18 12:59           ` Mark Brown
  0 siblings, 0 replies; 13+ messages in thread
From: Mark Brown @ 2017-07-18 12:59 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Linus Walleij,
	alsa-devel, Kuninori Morimoto, linux-kernel, stable

[-- Attachment #1: Type: text/plain, Size: 889 bytes --]

On Tue, Jul 18, 2017 at 12:36:29PM +0200, Johan Hovold wrote:
> On Tue, Jul 18, 2017 at 11:06:55AM +0100, Mark Brown wrote:

> > Reverts shouldn't be special - they're just regular patches and should
> > have sensible changelogs like any others.

> Stating that you're reverting a commit and which commit that is is in
> the summary is arguable sensible (of course, you still also need further
> details in the commit message body itself describing why it was needed).

> Check the logs and you'll see that we have a ton of "Revert <reverted
> commit summary>" for various subsystems. In fact, it seems to be by far
> the most common summary for direct reverts.

The easily findable ones are, and it doesn't mean it's good practice -
reverts seem to attract particularly bad commit messages in general, not
just the subject lines, and I happen to have a pre-canned response for
this so...

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2017-07-18 12:59 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-12 15:55 [PATCH 1/2] ASoC: fix pcm-creation regression Johan Hovold
2017-07-12 15:55 ` [PATCH 2/2] Revert "ASoC: ux500: drop platform DAI assignments" Johan Hovold
2017-07-14 13:36   ` Linus Walleij
2017-07-17  8:07     ` Johan Hovold
2017-07-17 14:51   ` Mark Brown
2017-07-18  8:21     ` Johan Hovold
2017-07-18 10:06       ` Mark Brown
2017-07-18 10:36         ` Johan Hovold
2017-07-18 12:59           ` Mark Brown
2017-07-17 16:05   ` Applied "ASoC: ux500: Restore platform DAI assignments" to the asoc tree Mark Brown
2017-07-14 13:35 ` [PATCH 1/2] ASoC: fix pcm-creation regression Linus Walleij
2017-07-17  8:03   ` Johan Hovold
2017-07-17 16:05 ` Applied "ASoC: fix pcm-creation regression" to the asoc tree Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).