alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [alsa-devel] [PATCH 0/8] ASoC: memalloc cleanups
@ 2019-11-08  9:46 Takashi Iwai
  2019-11-08  9:46 ` [alsa-devel] [PATCH 1/8] ASoC: Remove superfluous snd_dma_continuous_data() Takashi Iwai
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: Takashi Iwai @ 2019-11-08  9:46 UTC (permalink / raw)
  To: alsa-devel
  Cc: Cezary Rojewski, Pierre-Louis Bossart, Liam Girdwood, Mark Brown,
	Curtis Malainey, Bard Liao

Hi,

this is a patch series for ASoC to clean up ALSA memory allocation API
usages.  It's based on my recent API changes found on for-next branch
for 5.5 merge, so please give ACK if it's OK, so that I can merge them
into my sound git tree.

Basically three things:
* Drop superfluous snd_pcm_sgbuf_ops_page usages
* Drop snd_dma_continuous_data() macro usage for the normal continuous
  page allocation
* Convert PCM vmalloc buffer allocation with the preallocation API


Takashi

===

Takashi Iwai (8):
  ASoC: Remove superfluous snd_dma_continuous_data()
  ASoC: rt5514-spi: Convert to the common vmalloc memalloc
  ASoC: intel: Drop superfluous snd_pcm_sgbuf_ops_page
  ASoC: intel: Avoid non-standard macro usage
  ASoC: SOF: Drop superfluous snd_pcm_sgbuf_ops_page
  ASoC: rt5677-spi: Convert to the common vmalloc memalloc
  ASoC: cros_ec_codec: Convert to the common vmalloc memalloc
  ALSA: pcm: Unexport snd_pcm_sgbuf_ops_page

 include/sound/pcm.h                       |  8 --------
 sound/core/pcm_local.h                    |  5 +++++
 sound/core/pcm_memory.c                   |  3 +--
 sound/soc/au1x/dma.c                      |  2 +-
 sound/soc/codecs/cros_ec_codec.c          | 16 ++++++++--------
 sound/soc/codecs/rt5514-spi.c             | 21 +++++++++++----------
 sound/soc/codecs/rt5677-spi.c             | 17 ++++++++---------
 sound/soc/dwc/dwc-pcm.c                   |  2 +-
 sound/soc/intel/haswell/sst-haswell-pcm.c | 12 ------------
 sound/soc/intel/skylake/skl-pcm.c         | 14 +-------------
 sound/soc/sh/dma-sh7760.c                 |  2 +-
 sound/soc/sof/pcm.c                       | 12 ------------
 12 files changed, 37 insertions(+), 77 deletions(-)

-- 
2.16.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* [alsa-devel] [PATCH 1/8] ASoC: Remove superfluous snd_dma_continuous_data()
  2019-11-08  9:46 [alsa-devel] [PATCH 0/8] ASoC: memalloc cleanups Takashi Iwai
@ 2019-11-08  9:46 ` Takashi Iwai
  2019-11-08  9:46 ` [alsa-devel] [PATCH 2/8] ASoC: rt5514-spi: Convert to the common vmalloc memalloc Takashi Iwai
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Takashi Iwai @ 2019-11-08  9:46 UTC (permalink / raw)
  To: alsa-devel
  Cc: Cezary Rojewski, Pierre-Louis Bossart, Liam Girdwood, Mark Brown,
	Curtis Malainey, Bard Liao

The recent change (commit 08422d2c559d: "ALSA: memalloc: Allow NULL
device for SNDRV_DMA_TYPE_CONTINOUS type") made the PCM preallocation
helper accepting NULL as the device pointer for the default usage.
Drop the snd_dma_continuous_data() usage that became superfluous from
the callers.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/au1x/dma.c      | 2 +-
 sound/soc/dwc/dwc-pcm.c   | 2 +-
 sound/soc/sh/dma-sh7760.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/au1x/dma.c b/sound/soc/au1x/dma.c
index 49556eb409cd..054dfda89d3e 100644
--- a/sound/soc/au1x/dma.c
+++ b/sound/soc/au1x/dma.c
@@ -293,7 +293,7 @@ static int alchemy_pcm_new(struct snd_soc_component *component,
 	struct snd_pcm *pcm = rtd->pcm;
 
 	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
-		snd_dma_continuous_data(GFP_KERNEL), 65536, (4096 * 1024) - 1);
+					      NULL, 65536, (4096 * 1024) - 1);
 
 	return 0;
 }
diff --git a/sound/soc/dwc/dwc-pcm.c b/sound/soc/dwc/dwc-pcm.c
index de6fcc808832..4771eb5fbe2a 100644
--- a/sound/soc/dwc/dwc-pcm.c
+++ b/sound/soc/dwc/dwc-pcm.c
@@ -258,7 +258,7 @@ static int dw_pcm_new(struct snd_soc_component *component,
 
 	snd_pcm_lib_preallocate_pages_for_all(rtd->pcm,
 			SNDRV_DMA_TYPE_CONTINUOUS,
-			snd_dma_continuous_data(GFP_KERNEL), size, size);
+			NULL, size, size);
 	return 0;
 }
 
diff --git a/sound/soc/sh/dma-sh7760.c b/sound/soc/sh/dma-sh7760.c
index 93bb80d089be..2b0eca02a8b9 100644
--- a/sound/soc/sh/dma-sh7760.c
+++ b/sound/soc/sh/dma-sh7760.c
@@ -309,7 +309,7 @@ static int camelot_pcm_new(struct snd_soc_component *component,
 	 */
 	snd_pcm_lib_preallocate_pages_for_all(pcm,
 		SNDRV_DMA_TYPE_CONTINUOUS,
-		snd_dma_continuous_data(GFP_KERNEL),
+		NULL,
 		DMABRG_PREALLOC_BUFFER,	DMABRG_PREALLOC_BUFFER_MAX);
 
 	return 0;
-- 
2.16.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* [alsa-devel] [PATCH 2/8] ASoC: rt5514-spi: Convert to the common vmalloc memalloc
  2019-11-08  9:46 [alsa-devel] [PATCH 0/8] ASoC: memalloc cleanups Takashi Iwai
  2019-11-08  9:46 ` [alsa-devel] [PATCH 1/8] ASoC: Remove superfluous snd_dma_continuous_data() Takashi Iwai
@ 2019-11-08  9:46 ` Takashi Iwai
  2019-11-08  9:46 ` [alsa-devel] [PATCH 3/8] ASoC: intel: Drop superfluous snd_pcm_sgbuf_ops_page Takashi Iwai
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Takashi Iwai @ 2019-11-08  9:46 UTC (permalink / raw)
  To: alsa-devel
  Cc: Cezary Rojewski, Pierre-Louis Bossart, Liam Girdwood, Mark Brown,
	Curtis Malainey, Bard Liao

The recent change (*) in the ALSA memalloc core allows us to drop the
special vmalloc-specific allocation and page handling.  This patch
coverts to the common code.
(*) 1fe7f397cfe2: ALSA: memalloc: Add vmalloc buffer allocation
                  support
    7e8edae39fd1: ALSA: pcm: Handle special page mapping in the
                  default mmap handler

Since it requires the specific buffer type (SNDRV_DMA_TYPE_VMALLOC),
it's set in the pcm_new ops now.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/codecs/rt5514-spi.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c
index 57ff5aee452d..f1b7b947ecbd 100644
--- a/sound/soc/codecs/rt5514-spi.c
+++ b/sound/soc/codecs/rt5514-spi.c
@@ -219,8 +219,7 @@ static int rt5514_spi_hw_params(struct snd_soc_component *component,
 	u8 buf[8];
 
 	mutex_lock(&rt5514_dsp->dma_lock);
-	ret = snd_pcm_lib_alloc_vmalloc_buffer(substream,
-			params_buffer_bytes(hw_params));
+	ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
 	rt5514_dsp->substream = substream;
 	rt5514_dsp->dma_offset = 0;
 
@@ -246,7 +245,7 @@ static int rt5514_spi_hw_free(struct snd_soc_component *component,
 
 	cancel_delayed_work_sync(&rt5514_dsp->copy_work);
 
-	return snd_pcm_lib_free_vmalloc_buffer(substream);
+	return snd_pcm_lib_free_pages(substream);
 }
 
 static snd_pcm_uframes_t rt5514_spi_pcm_pointer(
@@ -260,12 +259,6 @@ static snd_pcm_uframes_t rt5514_spi_pcm_pointer(
 	return bytes_to_frames(runtime, rt5514_dsp->dma_offset);
 }
 
-static struct page *rt5514_spi_pcm_page(struct snd_soc_component *component,
-					struct snd_pcm_substream *substream,
-					unsigned long offset)
-{
-	return snd_pcm_lib_get_vmalloc_page(substream, offset);
-}
 
 static int rt5514_spi_pcm_probe(struct snd_soc_component *component)
 {
@@ -298,6 +291,14 @@ static int rt5514_spi_pcm_probe(struct snd_soc_component *component)
 	return 0;
 }
 
+static int rt5514_spi_pcm_new(struct snd_soc_component *component,
+			      struct snd_soc_pcm_runtime *rtd)
+{
+	snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, SNDRV_DMA_TYPE_VMALLOC,
+					      NULL, 0, 0);
+	return 0;
+}
+
 static const struct snd_soc_component_driver rt5514_spi_component = {
 	.name		= DRV_NAME,
 	.probe		= rt5514_spi_pcm_probe,
@@ -305,7 +306,7 @@ static const struct snd_soc_component_driver rt5514_spi_component = {
 	.hw_params	= rt5514_spi_hw_params,
 	.hw_free	= rt5514_spi_hw_free,
 	.pointer	= rt5514_spi_pcm_pointer,
-	.page		= rt5514_spi_pcm_page,
+	.pcm_construct	= rt5514_spi_pcm_new,
 };
 
 /**
-- 
2.16.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* [alsa-devel] [PATCH 3/8] ASoC: intel: Drop superfluous snd_pcm_sgbuf_ops_page
  2019-11-08  9:46 [alsa-devel] [PATCH 0/8] ASoC: memalloc cleanups Takashi Iwai
  2019-11-08  9:46 ` [alsa-devel] [PATCH 1/8] ASoC: Remove superfluous snd_dma_continuous_data() Takashi Iwai
  2019-11-08  9:46 ` [alsa-devel] [PATCH 2/8] ASoC: rt5514-spi: Convert to the common vmalloc memalloc Takashi Iwai
@ 2019-11-08  9:46 ` Takashi Iwai
  2019-11-08  9:46 ` [alsa-devel] [PATCH 4/8] ASoC: intel: Avoid non-standard macro usage Takashi Iwai
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Takashi Iwai @ 2019-11-08  9:46 UTC (permalink / raw)
  To: alsa-devel
  Cc: Cezary Rojewski, Pierre-Louis Bossart, Liam Girdwood, Mark Brown,
	Curtis Malainey, Bard Liao

snd_pcm_sgbuf_ops_page is no longer needed to be set explicitly to PCM
page ops since the recent change in the PCM core (*).  Leaving it NULL
should work as long as the preallocation has been done properly.

This patch drops the redundant lines.

(*) 7e8edae39fd1: ALSA: pcm: Handle special page mapping in the
                  default mmap handler

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/intel/haswell/sst-haswell-pcm.c | 12 ------------
 sound/soc/intel/skylake/skl-pcm.c         | 12 ------------
 2 files changed, 24 deletions(-)

diff --git a/sound/soc/intel/haswell/sst-haswell-pcm.c b/sound/soc/intel/haswell/sst-haswell-pcm.c
index 6e498a581d20..a3a5bba2fbd9 100644
--- a/sound/soc/intel/haswell/sst-haswell-pcm.c
+++ b/sound/soc/intel/haswell/sst-haswell-pcm.c
@@ -796,17 +796,6 @@ static snd_pcm_uframes_t hsw_pcm_pointer(struct snd_soc_component *component,
 	return offset;
 }
 
-#ifdef CONFIG_SND_DMA_SGBUF
-static struct page *hsw_pcm_page(struct snd_soc_component *component,
-				 struct snd_pcm_substream *substream,
-				 unsigned long offset)
-{
-	return snd_pcm_sgbuf_ops_page(substream, offset);
-}
-#else
-#define hsw_pcm_page NULL
-#endif /* CONFIG_SND_DMA_SGBUF */
-
 static int hsw_pcm_open(struct snd_soc_component *component,
 			struct snd_pcm_substream *substream)
 {
@@ -1128,7 +1117,6 @@ static const struct snd_soc_component_driver hsw_dai_component = {
 	.hw_free	= hsw_pcm_hw_free,
 	.trigger	= hsw_pcm_trigger,
 	.pointer	= hsw_pcm_pointer,
-	.page		= hsw_pcm_page,
 	.ioctl		= snd_soc_pcm_lib_ioctl,
 	.pcm_construct	= hsw_pcm_new,
 	.controls	= hsw_volume_controls,
diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
index 0850141c7d47..6bd14f65fe71 100644
--- a/sound/soc/intel/skylake/skl-pcm.c
+++ b/sound/soc/intel/skylake/skl-pcm.c
@@ -1235,17 +1235,6 @@ static int skl_platform_soc_mmap(struct snd_soc_component *component,
 	return snd_pcm_lib_default_mmap(substream, area);
 }
 
-#ifdef CONFIG_SND_DMA_SGBUF
-static struct page *skl_platform_soc_page(struct snd_soc_component *component,
-					  struct snd_pcm_substream *substream,
-					  unsigned long offset)
-{
-	return snd_pcm_sgbuf_ops_page(substream, offset);
-}
-#else
-#define skl_platform_soc_page NULL
-#endif /* CONFIG_SND_DMA_SGBUF */
-
 static u64 skl_adjust_codec_delay(struct snd_pcm_substream *substream,
 				u64 nsec)
 {
@@ -1493,7 +1482,6 @@ static const struct snd_soc_component_driver skl_component  = {
 	.pointer	= skl_platform_soc_pointer,
 	.get_time_info	= skl_platform_soc_get_time_info,
 	.mmap		= skl_platform_soc_mmap,
-	.page		= skl_platform_soc_page,
 	.pcm_construct	= skl_platform_soc_new,
 	.pcm_destruct	= skl_platform_soc_free,
 	.module_get_upon_open = 1, /* increment refcount when a pcm is opened */
-- 
2.16.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* [alsa-devel] [PATCH 4/8] ASoC: intel: Avoid non-standard macro usage
  2019-11-08  9:46 [alsa-devel] [PATCH 0/8] ASoC: memalloc cleanups Takashi Iwai
                   ` (2 preceding siblings ...)
  2019-11-08  9:46 ` [alsa-devel] [PATCH 3/8] ASoC: intel: Drop superfluous snd_pcm_sgbuf_ops_page Takashi Iwai
@ 2019-11-08  9:46 ` Takashi Iwai
  2019-11-08  9:46 ` [alsa-devel] [PATCH 5/8] ASoC: SOF: Drop superfluous snd_pcm_sgbuf_ops_page Takashi Iwai
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Takashi Iwai @ 2019-11-08  9:46 UTC (permalink / raw)
  To: alsa-devel
  Cc: Cezary Rojewski, Pierre-Louis Bossart, Liam Girdwood, Mark Brown,
	Curtis Malainey, Bard Liao

Pass the device pointer from the PCI pointer directly, instead of a
non-standard macro.  The macro didn't give any better readability.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/intel/skylake/skl-pcm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
index 6bd14f65fe71..8b9abb79a69e 100644
--- a/sound/soc/intel/skylake/skl-pcm.c
+++ b/sound/soc/intel/skylake/skl-pcm.c
@@ -1314,7 +1314,7 @@ static int skl_platform_soc_new(struct snd_soc_component *component,
 			size = MAX_PREALLOC_SIZE;
 		snd_pcm_lib_preallocate_pages_for_all(pcm,
 						SNDRV_DMA_TYPE_DEV_SG,
-						snd_dma_pci_data(skl->pci),
+						&skl->pci->dev,
 						size, MAX_PREALLOC_SIZE);
 	}
 
-- 
2.16.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* [alsa-devel] [PATCH 5/8] ASoC: SOF: Drop superfluous snd_pcm_sgbuf_ops_page
  2019-11-08  9:46 [alsa-devel] [PATCH 0/8] ASoC: memalloc cleanups Takashi Iwai
                   ` (3 preceding siblings ...)
  2019-11-08  9:46 ` [alsa-devel] [PATCH 4/8] ASoC: intel: Avoid non-standard macro usage Takashi Iwai
@ 2019-11-08  9:46 ` Takashi Iwai
  2019-11-08  9:46 ` [alsa-devel] [PATCH 6/8] ASoC: rt5677-spi: Convert to the common vmalloc memalloc Takashi Iwai
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Takashi Iwai @ 2019-11-08  9:46 UTC (permalink / raw)
  To: alsa-devel
  Cc: Cezary Rojewski, Pierre-Louis Bossart, Liam Girdwood, Mark Brown,
	Curtis Malainey, Bard Liao

snd_pcm_sgbuf_ops_page is no longer needed to be set explicitly to PCM
page ops since the recent change in the PCM core (*).  Leaving it NULL
should work as long as the preallocation has been done properly.

This patch drops the redundant lines.

(*) 7e8edae39fd1: ALSA: pcm: Handle special page mapping in the
                  default mmap handler

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/sof/pcm.c | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c
index 3d5cd1b445ba..549238a98b2a 100644
--- a/sound/soc/sof/pcm.c
+++ b/sound/soc/sof/pcm.c
@@ -454,17 +454,6 @@ static snd_pcm_uframes_t sof_pcm_pointer(struct snd_soc_component *component,
 	return host;
 }
 
-#ifdef CONFIG_SND_DMA_SGBUF
-static struct page *sof_pcm_page(struct snd_soc_component *component,
-				 struct snd_pcm_substream *substream,
-				 unsigned long offset)
-{
-	return snd_pcm_sgbuf_ops_page(substream, offset);
-}
-#else
-#define sof_pcm_page	NULL
-#endif /* CONFIG_SND_DMA_SGBUF */
-
 static int sof_pcm_open(struct snd_soc_component *component,
 			struct snd_pcm_substream *substream)
 {
@@ -788,7 +777,6 @@ void snd_sof_new_platform_drv(struct snd_sof_dev *sdev)
 	pd->hw_free = sof_pcm_hw_free;
 	pd->trigger = sof_pcm_trigger;
 	pd->pointer = sof_pcm_pointer;
-	pd->page = sof_pcm_page;
 
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_COMPRESS)
 	pd->compr_ops = &sof_compressed_ops;
-- 
2.16.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* [alsa-devel] [PATCH 6/8] ASoC: rt5677-spi: Convert to the common vmalloc memalloc
  2019-11-08  9:46 [alsa-devel] [PATCH 0/8] ASoC: memalloc cleanups Takashi Iwai
                   ` (4 preceding siblings ...)
  2019-11-08  9:46 ` [alsa-devel] [PATCH 5/8] ASoC: SOF: Drop superfluous snd_pcm_sgbuf_ops_page Takashi Iwai
@ 2019-11-08  9:46 ` Takashi Iwai
  2019-11-08 20:36   ` Curtis Malainey
  2019-11-08  9:46 ` [alsa-devel] [PATCH 7/8] ASoC: cros_ec_codec: " Takashi Iwai
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 11+ messages in thread
From: Takashi Iwai @ 2019-11-08  9:46 UTC (permalink / raw)
  To: alsa-devel
  Cc: Cezary Rojewski, Pierre-Louis Bossart, Liam Girdwood, Mark Brown,
	Curtis Malainey, Bard Liao

The recent change (*) in the ALSA memalloc core allows us to drop the
special vmalloc-specific allocation and page handling.  This patch
coverts to the common code.
(*) 1fe7f397cfe2: ALSA: memalloc: Add vmalloc buffer allocation
                  support
    7e8edae39fd1: ALSA: pcm: Handle special page mapping in the
                  default mmap handler

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/codecs/rt5677-spi.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/sound/soc/codecs/rt5677-spi.c b/sound/soc/codecs/rt5677-spi.c
index 3aa3ea7c2768..0c90f99b693f 100644
--- a/sound/soc/codecs/rt5677-spi.c
+++ b/sound/soc/codecs/rt5677-spi.c
@@ -128,8 +128,7 @@ static int rt5677_spi_hw_params(
 	int ret;
 
 	mutex_lock(&rt5677_dsp->dma_lock);
-	ret = snd_pcm_lib_alloc_vmalloc_buffer(substream,
-			params_buffer_bytes(hw_params));
+	ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
 	rt5677_dsp->substream = substream;
 	mutex_unlock(&rt5677_dsp->dma_lock);
 
@@ -147,7 +146,7 @@ static int rt5677_spi_hw_free(
 	rt5677_dsp->substream = NULL;
 	mutex_unlock(&rt5677_dsp->dma_lock);
 
-	return snd_pcm_lib_free_vmalloc_buffer(substream);
+	return snd_pcm_lib_free_pages(substream);
 }
 
 static int rt5677_spi_prepare(
@@ -361,12 +360,12 @@ static void rt5677_spi_copy_work(struct work_struct *work)
 	mutex_unlock(&rt5677_dsp->dma_lock);
 }
 
-static struct page *rt5677_spi_pcm_page(
-		struct snd_soc_component *component,
-		struct snd_pcm_substream *substream,
-		unsigned long offset)
+static int rt5677_spi_pcm_new(struct snd_soc_component *component,
+			      struct snd_soc_pcm_runtime *rtd)
 {
-	return snd_pcm_lib_get_vmalloc_page(substream, offset);
+	snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, SNDRV_DMA_TYPE_VMALLOC,
+					      NULL, 0, 0);
+	return 0;
 }
 
 static int rt5677_spi_pcm_probe(struct snd_soc_component *component)
@@ -394,7 +393,7 @@ static const struct snd_soc_component_driver rt5677_spi_dai_component = {
 	.hw_free	= rt5677_spi_hw_free,
 	.prepare	= rt5677_spi_prepare,
 	.pointer	= rt5677_spi_pcm_pointer,
-	.page		= rt5677_spi_pcm_page,
+	.pcm_construct	= rt5677_spi_pcm_new,
 };
 
 /* Select a suitable transfer command for the next transfer to ensure
-- 
2.16.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* [alsa-devel] [PATCH 7/8] ASoC: cros_ec_codec: Convert to the common vmalloc memalloc
  2019-11-08  9:46 [alsa-devel] [PATCH 0/8] ASoC: memalloc cleanups Takashi Iwai
                   ` (5 preceding siblings ...)
  2019-11-08  9:46 ` [alsa-devel] [PATCH 6/8] ASoC: rt5677-spi: Convert to the common vmalloc memalloc Takashi Iwai
@ 2019-11-08  9:46 ` Takashi Iwai
  2019-11-08  9:46 ` [alsa-devel] [PATCH 8/8] ALSA: pcm: Unexport snd_pcm_sgbuf_ops_page Takashi Iwai
  2019-11-08 12:43 ` [alsa-devel] [PATCH 0/8] ASoC: memalloc cleanups Mark Brown
  8 siblings, 0 replies; 11+ messages in thread
From: Takashi Iwai @ 2019-11-08  9:46 UTC (permalink / raw)
  To: alsa-devel
  Cc: Cezary Rojewski, Pierre-Louis Bossart, Liam Girdwood, Mark Brown,
	Curtis Malainey, Bard Liao

The recent change (*) in the ALSA memalloc core allows us to drop the
special vmalloc-specific allocation and page handling.  This patch
coverts to the common code.
(*) 1fe7f397cfe2: ALSA: memalloc: Add vmalloc buffer allocation
                  support
    7e8edae39fd1: ALSA: pcm: Handle special page mapping in the
                  default mmap handler

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/codecs/cros_ec_codec.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/sound/soc/codecs/cros_ec_codec.c b/sound/soc/codecs/cros_ec_codec.c
index dd14caf9091a..7b17f39a6a10 100644
--- a/sound/soc/codecs/cros_ec_codec.c
+++ b/sound/soc/codecs/cros_ec_codec.c
@@ -918,8 +918,7 @@ static int wov_pcm_hw_params(struct snd_soc_component *component,
 	priv->wov_burst_read = true;
 	mutex_unlock(&priv->wov_dma_lock);
 
-	return snd_pcm_lib_alloc_vmalloc_buffer(substream,
-			params_buffer_bytes(hw_params));
+	return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
 }
 
 static int wov_pcm_hw_free(struct snd_soc_component *component,
@@ -935,7 +934,7 @@ static int wov_pcm_hw_free(struct snd_soc_component *component,
 
 	cancel_delayed_work_sync(&priv->wov_copy_work);
 
-	return snd_pcm_lib_free_vmalloc_buffer(substream);
+	return snd_pcm_lib_free_pages(substream);
 }
 
 static snd_pcm_uframes_t wov_pcm_pointer(struct snd_soc_component *component,
@@ -948,11 +947,12 @@ static snd_pcm_uframes_t wov_pcm_pointer(struct snd_soc_component *component,
 	return bytes_to_frames(runtime, priv->wov_dma_offset);
 }
 
-static struct page *wov_pcm_page(struct snd_soc_component *component,
-				 struct snd_pcm_substream *substream,
-				 unsigned long offset)
+static int wov_pcm_new(struct snd_soc_component *component,
+		       struct snd_soc_pcm_runtime *rtd)
 {
-	return snd_pcm_lib_get_vmalloc_page(substream, offset);
+	snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, SNDRV_DMA_TYPE_VMALLOC,
+					      NULL, 0, 0);
+	return 0;
 }
 
 static const struct snd_soc_component_driver wov_component_driver = {
@@ -964,7 +964,7 @@ static const struct snd_soc_component_driver wov_component_driver = {
 	.hw_params	= wov_pcm_hw_params,
 	.hw_free	= wov_pcm_hw_free,
 	.pointer	= wov_pcm_pointer,
-	.page		= wov_pcm_page,
+	.pcm_construct	= wov_pcm_new,
 };
 
 static int cros_ec_codec_platform_probe(struct platform_device *pdev)
-- 
2.16.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* [alsa-devel] [PATCH 8/8] ALSA: pcm: Unexport snd_pcm_sgbuf_ops_page
  2019-11-08  9:46 [alsa-devel] [PATCH 0/8] ASoC: memalloc cleanups Takashi Iwai
                   ` (6 preceding siblings ...)
  2019-11-08  9:46 ` [alsa-devel] [PATCH 7/8] ASoC: cros_ec_codec: " Takashi Iwai
@ 2019-11-08  9:46 ` Takashi Iwai
  2019-11-08 12:43 ` [alsa-devel] [PATCH 0/8] ASoC: memalloc cleanups Mark Brown
  8 siblings, 0 replies; 11+ messages in thread
From: Takashi Iwai @ 2019-11-08  9:46 UTC (permalink / raw)
  To: alsa-devel
  Cc: Cezary Rojewski, Pierre-Louis Bossart, Liam Girdwood, Mark Brown,
	Curtis Malainey, Bard Liao

The helper is no longer referred after the recent code refactoring.
Drop the export for saving some bits and future misuse.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 include/sound/pcm.h     | 8 --------
 sound/core/pcm_local.h  | 5 +++++
 sound/core/pcm_memory.c | 3 +--
 3 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index bbe6eb1ff5d2..2c0aa884f5f1 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -1236,14 +1236,6 @@ static inline int snd_pcm_lib_alloc_vmalloc_32_buffer
  */
 #define snd_pcm_substream_sgbuf(substream) \
 	snd_pcm_get_dma_buf(substream)->private_data
-
-struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream,
-				    unsigned long offset);
-#else /* !SND_DMA_SGBUF */
-/*
- * fake using a continuous buffer
- */
-#define snd_pcm_sgbuf_ops_page	NULL
 #endif /* SND_DMA_SGBUF */
 
 /**
diff --git a/sound/core/pcm_local.h b/sound/core/pcm_local.h
index 1161ab2d6a5b..5565e1c4196a 100644
--- a/sound/core/pcm_local.h
+++ b/sound/core/pcm_local.h
@@ -67,4 +67,9 @@ static inline void snd_pcm_timer_done(struct snd_pcm_substream *substream) {}
 void __snd_pcm_xrun(struct snd_pcm_substream *substream);
 void snd_pcm_group_init(struct snd_pcm_group *group);
 
+#ifdef CONFIG_SND_DMA_SGBUF
+struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream,
+				    unsigned long offset);
+#endif
+
 #endif	/* __SOUND_CORE_PCM_LOCAL_H */
diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c
index 17ee361ce791..286f333f8e4c 100644
--- a/sound/core/pcm_memory.c
+++ b/sound/core/pcm_memory.c
@@ -255,7 +255,7 @@ void snd_pcm_lib_preallocate_pages_for_all(struct snd_pcm *pcm,
 EXPORT_SYMBOL(snd_pcm_lib_preallocate_pages_for_all);
 
 #ifdef CONFIG_SND_DMA_SGBUF
-/**
+/*
  * snd_pcm_sgbuf_ops_page - get the page struct at the given offset
  * @substream: the pcm substream instance
  * @offset: the buffer offset
@@ -273,7 +273,6 @@ struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream, unsigne
 		return NULL;
 	return sgbuf->page_table[idx];
 }
-EXPORT_SYMBOL(snd_pcm_sgbuf_ops_page);
 #endif /* CONFIG_SND_DMA_SGBUF */
 
 /**
-- 
2.16.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Re: [alsa-devel] [PATCH 0/8] ASoC: memalloc cleanups
  2019-11-08  9:46 [alsa-devel] [PATCH 0/8] ASoC: memalloc cleanups Takashi Iwai
                   ` (7 preceding siblings ...)
  2019-11-08  9:46 ` [alsa-devel] [PATCH 8/8] ALSA: pcm: Unexport snd_pcm_sgbuf_ops_page Takashi Iwai
@ 2019-11-08 12:43 ` Mark Brown
  8 siblings, 0 replies; 11+ messages in thread
From: Mark Brown @ 2019-11-08 12:43 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Cezary Rojewski, alsa-devel, Pierre-Louis Bossart, Liam Girdwood,
	Curtis Malainey, Bard Liao


[-- Attachment #1.1: Type: text/plain, Size: 367 bytes --]

On Fri, Nov 08, 2019 at 10:46:33AM +0100, Takashi Iwai wrote:
> Hi,
> 
> this is a patch series for ASoC to clean up ALSA memory allocation API
> usages.  It's based on my recent API changes found on for-next branch
> for 5.5 merge, so please give ACK if it's OK, so that I can merge them
> into my sound git tree.

Acked-by: Mark Brown <broonie@kernel.org>

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

[-- Attachment #2: Type: text/plain, Size: 161 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Re: [alsa-devel] [PATCH 6/8] ASoC: rt5677-spi: Convert to the common vmalloc memalloc
  2019-11-08  9:46 ` [alsa-devel] [PATCH 6/8] ASoC: rt5677-spi: Convert to the common vmalloc memalloc Takashi Iwai
@ 2019-11-08 20:36   ` Curtis Malainey
  0 siblings, 0 replies; 11+ messages in thread
From: Curtis Malainey @ 2019-11-08 20:36 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Cezary Rojewski, ALSA development, Pierre-Louis Bossart,
	Liam Girdwood, Mark Brown, Curtis Malainey, Bard Liao

On Fri, Nov 8, 2019 at 1:47 AM Takashi Iwai <tiwai@suse.de> wrote:
>
> The recent change (*) in the ALSA memalloc core allows us to drop the
> special vmalloc-specific allocation and page handling.  This patch
> coverts to the common code.
> (*) 1fe7f397cfe2: ALSA: memalloc: Add vmalloc buffer allocation
>                   support
>     7e8edae39fd1: ALSA: pcm: Handle special page mapping in the
>                   default mmap handler
>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Passes sanity checks on my end
Acked-by: Curtis Malainey <cujomalainey@chromium.org>
> ---
>  sound/soc/codecs/rt5677-spi.c | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/sound/soc/codecs/rt5677-spi.c b/sound/soc/codecs/rt5677-spi.c

>
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

end of thread, other threads:[~2019-11-08 20:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-08  9:46 [alsa-devel] [PATCH 0/8] ASoC: memalloc cleanups Takashi Iwai
2019-11-08  9:46 ` [alsa-devel] [PATCH 1/8] ASoC: Remove superfluous snd_dma_continuous_data() Takashi Iwai
2019-11-08  9:46 ` [alsa-devel] [PATCH 2/8] ASoC: rt5514-spi: Convert to the common vmalloc memalloc Takashi Iwai
2019-11-08  9:46 ` [alsa-devel] [PATCH 3/8] ASoC: intel: Drop superfluous snd_pcm_sgbuf_ops_page Takashi Iwai
2019-11-08  9:46 ` [alsa-devel] [PATCH 4/8] ASoC: intel: Avoid non-standard macro usage Takashi Iwai
2019-11-08  9:46 ` [alsa-devel] [PATCH 5/8] ASoC: SOF: Drop superfluous snd_pcm_sgbuf_ops_page Takashi Iwai
2019-11-08  9:46 ` [alsa-devel] [PATCH 6/8] ASoC: rt5677-spi: Convert to the common vmalloc memalloc Takashi Iwai
2019-11-08 20:36   ` Curtis Malainey
2019-11-08  9:46 ` [alsa-devel] [PATCH 7/8] ASoC: cros_ec_codec: " Takashi Iwai
2019-11-08  9:46 ` [alsa-devel] [PATCH 8/8] ALSA: pcm: Unexport snd_pcm_sgbuf_ops_page Takashi Iwai
2019-11-08 12:43 ` [alsa-devel] [PATCH 0/8] ASoC: memalloc cleanups 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).