aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2017-07-12 11:55:29 -0400
committerMark Brown <broonie@kernel.org>2017-07-17 10:50:32 -0400
commitc641e5b207ed7dfaa692820aeb5b6dde3de3e9b0 (patch)
tree32db6d91738de6ae0b00b6816068eb0ad109faae
parent5771a8c08880cdca3bfb4a3fc6d309d6bba20877 (diff)
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
-rw-r--r--include/sound/soc.h6
-rw-r--r--sound/soc/soc-core.c25
-rw-r--r--sound/soc/soc-pcm.c32
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 {
795 int (*suspend)(struct snd_soc_component *); 795 int (*suspend)(struct snd_soc_component *);
796 int (*resume)(struct snd_soc_component *); 796 int (*resume)(struct snd_soc_component *);
797 797
798 /* pcm creation and destruction */
799 int (*pcm_new)(struct snd_soc_pcm_runtime *);
800 void (*pcm_free)(struct snd_pcm *);
801
802 /* DT */ 798 /* DT */
803 int (*of_xlate_dai_name)(struct snd_soc_component *component, 799 int (*of_xlate_dai_name)(struct snd_soc_component *component,
804 struct of_phandle_args *args, 800 struct of_phandle_args *args,
@@ -874,8 +870,6 @@ struct snd_soc_component {
874 void (*remove)(struct snd_soc_component *); 870 void (*remove)(struct snd_soc_component *);
875 int (*suspend)(struct snd_soc_component *); 871 int (*suspend)(struct snd_soc_component *);
876 int (*resume)(struct snd_soc_component *); 872 int (*resume)(struct snd_soc_component *);
877 int (*pcm_new)(struct snd_soc_pcm_runtime *);
878 void (*pcm_free)(struct snd_pcm *);
879 873
880 /* machine specific init */ 874 /* machine specific init */
881 int (*init)(struct snd_soc_component *component); 875 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,
3171 component->remove = component->driver->remove; 3171 component->remove = component->driver->remove;
3172 component->suspend = component->driver->suspend; 3172 component->suspend = component->driver->suspend;
3173 component->resume = component->driver->resume; 3173 component->resume = component->driver->resume;
3174 component->pcm_new = component->driver->pcm_new;
3175 component->pcm_free = component->driver->pcm_free;
3176 3174
3177 dapm = &component->dapm; 3175 dapm = &component->dapm;
3178 dapm->dev = dev; 3176 dapm->dev = dev;
@@ -3360,25 +3358,6 @@ static void snd_soc_platform_drv_remove(struct snd_soc_component *component)
3360 platform->driver->remove(platform); 3358 platform->driver->remove(platform);
3361} 3359}
3362 3360
3363static int snd_soc_platform_drv_pcm_new(struct snd_soc_pcm_runtime *rtd)
3364{
3365 struct snd_soc_platform *platform = rtd->platform;
3366
3367 if (platform->driver->pcm_new)
3368 return platform->driver->pcm_new(rtd);
3369 else
3370 return 0;
3371}
3372
3373static void snd_soc_platform_drv_pcm_free(struct snd_pcm *pcm)
3374{
3375 struct snd_soc_pcm_runtime *rtd = pcm->private_data;
3376 struct snd_soc_platform *platform = rtd->platform;
3377
3378 if (platform->driver->pcm_free)
3379 platform->driver->pcm_free(pcm);
3380}
3381
3382/** 3361/**
3383 * snd_soc_add_platform - Add a platform to the ASoC core 3362 * snd_soc_add_platform - Add a platform to the ASoC core
3384 * @dev: The parent device for the platform 3363 * @dev: The parent device for the platform
@@ -3402,10 +3381,6 @@ int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform,
3402 platform->component.probe = snd_soc_platform_drv_probe; 3381 platform->component.probe = snd_soc_platform_drv_probe;
3403 if (platform_drv->remove) 3382 if (platform_drv->remove)
3404 platform->component.remove = snd_soc_platform_drv_remove; 3383 platform->component.remove = snd_soc_platform_drv_remove;
3405 if (platform_drv->pcm_new)
3406 platform->component.pcm_new = snd_soc_platform_drv_pcm_new;
3407 if (platform_drv->pcm_free)
3408 platform->component.pcm_free = snd_soc_platform_drv_pcm_free;
3409 3384
3410#ifdef CONFIG_DEBUG_FS 3385#ifdef CONFIG_DEBUG_FS
3411 platform->component.debugfs_prefix = "platform"; 3386 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)
2628 return ret; 2628 return ret;
2629} 2629}
2630 2630
2631static void soc_pcm_free(struct snd_pcm *pcm)
2632{
2633 struct snd_soc_pcm_runtime *rtd = pcm->private_data;
2634 struct snd_soc_component *component;
2635
2636 list_for_each_entry(component, &rtd->card->component_dev_list,
2637 card_list) {
2638 if (component->pcm_free)
2639 component->pcm_free(pcm);
2640 }
2641}
2642
2643/* create a new pcm */ 2631/* create a new pcm */
2644int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) 2632int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
2645{ 2633{
2646 struct snd_soc_platform *platform = rtd->platform; 2634 struct snd_soc_platform *platform = rtd->platform;
2647 struct snd_soc_dai *codec_dai; 2635 struct snd_soc_dai *codec_dai;
2648 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 2636 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
2649 struct snd_soc_component *component;
2650 struct snd_pcm *pcm; 2637 struct snd_pcm *pcm;
2651 char new_name[64]; 2638 char new_name[64];
2652 int ret = 0, playback = 0, capture = 0; 2639 int ret = 0, playback = 0, capture = 0;
@@ -2756,18 +2743,17 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
2756 if (capture) 2743 if (capture)
2757 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &rtd->ops); 2744 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &rtd->ops);
2758 2745
2759 list_for_each_entry(component, &rtd->card->component_dev_list, card_list) { 2746 if (platform->driver->pcm_new) {
2760 if (component->pcm_new) { 2747 ret = platform->driver->pcm_new(rtd);
2761 ret = component->pcm_new(rtd); 2748 if (ret < 0) {
2762 if (ret < 0) { 2749 dev_err(platform->dev,
2763 dev_err(component->dev, 2750 "ASoC: pcm constructor failed: %d\n",
2764 "ASoC: pcm constructor failed: %d\n", 2751 ret);
2765 ret); 2752 return ret;
2766 return ret;
2767 }
2768 } 2753 }
2769 } 2754 }
2770 pcm->private_free = soc_pcm_free; 2755
2756 pcm->private_free = platform->driver->pcm_free;
2771out: 2757out:
2772 dev_info(rtd->card->dev, "%s <-> %s mapping ok\n", 2758 dev_info(rtd->card->dev, "%s <-> %s mapping ok\n",
2773 (rtd->num_codecs > 1) ? "multicodec" : rtd->codec_dai->name, 2759 (rtd->num_codecs > 1) ? "multicodec" : rtd->codec_dai->name,