Skip to content

Commit d248220

Browse files
Roger QuadrosRussell King
authored andcommitted
ARM: 8617/1: dma: fix dma_max_pfn()
Since commit 6ce0d20 ("ARM: dma: Use dma_pfn_offset for dma address translation"), dma_to_pfn() already returns the PFN with the physical memory start offset so we don't need to add it again. This fixes USB mass storage lock-up problem on systems that can't do DMA over the entire physical memory range (e.g.) Keystone 2 systems with 4GB RAM can only do DMA over the first 2GB. [K2E-EVM]. What happens there is that without this patch SCSI layer sets a wrong bounce buffer limit in scsi_calculate_bounce_limit() for the USB mass storage device. dma_max_pfn() evaluates to 0x8fffff and bounce_limit is set to 0x8fffff000 whereas maximum DMA'ble physical memory on Keystone 2 is 0x87fffffff. This results in non DMA'ble pages being given to the USB controller and hence the lock-up. NOTE: in the above case, USB-SCSI-device's dma_pfn_offset was showing as 0. This should have really been 0x780000 as on K2e, LOWMEM_START is 0x80000000 and HIGHMEM_START is 0x800000000. DMA zone is 2GB so dma_max_pfn should be 0x87ffff. The incorrect dma_pfn_offset for the USB storage device is because USB devices are not correctly inheriting the dma_pfn_offset from the USB host controller. This will be fixed by a separate patch. Fixes: 6ce0d20 ("ARM: dma: Use dma_pfn_offset for dma address translation") Cc: [email protected] Cc: Greg Kroah-Hartman <[email protected]> Cc: Santosh Shilimkar <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Olof Johansson <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Linus Walleij <[email protected]> Reported-by: Grygorii Strashko <[email protected]> Signed-off-by: Roger Quadros <[email protected]> Signed-off-by: Russell King <[email protected]>
1 parent ba6dea4 commit d248220

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
111111
/* The ARM override for dma_max_pfn() */
112112
static inline unsigned long dma_max_pfn(struct device *dev)
113113
{
114-
return PHYS_PFN_OFFSET + dma_to_pfn(dev, *dev->dma_mask);
114+
return dma_to_pfn(dev, *dev->dma_mask);
115115
}
116116
#define dma_max_pfn(dev) dma_max_pfn(dev)
117117

0 commit comments

Comments
 (0)