alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: alsa-devel@alsa-project.org, linux-doc@vger.kernel.org,
	linux-mmc@vger.kernel.org, linux-fbdev@vger.kernel.org,
	linux-nvme@lists.infradead.org, Jaroslav Kysela <perex@perex.cz>,
	Peter Ujfalusi <peter.ujfalusi@ti.com>,
	linux-ide@vger.kernel.org, Kukjin Kim <kgene.kim@samsung.com>,
	devel@driverdev.osuosl.org, linux-samsung-soc@vger.kernel.org,
	linux-scsi@vger.kernel.org, e1000-devel@lists.sourceforge.net,
	b43-dev@lists.infradead.org, linux-media@vger.kernel.org,
	devicetree@vger.kernel.org,
	Haojian Zhuang <haojian.zhuang@gmail.com>,
	Timur Tabi <timur@tabi.org>, Mark Brown <broonie@kernel.org>,
	dri-devel@lists.freedesktop.org, Ben Dooks <ben-linux@fluff.org>,
	linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Solarflare linux maintainers <linux-net-drivers@solarflare.com>,
	Eric Miao <eric.y.miao@gmail.com>, Sangbeom Kim <sbkim73@sa>
Subject: Re: [PATCH 28/51] DMA-API: sound: fix dma mask handling in a lot of drivers
Date: Thu, 26 Sep 2013 09:51:23 +0200	[thread overview]
Message-ID: <s5h1u4cf2bo.wl%tiwai@suse.de> (raw)
In-Reply-To: <E1VMm9m-0007ij-ER@rmk-PC.arm.linux.org.uk>

Hi,

sorry for the lat response, as I've been traveling in the last weeks.

At Thu, 19 Sep 2013 22:53:02 +0100,
Russell King wrote:
> 
> This code sequence is unsafe in modules:
> 
> static u64 mask = DMA_BIT_MASK(something);
> ...
> 	if (!dev->dma_mask)
> 		dev->dma_mask = &mask;
> 
> as if a module is reloaded, the mask will be pointing at the original
> module's mask address, and this can lead to oopses.  Moreover, they
> all follow this with:
> 
> 	if (!dev->coherent_dma_mask)
> 		dev->coherent_dma_mask = mask;
> 
> where 'mask' is the same value as the statically defined mask, and this
> bypasses the architecture's check on whether the DMA mask is possible.
> 
> Fix these issues by using the new dma_coerce_coherent_and_mask()
> function.
> 
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

Applied with Mark's ack now.

BTW, sound/soc/fsl/imx-pcm-fiq.c wasn't covered by this patch, so I
fixed it, too.


Thanks!

Takashi


> ---
>  sound/arm/pxa2xx-pcm.c              |    9 +++------
>  sound/soc/atmel/atmel-pcm.c         |   11 ++++-------
>  sound/soc/blackfin/bf5xx-ac97-pcm.c |   11 ++++-------
>  sound/soc/blackfin/bf5xx-i2s-pcm.c  |   10 ++++------
>  sound/soc/davinci/davinci-pcm.c     |    9 +++------
>  sound/soc/fsl/fsl_dma.c             |    9 +++------
>  sound/soc/fsl/mpc5200_dma.c         |   10 ++++------
>  sound/soc/jz4740/jz4740-pcm.c       |   12 ++++--------
>  sound/soc/kirkwood/kirkwood-dma.c   |    9 +++------
>  sound/soc/nuc900/nuc900-pcm.c       |    9 ++++-----
>  sound/soc/omap/omap-pcm.c           |   11 ++++-------
>  sound/soc/pxa/pxa2xx-pcm.c          |   11 ++++-------
>  sound/soc/s6000/s6000-pcm.c         |    9 +++------
>  sound/soc/samsung/dma.c             |   11 ++++-------
>  sound/soc/samsung/idma.c            |   11 ++++-------
>  15 files changed, 55 insertions(+), 97 deletions(-)
> 
> diff --git a/sound/arm/pxa2xx-pcm.c b/sound/arm/pxa2xx-pcm.c
> index 69a2455..fb3b76f 100644
> --- a/sound/arm/pxa2xx-pcm.c
> +++ b/sound/arm/pxa2xx-pcm.c
> @@ -83,8 +83,6 @@ static struct snd_pcm_ops pxa2xx_pcm_ops = {
>  	.mmap		= pxa2xx_pcm_mmap,
>  };
>  
> -static u64 pxa2xx_pcm_dmamask = 0xffffffff;
> -
>  int pxa2xx_pcm_new(struct snd_card *card, struct pxa2xx_pcm_client *client,
>  		   struct snd_pcm **rpcm)
>  {
> @@ -100,10 +98,9 @@ int pxa2xx_pcm_new(struct snd_card *card, struct pxa2xx_pcm_client *client,
>  	pcm->private_data = client;
>  	pcm->private_free = pxa2xx_pcm_free_dma_buffers;
>  
> -	if (!card->dev->dma_mask)
> -		card->dev->dma_mask = &pxa2xx_pcm_dmamask;
> -	if (!card->dev->coherent_dma_mask)
> -		card->dev->coherent_dma_mask = 0xffffffff;
> +	ret = dma_coerce_mask_and_coherent_mask(card->dev, DMA_BIT_MASK(32));
> +	if (ret)
> +		goto out;
>  
>  	if (play) {
>  		int stream = SNDRV_PCM_STREAM_PLAYBACK;
> diff --git a/sound/soc/atmel/atmel-pcm.c b/sound/soc/atmel/atmel-pcm.c
> index 3109db7..fbb87e3 100644
> --- a/sound/soc/atmel/atmel-pcm.c
> +++ b/sound/soc/atmel/atmel-pcm.c
> @@ -68,18 +68,15 @@ int atmel_pcm_mmap(struct snd_pcm_substream *substream,
>  }
>  EXPORT_SYMBOL_GPL(atmel_pcm_mmap);
>  
> -static u64 atmel_pcm_dmamask = DMA_BIT_MASK(32);
> -
>  int atmel_pcm_new(struct snd_soc_pcm_runtime *rtd)
>  {
>  	struct snd_card *card = rtd->card->snd_card;
>  	struct snd_pcm *pcm = rtd->pcm;
> -	int ret = 0;
> +	int ret;
>  
> -	if (!card->dev->dma_mask)
> -		card->dev->dma_mask = &atmel_pcm_dmamask;
> -	if (!card->dev->coherent_dma_mask)
> -		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> +	ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> +	if (ret)
> +		return ret;
>  
>  	if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
>  		pr_debug("atmel-pcm: allocating PCM playback DMA buffer\n");
> diff --git a/sound/soc/blackfin/bf5xx-ac97-pcm.c b/sound/soc/blackfin/bf5xx-ac97-pcm.c
> index 53f8408..1d4c676 100644
> --- a/sound/soc/blackfin/bf5xx-ac97-pcm.c
> +++ b/sound/soc/blackfin/bf5xx-ac97-pcm.c
> @@ -415,19 +415,16 @@ static void bf5xx_pcm_free_dma_buffers(struct snd_pcm *pcm)
>  	}
>  }
>  
> -static u64 bf5xx_pcm_dmamask = DMA_BIT_MASK(32);
> -
>  static int bf5xx_pcm_ac97_new(struct snd_soc_pcm_runtime *rtd)
>  {
>  	struct snd_card *card = rtd->card->snd_card;
>  	struct snd_pcm *pcm = rtd->pcm;
> -	int ret = 0;
> +	int ret;
>  
>  	pr_debug("%s enter\n", __func__);
> -	if (!card->dev->dma_mask)
> -		card->dev->dma_mask = &bf5xx_pcm_dmamask;
> -	if (!card->dev->coherent_dma_mask)
> -		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> +	ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> +	if (ret)
> +		return ret;
>  
>  	if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
>  		ret = bf5xx_pcm_preallocate_dma_buffer(pcm,
> diff --git a/sound/soc/blackfin/bf5xx-i2s-pcm.c b/sound/soc/blackfin/bf5xx-i2s-pcm.c
> index 9cb4a80..2a5b434 100644
> --- a/sound/soc/blackfin/bf5xx-i2s-pcm.c
> +++ b/sound/soc/blackfin/bf5xx-i2s-pcm.c
> @@ -323,18 +323,16 @@ static struct snd_pcm_ops bf5xx_pcm_i2s_ops = {
>  	.silence	= bf5xx_pcm_silence,
>  };
>  
> -static u64 bf5xx_pcm_dmamask = DMA_BIT_MASK(32);
> -
>  static int bf5xx_pcm_i2s_new(struct snd_soc_pcm_runtime *rtd)
>  {
>  	struct snd_card *card = rtd->card->snd_card;
>  	size_t size = bf5xx_pcm_hardware.buffer_bytes_max;
> +	int ret;
>  
>  	pr_debug("%s enter\n", __func__);
> -	if (!card->dev->dma_mask)
> -		card->dev->dma_mask = &bf5xx_pcm_dmamask;
> -	if (!card->dev->coherent_dma_mask)
> -		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> +	ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> +	if (ret)
> +		return ret;
>  
>  	return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm,
>  				SNDRV_DMA_TYPE_DEV, card->dev, size, size);
> diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c
> index 8460edc..84a63c6 100644
> --- a/sound/soc/davinci/davinci-pcm.c
> +++ b/sound/soc/davinci/davinci-pcm.c
> @@ -844,18 +844,15 @@ static void davinci_pcm_free(struct snd_pcm *pcm)
>  	}
>  }
>  
> -static u64 davinci_pcm_dmamask = DMA_BIT_MASK(32);
> -
>  static int davinci_pcm_new(struct snd_soc_pcm_runtime *rtd)
>  {
>  	struct snd_card *card = rtd->card->snd_card;
>  	struct snd_pcm *pcm = rtd->pcm;
>  	int ret;
>  
> -	if (!card->dev->dma_mask)
> -		card->dev->dma_mask = &davinci_pcm_dmamask;
> -	if (!card->dev->coherent_dma_mask)
> -		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> +	ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> +	if (ret)
> +		return ret;
>  
>  	if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
>  		ret = davinci_pcm_preallocate_dma_buffer(pcm,
> diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c
> index 9cc5c1f..f73c7ef 100644
> --- a/sound/soc/fsl/fsl_dma.c
> +++ b/sound/soc/fsl/fsl_dma.c
> @@ -298,14 +298,11 @@ static int fsl_dma_new(struct snd_soc_pcm_runtime *rtd)
>  {
>  	struct snd_card *card = rtd->card->snd_card;
>  	struct snd_pcm *pcm = rtd->pcm;
> -	static u64 fsl_dma_dmamask = DMA_BIT_MASK(36);
>  	int ret;
>  
> -	if (!card->dev->dma_mask)
> -		card->dev->dma_mask = &fsl_dma_dmamask;
> -
> -	if (!card->dev->coherent_dma_mask)
> -		card->dev->coherent_dma_mask = fsl_dma_dmamask;
> +	ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(36));
> +	if (ret)
> +		return ret;
>  
>  	/* Some codecs have separate DAIs for playback and capture, so we
>  	 * should allocate a DMA buffer only for the streams that are valid.
> diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c
> index 2a847ca..8fcf224 100644
> --- a/sound/soc/fsl/mpc5200_dma.c
> +++ b/sound/soc/fsl/mpc5200_dma.c
> @@ -299,7 +299,6 @@ static struct snd_pcm_ops psc_dma_ops = {
>  	.hw_params	= psc_dma_hw_params,
>  };
>  
> -static u64 psc_dma_dmamask = DMA_BIT_MASK(32);
>  static int psc_dma_new(struct snd_soc_pcm_runtime *rtd)
>  {
>  	struct snd_card *card = rtd->card->snd_card;
> @@ -307,15 +306,14 @@ static int psc_dma_new(struct snd_soc_pcm_runtime *rtd)
>  	struct snd_pcm *pcm = rtd->pcm;
>  	struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(rtd->cpu_dai);
>  	size_t size = psc_dma_hardware.buffer_bytes_max;
> -	int rc = 0;
> +	int rc;
>  
>  	dev_dbg(rtd->platform->dev, "psc_dma_new(card=%p, dai=%p, pcm=%p)\n",
>  		card, dai, pcm);
>  
> -	if (!card->dev->dma_mask)
> -		card->dev->dma_mask = &psc_dma_dmamask;
> -	if (!card->dev->coherent_dma_mask)
> -		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> +	rc = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> +	if (rc)
> +		return rc;
>  
>  	if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
>  		rc = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->card->dev,
> diff --git a/sound/soc/jz4740/jz4740-pcm.c b/sound/soc/jz4740/jz4740-pcm.c
> index 7100592..1d7ef28 100644
> --- a/sound/soc/jz4740/jz4740-pcm.c
> +++ b/sound/soc/jz4740/jz4740-pcm.c
> @@ -297,19 +297,15 @@ static void jz4740_pcm_free(struct snd_pcm *pcm)
>  	}
>  }
>  
> -static u64 jz4740_pcm_dmamask = DMA_BIT_MASK(32);
> -
>  static int jz4740_pcm_new(struct snd_soc_pcm_runtime *rtd)
>  {
>  	struct snd_card *card = rtd->card->snd_card;
>  	struct snd_pcm *pcm = rtd->pcm;
> -	int ret = 0;
> -
> -	if (!card->dev->dma_mask)
> -		card->dev->dma_mask = &jz4740_pcm_dmamask;
> +	int ret;
>  
> -	if (!card->dev->coherent_dma_mask)
> -		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> +	ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> +	if (ret)
> +		return ret;
>  
>  	if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
>  		ret = jz4740_pcm_preallocate_dma_buffer(pcm,
> diff --git a/sound/soc/kirkwood/kirkwood-dma.c b/sound/soc/kirkwood/kirkwood-dma.c
> index b238434..3814bb0 100644
> --- a/sound/soc/kirkwood/kirkwood-dma.c
> +++ b/sound/soc/kirkwood/kirkwood-dma.c
> @@ -59,8 +59,6 @@ static struct snd_pcm_hardware kirkwood_dma_snd_hw = {
>  	.fifo_size		= 0,
>  };
>  
> -static u64 kirkwood_dma_dmamask = DMA_BIT_MASK(32);
> -
>  static irqreturn_t kirkwood_dma_irq(int irq, void *dev_id)
>  {
>  	struct kirkwood_dma_data *priv = dev_id;
> @@ -292,10 +290,9 @@ static int kirkwood_dma_new(struct snd_soc_pcm_runtime *rtd)
>  	struct snd_pcm *pcm = rtd->pcm;
>  	int ret;
>  
> -	if (!card->dev->dma_mask)
> -		card->dev->dma_mask = &kirkwood_dma_dmamask;
> -	if (!card->dev->coherent_dma_mask)
> -		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> +	ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> +	if (ret)
> +		return ret;
>  
>  	if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
>  		ret = kirkwood_dma_preallocate_dma_buffer(pcm,
> diff --git a/sound/soc/nuc900/nuc900-pcm.c b/sound/soc/nuc900/nuc900-pcm.c
> index c894ff0..f588ee4 100644
> --- a/sound/soc/nuc900/nuc900-pcm.c
> +++ b/sound/soc/nuc900/nuc900-pcm.c
> @@ -314,16 +314,15 @@ static void nuc900_dma_free_dma_buffers(struct snd_pcm *pcm)
>  	snd_pcm_lib_preallocate_free_for_all(pcm);
>  }
>  
> -static u64 nuc900_pcm_dmamask = DMA_BIT_MASK(32);
>  static int nuc900_dma_new(struct snd_soc_pcm_runtime *rtd)
>  {
>  	struct snd_card *card = rtd->card->snd_card;
>  	struct snd_pcm *pcm = rtd->pcm;
> +	int ret;
>  
> -	if (!card->dev->dma_mask)
> -		card->dev->dma_mask = &nuc900_pcm_dmamask;
> -	if (!card->dev->coherent_dma_mask)
> -		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> +	ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> +	if (ret)
> +		return ret;
>  
>  	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
>  		card->dev, 4 * 1024, (4 * 1024) - 1);
> diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
> index a11405d..b8fa986 100644
> --- a/sound/soc/omap/omap-pcm.c
> +++ b/sound/soc/omap/omap-pcm.c
> @@ -156,8 +156,6 @@ static struct snd_pcm_ops omap_pcm_ops = {
>  	.mmap		= omap_pcm_mmap,
>  };
>  
> -static u64 omap_pcm_dmamask = DMA_BIT_MASK(64);
> -
>  static int omap_pcm_preallocate_dma_buffer(struct snd_pcm *pcm,
>  	int stream)
>  {
> @@ -202,12 +200,11 @@ static int omap_pcm_new(struct snd_soc_pcm_runtime *rtd)
>  {
>  	struct snd_card *card = rtd->card->snd_card;
>  	struct snd_pcm *pcm = rtd->pcm;
> -	int ret = 0;
> +	int ret;
>  
> -	if (!card->dev->dma_mask)
> -		card->dev->dma_mask = &omap_pcm_dmamask;
> -	if (!card->dev->coherent_dma_mask)
> -		card->dev->coherent_dma_mask = DMA_BIT_MASK(64);
> +	ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(64));
> +	if (ret)
> +		return ret;
>  
>  	if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
>  		ret = omap_pcm_preallocate_dma_buffer(pcm,
> diff --git a/sound/soc/pxa/pxa2xx-pcm.c b/sound/soc/pxa/pxa2xx-pcm.c
> index 806da27..d58b09f 100644
> --- a/sound/soc/pxa/pxa2xx-pcm.c
> +++ b/sound/soc/pxa/pxa2xx-pcm.c
> @@ -87,18 +87,15 @@ static struct snd_pcm_ops pxa2xx_pcm_ops = {
>  	.mmap		= pxa2xx_pcm_mmap,
>  };
>  
> -static u64 pxa2xx_pcm_dmamask = DMA_BIT_MASK(32);
> -
>  static int pxa2xx_soc_pcm_new(struct snd_soc_pcm_runtime *rtd)
>  {
>  	struct snd_card *card = rtd->card->snd_card;
>  	struct snd_pcm *pcm = rtd->pcm;
> -	int ret = 0;
> +	int ret;
>  
> -	if (!card->dev->dma_mask)
> -		card->dev->dma_mask = &pxa2xx_pcm_dmamask;
> -	if (!card->dev->coherent_dma_mask)
> -		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> +	ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> +	if (ret)
> +		return ret;
>  
>  	if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
>  		ret = pxa2xx_pcm_preallocate_dma_buffer(pcm,
> diff --git a/sound/soc/s6000/s6000-pcm.c b/sound/soc/s6000/s6000-pcm.c
> index d0740a7..283620a 100644
> --- a/sound/soc/s6000/s6000-pcm.c
> +++ b/sound/soc/s6000/s6000-pcm.c
> @@ -444,8 +444,6 @@ static void s6000_pcm_free(struct snd_pcm *pcm)
>  	snd_pcm_lib_preallocate_free_for_all(pcm);
>  }
>  
> -static u64 s6000_pcm_dmamask = DMA_BIT_MASK(32);
> -
>  static int s6000_pcm_new(struct snd_soc_pcm_runtime *runtime)
>  {
>  	struct snd_card *card = runtime->card->snd_card;
> @@ -456,10 +454,9 @@ static int s6000_pcm_new(struct snd_soc_pcm_runtime *runtime)
>  	params = snd_soc_dai_get_dma_data(runtime->cpu_dai,
>  			pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream);
>  
> -	if (!card->dev->dma_mask)
> -		card->dev->dma_mask = &s6000_pcm_dmamask;
> -	if (!card->dev->coherent_dma_mask)
> -		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> +	res = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> +	if (res)
> +		return res;
>  
>  	if (params->dma_in) {
>  		s6dmac_disable_chan(DMA_MASK_DMAC(params->dma_in),
> diff --git a/sound/soc/samsung/dma.c b/sound/soc/samsung/dma.c
> index 9338d11..fe2748b 100644
> --- a/sound/soc/samsung/dma.c
> +++ b/sound/soc/samsung/dma.c
> @@ -406,20 +406,17 @@ static void dma_free_dma_buffers(struct snd_pcm *pcm)
>  	}
>  }
>  
> -static u64 dma_mask = DMA_BIT_MASK(32);
> -
>  static int dma_new(struct snd_soc_pcm_runtime *rtd)
>  {
>  	struct snd_card *card = rtd->card->snd_card;
>  	struct snd_pcm *pcm = rtd->pcm;
> -	int ret = 0;
> +	int ret;
>  
>  	pr_debug("Entered %s\n", __func__);
>  
> -	if (!card->dev->dma_mask)
> -		card->dev->dma_mask = &dma_mask;
> -	if (!card->dev->coherent_dma_mask)
> -		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> +	ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> +	if (ret)
> +		return ret;
>  
>  	if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
>  		ret = preallocate_dma_buffer(pcm,
> diff --git a/sound/soc/samsung/idma.c b/sound/soc/samsung/idma.c
> index ce1e1e1..e4f318f 100644
> --- a/sound/soc/samsung/idma.c
> +++ b/sound/soc/samsung/idma.c
> @@ -383,18 +383,15 @@ static int preallocate_idma_buffer(struct snd_pcm *pcm, int stream)
>  	return 0;
>  }
>  
> -static u64 idma_mask = DMA_BIT_MASK(32);
> -
>  static int idma_new(struct snd_soc_pcm_runtime *rtd)
>  {
>  	struct snd_card *card = rtd->card->snd_card;
>  	struct snd_pcm *pcm = rtd->pcm;
> -	int ret = 0;
> +	int ret;
>  
> -	if (!card->dev->dma_mask)
> -		card->dev->dma_mask = &idma_mask;
> -	if (!card->dev->coherent_dma_mask)
> -		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
> +	ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
> +	if (ret)
> +		return ret;
>  
>  	if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
>  		ret = preallocate_idma_buffer(pcm,
> -- 
> 1.7.4.4
> 

  parent reply	other threads:[~2013-09-26  7:51 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-19 21:22 [PATCH 00/51] DMA mask changes Russell King - ARM Linux
2013-09-19 21:25 ` [PATCH 01/51] DMA-API: provide a helper to set both DMA and coherent DMA masks Russell King
     [not found]   ` <E1VMlja-0007fA-HU-eh5Bv4kxaXIANfyc6IWni62ZND6+EDdj@public.gmane.org>
2013-09-20  1:21     ` Ben Hutchings
     [not found]       ` <1379640097.2500.4.camel-/LGg1Z1CJKQ+9kgCwbf1HqK4ta4zdZpAajtMo4Cw6ucAvxtiuMwx3w@public.gmane.org>
2013-09-20 14:12         ` Russell King - ARM Linux
2013-09-19 21:26 ` [PATCH 02/51] DMA-API: net: brocade/bna/bnad.c: fix 32-bit DMA mask handling Russell King
2013-09-19 21:27 ` [PATCH 03/51] DMA-API: net: intel/e1000e: " Russell King
2013-09-20 19:48   ` Jeff Kirsher
2013-09-19 21:30 ` [PATCH 06/51] DMA-API: net: intel/ixgb: " Russell King
2013-09-20 19:50   ` Jeff Kirsher
2013-09-19 21:31 ` [PATCH 07/51] DMA-API: net: intel/ixgbe: " Russell King
2013-09-20 19:51   ` Jeff Kirsher
2013-09-19 21:34 ` [PATCH 10/51] DMA-API: net: broadcom/bnx2x: replace dma_set_mask()+dma_set_coherent_mask() with new helper Russell King
2013-09-19 21:37 ` [PATCH 12/51] DMA-API: net: intel/e1000: " Russell King
2013-09-20 19:45   ` Jeff Kirsher
2013-09-19 21:38 ` [PATCH 13/51] DMA-API: net: sfc/efx.c: " Russell King
2013-09-19 21:39 ` [PATCH 14/51] DMA-API: net: b43: " Russell King
2013-09-19 21:40 ` [PATCH 15/51] DMA-API: net: b43legacy: " Russell King
2013-09-19 21:41 ` [PATCH 16/51] DMA-API: ppc: vio.c: " Russell King
2013-11-15 16:16   ` Cedric Le Goater
2013-09-19 21:42 ` [PATCH 17/51] DMA-API: block: nvme-core: " Russell King
2013-09-19 21:43 ` [PATCH 18/51] DMA-API: staging: et131x: " Russell King
2013-09-19 21:44 ` [PATCH 19/51] DMA-API: media: dt3155v4l: " Russell King
2013-09-30 11:57   ` Hans Verkuil
     [not found]     ` <5249673B.5020705-qWit8jRvyhVmR6Xm/wNWPw@public.gmane.org>
2013-10-31 11:46       ` Mauro Carvalho Chehab
2013-10-31 14:49         ` Russell King - ARM Linux
2013-09-19 21:45 ` [PATCH 20/51] DMA-API: usb: bcma: " Russell King
2013-09-19 21:46 ` [PATCH 21/51] DMA-API: usb: ssb-hcd: " Russell King
2013-09-19 21:47 ` [PATCH 22/51] DMA-API: amba: get rid of separate dma_mask Russell King
2013-09-22 12:18   ` Grant Likely
2013-09-19 21:48 ` [PATCH 23/51] DMA-API: dma: pl08x: add dma_set_mask_and_coherent() call Russell King
     [not found]   ` <E1VMm4v-0007hz-RC-eh5Bv4kxaXIANfyc6IWni62ZND6+EDdj@public.gmane.org>
2013-09-23 10:12     ` [alsa-devel] " Vinod Koul
2013-09-19 21:49 ` [PATCH 24/51] DMA-API: dma: pl330: " Russell King
     [not found]   ` <E1VMm5t-0007i5-V7-eh5Bv4kxaXIANfyc6IWni62ZND6+EDdj@public.gmane.org>
2013-09-20 17:26     ` Heiko Stübner
2013-09-21 20:00       ` Russell King - ARM Linux
2013-09-23 10:43         ` [alsa-devel] " Vinod Koul
2013-09-19 21:50 ` [PATCH 25/51] DMA-API: video: clcd: " Russell King
2013-09-19 21:51 ` [PATCH 26/51] DMA-API: usb: ohci-sa1111: add a note about DMA masks Russell King
2013-09-19 21:53 ` [PATCH 28/51] DMA-API: sound: fix dma mask handling in a lot of drivers Russell King
2013-09-20 16:36   ` Mark Brown
2013-09-26  7:51   ` Takashi Iwai [this message]
2013-09-26  7:54     ` Russell King - ARM Linux
2013-09-26  8:25       ` Takashi Iwai
2013-09-26  8:29         ` Takashi Iwai
2013-09-19 21:54 ` [PATCH 29/51] DMA-API: ata: pata_octeon_cf: convert to use dma_coerce_mask_and_coherent() Russell King
2013-10-30 19:08   ` Geert Uytterhoeven
2013-09-19 21:55 ` [PATCH 30/51] DMA-API: dma: dw_dmac.c: " Russell King
2013-09-19 21:56 ` [PATCH 31/51] DMA-API: media: omap3isp: " Russell King
     [not found]   ` <E1VMmCg-0007j1-Pi-eh5Bv4kxaXIANfyc6IWni62ZND6+EDdj@public.gmane.org>
2013-09-27  1:56     ` Laurent Pinchart
2013-09-19 21:57 ` [PATCH 32/51] DMA-API: mmc: sdhci-acpi: " Russell King
2013-09-19 21:58 ` [PATCH 33/51] DMA-API: net: nxp/lpc_eth: " Russell King
2013-09-19 21:59 ` [PATCH 34/51] DMA-API: net: octeon: " Russell King
2013-09-19 22:00 ` [PATCH 35/51] DMA-API: parport: parport_pc.c: " Russell King
2013-09-19 22:01 ` [PATCH 36/51] DMA-API: usb: use dma_set_coherent_mask() Russell King
2013-09-20 13:08   ` Felipe Balbi
2013-09-23 12:30   ` Nicolas Ferre
2013-09-23 18:27   ` Alan Stern
     [not found]     ` <Pine.LNX.4.44L0.1309231418030.1348-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-09-23 18:42       ` Russell King - ARM Linux
2013-09-19 22:02 ` [PATCH 37/51] DMA-API: usb: use new dma_coerce_mask_and_coherent() Russell King
2013-09-20 13:10   ` Felipe Balbi
     [not found]   ` <E1VMmIV-0007jw-Gq-eh5Bv4kxaXIANfyc6IWni62ZND6+EDdj@public.gmane.org>
2013-09-23 12:34     ` Nicolas Ferre
2013-09-19 22:03 ` [PATCH 38/51] DMA-API: staging: use dma_set_coherent_mask() Russell King
2013-09-19 23:11 ` [PATCH 39/51] DMA-API: others: " Russell King
2013-09-20 12:16   ` Tejun Heo
2013-09-20 12:18     ` Tejun Heo
2013-09-20 14:00     ` Russell King - ARM Linux
2013-09-20 22:20       ` Tejun Heo
2013-09-26 10:51   ` Archit Taneja
2013-09-19 23:12 ` [PATCH 40/51] DMA-API: crypto: fix ixp4xx crypto platform device support Russell King
2013-09-19 23:13 ` [PATCH 41/51] DMA-API: crypto: remove last references to 'static struct device *dev' Russell King
2013-09-19 23:14 ` [PATCH 42/51] DMA-API: usb: musb: use platform_device_register_full() to avoid directly messing with dma masks Russell King
2013-09-20 13:11   ` Felipe Balbi
2013-09-20 13:49     ` Russell King - ARM Linux
2013-09-20 15:15       ` Felipe Balbi
     [not found] ` <20130919212235.GD12758-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2013-09-19 21:28   ` [PATCH 04/51] DMA-API: net: intel/igb: fix 32-bit DMA mask handling Russell King
2013-09-20 19:49     ` Jeff Kirsher
2013-09-19 21:29   ` [PATCH 05/51] DMA-API: net: intel/igbvf: " Russell King
2013-09-20 19:49     ` Jeff Kirsher
2013-09-19 21:32   ` [PATCH 08/51] DMA-API: net: intel/ixgbevf: " Russell King
2013-09-20 19:51     ` Jeff Kirsher
2013-09-19 21:33   ` [PATCH 09/51] DMA-API: net: broadcom/b44: replace dma_set_mask()+dma_set_coherent_mask() with new helper Russell King
2013-09-19 21:36   ` [PATCH 11/51] DMA-API: net: emulex/benet: " Russell King
2013-09-19 21:52   ` [PATCH 27/51] DMA-API: provide a helper to setup DMA masks Russell King
2013-09-19 23:15   ` [PATCH 43/51] DMA-API: dma: edma.c: no need to explicitly initialize " Russell King
2013-09-23 10:25     ` [alsa-devel] " Vinod Koul
2013-09-23 11:37       ` Russell King - ARM Linux
2013-09-19 23:16   ` [PATCH 44/51] DMA-API: dcdbas: update DMA mask handing Russell King
2013-09-19 23:17 ` [PATCH 45/51] DMA-API: firmware/google/gsmi.c: avoid direct access to DMA masks Russell King
2013-09-19 23:39 ` [PATCH 46/51] ARM: DMA-API: better handing of DMA masks for coherent allocations Russell King
2013-09-19 23:40 ` [PATCH 47/51] ARM: 7794/1: block: Rename parameter dma_mask to max_addr for blk_queue_bounce_limit() Russell King
2013-09-19 23:41 ` [PATCH 48/51] ARM: 7795/1: mm: dma-mapping: Add dma_max_pfn(dev) helper function Russell King
2013-09-19 23:42 ` [PATCH 49/51] ARM: 7796/1: scsi: Use dma_max_pfn(dev) helper for bounce_limit calculations Russell King
2013-09-19 23:43 ` [PATCH 50/51] ARM: 7797/1: mmc: " Russell King
2013-09-19 23:44 ` [PATCH 51/51] ARM: 7805/1: mm: change max*pfn to include the physical offset of memory Russell King
2013-09-26 20:23 ` [PATCH 00/51] DMA mask changes Rafał Miłecki
2013-09-27  8:27   ` Russell King - ARM Linux

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5h1u4cf2bo.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=b43-dev@lists.infradead.org \
    --cc=ben-linux@fluff.org \
    --cc=broonie@kernel.org \
    --cc=devel@driverdev.osuosl.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=e1000-devel@lists.sourceforge.net \
    --cc=eric.y.miao@gmail.com \
    --cc=haojian.zhuang@gmail.com \
    --cc=kgene.kim@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-net-drivers@solarflare.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=peter.ujfalusi@ti.com \
    --cc=rmk+kernel@arm.linux.org.uk \
    --cc=sbkim73@sa \
    --cc=timur@tabi.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).