From 77df181d08dd337a2c2d889101145cfe7a1e5379 Mon Sep 17 00:00:00 2001 From: Vladimir Barinov Date: Tue, 7 Nov 2017 20:23:14 +0300 Subject: Replace pcm creation fix with upstream varian --- ...-check-condition-of-multiple-bindings-of-.patch | 42 +---- .../0079-ASoC-fix-pcm-creation-regression.patch | 173 +++++++++++++++++++++ .../linux/linux-renesas_4.9.bbappend | 1 + 3 files changed, 175 insertions(+), 41 deletions(-) create mode 100644 meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0079-ASoC-fix-pcm-creation-regression.patch (limited to 'meta-rcar-gen3-adas') diff --git a/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0022-ASoC-Modify-check-condition-of-multiple-bindings-of-.patch b/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0022-ASoC-Modify-check-condition-of-multiple-bindings-of-.patch index 73e2150..d979a41 100644 --- a/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0022-ASoC-Modify-check-condition-of-multiple-bindings-of-.patch +++ b/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0022-ASoC-Modify-check-condition-of-multiple-bindings-of-.patch @@ -18,8 +18,7 @@ Or we have to enable only one of them in dts file as it is designed. Signed-off-by: Andrey Gusakov --- sound/soc/soc-core.c | 6 ++++-- - sound/soc/soc-pcm.c | 9 +++++++++ - 2 files changed, 13 insertions(+), 2 deletions(-) + 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 16369ca..899d013 100644 @@ -45,44 +44,5 @@ index 16369ca..899d013 100644 ret = snd_soc_register_dais(cmpnt, dai_drv, num_dai, true); if (ret < 0) { -diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c -index f6667e4..719c866 100644 ---- a/sound/soc/soc-pcm.c -+++ b/sound/soc/soc-pcm.c -@@ -2632,11 +2632,16 @@ static void soc_pcm_free(struct snd_pcm *pcm) - { - struct snd_soc_pcm_runtime *rtd = pcm->private_data; - struct snd_soc_component *component; -+ struct snd_soc_platform *platform = rtd->platform; - - list_for_each_entry(component, &rtd->card->component_dev_list, - card_list) { -+ if (!component->registered_as_component) -+ component = &platform->component; - if (component->pcm_free) - component->pcm_free(pcm); -+ if (!component->registered_as_component) -+ break; - } - } - -@@ -2756,6 +2761,8 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) - 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->registered_as_component) -+ component = &platform->component; - if (component->pcm_new) { - ret = component->pcm_new(rtd); - if (ret < 0) { -@@ -2765,6 +2772,8 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) - return ret; - } - } -+ if (!component->registered_as_component) -+ break; - } - pcm->private_free = soc_pcm_free; - out: -- 1.7.10.4 diff --git a/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0079-ASoC-fix-pcm-creation-regression.patch b/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0079-ASoC-fix-pcm-creation-regression.patch new file mode 100644 index 0000000..ab0048c --- /dev/null +++ b/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0079-ASoC-fix-pcm-creation-regression.patch @@ -0,0 +1,173 @@ +From c641e5b207ed7dfaa692820aeb5b6dde3de3e9b0 Mon Sep 17 00:00:00 2001 +From: Johan Hovold +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 +Reviewed-by: Linus Walleij +Tested-by: Linus Walleij +Signed-off-by: Mark Brown +Cc: stable # 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 9c94b97..c4a8b19 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 921622a..c240e13 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 dcc5ece..553f7a7 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, +-- +1.9.1 + diff --git a/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas_4.9.bbappend b/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas_4.9.bbappend index 01446c4..7421ef9 100644 --- a/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas_4.9.bbappend +++ b/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas_4.9.bbappend @@ -66,6 +66,7 @@ SRC_URI_append = " \ file://0076-MOST-dim2-Renesas-R-Car3-variant.patch \ file://0077-MOST-dim2-add-timeouts.patch \ file://0078-MOST-aim-fix-null-pointer-crash.patch \ + file://0079-ASoC-fix-pcm-creation-regression.patch \ " SRC_URI_append_h3ulcb = " file://ulcb.cfg" -- cgit 1.2.3-korg