remove dma_alloc_noncoherent
Subsystems (12)
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.
PATCH 1/11 dma-mapping: remove dmam_free_noncoherent
This function was never used since it was added.
--- Documentation/driver-model/devres.txt | 1 - drivers/base/dma-mapping.c | 20 -------------------- include/linux/dma-mapping.h | 2 -- 3 files changed, 23 deletions(-)
Documentation/driver-model/devres.txt +0 -1
@@ -243,7 +243,6 @@ DMA dmam_alloc_noncoherent() dmam_declare_coherent_memory() dmam_free_coherent() - dmam_free_noncoherent() dmam_pool_create() dmam_pool_destroy()
drivers/base/dma-mapping.c +0 -20
@@ -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)
include/linux/dma-mapping.h +0 -2
@@ -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,
Signature · 1 line
2.11.0
Re: [PATCH 01/11] dma-mapping: remove dmam_free_noncoherent
Tejun, does this look ok to you?
Quoted 68 lines · Christoph Hellwig
This function was never used since it was added.
Signed-off-by Christoph Hellwig <[email protected]>--- Documentation/driver-model/devres.txt | 1 - drivers/base/dma-mapping.c | 20 -------------------- include/linux/dma-mapping.h | 2 -- 3 files changed, 23 deletions(-)Documentation/driver-model/devres.txt +0
-1@@ -243,7 +243,6 @@ DMA dmam_alloc_noncoherent() dmam_declare_coherent_memory() dmam_free_coherent() - dmam_free_noncoherent() dmam_pool_create() dmam_pool_destroy()drivers/base/dma-mapping.c +0
-20@@ -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)include/linux/dma-mapping.h +0
-2@@ -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,Signature · 1 line
2.11.0
---end quoted text---
Tejun Heo
Acked-byRe: [PATCH 01/11] dma-mapping: remove dmam_free_noncoherent
Quoted 1 line · Christoph Hellwig
Tejun, does this look ok to you?
Sure,
Thanks.
Signature · 1 line
tejun
PATCH 2/11 dma-mapping: replace dmam_alloc_noncoherent with dmam_alloc_attrs
In reply to Christoph Hellwigdmam_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.
--- 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(-)
Documentation/driver-model/devres.txt +1 -1
@@ -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()
drivers/base/dma-mapping.c +16 -20
@@ -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
drivers/video/fbdev/au1200fb.c +3 -2
@@ -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 );
include/linux/dma-mapping.h +3 -2
@@ -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,
Signature · 1 line
2.11.0
Re: [PATCH 02/11] dma-mapping: replace dmam_alloc_noncoherent with dmam_alloc_attrs
Tejun, does this look ok to you?
Quoted 159 lines · Christoph Hellwig
dmam_alloc_noncoherentis a trivial wrapper arounddmam_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 <[email protected]>--- 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(-)Documentation/driver-model/devres.txt +1
-1@@ -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()drivers/base/dma-mapping.c +16
-20@@ -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 drivers/video/fbdev/au1200fb.c +3
-2@@ -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 );include/linux/dma-mapping.h +3
-2@@ -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,Signature · 1 line
2.11.0
---end quoted text---
Tejun Heo
Acked-byRe: [PATCH 02/11] dma-mapping: replace dmam_alloc_noncoherent with dmam_alloc_attrs
Quoted 1 line · Christoph Hellwig
Tejun, does this look ok to you?
Thanks.
Signature · 1 line
tejun
PATCH 3/11 au1100fb: remove a bogus dma_free_nonconsistent call
In reply to Christoph Hellwigau1100fb 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).
--- drivers/video/fbdev/au1100fb.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/video/fbdev/au1100fb.c +0 -4
@@ -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); }
Signature · 1 line
2.11.0
Re: [PATCH 03/11] au1100fb: remove a bogus dma_free_nonconsistent call
Quoted 5 lines · Christoph Hellwig
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 <[email protected]>
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
Re: [PATCH 03/11] au1100fb: remove a bogus dma_free_nonconsistent call
Quoted 8 lines · Bartlomiej Zolnierkiewicz
Quoted 5 lines · Christoph Hellwig
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 <[email protected]>
Are you fine with picking this up through the new dma-mapping tree?
Re: [PATCH 03/11] au1100fb: remove a bogus dma_free_nonconsistent call
Quoted 11 lines · Christoph Hellwig
Quoted 8 lines · Bartlomiej Zolnierkiewicz
Quoted 5 lines · Christoph Hellwig
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 <[email protected]>Are you fine with picking this up through the new dma-mapping tree?
Yes, this is why Ack-ed it.
If you prefer me to merge it through fbdev for 4.13 please let me know.
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
PATCH 4/11 sound/hal2: switch to dma_alloc_attrs
In reply to Christoph HellwigUse dma_alloc_attrs directly instead of the dma_alloc_noncoherent wrapper.
--- sound/mips/hal2.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
sound/mips/hal2.c +10 -10
@@ -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 = {
Signature · 1 line
2.11.0
Re: [alsa-devel] [PATCH 04/11] sound/hal2: switch to dma_alloc_attrs
Quoted 4 lines · Christoph Hellwig
Use
dma_alloc_attrsdirectly instead of thedma_alloc_noncoherentwrapper.Signed-off-by Christoph Hellwig <[email protected]>
Should I take this one through sound git tree, or would you prefer taking all through another?
In the latter case,
thanks,
Takashi
Quoted 53 lines
--- sound/mips/hal2.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)sound/mips/hal2.c +10
-10@@ -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 = {Signature · 6 lines
2.11.0 _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Re: [alsa-devel] [PATCH 04/11] sound/hal2: switch to dma_alloc_attrs
Quoted 9 lines · Takashi Iwai
Quoted 4 lines · Christoph Hellwig
Use
dma_alloc_attrsdirectly instead of thedma_alloc_noncoherentwrapper.Signed-off-by Christoph Hellwig <[email protected]>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.
Re: [alsa-devel] [PATCH 04/11] sound/hal2: switch to dma_alloc_attrs
Quoted 5 lines · Christoph Hellwig
Quoted 3 lines · Takashi Iwai
Quoted 1 line · Christoph Hellwig
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Use
dma_alloc_attrsdirectly instead of thedma_alloc_noncoherentwrapper.Signed-off-by Christoph Hellwig <[email protected]>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
PATCH 5/11 serial/mpsc: switch to dma_alloc_attrs
In reply to Christoph HellwigUse dma_alloc_attrs directly instead of the dma_alloc_noncoherent wrapper.
--- drivers/tty/serial/mpsc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/tty/serial/mpsc.c +6 -4
@@ -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 ; }
Signature · 1 line
2.11.0
PATCH 6/11 sigwd93: switch to dma_alloc_attrs
In reply to Christoph HellwigUse dma_alloc_attrs directly instead of the dma_alloc_noncoherent wrapper.
--- drivers/scsi/sgiwd93.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/scsi/sgiwd93.c +6 -4
@@ -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 ; }
Signature · 1 line
2.11.0
Re: [PATCH 06/11] sigwd93: switch to dma_alloc_attrs
Christoph,
Quoted 2 lines
Use
dma_alloc_attrsdirectly instead of thedma_alloc_noncoherentwrapper.
Fixed driver name typo and applied to 4.13/scsi-queue.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
PATCH 7/11 53c700: switch to dma_alloc_attrs
In reply to Christoph HellwigUse dma_alloc_attrs directly instead of the dma_alloc_noncoherent wrapper.
--- drivers/scsi/53c700.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/scsi/53c700.c +4 -4
@@ -296,8 +296,8 @@ NCR_700_detect(struct scsi_host_template *tpnt,if (tpnt->sdev_attrs ==NULL ) tpnt->sdev_attrs = NCR_700_dev_attrs; - memory =dma_alloc_noncoherent (hostdata->dev,TOTAL_MEM_SIZE , - &pScript,GFP_KERNEL ); + memory =dma_alloc_attrs (hostdata->dev,TOTAL_MEM_SIZE , &pScript, +GFP_KERNEL ,DMA_ATTR_NON_CONSISTENT );if (memory ==NULL ) {printk (KERN_ERR "53c700: Failed to allocate memory for driver, detaching\n" );return NULL ;
@@ -410,8 +410,8 @@ NCR_700_release(struct Scsi_Host *host)struct NCR_700_Host_Parameters *hostdata = (struct NCR_700_Host_Parameters *)host->hostdata[0 ]; -dma_free_noncoherent (hostdata->dev,TOTAL_MEM_SIZE , - hostdata->script, hostdata->pScript); +dma_free_attrs (hostdata->dev,TOTAL_MEM_SIZE , hostdata->script, + hostdata->pScript,DMA_ATTR_NON_CONSISTENT );return 1 ; }
Signature · 1 line
2.11.0
Martin K. Petersen
AppliedRe: [PATCH 07/11] 53c700: switch to dma_alloc_attrs
Christoph,
Quoted 2 lines
Use
dma_alloc_attrsdirectly instead of thedma_alloc_noncoherentwrapper.
Applied to 4.13/scsi-queue.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
PATCH 8/11 sgiseeq: switch to dma_alloc_attrs
In reply to Christoph HellwigUse dma_alloc_attrs directly instead of the dma_alloc_noncoherent wrapper.
--- drivers/net/ethernet/seeq/sgiseeq.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/seeq/sgiseeq.c +4 -4
@@ -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 ;
Signature · 1 line
2.11.0
PATCH 9/11 au1000_eth: switch to dma_alloc_attrs
In reply to Christoph HellwigUse dma_alloc_attrs directly instead of the dma_alloc_noncoherent wrapper.
--- drivers/net/ethernet/amd/au1000_eth.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/net/ethernet/amd/au1000_eth.c +10 -8
@@ -1180,9 +1180,10 @@ static int au1000_probe(struct platform_device *pdev)/* Allocate the data buffers * Snooping works fine with eth on all au1xxx */ - aup->vaddr = (u32 )dma_alloc_noncoherent (NULL ,MAX_BUF_SIZE * - (NUM_TX_BUFFS +NUM_RX_BUFFS ), - &aup->dma_addr,0 ); + aup->vaddr = (u32 )dma_alloc_attrs (NULL ,MAX_BUF_SIZE * + (NUM_TX_BUFFS +NUM_RX_BUFFS ), + &aup->dma_addr,0 , +DMA_ATTR_NON_CONSISTENT );if (!aup->vaddr) {dev_err (&pdev->dev,"failed to allocate data buffers\n" ); err = -ENOMEM ;
@@ -1361,8 +1362,9 @@ static int au1000_probe(struct platform_device *pdev) err_remap2:iounmap (aup->mac); err_remap1: -dma_free_noncoherent (NULL ,MAX_BUF_SIZE * (NUM_TX_BUFFS +NUM_RX_BUFFS ), - (void *)aup->vaddr, aup->dma_addr); +dma_free_attrs (NULL ,MAX_BUF_SIZE * (NUM_TX_BUFFS +NUM_RX_BUFFS ), + (void *)aup->vaddr, aup->dma_addr, +DMA_ATTR_NON_CONSISTENT ); err_vaddr:free_netdev (dev); err_alloc:
@@ -1394,9 +1396,9 @@ static int au1000_remove(struct platform_device *pdev)if (aup->tx_db_inuse[i])au1000_ReleaseDB (aup, aup->tx_db_inuse[i]); -dma_free_noncoherent (NULL ,MAX_BUF_SIZE * - (NUM_TX_BUFFS +NUM_RX_BUFFS ), - (void *)aup->vaddr, aup->dma_addr); +dma_free_attrs (NULL ,MAX_BUF_SIZE * (NUM_TX_BUFFS +NUM_RX_BUFFS ), + (void *)aup->vaddr, aup->dma_addr, +DMA_ATTR_NON_CONSISTENT );iounmap (aup->macdma);iounmap (aup->mac);
Signature · 1 line
2.11.0
PATCH 10/11 i825xx: switch to switch to dma_alloc_attrs
In reply to Christoph HellwigThis way we can always pass DMA_ATTR_NON_CONSISTENT, the SNI mips version will simply ignore the flag.
--- 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(-)
drivers/net/ethernet/i825xx/lasi_82596.c +2 -4
@@ -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 ; }
drivers/net/ethernet/i825xx/lib82596.c +5 -4
@@ -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; }
drivers/net/ethernet/i825xx/sni_82596.c +2 -4
@@ -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);
Signature · 1 line
2.11.0
PATCH 11/11 dma-mapping: remove dma_alloc_noncoherent and dma_free_noncoherent
In reply to Christoph HellwigNo users left, everyone switched to the _attrs versions.
--- 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(-)
Documentation/DMA-API.txt +16 -14
@@ -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.
arch/metag/include/asm/dma-mapping.h +1 -1
@@ -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
arch/nios2/include/asm/dma-mapping.h +1 -1
@@ -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,
arch/tile/include/asm/dma-mapping.h +2 -2
@@ -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)
include/linux/dma-mapping.h +0 -14
@@ -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);
Signature · 1 line
2.11.0
From: Christoph Hellwig
Quoted 5 lines
Sent: 16 June 2017 08:17
For many years we've had the
dma_alloc_attrsAPI that is more flexible thandma_alloc_noncoherent. This series moves the remaining users over to the attrs API.
And most of the callers probably only want to specify 'noncoherent'. Grepping the source for other uses is easier if the wrapper is left.
David