dma/direct: Handle the memory encryption bit in common code
Give the basic phys_to_dma() and dma_to_phys() helpers a __-prefix and add the memory encryption mask to the non-prefixed versions. Use the __-prefixed versions directly instead of clearing the mask again in various places. Tested-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Joerg Roedel <joro@8bytes.org> Cc: Jon Mason <jdmason@kudzu.us> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Muli Ben-Yehuda <mulix@mulix.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: iommu@lists.linux-foundation.org Link: http://lkml.kernel.org/r/20180319103826.12853-13-hch@lst.de Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:

committed by
Ingo Molnar

parent
e7de6c7cc2
commit
b6e05477c1
@@ -69,8 +69,8 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
|
||||
return addr + size - 1 <= *dev->dma_mask;
|
||||
}
|
||||
|
||||
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 daddr);
|
||||
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 daddr);
|
||||
|
||||
struct dma_map_ops;
|
||||
extern const struct dma_map_ops *octeon_pci_dma_map_ops;
|
||||
|
@@ -25,13 +25,13 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
|
||||
return addr + size - 1 <= *dev->dma_mask;
|
||||
}
|
||||
|
||||
extern dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr);
|
||||
extern phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr);
|
||||
extern dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr);
|
||||
extern phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t daddr);
|
||||
static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr,
|
||||
size_t size)
|
||||
{
|
||||
#ifdef CONFIG_CPU_LOONGSON3
|
||||
return phys_to_dma(dev, virt_to_phys(addr));
|
||||
return __phys_to_dma(dev, virt_to_phys(addr));
|
||||
#else
|
||||
return virt_to_phys(addr) | 0x80000000;
|
||||
#endif
|
||||
@@ -41,7 +41,7 @@ static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,
|
||||
struct page *page)
|
||||
{
|
||||
#ifdef CONFIG_CPU_LOONGSON3
|
||||
return phys_to_dma(dev, page_to_phys(page));
|
||||
return __phys_to_dma(dev, page_to_phys(page));
|
||||
#else
|
||||
return page_to_phys(page) | 0x80000000;
|
||||
#endif
|
||||
@@ -51,7 +51,7 @@ static inline unsigned long plat_dma_addr_to_phys(struct device *dev,
|
||||
dma_addr_t dma_addr)
|
||||
{
|
||||
#if defined(CONFIG_CPU_LOONGSON3) && defined(CONFIG_64BIT)
|
||||
return dma_to_phys(dev, dma_addr);
|
||||
return __dma_to_phys(dev, dma_addr);
|
||||
#elif defined(CONFIG_CPU_LOONGSON2F) && defined(CONFIG_64BIT)
|
||||
return (dma_addr > 0x8fffffff) ? dma_addr : (dma_addr & 0x0fffffff);
|
||||
#else
|
||||
|
Reference in New Issue
Block a user