Release 4.14 arch/powerpc/kernel/dma-iommu.c
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corporation
*
* Provide default implementations of the DMA mapping callbacks for
* busses using the iommu infrastructure
*/
#include <linux/export.h>
#include <asm/iommu.h>
/*
* Generic iommu implementation
*/
/* Allocates a contiguous real buffer and creates mappings over it.
* Returns the virtual address of the buffer and sets dma_handle
* to the dma address (mapping) of the first page.
*/
static void *dma_iommu_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t flag,
unsigned long attrs)
{
return iommu_alloc_coherent(dev, get_iommu_table_base(dev), size,
dma_handle, dev->coherent_dma_mask, flag,
dev_to_node(dev));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Becky Bruce | 46 | 88.46% | 3 | 50.00% |
Andrzej Pietrasiewicz | 2 | 3.85% | 1 | 16.67% |
Nishanth Aravamudan | 2 | 3.85% | 1 | 16.67% |
Krzysztof Kozlowski | 2 | 3.85% | 1 | 16.67% |
Total | 52 | 100.00% | 6 | 100.00% |
static void dma_iommu_free_coherent(struct device *dev, size_t size,
void *vaddr, dma_addr_t dma_handle,
unsigned long attrs)
{
iommu_free_coherent(get_iommu_table_base(dev), size, vaddr, dma_handle);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Becky Bruce | 35 | 89.74% | 2 | 50.00% |
Krzysztof Kozlowski | 2 | 5.13% | 1 | 25.00% |
Andrzej Pietrasiewicz | 2 | 5.13% | 1 | 25.00% |
Total | 39 | 100.00% | 4 | 100.00% |
/* Creates TCEs for a user provided buffer. The user buffer must be
* contiguous real kernel storage (not vmalloc). The address passed here
* comprises a page address and offset into that page. The dma_addr_t
* returned will point to the same byte within the page as was passed in.
*/
static dma_addr_t dma_iommu_map_page(struct device *dev, struct page *page,
unsigned long offset, size_t size,
enum dma_data_direction direction,
unsigned long attrs)
{
return iommu_map_page(dev, get_iommu_table_base(dev), page, offset,
size, device_to_mask(dev), direction, attrs);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Becky Bruce | 43 | 75.44% | 2 | 50.00% |
Mark Nelson | 12 | 21.05% | 1 | 25.00% |
Krzysztof Kozlowski | 2 | 3.51% | 1 | 25.00% |
Total | 57 | 100.00% | 4 | 100.00% |
static void dma_iommu_unmap_page(struct device *dev, dma_addr_t dma_handle,
size_t size, enum dma_data_direction direction,
unsigned long attrs)
{
iommu_unmap_page(get_iommu_table_base(dev), dma_handle, size, direction,
attrs);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Becky Bruce | 37 | 90.24% | 2 | 50.00% |
Mark Nelson | 2 | 4.88% | 1 | 25.00% |
Krzysztof Kozlowski | 2 | 4.88% | 1 | 25.00% |
Total | 41 | 100.00% | 4 | 100.00% |
static int dma_iommu_map_sg(struct device *dev, struct scatterlist *sglist,
int nelems, enum dma_data_direction direction,
unsigned long attrs)
{
return ppc_iommu_map_sg(dev, get_iommu_table_base(dev), sglist, nelems,
device_to_mask(dev), direction, attrs);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Becky Bruce | 48 | 94.12% | 2 | 50.00% |
Krzysztof Kozlowski | 2 | 3.92% | 1 | 25.00% |
Joerg Roedel | 1 | 1.96% | 1 | 25.00% |
Total | 51 | 100.00% | 4 | 100.00% |
static void dma_iommu_unmap_sg(struct device *dev, struct scatterlist *sglist,
int nelems, enum dma_data_direction direction,
unsigned long attrs)
{
ppc_iommu_unmap_sg(get_iommu_table_base(dev), sglist, nelems,
direction, attrs);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Becky Bruce | 40 | 93.02% | 2 | 50.00% |
Krzysztof Kozlowski | 2 | 4.65% | 1 | 25.00% |
Joerg Roedel | 1 | 2.33% | 1 | 25.00% |
Total | 43 | 100.00% | 4 | 100.00% |
/* We support DMA to/from any memory page via the iommu */
int dma_iommu_dma_supported(struct device *dev, u64 mask)
{
struct iommu_table *tbl = get_iommu_table_base(dev);
if (!tbl) {
dev_info(dev, "Warning: IOMMU dma not supported: mask 0x%08llx"
", table unavailable\n", mask);
return 0;
}
if (tbl->it_offset > (mask >> tbl->it_page_shift)) {
dev_info(dev, "Warning: IOMMU offset too big for device mask\n");
dev_info(dev, "mask: 0x%08llx, table offset: 0x%08lx\n",
mask, tbl->it_offset << tbl->it_page_shift);
return 0;
} else
return 1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Becky Bruce | 54 | 60.00% | 2 | 40.00% |
Nishanth Aravamudan | 28 | 31.11% | 1 | 20.00% |
Alistair Popple | 6 | 6.67% | 1 | 20.00% |
Aaro Koskinen | 2 | 2.22% | 1 | 20.00% |
Total | 90 | 100.00% | 5 | 100.00% |
static u64 dma_iommu_get_required_mask(struct device *dev)
{
struct iommu_table *tbl = get_iommu_table_base(dev);
u64 mask;
if (!tbl)
return 0;
mask = 1ULL < (fls_long(tbl->it_offset + tbl->it_size) - 1);
mask += mask - 1;
return mask;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Milton D. Miller II | 60 | 100.00% | 2 | 100.00% |
Total | 60 | 100.00% | 2 | 100.00% |
int dma_iommu_mapping_error(struct device *dev, dma_addr_t dma_addr)
{
return dma_addr == IOMMU_MAPPING_ERROR;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Christoph Hellwig | 18 | 100.00% | 1 | 100.00% |
Total | 18 | 100.00% | 1 | 100.00% |
struct dma_map_ops dma_iommu_ops = {
.alloc = dma_iommu_alloc_coherent,
.free = dma_iommu_free_coherent,
.mmap = dma_direct_mmap_coherent,
.map_sg = dma_iommu_map_sg,
.unmap_sg = dma_iommu_unmap_sg,
.dma_supported = dma_iommu_dma_supported,
.map_page = dma_iommu_map_page,
.unmap_page = dma_iommu_unmap_page,
.get_required_mask = dma_iommu_get_required_mask,
.mapping_error = dma_iommu_mapping_error,
};
EXPORT_SYMBOL(dma_iommu_ops);
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Becky Bruce | 343 | 65.46% | 3 | 16.67% |
Milton D. Miller II | 65 | 12.40% | 2 | 11.11% |
Nishanth Aravamudan | 30 | 5.73% | 2 | 11.11% |
Mark Nelson | 25 | 4.77% | 1 | 5.56% |
Christoph Hellwig | 23 | 4.39% | 1 | 5.56% |
Krzysztof Kozlowski | 12 | 2.29% | 1 | 5.56% |
Andrzej Pietrasiewicz | 6 | 1.15% | 1 | 5.56% |
Alistair Popple | 6 | 1.15% | 1 | 5.56% |
Marek Szyprowski | 5 | 0.95% | 1 | 5.56% |
Paul Gortmaker | 3 | 0.57% | 1 | 5.56% |
Joerg Roedel | 2 | 0.38% | 1 | 5.56% |
Aaro Koskinen | 2 | 0.38% | 1 | 5.56% |
Greg Kroah-Hartman | 1 | 0.19% | 1 | 5.56% |
FUJITA Tomonori | 1 | 0.19% | 1 | 5.56% |
Total | 524 | 100.00% | 18 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.