Skip to content

Commit 5226971

Browse files
committed
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
2 parents ae71948 + d35b099 commit 5226971

File tree

22 files changed

+156
-210
lines changed

22 files changed

+156
-210
lines changed

Documentation/DMA-API.txt

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -515,14 +515,15 @@ API at all.
515515
::
516516

517517
void *
518-
dma_alloc_noncoherent(struct device *dev, size_t size,
519-
dma_addr_t *dma_handle, gfp_t flag)
518+
dma_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle,
519+
gfp_t flag, unsigned long attrs)
520520

521-
Identical to dma_alloc_coherent() except that the platform will
522-
choose to return either consistent or non-consistent memory as it sees
523-
fit. By using this API, you are guaranteeing to the platform that you
524-
have all the correct and necessary sync points for this memory in the
525-
driver should it choose to return non-consistent memory.
521+
Identical to dma_alloc_coherent() except that when the
522+
DMA_ATTR_NON_CONSISTENT flags is passed in the attrs argument, the
523+
platform will choose to return either consistent or non-consistent memory
524+
as it sees fit. By using this API, you are guaranteeing to the platform
525+
that you have all the correct and necessary sync points for this memory
526+
in the driver should it choose to return non-consistent memory.
526527

527528
Note: where the platform can return consistent memory, it will
528529
guarantee that the sync points become nops.
@@ -535,12 +536,13 @@ that simply cannot make consistent memory.
535536
::
536537

537538
void
538-
dma_free_noncoherent(struct device *dev, size_t size, void *cpu_addr,
539-
dma_addr_t dma_handle)
539+
dma_free_attrs(struct device *dev, size_t size, void *cpu_addr,
540+
dma_addr_t dma_handle, unsigned long attrs)
540541

541-
Free memory allocated by the nonconsistent API. All parameters must
542-
be identical to those passed in (and returned by
543-
dma_alloc_noncoherent()).
542+
Free memory allocated by the dma_alloc_attrs(). All parameters common
543+
parameters must identical to those otherwise passed to dma_fre_coherent,
544+
and the attrs argument must be identical to the attrs passed to
545+
dma_alloc_attrs().
544546

545547
::
546548

@@ -564,8 +566,8 @@ memory or doing partial flushes.
564566
dma_cache_sync(struct device *dev, void *vaddr, size_t size,
565567
enum dma_data_direction direction)
566568

567-
Do a partial sync of memory that was allocated by
568-
dma_alloc_noncoherent(), starting at virtual address vaddr and
569+
Do a partial sync of memory that was allocated by dma_alloc_attrs() with
570+
the DMA_ATTR_NON_CONSISTENT flag starting at virtual address vaddr and
569571
continuing on for size. Again, you *must* observe the cache line
570572
boundaries when doing this.
571573

@@ -590,34 +592,11 @@ size is the size of the area (must be multiples of PAGE_SIZE).
590592

591593
flags can be ORed together and are:
592594

593-
- DMA_MEMORY_MAP - request that the memory returned from
594-
dma_alloc_coherent() be directly writable.
595-
596-
- DMA_MEMORY_IO - request that the memory returned from
597-
dma_alloc_coherent() be addressable using read()/write()/memcpy_toio() etc.
598-
599-
One or both of these flags must be present.
600-
601-
- DMA_MEMORY_INCLUDES_CHILDREN - make the declared memory be allocated by
602-
dma_alloc_coherent of any child devices of this one (for memory residing
603-
on a bridge).
604-
605595
- DMA_MEMORY_EXCLUSIVE - only allocate memory from the declared regions.
606596
Do not allow dma_alloc_coherent() to fall back to system memory when
607597
it's out of memory in the declared region.
608598

609-
The return value will be either DMA_MEMORY_MAP or DMA_MEMORY_IO and
610-
must correspond to a passed in flag (i.e. no returning DMA_MEMORY_IO
611-
if only DMA_MEMORY_MAP were passed in) for success or zero for
612-
failure.
613-
614-
Note, for DMA_MEMORY_IO returns, all subsequent memory returned by
615-
dma_alloc_coherent() may no longer be accessed directly, but instead
616-
must be accessed using the correct bus functions. If your driver
617-
isn't prepared to handle this contingency, it should not specify
618-
DMA_MEMORY_IO in the input flags.
619-
620-
As a simplification for the platforms, only **one** such region of
599+
As a simplification for the platforms, only *one* such region of
621600
memory may be declared per device.
622601

623602
For reasons of efficiency, most platforms choose to track the declared

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4219,7 +4219,7 @@ DMA MAPPING HELPERS
42194219
M: Christoph Hellwig <[email protected]>
42204220
M: Marek Szyprowski <[email protected]>
42214221
R: Robin Murphy <[email protected]>
4222-
4222+
42234223
T: git git://git.infradead.org/users/hch/dma-mapping.git
42244224
W: http://git.infradead.org/users/hch/dma-mapping.git
42254225
S: Supported

arch/arm/mach-imx/mach-imx27_visstrim_m10.c

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ static phys_addr_t mx2_camera_base __initdata;
245245
static void __init visstrim_analog_camera_init(void)
246246
{
247247
struct platform_device *pdev;
248-
int dma;
249248

250249
gpio_set_value(TVP5150_PWDN, 1);
251250
ndelay(1);
@@ -258,12 +257,9 @@ static void __init visstrim_analog_camera_init(void)
258257
if (IS_ERR(pdev))
259258
return;
260259

261-
dma = dma_declare_coherent_memory(&pdev->dev,
262-
mx2_camera_base, mx2_camera_base,
263-
MX2_CAMERA_BUF_SIZE,
264-
DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE);
265-
if (!(dma & DMA_MEMORY_MAP))
266-
return;
260+
dma_declare_coherent_memory(&pdev->dev, mx2_camera_base,
261+
mx2_camera_base, MX2_CAMERA_BUF_SIZE,
262+
DMA_MEMORY_EXCLUSIVE);
267263
}
268264

269265
static void __init visstrim_reserve(void)
@@ -444,16 +440,13 @@ static const struct imx_ssi_platform_data visstrim_m10_ssi_pdata __initconst = {
444440
static void __init visstrim_coda_init(void)
445441
{
446442
struct platform_device *pdev;
447-
int dma;
448443

449444
pdev = imx27_add_coda();
450-
dma = dma_declare_coherent_memory(&pdev->dev,
451-
mx2_camera_base + MX2_CAMERA_BUF_SIZE,
452-
mx2_camera_base + MX2_CAMERA_BUF_SIZE,
453-
MX2_CAMERA_BUF_SIZE,
454-
DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE);
455-
if (!(dma & DMA_MEMORY_MAP))
456-
return;
445+
dma_declare_coherent_memory(&pdev->dev,
446+
mx2_camera_base + MX2_CAMERA_BUF_SIZE,
447+
mx2_camera_base + MX2_CAMERA_BUF_SIZE,
448+
MX2_CAMERA_BUF_SIZE,
449+
DMA_MEMORY_EXCLUSIVE);
457450
}
458451

459452
/* DMA deinterlace */
@@ -466,24 +459,21 @@ static void __init visstrim_deinterlace_init(void)
466459
{
467460
int ret = -ENOMEM;
468461
struct platform_device *pdev = &visstrim_deinterlace;
469-
int dma;
470462

471463
ret = platform_device_register(pdev);
472464

473-
dma = dma_declare_coherent_memory(&pdev->dev,
474-
mx2_camera_base + 2 * MX2_CAMERA_BUF_SIZE,
475-
mx2_camera_base + 2 * MX2_CAMERA_BUF_SIZE,
476-
MX2_CAMERA_BUF_SIZE,
477-
DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE);
478-
if (!(dma & DMA_MEMORY_MAP))
479-
return;
465+
dma_declare_coherent_memory(&pdev->dev,
466+
mx2_camera_base + 2 * MX2_CAMERA_BUF_SIZE,
467+
mx2_camera_base + 2 * MX2_CAMERA_BUF_SIZE,
468+
MX2_CAMERA_BUF_SIZE,
469+
DMA_MEMORY_EXCLUSIVE);
480470
}
481471

482472
/* Emma-PrP for format conversion */
483473
static void __init visstrim_emmaprp_init(void)
484474
{
485475
struct platform_device *pdev;
486-
int dma;
476+
int ret;
487477

488478
pdev = imx27_add_mx2_emmaprp();
489479
if (IS_ERR(pdev))
@@ -493,11 +483,11 @@ static void __init visstrim_emmaprp_init(void)
493483
* Use the same memory area as the analog camera since both
494484
* devices are, by nature, exclusive.
495485
*/
496-
dma = dma_declare_coherent_memory(&pdev->dev,
486+
ret = dma_declare_coherent_memory(&pdev->dev,
497487
mx2_camera_base, mx2_camera_base,
498488
MX2_CAMERA_BUF_SIZE,
499-
DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE);
500-
if (!(dma & DMA_MEMORY_MAP))
489+
DMA_MEMORY_EXCLUSIVE);
490+
if (ret)
501491
pr_err("Failed to declare memory for emmaprp\n");
502492
}
503493

arch/arm/mach-imx/mach-mx31moboard.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ static phys_addr_t mx3_camera_base __initdata;
475475

476476
static int __init mx31moboard_init_cam(void)
477477
{
478-
int dma, ret = -ENOMEM;
478+
int ret;
479479
struct platform_device *pdev;
480480

481481
imx31_add_ipu_core();
@@ -484,11 +484,11 @@ static int __init mx31moboard_init_cam(void)
484484
if (IS_ERR(pdev))
485485
return PTR_ERR(pdev);
486486

487-
dma = dma_declare_coherent_memory(&pdev->dev,
488-
mx3_camera_base, mx3_camera_base,
489-
MX3_CAMERA_BUF_SIZE,
490-
DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE);
491-
if (!(dma & DMA_MEMORY_MAP))
487+
ret = dma_declare_coherent_memory(&pdev->dev,
488+
mx3_camera_base, mx3_camera_base,
489+
MX3_CAMERA_BUF_SIZE,
490+
DMA_MEMORY_EXCLUSIVE);
491+
if (ret)
492492
goto err;
493493

494494
ret = platform_device_add(pdev);

arch/metag/include/asm/dma-mapping.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
99
}
1010

1111
/*
12-
* dma_alloc_noncoherent() returns non-cacheable memory, so there's no need to
12+
* dma_alloc_attrs() always returns non-cacheable memory, so there's no need to
1313
* do any flushing here.
1414
*/
1515
static inline void

arch/nios2/include/asm/dma-mapping.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
1818
}
1919

2020
/*
21-
* dma_alloc_noncoherent() returns non-cacheable memory, so there's no need to
21+
* dma_alloc_attrs() always returns non-cacheable memory, so there's no need to
2222
* do any flushing here.
2323
*/
2424
static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,

arch/sh/drivers/pci/fixups-dreamcast.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,10 @@ static void gapspci_fixup_resources(struct pci_dev *dev)
6363
res.end = GAPSPCI_DMA_BASE + GAPSPCI_DMA_SIZE - 1;
6464
res.flags = IORESOURCE_MEM;
6565
pcibios_resource_to_bus(dev->bus, &region, &res);
66-
BUG_ON(!dma_declare_coherent_memory(&dev->dev,
66+
BUG_ON(dma_declare_coherent_memory(&dev->dev,
6767
res.start,
6868
region.start,
6969
resource_size(&res),
70-
DMA_MEMORY_MAP |
7170
DMA_MEMORY_EXCLUSIVE));
7271
break;
7372
default:

arch/tile/include/asm/dma-mapping.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
6868
int dma_set_mask(struct device *dev, u64 mask);
6969

7070
/*
71-
* dma_alloc_noncoherent() is #defined to return coherent memory,
72-
* so there's no need to do any flushing here.
71+
* dma_alloc_attrs() always returns non-cacheable memory, so there's no need to
72+
* do any flushing here.
7373
*/
7474
static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
7575
enum dma_data_direction direction)

0 commit comments

Comments
 (0)