Skip to content

Commit 3048b2e

Browse files
notropopcornmix
authored andcommitted
fixup: restore dma-mapping.h
dwc_otg has been fixed, so no need to revert 6ce0d20: ARM: dma: Use dma_pfn_offset for dma address translation The pfn_to_dma/dma_to_pfn changes that came with that commit is needed to use the 'dma-ranges' DT property on ARCH_BCM2835. dma-ranges is needed by bcm2708_fb and vchiq on ARCH_BCM2835. If not the mailbox call fails to hand over the correct bus address to videocore. Signed-off-by: Noralf Trønnes <[email protected]>
1 parent d54112e commit 3048b2e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,37 @@ static inline int dma_set_mask(struct device *dev, u64 mask)
5858
#ifndef __arch_pfn_to_dma
5959
static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
6060
{
61+
if (dev)
62+
pfn -= dev->dma_pfn_offset;
6163
return (dma_addr_t)__pfn_to_bus(pfn);
6264
}
6365

6466
static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
6567
{
66-
return __bus_to_pfn(addr);
68+
unsigned long pfn = __bus_to_pfn(addr);
69+
70+
if (dev)
71+
pfn += dev->dma_pfn_offset;
72+
73+
return pfn;
6774
}
6875

6976
static inline void *dma_to_virt(struct device *dev, dma_addr_t addr)
7077
{
78+
if (dev) {
79+
unsigned long pfn = dma_to_pfn(dev, addr);
80+
81+
return phys_to_virt(__pfn_to_phys(pfn));
82+
}
83+
7184
return (void *)__bus_to_virt((unsigned long)addr);
7285
}
7386

7487
static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
7588
{
89+
if (dev)
90+
return pfn_to_dma(dev, virt_to_pfn(addr));
91+
7692
return (dma_addr_t)__virt_to_bus((unsigned long)(addr));
7793
}
7894

0 commit comments

Comments
 (0)