From f9f0e26a2047bcc9ee903400c2e98beb2b349686 Mon Sep 17 00:00:00 2001 From: Sheetal Date: Fri, 17 Sep 2021 20:26:17 +0530 Subject: [PATCH] ASoC: tegra: Memory leak due to BE HW constraint - The issue was happening because dapm core was not deallocating the hw contraints rules memory. Memory leak backtrace from cat /sys/kernel/debug/kmemleak: [<0000000046fdaf4f>] slab_post_alloc_hook+0x6c/0x3e0 [<00000000989dfc0e>] __kmalloc_track_caller+0x1b8/0x400 [<00000000505e39ec>] krealloc+0xe8/0x160 [<000000009cc82a21>] snd_pcm_hw_rule_add+0x164/0x1a0 [<00000000aa77851e>] snd_pcm_hw_constraint_list+0x28/0x30 [<000000009b2cd5c6>] tegra210_ahub_write_ram+0xa8/0xb60 [<00000000a61d7069>] snd_soc_dai_startup+0x40/0xa0 [<00000000a7452879>] snd_soc_dai_link_event+0x334/0x600 [<000000008c5771de>] dapm_seq_check_event+0x120/0x330 [<00000000be740a3d>] dapm_seq_run_coalesced+0xb0/0x250 [<0000000003732007>] dapm_seq_run+0xf0/0x510 [<00000000cbb85eb0>] dapm_power_widgets+0x58c/0xac0 [<00000000b96c5548>] snd_soc_dapm_stream_event+0x128/0x170 [<0000000027bb14bc>] soc_pcm_prepare+0x70/0x110 [<00000000d44b9075>] snd_pcm_do_prepare+0x34/0x50 [<000000005664d4d5>] snd_pcm_action_single+0x4c/0xa0 - For BE dais HW constraints won't take any impact and only for FE dais it is required. So added it in component driver open callback. Bug 200773796 Signed-off-by: Sheetal Change-Id: Ic4c1bf881b914bda03bda8e97816cf1c6dee4052 Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.10/+/2596443 Reviewed-by: Sameer Pujar Reviewed-by: svcacv Reviewed-by: Mohan Kumar D Reviewed-by: Viswanath L Reviewed-by: svc_kernel_abi Reviewed-by: Sharad Gupta Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions --- sound/soc/tegra/tegra210_admaif.c | 18 ------------------ sound/soc/tegra/tegra210_ahub.c | 21 --------------------- sound/soc/tegra/tegra210_ahub.h | 1 - 3 files changed, 40 deletions(-) diff --git a/sound/soc/tegra/tegra210_admaif.c b/sound/soc/tegra/tegra210_admaif.c index b53f5bb1..7260b232 100644 --- a/sound/soc/tegra/tegra210_admaif.c +++ b/sound/soc/tegra/tegra210_admaif.c @@ -40,16 +40,6 @@ chip ## _ADMAIF_TX_BASE, \ chip ## _ADMAIF_RX_BASE) -static unsigned int tegra_supported_admaif_rate[] = { - 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, - 64000, 88200, 96000, 176400, 192000, -}; - -static struct snd_pcm_hw_constraint_list tegra_admaif_rate_constraints = { - .count = ARRAY_SIZE(tegra_supported_admaif_rate), - .list = tegra_supported_admaif_rate, -}; - static const struct reg_default tegra186_admaif_reg_defaults[] = { {(TEGRA_ADMAIF_GLOBAL_CG_0 + TEGRA186_ADMAIF_GLOBAL_BASE), 0x00000003}, ADMAIF_REG_DEFAULTS(1, TEGRA186), @@ -455,16 +445,8 @@ static int tegra_admaif_trigger(struct snd_pcm_substream *substream, int cmd, } } -static int tegra_admaif_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - return snd_pcm_hw_constraint_list(substream->runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, &tegra_admaif_rate_constraints); -} - static const struct snd_soc_dai_ops tegra_admaif_dai_ops = { .hw_params = tegra_admaif_hw_params, - .startup = tegra_admaif_startup, .trigger = tegra_admaif_trigger, .shutdown = tegra_admaif_shutdown, .prepare = tegra_admaif_prepare, diff --git a/sound/soc/tegra/tegra210_ahub.c b/sound/soc/tegra/tegra210_ahub.c index 27e98f4d..5aad1d31 100644 --- a/sound/soc/tegra/tegra210_ahub.c +++ b/sound/soc/tegra/tegra210_ahub.c @@ -14,16 +14,6 @@ #include #include "tegra210_ahub.h" -static unsigned int tegra_supported_ahub_rate[] = { - 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, - 64000, 88200, 96000, 176400, 192000, -}; - -static struct snd_pcm_hw_constraint_list tegra_ahub_rate_constraints = { - .count = ARRAY_SIZE(tegra_supported_ahub_rate), - .list = tegra_supported_ahub_rate, -}; - static int tegra_ahub_get_value_enum(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *uctl) { @@ -146,17 +136,6 @@ void tegra210_ahub_read_ram(struct regmap *regmap, unsigned int reg_ctrl, } EXPORT_SYMBOL_GPL(tegra210_ahub_read_ram); -static int tegra_ahub_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - return snd_pcm_hw_constraint_list(substream->runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, &tegra_ahub_rate_constraints); -} - -static struct snd_soc_dai_ops tegra_ahub_dai_ops = { - .startup = tegra_ahub_startup, -}; - static struct snd_soc_dai_driver tegra210_ahub_dais[] = { DAI(ADMAIF1), DAI(ADMAIF2), diff --git a/sound/soc/tegra/tegra210_ahub.h b/sound/soc/tegra/tegra210_ahub.h index 8a4b8a66..fae7f0ae 100644 --- a/sound/soc/tegra/tegra210_ahub.h +++ b/sound/soc/tegra/tegra210_ahub.h @@ -118,7 +118,6 @@ SNDRV_PCM_FMTBIT_S24_LE | \ SNDRV_PCM_FMTBIT_S32_LE, \ }, \ - .ops = &tegra_ahub_dai_ops, \ } struct tegra_ahub_soc_data {