ASoC: mediatek: Use managed buffer allocation
Subsystems (4)
PATCH v2 1/2 ASoC: mediatek: Use managed buffer allocation
Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped, as well as the superfluous snd_pcm_lib_preallocate_free_for_all() call. As of the result, hw_free and pcm_destruct ops became empty and got removed.
--- sound/soc/mediatek/common/mtk-afe-fe-dai.c | 6 +----- sound/soc/mediatek/common/mtk-afe-platform-driver.c | 12 ++---------- sound/soc/mediatek/common/mtk-afe-platform-driver.h | 2 -- sound/soc/mediatek/mt6797/mt6797-afe-pcm.c | 1 - sound/soc/mediatek/mt8183/mt8183-afe-pcm.c | 1 - 5 files changed, 3 insertions(+), 19 deletions(-)
sound/soc/mediatek/common/mtk-afe-fe-dai.c +1 -5
@@ -129,10 +129,6 @@ int mtk_afe_fe_hw_params(struct snd_pcm_substream *substream,unsigned int rate =params_rate (params);snd_pcm_format_t format =params_format (params); - ret =snd_pcm_lib_malloc_pages (substream,params_buffer_bytes (params)); -if (ret <0 ) -return ret; -if (afe->request_dram_resource) afe->request_dram_resource (afe->dev);
@@ -193,7 +189,7 @@ int mtk_afe_fe_hw_free(struct snd_pcm_substream *substream,if (afe->release_dram_resource) afe->release_dram_resource (afe->dev); -return snd_pcm_lib_free_pages (substream); +return 0 ; }EXPORT_SYMBOL_GPL (mtk_afe_fe_hw_free);
sound/soc/mediatek/common/mtk-afe-platform-driver.c +2 -10
@@ -120,25 +120,17 @@ int mtk_afe_pcm_new(struct snd_soc_component *component,struct mtk_base_afe *afe =snd_soc_component_get_drvdata (component); size = afe->mtk_afe_hardware->buffer_bytes_max; -snd_pcm_lib_preallocate_pages_for_all (pcm,SNDRV_DMA_TYPE_DEV , - afe->dev, size, size); +snd_pcm_set_managed_buffer_all (pcm,SNDRV_DMA_TYPE_DEV , + afe->dev, size, size);return 0 ; }EXPORT_SYMBOL_GPL (mtk_afe_pcm_new); -void mtk_afe_pcm_free (struct snd_soc_component *component, -struct snd_pcm *pcm) -{ -snd_pcm_lib_preallocate_free_for_all (pcm); -} -EXPORT_SYMBOL_GPL (mtk_afe_pcm_free); -const struct snd_soc_component_driver mtk_afe_pcm_platform = { .name =AFE_PCM_NAME , .ioctl = snd_soc_pcm_lib_ioctl, .pointer = mtk_afe_pcm_pointer, .pcm_construct = mtk_afe_pcm_new, - .pcm_destruct = mtk_afe_pcm_free, };EXPORT_SYMBOL_GPL (mtk_afe_pcm_platform);
sound/soc/mediatek/common/mtk-afe-platform-driver.h +0 -2
@@ -21,8 +21,6 @@ snd_pcm_uframes_t mtk_afe_pcm_pointer(struct snd_soc_component *component, struct snd_pcm_substream *substream);int mtk_afe_pcm_new (struct snd_soc_component *component,struct snd_soc_pcm_runtime *rtd); -void mtk_afe_pcm_free (struct snd_soc_component *component, -struct snd_pcm *pcm);int mtk_afe_combine_sub_dai (struct mtk_base_afe *afe);int mtk_afe_add_sub_dai_control (struct snd_soc_component *component);
sound/soc/mediatek/mt6797/mt6797-afe-pcm.c +0 -1
@@ -715,7 +715,6 @@ static const struct snd_soc_component_driver mt6797_afe_component = { .ioctl = snd_soc_pcm_lib_ioctl, .pointer = mtk_afe_pcm_pointer, .pcm_construct = mtk_afe_pcm_new, - .pcm_destruct = mtk_afe_pcm_free, };static int mt6797_dai_memif_register (struct mtk_base_afe *afe)
sound/soc/mediatek/mt8183/mt8183-afe-pcm.c +0 -1
@@ -1053,7 +1053,6 @@ static const struct snd_soc_component_driver mt8183_afe_component = { .ioctl = snd_soc_pcm_lib_ioctl, .pointer = mtk_afe_pcm_pointer, .pcm_construct = mtk_afe_pcm_new, - .pcm_destruct = mtk_afe_pcm_free, };static int mt8183_dai_memif_register (struct mtk_base_afe *afe)
Signature · 6 lines
2.16.4 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v2 2/2 ASoC: SOF: Use managed buffer allocation
Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped.
--- sound/soc/sof/pcm.c | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-)
sound/soc/sof/pcm.c +10 -24
@@ -118,20 +118,8 @@ static int sof_pcm_hw_params(struct snd_soc_component *component,memset (&pcm,0 ,sizeof (pcm)); -/* allocate audio buffer pages */ - ret =snd_pcm_lib_malloc_pages (substream,params_buffer_bytes (params)); -if (ret <0 ) { -dev_err (component->dev,"error: could not allocate %d bytes for PCM %d\n" , -params_buffer_bytes (params), spcm->pcm.pcm_id); -return ret; - } -if (ret) { -/* -* ret == 1 means the buffer is changed -* create compressed page table for audio firmware -* ret == 0 means the buffer is not changed -* so no need to regenerate the page table -*/ +/* create compressed page table for audio firmware */ +if (runtime->buffer_changed) { ret =create_page_table (component, substream, runtime->dma_area, runtime->dma_bytes);if (ret <0 )
@@ -259,8 +247,6 @@ static int sof_pcm_hw_free(struct snd_soc_component *component, err = ret; } -snd_pcm_lib_free_pages (substream); -cancel_work_sync (&spcm->stream[substream->stream].period_elapsed_work); ret =snd_sof_pcm_platform_hw_free (sdev, substream);
@@ -596,10 +582,10 @@ static int sof_pcm_new(struct snd_soc_component *component,"spcm: allocate %s playback DMA buffer size 0x%x max 0x%x\n" , caps->name, caps->buffer_size_min, caps->buffer_size_max); -snd_pcm_lib_preallocate_pages (pcm->streams[stream].substream, -SNDRV_DMA_TYPE_DEV_SG , sdev->dev, -le32_to_cpu (caps->buffer_size_min), -le32_to_cpu (caps->buffer_size_max)); +snd_pcm_set_managed_buffer (pcm->streams[stream].substream, +SNDRV_DMA_TYPE_DEV_SG , sdev->dev, +le32_to_cpu (caps->buffer_size_min), +le32_to_cpu (caps->buffer_size_max)); capture: stream =SNDRV_PCM_STREAM_CAPTURE ;
@@ -614,10 +600,10 @@ static int sof_pcm_new(struct snd_soc_component *component,"spcm: allocate %s capture DMA buffer size 0x%x max 0x%x\n" , caps->name, caps->buffer_size_min, caps->buffer_size_max); -snd_pcm_lib_preallocate_pages (pcm->streams[stream].substream, -SNDRV_DMA_TYPE_DEV_SG , sdev->dev, -le32_to_cpu (caps->buffer_size_min), -le32_to_cpu (caps->buffer_size_max)); +snd_pcm_set_managed_buffer (pcm->streams[stream].substream, +SNDRV_DMA_TYPE_DEV_SG , sdev->dev, +le32_to_cpu (caps->buffer_size_min), +le32_to_cpu (caps->buffer_size_max));return 0 ; }
Signature · 6 lines
2.16.4 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Mark Brown
maintainer[alsa-devel] Applied "ASoC: SOF: Use managed buffer allocation" to the asoc tree
The patch
ASoC: SOF: Use managed buffer allocation
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.6
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 57e960f0020ec46db277426762ba5ffe77e03e3c Mon Sep 17 00:00:00 2001
From: Takashi Iwai <[email protected]>
Date: Wed, 11 Dec 2019 18:20:19 +0100
Subject: [PATCH] ASoC: SOF: Use managed buffer allocation
Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped.
--- sound/soc/sof/pcm.c | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-)
sound/soc/sof/pcm.c +10 -24
@@ -118,20 +118,8 @@ static int sof_pcm_hw_params(struct snd_soc_component *component,memset (&pcm,0 ,sizeof (pcm)); -/* allocate audio buffer pages */ - ret =snd_pcm_lib_malloc_pages (substream,params_buffer_bytes (params)); -if (ret <0 ) { -dev_err (component->dev,"error: could not allocate %d bytes for PCM %d\n" , -params_buffer_bytes (params), spcm->pcm.pcm_id); -return ret; - } -if (ret) { -/* -* ret == 1 means the buffer is changed -* create compressed page table for audio firmware -* ret == 0 means the buffer is not changed -* so no need to regenerate the page table -*/ +/* create compressed page table for audio firmware */ +if (runtime->buffer_changed) { ret =create_page_table (component, substream, runtime->dma_area, runtime->dma_bytes);if (ret <0 )
@@ -259,8 +247,6 @@ static int sof_pcm_hw_free(struct snd_soc_component *component, err = ret; } -snd_pcm_lib_free_pages (substream); -cancel_work_sync (&spcm->stream[substream->stream].period_elapsed_work); ret =snd_sof_pcm_platform_hw_free (sdev, substream);
@@ -596,10 +582,10 @@ static int sof_pcm_new(struct snd_soc_component *component,"spcm: allocate %s playback DMA buffer size 0x%x max 0x%x\n" , caps->name, caps->buffer_size_min, caps->buffer_size_max); -snd_pcm_lib_preallocate_pages (pcm->streams[stream].substream, -SNDRV_DMA_TYPE_DEV_SG , sdev->dev, -le32_to_cpu (caps->buffer_size_min), -le32_to_cpu (caps->buffer_size_max)); +snd_pcm_set_managed_buffer (pcm->streams[stream].substream, +SNDRV_DMA_TYPE_DEV_SG , sdev->dev, +le32_to_cpu (caps->buffer_size_min), +le32_to_cpu (caps->buffer_size_max)); capture: stream =SNDRV_PCM_STREAM_CAPTURE ;
@@ -614,10 +600,10 @@ static int sof_pcm_new(struct snd_soc_component *component,"spcm: allocate %s capture DMA buffer size 0x%x max 0x%x\n" , caps->name, caps->buffer_size_min, caps->buffer_size_max); -snd_pcm_lib_preallocate_pages (pcm->streams[stream].substream, -SNDRV_DMA_TYPE_DEV_SG , sdev->dev, -le32_to_cpu (caps->buffer_size_min), -le32_to_cpu (caps->buffer_size_max)); +snd_pcm_set_managed_buffer (pcm->streams[stream].substream, +SNDRV_DMA_TYPE_DEV_SG , sdev->dev, +le32_to_cpu (caps->buffer_size_min), +le32_to_cpu (caps->buffer_size_max));return 0 ; }
Signature · 6 lines
2.20.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Mark Brown
maintainer[alsa-devel] Applied "ASoC: mediatek: Use managed buffer allocation" to the asoc tree
In reply to Takashi IwaiThe patch
ASoC: mediatek: Use managed buffer allocation
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.6
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 bf523463d8c38cd92424ed011b90769c29ef99ce Mon Sep 17 00:00:00 2001
From: Takashi Iwai <[email protected]>
Date: Wed, 11 Dec 2019 18:20:18 +0100
Subject: [PATCH] ASoC: mediatek: Use managed buffer allocation
Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped, as well as the superfluous snd_pcm_lib_preallocate_free_for_all() call. As of the result, hw_free and pcm_destruct ops became empty and got removed.
--- sound/soc/mediatek/common/mtk-afe-fe-dai.c | 6 +----- sound/soc/mediatek/common/mtk-afe-platform-driver.c | 12 ++---------- sound/soc/mediatek/common/mtk-afe-platform-driver.h | 2 -- sound/soc/mediatek/mt6797/mt6797-afe-pcm.c | 1 - sound/soc/mediatek/mt8183/mt8183-afe-pcm.c | 1 - 5 files changed, 3 insertions(+), 19 deletions(-)
sound/soc/mediatek/common/mtk-afe-fe-dai.c +1 -5
@@ -129,10 +129,6 @@ int mtk_afe_fe_hw_params(struct snd_pcm_substream *substream,unsigned int rate =params_rate (params);snd_pcm_format_t format =params_format (params); - ret =snd_pcm_lib_malloc_pages (substream,params_buffer_bytes (params)); -if (ret <0 ) -return ret; -if (afe->request_dram_resource) afe->request_dram_resource (afe->dev);
@@ -193,7 +189,7 @@ int mtk_afe_fe_hw_free(struct snd_pcm_substream *substream,if (afe->release_dram_resource) afe->release_dram_resource (afe->dev); -return snd_pcm_lib_free_pages (substream); +return 0 ; }EXPORT_SYMBOL_GPL (mtk_afe_fe_hw_free);
sound/soc/mediatek/common/mtk-afe-platform-driver.c +2 -10
@@ -120,24 +120,16 @@ int mtk_afe_pcm_new(struct snd_soc_component *component,struct mtk_base_afe *afe =snd_soc_component_get_drvdata (component); size = afe->mtk_afe_hardware->buffer_bytes_max; -snd_pcm_lib_preallocate_pages_for_all (pcm,SNDRV_DMA_TYPE_DEV , - afe->dev, size, size); +snd_pcm_set_managed_buffer_all (pcm,SNDRV_DMA_TYPE_DEV , + afe->dev, size, size);return 0 ; }EXPORT_SYMBOL_GPL (mtk_afe_pcm_new); -void mtk_afe_pcm_free (struct snd_soc_component *component, -struct snd_pcm *pcm) -{ -snd_pcm_lib_preallocate_free_for_all (pcm); -} -EXPORT_SYMBOL_GPL (mtk_afe_pcm_free); -const struct snd_soc_component_driver mtk_afe_pcm_platform = { .name =AFE_PCM_NAME , .pointer = mtk_afe_pcm_pointer, .pcm_construct = mtk_afe_pcm_new, - .pcm_destruct = mtk_afe_pcm_free, };EXPORT_SYMBOL_GPL (mtk_afe_pcm_platform);
sound/soc/mediatek/common/mtk-afe-platform-driver.h +0 -2
@@ -21,8 +21,6 @@ snd_pcm_uframes_t mtk_afe_pcm_pointer(struct snd_soc_component *component, struct snd_pcm_substream *substream);int mtk_afe_pcm_new (struct snd_soc_component *component,struct snd_soc_pcm_runtime *rtd); -void mtk_afe_pcm_free (struct snd_soc_component *component, -struct snd_pcm *pcm);int mtk_afe_combine_sub_dai (struct mtk_base_afe *afe);int mtk_afe_add_sub_dai_control (struct snd_soc_component *component);
sound/soc/mediatek/mt6797/mt6797-afe-pcm.c +0 -1
@@ -714,7 +714,6 @@ static const struct snd_soc_component_driver mt6797_afe_component = { .probe = mt6797_afe_component_probe, .pointer = mtk_afe_pcm_pointer, .pcm_construct = mtk_afe_pcm_new, - .pcm_destruct = mtk_afe_pcm_free, };static int mt6797_dai_memif_register (struct mtk_base_afe *afe)
sound/soc/mediatek/mt8183/mt8183-afe-pcm.c +0 -1
@@ -1052,7 +1052,6 @@ static const struct snd_soc_component_driver mt8183_afe_component = { .probe = mt8183_afe_component_probe, .pointer = mtk_afe_pcm_pointer, .pcm_construct = mtk_afe_pcm_new, - .pcm_destruct = mtk_afe_pcm_free, };static int mt8183_dai_memif_register (struct mtk_base_afe *afe)
Signature · 6 lines
2.20.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel