Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1464540

[PATCH 1/1] ARM: dma: fix dma_max_pfn()

From Roger Quadros <rogerq@ti.com>
Newsgroups linux.kernel
Subject [PATCH 1/1] ARM: dma: fix dma_max_pfn()
Date 2016-08-17 14:10 +0200
Message-ID <s77Ps-PF-27@gated-at.bofh.it> (permalink)
References <s77Pr-PF-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Since commit 6ce0d2001692 ("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: 6ce0d2001692 ("ARM: dma: Use dma_pfn_offset for dma address translation")
Cc: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Olof Johansson <olof@lixom.net>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Reported-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 arch/arm/include/asm/dma-mapping.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
index d009f79..bf02dbd 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -111,7 +111,7 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
 /* The ARM override for dma_max_pfn() */
 static inline unsigned long dma_max_pfn(struct device *dev)
 {
-	return PHYS_PFN_OFFSET + dma_to_pfn(dev, *dev->dma_mask);
+	return dma_to_pfn(dev, *dev->dma_mask);
 }
 #define dma_max_pfn(dev) dma_max_pfn(dev)
 
-- 
2.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/1] ARM: Keystone: Fix USB Mass storage on K2E Roger Quadros <rogerq@ti.com> - 2016-08-17 14:10 +0200
  [PATCH 1/1] ARM: dma: fix dma_max_pfn() Roger Quadros <rogerq@ti.com> - 2016-08-17 14:10 +0200
    Re: [PATCH 1/1] ARM: dma: fix dma_max_pfn() Russell King - ARM Linux <linux@armlinux.org.uk> - 2016-08-18 16:30 +0200
      Re: [PATCH 1/1] ARM: dma: fix dma_max_pfn() Russell King - ARM Linux <linux@armlinux.org.uk> - 2016-08-19 02:50 +0200
        Re: [PATCH 1/1] ARM: dma: fix dma_max_pfn() Santosh Shilimkar <santosh.shilimkar@oracle.com> - 2016-08-19 04:10 +0200
          Re: [PATCH 1/1] ARM: dma: fix dma_max_pfn() Roger Quadros <rogerq@ti.com> - 2016-08-19 09:40 +0200
            Re: [PATCH 1/1] ARM: dma: fix dma_max_pfn() Santosh Shilimkar <santosh.shilimkar@oracle.com> - 2016-08-19 18:40 +0200
      Re: [PATCH 1/1] ARM: dma: fix dma_max_pfn() Santosh Shilimkar <santosh.shilimkar@oracle.com> - 2016-08-19 03:00 +0200

csiph-web