Skip to content

Commit f2e3d55

Browse files
committed
ARC: dma: reintroduce platform specific dma<->phys
Signed-off-by: Vineet Gupta <[email protected]>
1 parent f5db19e commit f2e3d55

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

arch/arc/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,9 @@ config ARCH_PHYS_ADDR_T_64BIT
468468
config ARCH_DMA_ADDR_T_64BIT
469469
bool
470470

471+
config ARC_PLAT_NEEDS_PHYS_TO_DMA
472+
bool
473+
471474
config ARC_CURR_IN_REG
472475
bool "Dedicate Register r25 for current_task pointer"
473476
default y

arch/arc/include/asm/dma-mapping.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
#ifndef ASM_ARC_DMA_MAPPING_H
1212
#define ASM_ARC_DMA_MAPPING_H
1313

14+
#ifndef CONFIG_ARC_PLAT_NEEDS_PHYS_TO_DMA
15+
#define plat_dma_to_phys(dev, dma_handle) ((phys_addr_t)(dma_handle))
16+
#define plat_phys_to_dma(dev, paddr) ((dma_addr_t)(paddr))
17+
#else
18+
#include <plat/dma.h>
19+
#endif
20+
1421
extern struct dma_map_ops arc_dma_ops;
1522

1623
static inline struct dma_map_ops *get_dma_ops(struct device *dev)

arch/arc/mm/dma.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ static void *arc_dma_alloc(struct device *dev, size_t size,
6060
/* This is linear addr (0x8000_0000 based) */
6161
paddr = page_to_phys(page);
6262

63-
/* For now bus address is exactly same as paddr */
64-
*dma_handle = paddr;
63+
*dma_handle = plat_phys_to_dma(dev, paddr);
6564

6665
/* This is kernel Virtual address (0x7000_0000 based) */
6766
if (need_kvaddr) {
@@ -134,7 +133,7 @@ static dma_addr_t arc_dma_map_page(struct device *dev, struct page *page,
134133
{
135134
phys_addr_t paddr = page_to_phys(page) + offset;
136135
_dma_cache_sync(paddr, size, dir);
137-
return (dma_addr_t)paddr;
136+
return plat_phys_to_dma(dev, paddr);
138137
}
139138

140139
static int arc_dma_map_sg(struct device *dev, struct scatterlist *sg,
@@ -153,13 +152,13 @@ static int arc_dma_map_sg(struct device *dev, struct scatterlist *sg,
153152
static void arc_dma_sync_single_for_cpu(struct device *dev,
154153
dma_addr_t dma_handle, size_t size, enum dma_data_direction dir)
155154
{
156-
_dma_cache_sync(dma_handle, size, DMA_FROM_DEVICE);
155+
_dma_cache_sync(plat_dma_to_phys(dev, dma_handle), size, DMA_FROM_DEVICE);
157156
}
158157

159158
static void arc_dma_sync_single_for_device(struct device *dev,
160159
dma_addr_t dma_handle, size_t size, enum dma_data_direction dir)
161160
{
162-
_dma_cache_sync(dma_handle, size, DMA_TO_DEVICE);
161+
_dma_cache_sync(plat_dma_to_phys(dev, dma_handle), size, DMA_TO_DEVICE);
163162
}
164163

165164
static void arc_dma_sync_sg_for_cpu(struct device *dev,

0 commit comments

Comments
 (0)