Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1667476 > unrolled thread

remove dma_alloc_noncoherent

Started byChristoph Hellwig <hch@lst.de>
First post2017-06-16 09:20 +0200
Last post2017-06-16 09:30 +0200
Articles 14 — 3 participants

Back to article view | Back to linux.kernel


Contents

  remove dma_alloc_noncoherent Christoph Hellwig <hch@lst.de> - 2017-06-16 09:20 +0200
    [PATCH 08/11] sgiseeq: switch to dma_alloc_attrs Christoph Hellwig <hch@lst.de> - 2017-06-16 09:20 +0200
    [PATCH 11/11] dma-mapping: remove dma_alloc_noncoherent and dma_free_noncoherent Christoph Hellwig <hch@lst.de> - 2017-06-16 09:20 +0200
    [PATCH 02/11] dma-mapping: replace dmam_alloc_noncoherent with dmam_alloc_attrs Christoph Hellwig <hch@lst.de> - 2017-06-16 09:20 +0200
    [PATCH 04/11] sound/hal2: switch to dma_alloc_attrs Christoph Hellwig <hch@lst.de> - 2017-06-16 09:20 +0200
      Re: [alsa-devel] [PATCH 04/11] sound/hal2: switch to dma_alloc_attrs Takashi Iwai <tiwai@suse.de> - 2017-06-16 11:00 +0200
        Re: [alsa-devel] [PATCH 04/11] sound/hal2: switch to   dma_alloc_attrs Takashi Iwai <tiwai@suse.de> - 2017-06-16 11:00 +0200
        Re: [alsa-devel] [PATCH 04/11] sound/hal2: switch to         dma_alloc_attrs Christoph Hellwig <hch@lst.de> - 2017-06-16 11:00 +0200
    [PATCH 10/11] i825xx: switch to switch to dma_alloc_attrs Christoph Hellwig <hch@lst.de> - 2017-06-16 09:20 +0200
    [PATCH 05/11] serial/mpsc: switch to dma_alloc_attrs Christoph Hellwig <hch@lst.de> - 2017-06-16 09:30 +0200
    [PATCH 03/11] au1100fb: remove a bogus dma_free_nonconsistent call Christoph Hellwig <hch@lst.de> - 2017-06-16 09:30 +0200
      Re: [PATCH 03/11] au1100fb: remove a bogus dma_free_nonconsistent  call Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> - 2017-06-19 13:20 +0200
    [PATCH 01/11] dma-mapping: remove dmam_free_noncoherent Christoph Hellwig <hch@lst.de> - 2017-06-16 09:30 +0200
    [PATCH 06/11] sigwd93: switch to dma_alloc_attrs Christoph Hellwig <hch@lst.de> - 2017-06-16 09:30 +0200

#1667476 — remove dma_alloc_noncoherent

FromChristoph Hellwig <hch@lst.de>
Date2017-06-16 09:20 +0200
Subjectremove dma_alloc_noncoherent
Message-ID<tSTHX-5l6-3@gated-at.bofh.it>
For many years we've had the dma_alloc_attrs API that is more flexible
than dma_alloc_noncoherent.  This series moves the remaining users over
to the attrs API.

[toc] | [next] | [standalone]


#1667477 — [PATCH 08/11] sgiseeq: switch to dma_alloc_attrs

FromChristoph Hellwig <hch@lst.de>
Date2017-06-16 09:20 +0200
Subject[PATCH 08/11] sgiseeq: switch to dma_alloc_attrs
Message-ID<tSTHX-5l6-13@gated-at.bofh.it>
In reply to#1667476
Use dma_alloc_attrs directly instead of the dma_alloc_noncoherent wrapper.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/net/ethernet/seeq/sgiseeq.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/seeq/sgiseeq.c b/drivers/net/ethernet/seeq/sgiseeq.c
index 70347720fdf9..573691bc3b71 100644
--- a/drivers/net/ethernet/seeq/sgiseeq.c
+++ b/drivers/net/ethernet/seeq/sgiseeq.c
@@ -737,8 +737,8 @@ static int sgiseeq_probe(struct platform_device *pdev)
 	sp = netdev_priv(dev);
 
 	/* Make private data page aligned */
-	sr = dma_alloc_noncoherent(&pdev->dev, sizeof(*sp->srings),
-				&sp->srings_dma, GFP_KERNEL);
+	sr = dma_alloc_attrs(&pdev->dev, sizeof(*sp->srings), &sp->srings_dma,
+			     GFP_KERNEL, DMA_ATTR_NON_CONSISTENT);
 	if (!sr) {
 		printk(KERN_ERR "Sgiseeq: Page alloc failed, aborting.\n");
 		err = -ENOMEM;
@@ -813,8 +813,8 @@ static int sgiseeq_remove(struct platform_device *pdev)
 	struct sgiseeq_private *sp = netdev_priv(dev);
 
 	unregister_netdev(dev);
-	dma_free_noncoherent(&pdev->dev, sizeof(*sp->srings), sp->srings,
-			     sp->srings_dma);
+	dma_free_attrs(&pdev->dev, sizeof(*sp->srings), sp->srings,
+		       sp->srings_dma, DMA_ATTR_NON_CONSISTENT);
 	free_netdev(dev);
 
 	return 0;
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1667479 — [PATCH 11/11] dma-mapping: remove dma_alloc_noncoherent and dma_free_noncoherent

FromChristoph Hellwig <hch@lst.de>
Date2017-06-16 09:20 +0200
Subject[PATCH 11/11] dma-mapping: remove dma_alloc_noncoherent and dma_free_noncoherent
Message-ID<tSTHX-5l6-17@gated-at.bofh.it>
In reply to#1667476
No users left, everyone switched to the _attrs versions.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 Documentation/DMA-API.txt            | 30 ++++++++++++++++--------------
 arch/metag/include/asm/dma-mapping.h |  2 +-
 arch/nios2/include/asm/dma-mapping.h |  2 +-
 arch/tile/include/asm/dma-mapping.h  |  4 ++--
 include/linux/dma-mapping.h          | 14 --------------
 5 files changed, 20 insertions(+), 32 deletions(-)

diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt
index 6b20128fab8a..c55782f68348 100644
--- a/Documentation/DMA-API.txt
+++ b/Documentation/DMA-API.txt
@@ -451,14 +451,15 @@ processor and an I/O device, you should not be using this part of the
 API at all.
 
 void *
-dma_alloc_noncoherent(struct device *dev, size_t size,
-			       dma_addr_t *dma_handle, gfp_t flag)
+dma_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle,
+		gfp_t flag, unsigned long attrs)
 
-Identical to dma_alloc_coherent() except that the platform will
-choose to return either consistent or non-consistent memory as it sees
-fit.  By using this API, you are guaranteeing to the platform that you
-have all the correct and necessary sync points for this memory in the
-driver should it choose to return non-consistent memory.
+Identical to dma_alloc_coherent() except that when the
+DMA_ATTR_NON_CONSISTENT flags is passed in the attrs argument, the
+platform will choose to return either consistent or non-consistent memory
+as it sees fit.  By using this API, you are guaranteeing to the platform
+that you have all the correct and necessary sync points for this memory
+in the driver should it choose to return non-consistent memory.
 
 Note: where the platform can return consistent memory, it will
 guarantee that the sync points become nops.
@@ -469,12 +470,13 @@ required to work on one of the rare (usually non-PCI) architectures
 that simply cannot make consistent memory.
 
 void
-dma_free_noncoherent(struct device *dev, size_t size, void *cpu_addr,
-			      dma_addr_t dma_handle)
+dma_free_attrs(struct device *dev, size_t size, void *cpu_addr,
+	       dma_addr_t dma_handle, unsigned long attrs)
 
-Free memory allocated by the nonconsistent API.  All parameters must
-be identical to those passed in (and returned by
-dma_alloc_noncoherent()).
+Free memory allocated by the dma_alloc_attrs().  All parameters common
+parameters must identical to those otherwise passed to dma_fre_coherent,
+and the attrs argument must be identical to the attrs passed to
+dma_alloc_attrs().
 
 int
 dma_get_cache_alignment(void)
@@ -492,8 +494,8 @@ void
 dma_cache_sync(struct device *dev, void *vaddr, size_t size,
 	       enum dma_data_direction direction)
 
-Do a partial sync of memory that was allocated by
-dma_alloc_noncoherent(), starting at virtual address vaddr and
+Do a partial sync of memory that was allocated by dma_alloc_attrs() with
+the DMA_ATTR_NON_CONSISTENT flag starting at virtual address vaddr and
 continuing on for size.  Again, you *must* observe the cache line
 boundaries when doing this.
 
diff --git a/arch/metag/include/asm/dma-mapping.h b/arch/metag/include/asm/dma-mapping.h
index fad3dc3cb210..ea573be2b6d0 100644
--- a/arch/metag/include/asm/dma-mapping.h
+++ b/arch/metag/include/asm/dma-mapping.h
@@ -9,7 +9,7 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 }
 
 /*
- * dma_alloc_noncoherent() returns non-cacheable memory, so there's no need to
+ * dma_alloc_attrs() always returns non-cacheable memory, so there's no need to
  * do any flushing here.
  */
 static inline void
diff --git a/arch/nios2/include/asm/dma-mapping.h b/arch/nios2/include/asm/dma-mapping.h
index 7b3c6f280293..f8dc62222741 100644
--- a/arch/nios2/include/asm/dma-mapping.h
+++ b/arch/nios2/include/asm/dma-mapping.h
@@ -18,7 +18,7 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 }
 
 /*
- * dma_alloc_noncoherent() returns non-cacheable memory, so there's no need to
+ * dma_alloc_attrs() always returns non-cacheable memory, so there's no need to
  * do any flushing here.
  */
 static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
diff --git a/arch/tile/include/asm/dma-mapping.h b/arch/tile/include/asm/dma-mapping.h
index bbc71a29b2c6..7061dc8af43a 100644
--- a/arch/tile/include/asm/dma-mapping.h
+++ b/arch/tile/include/asm/dma-mapping.h
@@ -68,8 +68,8 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
 int dma_set_mask(struct device *dev, u64 mask);
 
 /*
- * dma_alloc_noncoherent() is #defined to return coherent memory,
- * so there's no need to do any flushing here.
+ * dma_alloc_attrs() always returns non-cacheable memory, so there's no need to
+ * do any flushing here.
  */
 static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
 				  enum dma_data_direction direction)
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 6cdf5634906d..e8861e7df6ab 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -526,20 +526,6 @@ static inline void dma_free_coherent(struct device *dev, size_t size,
 	return dma_free_attrs(dev, size, cpu_addr, dma_handle, 0);
 }
 
-static inline void *dma_alloc_noncoherent(struct device *dev, size_t size,
-		dma_addr_t *dma_handle, gfp_t gfp)
-{
-	return dma_alloc_attrs(dev, size, dma_handle, gfp,
-			       DMA_ATTR_NON_CONSISTENT);
-}
-
-static inline void dma_free_noncoherent(struct device *dev, size_t size,
-		void *cpu_addr, dma_addr_t dma_handle)
-{
-	dma_free_attrs(dev, size, cpu_addr, dma_handle,
-		       DMA_ATTR_NON_CONSISTENT);
-}
-
 static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
 {
 	debug_dma_mapping_error(dev, dma_addr);
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1667480 — [PATCH 02/11] dma-mapping: replace dmam_alloc_noncoherent with dmam_alloc_attrs

FromChristoph Hellwig <hch@lst.de>
Date2017-06-16 09:20 +0200
Subject[PATCH 02/11] dma-mapping: replace dmam_alloc_noncoherent with dmam_alloc_attrs
Message-ID<tSTHY-5l6-23@gated-at.bofh.it>
In reply to#1667476
dmam_alloc_noncoherent is a trivial wrapper around dmam_alloc_attrs,
that hardcodes one particular flag.  Make the devres code more
flexible by allowing the callers to pass arbitrary flags.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 Documentation/driver-model/devres.txt |  2 +-
 drivers/base/dma-mapping.c            | 36 ++++++++++++++++-------------------
 drivers/video/fbdev/au1200fb.c        |  5 +++--
 include/linux/dma-mapping.h           |  5 +++--
 4 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
index 9070ff06b558..7e08c02b5393 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -240,7 +240,7 @@ CLOCK
 
 DMA
   dmam_alloc_coherent()
-  dmam_alloc_noncoherent()
+  dmam_alloc_attrs()
   dmam_declare_coherent_memory()
   dmam_free_coherent()
   dmam_pool_create()
diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
index 5940c9dace36..10e7c022e8cf 100644
--- a/drivers/base/dma-mapping.c
+++ b/drivers/base/dma-mapping.c
@@ -22,20 +22,15 @@ struct dma_devres {
 	size_t		size;
 	void		*vaddr;
 	dma_addr_t	dma_handle;
+	unsigned long	attrs;
 };
 
-static void dmam_coherent_release(struct device *dev, void *res)
+static void dmam_release(struct device *dev, void *res)
 {
 	struct dma_devres *this = res;
 
-	dma_free_coherent(dev, this->size, this->vaddr, this->dma_handle);
-}
-
-static void dmam_noncoherent_release(struct device *dev, void *res)
-{
-	struct dma_devres *this = res;
-
-	dma_free_noncoherent(dev, this->size, this->vaddr, this->dma_handle);
+	dma_free_attrs(dev, this->size, this->vaddr, this->dma_handle,
+			this->attrs);
 }
 
 static int dmam_match(struct device *dev, void *res, void *match_data)
@@ -69,7 +64,7 @@ void *dmam_alloc_coherent(struct device *dev, size_t size,
 	struct dma_devres *dr;
 	void *vaddr;
 
-	dr = devres_alloc(dmam_coherent_release, sizeof(*dr), gfp);
+	dr = devres_alloc(dmam_release, sizeof(*dr), gfp);
 	if (!dr)
 		return NULL;
 
@@ -104,35 +99,35 @@ void dmam_free_coherent(struct device *dev, size_t size, void *vaddr,
 	struct dma_devres match_data = { size, vaddr, dma_handle };
 
 	dma_free_coherent(dev, size, vaddr, dma_handle);
-	WARN_ON(devres_destroy(dev, dmam_coherent_release, dmam_match,
-			       &match_data));
+	WARN_ON(devres_destroy(dev, dmam_release, dmam_match, &match_data));
 }
 EXPORT_SYMBOL(dmam_free_coherent);
 
 /**
- * dmam_alloc_non_coherent - Managed dma_alloc_noncoherent()
+ * dmam_alloc_attrs - Managed dma_alloc_attrs()
  * @dev: Device to allocate non_coherent memory for
  * @size: Size of allocation
  * @dma_handle: Out argument for allocated DMA handle
  * @gfp: Allocation flags
+ * @attrs: Flags in the DMA_ATTR_* namespace.
  *
- * Managed dma_alloc_noncoherent().  Memory allocated using this
- * function will be automatically released on driver detach.
+ * Managed dma_alloc_attrs().  Memory allocated using this function will be
+ * automatically released on driver detach.
  *
  * RETURNS:
  * Pointer to allocated memory on success, NULL on failure.
  */
-void *dmam_alloc_noncoherent(struct device *dev, size_t size,
-			     dma_addr_t *dma_handle, gfp_t gfp)
+void *dmam_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle,
+		gfp_t gfp, unsigned long attrs)
 {
 	struct dma_devres *dr;
 	void *vaddr;
 
-	dr = devres_alloc(dmam_noncoherent_release, sizeof(*dr), gfp);
+	dr = devres_alloc(dmam_release, sizeof(*dr), gfp);
 	if (!dr)
 		return NULL;
 
-	vaddr = dma_alloc_noncoherent(dev, size, dma_handle, gfp);
+	vaddr = dma_alloc_attrs(dev, size, dma_handle, gfp, attrs);
 	if (!vaddr) {
 		devres_free(dr);
 		return NULL;
@@ -141,12 +136,13 @@ void *dmam_alloc_noncoherent(struct device *dev, size_t size,
 	dr->vaddr = vaddr;
 	dr->dma_handle = *dma_handle;
 	dr->size = size;
+	dr->attrs = attrs;
 
 	devres_add(dev, dr);
 
 	return vaddr;
 }
-EXPORT_SYMBOL(dmam_alloc_noncoherent);
+EXPORT_SYMBOL(dmam_alloc_attrs);
 
 #ifdef CONFIG_HAVE_GENERIC_DMA_COHERENT
 
diff --git a/drivers/video/fbdev/au1200fb.c b/drivers/video/fbdev/au1200fb.c
index 6c2b2ca4a909..5f04b4096c42 100644
--- a/drivers/video/fbdev/au1200fb.c
+++ b/drivers/video/fbdev/au1200fb.c
@@ -1694,9 +1694,10 @@ static int au1200fb_drv_probe(struct platform_device *dev)
 		/* Allocate the framebuffer to the maximum screen size */
 		fbdev->fb_len = (win->w[plane].xres * win->w[plane].yres * bpp) / 8;
 
-		fbdev->fb_mem = dmam_alloc_noncoherent(&dev->dev,
+		fbdev->fb_mem = dmam_alloc_attrs(&dev->dev,
 				PAGE_ALIGN(fbdev->fb_len),
-				&fbdev->fb_phys, GFP_KERNEL);
+				&fbdev->fb_phys, GFP_KERNEL,
+				DMA_ATTR_NON_CONSISTENT);
 		if (!fbdev->fb_mem) {
 			print_err("fail to allocate frambuffer (size: %dK))",
 				  fbdev->fb_len / 1024);
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 830ec5f06a4f..6cdf5634906d 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -747,8 +747,9 @@ extern void *dmam_alloc_coherent(struct device *dev, size_t size,
 				 dma_addr_t *dma_handle, gfp_t gfp);
 extern void dmam_free_coherent(struct device *dev, size_t size, void *vaddr,
 			       dma_addr_t dma_handle);
-extern void *dmam_alloc_noncoherent(struct device *dev, size_t size,
-				    dma_addr_t *dma_handle, gfp_t gfp);
+extern void *dmam_alloc_attrs(struct device *dev, size_t size,
+			      dma_addr_t *dma_handle, gfp_t gfp,
+			      unsigned long attrs);
 #ifdef CONFIG_HAVE_GENERIC_DMA_COHERENT
 extern int dmam_declare_coherent_memory(struct device *dev,
 					phys_addr_t phys_addr,
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1667481 — [PATCH 04/11] sound/hal2: switch to dma_alloc_attrs

FromChristoph Hellwig <hch@lst.de>
Date2017-06-16 09:20 +0200
Subject[PATCH 04/11] sound/hal2: switch to dma_alloc_attrs
Message-ID<tSTHY-5l6-21@gated-at.bofh.it>
In reply to#1667476
Use dma_alloc_attrs directly instead of the dma_alloc_noncoherent wrapper.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 sound/mips/hal2.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/sound/mips/hal2.c b/sound/mips/hal2.c
index 00fc9241d266..17a78a93e885 100644
--- a/sound/mips/hal2.c
+++ b/sound/mips/hal2.c
@@ -461,15 +461,15 @@ static int hal2_alloc_dmabuf(struct hal2_codec *codec)
 	int count = H2_BUF_SIZE / H2_BLOCK_SIZE;
 	int i;
 
-	codec->buffer = dma_alloc_noncoherent(NULL, H2_BUF_SIZE,
-					      &buffer_dma, GFP_KERNEL);
+	codec->buffer = dma_alloc_attrs(NULL, H2_BUF_SIZE, &buffer_dma,
+					GFP_KERNEL, DMA_ATTR_NON_CONSISTENT);
 	if (!codec->buffer)
 		return -ENOMEM;
-	desc = dma_alloc_noncoherent(NULL, count * sizeof(struct hal2_desc),
-				     &desc_dma, GFP_KERNEL);
+	desc = dma_alloc_attrs(NULL, count * sizeof(struct hal2_desc),
+			       &desc_dma, GFP_KERNEL, DMA_ATTR_NON_CONSISTENT);
 	if (!desc) {
-		dma_free_noncoherent(NULL, H2_BUF_SIZE,
-				     codec->buffer, buffer_dma);
+		dma_free_attrs(NULL, H2_BUF_SIZE, codec->buffer, buffer_dma,
+			       DMA_ATTR_NON_CONSISTENT);
 		return -ENOMEM;
 	}
 	codec->buffer_dma = buffer_dma;
@@ -490,10 +490,10 @@ static int hal2_alloc_dmabuf(struct hal2_codec *codec)
 
 static void hal2_free_dmabuf(struct hal2_codec *codec)
 {
-	dma_free_noncoherent(NULL, codec->desc_count * sizeof(struct hal2_desc),
-			     codec->desc, codec->desc_dma);
-	dma_free_noncoherent(NULL, H2_BUF_SIZE, codec->buffer,
-			     codec->buffer_dma);
+	dma_free_attrs(NULL, codec->desc_count * sizeof(struct hal2_desc),
+		       codec->desc, codec->desc_dma, DMA_ATTR_NON_CONSISTENT);
+	dma_free_attrs(NULL, H2_BUF_SIZE, codec->buffer, codec->buffer_dma,
+		       DMA_ATTR_NON_CONSISTENT);
 }
 
 static struct snd_pcm_hardware hal2_pcm_hw = {
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1667535 — Re: [alsa-devel] [PATCH 04/11] sound/hal2: switch to dma_alloc_attrs

FromTakashi Iwai <tiwai@suse.de>
Date2017-06-16 11:00 +0200
SubjectRe: [alsa-devel] [PATCH 04/11] sound/hal2: switch to dma_alloc_attrs
Message-ID<tSVgJ-6bj-5@gated-at.bofh.it>
In reply to#1667481
On Fri, 16 Jun 2017 09:17:09 +0200,
Christoph Hellwig wrote:
> 
> Use dma_alloc_attrs directly instead of the dma_alloc_noncoherent wrapper.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Should I take this one through sound git tree, or would you prefer
taking all through another?

In the latter case,
  Reviewed-by: Takashi Iwai <tiwai@suse.de>


thanks,

Takashi

> ---
>  sound/mips/hal2.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/sound/mips/hal2.c b/sound/mips/hal2.c
> index 00fc9241d266..17a78a93e885 100644
> --- a/sound/mips/hal2.c
> +++ b/sound/mips/hal2.c
> @@ -461,15 +461,15 @@ static int hal2_alloc_dmabuf(struct hal2_codec *codec)
>  	int count = H2_BUF_SIZE / H2_BLOCK_SIZE;
>  	int i;
>  
> -	codec->buffer = dma_alloc_noncoherent(NULL, H2_BUF_SIZE,
> -					      &buffer_dma, GFP_KERNEL);
> +	codec->buffer = dma_alloc_attrs(NULL, H2_BUF_SIZE, &buffer_dma,
> +					GFP_KERNEL, DMA_ATTR_NON_CONSISTENT);
>  	if (!codec->buffer)
>  		return -ENOMEM;
> -	desc = dma_alloc_noncoherent(NULL, count * sizeof(struct hal2_desc),
> -				     &desc_dma, GFP_KERNEL);
> +	desc = dma_alloc_attrs(NULL, count * sizeof(struct hal2_desc),
> +			       &desc_dma, GFP_KERNEL, DMA_ATTR_NON_CONSISTENT);
>  	if (!desc) {
> -		dma_free_noncoherent(NULL, H2_BUF_SIZE,
> -				     codec->buffer, buffer_dma);
> +		dma_free_attrs(NULL, H2_BUF_SIZE, codec->buffer, buffer_dma,
> +			       DMA_ATTR_NON_CONSISTENT);
>  		return -ENOMEM;
>  	}
>  	codec->buffer_dma = buffer_dma;
> @@ -490,10 +490,10 @@ static int hal2_alloc_dmabuf(struct hal2_codec *codec)
>  
>  static void hal2_free_dmabuf(struct hal2_codec *codec)
>  {
> -	dma_free_noncoherent(NULL, codec->desc_count * sizeof(struct hal2_desc),
> -			     codec->desc, codec->desc_dma);
> -	dma_free_noncoherent(NULL, H2_BUF_SIZE, codec->buffer,
> -			     codec->buffer_dma);
> +	dma_free_attrs(NULL, codec->desc_count * sizeof(struct hal2_desc),
> +		       codec->desc, codec->desc_dma, DMA_ATTR_NON_CONSISTENT);
> +	dma_free_attrs(NULL, H2_BUF_SIZE, codec->buffer, codec->buffer_dma,
> +		       DMA_ATTR_NON_CONSISTENT);
>  }
>  
>  static struct snd_pcm_hardware hal2_pcm_hw = {
> -- 
> 2.11.0
> 
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> 

[toc] | [prev] | [next] | [standalone]


#1667536 — Re: [alsa-devel] [PATCH 04/11] sound/hal2: switch to dma_alloc_attrs

FromTakashi Iwai <tiwai@suse.de>
Date2017-06-16 11:00 +0200
SubjectRe: [alsa-devel] [PATCH 04/11] sound/hal2: switch to dma_alloc_attrs
Message-ID<tSVgJ-6bj-9@gated-at.bofh.it>
In reply to#1667535
On Fri, 16 Jun 2017 10:51:47 +0200,
Christoph Hellwig wrote:
> 
> On Fri, Jun 16, 2017 at 10:49:56AM +0200, Takashi Iwai wrote:
> > On Fri, 16 Jun 2017 09:17:09 +0200,
> > Christoph Hellwig wrote:
> > > 
> > > Use dma_alloc_attrs directly instead of the dma_alloc_noncoherent wrapper.
> > > 
> > > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > 
> > Should I take this one through sound git tree, or would you prefer
> > taking all through another?
> 
> Feel free to take it through the sound tree.

OK, applied now.  Thanks!


Takashi

[toc] | [prev] | [next] | [standalone]


#1667540 — Re: [alsa-devel] [PATCH 04/11] sound/hal2: switch to dma_alloc_attrs

FromChristoph Hellwig <hch@lst.de>
Date2017-06-16 11:00 +0200
SubjectRe: [alsa-devel] [PATCH 04/11] sound/hal2: switch to dma_alloc_attrs
Message-ID<tSVgJ-6bj-11@gated-at.bofh.it>
In reply to#1667535
On Fri, Jun 16, 2017 at 10:49:56AM +0200, Takashi Iwai wrote:
> On Fri, 16 Jun 2017 09:17:09 +0200,
> Christoph Hellwig wrote:
> > 
> > Use dma_alloc_attrs directly instead of the dma_alloc_noncoherent wrapper.
> > 
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> Should I take this one through sound git tree, or would you prefer
> taking all through another?

Feel free to take it through the sound tree.

[toc] | [prev] | [next] | [standalone]


#1667483 — [PATCH 10/11] i825xx: switch to switch to dma_alloc_attrs

FromChristoph Hellwig <hch@lst.de>
Date2017-06-16 09:20 +0200
Subject[PATCH 10/11] i825xx: switch to switch to dma_alloc_attrs
Message-ID<tSTHY-5l6-27@gated-at.bofh.it>
In reply to#1667476
This way we can always pass DMA_ATTR_NON_CONSISTENT, the SNI mips version
will simply ignore the flag.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/net/ethernet/i825xx/lasi_82596.c | 6 ++----
 drivers/net/ethernet/i825xx/lib82596.c   | 9 +++++----
 drivers/net/ethernet/i825xx/sni_82596.c  | 6 ++----
 3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/i825xx/lasi_82596.c b/drivers/net/ethernet/i825xx/lasi_82596.c
index d787fdd5db7b..d5b5021aa759 100644
--- a/drivers/net/ethernet/i825xx/lasi_82596.c
+++ b/drivers/net/ethernet/i825xx/lasi_82596.c
@@ -96,8 +96,6 @@
 
 #define OPT_SWAP_PORT	0x0001	/* Need to wordswp on the MPU port */
 
-#define DMA_ALLOC                        dma_alloc_noncoherent
-#define DMA_FREE                         dma_free_noncoherent
 #define DMA_WBACK(ndev, addr, len) \
 	do { dma_cache_sync((ndev)->dev.parent, (void *)addr, len, DMA_TO_DEVICE); } while (0)
 
@@ -200,8 +198,8 @@ static int lan_remove_chip(struct parisc_device *pdev)
 	struct i596_private *lp = netdev_priv(dev);
 
 	unregister_netdev (dev);
-	DMA_FREE(&pdev->dev, sizeof(struct i596_private),
-		 (void *)lp->dma, lp->dma_addr);
+	dma_free_attrs(&pdev->dev, sizeof(struct i596_private), lp->dma,
+		       lp->dma_addr, DMA_ATTR_NON_CONSISTENT);
 	free_netdev (dev);
 	return 0;
 }
diff --git a/drivers/net/ethernet/i825xx/lib82596.c b/drivers/net/ethernet/i825xx/lib82596.c
index e86773325cbe..31e879fbec07 100644
--- a/drivers/net/ethernet/i825xx/lib82596.c
+++ b/drivers/net/ethernet/i825xx/lib82596.c
@@ -1062,8 +1062,9 @@ static int i82596_probe(struct net_device *dev)
 	if (!dev->base_addr || !dev->irq)
 		return -ENODEV;
 
-	dma = (struct i596_dma *) DMA_ALLOC(dev->dev.parent,
-		sizeof(struct i596_dma), &lp->dma_addr, GFP_KERNEL);
+	dma = dma_alloc_attrs(dev->dev.parent, sizeof(struct i596_dma),
+			      &lp->dma_addr, GFP_KERNEL,
+			      DMA_ATTR_NON_CONSISTENT);
 	if (!dma) {
 		printk(KERN_ERR "%s: Couldn't get shared memory\n", __FILE__);
 		return -ENOMEM;
@@ -1084,8 +1085,8 @@ static int i82596_probe(struct net_device *dev)
 
 	i = register_netdev(dev);
 	if (i) {
-		DMA_FREE(dev->dev.parent, sizeof(struct i596_dma),
-				    (void *)dma, lp->dma_addr);
+		dma_free_attrs(dev->dev.parent, sizeof(struct i596_dma),
+			       dma, lp->dma_addr, DMA_ATTR_NON_CONSISTENT);
 		return i;
 	}
 
diff --git a/drivers/net/ethernet/i825xx/sni_82596.c b/drivers/net/ethernet/i825xx/sni_82596.c
index 2af7f77345fb..b2c04a789744 100644
--- a/drivers/net/ethernet/i825xx/sni_82596.c
+++ b/drivers/net/ethernet/i825xx/sni_82596.c
@@ -23,8 +23,6 @@
 
 static const char sni_82596_string[] = "snirm_82596";
 
-#define DMA_ALLOC                      dma_alloc_coherent
-#define DMA_FREE                       dma_free_coherent
 #define DMA_WBACK(priv, addr, len)     do { } while (0)
 #define DMA_INV(priv, addr, len)       do { } while (0)
 #define DMA_WBACK_INV(priv, addr, len) do { } while (0)
@@ -152,8 +150,8 @@ static int sni_82596_driver_remove(struct platform_device *pdev)
 	struct i596_private *lp = netdev_priv(dev);
 
 	unregister_netdev(dev);
-	DMA_FREE(dev->dev.parent, sizeof(struct i596_private),
-		 lp->dma, lp->dma_addr);
+	dma_free_attrs(dev->dev.parent, sizeof(struct i596_private), lp->dma,
+		       lp->dma_addr, DMA_ATTR_NON_CONSISTENT);
 	iounmap(lp->ca);
 	iounmap(lp->mpu_port);
 	free_netdev (dev);
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1667484 — [PATCH 05/11] serial/mpsc: switch to dma_alloc_attrs

FromChristoph Hellwig <hch@lst.de>
Date2017-06-16 09:30 +0200
Subject[PATCH 05/11] serial/mpsc: switch to dma_alloc_attrs
Message-ID<tSTRE-5pn-1@gated-at.bofh.it>
In reply to#1667476
Use dma_alloc_attrs directly instead of the dma_alloc_noncoherent wrapper.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/tty/serial/mpsc.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/mpsc.c b/drivers/tty/serial/mpsc.c
index 1a60a2063e75..67ffecc50e42 100644
--- a/drivers/tty/serial/mpsc.c
+++ b/drivers/tty/serial/mpsc.c
@@ -754,9 +754,10 @@ static int mpsc_alloc_ring_mem(struct mpsc_port_info *pi)
 		if (!dma_set_mask(pi->port.dev, 0xffffffff)) {
 			printk(KERN_ERR "MPSC: Inadequate DMA support\n");
 			rc = -ENXIO;
-		} else if ((pi->dma_region = dma_alloc_noncoherent(pi->port.dev,
+		} else if ((pi->dma_region = dma_alloc_attrs(pi->port.dev,
 						MPSC_DMA_ALLOC_SIZE,
-						&pi->dma_region_p, GFP_KERNEL))
+						&pi->dma_region_p, GFP_KERNEL,
+						DMA_ATTR_NON_CONSISTENT))
 				== NULL) {
 			printk(KERN_ERR "MPSC: Can't alloc Desc region\n");
 			rc = -ENOMEM;
@@ -771,8 +772,9 @@ static void mpsc_free_ring_mem(struct mpsc_port_info *pi)
 	pr_debug("mpsc_free_ring_mem[%d]: Freeing ring mem\n", pi->port.line);
 
 	if (pi->dma_region) {
-		dma_free_noncoherent(pi->port.dev, MPSC_DMA_ALLOC_SIZE,
-				pi->dma_region, pi->dma_region_p);
+		dma_free_attrs(pi->port.dev, MPSC_DMA_ALLOC_SIZE,
+				pi->dma_region, pi->dma_region_p,
+				DMA_ATTR_NON_CONSISTENT);
 		pi->dma_region = NULL;
 		pi->dma_region_p = (dma_addr_t)NULL;
 	}
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1667485 — [PATCH 03/11] au1100fb: remove a bogus dma_free_nonconsistent call

FromChristoph Hellwig <hch@lst.de>
Date2017-06-16 09:30 +0200
Subject[PATCH 03/11] au1100fb: remove a bogus dma_free_nonconsistent call
Message-ID<tSTRE-5pn-3@gated-at.bofh.it>
In reply to#1667476
au1100fb is using managed dma allocations, so it doesn't need to
explicitly free the dma memory in the error path (and if it did
it would have to use the managed version).

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/video/fbdev/au1100fb.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/video/fbdev/au1100fb.c b/drivers/video/fbdev/au1100fb.c
index 35df2c1a8a63..8de42f617d16 100644
--- a/drivers/video/fbdev/au1100fb.c
+++ b/drivers/video/fbdev/au1100fb.c
@@ -532,10 +532,6 @@ static int au1100fb_drv_probe(struct platform_device *dev)
 		clk_disable_unprepare(fbdev->lcdclk);
 		clk_put(fbdev->lcdclk);
 	}
-	if (fbdev->fb_mem) {
-		dma_free_noncoherent(&dev->dev, fbdev->fb_len, fbdev->fb_mem,
-				     fbdev->fb_phys);
-	}
 	if (fbdev->info.cmap.len != 0) {
 		fb_dealloc_cmap(&fbdev->info.cmap);
 	}
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1669012 — Re: [PATCH 03/11] au1100fb: remove a bogus dma_free_nonconsistent call

FromBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Date2017-06-19 13:20 +0200
SubjectRe: [PATCH 03/11] au1100fb: remove a bogus dma_free_nonconsistent call
Message-ID<tU2SS-1UV-7@gated-at.bofh.it>
In reply to#1667485
On Friday, June 16, 2017 09:17:08 AM Christoph Hellwig wrote:
> au1100fb is using managed dma allocations, so it doesn't need to
> explicitly free the dma memory in the error path (and if it did
> it would have to use the managed version).
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

[toc] | [prev] | [next] | [standalone]


#1667488 — [PATCH 01/11] dma-mapping: remove dmam_free_noncoherent

FromChristoph Hellwig <hch@lst.de>
Date2017-06-16 09:30 +0200
Subject[PATCH 01/11] dma-mapping: remove dmam_free_noncoherent
Message-ID<tSTRE-5pn-9@gated-at.bofh.it>
In reply to#1667476
This function was never used since it was added.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 Documentation/driver-model/devres.txt |  1 -
 drivers/base/dma-mapping.c            | 20 --------------------
 include/linux/dma-mapping.h           |  2 --
 3 files changed, 23 deletions(-)

diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
index e72587fe477d..9070ff06b558 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -243,7 +243,6 @@ DMA
   dmam_alloc_noncoherent()
   dmam_declare_coherent_memory()
   dmam_free_coherent()
-  dmam_free_noncoherent()
   dmam_pool_create()
   dmam_pool_destroy()
 
diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
index f3deb6af42ad..5940c9dace36 100644
--- a/drivers/base/dma-mapping.c
+++ b/drivers/base/dma-mapping.c
@@ -148,26 +148,6 @@ void *dmam_alloc_noncoherent(struct device *dev, size_t size,
 }
 EXPORT_SYMBOL(dmam_alloc_noncoherent);
 
-/**
- * dmam_free_coherent - Managed dma_free_noncoherent()
- * @dev: Device to free noncoherent memory for
- * @size: Size of allocation
- * @vaddr: Virtual address of the memory to free
- * @dma_handle: DMA handle of the memory to free
- *
- * Managed dma_free_noncoherent().
- */
-void dmam_free_noncoherent(struct device *dev, size_t size, void *vaddr,
-			   dma_addr_t dma_handle)
-{
-	struct dma_devres match_data = { size, vaddr, dma_handle };
-
-	dma_free_noncoherent(dev, size, vaddr, dma_handle);
-	WARN_ON(!devres_destroy(dev, dmam_noncoherent_release, dmam_match,
-				&match_data));
-}
-EXPORT_SYMBOL(dmam_free_noncoherent);
-
 #ifdef CONFIG_HAVE_GENERIC_DMA_COHERENT
 
 static void dmam_coherent_decl_release(struct device *dev, void *res)
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 4f3eecedca2d..830ec5f06a4f 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -749,8 +749,6 @@ extern void dmam_free_coherent(struct device *dev, size_t size, void *vaddr,
 			       dma_addr_t dma_handle);
 extern void *dmam_alloc_noncoherent(struct device *dev, size_t size,
 				    dma_addr_t *dma_handle, gfp_t gfp);
-extern void dmam_free_noncoherent(struct device *dev, size_t size, void *vaddr,
-				  dma_addr_t dma_handle);
 #ifdef CONFIG_HAVE_GENERIC_DMA_COHERENT
 extern int dmam_declare_coherent_memory(struct device *dev,
 					phys_addr_t phys_addr,
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1667489 — [PATCH 06/11] sigwd93: switch to dma_alloc_attrs

FromChristoph Hellwig <hch@lst.de>
Date2017-06-16 09:30 +0200
Subject[PATCH 06/11] sigwd93: switch to dma_alloc_attrs
Message-ID<tSTRE-5pn-15@gated-at.bofh.it>
In reply to#1667476
Use dma_alloc_attrs directly instead of the dma_alloc_noncoherent wrapper.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/scsi/sgiwd93.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/sgiwd93.c b/drivers/scsi/sgiwd93.c
index 71b4b91d2215..80cfa93e407c 100644
--- a/drivers/scsi/sgiwd93.c
+++ b/drivers/scsi/sgiwd93.c
@@ -249,8 +249,8 @@ static int sgiwd93_probe(struct platform_device *pdev)
 
 	hdata = host_to_hostdata(host);
 	hdata->dev = &pdev->dev;
-	hdata->cpu = dma_alloc_noncoherent(&pdev->dev, HPC_DMA_SIZE,
-					   &hdata->dma, GFP_KERNEL);
+	hdata->cpu = dma_alloc_attrs(&pdev->dev, HPC_DMA_SIZE, &hdata->dma,
+				     GFP_KERNEL, DMA_ATTR_NON_CONSISTENT);
 	if (!hdata->cpu) {
 		printk(KERN_WARNING "sgiwd93: Could not allocate memory for "
 		       "host %d buffer.\n", unit);
@@ -289,7 +289,8 @@ static int sgiwd93_probe(struct platform_device *pdev)
 out_irq:
 	free_irq(irq, host);
 out_free:
-	dma_free_noncoherent(&pdev->dev, HPC_DMA_SIZE, hdata->cpu, hdata->dma);
+	dma_free_attrs(&pdev->dev, HPC_DMA_SIZE, hdata->cpu, hdata->dma,
+		       DMA_ATTR_NON_CONSISTENT);
 out_put:
 	scsi_host_put(host);
 out:
@@ -305,7 +306,8 @@ static int sgiwd93_remove(struct platform_device *pdev)
 
 	scsi_remove_host(host);
 	free_irq(pd->irq, host);
-	dma_free_noncoherent(&pdev->dev, HPC_DMA_SIZE, hdata->cpu, hdata->dma);
+	dma_free_attrs(&pdev->dev, HPC_DMA_SIZE, hdata->cpu, hdata->dma,
+		       DMA_ATTR_NON_CONSISTENT);
 	scsi_host_put(host);
 	return 0;
 }
-- 
2.11.0

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web