- mostly more consolidation of the direct mapping code, including converting over hexagon, and merging the coherent and non-coherent code into a single dma_map_ops instance (me) - cleanups for the dma_configure/dma_unconfigure callchains (me) - better handling of dma_masks in odd setups (me, Alexander Duyck) - better debugging of passing vmalloc address to the DMA API (Stephen Boyd) - CMA command line parsing fix (He Zhe) -----BEGIN PGP SIGNATURE----- iQI/BAABCgApFiEEgdbnc3r/njty3Iq9D55TZVIEUYMFAlvNg6YLHGhjaEBsc3Qu ZGUACgkQD55TZVIEUYMm/Q/9FFVOH73Nc3rT40N2HdaPbzV2hXmI1//hEJcImDP5 mLGq8XqieGuo8Pmu9+xp1tC2UnfUkhK4FjhQbWM+qKER/RNYES2BD50xVFmt6ICS 9d8IaRcs+ceggljfdwszkkucJspBsYNxpiKjjao0OsHn6UDatu6elZs/yvb2nXci HCJUvs9vYm9MkAtVXEtOQtij3YRaJ/9xYY4h5Dy5vBtHPp+kjUMF0mWAwA2+Ec1V 8iqKjUY3c8nr8Kf6WE9tzJ0wrMFijc4HJlE3W1ud8YsKdfCkCf8XiIuS6PgTzOeK 0cn9h8dVrV1ZXJ/D/9JZDivmYvIsoKWAYVQHNzAiq7PI3uOJY1ggCxyZpWtTHZhM ATHF0sJGpIenkSWybYpKee8e8RsS7L9dUgu6bYpK5pVkirNYnR9IOGVJNmS63L7Q B0uUtqjBKDG2yNGZGY9zqBQFgxiPO0wxFLeKyHbIsC0b7FBti3rXGAimch5WiBuL zlDV0zEfMH0BW6gNPrjfFur84duKtGZ/0DBSxQ0E1Mvk8B1LBr78MgZt8OfJEuoe dx1FYU70u8PYi+hjmn386YnNNMTjd1GT5XW7AWedM2wCjRYmNy0yMGmm9cACMneN 5eBv/SYr7X1zKNL7w7H6KQVZilTJcBoj3f/lmjL7i22m9FXYQpcUP61L8wHNM8H2 iJo= =AVSD -----END PGP SIGNATURE----- Merge tag 'dma-mapping-4.20' of git://git.infradead.org/users/hch/dma-mapping Pull dma mapping updates from Christoph Hellwig: "First batch of dma-mapping changes for 4.20. There will be a second PR as some big changes were only applied just before the end of the merge window, and I want to give them a few more days in linux-next. Summary: - mostly more consolidation of the direct mapping code, including converting over hexagon, and merging the coherent and non-coherent code into a single dma_map_ops instance (me) - cleanups for the dma_configure/dma_unconfigure callchains (me) - better handling of dma_masks in odd setups (me, Alexander Duyck) - better debugging of passing vmalloc address to the DMA API (Stephen Boyd) - CMA command line parsing fix (He Zhe)" * tag 'dma-mapping-4.20' of git://git.infradead.org/users/hch/dma-mapping: (27 commits) dma-direct: respect DMA_ATTR_NO_WARN dma-mapping: translate __GFP_NOFAIL to DMA_ATTR_NO_WARN dma-direct: document the zone selection logic dma-debug: Check for drivers mapping invalid addresses in dma_map_single() dma-direct: fix return value of dma_direct_supported dma-mapping: move dma_default_get_required_mask under ifdef dma-direct: always allow dma mask <= physiscal memory size dma-direct: implement complete bus_dma_mask handling dma-direct: refine dma_direct_alloc zone selection dma-direct: add an explicit dma_direct_get_required_mask dma-mapping: make the get_required_mask method available unconditionally unicore32: remove swiotlb support Revert "dma-mapping: clear dev->dma_ops in arch_teardown_dma_ops" dma-mapping: support non-coherent devices in dma_common_get_sgtable dma-mapping: consolidate the dma mmap implementations dma-mapping: merge direct and noncoherent ops dma-mapping: move the dma_coherent flag to struct device MIPS: don't select DMA_MAYBE_COHERENT from DMA_PERDEV_COHERENT dma-mapping: add the missing ARCH_HAS_SYNC_DMA_FOR_CPU_ALL declaration dma-mapping: fix panic caused by passing empty cma command line argument ...
93 lines
2.4 KiB
C
93 lines
2.4 KiB
C
/*
|
|
* DMA implementation for Hexagon
|
|
*
|
|
* Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 and
|
|
* only version 2 as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
* 02110-1301, USA.
|
|
*/
|
|
|
|
#include <linux/dma-noncoherent.h>
|
|
#include <linux/bootmem.h>
|
|
#include <linux/genalloc.h>
|
|
#include <linux/module.h>
|
|
#include <asm/page.h>
|
|
|
|
static struct gen_pool *coherent_pool;
|
|
|
|
|
|
/* Allocates from a pool of uncached memory that was reserved at boot time */
|
|
|
|
void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_addr,
|
|
gfp_t flag, unsigned long attrs)
|
|
{
|
|
void *ret;
|
|
|
|
/*
|
|
* Our max_low_pfn should have been backed off by 16MB in
|
|
* mm/init.c to create DMA coherent space. Use that as the VA
|
|
* for the pool.
|
|
*/
|
|
|
|
if (coherent_pool == NULL) {
|
|
coherent_pool = gen_pool_create(PAGE_SHIFT, -1);
|
|
|
|
if (coherent_pool == NULL)
|
|
panic("Can't create %s() memory pool!", __func__);
|
|
else
|
|
gen_pool_add(coherent_pool,
|
|
(unsigned long)pfn_to_virt(max_low_pfn),
|
|
hexagon_coherent_pool_size, -1);
|
|
}
|
|
|
|
ret = (void *) gen_pool_alloc(coherent_pool, size);
|
|
|
|
if (ret) {
|
|
memset(ret, 0, size);
|
|
*dma_addr = (dma_addr_t) virt_to_phys(ret);
|
|
} else
|
|
*dma_addr = ~0;
|
|
|
|
return ret;
|
|
}
|
|
|
|
void arch_dma_free(struct device *dev, size_t size, void *vaddr,
|
|
dma_addr_t dma_addr, unsigned long attrs)
|
|
{
|
|
gen_pool_free(coherent_pool, (unsigned long) vaddr, size);
|
|
}
|
|
|
|
void arch_sync_dma_for_device(struct device *dev, phys_addr_t paddr,
|
|
size_t size, enum dma_data_direction dir)
|
|
{
|
|
void *addr = phys_to_virt(paddr);
|
|
|
|
switch (dir) {
|
|
case DMA_TO_DEVICE:
|
|
hexagon_clean_dcache_range((unsigned long) addr,
|
|
(unsigned long) addr + size);
|
|
break;
|
|
case DMA_FROM_DEVICE:
|
|
hexagon_inv_dcache_range((unsigned long) addr,
|
|
(unsigned long) addr + size);
|
|
break;
|
|
case DMA_BIDIRECTIONAL:
|
|
flush_dcache_range((unsigned long) addr,
|
|
(unsigned long) addr + size);
|
|
break;
|
|
default:
|
|
BUG();
|
|
}
|
|
}
|