-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARM/dma-mapping: use the generic versions of dma_to_phys/phys_to_dma …
…by default Only the footbridge platforms provide their own DMA address translation helpers, so switch to the generic version for all other platforms, and consolidate the footbridge implementation to remove two levels of indirection. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Tested-by: Marc Zyngier <maz@kernel.org>
- Loading branch information
Christoph Hellwig
committed
Jul 7, 2022
1 parent
f9774cf
commit af6f23b
Showing
7 changed files
with
21 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef ASM_ARM_DMA_DIRECT_H | ||
#define ASM_ARM_DMA_DIRECT_H 1 | ||
|
||
#include <asm/memory.h> | ||
|
||
/* | ||
* dma_to_pfn/pfn_to_dma are architecture private | ||
* functions used internally by the DMA-mapping API to provide DMA | ||
* addresses. They must not be used by drivers. | ||
*/ | ||
static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn) | ||
{ | ||
if (dev && dev->dma_range_map) | ||
pfn = PFN_DOWN(translate_phys_to_dma(dev, PFN_PHYS(pfn))); | ||
return (dma_addr_t)__pfn_to_bus(pfn); | ||
} | ||
|
||
static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr) | ||
{ | ||
unsigned long pfn = __bus_to_pfn(addr); | ||
|
||
if (dev && dev->dma_range_map) | ||
pfn = PFN_DOWN(translate_dma_to_phys(dev, PFN_PHYS(pfn))); | ||
return pfn; | ||
} | ||
|
||
static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) | ||
{ | ||
unsigned int offset = paddr & ~PAGE_MASK; | ||
return pfn_to_dma(dev, __phys_to_pfn(paddr)) + offset; | ||
} | ||
|
||
static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr) | ||
{ | ||
unsigned int offset = dev_addr & ~PAGE_MASK; | ||
return __pfn_to_phys(dma_to_pfn(dev, dev_addr)) + offset; | ||
} | ||
|
||
#endif /* ASM_ARM_DMA_DIRECT_H */ | ||
#include <mach/dma-direct.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef MACH_FOOTBRIDGE_DMA_DIRECT_H | ||
#define MACH_FOOTBRIDGE_DMA_DIRECT_H 1 | ||
|
||
dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr); | ||
phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr); | ||
|
||
#endif /* MACH_FOOTBRIDGE_DMA_DIRECT_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters