Release 4.14 arch/blackfin/kernel/dma-mapping.c
/*
* Dynamic DMA mapping support
*
* Copyright 2005-2009 Analog Devices Inc.
*
* Licensed under the GPL-2 or later
*/
#include <linux/types.h>
#include <linux/gfp.h>
#include <linux/string.h>
#include <linux/spinlock.h>
#include <linux/dma-mapping.h>
#include <linux/scatterlist.h>
#include <linux/export.h>
#include <linux/bitmap.h>
static spinlock_t dma_page_lock;
static unsigned long *dma_page;
static unsigned int dma_pages;
static unsigned long dma_base;
static unsigned long dma_size;
static unsigned int dma_initialized;
static void dma_alloc_init(unsigned long start, unsigned long end)
{
spin_lock_init(&dma_page_lock);
dma_initialized = 0;
dma_page = (unsigned long *)__get_free_page(GFP_KERNEL);
memset(dma_page, 0, PAGE_SIZE);
dma_base = PAGE_ALIGN(start);
dma_size = PAGE_ALIGN(end) - PAGE_ALIGN(start);
dma_pages = dma_size >> PAGE_SHIFT;
memset((void *)dma_base, 0, DMA_UNCACHED_REGION);
dma_initialized = 1;
printk(KERN_INFO "%s: dma_page @ 0x%p - %d pages at 0x%08lx\n", __func__,
dma_page, dma_pages, dma_base);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Bryan Wu | 98 | 97.03% | 1 | 25.00% |
Barry Song | 1 | 0.99% | 1 | 25.00% |
Michael Hennerich | 1 | 0.99% | 1 | 25.00% |
Harvey Harrison | 1 | 0.99% | 1 | 25.00% |
Total | 101 | 100.00% | 4 | 100.00% |
static inline unsigned int get_pages(size_t size)
{
return ((size - 1) >> PAGE_SHIFT) + 1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Bryan Wu | 24 | 100.00% | 1 | 100.00% |
Total | 24 | 100.00% | 1 | 100.00% |
static unsigned long __alloc_dma_pages(unsigned int pages)
{
unsigned long ret = 0, flags;
unsigned long start;
if (dma_initialized == 0)
dma_alloc_init(_ramend - DMA_UNCACHED_REGION, _ramend);
spin_lock_irqsave(&dma_page_lock, flags);
start = bitmap_find_next_zero_area(dma_page, dma_pages, 0, pages, 0);
if (start < dma_pages) {
ret = dma_base + (start << PAGE_SHIFT);
bitmap_set(dma_page, start, pages);
}
spin_unlock_irqrestore(&dma_page_lock, flags);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Bryan Wu | 69 | 69.70% | 1 | 33.33% |
Akinobu Mita | 26 | 26.26% | 1 | 33.33% |
Michael Hennerich | 4 | 4.04% | 1 | 33.33% |
Total | 99 | 100.00% | 3 | 100.00% |
static void __free_dma_pages(unsigned long addr, unsigned int pages)
{
unsigned long page = (addr - dma_base) >> PAGE_SHIFT;
unsigned long flags;
if ((page + pages) > dma_pages) {
printk(KERN_ERR "%s: freeing outside range.\n", __func__);
BUG();
}
spin_lock_irqsave(&dma_page_lock, flags);
bitmap_clear(dma_page, page, pages);
spin_unlock_irqrestore(&dma_page_lock, flags);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Bryan Wu | 69 | 88.46% | 1 | 25.00% |
Akinobu Mita | 5 | 6.41% | 1 | 25.00% |
Michael Hennerich | 3 | 3.85% | 1 | 25.00% |
Harvey Harrison | 1 | 1.28% | 1 | 25.00% |
Total | 78 | 100.00% | 4 | 100.00% |
static void *bfin_dma_alloc(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t gfp, unsigned long attrs)
{
void *ret;
ret = (void *)__alloc_dma_pages(get_pages(size));
if (ret) {
memset(ret, 0, size);
*dma_handle = virt_to_phys(ret);
}
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Bryan Wu | 64 | 91.43% | 1 | 33.33% |
Christoph Hellwig | 4 | 5.71% | 1 | 33.33% |
Krzysztof Kozlowski | 2 | 2.86% | 1 | 33.33% |
Total | 70 | 100.00% | 3 | 100.00% |
static void bfin_dma_free(struct device *dev, size_t size, void *vaddr,
dma_addr_t dma_handle, unsigned long attrs)
{
__free_dma_pages((unsigned long)vaddr, get_pages(size));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Bryan Wu | 33 | 84.62% | 1 | 33.33% |
Christoph Hellwig | 4 | 10.26% | 1 | 33.33% |
Krzysztof Kozlowski | 2 | 5.13% | 1 | 33.33% |
Total | 39 | 100.00% | 3 | 100.00% |
/*
* Streaming DMA mappings
*/
void __dma_sync(dma_addr_t addr, size_t size,
enum dma_data_direction dir)
{
__dma_sync_inline(addr, size, dir);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Bryan Wu | 15 | 62.50% | 1 | 33.33% |
Barry Song | 8 | 33.33% | 1 | 33.33% |
Sonic Zhang | 1 | 4.17% | 1 | 33.33% |
Total | 24 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL(__dma_sync);
static int bfin_dma_map_sg(struct device *dev, struct scatterlist *sg_list,
int nents, enum dma_data_direction direction,
unsigned long attrs)
{
struct scatterlist *sg;
int i;
for_each_sg(sg_list, sg, nents, i) {
sg->dma_address = (dma_addr_t) sg_virt(sg);
if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
continue;
__dma_sync(sg_dma_address(sg), sg_dma_len(sg), direction);
}
return nents;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Bryan Wu | 40 | 47.62% | 2 | 22.22% |
Sonic Zhang | 25 | 29.76% | 2 | 22.22% |
Alexander Duyck | 7 | 8.33% | 1 | 11.11% |
Christoph Hellwig | 4 | 4.76% | 1 | 11.11% |
Barry Song | 3 | 3.57% | 1 | 11.11% |
Jens Axboe | 3 | 3.57% | 1 | 11.11% |
Krzysztof Kozlowski | 2 | 2.38% | 1 | 11.11% |
Total | 84 | 100.00% | 9 | 100.00% |
static void bfin_dma_sync_sg_for_device(struct device *dev,
struct scatterlist *sg_list, int nelems,
enum dma_data_direction direction)
{
struct scatterlist *sg;
int i;
for_each_sg(sg_list, sg, nelems, i) {
sg->dma_address = (dma_addr_t) sg_virt(sg);
__dma_sync(sg_dma_address(sg), sg_dma_len(sg), direction);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Barry Song | 29 | 41.43% | 1 | 25.00% |
Bryan Wu | 23 | 32.86% | 1 | 25.00% |
Sonic Zhang | 16 | 22.86% | 1 | 25.00% |
Christoph Hellwig | 2 | 2.86% | 1 | 25.00% |
Total | 70 | 100.00% | 4 | 100.00% |
static dma_addr_t bfin_dma_map_page(struct device *dev, struct page *page,
unsigned long offset, size_t size, enum dma_data_direction dir,
unsigned long attrs)
{
dma_addr_t handle = (dma_addr_t)(page_address(page) + offset);
if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
_dma_sync(handle, size, dir);
return handle;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Christoph Hellwig | 56 | 83.58% | 1 | 33.33% |
Alexander Duyck | 9 | 13.43% | 1 | 33.33% |
Krzysztof Kozlowski | 2 | 2.99% | 1 | 33.33% |
Total | 67 | 100.00% | 3 | 100.00% |
static inline void bfin_dma_sync_single_for_device(struct device *dev,
dma_addr_t handle, size_t size, enum dma_data_direction dir)
{
_dma_sync(handle, size, dir);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Christoph Hellwig | 31 | 100.00% | 1 | 100.00% |
Total | 31 | 100.00% | 1 | 100.00% |
const struct dma_map_ops bfin_dma_ops = {
.alloc = bfin_dma_alloc,
.free = bfin_dma_free,
.map_page = bfin_dma_map_page,
.map_sg = bfin_dma_map_sg,
.sync_single_for_device = bfin_dma_sync_single_for_device,
.sync_sg_for_device = bfin_dma_sync_sg_for_device,
};
EXPORT_SYMBOL(bfin_dma_ops);
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Bryan Wu | 488 | 61.77% | 2 | 11.76% |
Christoph Hellwig | 138 | 17.47% | 1 | 5.88% |
Barry Song | 44 | 5.57% | 1 | 5.88% |
Sonic Zhang | 42 | 5.32% | 3 | 17.65% |
Akinobu Mita | 34 | 4.30% | 1 | 5.88% |
Alexander Duyck | 16 | 2.03% | 1 | 5.88% |
Michael Hennerich | 9 | 1.14% | 1 | 5.88% |
Krzysztof Kozlowski | 8 | 1.01% | 1 | 5.88% |
Jens Axboe | 3 | 0.38% | 1 | 5.88% |
Paul Gortmaker | 3 | 0.38% | 1 | 5.88% |
Harvey Harrison | 2 | 0.25% | 1 | 5.88% |
Robin Getz | 1 | 0.13% | 1 | 5.88% |
Adrian Bunk | 1 | 0.13% | 1 | 5.88% |
Bart Van Assche | 1 | 0.13% | 1 | 5.88% |
Total | 790 | 100.00% | 17 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.