mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-07 14:32:23 +00:00
dma-mapping: don't store redundant offsets
A bus_dma_region necessarily stores both CPU and DMA base addresses for a range, so there's no need to also store the difference between them. Signed-off-by: Robin Murphy <robin.murphy@arm.com> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
3f7168591e
commit
4ad4c1f394
@ -1532,7 +1532,6 @@ int acpi_dma_get_range(struct device *dev, const struct bus_dma_region **map)
|
||||
r->cpu_start = rentry->res->start;
|
||||
r->dma_start = rentry->res->start - rentry->offset;
|
||||
r->size = resource_size(rentry->res);
|
||||
r->offset = rentry->offset;
|
||||
r++;
|
||||
}
|
||||
}
|
||||
|
@ -955,7 +955,6 @@ int of_dma_get_range(struct device_node *np, const struct bus_dma_region **map)
|
||||
r->cpu_start = range.cpu_addr;
|
||||
r->dma_start = range.bus_addr;
|
||||
r->size = range.size;
|
||||
r->offset = range.cpu_addr - range.bus_addr;
|
||||
r++;
|
||||
}
|
||||
out:
|
||||
|
@ -21,7 +21,6 @@ struct bus_dma_region {
|
||||
phys_addr_t cpu_start;
|
||||
dma_addr_t dma_start;
|
||||
u64 size;
|
||||
u64 offset;
|
||||
};
|
||||
|
||||
static inline dma_addr_t translate_phys_to_dma(struct device *dev,
|
||||
@ -29,9 +28,12 @@ static inline dma_addr_t translate_phys_to_dma(struct device *dev,
|
||||
{
|
||||
const struct bus_dma_region *m;
|
||||
|
||||
for (m = dev->dma_range_map; m->size; m++)
|
||||
if (paddr >= m->cpu_start && paddr - m->cpu_start < m->size)
|
||||
return (dma_addr_t)paddr - m->offset;
|
||||
for (m = dev->dma_range_map; m->size; m++) {
|
||||
u64 offset = paddr - m->cpu_start;
|
||||
|
||||
if (paddr >= m->cpu_start && offset < m->size)
|
||||
return m->dma_start + offset;
|
||||
}
|
||||
|
||||
/* make sure dma_capable fails when no translation is available */
|
||||
return DMA_MAPPING_ERROR;
|
||||
@ -42,9 +44,12 @@ static inline phys_addr_t translate_dma_to_phys(struct device *dev,
|
||||
{
|
||||
const struct bus_dma_region *m;
|
||||
|
||||
for (m = dev->dma_range_map; m->size; m++)
|
||||
if (dma_addr >= m->dma_start && dma_addr - m->dma_start < m->size)
|
||||
return (phys_addr_t)dma_addr + m->offset;
|
||||
for (m = dev->dma_range_map; m->size; m++) {
|
||||
u64 offset = dma_addr - m->dma_start;
|
||||
|
||||
if (dma_addr >= m->dma_start && offset < m->size)
|
||||
return m->cpu_start + offset;
|
||||
}
|
||||
|
||||
return (phys_addr_t)-1;
|
||||
}
|
||||
|
@ -677,7 +677,6 @@ int dma_direct_set_offset(struct device *dev, phys_addr_t cpu_start,
|
||||
return -ENOMEM;
|
||||
map[0].cpu_start = cpu_start;
|
||||
map[0].dma_start = dma_start;
|
||||
map[0].offset = offset;
|
||||
map[0].size = size;
|
||||
dev->dma_range_map = map;
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user