* clean up dma_declare_coherent_memory calling conventions V2 @ 2017-08-26 7:26 Christoph Hellwig 2017-08-26 7:26 ` [PATCH 1/2] dma-coherent: remove the DMA_MEMORY_INCLUDES_CHILDREN flag Christoph Hellwig 2017-08-26 7:26 ` [PATCH 2/2] dma-coherent: remove the DMA_MEMORY_MAP and DMA_MEMORY_IO flags Christoph Hellwig 0 siblings, 2 replies; 8+ messages in thread From: Christoph Hellwig @ 2017-08-26 7:26 UTC (permalink / raw) To: linux-kernel; +Cc: Marek Szyprowski, Robin Murphy Remove various unused flags, and return a reasonable error code. Changes since V1: - rebased - fix an incorrect return value - propagate the error value in ohci-sm501 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] dma-coherent: remove the DMA_MEMORY_INCLUDES_CHILDREN flag 2017-08-26 7:26 clean up dma_declare_coherent_memory calling conventions V2 Christoph Hellwig @ 2017-08-26 7:26 ` Christoph Hellwig 2017-08-26 7:26 ` [PATCH 2/2] dma-coherent: remove the DMA_MEMORY_MAP and DMA_MEMORY_IO flags Christoph Hellwig 1 sibling, 0 replies; 8+ messages in thread From: Christoph Hellwig @ 2017-08-26 7:26 UTC (permalink / raw) To: linux-kernel; +Cc: Marek Szyprowski, Robin Murphy This flag was never implemented or used. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Robin Murphy <robin.murphy@arm.com> --- Documentation/DMA-API.txt | 4 ---- drivers/base/dma-coherent.c | 2 -- drivers/char/virtio_console.c | 3 --- include/linux/dma-mapping.h | 3 +-- 4 files changed, 1 insertion(+), 11 deletions(-) diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt index 45b29326d719..ded50aed1cd8 100644 --- a/Documentation/DMA-API.txt +++ b/Documentation/DMA-API.txt @@ -598,10 +598,6 @@ flags can be ORed together and are: One or both of these flags must be present. -- DMA_MEMORY_INCLUDES_CHILDREN - make the declared memory be allocated by - dma_alloc_coherent of any child devices of this one (for memory residing - on a bridge). - - DMA_MEMORY_EXCLUSIVE - only allocate memory from the declared regions. Do not allow dma_alloc_coherent() to fall back to system memory when it's out of memory in the declared region. diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c index 1c152aed6b82..6f6dc4d41788 100644 --- a/drivers/base/dma-coherent.c +++ b/drivers/base/dma-coherent.c @@ -109,8 +109,6 @@ static int dma_assign_coherent_memory(struct device *dev, return -EBUSY; dev->dma_mem = mem; - /* FIXME: this routine just ignores DMA_MEMORY_INCLUDES_CHILDREN */ - return 0; } diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index ad843eb02ae7..48e86ce9fac8 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -451,9 +451,6 @@ static struct port_buffer *alloc_buf(struct virtqueue *vq, size_t buf_size, * device is created by remoteproc, the DMA memory is * associated with the grandparent device: * vdev => rproc => platform-dev. - * The code here would have been less quirky if - * DMA_MEMORY_INCLUDES_CHILDREN had been supported - * in dma-coherent.c */ if (!vq->vdev->dev.parent || !vq->vdev->dev.parent->parent) goto free_buf; diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 66d8ea68f40b..9b12cb255063 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -710,8 +710,7 @@ static inline int dma_get_cache_alignment(void) /* flags for the coherent memory api */ #define DMA_MEMORY_MAP 0x01 #define DMA_MEMORY_IO 0x02 -#define DMA_MEMORY_INCLUDES_CHILDREN 0x04 -#define DMA_MEMORY_EXCLUSIVE 0x08 +#define DMA_MEMORY_EXCLUSIVE 0x04 #ifdef CONFIG_HAVE_GENERIC_DMA_COHERENT int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr, -- 2.11.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] dma-coherent: remove the DMA_MEMORY_MAP and DMA_MEMORY_IO flags 2017-08-26 7:26 clean up dma_declare_coherent_memory calling conventions V2 Christoph Hellwig 2017-08-26 7:26 ` [PATCH 1/2] dma-coherent: remove the DMA_MEMORY_INCLUDES_CHILDREN flag Christoph Hellwig @ 2017-08-26 7:26 ` Christoph Hellwig 2017-09-01 7:53 ` Christoph Hellwig 2017-09-01 8:19 ` Marek Szyprowski 1 sibling, 2 replies; 8+ messages in thread From: Christoph Hellwig @ 2017-08-26 7:26 UTC (permalink / raw) To: linux-kernel; +Cc: Marek Szyprowski, Robin Murphy DMA_MEMORY_IO was never used in the tree, so remove it. That means there is no need for the DMA_MEMORY_MAP flag either now, so remove it as well and change dma_declare_coherent_memory to return a normal errno value. Signed-off-by: Christoph Hellwig <hch@lst.de> --- Documentation/DMA-API.txt | 21 +--------- arch/arm/mach-imx/mach-imx27_visstrim_m10.c | 43 +++++++------------- arch/arm/mach-imx/mach-mx31moboard.c | 12 +++--- arch/sh/drivers/pci/fixups-dreamcast.c | 3 +- drivers/base/dma-coherent.c | 46 +++++++--------------- drivers/base/dma-mapping.c | 7 +--- .../platform/soc_camera/sh_mobile_ceu_camera.c | 5 +-- drivers/scsi/NCR_Q720.c | 3 +- drivers/usb/host/ohci-sm501.c | 7 ++-- drivers/usb/host/ohci-tmio.c | 9 ++--- include/linux/dma-mapping.h | 6 +-- 11 files changed, 50 insertions(+), 112 deletions(-) diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt index ded50aed1cd8..da58585c7b3a 100644 --- a/Documentation/DMA-API.txt +++ b/Documentation/DMA-API.txt @@ -590,30 +590,11 @@ size is the size of the area (must be multiples of PAGE_SIZE). flags can be ORed together and are: -- DMA_MEMORY_MAP - request that the memory returned from - dma_alloc_coherent() be directly writable. - -- DMA_MEMORY_IO - request that the memory returned from - dma_alloc_coherent() be addressable using read()/write()/memcpy_toio() etc. - -One or both of these flags must be present. - - DMA_MEMORY_EXCLUSIVE - only allocate memory from the declared regions. Do not allow dma_alloc_coherent() to fall back to system memory when it's out of memory in the declared region. -The return value will be either DMA_MEMORY_MAP or DMA_MEMORY_IO and -must correspond to a passed in flag (i.e. no returning DMA_MEMORY_IO -if only DMA_MEMORY_MAP were passed in) for success or zero for -failure. - -Note, for DMA_MEMORY_IO returns, all subsequent memory returned by -dma_alloc_coherent() may no longer be accessed directly, but instead -must be accessed using the correct bus functions. If your driver -isn't prepared to handle this contingency, it should not specify -DMA_MEMORY_IO in the input flags. - -As a simplification for the platforms, only **one** such region of +As a simplification for the platforms, only *one* such region of memory may be declared per device. For reasons of efficiency, most platforms choose to track the declared diff --git a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c index dd75a4756761..c2818af18c55 100644 --- a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c +++ b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c @@ -245,7 +245,6 @@ static phys_addr_t mx2_camera_base __initdata; static void __init visstrim_analog_camera_init(void) { struct platform_device *pdev; - int dma; gpio_set_value(TVP5150_PWDN, 1); ndelay(1); @@ -258,12 +257,9 @@ static void __init visstrim_analog_camera_init(void) if (IS_ERR(pdev)) return; - dma = dma_declare_coherent_memory(&pdev->dev, - mx2_camera_base, mx2_camera_base, - MX2_CAMERA_BUF_SIZE, - DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); - if (!(dma & DMA_MEMORY_MAP)) - return; + dma_declare_coherent_memory(&pdev->dev, mx2_camera_base, + mx2_camera_base, MX2_CAMERA_BUF_SIZE, + DMA_MEMORY_EXCLUSIVE); } static void __init visstrim_reserve(void) @@ -444,16 +440,13 @@ static const struct imx_ssi_platform_data visstrim_m10_ssi_pdata __initconst = { static void __init visstrim_coda_init(void) { struct platform_device *pdev; - int dma; pdev = imx27_add_coda(); - dma = dma_declare_coherent_memory(&pdev->dev, - mx2_camera_base + MX2_CAMERA_BUF_SIZE, - mx2_camera_base + MX2_CAMERA_BUF_SIZE, - MX2_CAMERA_BUF_SIZE, - DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); - if (!(dma & DMA_MEMORY_MAP)) - return; + dma_declare_coherent_memory(&pdev->dev, + mx2_camera_base + MX2_CAMERA_BUF_SIZE, + mx2_camera_base + MX2_CAMERA_BUF_SIZE, + MX2_CAMERA_BUF_SIZE, + DMA_MEMORY_EXCLUSIVE); } /* DMA deinterlace */ @@ -466,24 +459,20 @@ static void __init visstrim_deinterlace_init(void) { int ret = -ENOMEM; struct platform_device *pdev = &visstrim_deinterlace; - int dma; ret = platform_device_register(pdev); - dma = dma_declare_coherent_memory(&pdev->dev, - mx2_camera_base + 2 * MX2_CAMERA_BUF_SIZE, - mx2_camera_base + 2 * MX2_CAMERA_BUF_SIZE, - MX2_CAMERA_BUF_SIZE, - DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); - if (!(dma & DMA_MEMORY_MAP)) - return; + dma_declare_coherent_memory(&pdev->dev, + mx2_camera_base + 2 * MX2_CAMERA_BUF_SIZE, + mx2_camera_base + 2 * MX2_CAMERA_BUF_SIZE, + MX2_CAMERA_BUF_SIZE, + DMA_MEMORY_EXCLUSIVE); } /* Emma-PrP for format conversion */ static void __init visstrim_emmaprp_init(void) { struct platform_device *pdev; - int dma; pdev = imx27_add_mx2_emmaprp(); if (IS_ERR(pdev)) @@ -493,12 +482,10 @@ static void __init visstrim_emmaprp_init(void) * Use the same memory area as the analog camera since both * devices are, by nature, exclusive. */ - dma = dma_declare_coherent_memory(&pdev->dev, + dma_declare_coherent_memory(&pdev->dev, mx2_camera_base, mx2_camera_base, MX2_CAMERA_BUF_SIZE, - DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); - if (!(dma & DMA_MEMORY_MAP)) - pr_err("Failed to declare memory for emmaprp\n"); + DMA_MEMORY_EXCLUSIVE); } /* Audio */ diff --git a/arch/arm/mach-imx/mach-mx31moboard.c b/arch/arm/mach-imx/mach-mx31moboard.c index bde9a9af6714..3cd030960c98 100644 --- a/arch/arm/mach-imx/mach-mx31moboard.c +++ b/arch/arm/mach-imx/mach-mx31moboard.c @@ -475,7 +475,7 @@ static phys_addr_t mx3_camera_base __initdata; static int __init mx31moboard_init_cam(void) { - int dma, ret = -ENOMEM; + int dma, ret; struct platform_device *pdev; imx31_add_ipu_core(); @@ -484,11 +484,11 @@ static int __init mx31moboard_init_cam(void) if (IS_ERR(pdev)) return PTR_ERR(pdev); - dma = dma_declare_coherent_memory(&pdev->dev, - mx3_camera_base, mx3_camera_base, - MX3_CAMERA_BUF_SIZE, - DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); - if (!(dma & DMA_MEMORY_MAP)) + ret = dma_declare_coherent_memory(&pdev->dev, + mx3_camera_base, mx3_camera_base, + MX3_CAMERA_BUF_SIZE, + DMA_MEMORY_EXCLUSIVE); + if (ret) goto err; ret = platform_device_add(pdev); diff --git a/arch/sh/drivers/pci/fixups-dreamcast.c b/arch/sh/drivers/pci/fixups-dreamcast.c index 1d1c5a227e50..c931d5872ffe 100644 --- a/arch/sh/drivers/pci/fixups-dreamcast.c +++ b/arch/sh/drivers/pci/fixups-dreamcast.c @@ -63,11 +63,10 @@ static void gapspci_fixup_resources(struct pci_dev *dev) res.end = GAPSPCI_DMA_BASE + GAPSPCI_DMA_SIZE - 1; res.flags = IORESOURCE_MEM; pcibios_resource_to_bus(dev->bus, ®ion, &res); - BUG_ON(!dma_declare_coherent_memory(&dev->dev, + BUG_ON(dma_declare_coherent_memory(&dev->dev, res.start, region.start, resource_size(&res), - DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE)); break; default: diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c index 6f6dc4d41788..b275eeb739f1 100644 --- a/drivers/base/dma-coherent.c +++ b/drivers/base/dma-coherent.c @@ -46,15 +46,10 @@ static bool dma_init_coherent_memory( int pages = size >> PAGE_SHIFT; int bitmap_size = BITS_TO_LONGS(pages) * sizeof(long); - if ((flags & (DMA_MEMORY_MAP | DMA_MEMORY_IO)) == 0) - goto out; if (!size) goto out; - if (flags & DMA_MEMORY_MAP) - mem_base = memremap(phys_addr, size, MEMREMAP_WC); - else - mem_base = ioremap(phys_addr, size); + mem_base = memremap(phys_addr, size, MEMREMAP_WC); if (!mem_base) goto out; @@ -77,12 +72,8 @@ static bool dma_init_coherent_memory( out: kfree(dma_mem); - if (mem_base) { - if (flags & DMA_MEMORY_MAP) - memunmap(mem_base); - else - iounmap(mem_base); - } + if (mem_base) + memunmap(mem_base); return false; } @@ -91,10 +82,7 @@ static void dma_release_coherent_memory(struct dma_coherent_mem *mem) if (!mem) return; - if (mem->flags & DMA_MEMORY_MAP) - memunmap(mem->virt_base); - else - iounmap(mem->virt_base); + memunmap(mem->virt_base); kfree(mem->bitmap); kfree(mem); } @@ -116,16 +104,16 @@ int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr, dma_addr_t device_addr, size_t size, int flags) { struct dma_coherent_mem *mem; + int ret; - if (!dma_init_coherent_memory(phys_addr, device_addr, size, flags, - &mem)) - return 0; - - if (dma_assign_coherent_memory(dev, mem) == 0) - return flags & DMA_MEMORY_MAP ? DMA_MEMORY_MAP : DMA_MEMORY_IO; + ret = dma_init_coherent_memory(phys_addr, device_addr, size, flags, &mem); + if (ret) + return ret; - dma_release_coherent_memory(mem); - return 0; + ret = dma_assign_coherent_memory(dev, mem); + if (ret) + dma_release_coherent_memory(mem); + return ret; } EXPORT_SYMBOL(dma_declare_coherent_memory); @@ -186,15 +174,9 @@ static void *__dma_alloc_from_coherent(struct dma_coherent_mem *mem, */ *dma_handle = mem->device_base + (pageno << PAGE_SHIFT); ret = mem->virt_base + (pageno << PAGE_SHIFT); - dma_memory_map = (mem->flags & DMA_MEMORY_MAP); spin_unlock_irqrestore(&mem->spinlock, flags); - if (dma_memory_map) - memset(ret, 0, size); - else - memset_io(ret, 0, size); - + memset(ret, 0, size); return ret; - err: spin_unlock_irqrestore(&mem->spinlock, flags); return NULL; @@ -360,7 +342,7 @@ static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev) if (!mem && !dma_init_coherent_memory(rmem->base, rmem->base, rmem->size, - DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE, + DMA_MEMORY_EXCLUSIVE, &mem)) { pr_err("Reserved memory: failed to init DMA memory pool at %pa, size %ld MiB\n", &rmem->base, (unsigned long)rmem->size / SZ_1M); diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c index b555ff9dd8fc..e584eddef0a7 100644 --- a/drivers/base/dma-mapping.c +++ b/drivers/base/dma-mapping.c @@ -176,13 +176,10 @@ int dmam_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr, rc = dma_declare_coherent_memory(dev, phys_addr, device_addr, size, flags); - if (rc) { + if (!rc) devres_add(dev, res); - rc = 0; - } else { + else devres_free(res); - rc = -ENOMEM; - } return rc; } diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c index 96dc01750bc0..36762ec954e7 100644 --- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c +++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c @@ -1708,11 +1708,10 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev) err = dma_declare_coherent_memory(&pdev->dev, res->start, res->start, resource_size(res), - DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); - if (!err) { + if (err) { dev_err(&pdev->dev, "Unable to declare CEU memory.\n"); - return -ENXIO; + return err; } pcdev->video_limit = resource_size(res); diff --git a/drivers/scsi/NCR_Q720.c b/drivers/scsi/NCR_Q720.c index 05835bf1bf9c..54e7d26908ee 100644 --- a/drivers/scsi/NCR_Q720.c +++ b/drivers/scsi/NCR_Q720.c @@ -217,8 +217,7 @@ NCR_Q720_probe(struct device *dev) } if (dma_declare_coherent_memory(dev, base_addr, base_addr, - mem_size, DMA_MEMORY_MAP) - != DMA_MEMORY_MAP) { + mem_size, 0)) { printk(KERN_ERR "NCR_Q720: DMA declare memory failed\n"); goto out_release_region; } diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c index a8b8d8b8d9f3..d4e0f7cd96fa 100644 --- a/drivers/usb/host/ohci-sm501.c +++ b/drivers/usb/host/ohci-sm501.c @@ -123,13 +123,12 @@ static int ohci_hcd_sm501_drv_probe(struct platform_device *pdev) * regular memory. The HCD_LOCAL_MEM flag does just that. */ - if (!dma_declare_coherent_memory(dev, mem->start, + retval = dma_declare_coherent_memory(dev, mem->start, mem->start - mem->parent->start, resource_size(mem), - DMA_MEMORY_MAP | - DMA_MEMORY_EXCLUSIVE)) { + DMA_MEMORY_EXCLUSIVE); + if (retval) { dev_err(dev, "cannot declare coherent memory\n"); - retval = -ENXIO; goto err1; } diff --git a/drivers/usb/host/ohci-tmio.c b/drivers/usb/host/ohci-tmio.c index cfcfadfc94fc..16d081a093bb 100644 --- a/drivers/usb/host/ohci-tmio.c +++ b/drivers/usb/host/ohci-tmio.c @@ -227,13 +227,10 @@ static int ohci_hcd_tmio_drv_probe(struct platform_device *dev) goto err_ioremap_regs; } - if (!dma_declare_coherent_memory(&dev->dev, sram->start, - sram->start, - resource_size(sram), - DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE)) { - ret = -EBUSY; + ret = dma_declare_coherent_memory(&dev->dev, sram->start, sram->start, + resource_size(sram), DMA_MEMORY_EXCLUSIVE); + if (ret) goto err_dma_declare; - } if (cell->enable) { ret = cell->enable(dev); diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 9b12cb255063..92f7d84e51f5 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -708,9 +708,7 @@ static inline int dma_get_cache_alignment(void) #endif /* flags for the coherent memory api */ -#define DMA_MEMORY_MAP 0x01 -#define DMA_MEMORY_IO 0x02 -#define DMA_MEMORY_EXCLUSIVE 0x04 +#define DMA_MEMORY_EXCLUSIVE 0x01 #ifdef CONFIG_HAVE_GENERIC_DMA_COHERENT int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr, @@ -723,7 +721,7 @@ static inline int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr, dma_addr_t device_addr, size_t size, int flags) { - return 0; + return -EINVAL; } static inline void -- 2.11.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] dma-coherent: remove the DMA_MEMORY_MAP and DMA_MEMORY_IO flags 2017-08-26 7:26 ` [PATCH 2/2] dma-coherent: remove the DMA_MEMORY_MAP and DMA_MEMORY_IO flags Christoph Hellwig @ 2017-09-01 7:53 ` Christoph Hellwig 2017-09-01 8:19 ` Marek Szyprowski 1 sibling, 0 replies; 8+ messages in thread From: Christoph Hellwig @ 2017-09-01 7:53 UTC (permalink / raw) To: linux-kernel; +Cc: Marek Szyprowski, Robin Murphy Can I get a review for this one? ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] dma-coherent: remove the DMA_MEMORY_MAP and DMA_MEMORY_IO flags 2017-08-26 7:26 ` [PATCH 2/2] dma-coherent: remove the DMA_MEMORY_MAP and DMA_MEMORY_IO flags Christoph Hellwig 2017-09-01 7:53 ` Christoph Hellwig @ 2017-09-01 8:19 ` Marek Szyprowski 2017-09-01 9:37 ` Christoph Hellwig 1 sibling, 1 reply; 8+ messages in thread From: Marek Szyprowski @ 2017-09-01 8:19 UTC (permalink / raw) To: Christoph Hellwig, linux-kernel; +Cc: Robin Murphy Hi Christoph, On 2017-08-26 09:26, Christoph Hellwig wrote: > DMA_MEMORY_IO was never used in the tree, so remove it. That means there is > no need for the DMA_MEMORY_MAP flag either now, so remove it as well and > change dma_declare_coherent_memory to return a normal errno value. > > Signed-off-by: Christoph Hellwig <hch@lst.de> There are 2 minor issues, besides that: Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com> > --- > Documentation/DMA-API.txt | 21 +--------- > arch/arm/mach-imx/mach-imx27_visstrim_m10.c | 43 +++++++------------- > arch/arm/mach-imx/mach-mx31moboard.c | 12 +++--- > arch/sh/drivers/pci/fixups-dreamcast.c | 3 +- > drivers/base/dma-coherent.c | 46 +++++++--------------- > drivers/base/dma-mapping.c | 7 +--- > .../platform/soc_camera/sh_mobile_ceu_camera.c | 5 +-- > drivers/scsi/NCR_Q720.c | 3 +- > drivers/usb/host/ohci-sm501.c | 7 ++-- > drivers/usb/host/ohci-tmio.c | 9 ++--- > include/linux/dma-mapping.h | 6 +-- > 11 files changed, 50 insertions(+), 112 deletions(-) > > diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt > index ded50aed1cd8..da58585c7b3a 100644 > --- a/Documentation/DMA-API.txt > +++ b/Documentation/DMA-API.txt > @@ -590,30 +590,11 @@ size is the size of the area (must be multiples of PAGE_SIZE). > > flags can be ORed together and are: > > -- DMA_MEMORY_MAP - request that the memory returned from > - dma_alloc_coherent() be directly writable. > - > -- DMA_MEMORY_IO - request that the memory returned from > - dma_alloc_coherent() be addressable using read()/write()/memcpy_toio() etc. > - > -One or both of these flags must be present. > - > - DMA_MEMORY_EXCLUSIVE - only allocate memory from the declared regions. > Do not allow dma_alloc_coherent() to fall back to system memory when > it's out of memory in the declared region. > > -The return value will be either DMA_MEMORY_MAP or DMA_MEMORY_IO and > -must correspond to a passed in flag (i.e. no returning DMA_MEMORY_IO > -if only DMA_MEMORY_MAP were passed in) for success or zero for > -failure. > - > -Note, for DMA_MEMORY_IO returns, all subsequent memory returned by > -dma_alloc_coherent() may no longer be accessed directly, but instead > -must be accessed using the correct bus functions. If your driver > -isn't prepared to handle this contingency, it should not specify > -DMA_MEMORY_IO in the input flags. > - > -As a simplification for the platforms, only **one** such region of > +As a simplification for the platforms, only *one* such region of > memory may be declared per device. > > For reasons of efficiency, most platforms choose to track the declared > diff --git a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c > index dd75a4756761..c2818af18c55 100644 > --- a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c > +++ b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c > @@ -245,7 +245,6 @@ static phys_addr_t mx2_camera_base __initdata; > static void __init visstrim_analog_camera_init(void) > { > struct platform_device *pdev; > - int dma; > > gpio_set_value(TVP5150_PWDN, 1); > ndelay(1); > @@ -258,12 +257,9 @@ static void __init visstrim_analog_camera_init(void) > if (IS_ERR(pdev)) > return; > > - dma = dma_declare_coherent_memory(&pdev->dev, > - mx2_camera_base, mx2_camera_base, > - MX2_CAMERA_BUF_SIZE, > - DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); > - if (!(dma & DMA_MEMORY_MAP)) > - return; > + dma_declare_coherent_memory(&pdev->dev, mx2_camera_base, > + mx2_camera_base, MX2_CAMERA_BUF_SIZE, > + DMA_MEMORY_EXCLUSIVE); > } > > static void __init visstrim_reserve(void) > @@ -444,16 +440,13 @@ static const struct imx_ssi_platform_data visstrim_m10_ssi_pdata __initconst = { > static void __init visstrim_coda_init(void) > { > struct platform_device *pdev; > - int dma; > > pdev = imx27_add_coda(); > - dma = dma_declare_coherent_memory(&pdev->dev, > - mx2_camera_base + MX2_CAMERA_BUF_SIZE, > - mx2_camera_base + MX2_CAMERA_BUF_SIZE, > - MX2_CAMERA_BUF_SIZE, > - DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); > - if (!(dma & DMA_MEMORY_MAP)) > - return; > + dma_declare_coherent_memory(&pdev->dev, > + mx2_camera_base + MX2_CAMERA_BUF_SIZE, > + mx2_camera_base + MX2_CAMERA_BUF_SIZE, > + MX2_CAMERA_BUF_SIZE, > + DMA_MEMORY_EXCLUSIVE); > } > > /* DMA deinterlace */ > @@ -466,24 +459,20 @@ static void __init visstrim_deinterlace_init(void) > { > int ret = -ENOMEM; > struct platform_device *pdev = &visstrim_deinterlace; > - int dma; > > ret = platform_device_register(pdev); > > - dma = dma_declare_coherent_memory(&pdev->dev, > - mx2_camera_base + 2 * MX2_CAMERA_BUF_SIZE, > - mx2_camera_base + 2 * MX2_CAMERA_BUF_SIZE, > - MX2_CAMERA_BUF_SIZE, > - DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); > - if (!(dma & DMA_MEMORY_MAP)) > - return; > + dma_declare_coherent_memory(&pdev->dev, > + mx2_camera_base + 2 * MX2_CAMERA_BUF_SIZE, > + mx2_camera_base + 2 * MX2_CAMERA_BUF_SIZE, > + MX2_CAMERA_BUF_SIZE, > + DMA_MEMORY_EXCLUSIVE); > } > > /* Emma-PrP for format conversion */ > static void __init visstrim_emmaprp_init(void) > { > struct platform_device *pdev; > - int dma; > > pdev = imx27_add_mx2_emmaprp(); > if (IS_ERR(pdev)) > @@ -493,12 +482,10 @@ static void __init visstrim_emmaprp_init(void) > * Use the same memory area as the analog camera since both > * devices are, by nature, exclusive. > */ > - dma = dma_declare_coherent_memory(&pdev->dev, > + dma_declare_coherent_memory(&pdev->dev, > mx2_camera_base, mx2_camera_base, > MX2_CAMERA_BUF_SIZE, > - DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); > - if (!(dma & DMA_MEMORY_MAP)) > - pr_err("Failed to declare memory for emmaprp\n"); > + DMA_MEMORY_EXCLUSIVE); Can we keep error message? It might be useful in case of any problems, because the return value is not propagated otherwise. > > [...] > diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h > index 9b12cb255063..92f7d84e51f5 100644 > --- a/include/linux/dma-mapping.h > +++ b/include/linux/dma-mapping.h > @@ -708,9 +708,7 @@ static inline int dma_get_cache_alignment(void) > #endif > > /* flags for the coherent memory api */ > -#define DMA_MEMORY_MAP 0x01 > -#define DMA_MEMORY_IO 0x02 > -#define DMA_MEMORY_EXCLUSIVE 0x04 > +#define DMA_MEMORY_EXCLUSIVE 0x01 > > #ifdef CONFIG_HAVE_GENERIC_DMA_COHERENT > int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr, > @@ -723,7 +721,7 @@ static inline int > dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr, > dma_addr_t device_addr, size_t size, int flags) > { > - return 0; > + return -EINVAL; ENOSYS ? > } > > static inline void Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] dma-coherent: remove the DMA_MEMORY_MAP and DMA_MEMORY_IO flags 2017-09-01 8:19 ` Marek Szyprowski @ 2017-09-01 9:37 ` Christoph Hellwig 0 siblings, 0 replies; 8+ messages in thread From: Christoph Hellwig @ 2017-09-01 9:37 UTC (permalink / raw) To: Marek Szyprowski; +Cc: Christoph Hellwig, linux-kernel, Robin Murphy Hi Marek, thanks for the review. I'll fix those two issues up. ^ permalink raw reply [flat|nested] 8+ messages in thread
* clean up dma_declare_coherent_memory calling conventions @ 2017-06-27 20:17 Christoph Hellwig 2017-06-27 20:17 ` [PATCH 1/2] dma-coherent: remove the DMA_MEMORY_INCLUDES_CHILDREN flag Christoph Hellwig 0 siblings, 1 reply; 8+ messages in thread From: Christoph Hellwig @ 2017-06-27 20:17 UTC (permalink / raw) To: linux-kernel, m.szyprowski, robin.murphy Remove various unused flags, and return a reasonable error code. ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] dma-coherent: remove the DMA_MEMORY_INCLUDES_CHILDREN flag 2017-06-27 20:17 clean up dma_declare_coherent_memory calling conventions Christoph Hellwig @ 2017-06-27 20:17 ` Christoph Hellwig 2017-06-28 14:34 ` Robin Murphy 0 siblings, 1 reply; 8+ messages in thread From: Christoph Hellwig @ 2017-06-27 20:17 UTC (permalink / raw) To: linux-kernel, m.szyprowski, robin.murphy This flag was never implemented or used. Signed-off-by: Christoph Hellwig <hch@lst.de> --- Documentation/DMA-API.txt | 4 ---- drivers/base/dma-coherent.c | 2 -- drivers/char/virtio_console.c | 3 --- include/linux/dma-mapping.h | 3 +-- 4 files changed, 1 insertion(+), 11 deletions(-) diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt index 6b20128fab8a..03072bc7ff74 100644 --- a/Documentation/DMA-API.txt +++ b/Documentation/DMA-API.txt @@ -524,10 +524,6 @@ dma_alloc_coherent() be addressable using read()/write()/memcpy_toio() etc. One or both of these flags must be present. -DMA_MEMORY_INCLUDES_CHILDREN - make the declared memory be allocated by -dma_alloc_coherent of any child devices of this one (for memory residing -on a bridge). - DMA_MEMORY_EXCLUSIVE - only allocate memory from the declared regions. Do not allow dma_alloc_coherent() to fall back to system memory when it's out of memory in the declared region. diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c index 2ae24c28e70c..e70e33d5c902 100644 --- a/drivers/base/dma-coherent.c +++ b/drivers/base/dma-coherent.c @@ -109,8 +109,6 @@ static int dma_assign_coherent_memory(struct device *dev, return -EBUSY; dev->dma_mem = mem; - /* FIXME: this routine just ignores DMA_MEMORY_INCLUDES_CHILDREN */ - return 0; } diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index ad843eb02ae7..48e86ce9fac8 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -451,9 +451,6 @@ static struct port_buffer *alloc_buf(struct virtqueue *vq, size_t buf_size, * device is created by remoteproc, the DMA memory is * associated with the grandparent device: * vdev => rproc => platform-dev. - * The code here would have been less quirky if - * DMA_MEMORY_INCLUDES_CHILDREN had been supported - * in dma-coherent.c */ if (!vq->vdev->dev.parent || !vq->vdev->dev.parent->parent) goto free_buf; diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 843ab866e0f4..fb66fe98e61d 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -685,8 +685,7 @@ static inline int dma_get_cache_alignment(void) /* flags for the coherent memory api */ #define DMA_MEMORY_MAP 0x01 #define DMA_MEMORY_IO 0x02 -#define DMA_MEMORY_INCLUDES_CHILDREN 0x04 -#define DMA_MEMORY_EXCLUSIVE 0x08 +#define DMA_MEMORY_EXCLUSIVE 0x04 #ifdef CONFIG_HAVE_GENERIC_DMA_COHERENT int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr, -- 2.11.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] dma-coherent: remove the DMA_MEMORY_INCLUDES_CHILDREN flag 2017-06-27 20:17 ` [PATCH 1/2] dma-coherent: remove the DMA_MEMORY_INCLUDES_CHILDREN flag Christoph Hellwig @ 2017-06-28 14:34 ` Robin Murphy 0 siblings, 0 replies; 8+ messages in thread From: Robin Murphy @ 2017-06-28 14:34 UTC (permalink / raw) To: Christoph Hellwig, linux-kernel, m.szyprowski On 27/06/17 21:17, Christoph Hellwig wrote: > This flag was never implemented or used. And at worst, we can always bring it back. Reviewed-by: Robin Murphy <robin.murphy@arm.com> > Signed-off-by: Christoph Hellwig <hch@lst.de> > --- > Documentation/DMA-API.txt | 4 ---- > drivers/base/dma-coherent.c | 2 -- > drivers/char/virtio_console.c | 3 --- > include/linux/dma-mapping.h | 3 +-- > 4 files changed, 1 insertion(+), 11 deletions(-) > > diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt > index 6b20128fab8a..03072bc7ff74 100644 > --- a/Documentation/DMA-API.txt > +++ b/Documentation/DMA-API.txt > @@ -524,10 +524,6 @@ dma_alloc_coherent() be addressable using read()/write()/memcpy_toio() etc. > > One or both of these flags must be present. > > -DMA_MEMORY_INCLUDES_CHILDREN - make the declared memory be allocated by > -dma_alloc_coherent of any child devices of this one (for memory residing > -on a bridge). > - > DMA_MEMORY_EXCLUSIVE - only allocate memory from the declared regions. > Do not allow dma_alloc_coherent() to fall back to system memory when > it's out of memory in the declared region. > diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c > index 2ae24c28e70c..e70e33d5c902 100644 > --- a/drivers/base/dma-coherent.c > +++ b/drivers/base/dma-coherent.c > @@ -109,8 +109,6 @@ static int dma_assign_coherent_memory(struct device *dev, > return -EBUSY; > > dev->dma_mem = mem; > - /* FIXME: this routine just ignores DMA_MEMORY_INCLUDES_CHILDREN */ > - > return 0; > } > > diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c > index ad843eb02ae7..48e86ce9fac8 100644 > --- a/drivers/char/virtio_console.c > +++ b/drivers/char/virtio_console.c > @@ -451,9 +451,6 @@ static struct port_buffer *alloc_buf(struct virtqueue *vq, size_t buf_size, > * device is created by remoteproc, the DMA memory is > * associated with the grandparent device: > * vdev => rproc => platform-dev. > - * The code here would have been less quirky if > - * DMA_MEMORY_INCLUDES_CHILDREN had been supported > - * in dma-coherent.c > */ > if (!vq->vdev->dev.parent || !vq->vdev->dev.parent->parent) > goto free_buf; > diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h > index 843ab866e0f4..fb66fe98e61d 100644 > --- a/include/linux/dma-mapping.h > +++ b/include/linux/dma-mapping.h > @@ -685,8 +685,7 @@ static inline int dma_get_cache_alignment(void) > /* flags for the coherent memory api */ > #define DMA_MEMORY_MAP 0x01 > #define DMA_MEMORY_IO 0x02 > -#define DMA_MEMORY_INCLUDES_CHILDREN 0x04 > -#define DMA_MEMORY_EXCLUSIVE 0x08 > +#define DMA_MEMORY_EXCLUSIVE 0x04 > > #ifdef CONFIG_HAVE_GENERIC_DMA_COHERENT > int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr, > ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-09-01 9:37 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-08-26 7:26 clean up dma_declare_coherent_memory calling conventions V2 Christoph Hellwig 2017-08-26 7:26 ` [PATCH 1/2] dma-coherent: remove the DMA_MEMORY_INCLUDES_CHILDREN flag Christoph Hellwig 2017-08-26 7:26 ` [PATCH 2/2] dma-coherent: remove the DMA_MEMORY_MAP and DMA_MEMORY_IO flags Christoph Hellwig 2017-09-01 7:53 ` Christoph Hellwig 2017-09-01 8:19 ` Marek Szyprowski 2017-09-01 9:37 ` Christoph Hellwig -- strict thread matches above, loose matches on Subject: below -- 2017-06-27 20:17 clean up dma_declare_coherent_memory calling conventions Christoph Hellwig 2017-06-27 20:17 ` [PATCH 1/2] dma-coherent: remove the DMA_MEMORY_INCLUDES_CHILDREN flag Christoph Hellwig 2017-06-28 14:34 ` Robin Murphy
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).