summaryrefslogtreecommitdiff
path: root/arch/arm/include/asm/dma-mapping.h
AgeCommit message (Collapse)Author
2012-06-13Avoid aliasing mappings in DMA coherent allocatorManoj Chourasia
Avoid multiple mappings with DMA coherent/writecombine allocator by pre- allocating the mappings, and removing that memory from the system memory mapping. (See previous discussions on linux-arm-kernel as to why this is bad.) NB1: By default, we preallocate 2MB for DMA coherent, and 2MB for write combine memory, rather than 1MB for each in case 1MB is not sufficient for existing platform usage. Platforms have the option of shrinking this down to 1MB DMA / 1MB WC (or even 2MB DMA / 0MB WC) if they so wish. The DMA memory must be a multiple of 1MB, the write combine memory must also be a multiple of 1MB, and the two together must be a multiple of 2MB. NB2: On ARMv6/7 where we use 'normal uncacheable' memory for both DMA and WC, the two pools are combined into one, as was the case with the previous implementation. The down side to this change is that the memory is permanently set aside for DMA purposes, but I believe that to be unavoidable if we are to avoid the possibility of the cache getting in the way on VIPT CPUs. This removes the last known offender (at this time) from the kernel. Given that DMA memory is fully coherent by this patch, cache invalidation/clean is not required and so, we skip cache related activities for the memory managed by the DMA layer. The bus address -> virtual address conversion normally used in the calling path and the fact that we remove kernel static mapping corresponding to the DMA buffers leads to exceptions otherwise. bug 876019 bug 965047 bug 987589 Change-Id: I72beb386605aafe1a301494a95a67d094ea6b2e4 Signed-off-by: Russell King <rmk@arm.linux.org.uk> Signed-off-by: Manoj Chourasia <mchourasia@nvidia.com> Reviewed-on: http://git-master/r/106212 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Varun Wadekar <vwadekar@nvidia.com> Reviewed-by: Krishna Reddy <vdumpa@nvidia.com> Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>
2011-07-12ARM: dma: replace ISA_DMA_THRESHOLD with a variableRussell King
ISA_DMA_THRESHOLD has been unused by non-arch code, so lets now get rid of it from ARM by replacing it with arm_dma_zone_mask. Move dma_supported() and dma_set_mask() out of line, and have dma_supported() check this new variable instead. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2011-07-08ARM: dmabounce: simplify dma_set_mask()Russell King
Simplify the dmabounce specific code in dma_set_mask(). We can just omit setting the dma mask if dmabounce is enabled (we will have already set dma mask via callbacks when the device is created in that case.) Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2011-07-04ARM: dmabounce: get rid of dma_needs_bounce global functionRussell King
Pass the device type specific needs_bounce function in at dmabounce register time, avoiding the need for a platform specific global function to do this. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2011-07-03ARM: dma-mapping: define dma_(un)?map_single in terms of dma_(un)?map_pageRussell King
Use dma_map_page()/dma_unmap_page() internals to handle dma_map_single() and dma_unmap_single(). Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2011-01-06ARM: DMA: add support for DMA debuggingRussell King
Add ARM support for the DMA debug infrastructure, which allows the DMA API usage to be debugged. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2011-01-03ARM: DMA: Replace page_to_dma()/dma_to_page() with pfn_to_dma()/dma_to_pfn()Russell King
Replace the page_to_dma() and dma_to_page() macros with their PFN equivalents. This allows us to map parts of memory which do not have a struct page allocated to them to bus addresses. This will be used internally by dma_alloc_coherent()/dma_alloc_writecombine(). Build tested on Versatile, OMAP1, IOP13xx and KS8695. Tested-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2010-09-08Revert "[ARM] pxa: remove now unnecessary dma_needs_bounce()"Russell King
This reverts commit 4fa5518, which causes a compilation regression for IXP4xx platforms. Reported-by: Richard Cochran <richardcochran@gmail.com> Acked-by: Eric Miao <eric.y.miao@gmail.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2010-08-11Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-armLinus Torvalds
* 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm: (226 commits) ARM: 6323/1: cam60: don't use __init for cam60_spi_{flash_platform_data,partitions} ARM: 6324/1: cam60: move cam60_spi_devices to .init.data ARM: 6322/1: imx/pca100: Fix name of spi platform data ARM: 6321/1: fix syntax error in main Kconfig file ARM: 6297/1: move U300 timer to dynamic clock lookup ARM: 6296/1: clock U300 intcon and timer properly ARM: 6295/1: fix U300 apb_pclk split ARM: 6306/1: fix inverted MMC card detect in U300 ARM: 6299/1: errata: TLBIASIDIS and TLBIMVAIS operations can broadcast a faulty ASID ARM: 6294/1: etm: do a dummy read from OSSRR during initialization ARM: 6292/1: coresight: add ETM management registers ARM: 6288/1: ftrace: document mcount formats ARM: 6287/1: ftrace: clean up mcount assembly indentation ARM: 6286/1: fix Thumb-2 decompressor broken by "Auto calculate ZRELADDR" ARM: 6281/1: video/imxfb.c: allow usage without BACKLIGHT_CLASS_DEVICE ARM: 6280/1: imx: Fix build failure when including <mach/gpio.h> without <linux/spinlock.h> ARM: S5PV210: Fix on missing s3c-sdhci card detection method for hsmmc3 ARM: S5P: Fix on missing S5P_DEV_FIMC in plat-s5p/Kconfig ARM: S5PV210: Override FIMC driver name on Aquila board ARM: S5PC100: enable FIMC on SMDKC100 ... Fix up conflicts in arch/arm/mach-{s5pc100,s5pv210}/cpu.c due to different subsystem 'setname' calls, and trivial port types in include/linux/serial_core.h
2010-08-11dma-mapping: remove dma_is_consistent APIFUJITA Tomonori
Architectures implement dma_is_consistent() in different ways (some misinterpret the definition of API in DMA-API.txt). So it hasn't been so useful for drivers. We have only one user of the API in tree. Unlikely out-of-tree drivers use the API. Even if we fix dma_is_consistent() in some architectures, it doesn't look useful at all. It was invented long ago for some old systems that can't allocate coherent memory at all. It's better to export only APIs that are definitely necessary for drivers. Let's remove this API. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Cc: James Bottomley <James.Bottomley@HansenPartnership.com> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: <linux-arch@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-08-11dma-mapping: unify dma_get_cache_alignment implementationsFUJITA Tomonori
dma_get_cache_alignment returns the minimum DMA alignment. Architectures defines it as ARCH_DMA_MINALIGN (formally ARCH_KMALLOC_MINALIGN). So we can unify dma_get_cache_alignment implementations. Note that some architectures implement dma_get_cache_alignment wrongly. dma_get_cache_alignment() should return the minimum DMA alignment. So fully-coherent architectures should return 1. This patch also fixes this issue. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Cc: <linux-arch@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-08-05[ARM] pxa: remove now unnecessary dma_needs_bounce()Eric Miao
With a correct dev->dma_mask before calling dmabounce_register_dev(), dma_needs_bounce() is not necessary. The sa1111, though, is a bit complicated. Until it's fully understood and fixed, dma_needs_bounce() for sa1111 is kept if CONFIG_SA1111 is enabled with no side effect (with the condition of machine_is_*) Thanks for Mike Rapoport to fix one error in the original version of the patch and get this tested. Acked-by: Mike Rapoport <mike@compulab.co.il> Signed-off-by: Eric Miao <eric.y.miao@gmail.com>
2010-03-12dma-mapping: arm: use generic pci_set_dma_mask and pci_set_consistent_dma_maskFUJITA Tomonori
This converts arm to the generic pci_set_dma_mask and pci_set_consistent_dma_mask (removes HAVE_ARCH_PCI_SET_DMA_MASK for dmabounce). Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Looked-over-by: Russell King <rmk+kernel@arm.linux.org.uk> Cc: Jesse Barnes <jbarnes@virtuousgeek.org> Cc: Greg KH <greg@kroah.com> Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-02-15ARM: dma-mapping: push buffer ownership down into dma-mapping.cRussell King
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Tested-By: Santosh Shilimkar <santosh.shilimkar@ti.com>
2010-02-15ARM: dma-mapping: introduce the idea of buffer ownershipRussell King
The DMA API has the notion of buffer ownership; make it explicit in the ARM implementation of this API. This gives us a set of hooks to allow us to deal with CPU cache issues arising from non-cache coherent DMA. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Tested-By: Santosh Shilimkar <santosh.shilimkar@ti.com> Tested-By: Jamie Iles <jamie@jamieiles.com>
2009-11-23ARM: dma-mapping: split dma_unmap_page() from dma_unmap_single()Russell King
We will need to treat dma_unmap_page() differently from dma_unmap_single() Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Tested-By: Jamie Iles <jamie@jamieiles.com>
2009-11-23ARM: dma-mapping: provide dma_to_page()Russell King
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Tested-By: Jamie Iles <jamie@jamieiles.com>
2009-11-23ARM: dma-mapping: simplify page_to_dma() and __pfn_to_bus()Russell King
The non-highmem() and the __pfn_to_bus() based page_to_dma() both compile to the same code, so its pointless having these two different approaches. Use the __pfn_to_bus() based version. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Tested-By: Jamie Iles <jamie@jamieiles.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
2009-03-15[ARM] make page_to_dma() highmem awareNicolas Pitre
If a machine class has a custom __virt_to_bus() implementation then it must provide a __arch_page_to_dma() implementation as well which is _not_ based on page_address() to support highmem. This patch fixes existing __arch_page_to_dma() and provide a default implementation otherwise. The default implementation for highmem is based on __pfn_to_bus() which is defined only when no custom __virt_to_bus() is provided by the machine class. That leaves only ebsa110 and footbridge which cannot support highmem until they provide their own __arch_page_to_dma() implementation. But highmem support on those legacy platforms with limited memory is certainly not a priority. Signed-off-by: Nicolas Pitre <nico@marvell.com>
2009-03-15[ARM] introduce dma_cache_maint_page()Nicolas Pitre
This is a helper to be used by the DMA mapping API to handle cache maintenance for memory identified by a page structure instead of a virtual address. Those pages may or may not be highmem pages, and when they're highmem pages, they may or may not be virtually mapped. When they're not mapped then there is no L1 cache to worry about. But even in that case the L2 cache must be processed since unmapped highmem pages can still be L2 cached. Signed-off-by: Nicolas Pitre <nico@marvell.com>
2008-12-13[ARM] dma: correct dma_supported() implementationRussell King
dma_supported() is supposed to indicate whether the system can support the DMA mask it was passed, which depends on the maximal address which can be returned for DMA allocations. If the mask is smaller than that, we are unable to guarantee that the driver can reliably obtain suitable memory. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2008-11-13[ARM] dma-mapping: fix compiler warningRussell King
arch/arm/mm/dma-mapping.c: In function `dma_sync_sg_for_cpu': arch/arm/mm/dma-mapping.c:588: warning: statement with no effect Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2008-09-30[ARM] dma: fix some comments in dma-mapping.hRussell King
... to prevent people being mislead. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2008-09-30[ARM] dma: don't touch cache on dma_*_for_cpu()Russell King
As per the dma_unmap_* calls, we don't touch the cache when a DMA buffer transitions from device to CPU ownership. Presently, no problems have been identified with speculative cache prefetching which in itself is a new feature in later architectures. We may have to revisit the DMA API later for these architectures anyway. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2008-09-29[ARM] dma: add validation of DMA paramsRussell King
Validate the direction argument like x86 does. In addition, validate the dma_unmap_* parameters against those passed to dma_map_* when using the DMA bounce code. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2008-09-29[ARM] dma: coding style cleanupsRussell King
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2008-09-29[ARM] dma: fix dmabounce dma_sync_xxx() implementationsRussell King
The dmabounce dma_sync_xxx() implementation have been broken for quite some time; they all copy data between the DMA buffer and the CPU visible buffer no irrespective of the change of ownership. (IOW, a DMA_FROM_DEVICE mapping copies data from the DMA buffer to the CPU buffer during a call to dma_sync_single_for_device().) Fix it by getting rid of sync_single(), moving the contents into the recently created dmabounce_sync_for_xxx() functions and adjusting appropriately. This also makes it possible to properly support the DMA range sync functions. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2008-09-29[ARM] dma: use new dmabounce_sync_for_xxx() for dma_sync_single_xxx()Russell King
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2008-09-29[ARM] dma: Reduce to one dma_sync_sg_* implementationRussell King
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2008-09-25[ARM] dma: provide a better dma_map_page() implementationRussell King
We can translate a struct page directly to a DMA address using page_to_dma(). No need to use page_address() followed by virt_to_dma(). Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2008-09-25[ARM] Update dma_map_sg()/dma_unmap_sg() APIRussell King
Update the ARM DMA scatter gather APIs for the scatterlist changes. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2008-08-10[ARM] dma-mapping: provide sync_range APIsRussell King
Convert the existing dma_sync_single_for_* APIs to the new range based APIs, and make the dma_sync_single_for_* API a superset of it. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2008-08-10[ARM] dma-mapping: improve type-safeness of DMA translationsRussell King
OMAP at least gets the return type(s) for the DMA translation functions wrong, which can lead to subtle errors. Avoid this by moving the DMA translation functions to asm/dma-mapping.h, and converting them to inline functions. Fix the OMAP DMA translation macros to use the correct argument and result types. Also, remove the unnecessary casts in dmabounce.c. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2008-08-03Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-armLinus Torvalds
* 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm: [ARM] 5182/1: pxa: Fix pcm990 compilation [ARM] Fix explicit asm(-arm)?/arch-foo references [ARM] move include/asm-arm to arch/arm/include/asm [ARM] Remove explicit dependency for misc.o from compressed/Makefile [ARM] initrd: claim initrd memory exclusively [ARM] pxa: add support for L2 outer cache on XScale3 (attempt 2) [ARM] 5180/1: at91: Fix at91_nand -> atmel_nand rename fallout [ARM] add Sascha Hauer as Freescale i.MX Maintainer [ARM] i.MX: add missing clock functions exports [ARM] i.MX: remove set_imx_fb_info() export [ARM] mx1ads: make mmc platform data available for modules [ARM] mx2: add missing Kconfig dependency
2008-08-02[ARM] move include/asm-arm to arch/arm/include/asmRussell King
Move platform independent header files to arch/arm/include/asm, leaving those in asm/arch* and asm/plat* alone. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>