Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 52269718 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'dma-mapping-4.14' of git://git.infradead.org/users/hch/dma-mapping

Pull dma-mapping updates from Christoph Hellwig:

 - removal of the old dma_alloc_noncoherent interface

 - remove unused flags to dma_declare_coherent_memory

 - restrict OF DMA configuration to specific physical busses

 - use the iommu mailing list for dma-mapping questions and patches

* tag 'dma-mapping-4.14' of git://git.infradead.org/users/hch/dma-mapping:
  dma-coherent: fix dma_declare_coherent_memory() logic error
  ARM: imx: mx31moboard: Remove unused 'dma' variable
  dma-coherent: remove an unused variable
  MAINTAINERS: use the iommu list for the dma-mapping subsystem
  dma-coherent: remove the DMA_MEMORY_MAP and DMA_MEMORY_IO flags
  dma-coherent: remove the DMA_MEMORY_INCLUDES_CHILDREN flag
  of: restrict DMA configuration
  dma-mapping: remove dma_alloc_noncoherent and dma_free_noncoherent
  i825xx: switch to switch to dma_alloc_attrs
  au1000_eth: switch to dma_alloc_attrs
  sgiseeq: switch to dma_alloc_attrs
  dma-mapping: reduce dma_mapping_error inline bloat
parents ae71948f d35b0996
Loading
Loading
Loading
Loading
+17 −38
Original line number Diff line number Diff line
@@ -515,14 +515,15 @@ 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.
@@ -535,12 +536,13 @@ 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().

::

@@ -564,8 +566,8 @@ memory or doing partial flushes.
	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.

@@ -590,34 +592,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_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.

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
+1 −1
Original line number Diff line number Diff line
@@ -4219,7 +4219,7 @@ DMA MAPPING HELPERS
M:	Christoph Hellwig <hch@lst.de>
M:	Marek Szyprowski <m.szyprowski@samsung.com>
R:	Robin Murphy <robin.murphy@arm.com>
L:	linux-kernel@vger.kernel.org
L:	iommu@lists.linux-foundation.org
T:	git git://git.infradead.org/users/hch/dma-mapping.git
W:	http://git.infradead.org/users/hch/dma-mapping.git
S:	Supported
+17 −27
Original line number Diff line number Diff line
@@ -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,
	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_MEMORY_EXCLUSIVE);
}

/* DMA deinterlace */
@@ -466,24 +459,21 @@ 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,
	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_MEMORY_EXCLUSIVE);
}

/* Emma-PrP for format conversion */
static void __init visstrim_emmaprp_init(void)
{
	struct platform_device *pdev;
	int dma;
	int ret;

	pdev = imx27_add_mx2_emmaprp();
	if (IS_ERR(pdev))
@@ -493,11 +483,11 @@ 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,
	ret = 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))
				DMA_MEMORY_EXCLUSIVE);
	if (ret)
		pr_err("Failed to declare memory for emmaprp\n");
}

+6 −6
Original line number Diff line number Diff line
@@ -475,7 +475,7 @@ static phys_addr_t mx3_camera_base __initdata;

static int __init mx31moboard_init_cam(void)
{
	int dma, ret = -ENOMEM;
	int 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,
	ret = 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))
					  DMA_MEMORY_EXCLUSIVE);
	if (ret)
		goto err;

	ret = platform_device_add(pdev);
+1 −1
Original line number Diff line number Diff line
@@ -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
Loading