All of lore.kernel.org
 help / color / mirror / Atom feed
* RFC: remove the need for <asm/dma-direct.h> on ARM
@ 2020-09-17 17:32 ` Christoph Hellwig
  0 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-17 17:32 UTC (permalink / raw)
  To: Russell King
  Cc: Aaro Koskinen, Tony Lindgren, Robin Murphy, iommu,
	linux-arm-kernel, linux-kernel, linux-omap, linux-usb

Hi Russell,

as Robin pointed out there is not much need for the ARM specific
routines to translated to and from a dma_addr_t given that we have
the dma offset (and now offset range) functionality.  This series
converts ARM over to the generic helpers.  This has only been tested
on qemu, and specificall not on omap1 and footbridge given that I
do not have the hardware.

The patches are on to of the dma-mapping for-next tree, to make
review and testing easier a git tree is also available here:

    git://git.infradead.org/users/hch/misc.git arm-dma-direct-cleanups

Gitweb:

    http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/arm-dma-direct-cleanups


Diffstat:
 arch/arm/include/asm/dma-direct.h                |   66 -----------------------
 b/arch/arm/Kconfig                               |    1 
 b/arch/arm/common/dmabounce.c                    |   14 ++--
 b/arch/arm/include/asm/memory.h                  |    2 
 b/arch/arm/mach-footbridge/cats-pci.c            |    7 +-
 b/arch/arm/mach-footbridge/common.c              |   40 ++++++++++---
 b/arch/arm/mach-footbridge/common.h              |    3 +
 b/arch/arm/mach-footbridge/ebsa285-pci.c         |    7 +-
 b/arch/arm/mach-footbridge/include/mach/memory.h |    4 -
 b/arch/arm/mach-footbridge/netwinder-pci.c       |    7 +-
 b/arch/arm/mach-footbridge/personal-pci.c        |    7 +-
 b/arch/arm/mach-omap1/include/mach/memory.h      |   31 ----------
 b/arch/arm/mach-omap1/usb.c                      |   22 +++++++
 b/arch/arm/mm/dma-mapping.c                      |   20 +++---
 14 files changed, 91 insertions(+), 140 deletions(-)

^ permalink raw reply	[flat|nested] 42+ messages in thread

* RFC: remove the need for <asm/dma-direct.h> on ARM
@ 2020-09-17 17:32 ` Christoph Hellwig
  0 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-17 17:32 UTC (permalink / raw)
  To: Russell King
  Cc: Aaro Koskinen, Tony Lindgren, linux-usb, linux-kernel, iommu,
	linux-omap, Robin Murphy, linux-arm-kernel

Hi Russell,

as Robin pointed out there is not much need for the ARM specific
routines to translated to and from a dma_addr_t given that we have
the dma offset (and now offset range) functionality.  This series
converts ARM over to the generic helpers.  This has only been tested
on qemu, and specificall not on omap1 and footbridge given that I
do not have the hardware.

The patches are on to of the dma-mapping for-next tree, to make
review and testing easier a git tree is also available here:

    git://git.infradead.org/users/hch/misc.git arm-dma-direct-cleanups

Gitweb:

    http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/arm-dma-direct-cleanups


Diffstat:
 arch/arm/include/asm/dma-direct.h                |   66 -----------------------
 b/arch/arm/Kconfig                               |    1 
 b/arch/arm/common/dmabounce.c                    |   14 ++--
 b/arch/arm/include/asm/memory.h                  |    2 
 b/arch/arm/mach-footbridge/cats-pci.c            |    7 +-
 b/arch/arm/mach-footbridge/common.c              |   40 ++++++++++---
 b/arch/arm/mach-footbridge/common.h              |    3 +
 b/arch/arm/mach-footbridge/ebsa285-pci.c         |    7 +-
 b/arch/arm/mach-footbridge/include/mach/memory.h |    4 -
 b/arch/arm/mach-footbridge/netwinder-pci.c       |    7 +-
 b/arch/arm/mach-footbridge/personal-pci.c        |    7 +-
 b/arch/arm/mach-omap1/include/mach/memory.h      |   31 ----------
 b/arch/arm/mach-omap1/usb.c                      |   22 +++++++
 b/arch/arm/mm/dma-mapping.c                      |   20 +++---
 14 files changed, 91 insertions(+), 140 deletions(-)
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 42+ messages in thread

* RFC: remove the need for <asm/dma-direct.h> on ARM
@ 2020-09-17 17:32 ` Christoph Hellwig
  0 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-17 17:32 UTC (permalink / raw)
  To: Russell King
  Cc: Aaro Koskinen, Tony Lindgren, linux-usb, linux-kernel, iommu,
	linux-omap, Robin Murphy, linux-arm-kernel

Hi Russell,

as Robin pointed out there is not much need for the ARM specific
routines to translated to and from a dma_addr_t given that we have
the dma offset (and now offset range) functionality.  This series
converts ARM over to the generic helpers.  This has only been tested
on qemu, and specificall not on omap1 and footbridge given that I
do not have the hardware.

The patches are on to of the dma-mapping for-next tree, to make
review and testing easier a git tree is also available here:

    git://git.infradead.org/users/hch/misc.git arm-dma-direct-cleanups

Gitweb:

    http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/arm-dma-direct-cleanups


Diffstat:
 arch/arm/include/asm/dma-direct.h                |   66 -----------------------
 b/arch/arm/Kconfig                               |    1 
 b/arch/arm/common/dmabounce.c                    |   14 ++--
 b/arch/arm/include/asm/memory.h                  |    2 
 b/arch/arm/mach-footbridge/cats-pci.c            |    7 +-
 b/arch/arm/mach-footbridge/common.c              |   40 ++++++++++---
 b/arch/arm/mach-footbridge/common.h              |    3 +
 b/arch/arm/mach-footbridge/ebsa285-pci.c         |    7 +-
 b/arch/arm/mach-footbridge/include/mach/memory.h |    4 -
 b/arch/arm/mach-footbridge/netwinder-pci.c       |    7 +-
 b/arch/arm/mach-footbridge/personal-pci.c        |    7 +-
 b/arch/arm/mach-omap1/include/mach/memory.h      |   31 ----------
 b/arch/arm/mach-omap1/usb.c                      |   22 +++++++
 b/arch/arm/mm/dma-mapping.c                      |   20 +++---
 14 files changed, 91 insertions(+), 140 deletions(-)

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets
  2020-09-17 17:32 ` Christoph Hellwig
  (?)
@ 2020-09-17 17:32   ` Christoph Hellwig
  -1 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-17 17:32 UTC (permalink / raw)
  To: Russell King
  Cc: Aaro Koskinen, Tony Lindgren, Robin Murphy, iommu,
	linux-arm-kernel, linux-kernel, linux-omap, linux-usb

Switch the omap1510 platform ohci device to use dma_direct_set_offset
to set the DMA offset instead of using direct hooks into the DMA
mapping code and remove the now unused hooks.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/arm/include/asm/dma-direct.h         | 18 -------------
 arch/arm/mach-omap1/include/mach/memory.h | 31 -----------------------
 arch/arm/mach-omap1/usb.c                 | 22 ++++++++++++++++
 3 files changed, 22 insertions(+), 49 deletions(-)

diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h
index 436544aeb83405..77fcb7ee5ec907 100644
--- a/arch/arm/include/asm/dma-direct.h
+++ b/arch/arm/include/asm/dma-direct.h
@@ -9,7 +9,6 @@
  * functions used internally by the DMA-mapping API to provide DMA
  * addresses. They must not be used by drivers.
  */
-#ifndef __arch_pfn_to_dma
 static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
 {
 	if (dev && dev->dma_range_map)
@@ -34,23 +33,6 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
 	return (dma_addr_t)__virt_to_bus((unsigned long)(addr));
 }
 
-#else
-static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
-{
-	return __arch_pfn_to_dma(dev, pfn);
-}
-
-static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
-{
-	return __arch_dma_to_pfn(dev, addr);
-}
-
-static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
-{
-	return __arch_virt_to_dma(dev, addr);
-}
-#endif
-
 static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
 {
 	unsigned int offset = paddr & ~PAGE_MASK;
diff --git a/arch/arm/mach-omap1/include/mach/memory.h b/arch/arm/mach-omap1/include/mach/memory.h
index 1142560e0078f5..36bc0000cb6ab8 100644
--- a/arch/arm/mach-omap1/include/mach/memory.h
+++ b/arch/arm/mach-omap1/include/mach/memory.h
@@ -14,42 +14,11 @@
  * OMAP-1510 bus address is translated into a Local Bus address if the
  * OMAP bus type is lbus. We do the address translation based on the
  * device overriding the defaults used in the dma-mapping API.
- * Note that the is_lbus_device() test is not very efficient on 1510
- * because of the strncmp().
  */
-#if defined(CONFIG_ARCH_OMAP15XX) && !defined(__ASSEMBLER__)
 
 /*
  * OMAP-1510 Local Bus address offset
  */
 #define OMAP1510_LB_OFFSET	UL(0x30000000)
 
-#define virt_to_lbus(x)		((x) - PAGE_OFFSET + OMAP1510_LB_OFFSET)
-#define lbus_to_virt(x)		((x) - OMAP1510_LB_OFFSET + PAGE_OFFSET)
-#define is_lbus_device(dev)	(cpu_is_omap15xx() && dev && (strncmp(dev_name(dev), "ohci", 4) == 0))
-
-#define __arch_pfn_to_dma(dev, pfn)	\
-	({ dma_addr_t __dma = __pfn_to_phys(pfn); \
-	   if (is_lbus_device(dev)) \
-		__dma = __dma - PHYS_OFFSET + OMAP1510_LB_OFFSET; \
-	   __dma; })
-
-#define __arch_dma_to_pfn(dev, addr)	\
-	({ dma_addr_t __dma = addr;				\
-	   if (is_lbus_device(dev))				\
-		__dma += PHYS_OFFSET - OMAP1510_LB_OFFSET;	\
-	   __phys_to_pfn(__dma);				\
-	})
-
-#define __arch_dma_to_virt(dev, addr)	({ (void *) (is_lbus_device(dev) ? \
-						lbus_to_virt(addr) : \
-						__phys_to_virt(addr)); })
-
-#define __arch_virt_to_dma(dev, addr)	({ unsigned long __addr = (unsigned long)(addr); \
-					   (dma_addr_t) (is_lbus_device(dev) ? \
-						virt_to_lbus(__addr) : \
-						__virt_to_phys(__addr)); })
-
-#endif	/* CONFIG_ARCH_OMAP15XX */
-
 #endif
diff --git a/arch/arm/mach-omap1/usb.c b/arch/arm/mach-omap1/usb.c
index d8e9bbda8f7bdd..ba8566204ea9f4 100644
--- a/arch/arm/mach-omap1/usb.c
+++ b/arch/arm/mach-omap1/usb.c
@@ -9,6 +9,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
+#include <linux/dma-mapping.h>
 #include <linux/io.h>
 
 #include <asm/irq.h>
@@ -542,6 +543,25 @@ static u32 __init omap1_usb2_init(unsigned nwires, unsigned alt_pingroup)
 /* ULPD_APLL_CTRL */
 #define APLL_NDPLL_SWITCH	(1 << 0)
 
+static int omap_1510_usb_ohci_notifier(struct notifier_block *nb,
+		unsigned long event, void *data)
+{
+	struct device *dev = data;
+
+	if (event != BUS_NOTIFY_ADD_DEVICE)
+		return NOTIFY_DONE;
+
+	if (strncmp(dev_name(dev), "ohci", 4) == 0 &&
+	    dma_direct_set_offset(dev, PHYS_OFFSET, OMAP1510_LB_OFFSET,
+			(u64)-1))
+		WARN_ONCE(1, "failed to set DMA offset\n");
+	return NOTIFY_OK;
+}
+
+static struct notifier_block omap_1510_usb_ohci_nb = {
+	.notifier_call		= omap_1510_usb_ohci_notifier,
+};
+
 static void __init omap_1510_usb_init(struct omap_usb_config *config)
 {
 	unsigned int val;
@@ -600,6 +620,8 @@ static void __init omap_1510_usb_init(struct omap_usb_config *config)
 	if (config->register_host) {
 		int status;
 
+		bus_register_notifier(&platform_bus_type,
+				      &omap_1510_usb_ohci_nb);
 		ohci_device.dev.platform_data = config;
 		status = platform_device_register(&ohci_device);
 		if (status)
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets
@ 2020-09-17 17:32   ` Christoph Hellwig
  0 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-17 17:32 UTC (permalink / raw)
  To: Russell King
  Cc: Aaro Koskinen, Tony Lindgren, linux-usb, linux-kernel, iommu,
	linux-omap, Robin Murphy, linux-arm-kernel

Switch the omap1510 platform ohci device to use dma_direct_set_offset
to set the DMA offset instead of using direct hooks into the DMA
mapping code and remove the now unused hooks.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/arm/include/asm/dma-direct.h         | 18 -------------
 arch/arm/mach-omap1/include/mach/memory.h | 31 -----------------------
 arch/arm/mach-omap1/usb.c                 | 22 ++++++++++++++++
 3 files changed, 22 insertions(+), 49 deletions(-)

diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h
index 436544aeb83405..77fcb7ee5ec907 100644
--- a/arch/arm/include/asm/dma-direct.h
+++ b/arch/arm/include/asm/dma-direct.h
@@ -9,7 +9,6 @@
  * functions used internally by the DMA-mapping API to provide DMA
  * addresses. They must not be used by drivers.
  */
-#ifndef __arch_pfn_to_dma
 static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
 {
 	if (dev && dev->dma_range_map)
@@ -34,23 +33,6 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
 	return (dma_addr_t)__virt_to_bus((unsigned long)(addr));
 }
 
-#else
-static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
-{
-	return __arch_pfn_to_dma(dev, pfn);
-}
-
-static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
-{
-	return __arch_dma_to_pfn(dev, addr);
-}
-
-static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
-{
-	return __arch_virt_to_dma(dev, addr);
-}
-#endif
-
 static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
 {
 	unsigned int offset = paddr & ~PAGE_MASK;
diff --git a/arch/arm/mach-omap1/include/mach/memory.h b/arch/arm/mach-omap1/include/mach/memory.h
index 1142560e0078f5..36bc0000cb6ab8 100644
--- a/arch/arm/mach-omap1/include/mach/memory.h
+++ b/arch/arm/mach-omap1/include/mach/memory.h
@@ -14,42 +14,11 @@
  * OMAP-1510 bus address is translated into a Local Bus address if the
  * OMAP bus type is lbus. We do the address translation based on the
  * device overriding the defaults used in the dma-mapping API.
- * Note that the is_lbus_device() test is not very efficient on 1510
- * because of the strncmp().
  */
-#if defined(CONFIG_ARCH_OMAP15XX) && !defined(__ASSEMBLER__)
 
 /*
  * OMAP-1510 Local Bus address offset
  */
 #define OMAP1510_LB_OFFSET	UL(0x30000000)
 
-#define virt_to_lbus(x)		((x) - PAGE_OFFSET + OMAP1510_LB_OFFSET)
-#define lbus_to_virt(x)		((x) - OMAP1510_LB_OFFSET + PAGE_OFFSET)
-#define is_lbus_device(dev)	(cpu_is_omap15xx() && dev && (strncmp(dev_name(dev), "ohci", 4) == 0))
-
-#define __arch_pfn_to_dma(dev, pfn)	\
-	({ dma_addr_t __dma = __pfn_to_phys(pfn); \
-	   if (is_lbus_device(dev)) \
-		__dma = __dma - PHYS_OFFSET + OMAP1510_LB_OFFSET; \
-	   __dma; })
-
-#define __arch_dma_to_pfn(dev, addr)	\
-	({ dma_addr_t __dma = addr;				\
-	   if (is_lbus_device(dev))				\
-		__dma += PHYS_OFFSET - OMAP1510_LB_OFFSET;	\
-	   __phys_to_pfn(__dma);				\
-	})
-
-#define __arch_dma_to_virt(dev, addr)	({ (void *) (is_lbus_device(dev) ? \
-						lbus_to_virt(addr) : \
-						__phys_to_virt(addr)); })
-
-#define __arch_virt_to_dma(dev, addr)	({ unsigned long __addr = (unsigned long)(addr); \
-					   (dma_addr_t) (is_lbus_device(dev) ? \
-						virt_to_lbus(__addr) : \
-						__virt_to_phys(__addr)); })
-
-#endif	/* CONFIG_ARCH_OMAP15XX */
-
 #endif
diff --git a/arch/arm/mach-omap1/usb.c b/arch/arm/mach-omap1/usb.c
index d8e9bbda8f7bdd..ba8566204ea9f4 100644
--- a/arch/arm/mach-omap1/usb.c
+++ b/arch/arm/mach-omap1/usb.c
@@ -9,6 +9,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
+#include <linux/dma-mapping.h>
 #include <linux/io.h>
 
 #include <asm/irq.h>
@@ -542,6 +543,25 @@ static u32 __init omap1_usb2_init(unsigned nwires, unsigned alt_pingroup)
 /* ULPD_APLL_CTRL */
 #define APLL_NDPLL_SWITCH	(1 << 0)
 
+static int omap_1510_usb_ohci_notifier(struct notifier_block *nb,
+		unsigned long event, void *data)
+{
+	struct device *dev = data;
+
+	if (event != BUS_NOTIFY_ADD_DEVICE)
+		return NOTIFY_DONE;
+
+	if (strncmp(dev_name(dev), "ohci", 4) == 0 &&
+	    dma_direct_set_offset(dev, PHYS_OFFSET, OMAP1510_LB_OFFSET,
+			(u64)-1))
+		WARN_ONCE(1, "failed to set DMA offset\n");
+	return NOTIFY_OK;
+}
+
+static struct notifier_block omap_1510_usb_ohci_nb = {
+	.notifier_call		= omap_1510_usb_ohci_notifier,
+};
+
 static void __init omap_1510_usb_init(struct omap_usb_config *config)
 {
 	unsigned int val;
@@ -600,6 +620,8 @@ static void __init omap_1510_usb_init(struct omap_usb_config *config)
 	if (config->register_host) {
 		int status;
 
+		bus_register_notifier(&platform_bus_type,
+				      &omap_1510_usb_ohci_nb);
 		ohci_device.dev.platform_data = config;
 		status = platform_device_register(&ohci_device);
 		if (status)
-- 
2.28.0

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets
@ 2020-09-17 17:32   ` Christoph Hellwig
  0 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-17 17:32 UTC (permalink / raw)
  To: Russell King
  Cc: Aaro Koskinen, Tony Lindgren, linux-usb, linux-kernel, iommu,
	linux-omap, Robin Murphy, linux-arm-kernel

Switch the omap1510 platform ohci device to use dma_direct_set_offset
to set the DMA offset instead of using direct hooks into the DMA
mapping code and remove the now unused hooks.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/arm/include/asm/dma-direct.h         | 18 -------------
 arch/arm/mach-omap1/include/mach/memory.h | 31 -----------------------
 arch/arm/mach-omap1/usb.c                 | 22 ++++++++++++++++
 3 files changed, 22 insertions(+), 49 deletions(-)

diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h
index 436544aeb83405..77fcb7ee5ec907 100644
--- a/arch/arm/include/asm/dma-direct.h
+++ b/arch/arm/include/asm/dma-direct.h
@@ -9,7 +9,6 @@
  * functions used internally by the DMA-mapping API to provide DMA
  * addresses. They must not be used by drivers.
  */
-#ifndef __arch_pfn_to_dma
 static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
 {
 	if (dev && dev->dma_range_map)
@@ -34,23 +33,6 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
 	return (dma_addr_t)__virt_to_bus((unsigned long)(addr));
 }
 
-#else
-static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
-{
-	return __arch_pfn_to_dma(dev, pfn);
-}
-
-static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
-{
-	return __arch_dma_to_pfn(dev, addr);
-}
-
-static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
-{
-	return __arch_virt_to_dma(dev, addr);
-}
-#endif
-
 static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
 {
 	unsigned int offset = paddr & ~PAGE_MASK;
diff --git a/arch/arm/mach-omap1/include/mach/memory.h b/arch/arm/mach-omap1/include/mach/memory.h
index 1142560e0078f5..36bc0000cb6ab8 100644
--- a/arch/arm/mach-omap1/include/mach/memory.h
+++ b/arch/arm/mach-omap1/include/mach/memory.h
@@ -14,42 +14,11 @@
  * OMAP-1510 bus address is translated into a Local Bus address if the
  * OMAP bus type is lbus. We do the address translation based on the
  * device overriding the defaults used in the dma-mapping API.
- * Note that the is_lbus_device() test is not very efficient on 1510
- * because of the strncmp().
  */
-#if defined(CONFIG_ARCH_OMAP15XX) && !defined(__ASSEMBLER__)
 
 /*
  * OMAP-1510 Local Bus address offset
  */
 #define OMAP1510_LB_OFFSET	UL(0x30000000)
 
-#define virt_to_lbus(x)		((x) - PAGE_OFFSET + OMAP1510_LB_OFFSET)
-#define lbus_to_virt(x)		((x) - OMAP1510_LB_OFFSET + PAGE_OFFSET)
-#define is_lbus_device(dev)	(cpu_is_omap15xx() && dev && (strncmp(dev_name(dev), "ohci", 4) == 0))
-
-#define __arch_pfn_to_dma(dev, pfn)	\
-	({ dma_addr_t __dma = __pfn_to_phys(pfn); \
-	   if (is_lbus_device(dev)) \
-		__dma = __dma - PHYS_OFFSET + OMAP1510_LB_OFFSET; \
-	   __dma; })
-
-#define __arch_dma_to_pfn(dev, addr)	\
-	({ dma_addr_t __dma = addr;				\
-	   if (is_lbus_device(dev))				\
-		__dma += PHYS_OFFSET - OMAP1510_LB_OFFSET;	\
-	   __phys_to_pfn(__dma);				\
-	})
-
-#define __arch_dma_to_virt(dev, addr)	({ (void *) (is_lbus_device(dev) ? \
-						lbus_to_virt(addr) : \
-						__phys_to_virt(addr)); })
-
-#define __arch_virt_to_dma(dev, addr)	({ unsigned long __addr = (unsigned long)(addr); \
-					   (dma_addr_t) (is_lbus_device(dev) ? \
-						virt_to_lbus(__addr) : \
-						__virt_to_phys(__addr)); })
-
-#endif	/* CONFIG_ARCH_OMAP15XX */
-
 #endif
diff --git a/arch/arm/mach-omap1/usb.c b/arch/arm/mach-omap1/usb.c
index d8e9bbda8f7bdd..ba8566204ea9f4 100644
--- a/arch/arm/mach-omap1/usb.c
+++ b/arch/arm/mach-omap1/usb.c
@@ -9,6 +9,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
+#include <linux/dma-mapping.h>
 #include <linux/io.h>
 
 #include <asm/irq.h>
@@ -542,6 +543,25 @@ static u32 __init omap1_usb2_init(unsigned nwires, unsigned alt_pingroup)
 /* ULPD_APLL_CTRL */
 #define APLL_NDPLL_SWITCH	(1 << 0)
 
+static int omap_1510_usb_ohci_notifier(struct notifier_block *nb,
+		unsigned long event, void *data)
+{
+	struct device *dev = data;
+
+	if (event != BUS_NOTIFY_ADD_DEVICE)
+		return NOTIFY_DONE;
+
+	if (strncmp(dev_name(dev), "ohci", 4) == 0 &&
+	    dma_direct_set_offset(dev, PHYS_OFFSET, OMAP1510_LB_OFFSET,
+			(u64)-1))
+		WARN_ONCE(1, "failed to set DMA offset\n");
+	return NOTIFY_OK;
+}
+
+static struct notifier_block omap_1510_usb_ohci_nb = {
+	.notifier_call		= omap_1510_usb_ohci_notifier,
+};
+
 static void __init omap_1510_usb_init(struct omap_usb_config *config)
 {
 	unsigned int val;
@@ -600,6 +620,8 @@ static void __init omap_1510_usb_init(struct omap_usb_config *config)
 	if (config->register_host) {
 		int status;
 
+		bus_register_notifier(&platform_bus_type,
+				      &omap_1510_usb_ohci_nb);
 		ohci_device.dev.platform_data = config;
 		status = platform_device_register(&ohci_device);
 		if (status)
-- 
2.28.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 2/4] ARM/footbridge: switch to use dma_direct_set_offset for lbus DMA offsets
  2020-09-17 17:32 ` Christoph Hellwig
  (?)
@ 2020-09-17 17:32   ` Christoph Hellwig
  -1 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-17 17:32 UTC (permalink / raw)
  To: Russell King
  Cc: Aaro Koskinen, Tony Lindgren, Robin Murphy, iommu,
	linux-arm-kernel, linux-kernel, linux-omap, linux-usb

Switch the footbridge PCI devices to use dma_direct_set_offset to set the
DMA offset instead of using direct hooks into the DMA mapping code and
remove the now unused hooks.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/arm/include/asm/dma-direct.h             |  4 +-
 arch/arm/include/asm/memory.h                 |  2 -
 arch/arm/mach-footbridge/cats-pci.c           |  7 +++-
 arch/arm/mach-footbridge/common.c             | 40 ++++++++++++++-----
 arch/arm/mach-footbridge/common.h             |  3 ++
 arch/arm/mach-footbridge/ebsa285-pci.c        |  7 +++-
 .../arm/mach-footbridge/include/mach/memory.h |  4 --
 arch/arm/mach-footbridge/netwinder-pci.c      |  7 +++-
 arch/arm/mach-footbridge/personal-pci.c       |  7 +++-
 9 files changed, 54 insertions(+), 27 deletions(-)

diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h
index 77fcb7ee5ec907..1f04a5e1c615de 100644
--- a/arch/arm/include/asm/dma-direct.h
+++ b/arch/arm/include/asm/dma-direct.h
@@ -13,12 +13,12 @@ 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);
+	return (dma_addr_t)__pfn_to_phys(pfn);
 }
 
 static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
 {
-	unsigned long pfn = __bus_to_pfn(addr);
+	unsigned long pfn = __phys_to_pfn(addr);
 
 	if (dev && dev->dma_range_map)
 		pfn = PFN_DOWN(translate_dma_to_phys(dev, PFN_PHYS(pfn)));
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index 99035b5891ef44..af612606136ff2 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -346,8 +346,6 @@ static inline unsigned long __virt_to_idmap(unsigned long x)
 #ifndef __virt_to_bus
 #define __virt_to_bus	__virt_to_phys
 #define __bus_to_virt	__phys_to_virt
-#define __pfn_to_bus(x)	__pfn_to_phys(x)
-#define __bus_to_pfn(x)	__phys_to_pfn(x)
 #endif
 
 /*
diff --git a/arch/arm/mach-footbridge/cats-pci.c b/arch/arm/mach-footbridge/cats-pci.c
index 0b2fd7e2e9b429..257cb068ac0c5b 100644
--- a/arch/arm/mach-footbridge/cats-pci.c
+++ b/arch/arm/mach-footbridge/cats-pci.c
@@ -13,6 +13,7 @@
 #include <asm/irq.h>
 #include <asm/mach/pci.h>
 #include <asm/mach-types.h>
+#include "common.h"
 
 /* cats host-specific stuff */
 static int irqmap_cats[] __initdata = { IRQ_PCI, IRQ_IN0, IRQ_IN1, IRQ_IN3 };
@@ -56,8 +57,10 @@ static struct hw_pci cats_pci __initdata = {
 
 static int __init cats_pci_init(void)
 {
-	if (machine_is_cats())
-		pci_common_init(&cats_pci);
+	if (!machine_is_cats())
+		return 0;
+	bus_register_notifier(&pci_bus_type, &footbridge_pci_dma_nb);
+	pci_common_init(&cats_pci);
 	return 0;
 }
 
diff --git a/arch/arm/mach-footbridge/common.c b/arch/arm/mach-footbridge/common.c
index eee095f0e2f6c2..dc14d72ca7bb3f 100644
--- a/arch/arm/mach-footbridge/common.c
+++ b/arch/arm/mach-footbridge/common.c
@@ -12,6 +12,8 @@
 #include <linux/init.h>
 #include <linux/io.h>
 #include <linux/spinlock.h>
+#include <linux/device/bus.h>
+#include <linux/dma-mapping.h>
 #include <video/vga.h>
 
 #include <asm/page.h>
@@ -219,8 +221,17 @@ void footbridge_restart(enum reboot_mode mode, const char *cmd)
 	}
 }
 
-#ifdef CONFIG_FOOTBRIDGE_ADDIN
-
+#ifdef CONFIG_FOOTBRIDGE_HOST
+/*
+ * The footbridge is programmed to expose the system RAM at 0xe0000000.
+ * The requirement is that the RAM isn't placed at bus address 0, which
+ * would clash with VGA cards.
+ */
+static inline unsigned long fb_bus_sdram_offset(void)
+{
+	return 0xe0000000;
+}
+#elif defined(CONFIG_FOOTBRIDGE_ADDIN)
 static inline unsigned long fb_bus_sdram_offset(void)
 {
 	return *CSR_PCISDRAMBASE & 0xfffffff0;
@@ -248,17 +259,24 @@ unsigned long __bus_to_virt(unsigned long res)
 	return res;
 }
 EXPORT_SYMBOL(__bus_to_virt);
+#else
+#error "Undefined footbridge mode"
+#endif
 
-unsigned long __pfn_to_bus(unsigned long pfn)
+static int footbridge_pci_dma_notifier(struct notifier_block *nb,
+		unsigned long event, void *data)
 {
-	return __pfn_to_phys(pfn) + (fb_bus_sdram_offset() - PHYS_OFFSET);
-}
-EXPORT_SYMBOL(__pfn_to_bus);
+	struct device *dev = data;
 
-unsigned long __bus_to_pfn(unsigned long bus)
-{
-	return __phys_to_pfn(bus - (fb_bus_sdram_offset() - PHYS_OFFSET));
+	if (event != BUS_NOTIFY_ADD_DEVICE)
+		return NOTIFY_DONE;
+
+	if (dma_direct_set_offset(dev, PAGE_OFFSET, fb_bus_sdram_offset(),
+			(u64)-1))
+		WARN_ONCE(1, "failed to set DMA offset\n");
+	return NOTIFY_OK;
 }
-EXPORT_SYMBOL(__bus_to_pfn);
 
-#endif
+struct notifier_block footbridge_pci_dma_nb = {
+	.notifier_call		= footbridge_pci_dma_notifier,
+};
diff --git a/arch/arm/mach-footbridge/common.h b/arch/arm/mach-footbridge/common.h
index e12587db59c4c8..1773a4183b580c 100644
--- a/arch/arm/mach-footbridge/common.h
+++ b/arch/arm/mach-footbridge/common.h
@@ -1,4 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+#include <linux/notifier.h>
 #include <linux/reboot.h>
 
 extern void footbridge_timer_init(void);
@@ -13,3 +14,5 @@ extern void isa_init_irq(unsigned int irq);
 extern void footbridge_restart(enum reboot_mode, const char *);
 
 extern void footbridge_sched_clock(void);
+
+extern struct notifier_block footbridge_pci_dma_nb;
diff --git a/arch/arm/mach-footbridge/ebsa285-pci.c b/arch/arm/mach-footbridge/ebsa285-pci.c
index 6f28aaa9ca79b2..80b4f5ace20b35 100644
--- a/arch/arm/mach-footbridge/ebsa285-pci.c
+++ b/arch/arm/mach-footbridge/ebsa285-pci.c
@@ -13,6 +13,7 @@
 #include <asm/irq.h>
 #include <asm/mach/pci.h>
 #include <asm/mach-types.h>
+#include "common.h"
 
 static int irqmap_ebsa285[] __initdata = { IRQ_IN3, IRQ_IN1, IRQ_IN0, IRQ_PCI };
 
@@ -40,8 +41,10 @@ static struct hw_pci ebsa285_pci __initdata = {
 
 static int __init ebsa285_init_pci(void)
 {
-	if (machine_is_ebsa285())
-		pci_common_init(&ebsa285_pci);
+	if (!machine_is_ebsa285())
+		return 0;
+	bus_register_notifier(&pci_bus_type, &footbridge_pci_dma_nb);
+	pci_common_init(&ebsa285_pci);
 	return 0;
 }
 
diff --git a/arch/arm/mach-footbridge/include/mach/memory.h b/arch/arm/mach-footbridge/include/mach/memory.h
index 46fd4a8872b9a3..3a5d2638c18f88 100644
--- a/arch/arm/mach-footbridge/include/mach/memory.h
+++ b/arch/arm/mach-footbridge/include/mach/memory.h
@@ -26,8 +26,6 @@
 #ifndef __ASSEMBLY__
 extern unsigned long __virt_to_bus(unsigned long);
 extern unsigned long __bus_to_virt(unsigned long);
-extern unsigned long __pfn_to_bus(unsigned long);
-extern unsigned long __bus_to_pfn(unsigned long);
 #endif
 #define __virt_to_bus	__virt_to_bus
 #define __bus_to_virt	__bus_to_virt
@@ -42,8 +40,6 @@ extern unsigned long __bus_to_pfn(unsigned long);
 #define BUS_OFFSET		0xe0000000
 #define __virt_to_bus(x)	((x) + (BUS_OFFSET - PAGE_OFFSET))
 #define __bus_to_virt(x)	((x) - (BUS_OFFSET - PAGE_OFFSET))
-#define __pfn_to_bus(x)		(__pfn_to_phys(x) + (BUS_OFFSET - PHYS_OFFSET))
-#define __bus_to_pfn(x)		__phys_to_pfn((x) - (BUS_OFFSET - PHYS_OFFSET))
 
 #else
 
diff --git a/arch/arm/mach-footbridge/netwinder-pci.c b/arch/arm/mach-footbridge/netwinder-pci.c
index 9473aa0305e5f7..68dac9446e7f44 100644
--- a/arch/arm/mach-footbridge/netwinder-pci.c
+++ b/arch/arm/mach-footbridge/netwinder-pci.c
@@ -13,6 +13,7 @@
 #include <asm/irq.h>
 #include <asm/mach/pci.h>
 #include <asm/mach-types.h>
+#include "common.h"
 
 /*
  * We now use the slot ID instead of the device identifiers to select
@@ -54,8 +55,10 @@ static struct hw_pci netwinder_pci __initdata = {
 
 static int __init netwinder_pci_init(void)
 {
-	if (machine_is_netwinder())
-		pci_common_init(&netwinder_pci);
+	if (!machine_is_netwinder())
+		return 0;
+	bus_register_notifier(&pci_bus_type, &footbridge_pci_dma_nb);
+	pci_common_init(&netwinder_pci);
 	return 0;
 }
 
diff --git a/arch/arm/mach-footbridge/personal-pci.c b/arch/arm/mach-footbridge/personal-pci.c
index 4391e433a4b2fc..5d6759e158b9d0 100644
--- a/arch/arm/mach-footbridge/personal-pci.c
+++ b/arch/arm/mach-footbridge/personal-pci.c
@@ -13,6 +13,7 @@
 #include <asm/irq.h>
 #include <asm/mach/pci.h>
 #include <asm/mach-types.h>
+#include "common.h"
 
 static int irqmap_personal_server[] __initdata = {
 	IRQ_IN0, IRQ_IN1, IRQ_IN2, IRQ_IN3, 0, 0, 0,
@@ -50,8 +51,10 @@ static struct hw_pci personal_server_pci __initdata = {
 
 static int __init personal_pci_init(void)
 {
-	if (machine_is_personal_server())
-		pci_common_init(&personal_server_pci);
+	if (!machine_is_personal_server())
+		return 0;
+	bus_register_notifier(&pci_bus_type, &footbridge_pci_dma_nb);
+	pci_common_init(&personal_server_pci);
 	return 0;
 }
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 2/4] ARM/footbridge: switch to use dma_direct_set_offset for lbus DMA offsets
@ 2020-09-17 17:32   ` Christoph Hellwig
  0 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-17 17:32 UTC (permalink / raw)
  To: Russell King
  Cc: Aaro Koskinen, Tony Lindgren, linux-usb, linux-kernel, iommu,
	linux-omap, Robin Murphy, linux-arm-kernel

Switch the footbridge PCI devices to use dma_direct_set_offset to set the
DMA offset instead of using direct hooks into the DMA mapping code and
remove the now unused hooks.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/arm/include/asm/dma-direct.h             |  4 +-
 arch/arm/include/asm/memory.h                 |  2 -
 arch/arm/mach-footbridge/cats-pci.c           |  7 +++-
 arch/arm/mach-footbridge/common.c             | 40 ++++++++++++++-----
 arch/arm/mach-footbridge/common.h             |  3 ++
 arch/arm/mach-footbridge/ebsa285-pci.c        |  7 +++-
 .../arm/mach-footbridge/include/mach/memory.h |  4 --
 arch/arm/mach-footbridge/netwinder-pci.c      |  7 +++-
 arch/arm/mach-footbridge/personal-pci.c       |  7 +++-
 9 files changed, 54 insertions(+), 27 deletions(-)

diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h
index 77fcb7ee5ec907..1f04a5e1c615de 100644
--- a/arch/arm/include/asm/dma-direct.h
+++ b/arch/arm/include/asm/dma-direct.h
@@ -13,12 +13,12 @@ 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);
+	return (dma_addr_t)__pfn_to_phys(pfn);
 }
 
 static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
 {
-	unsigned long pfn = __bus_to_pfn(addr);
+	unsigned long pfn = __phys_to_pfn(addr);
 
 	if (dev && dev->dma_range_map)
 		pfn = PFN_DOWN(translate_dma_to_phys(dev, PFN_PHYS(pfn)));
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index 99035b5891ef44..af612606136ff2 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -346,8 +346,6 @@ static inline unsigned long __virt_to_idmap(unsigned long x)
 #ifndef __virt_to_bus
 #define __virt_to_bus	__virt_to_phys
 #define __bus_to_virt	__phys_to_virt
-#define __pfn_to_bus(x)	__pfn_to_phys(x)
-#define __bus_to_pfn(x)	__phys_to_pfn(x)
 #endif
 
 /*
diff --git a/arch/arm/mach-footbridge/cats-pci.c b/arch/arm/mach-footbridge/cats-pci.c
index 0b2fd7e2e9b429..257cb068ac0c5b 100644
--- a/arch/arm/mach-footbridge/cats-pci.c
+++ b/arch/arm/mach-footbridge/cats-pci.c
@@ -13,6 +13,7 @@
 #include <asm/irq.h>
 #include <asm/mach/pci.h>
 #include <asm/mach-types.h>
+#include "common.h"
 
 /* cats host-specific stuff */
 static int irqmap_cats[] __initdata = { IRQ_PCI, IRQ_IN0, IRQ_IN1, IRQ_IN3 };
@@ -56,8 +57,10 @@ static struct hw_pci cats_pci __initdata = {
 
 static int __init cats_pci_init(void)
 {
-	if (machine_is_cats())
-		pci_common_init(&cats_pci);
+	if (!machine_is_cats())
+		return 0;
+	bus_register_notifier(&pci_bus_type, &footbridge_pci_dma_nb);
+	pci_common_init(&cats_pci);
 	return 0;
 }
 
diff --git a/arch/arm/mach-footbridge/common.c b/arch/arm/mach-footbridge/common.c
index eee095f0e2f6c2..dc14d72ca7bb3f 100644
--- a/arch/arm/mach-footbridge/common.c
+++ b/arch/arm/mach-footbridge/common.c
@@ -12,6 +12,8 @@
 #include <linux/init.h>
 #include <linux/io.h>
 #include <linux/spinlock.h>
+#include <linux/device/bus.h>
+#include <linux/dma-mapping.h>
 #include <video/vga.h>
 
 #include <asm/page.h>
@@ -219,8 +221,17 @@ void footbridge_restart(enum reboot_mode mode, const char *cmd)
 	}
 }
 
-#ifdef CONFIG_FOOTBRIDGE_ADDIN
-
+#ifdef CONFIG_FOOTBRIDGE_HOST
+/*
+ * The footbridge is programmed to expose the system RAM at 0xe0000000.
+ * The requirement is that the RAM isn't placed at bus address 0, which
+ * would clash with VGA cards.
+ */
+static inline unsigned long fb_bus_sdram_offset(void)
+{
+	return 0xe0000000;
+}
+#elif defined(CONFIG_FOOTBRIDGE_ADDIN)
 static inline unsigned long fb_bus_sdram_offset(void)
 {
 	return *CSR_PCISDRAMBASE & 0xfffffff0;
@@ -248,17 +259,24 @@ unsigned long __bus_to_virt(unsigned long res)
 	return res;
 }
 EXPORT_SYMBOL(__bus_to_virt);
+#else
+#error "Undefined footbridge mode"
+#endif
 
-unsigned long __pfn_to_bus(unsigned long pfn)
+static int footbridge_pci_dma_notifier(struct notifier_block *nb,
+		unsigned long event, void *data)
 {
-	return __pfn_to_phys(pfn) + (fb_bus_sdram_offset() - PHYS_OFFSET);
-}
-EXPORT_SYMBOL(__pfn_to_bus);
+	struct device *dev = data;
 
-unsigned long __bus_to_pfn(unsigned long bus)
-{
-	return __phys_to_pfn(bus - (fb_bus_sdram_offset() - PHYS_OFFSET));
+	if (event != BUS_NOTIFY_ADD_DEVICE)
+		return NOTIFY_DONE;
+
+	if (dma_direct_set_offset(dev, PAGE_OFFSET, fb_bus_sdram_offset(),
+			(u64)-1))
+		WARN_ONCE(1, "failed to set DMA offset\n");
+	return NOTIFY_OK;
 }
-EXPORT_SYMBOL(__bus_to_pfn);
 
-#endif
+struct notifier_block footbridge_pci_dma_nb = {
+	.notifier_call		= footbridge_pci_dma_notifier,
+};
diff --git a/arch/arm/mach-footbridge/common.h b/arch/arm/mach-footbridge/common.h
index e12587db59c4c8..1773a4183b580c 100644
--- a/arch/arm/mach-footbridge/common.h
+++ b/arch/arm/mach-footbridge/common.h
@@ -1,4 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+#include <linux/notifier.h>
 #include <linux/reboot.h>
 
 extern void footbridge_timer_init(void);
@@ -13,3 +14,5 @@ extern void isa_init_irq(unsigned int irq);
 extern void footbridge_restart(enum reboot_mode, const char *);
 
 extern void footbridge_sched_clock(void);
+
+extern struct notifier_block footbridge_pci_dma_nb;
diff --git a/arch/arm/mach-footbridge/ebsa285-pci.c b/arch/arm/mach-footbridge/ebsa285-pci.c
index 6f28aaa9ca79b2..80b4f5ace20b35 100644
--- a/arch/arm/mach-footbridge/ebsa285-pci.c
+++ b/arch/arm/mach-footbridge/ebsa285-pci.c
@@ -13,6 +13,7 @@
 #include <asm/irq.h>
 #include <asm/mach/pci.h>
 #include <asm/mach-types.h>
+#include "common.h"
 
 static int irqmap_ebsa285[] __initdata = { IRQ_IN3, IRQ_IN1, IRQ_IN0, IRQ_PCI };
 
@@ -40,8 +41,10 @@ static struct hw_pci ebsa285_pci __initdata = {
 
 static int __init ebsa285_init_pci(void)
 {
-	if (machine_is_ebsa285())
-		pci_common_init(&ebsa285_pci);
+	if (!machine_is_ebsa285())
+		return 0;
+	bus_register_notifier(&pci_bus_type, &footbridge_pci_dma_nb);
+	pci_common_init(&ebsa285_pci);
 	return 0;
 }
 
diff --git a/arch/arm/mach-footbridge/include/mach/memory.h b/arch/arm/mach-footbridge/include/mach/memory.h
index 46fd4a8872b9a3..3a5d2638c18f88 100644
--- a/arch/arm/mach-footbridge/include/mach/memory.h
+++ b/arch/arm/mach-footbridge/include/mach/memory.h
@@ -26,8 +26,6 @@
 #ifndef __ASSEMBLY__
 extern unsigned long __virt_to_bus(unsigned long);
 extern unsigned long __bus_to_virt(unsigned long);
-extern unsigned long __pfn_to_bus(unsigned long);
-extern unsigned long __bus_to_pfn(unsigned long);
 #endif
 #define __virt_to_bus	__virt_to_bus
 #define __bus_to_virt	__bus_to_virt
@@ -42,8 +40,6 @@ extern unsigned long __bus_to_pfn(unsigned long);
 #define BUS_OFFSET		0xe0000000
 #define __virt_to_bus(x)	((x) + (BUS_OFFSET - PAGE_OFFSET))
 #define __bus_to_virt(x)	((x) - (BUS_OFFSET - PAGE_OFFSET))
-#define __pfn_to_bus(x)		(__pfn_to_phys(x) + (BUS_OFFSET - PHYS_OFFSET))
-#define __bus_to_pfn(x)		__phys_to_pfn((x) - (BUS_OFFSET - PHYS_OFFSET))
 
 #else
 
diff --git a/arch/arm/mach-footbridge/netwinder-pci.c b/arch/arm/mach-footbridge/netwinder-pci.c
index 9473aa0305e5f7..68dac9446e7f44 100644
--- a/arch/arm/mach-footbridge/netwinder-pci.c
+++ b/arch/arm/mach-footbridge/netwinder-pci.c
@@ -13,6 +13,7 @@
 #include <asm/irq.h>
 #include <asm/mach/pci.h>
 #include <asm/mach-types.h>
+#include "common.h"
 
 /*
  * We now use the slot ID instead of the device identifiers to select
@@ -54,8 +55,10 @@ static struct hw_pci netwinder_pci __initdata = {
 
 static int __init netwinder_pci_init(void)
 {
-	if (machine_is_netwinder())
-		pci_common_init(&netwinder_pci);
+	if (!machine_is_netwinder())
+		return 0;
+	bus_register_notifier(&pci_bus_type, &footbridge_pci_dma_nb);
+	pci_common_init(&netwinder_pci);
 	return 0;
 }
 
diff --git a/arch/arm/mach-footbridge/personal-pci.c b/arch/arm/mach-footbridge/personal-pci.c
index 4391e433a4b2fc..5d6759e158b9d0 100644
--- a/arch/arm/mach-footbridge/personal-pci.c
+++ b/arch/arm/mach-footbridge/personal-pci.c
@@ -13,6 +13,7 @@
 #include <asm/irq.h>
 #include <asm/mach/pci.h>
 #include <asm/mach-types.h>
+#include "common.h"
 
 static int irqmap_personal_server[] __initdata = {
 	IRQ_IN0, IRQ_IN1, IRQ_IN2, IRQ_IN3, 0, 0, 0,
@@ -50,8 +51,10 @@ static struct hw_pci personal_server_pci __initdata = {
 
 static int __init personal_pci_init(void)
 {
-	if (machine_is_personal_server())
-		pci_common_init(&personal_server_pci);
+	if (!machine_is_personal_server())
+		return 0;
+	bus_register_notifier(&pci_bus_type, &footbridge_pci_dma_nb);
+	pci_common_init(&personal_server_pci);
 	return 0;
 }
 
-- 
2.28.0

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 2/4] ARM/footbridge: switch to use dma_direct_set_offset for lbus DMA offsets
@ 2020-09-17 17:32   ` Christoph Hellwig
  0 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-17 17:32 UTC (permalink / raw)
  To: Russell King
  Cc: Aaro Koskinen, Tony Lindgren, linux-usb, linux-kernel, iommu,
	linux-omap, Robin Murphy, linux-arm-kernel

Switch the footbridge PCI devices to use dma_direct_set_offset to set the
DMA offset instead of using direct hooks into the DMA mapping code and
remove the now unused hooks.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/arm/include/asm/dma-direct.h             |  4 +-
 arch/arm/include/asm/memory.h                 |  2 -
 arch/arm/mach-footbridge/cats-pci.c           |  7 +++-
 arch/arm/mach-footbridge/common.c             | 40 ++++++++++++++-----
 arch/arm/mach-footbridge/common.h             |  3 ++
 arch/arm/mach-footbridge/ebsa285-pci.c        |  7 +++-
 .../arm/mach-footbridge/include/mach/memory.h |  4 --
 arch/arm/mach-footbridge/netwinder-pci.c      |  7 +++-
 arch/arm/mach-footbridge/personal-pci.c       |  7 +++-
 9 files changed, 54 insertions(+), 27 deletions(-)

diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h
index 77fcb7ee5ec907..1f04a5e1c615de 100644
--- a/arch/arm/include/asm/dma-direct.h
+++ b/arch/arm/include/asm/dma-direct.h
@@ -13,12 +13,12 @@ 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);
+	return (dma_addr_t)__pfn_to_phys(pfn);
 }
 
 static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
 {
-	unsigned long pfn = __bus_to_pfn(addr);
+	unsigned long pfn = __phys_to_pfn(addr);
 
 	if (dev && dev->dma_range_map)
 		pfn = PFN_DOWN(translate_dma_to_phys(dev, PFN_PHYS(pfn)));
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index 99035b5891ef44..af612606136ff2 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -346,8 +346,6 @@ static inline unsigned long __virt_to_idmap(unsigned long x)
 #ifndef __virt_to_bus
 #define __virt_to_bus	__virt_to_phys
 #define __bus_to_virt	__phys_to_virt
-#define __pfn_to_bus(x)	__pfn_to_phys(x)
-#define __bus_to_pfn(x)	__phys_to_pfn(x)
 #endif
 
 /*
diff --git a/arch/arm/mach-footbridge/cats-pci.c b/arch/arm/mach-footbridge/cats-pci.c
index 0b2fd7e2e9b429..257cb068ac0c5b 100644
--- a/arch/arm/mach-footbridge/cats-pci.c
+++ b/arch/arm/mach-footbridge/cats-pci.c
@@ -13,6 +13,7 @@
 #include <asm/irq.h>
 #include <asm/mach/pci.h>
 #include <asm/mach-types.h>
+#include "common.h"
 
 /* cats host-specific stuff */
 static int irqmap_cats[] __initdata = { IRQ_PCI, IRQ_IN0, IRQ_IN1, IRQ_IN3 };
@@ -56,8 +57,10 @@ static struct hw_pci cats_pci __initdata = {
 
 static int __init cats_pci_init(void)
 {
-	if (machine_is_cats())
-		pci_common_init(&cats_pci);
+	if (!machine_is_cats())
+		return 0;
+	bus_register_notifier(&pci_bus_type, &footbridge_pci_dma_nb);
+	pci_common_init(&cats_pci);
 	return 0;
 }
 
diff --git a/arch/arm/mach-footbridge/common.c b/arch/arm/mach-footbridge/common.c
index eee095f0e2f6c2..dc14d72ca7bb3f 100644
--- a/arch/arm/mach-footbridge/common.c
+++ b/arch/arm/mach-footbridge/common.c
@@ -12,6 +12,8 @@
 #include <linux/init.h>
 #include <linux/io.h>
 #include <linux/spinlock.h>
+#include <linux/device/bus.h>
+#include <linux/dma-mapping.h>
 #include <video/vga.h>
 
 #include <asm/page.h>
@@ -219,8 +221,17 @@ void footbridge_restart(enum reboot_mode mode, const char *cmd)
 	}
 }
 
-#ifdef CONFIG_FOOTBRIDGE_ADDIN
-
+#ifdef CONFIG_FOOTBRIDGE_HOST
+/*
+ * The footbridge is programmed to expose the system RAM at 0xe0000000.
+ * The requirement is that the RAM isn't placed at bus address 0, which
+ * would clash with VGA cards.
+ */
+static inline unsigned long fb_bus_sdram_offset(void)
+{
+	return 0xe0000000;
+}
+#elif defined(CONFIG_FOOTBRIDGE_ADDIN)
 static inline unsigned long fb_bus_sdram_offset(void)
 {
 	return *CSR_PCISDRAMBASE & 0xfffffff0;
@@ -248,17 +259,24 @@ unsigned long __bus_to_virt(unsigned long res)
 	return res;
 }
 EXPORT_SYMBOL(__bus_to_virt);
+#else
+#error "Undefined footbridge mode"
+#endif
 
-unsigned long __pfn_to_bus(unsigned long pfn)
+static int footbridge_pci_dma_notifier(struct notifier_block *nb,
+		unsigned long event, void *data)
 {
-	return __pfn_to_phys(pfn) + (fb_bus_sdram_offset() - PHYS_OFFSET);
-}
-EXPORT_SYMBOL(__pfn_to_bus);
+	struct device *dev = data;
 
-unsigned long __bus_to_pfn(unsigned long bus)
-{
-	return __phys_to_pfn(bus - (fb_bus_sdram_offset() - PHYS_OFFSET));
+	if (event != BUS_NOTIFY_ADD_DEVICE)
+		return NOTIFY_DONE;
+
+	if (dma_direct_set_offset(dev, PAGE_OFFSET, fb_bus_sdram_offset(),
+			(u64)-1))
+		WARN_ONCE(1, "failed to set DMA offset\n");
+	return NOTIFY_OK;
 }
-EXPORT_SYMBOL(__bus_to_pfn);
 
-#endif
+struct notifier_block footbridge_pci_dma_nb = {
+	.notifier_call		= footbridge_pci_dma_notifier,
+};
diff --git a/arch/arm/mach-footbridge/common.h b/arch/arm/mach-footbridge/common.h
index e12587db59c4c8..1773a4183b580c 100644
--- a/arch/arm/mach-footbridge/common.h
+++ b/arch/arm/mach-footbridge/common.h
@@ -1,4 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+#include <linux/notifier.h>
 #include <linux/reboot.h>
 
 extern void footbridge_timer_init(void);
@@ -13,3 +14,5 @@ extern void isa_init_irq(unsigned int irq);
 extern void footbridge_restart(enum reboot_mode, const char *);
 
 extern void footbridge_sched_clock(void);
+
+extern struct notifier_block footbridge_pci_dma_nb;
diff --git a/arch/arm/mach-footbridge/ebsa285-pci.c b/arch/arm/mach-footbridge/ebsa285-pci.c
index 6f28aaa9ca79b2..80b4f5ace20b35 100644
--- a/arch/arm/mach-footbridge/ebsa285-pci.c
+++ b/arch/arm/mach-footbridge/ebsa285-pci.c
@@ -13,6 +13,7 @@
 #include <asm/irq.h>
 #include <asm/mach/pci.h>
 #include <asm/mach-types.h>
+#include "common.h"
 
 static int irqmap_ebsa285[] __initdata = { IRQ_IN3, IRQ_IN1, IRQ_IN0, IRQ_PCI };
 
@@ -40,8 +41,10 @@ static struct hw_pci ebsa285_pci __initdata = {
 
 static int __init ebsa285_init_pci(void)
 {
-	if (machine_is_ebsa285())
-		pci_common_init(&ebsa285_pci);
+	if (!machine_is_ebsa285())
+		return 0;
+	bus_register_notifier(&pci_bus_type, &footbridge_pci_dma_nb);
+	pci_common_init(&ebsa285_pci);
 	return 0;
 }
 
diff --git a/arch/arm/mach-footbridge/include/mach/memory.h b/arch/arm/mach-footbridge/include/mach/memory.h
index 46fd4a8872b9a3..3a5d2638c18f88 100644
--- a/arch/arm/mach-footbridge/include/mach/memory.h
+++ b/arch/arm/mach-footbridge/include/mach/memory.h
@@ -26,8 +26,6 @@
 #ifndef __ASSEMBLY__
 extern unsigned long __virt_to_bus(unsigned long);
 extern unsigned long __bus_to_virt(unsigned long);
-extern unsigned long __pfn_to_bus(unsigned long);
-extern unsigned long __bus_to_pfn(unsigned long);
 #endif
 #define __virt_to_bus	__virt_to_bus
 #define __bus_to_virt	__bus_to_virt
@@ -42,8 +40,6 @@ extern unsigned long __bus_to_pfn(unsigned long);
 #define BUS_OFFSET		0xe0000000
 #define __virt_to_bus(x)	((x) + (BUS_OFFSET - PAGE_OFFSET))
 #define __bus_to_virt(x)	((x) - (BUS_OFFSET - PAGE_OFFSET))
-#define __pfn_to_bus(x)		(__pfn_to_phys(x) + (BUS_OFFSET - PHYS_OFFSET))
-#define __bus_to_pfn(x)		__phys_to_pfn((x) - (BUS_OFFSET - PHYS_OFFSET))
 
 #else
 
diff --git a/arch/arm/mach-footbridge/netwinder-pci.c b/arch/arm/mach-footbridge/netwinder-pci.c
index 9473aa0305e5f7..68dac9446e7f44 100644
--- a/arch/arm/mach-footbridge/netwinder-pci.c
+++ b/arch/arm/mach-footbridge/netwinder-pci.c
@@ -13,6 +13,7 @@
 #include <asm/irq.h>
 #include <asm/mach/pci.h>
 #include <asm/mach-types.h>
+#include "common.h"
 
 /*
  * We now use the slot ID instead of the device identifiers to select
@@ -54,8 +55,10 @@ static struct hw_pci netwinder_pci __initdata = {
 
 static int __init netwinder_pci_init(void)
 {
-	if (machine_is_netwinder())
-		pci_common_init(&netwinder_pci);
+	if (!machine_is_netwinder())
+		return 0;
+	bus_register_notifier(&pci_bus_type, &footbridge_pci_dma_nb);
+	pci_common_init(&netwinder_pci);
 	return 0;
 }
 
diff --git a/arch/arm/mach-footbridge/personal-pci.c b/arch/arm/mach-footbridge/personal-pci.c
index 4391e433a4b2fc..5d6759e158b9d0 100644
--- a/arch/arm/mach-footbridge/personal-pci.c
+++ b/arch/arm/mach-footbridge/personal-pci.c
@@ -13,6 +13,7 @@
 #include <asm/irq.h>
 #include <asm/mach/pci.h>
 #include <asm/mach-types.h>
+#include "common.h"
 
 static int irqmap_personal_server[] __initdata = {
 	IRQ_IN0, IRQ_IN1, IRQ_IN2, IRQ_IN3, 0, 0, 0,
@@ -50,8 +51,10 @@ static struct hw_pci personal_server_pci __initdata = {
 
 static int __init personal_pci_init(void)
 {
-	if (machine_is_personal_server())
-		pci_common_init(&personal_server_pci);
+	if (!machine_is_personal_server())
+		return 0;
+	bus_register_notifier(&pci_bus_type, &footbridge_pci_dma_nb);
+	pci_common_init(&personal_server_pci);
 	return 0;
 }
 
-- 
2.28.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 3/4] ARM/dma-mapping: don't handle NULL devices in dma-direct.h
  2020-09-17 17:32 ` Christoph Hellwig
  (?)
@ 2020-09-17 17:32   ` Christoph Hellwig
  -1 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-17 17:32 UTC (permalink / raw)
  To: Russell King
  Cc: Aaro Koskinen, Tony Lindgren, Robin Murphy, iommu,
	linux-arm-kernel, linux-kernel, linux-omap, linux-usb

The DMA API removed support for not passing in a device a long time
ago, so remove the NULL checks.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/arm/include/asm/dma-direct.h | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h
index 1f04a5e1c615de..84cb4e30658891 100644
--- a/arch/arm/include/asm/dma-direct.h
+++ b/arch/arm/include/asm/dma-direct.h
@@ -11,7 +11,7 @@
  */
 static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
 {
-	if (dev && dev->dma_range_map)
+	if (dev->dma_range_map)
 		pfn = PFN_DOWN(translate_phys_to_dma(dev, PFN_PHYS(pfn)));
 	return (dma_addr_t)__pfn_to_phys(pfn);
 }
@@ -20,16 +20,13 @@ static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
 {
 	unsigned long pfn = __phys_to_pfn(addr);
 
-	if (dev && dev->dma_range_map)
+	if (dev->dma_range_map)
 		pfn = PFN_DOWN(translate_dma_to_phys(dev, PFN_PHYS(pfn)));
 	return pfn;
 }
 
 static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
 {
-	if (dev)
-		return pfn_to_dma(dev, virt_to_pfn(addr));
-
 	return (dma_addr_t)__virt_to_bus((unsigned long)(addr));
 }
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 3/4] ARM/dma-mapping: don't handle NULL devices in dma-direct.h
@ 2020-09-17 17:32   ` Christoph Hellwig
  0 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-17 17:32 UTC (permalink / raw)
  To: Russell King
  Cc: Aaro Koskinen, Tony Lindgren, linux-usb, linux-kernel, iommu,
	linux-omap, Robin Murphy, linux-arm-kernel

The DMA API removed support for not passing in a device a long time
ago, so remove the NULL checks.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/arm/include/asm/dma-direct.h | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h
index 1f04a5e1c615de..84cb4e30658891 100644
--- a/arch/arm/include/asm/dma-direct.h
+++ b/arch/arm/include/asm/dma-direct.h
@@ -11,7 +11,7 @@
  */
 static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
 {
-	if (dev && dev->dma_range_map)
+	if (dev->dma_range_map)
 		pfn = PFN_DOWN(translate_phys_to_dma(dev, PFN_PHYS(pfn)));
 	return (dma_addr_t)__pfn_to_phys(pfn);
 }
@@ -20,16 +20,13 @@ static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
 {
 	unsigned long pfn = __phys_to_pfn(addr);
 
-	if (dev && dev->dma_range_map)
+	if (dev->dma_range_map)
 		pfn = PFN_DOWN(translate_dma_to_phys(dev, PFN_PHYS(pfn)));
 	return pfn;
 }
 
 static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
 {
-	if (dev)
-		return pfn_to_dma(dev, virt_to_pfn(addr));
-
 	return (dma_addr_t)__virt_to_bus((unsigned long)(addr));
 }
 
-- 
2.28.0

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 3/4] ARM/dma-mapping: don't handle NULL devices in dma-direct.h
@ 2020-09-17 17:32   ` Christoph Hellwig
  0 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-17 17:32 UTC (permalink / raw)
  To: Russell King
  Cc: Aaro Koskinen, Tony Lindgren, linux-usb, linux-kernel, iommu,
	linux-omap, Robin Murphy, linux-arm-kernel

The DMA API removed support for not passing in a device a long time
ago, so remove the NULL checks.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/arm/include/asm/dma-direct.h | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h
index 1f04a5e1c615de..84cb4e30658891 100644
--- a/arch/arm/include/asm/dma-direct.h
+++ b/arch/arm/include/asm/dma-direct.h
@@ -11,7 +11,7 @@
  */
 static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
 {
-	if (dev && dev->dma_range_map)
+	if (dev->dma_range_map)
 		pfn = PFN_DOWN(translate_phys_to_dma(dev, PFN_PHYS(pfn)));
 	return (dma_addr_t)__pfn_to_phys(pfn);
 }
@@ -20,16 +20,13 @@ static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
 {
 	unsigned long pfn = __phys_to_pfn(addr);
 
-	if (dev && dev->dma_range_map)
+	if (dev->dma_range_map)
 		pfn = PFN_DOWN(translate_dma_to_phys(dev, PFN_PHYS(pfn)));
 	return pfn;
 }
 
 static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
 {
-	if (dev)
-		return pfn_to_dma(dev, virt_to_pfn(addr));
-
 	return (dma_addr_t)__virt_to_bus((unsigned long)(addr));
 }
 
-- 
2.28.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 4/4] ARM/dma-mapping: remove the arm specific phys to dma translation helpers
  2020-09-17 17:32 ` Christoph Hellwig
  (?)
@ 2020-09-17 17:32   ` Christoph Hellwig
  -1 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-17 17:32 UTC (permalink / raw)
  To: Russell King
  Cc: Aaro Koskinen, Tony Lindgren, Robin Murphy, iommu,
	linux-arm-kernel, linux-kernel, linux-omap, linux-usb

Now that the two remaining architectures that hooked into the DMA
translation directly use the range map instead, there is no need to
override phys_to_dma and dma_to_phys.  Remove asm/dma-direct.h after
switching the remaining callsites to the phys addr based generic
helpers instead of the PFN or virt addr based arm ones.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/arm/Kconfig                  |  1 -
 arch/arm/common/dmabounce.c       | 14 +++++-----
 arch/arm/include/asm/dma-direct.h | 45 -------------------------------
 arch/arm/mm/dma-mapping.c         | 20 +++++++-------
 4 files changed, 17 insertions(+), 63 deletions(-)
 delete mode 100644 arch/arm/include/asm/dma-direct.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index e00d94b1665876..2c4d608fa5fecf 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -14,7 +14,6 @@ config ARM
 	select ARCH_HAS_MEMBARRIER_SYNC_CORE
 	select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
 	select ARCH_HAS_PTE_SPECIAL if ARM_LPAE
-	select ARCH_HAS_PHYS_TO_DMA
 	select ARCH_HAS_SETUP_DMA_OPS
 	select ARCH_HAS_SET_MEMORY
 	select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index d3e00ea9208834..561d6d06c6b6aa 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -258,7 +258,7 @@ static inline dma_addr_t map_single(struct device *dev, void *ptr, size_t size,
 	}
 
 	dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n",
-		__func__, buf->ptr, virt_to_dma(dev, buf->ptr),
+		__func__, buf->ptr, phys_to_dma(dev, virt_to_phys(buf->ptr)),
 		buf->safe, buf->safe_dma_addr);
 
 	if ((dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL) &&
@@ -279,7 +279,7 @@ static inline void unmap_single(struct device *dev, struct safe_buffer *buf,
 	BUG_ON(buf->direction != dir);
 
 	dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n",
-		__func__, buf->ptr, virt_to_dma(dev, buf->ptr),
+		__func__, buf->ptr, phys_to_dma(dev, virt_to_phys(buf->ptr)),
 		buf->safe, buf->safe_dma_addr);
 
 	DO_STATS(dev->archdata.dmabounce->bounce_count++);
@@ -320,7 +320,7 @@ static dma_addr_t dmabounce_map_page(struct device *dev, struct page *page,
 	dev_dbg(dev, "%s(page=%p,off=%#lx,size=%zx,dir=%x)\n",
 		__func__, page, offset, size, dir);
 
-	dma_addr = pfn_to_dma(dev, page_to_pfn(page)) + offset;
+	dma_addr = phys_to_dma(dev, page_to_phys(page)) + offset;
 
 	ret = needs_bounce(dev, dma_addr, size);
 	if (ret < 0)
@@ -380,8 +380,8 @@ static int __dmabounce_sync_for_cpu(struct device *dev, dma_addr_t addr,
 	BUG_ON(buf->direction != dir);
 
 	dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x off=%#lx) mapped to %p (dma=%#x)\n",
-		__func__, buf->ptr, virt_to_dma(dev, buf->ptr), off,
-		buf->safe, buf->safe_dma_addr);
+		__func__, buf->ptr, phys_to_dma(dev, virt_to_phys(buf->ptr)),
+		off, buf->safe, buf->safe_dma_addr);
 
 	DO_STATS(dev->archdata.dmabounce->bounce_count++);
 
@@ -420,8 +420,8 @@ static int __dmabounce_sync_for_device(struct device *dev, dma_addr_t addr,
 	BUG_ON(buf->direction != dir);
 
 	dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x off=%#lx) mapped to %p (dma=%#x)\n",
-		__func__, buf->ptr, virt_to_dma(dev, buf->ptr), off,
-		buf->safe, buf->safe_dma_addr);
+		__func__, buf->ptr, phys_to_dma(dev, virt_to_phys(buf->ptr)),
+		off, buf->safe, buf->safe_dma_addr);
 
 	DO_STATS(dev->archdata.dmabounce->bounce_count++);
 
diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h
deleted file mode 100644
index 84cb4e30658891..00000000000000
--- a/arch/arm/include/asm/dma-direct.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* 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/virt_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->dma_range_map)
-		pfn = PFN_DOWN(translate_phys_to_dma(dev, PFN_PHYS(pfn)));
-	return (dma_addr_t)__pfn_to_phys(pfn);
-}
-
-static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
-{
-	unsigned long pfn = __phys_to_pfn(addr);
-
-	if (dev->dma_range_map)
-		pfn = PFN_DOWN(translate_dma_to_phys(dev, PFN_PHYS(pfn)));
-	return pfn;
-}
-
-static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
-{
-	return (dma_addr_t)__virt_to_bus((unsigned long)(addr));
-}
-
-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 */
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 8a8949174b1c06..9d800d0a53af7a 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -131,14 +131,14 @@ static dma_addr_t arm_dma_map_page(struct device *dev, struct page *page,
 {
 	if ((attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
 		__dma_page_cpu_to_dev(page, offset, size, dir);
-	return pfn_to_dma(dev, page_to_pfn(page)) + offset;
+	return phys_to_dma(dev, page_to_phys(page)) + offset;
 }
 
 static dma_addr_t arm_coherent_dma_map_page(struct device *dev, struct page *page,
 	     unsigned long offset, size_t size, enum dma_data_direction dir,
 	     unsigned long attrs)
 {
-	return pfn_to_dma(dev, page_to_pfn(page)) + offset;
+	return phys_to_dma(dev, page_to_phys(page)) + offset;
 }
 
 /**
@@ -159,7 +159,7 @@ static void arm_dma_unmap_page(struct device *dev, dma_addr_t handle,
 		size_t size, enum dma_data_direction dir, unsigned long attrs)
 {
 	if ((attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
-		__dma_page_dev_to_cpu(pfn_to_page(dma_to_pfn(dev, handle)),
+		__dma_page_dev_to_cpu(phys_to_page(dma_to_phys(dev, handle)),
 				      handle & ~PAGE_MASK, size, dir);
 }
 
@@ -167,7 +167,7 @@ static void arm_dma_sync_single_for_cpu(struct device *dev,
 		dma_addr_t handle, size_t size, enum dma_data_direction dir)
 {
 	unsigned int offset = handle & (PAGE_SIZE - 1);
-	struct page *page = pfn_to_page(dma_to_pfn(dev, handle-offset));
+	struct page *page = phys_to_page(dma_to_phys(dev, handle-offset));
 	__dma_page_dev_to_cpu(page, offset, size, dir);
 }
 
@@ -175,7 +175,7 @@ static void arm_dma_sync_single_for_device(struct device *dev,
 		dma_addr_t handle, size_t size, enum dma_data_direction dir)
 {
 	unsigned int offset = handle & (PAGE_SIZE - 1);
-	struct page *page = pfn_to_page(dma_to_pfn(dev, handle-offset));
+	struct page *page = phys_to_page(dma_to_phys(dev, handle-offset));
 	__dma_page_cpu_to_dev(page, offset, size, dir);
 }
 
@@ -193,7 +193,7 @@ static int arm_dma_supported(struct device *dev, u64 mask)
 	 * Translate the device's DMA mask to a PFN limit.  This
 	 * PFN number includes the page which we can DMA to.
 	 */
-	return dma_to_pfn(dev, mask) >= max_dma_pfn;
+	return PHYS_PFN(dma_to_phys(dev, mask)) >= max_dma_pfn;
 }
 
 const struct dma_map_ops arm_dma_ops = {
@@ -722,7 +722,7 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
 	if (page) {
 		unsigned long flags;
 
-		*handle = pfn_to_dma(dev, page_to_pfn(page));
+		*handle = phys_to_dma(dev, page_to_phys(page));
 		buf->virt = args.want_vaddr ? addr : page;
 
 		spin_lock_irqsave(&arm_dma_bufs_lock, flags);
@@ -762,7 +762,7 @@ static int __arm_dma_mmap(struct device *dev, struct vm_area_struct *vma,
 	int ret = -ENXIO;
 	unsigned long nr_vma_pages = vma_pages(vma);
 	unsigned long nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
-	unsigned long pfn = dma_to_pfn(dev, dma_addr);
+	unsigned long pfn = PHYS_PFN(dma_to_phys(dev, dma_addr));
 	unsigned long off = vma->vm_pgoff;
 
 	if (dma_mmap_from_dev_coherent(dev, vma, cpu_addr, size, &ret))
@@ -803,7 +803,7 @@ static void __arm_dma_free(struct device *dev, size_t size, void *cpu_addr,
 			   dma_addr_t handle, unsigned long attrs,
 			   bool is_coherent)
 {
-	struct page *page = pfn_to_page(dma_to_pfn(dev, handle));
+	struct page *page = phys_to_page(dma_to_phys(dev, handle));
 	struct arm_dma_buffer *buf;
 	struct arm_dma_free_args args = {
 		.dev = dev,
@@ -837,7 +837,7 @@ int arm_dma_get_sgtable(struct device *dev, struct sg_table *sgt,
 		 void *cpu_addr, dma_addr_t handle, size_t size,
 		 unsigned long attrs)
 {
-	unsigned long pfn = dma_to_pfn(dev, handle);
+	unsigned long pfn = PHYS_PFN(dma_to_phys(dev, handle));
 	struct page *page;
 	int ret;
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 4/4] ARM/dma-mapping: remove the arm specific phys to dma translation helpers
@ 2020-09-17 17:32   ` Christoph Hellwig
  0 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-17 17:32 UTC (permalink / raw)
  To: Russell King
  Cc: Aaro Koskinen, Tony Lindgren, linux-usb, linux-kernel, iommu,
	linux-omap, Robin Murphy, linux-arm-kernel

Now that the two remaining architectures that hooked into the DMA
translation directly use the range map instead, there is no need to
override phys_to_dma and dma_to_phys.  Remove asm/dma-direct.h after
switching the remaining callsites to the phys addr based generic
helpers instead of the PFN or virt addr based arm ones.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/arm/Kconfig                  |  1 -
 arch/arm/common/dmabounce.c       | 14 +++++-----
 arch/arm/include/asm/dma-direct.h | 45 -------------------------------
 arch/arm/mm/dma-mapping.c         | 20 +++++++-------
 4 files changed, 17 insertions(+), 63 deletions(-)
 delete mode 100644 arch/arm/include/asm/dma-direct.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index e00d94b1665876..2c4d608fa5fecf 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -14,7 +14,6 @@ config ARM
 	select ARCH_HAS_MEMBARRIER_SYNC_CORE
 	select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
 	select ARCH_HAS_PTE_SPECIAL if ARM_LPAE
-	select ARCH_HAS_PHYS_TO_DMA
 	select ARCH_HAS_SETUP_DMA_OPS
 	select ARCH_HAS_SET_MEMORY
 	select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index d3e00ea9208834..561d6d06c6b6aa 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -258,7 +258,7 @@ static inline dma_addr_t map_single(struct device *dev, void *ptr, size_t size,
 	}
 
 	dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n",
-		__func__, buf->ptr, virt_to_dma(dev, buf->ptr),
+		__func__, buf->ptr, phys_to_dma(dev, virt_to_phys(buf->ptr)),
 		buf->safe, buf->safe_dma_addr);
 
 	if ((dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL) &&
@@ -279,7 +279,7 @@ static inline void unmap_single(struct device *dev, struct safe_buffer *buf,
 	BUG_ON(buf->direction != dir);
 
 	dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n",
-		__func__, buf->ptr, virt_to_dma(dev, buf->ptr),
+		__func__, buf->ptr, phys_to_dma(dev, virt_to_phys(buf->ptr)),
 		buf->safe, buf->safe_dma_addr);
 
 	DO_STATS(dev->archdata.dmabounce->bounce_count++);
@@ -320,7 +320,7 @@ static dma_addr_t dmabounce_map_page(struct device *dev, struct page *page,
 	dev_dbg(dev, "%s(page=%p,off=%#lx,size=%zx,dir=%x)\n",
 		__func__, page, offset, size, dir);
 
-	dma_addr = pfn_to_dma(dev, page_to_pfn(page)) + offset;
+	dma_addr = phys_to_dma(dev, page_to_phys(page)) + offset;
 
 	ret = needs_bounce(dev, dma_addr, size);
 	if (ret < 0)
@@ -380,8 +380,8 @@ static int __dmabounce_sync_for_cpu(struct device *dev, dma_addr_t addr,
 	BUG_ON(buf->direction != dir);
 
 	dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x off=%#lx) mapped to %p (dma=%#x)\n",
-		__func__, buf->ptr, virt_to_dma(dev, buf->ptr), off,
-		buf->safe, buf->safe_dma_addr);
+		__func__, buf->ptr, phys_to_dma(dev, virt_to_phys(buf->ptr)),
+		off, buf->safe, buf->safe_dma_addr);
 
 	DO_STATS(dev->archdata.dmabounce->bounce_count++);
 
@@ -420,8 +420,8 @@ static int __dmabounce_sync_for_device(struct device *dev, dma_addr_t addr,
 	BUG_ON(buf->direction != dir);
 
 	dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x off=%#lx) mapped to %p (dma=%#x)\n",
-		__func__, buf->ptr, virt_to_dma(dev, buf->ptr), off,
-		buf->safe, buf->safe_dma_addr);
+		__func__, buf->ptr, phys_to_dma(dev, virt_to_phys(buf->ptr)),
+		off, buf->safe, buf->safe_dma_addr);
 
 	DO_STATS(dev->archdata.dmabounce->bounce_count++);
 
diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h
deleted file mode 100644
index 84cb4e30658891..00000000000000
--- a/arch/arm/include/asm/dma-direct.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* 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/virt_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->dma_range_map)
-		pfn = PFN_DOWN(translate_phys_to_dma(dev, PFN_PHYS(pfn)));
-	return (dma_addr_t)__pfn_to_phys(pfn);
-}
-
-static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
-{
-	unsigned long pfn = __phys_to_pfn(addr);
-
-	if (dev->dma_range_map)
-		pfn = PFN_DOWN(translate_dma_to_phys(dev, PFN_PHYS(pfn)));
-	return pfn;
-}
-
-static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
-{
-	return (dma_addr_t)__virt_to_bus((unsigned long)(addr));
-}
-
-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 */
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 8a8949174b1c06..9d800d0a53af7a 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -131,14 +131,14 @@ static dma_addr_t arm_dma_map_page(struct device *dev, struct page *page,
 {
 	if ((attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
 		__dma_page_cpu_to_dev(page, offset, size, dir);
-	return pfn_to_dma(dev, page_to_pfn(page)) + offset;
+	return phys_to_dma(dev, page_to_phys(page)) + offset;
 }
 
 static dma_addr_t arm_coherent_dma_map_page(struct device *dev, struct page *page,
 	     unsigned long offset, size_t size, enum dma_data_direction dir,
 	     unsigned long attrs)
 {
-	return pfn_to_dma(dev, page_to_pfn(page)) + offset;
+	return phys_to_dma(dev, page_to_phys(page)) + offset;
 }
 
 /**
@@ -159,7 +159,7 @@ static void arm_dma_unmap_page(struct device *dev, dma_addr_t handle,
 		size_t size, enum dma_data_direction dir, unsigned long attrs)
 {
 	if ((attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
-		__dma_page_dev_to_cpu(pfn_to_page(dma_to_pfn(dev, handle)),
+		__dma_page_dev_to_cpu(phys_to_page(dma_to_phys(dev, handle)),
 				      handle & ~PAGE_MASK, size, dir);
 }
 
@@ -167,7 +167,7 @@ static void arm_dma_sync_single_for_cpu(struct device *dev,
 		dma_addr_t handle, size_t size, enum dma_data_direction dir)
 {
 	unsigned int offset = handle & (PAGE_SIZE - 1);
-	struct page *page = pfn_to_page(dma_to_pfn(dev, handle-offset));
+	struct page *page = phys_to_page(dma_to_phys(dev, handle-offset));
 	__dma_page_dev_to_cpu(page, offset, size, dir);
 }
 
@@ -175,7 +175,7 @@ static void arm_dma_sync_single_for_device(struct device *dev,
 		dma_addr_t handle, size_t size, enum dma_data_direction dir)
 {
 	unsigned int offset = handle & (PAGE_SIZE - 1);
-	struct page *page = pfn_to_page(dma_to_pfn(dev, handle-offset));
+	struct page *page = phys_to_page(dma_to_phys(dev, handle-offset));
 	__dma_page_cpu_to_dev(page, offset, size, dir);
 }
 
@@ -193,7 +193,7 @@ static int arm_dma_supported(struct device *dev, u64 mask)
 	 * Translate the device's DMA mask to a PFN limit.  This
 	 * PFN number includes the page which we can DMA to.
 	 */
-	return dma_to_pfn(dev, mask) >= max_dma_pfn;
+	return PHYS_PFN(dma_to_phys(dev, mask)) >= max_dma_pfn;
 }
 
 const struct dma_map_ops arm_dma_ops = {
@@ -722,7 +722,7 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
 	if (page) {
 		unsigned long flags;
 
-		*handle = pfn_to_dma(dev, page_to_pfn(page));
+		*handle = phys_to_dma(dev, page_to_phys(page));
 		buf->virt = args.want_vaddr ? addr : page;
 
 		spin_lock_irqsave(&arm_dma_bufs_lock, flags);
@@ -762,7 +762,7 @@ static int __arm_dma_mmap(struct device *dev, struct vm_area_struct *vma,
 	int ret = -ENXIO;
 	unsigned long nr_vma_pages = vma_pages(vma);
 	unsigned long nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
-	unsigned long pfn = dma_to_pfn(dev, dma_addr);
+	unsigned long pfn = PHYS_PFN(dma_to_phys(dev, dma_addr));
 	unsigned long off = vma->vm_pgoff;
 
 	if (dma_mmap_from_dev_coherent(dev, vma, cpu_addr, size, &ret))
@@ -803,7 +803,7 @@ static void __arm_dma_free(struct device *dev, size_t size, void *cpu_addr,
 			   dma_addr_t handle, unsigned long attrs,
 			   bool is_coherent)
 {
-	struct page *page = pfn_to_page(dma_to_pfn(dev, handle));
+	struct page *page = phys_to_page(dma_to_phys(dev, handle));
 	struct arm_dma_buffer *buf;
 	struct arm_dma_free_args args = {
 		.dev = dev,
@@ -837,7 +837,7 @@ int arm_dma_get_sgtable(struct device *dev, struct sg_table *sgt,
 		 void *cpu_addr, dma_addr_t handle, size_t size,
 		 unsigned long attrs)
 {
-	unsigned long pfn = dma_to_pfn(dev, handle);
+	unsigned long pfn = PHYS_PFN(dma_to_phys(dev, handle));
 	struct page *page;
 	int ret;
 
-- 
2.28.0

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 4/4] ARM/dma-mapping: remove the arm specific phys to dma translation helpers
@ 2020-09-17 17:32   ` Christoph Hellwig
  0 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-17 17:32 UTC (permalink / raw)
  To: Russell King
  Cc: Aaro Koskinen, Tony Lindgren, linux-usb, linux-kernel, iommu,
	linux-omap, Robin Murphy, linux-arm-kernel

Now that the two remaining architectures that hooked into the DMA
translation directly use the range map instead, there is no need to
override phys_to_dma and dma_to_phys.  Remove asm/dma-direct.h after
switching the remaining callsites to the phys addr based generic
helpers instead of the PFN or virt addr based arm ones.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/arm/Kconfig                  |  1 -
 arch/arm/common/dmabounce.c       | 14 +++++-----
 arch/arm/include/asm/dma-direct.h | 45 -------------------------------
 arch/arm/mm/dma-mapping.c         | 20 +++++++-------
 4 files changed, 17 insertions(+), 63 deletions(-)
 delete mode 100644 arch/arm/include/asm/dma-direct.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index e00d94b1665876..2c4d608fa5fecf 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -14,7 +14,6 @@ config ARM
 	select ARCH_HAS_MEMBARRIER_SYNC_CORE
 	select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
 	select ARCH_HAS_PTE_SPECIAL if ARM_LPAE
-	select ARCH_HAS_PHYS_TO_DMA
 	select ARCH_HAS_SETUP_DMA_OPS
 	select ARCH_HAS_SET_MEMORY
 	select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index d3e00ea9208834..561d6d06c6b6aa 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -258,7 +258,7 @@ static inline dma_addr_t map_single(struct device *dev, void *ptr, size_t size,
 	}
 
 	dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n",
-		__func__, buf->ptr, virt_to_dma(dev, buf->ptr),
+		__func__, buf->ptr, phys_to_dma(dev, virt_to_phys(buf->ptr)),
 		buf->safe, buf->safe_dma_addr);
 
 	if ((dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL) &&
@@ -279,7 +279,7 @@ static inline void unmap_single(struct device *dev, struct safe_buffer *buf,
 	BUG_ON(buf->direction != dir);
 
 	dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n",
-		__func__, buf->ptr, virt_to_dma(dev, buf->ptr),
+		__func__, buf->ptr, phys_to_dma(dev, virt_to_phys(buf->ptr)),
 		buf->safe, buf->safe_dma_addr);
 
 	DO_STATS(dev->archdata.dmabounce->bounce_count++);
@@ -320,7 +320,7 @@ static dma_addr_t dmabounce_map_page(struct device *dev, struct page *page,
 	dev_dbg(dev, "%s(page=%p,off=%#lx,size=%zx,dir=%x)\n",
 		__func__, page, offset, size, dir);
 
-	dma_addr = pfn_to_dma(dev, page_to_pfn(page)) + offset;
+	dma_addr = phys_to_dma(dev, page_to_phys(page)) + offset;
 
 	ret = needs_bounce(dev, dma_addr, size);
 	if (ret < 0)
@@ -380,8 +380,8 @@ static int __dmabounce_sync_for_cpu(struct device *dev, dma_addr_t addr,
 	BUG_ON(buf->direction != dir);
 
 	dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x off=%#lx) mapped to %p (dma=%#x)\n",
-		__func__, buf->ptr, virt_to_dma(dev, buf->ptr), off,
-		buf->safe, buf->safe_dma_addr);
+		__func__, buf->ptr, phys_to_dma(dev, virt_to_phys(buf->ptr)),
+		off, buf->safe, buf->safe_dma_addr);
 
 	DO_STATS(dev->archdata.dmabounce->bounce_count++);
 
@@ -420,8 +420,8 @@ static int __dmabounce_sync_for_device(struct device *dev, dma_addr_t addr,
 	BUG_ON(buf->direction != dir);
 
 	dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x off=%#lx) mapped to %p (dma=%#x)\n",
-		__func__, buf->ptr, virt_to_dma(dev, buf->ptr), off,
-		buf->safe, buf->safe_dma_addr);
+		__func__, buf->ptr, phys_to_dma(dev, virt_to_phys(buf->ptr)),
+		off, buf->safe, buf->safe_dma_addr);
 
 	DO_STATS(dev->archdata.dmabounce->bounce_count++);
 
diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h
deleted file mode 100644
index 84cb4e30658891..00000000000000
--- a/arch/arm/include/asm/dma-direct.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* 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/virt_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->dma_range_map)
-		pfn = PFN_DOWN(translate_phys_to_dma(dev, PFN_PHYS(pfn)));
-	return (dma_addr_t)__pfn_to_phys(pfn);
-}
-
-static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
-{
-	unsigned long pfn = __phys_to_pfn(addr);
-
-	if (dev->dma_range_map)
-		pfn = PFN_DOWN(translate_dma_to_phys(dev, PFN_PHYS(pfn)));
-	return pfn;
-}
-
-static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
-{
-	return (dma_addr_t)__virt_to_bus((unsigned long)(addr));
-}
-
-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 */
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 8a8949174b1c06..9d800d0a53af7a 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -131,14 +131,14 @@ static dma_addr_t arm_dma_map_page(struct device *dev, struct page *page,
 {
 	if ((attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
 		__dma_page_cpu_to_dev(page, offset, size, dir);
-	return pfn_to_dma(dev, page_to_pfn(page)) + offset;
+	return phys_to_dma(dev, page_to_phys(page)) + offset;
 }
 
 static dma_addr_t arm_coherent_dma_map_page(struct device *dev, struct page *page,
 	     unsigned long offset, size_t size, enum dma_data_direction dir,
 	     unsigned long attrs)
 {
-	return pfn_to_dma(dev, page_to_pfn(page)) + offset;
+	return phys_to_dma(dev, page_to_phys(page)) + offset;
 }
 
 /**
@@ -159,7 +159,7 @@ static void arm_dma_unmap_page(struct device *dev, dma_addr_t handle,
 		size_t size, enum dma_data_direction dir, unsigned long attrs)
 {
 	if ((attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
-		__dma_page_dev_to_cpu(pfn_to_page(dma_to_pfn(dev, handle)),
+		__dma_page_dev_to_cpu(phys_to_page(dma_to_phys(dev, handle)),
 				      handle & ~PAGE_MASK, size, dir);
 }
 
@@ -167,7 +167,7 @@ static void arm_dma_sync_single_for_cpu(struct device *dev,
 		dma_addr_t handle, size_t size, enum dma_data_direction dir)
 {
 	unsigned int offset = handle & (PAGE_SIZE - 1);
-	struct page *page = pfn_to_page(dma_to_pfn(dev, handle-offset));
+	struct page *page = phys_to_page(dma_to_phys(dev, handle-offset));
 	__dma_page_dev_to_cpu(page, offset, size, dir);
 }
 
@@ -175,7 +175,7 @@ static void arm_dma_sync_single_for_device(struct device *dev,
 		dma_addr_t handle, size_t size, enum dma_data_direction dir)
 {
 	unsigned int offset = handle & (PAGE_SIZE - 1);
-	struct page *page = pfn_to_page(dma_to_pfn(dev, handle-offset));
+	struct page *page = phys_to_page(dma_to_phys(dev, handle-offset));
 	__dma_page_cpu_to_dev(page, offset, size, dir);
 }
 
@@ -193,7 +193,7 @@ static int arm_dma_supported(struct device *dev, u64 mask)
 	 * Translate the device's DMA mask to a PFN limit.  This
 	 * PFN number includes the page which we can DMA to.
 	 */
-	return dma_to_pfn(dev, mask) >= max_dma_pfn;
+	return PHYS_PFN(dma_to_phys(dev, mask)) >= max_dma_pfn;
 }
 
 const struct dma_map_ops arm_dma_ops = {
@@ -722,7 +722,7 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
 	if (page) {
 		unsigned long flags;
 
-		*handle = pfn_to_dma(dev, page_to_pfn(page));
+		*handle = phys_to_dma(dev, page_to_phys(page));
 		buf->virt = args.want_vaddr ? addr : page;
 
 		spin_lock_irqsave(&arm_dma_bufs_lock, flags);
@@ -762,7 +762,7 @@ static int __arm_dma_mmap(struct device *dev, struct vm_area_struct *vma,
 	int ret = -ENXIO;
 	unsigned long nr_vma_pages = vma_pages(vma);
 	unsigned long nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
-	unsigned long pfn = dma_to_pfn(dev, dma_addr);
+	unsigned long pfn = PHYS_PFN(dma_to_phys(dev, dma_addr));
 	unsigned long off = vma->vm_pgoff;
 
 	if (dma_mmap_from_dev_coherent(dev, vma, cpu_addr, size, &ret))
@@ -803,7 +803,7 @@ static void __arm_dma_free(struct device *dev, size_t size, void *cpu_addr,
 			   dma_addr_t handle, unsigned long attrs,
 			   bool is_coherent)
 {
-	struct page *page = pfn_to_page(dma_to_pfn(dev, handle));
+	struct page *page = phys_to_page(dma_to_phys(dev, handle));
 	struct arm_dma_buffer *buf;
 	struct arm_dma_free_args args = {
 		.dev = dev,
@@ -837,7 +837,7 @@ int arm_dma_get_sgtable(struct device *dev, struct sg_table *sgt,
 		 void *cpu_addr, dma_addr_t handle, size_t size,
 		 unsigned long attrs)
 {
-	unsigned long pfn = dma_to_pfn(dev, handle);
+	unsigned long pfn = PHYS_PFN(dma_to_phys(dev, handle));
 	struct page *page;
 	int ret;
 
-- 
2.28.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* Re: [PATCH 3/4] ARM/dma-mapping: don't handle NULL devices in dma-direct.h
  2020-09-17 17:32   ` Christoph Hellwig
  (?)
@ 2020-09-17 18:50     ` Russell King - ARM Linux admin
  -1 siblings, 0 replies; 42+ messages in thread
From: Russell King - ARM Linux admin @ 2020-09-17 18:50 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Aaro Koskinen, Tony Lindgren, Robin Murphy, iommu,
	linux-arm-kernel, linux-kernel, linux-omap, linux-usb

On Thu, Sep 17, 2020 at 07:32:28PM +0200, Christoph Hellwig wrote:
> The DMA API removed support for not passing in a device a long time
> ago, so remove the NULL checks.

What happens with ISA devices?

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 3/4] ARM/dma-mapping: don't handle NULL devices in dma-direct.h
@ 2020-09-17 18:50     ` Russell King - ARM Linux admin
  0 siblings, 0 replies; 42+ messages in thread
From: Russell King - ARM Linux admin @ 2020-09-17 18:50 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Aaro Koskinen, Tony Lindgren, linux-usb, linux-kernel, iommu,
	linux-omap, Robin Murphy, linux-arm-kernel

On Thu, Sep 17, 2020 at 07:32:28PM +0200, Christoph Hellwig wrote:
> The DMA API removed support for not passing in a device a long time
> ago, so remove the NULL checks.

What happens with ISA devices?

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 3/4] ARM/dma-mapping: don't handle NULL devices in dma-direct.h
@ 2020-09-17 18:50     ` Russell King - ARM Linux admin
  0 siblings, 0 replies; 42+ messages in thread
From: Russell King - ARM Linux admin @ 2020-09-17 18:50 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Aaro Koskinen, Tony Lindgren, linux-usb, linux-kernel, iommu,
	linux-omap, Robin Murphy, linux-arm-kernel

On Thu, Sep 17, 2020 at 07:32:28PM +0200, Christoph Hellwig wrote:
> The DMA API removed support for not passing in a device a long time
> ago, so remove the NULL checks.

What happens with ISA devices?

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 2/4] ARM/footbridge: switch to use dma_direct_set_offset for lbus DMA offsets
  2020-09-17 17:32   ` Christoph Hellwig
  (?)
@ 2020-09-17 18:53     ` Russell King - ARM Linux admin
  -1 siblings, 0 replies; 42+ messages in thread
From: Russell King - ARM Linux admin @ 2020-09-17 18:53 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Aaro Koskinen, Tony Lindgren, Robin Murphy, iommu,
	linux-arm-kernel, linux-kernel, linux-omap, linux-usb

On Thu, Sep 17, 2020 at 07:32:27PM +0200, Christoph Hellwig wrote:
>  static int __init cats_pci_init(void)
>  {
> -	if (machine_is_cats())
> -		pci_common_init(&cats_pci);
> +	if (!machine_is_cats())
> +		return 0;
> +	bus_register_notifier(&pci_bus_type, &footbridge_pci_dma_nb);
> +	pci_common_init(&cats_pci);

I'd prefer these things to retain a positive-logic construct, so:

	if (machine_is_cats()) {
		bus_register_notifier(&pci_bus_type, &footbridge_pci_dma_nb);
		pci_common_init(&cats_pci);
	}

It's the same number of lines.

Otherwise, I think it's fine. I'll try to find some spare time to give
it a go on a Netwinder.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 2/4] ARM/footbridge: switch to use dma_direct_set_offset for lbus DMA offsets
@ 2020-09-17 18:53     ` Russell King - ARM Linux admin
  0 siblings, 0 replies; 42+ messages in thread
From: Russell King - ARM Linux admin @ 2020-09-17 18:53 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Aaro Koskinen, Tony Lindgren, linux-usb, linux-kernel, iommu,
	linux-omap, Robin Murphy, linux-arm-kernel

On Thu, Sep 17, 2020 at 07:32:27PM +0200, Christoph Hellwig wrote:
>  static int __init cats_pci_init(void)
>  {
> -	if (machine_is_cats())
> -		pci_common_init(&cats_pci);
> +	if (!machine_is_cats())
> +		return 0;
> +	bus_register_notifier(&pci_bus_type, &footbridge_pci_dma_nb);
> +	pci_common_init(&cats_pci);

I'd prefer these things to retain a positive-logic construct, so:

	if (machine_is_cats()) {
		bus_register_notifier(&pci_bus_type, &footbridge_pci_dma_nb);
		pci_common_init(&cats_pci);
	}

It's the same number of lines.

Otherwise, I think it's fine. I'll try to find some spare time to give
it a go on a Netwinder.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 2/4] ARM/footbridge: switch to use dma_direct_set_offset for lbus DMA offsets
@ 2020-09-17 18:53     ` Russell King - ARM Linux admin
  0 siblings, 0 replies; 42+ messages in thread
From: Russell King - ARM Linux admin @ 2020-09-17 18:53 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Aaro Koskinen, Tony Lindgren, linux-usb, linux-kernel, iommu,
	linux-omap, Robin Murphy, linux-arm-kernel

On Thu, Sep 17, 2020 at 07:32:27PM +0200, Christoph Hellwig wrote:
>  static int __init cats_pci_init(void)
>  {
> -	if (machine_is_cats())
> -		pci_common_init(&cats_pci);
> +	if (!machine_is_cats())
> +		return 0;
> +	bus_register_notifier(&pci_bus_type, &footbridge_pci_dma_nb);
> +	pci_common_init(&cats_pci);

I'd prefer these things to retain a positive-logic construct, so:

	if (machine_is_cats()) {
		bus_register_notifier(&pci_bus_type, &footbridge_pci_dma_nb);
		pci_common_init(&cats_pci);
	}

It's the same number of lines.

Otherwise, I think it's fine. I'll try to find some spare time to give
it a go on a Netwinder.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 3/4] ARM/dma-mapping: don't handle NULL devices in dma-direct.h
  2020-09-17 18:50     ` Russell King - ARM Linux admin
  (?)
@ 2020-09-18  5:10       ` Christoph Hellwig
  -1 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-18  5:10 UTC (permalink / raw)
  To: Russell King - ARM Linux admin
  Cc: Christoph Hellwig, Aaro Koskinen, Tony Lindgren, Robin Murphy,
	iommu, linux-arm-kernel, linux-kernel, linux-omap, linux-usb

On Thu, Sep 17, 2020 at 07:50:10PM +0100, Russell King - ARM Linux admin wrote:
> On Thu, Sep 17, 2020 at 07:32:28PM +0200, Christoph Hellwig wrote:
> > The DMA API removed support for not passing in a device a long time
> > ago, so remove the NULL checks.
> 
> What happens with ISA devices?

For actual drivers they've been switched to struct isa_driver, which
provides a struct device.  For some of the special case like the
arch/arm/kernel/dma-isa.c we now use static struct device instances.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 3/4] ARM/dma-mapping: don't handle NULL devices in dma-direct.h
@ 2020-09-18  5:10       ` Christoph Hellwig
  0 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-18  5:10 UTC (permalink / raw)
  To: Russell King - ARM Linux admin
  Cc: Aaro Koskinen, Tony Lindgren, linux-usb, linux-kernel, iommu,
	linux-omap, Robin Murphy, Christoph Hellwig, linux-arm-kernel

On Thu, Sep 17, 2020 at 07:50:10PM +0100, Russell King - ARM Linux admin wrote:
> On Thu, Sep 17, 2020 at 07:32:28PM +0200, Christoph Hellwig wrote:
> > The DMA API removed support for not passing in a device a long time
> > ago, so remove the NULL checks.
> 
> What happens with ISA devices?

For actual drivers they've been switched to struct isa_driver, which
provides a struct device.  For some of the special case like the
arch/arm/kernel/dma-isa.c we now use static struct device instances.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 3/4] ARM/dma-mapping: don't handle NULL devices in dma-direct.h
@ 2020-09-18  5:10       ` Christoph Hellwig
  0 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-18  5:10 UTC (permalink / raw)
  To: Russell King - ARM Linux admin
  Cc: Aaro Koskinen, Tony Lindgren, linux-usb, linux-kernel, iommu,
	linux-omap, Robin Murphy, Christoph Hellwig, linux-arm-kernel

On Thu, Sep 17, 2020 at 07:50:10PM +0100, Russell King - ARM Linux admin wrote:
> On Thu, Sep 17, 2020 at 07:32:28PM +0200, Christoph Hellwig wrote:
> > The DMA API removed support for not passing in a device a long time
> > ago, so remove the NULL checks.
> 
> What happens with ISA devices?

For actual drivers they've been switched to struct isa_driver, which
provides a struct device.  For some of the special case like the
arch/arm/kernel/dma-isa.c we now use static struct device instances.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets
  2020-09-17 17:32   ` Christoph Hellwig
  (?)
@ 2020-09-18  5:49     ` Tony Lindgren
  -1 siblings, 0 replies; 42+ messages in thread
From: Tony Lindgren @ 2020-09-18  5:49 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Russell King, Aaro Koskinen, Robin Murphy, iommu,
	linux-arm-kernel, linux-kernel, linux-omap, linux-usb,
	Janusz Krzysztofik

* Christoph Hellwig <hch@lst.de> [200917 17:37]:
> Switch the omap1510 platform ohci device to use dma_direct_set_offset
> to set the DMA offset instead of using direct hooks into the DMA
> mapping code and remove the now unused hooks.

Looks nice to me :) I still can't test this probably for few more weeks
though but hopefully Aaro or Janusz (Added to Cc) can test it.

Regards,

Tony

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  arch/arm/include/asm/dma-direct.h         | 18 -------------
>  arch/arm/mach-omap1/include/mach/memory.h | 31 -----------------------
>  arch/arm/mach-omap1/usb.c                 | 22 ++++++++++++++++
>  3 files changed, 22 insertions(+), 49 deletions(-)
> 
> diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h
> index 436544aeb83405..77fcb7ee5ec907 100644
> --- a/arch/arm/include/asm/dma-direct.h
> +++ b/arch/arm/include/asm/dma-direct.h
> @@ -9,7 +9,6 @@
>   * functions used internally by the DMA-mapping API to provide DMA
>   * addresses. They must not be used by drivers.
>   */
> -#ifndef __arch_pfn_to_dma
>  static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
>  {
>  	if (dev && dev->dma_range_map)
> @@ -34,23 +33,6 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
>  	return (dma_addr_t)__virt_to_bus((unsigned long)(addr));
>  }
>  
> -#else
> -static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
> -{
> -	return __arch_pfn_to_dma(dev, pfn);
> -}
> -
> -static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
> -{
> -	return __arch_dma_to_pfn(dev, addr);
> -}
> -
> -static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
> -{
> -	return __arch_virt_to_dma(dev, addr);
> -}
> -#endif
> -
>  static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
>  {
>  	unsigned int offset = paddr & ~PAGE_MASK;
> diff --git a/arch/arm/mach-omap1/include/mach/memory.h b/arch/arm/mach-omap1/include/mach/memory.h
> index 1142560e0078f5..36bc0000cb6ab8 100644
> --- a/arch/arm/mach-omap1/include/mach/memory.h
> +++ b/arch/arm/mach-omap1/include/mach/memory.h
> @@ -14,42 +14,11 @@
>   * OMAP-1510 bus address is translated into a Local Bus address if the
>   * OMAP bus type is lbus. We do the address translation based on the
>   * device overriding the defaults used in the dma-mapping API.
> - * Note that the is_lbus_device() test is not very efficient on 1510
> - * because of the strncmp().
>   */
> -#if defined(CONFIG_ARCH_OMAP15XX) && !defined(__ASSEMBLER__)
>  
>  /*
>   * OMAP-1510 Local Bus address offset
>   */
>  #define OMAP1510_LB_OFFSET	UL(0x30000000)
>  
> -#define virt_to_lbus(x)		((x) - PAGE_OFFSET + OMAP1510_LB_OFFSET)
> -#define lbus_to_virt(x)		((x) - OMAP1510_LB_OFFSET + PAGE_OFFSET)
> -#define is_lbus_device(dev)	(cpu_is_omap15xx() && dev && (strncmp(dev_name(dev), "ohci", 4) == 0))
> -
> -#define __arch_pfn_to_dma(dev, pfn)	\
> -	({ dma_addr_t __dma = __pfn_to_phys(pfn); \
> -	   if (is_lbus_device(dev)) \
> -		__dma = __dma - PHYS_OFFSET + OMAP1510_LB_OFFSET; \
> -	   __dma; })
> -
> -#define __arch_dma_to_pfn(dev, addr)	\
> -	({ dma_addr_t __dma = addr;				\
> -	   if (is_lbus_device(dev))				\
> -		__dma += PHYS_OFFSET - OMAP1510_LB_OFFSET;	\
> -	   __phys_to_pfn(__dma);				\
> -	})
> -
> -#define __arch_dma_to_virt(dev, addr)	({ (void *) (is_lbus_device(dev) ? \
> -						lbus_to_virt(addr) : \
> -						__phys_to_virt(addr)); })
> -
> -#define __arch_virt_to_dma(dev, addr)	({ unsigned long __addr = (unsigned long)(addr); \
> -					   (dma_addr_t) (is_lbus_device(dev) ? \
> -						virt_to_lbus(__addr) : \
> -						__virt_to_phys(__addr)); })
> -
> -#endif	/* CONFIG_ARCH_OMAP15XX */
> -
>  #endif
> diff --git a/arch/arm/mach-omap1/usb.c b/arch/arm/mach-omap1/usb.c
> index d8e9bbda8f7bdd..ba8566204ea9f4 100644
> --- a/arch/arm/mach-omap1/usb.c
> +++ b/arch/arm/mach-omap1/usb.c
> @@ -9,6 +9,7 @@
>  #include <linux/kernel.h>
>  #include <linux/init.h>
>  #include <linux/platform_device.h>
> +#include <linux/dma-mapping.h>
>  #include <linux/io.h>
>  
>  #include <asm/irq.h>
> @@ -542,6 +543,25 @@ static u32 __init omap1_usb2_init(unsigned nwires, unsigned alt_pingroup)
>  /* ULPD_APLL_CTRL */
>  #define APLL_NDPLL_SWITCH	(1 << 0)
>  
> +static int omap_1510_usb_ohci_notifier(struct notifier_block *nb,
> +		unsigned long event, void *data)
> +{
> +	struct device *dev = data;
> +
> +	if (event != BUS_NOTIFY_ADD_DEVICE)
> +		return NOTIFY_DONE;
> +
> +	if (strncmp(dev_name(dev), "ohci", 4) == 0 &&
> +	    dma_direct_set_offset(dev, PHYS_OFFSET, OMAP1510_LB_OFFSET,
> +			(u64)-1))
> +		WARN_ONCE(1, "failed to set DMA offset\n");
> +	return NOTIFY_OK;
> +}
> +
> +static struct notifier_block omap_1510_usb_ohci_nb = {
> +	.notifier_call		= omap_1510_usb_ohci_notifier,
> +};
> +
>  static void __init omap_1510_usb_init(struct omap_usb_config *config)
>  {
>  	unsigned int val;
> @@ -600,6 +620,8 @@ static void __init omap_1510_usb_init(struct omap_usb_config *config)
>  	if (config->register_host) {
>  		int status;
>  
> +		bus_register_notifier(&platform_bus_type,
> +				      &omap_1510_usb_ohci_nb);
>  		ohci_device.dev.platform_data = config;
>  		status = platform_device_register(&ohci_device);
>  		if (status)
> -- 
> 2.28.0
> 

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets
@ 2020-09-18  5:49     ` Tony Lindgren
  0 siblings, 0 replies; 42+ messages in thread
From: Tony Lindgren @ 2020-09-18  5:49 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Aaro Koskinen, linux-usb, Janusz Krzysztofik, linux-kernel,
	Russell King, iommu, linux-omap, Robin Murphy, linux-arm-kernel

* Christoph Hellwig <hch@lst.de> [200917 17:37]:
> Switch the omap1510 platform ohci device to use dma_direct_set_offset
> to set the DMA offset instead of using direct hooks into the DMA
> mapping code and remove the now unused hooks.

Looks nice to me :) I still can't test this probably for few more weeks
though but hopefully Aaro or Janusz (Added to Cc) can test it.

Regards,

Tony

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  arch/arm/include/asm/dma-direct.h         | 18 -------------
>  arch/arm/mach-omap1/include/mach/memory.h | 31 -----------------------
>  arch/arm/mach-omap1/usb.c                 | 22 ++++++++++++++++
>  3 files changed, 22 insertions(+), 49 deletions(-)
> 
> diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h
> index 436544aeb83405..77fcb7ee5ec907 100644
> --- a/arch/arm/include/asm/dma-direct.h
> +++ b/arch/arm/include/asm/dma-direct.h
> @@ -9,7 +9,6 @@
>   * functions used internally by the DMA-mapping API to provide DMA
>   * addresses. They must not be used by drivers.
>   */
> -#ifndef __arch_pfn_to_dma
>  static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
>  {
>  	if (dev && dev->dma_range_map)
> @@ -34,23 +33,6 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
>  	return (dma_addr_t)__virt_to_bus((unsigned long)(addr));
>  }
>  
> -#else
> -static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
> -{
> -	return __arch_pfn_to_dma(dev, pfn);
> -}
> -
> -static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
> -{
> -	return __arch_dma_to_pfn(dev, addr);
> -}
> -
> -static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
> -{
> -	return __arch_virt_to_dma(dev, addr);
> -}
> -#endif
> -
>  static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
>  {
>  	unsigned int offset = paddr & ~PAGE_MASK;
> diff --git a/arch/arm/mach-omap1/include/mach/memory.h b/arch/arm/mach-omap1/include/mach/memory.h
> index 1142560e0078f5..36bc0000cb6ab8 100644
> --- a/arch/arm/mach-omap1/include/mach/memory.h
> +++ b/arch/arm/mach-omap1/include/mach/memory.h
> @@ -14,42 +14,11 @@
>   * OMAP-1510 bus address is translated into a Local Bus address if the
>   * OMAP bus type is lbus. We do the address translation based on the
>   * device overriding the defaults used in the dma-mapping API.
> - * Note that the is_lbus_device() test is not very efficient on 1510
> - * because of the strncmp().
>   */
> -#if defined(CONFIG_ARCH_OMAP15XX) && !defined(__ASSEMBLER__)
>  
>  /*
>   * OMAP-1510 Local Bus address offset
>   */
>  #define OMAP1510_LB_OFFSET	UL(0x30000000)
>  
> -#define virt_to_lbus(x)		((x) - PAGE_OFFSET + OMAP1510_LB_OFFSET)
> -#define lbus_to_virt(x)		((x) - OMAP1510_LB_OFFSET + PAGE_OFFSET)
> -#define is_lbus_device(dev)	(cpu_is_omap15xx() && dev && (strncmp(dev_name(dev), "ohci", 4) == 0))
> -
> -#define __arch_pfn_to_dma(dev, pfn)	\
> -	({ dma_addr_t __dma = __pfn_to_phys(pfn); \
> -	   if (is_lbus_device(dev)) \
> -		__dma = __dma - PHYS_OFFSET + OMAP1510_LB_OFFSET; \
> -	   __dma; })
> -
> -#define __arch_dma_to_pfn(dev, addr)	\
> -	({ dma_addr_t __dma = addr;				\
> -	   if (is_lbus_device(dev))				\
> -		__dma += PHYS_OFFSET - OMAP1510_LB_OFFSET;	\
> -	   __phys_to_pfn(__dma);				\
> -	})
> -
> -#define __arch_dma_to_virt(dev, addr)	({ (void *) (is_lbus_device(dev) ? \
> -						lbus_to_virt(addr) : \
> -						__phys_to_virt(addr)); })
> -
> -#define __arch_virt_to_dma(dev, addr)	({ unsigned long __addr = (unsigned long)(addr); \
> -					   (dma_addr_t) (is_lbus_device(dev) ? \
> -						virt_to_lbus(__addr) : \
> -						__virt_to_phys(__addr)); })
> -
> -#endif	/* CONFIG_ARCH_OMAP15XX */
> -
>  #endif
> diff --git a/arch/arm/mach-omap1/usb.c b/arch/arm/mach-omap1/usb.c
> index d8e9bbda8f7bdd..ba8566204ea9f4 100644
> --- a/arch/arm/mach-omap1/usb.c
> +++ b/arch/arm/mach-omap1/usb.c
> @@ -9,6 +9,7 @@
>  #include <linux/kernel.h>
>  #include <linux/init.h>
>  #include <linux/platform_device.h>
> +#include <linux/dma-mapping.h>
>  #include <linux/io.h>
>  
>  #include <asm/irq.h>
> @@ -542,6 +543,25 @@ static u32 __init omap1_usb2_init(unsigned nwires, unsigned alt_pingroup)
>  /* ULPD_APLL_CTRL */
>  #define APLL_NDPLL_SWITCH	(1 << 0)
>  
> +static int omap_1510_usb_ohci_notifier(struct notifier_block *nb,
> +		unsigned long event, void *data)
> +{
> +	struct device *dev = data;
> +
> +	if (event != BUS_NOTIFY_ADD_DEVICE)
> +		return NOTIFY_DONE;
> +
> +	if (strncmp(dev_name(dev), "ohci", 4) == 0 &&
> +	    dma_direct_set_offset(dev, PHYS_OFFSET, OMAP1510_LB_OFFSET,
> +			(u64)-1))
> +		WARN_ONCE(1, "failed to set DMA offset\n");
> +	return NOTIFY_OK;
> +}
> +
> +static struct notifier_block omap_1510_usb_ohci_nb = {
> +	.notifier_call		= omap_1510_usb_ohci_notifier,
> +};
> +
>  static void __init omap_1510_usb_init(struct omap_usb_config *config)
>  {
>  	unsigned int val;
> @@ -600,6 +620,8 @@ static void __init omap_1510_usb_init(struct omap_usb_config *config)
>  	if (config->register_host) {
>  		int status;
>  
> +		bus_register_notifier(&platform_bus_type,
> +				      &omap_1510_usb_ohci_nb);
>  		ohci_device.dev.platform_data = config;
>  		status = platform_device_register(&ohci_device);
>  		if (status)
> -- 
> 2.28.0
> 
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets
@ 2020-09-18  5:49     ` Tony Lindgren
  0 siblings, 0 replies; 42+ messages in thread
From: Tony Lindgren @ 2020-09-18  5:49 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Aaro Koskinen, linux-usb, Janusz Krzysztofik, linux-kernel,
	Russell King, iommu, linux-omap, Robin Murphy, linux-arm-kernel

* Christoph Hellwig <hch@lst.de> [200917 17:37]:
> Switch the omap1510 platform ohci device to use dma_direct_set_offset
> to set the DMA offset instead of using direct hooks into the DMA
> mapping code and remove the now unused hooks.

Looks nice to me :) I still can't test this probably for few more weeks
though but hopefully Aaro or Janusz (Added to Cc) can test it.

Regards,

Tony

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  arch/arm/include/asm/dma-direct.h         | 18 -------------
>  arch/arm/mach-omap1/include/mach/memory.h | 31 -----------------------
>  arch/arm/mach-omap1/usb.c                 | 22 ++++++++++++++++
>  3 files changed, 22 insertions(+), 49 deletions(-)
> 
> diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h
> index 436544aeb83405..77fcb7ee5ec907 100644
> --- a/arch/arm/include/asm/dma-direct.h
> +++ b/arch/arm/include/asm/dma-direct.h
> @@ -9,7 +9,6 @@
>   * functions used internally by the DMA-mapping API to provide DMA
>   * addresses. They must not be used by drivers.
>   */
> -#ifndef __arch_pfn_to_dma
>  static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
>  {
>  	if (dev && dev->dma_range_map)
> @@ -34,23 +33,6 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
>  	return (dma_addr_t)__virt_to_bus((unsigned long)(addr));
>  }
>  
> -#else
> -static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
> -{
> -	return __arch_pfn_to_dma(dev, pfn);
> -}
> -
> -static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
> -{
> -	return __arch_dma_to_pfn(dev, addr);
> -}
> -
> -static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
> -{
> -	return __arch_virt_to_dma(dev, addr);
> -}
> -#endif
> -
>  static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
>  {
>  	unsigned int offset = paddr & ~PAGE_MASK;
> diff --git a/arch/arm/mach-omap1/include/mach/memory.h b/arch/arm/mach-omap1/include/mach/memory.h
> index 1142560e0078f5..36bc0000cb6ab8 100644
> --- a/arch/arm/mach-omap1/include/mach/memory.h
> +++ b/arch/arm/mach-omap1/include/mach/memory.h
> @@ -14,42 +14,11 @@
>   * OMAP-1510 bus address is translated into a Local Bus address if the
>   * OMAP bus type is lbus. We do the address translation based on the
>   * device overriding the defaults used in the dma-mapping API.
> - * Note that the is_lbus_device() test is not very efficient on 1510
> - * because of the strncmp().
>   */
> -#if defined(CONFIG_ARCH_OMAP15XX) && !defined(__ASSEMBLER__)
>  
>  /*
>   * OMAP-1510 Local Bus address offset
>   */
>  #define OMAP1510_LB_OFFSET	UL(0x30000000)
>  
> -#define virt_to_lbus(x)		((x) - PAGE_OFFSET + OMAP1510_LB_OFFSET)
> -#define lbus_to_virt(x)		((x) - OMAP1510_LB_OFFSET + PAGE_OFFSET)
> -#define is_lbus_device(dev)	(cpu_is_omap15xx() && dev && (strncmp(dev_name(dev), "ohci", 4) == 0))
> -
> -#define __arch_pfn_to_dma(dev, pfn)	\
> -	({ dma_addr_t __dma = __pfn_to_phys(pfn); \
> -	   if (is_lbus_device(dev)) \
> -		__dma = __dma - PHYS_OFFSET + OMAP1510_LB_OFFSET; \
> -	   __dma; })
> -
> -#define __arch_dma_to_pfn(dev, addr)	\
> -	({ dma_addr_t __dma = addr;				\
> -	   if (is_lbus_device(dev))				\
> -		__dma += PHYS_OFFSET - OMAP1510_LB_OFFSET;	\
> -	   __phys_to_pfn(__dma);				\
> -	})
> -
> -#define __arch_dma_to_virt(dev, addr)	({ (void *) (is_lbus_device(dev) ? \
> -						lbus_to_virt(addr) : \
> -						__phys_to_virt(addr)); })
> -
> -#define __arch_virt_to_dma(dev, addr)	({ unsigned long __addr = (unsigned long)(addr); \
> -					   (dma_addr_t) (is_lbus_device(dev) ? \
> -						virt_to_lbus(__addr) : \
> -						__virt_to_phys(__addr)); })
> -
> -#endif	/* CONFIG_ARCH_OMAP15XX */
> -
>  #endif
> diff --git a/arch/arm/mach-omap1/usb.c b/arch/arm/mach-omap1/usb.c
> index d8e9bbda8f7bdd..ba8566204ea9f4 100644
> --- a/arch/arm/mach-omap1/usb.c
> +++ b/arch/arm/mach-omap1/usb.c
> @@ -9,6 +9,7 @@
>  #include <linux/kernel.h>
>  #include <linux/init.h>
>  #include <linux/platform_device.h>
> +#include <linux/dma-mapping.h>
>  #include <linux/io.h>
>  
>  #include <asm/irq.h>
> @@ -542,6 +543,25 @@ static u32 __init omap1_usb2_init(unsigned nwires, unsigned alt_pingroup)
>  /* ULPD_APLL_CTRL */
>  #define APLL_NDPLL_SWITCH	(1 << 0)
>  
> +static int omap_1510_usb_ohci_notifier(struct notifier_block *nb,
> +		unsigned long event, void *data)
> +{
> +	struct device *dev = data;
> +
> +	if (event != BUS_NOTIFY_ADD_DEVICE)
> +		return NOTIFY_DONE;
> +
> +	if (strncmp(dev_name(dev), "ohci", 4) == 0 &&
> +	    dma_direct_set_offset(dev, PHYS_OFFSET, OMAP1510_LB_OFFSET,
> +			(u64)-1))
> +		WARN_ONCE(1, "failed to set DMA offset\n");
> +	return NOTIFY_OK;
> +}
> +
> +static struct notifier_block omap_1510_usb_ohci_nb = {
> +	.notifier_call		= omap_1510_usb_ohci_notifier,
> +};
> +
>  static void __init omap_1510_usb_init(struct omap_usb_config *config)
>  {
>  	unsigned int val;
> @@ -600,6 +620,8 @@ static void __init omap_1510_usb_init(struct omap_usb_config *config)
>  	if (config->register_host) {
>  		int status;
>  
> +		bus_register_notifier(&platform_bus_type,
> +				      &omap_1510_usb_ohci_nb);
>  		ohci_device.dev.platform_data = config;
>  		status = platform_device_register(&ohci_device);
>  		if (status)
> -- 
> 2.28.0
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets
  2020-09-18  5:49     ` Tony Lindgren
  (?)
@ 2020-09-19 22:29       ` Janusz Krzysztofik
  -1 siblings, 0 replies; 42+ messages in thread
From: Janusz Krzysztofik @ 2020-09-19 22:29 UTC (permalink / raw)
  To: Christoph Hellwig, Tony Lindgren
  Cc: Russell King, Aaro Koskinen, Robin Murphy, iommu,
	linux-arm-kernel, linux-kernel, linux-omap, linux-usb

Hi Tony,

On Friday, September 18, 2020 7:49:33 A.M. CEST Tony Lindgren wrote:
> * Christoph Hellwig <hch@lst.de> [200917 17:37]:
> > Switch the omap1510 platform ohci device to use dma_direct_set_offset
> > to set the DMA offset instead of using direct hooks into the DMA
> > mapping code and remove the now unused hooks.
> 
> Looks nice to me :) I still can't test this probably for few more weeks
> though but hopefully Aaro or Janusz (Added to Cc) can test it.

Works for me on Amstrad Delta (tested with a USB ethernet adapter).

Tested-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>

Thanks,
Janusz

> 
> Regards,
> 
> Tony
> 
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > ---
> >  arch/arm/include/asm/dma-direct.h         | 18 -------------
> >  arch/arm/mach-omap1/include/mach/memory.h | 31 -----------------------
> >  arch/arm/mach-omap1/usb.c                 | 22 ++++++++++++++++
> >  3 files changed, 22 insertions(+), 49 deletions(-)
> > 
> > diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h
> > index 436544aeb83405..77fcb7ee5ec907 100644
> > --- a/arch/arm/include/asm/dma-direct.h
> > +++ b/arch/arm/include/asm/dma-direct.h
> > @@ -9,7 +9,6 @@
> >   * functions used internally by the DMA-mapping API to provide DMA
> >   * addresses. They must not be used by drivers.
> >   */
> > -#ifndef __arch_pfn_to_dma
> >  static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
> >  {
> >  	if (dev && dev->dma_range_map)
> > @@ -34,23 +33,6 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
> >  	return (dma_addr_t)__virt_to_bus((unsigned long)(addr));
> >  }
> >  
> > -#else
> > -static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
> > -{
> > -	return __arch_pfn_to_dma(dev, pfn);
> > -}
> > -
> > -static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
> > -{
> > -	return __arch_dma_to_pfn(dev, addr);
> > -}
> > -
> > -static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
> > -{
> > -	return __arch_virt_to_dma(dev, addr);
> > -}
> > -#endif
> > -
> >  static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
> >  {
> >  	unsigned int offset = paddr & ~PAGE_MASK;
> > diff --git a/arch/arm/mach-omap1/include/mach/memory.h b/arch/arm/mach-omap1/include/mach/memory.h
> > index 1142560e0078f5..36bc0000cb6ab8 100644
> > --- a/arch/arm/mach-omap1/include/mach/memory.h
> > +++ b/arch/arm/mach-omap1/include/mach/memory.h
> > @@ -14,42 +14,11 @@
> >   * OMAP-1510 bus address is translated into a Local Bus address if the
> >   * OMAP bus type is lbus. We do the address translation based on the
> >   * device overriding the defaults used in the dma-mapping API.
> > - * Note that the is_lbus_device() test is not very efficient on 1510
> > - * because of the strncmp().
> >   */
> > -#if defined(CONFIG_ARCH_OMAP15XX) && !defined(__ASSEMBLER__)
> >  
> >  /*
> >   * OMAP-1510 Local Bus address offset
> >   */
> >  #define OMAP1510_LB_OFFSET	UL(0x30000000)
> >  
> > -#define virt_to_lbus(x)		((x) - PAGE_OFFSET + OMAP1510_LB_OFFSET)
> > -#define lbus_to_virt(x)		((x) - OMAP1510_LB_OFFSET + PAGE_OFFSET)
> > -#define is_lbus_device(dev)	(cpu_is_omap15xx() && dev && (strncmp(dev_name(dev), "ohci", 4) == 0))
> > -
> > -#define __arch_pfn_to_dma(dev, pfn)	\
> > -	({ dma_addr_t __dma = __pfn_to_phys(pfn); \
> > -	   if (is_lbus_device(dev)) \
> > -		__dma = __dma - PHYS_OFFSET + OMAP1510_LB_OFFSET; \
> > -	   __dma; })
> > -
> > -#define __arch_dma_to_pfn(dev, addr)	\
> > -	({ dma_addr_t __dma = addr;				\
> > -	   if (is_lbus_device(dev))				\
> > -		__dma += PHYS_OFFSET - OMAP1510_LB_OFFSET;	\
> > -	   __phys_to_pfn(__dma);				\
> > -	})
> > -
> > -#define __arch_dma_to_virt(dev, addr)	({ (void *) (is_lbus_device(dev) ? \
> > -						lbus_to_virt(addr) : \
> > -						__phys_to_virt(addr)); })
> > -
> > -#define __arch_virt_to_dma(dev, addr)	({ unsigned long __addr = (unsigned long)(addr); \
> > -					   (dma_addr_t) (is_lbus_device(dev) ? \
> > -						virt_to_lbus(__addr) : \
> > -						__virt_to_phys(__addr)); })
> > -
> > -#endif	/* CONFIG_ARCH_OMAP15XX */
> > -
> >  #endif
> > diff --git a/arch/arm/mach-omap1/usb.c b/arch/arm/mach-omap1/usb.c
> > index d8e9bbda8f7bdd..ba8566204ea9f4 100644
> > --- a/arch/arm/mach-omap1/usb.c
> > +++ b/arch/arm/mach-omap1/usb.c
> > @@ -9,6 +9,7 @@
> >  #include <linux/kernel.h>
> >  #include <linux/init.h>
> >  #include <linux/platform_device.h>
> > +#include <linux/dma-mapping.h>
> >  #include <linux/io.h>
> >  
> >  #include <asm/irq.h>
> > @@ -542,6 +543,25 @@ static u32 __init omap1_usb2_init(unsigned nwires, unsigned alt_pingroup)
> >  /* ULPD_APLL_CTRL */
> >  #define APLL_NDPLL_SWITCH	(1 << 0)
> >  
> > +static int omap_1510_usb_ohci_notifier(struct notifier_block *nb,
> > +		unsigned long event, void *data)
> > +{
> > +	struct device *dev = data;
> > +
> > +	if (event != BUS_NOTIFY_ADD_DEVICE)
> > +		return NOTIFY_DONE;
> > +
> > +	if (strncmp(dev_name(dev), "ohci", 4) == 0 &&
> > +	    dma_direct_set_offset(dev, PHYS_OFFSET, OMAP1510_LB_OFFSET,
> > +			(u64)-1))
> > +		WARN_ONCE(1, "failed to set DMA offset\n");
> > +	return NOTIFY_OK;
> > +}
> > +
> > +static struct notifier_block omap_1510_usb_ohci_nb = {
> > +	.notifier_call		= omap_1510_usb_ohci_notifier,
> > +};
> > +
> >  static void __init omap_1510_usb_init(struct omap_usb_config *config)
> >  {
> >  	unsigned int val;
> > @@ -600,6 +620,8 @@ static void __init omap_1510_usb_init(struct omap_usb_config *config)
> >  	if (config->register_host) {
> >  		int status;
> >  
> > +		bus_register_notifier(&platform_bus_type,
> > +				      &omap_1510_usb_ohci_nb);
> >  		ohci_device.dev.platform_data = config;
> >  		status = platform_device_register(&ohci_device);
> >  		if (status)
> 





^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets
@ 2020-09-19 22:29       ` Janusz Krzysztofik
  0 siblings, 0 replies; 42+ messages in thread
From: Janusz Krzysztofik @ 2020-09-19 22:29 UTC (permalink / raw)
  To: Christoph Hellwig, Tony Lindgren
  Cc: Aaro Koskinen, linux-usb, linux-kernel, Russell King, iommu,
	linux-omap, Robin Murphy, linux-arm-kernel

Hi Tony,

On Friday, September 18, 2020 7:49:33 A.M. CEST Tony Lindgren wrote:
> * Christoph Hellwig <hch@lst.de> [200917 17:37]:
> > Switch the omap1510 platform ohci device to use dma_direct_set_offset
> > to set the DMA offset instead of using direct hooks into the DMA
> > mapping code and remove the now unused hooks.
> 
> Looks nice to me :) I still can't test this probably for few more weeks
> though but hopefully Aaro or Janusz (Added to Cc) can test it.

Works for me on Amstrad Delta (tested with a USB ethernet adapter).

Tested-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>

Thanks,
Janusz

> 
> Regards,
> 
> Tony
> 
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > ---
> >  arch/arm/include/asm/dma-direct.h         | 18 -------------
> >  arch/arm/mach-omap1/include/mach/memory.h | 31 -----------------------
> >  arch/arm/mach-omap1/usb.c                 | 22 ++++++++++++++++
> >  3 files changed, 22 insertions(+), 49 deletions(-)
> > 
> > diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h
> > index 436544aeb83405..77fcb7ee5ec907 100644
> > --- a/arch/arm/include/asm/dma-direct.h
> > +++ b/arch/arm/include/asm/dma-direct.h
> > @@ -9,7 +9,6 @@
> >   * functions used internally by the DMA-mapping API to provide DMA
> >   * addresses. They must not be used by drivers.
> >   */
> > -#ifndef __arch_pfn_to_dma
> >  static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
> >  {
> >  	if (dev && dev->dma_range_map)
> > @@ -34,23 +33,6 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
> >  	return (dma_addr_t)__virt_to_bus((unsigned long)(addr));
> >  }
> >  
> > -#else
> > -static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
> > -{
> > -	return __arch_pfn_to_dma(dev, pfn);
> > -}
> > -
> > -static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
> > -{
> > -	return __arch_dma_to_pfn(dev, addr);
> > -}
> > -
> > -static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
> > -{
> > -	return __arch_virt_to_dma(dev, addr);
> > -}
> > -#endif
> > -
> >  static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
> >  {
> >  	unsigned int offset = paddr & ~PAGE_MASK;
> > diff --git a/arch/arm/mach-omap1/include/mach/memory.h b/arch/arm/mach-omap1/include/mach/memory.h
> > index 1142560e0078f5..36bc0000cb6ab8 100644
> > --- a/arch/arm/mach-omap1/include/mach/memory.h
> > +++ b/arch/arm/mach-omap1/include/mach/memory.h
> > @@ -14,42 +14,11 @@
> >   * OMAP-1510 bus address is translated into a Local Bus address if the
> >   * OMAP bus type is lbus. We do the address translation based on the
> >   * device overriding the defaults used in the dma-mapping API.
> > - * Note that the is_lbus_device() test is not very efficient on 1510
> > - * because of the strncmp().
> >   */
> > -#if defined(CONFIG_ARCH_OMAP15XX) && !defined(__ASSEMBLER__)
> >  
> >  /*
> >   * OMAP-1510 Local Bus address offset
> >   */
> >  #define OMAP1510_LB_OFFSET	UL(0x30000000)
> >  
> > -#define virt_to_lbus(x)		((x) - PAGE_OFFSET + OMAP1510_LB_OFFSET)
> > -#define lbus_to_virt(x)		((x) - OMAP1510_LB_OFFSET + PAGE_OFFSET)
> > -#define is_lbus_device(dev)	(cpu_is_omap15xx() && dev && (strncmp(dev_name(dev), "ohci", 4) == 0))
> > -
> > -#define __arch_pfn_to_dma(dev, pfn)	\
> > -	({ dma_addr_t __dma = __pfn_to_phys(pfn); \
> > -	   if (is_lbus_device(dev)) \
> > -		__dma = __dma - PHYS_OFFSET + OMAP1510_LB_OFFSET; \
> > -	   __dma; })
> > -
> > -#define __arch_dma_to_pfn(dev, addr)	\
> > -	({ dma_addr_t __dma = addr;				\
> > -	   if (is_lbus_device(dev))				\
> > -		__dma += PHYS_OFFSET - OMAP1510_LB_OFFSET;	\
> > -	   __phys_to_pfn(__dma);				\
> > -	})
> > -
> > -#define __arch_dma_to_virt(dev, addr)	({ (void *) (is_lbus_device(dev) ? \
> > -						lbus_to_virt(addr) : \
> > -						__phys_to_virt(addr)); })
> > -
> > -#define __arch_virt_to_dma(dev, addr)	({ unsigned long __addr = (unsigned long)(addr); \
> > -					   (dma_addr_t) (is_lbus_device(dev) ? \
> > -						virt_to_lbus(__addr) : \
> > -						__virt_to_phys(__addr)); })
> > -
> > -#endif	/* CONFIG_ARCH_OMAP15XX */
> > -
> >  #endif
> > diff --git a/arch/arm/mach-omap1/usb.c b/arch/arm/mach-omap1/usb.c
> > index d8e9bbda8f7bdd..ba8566204ea9f4 100644
> > --- a/arch/arm/mach-omap1/usb.c
> > +++ b/arch/arm/mach-omap1/usb.c
> > @@ -9,6 +9,7 @@
> >  #include <linux/kernel.h>
> >  #include <linux/init.h>
> >  #include <linux/platform_device.h>
> > +#include <linux/dma-mapping.h>
> >  #include <linux/io.h>
> >  
> >  #include <asm/irq.h>
> > @@ -542,6 +543,25 @@ static u32 __init omap1_usb2_init(unsigned nwires, unsigned alt_pingroup)
> >  /* ULPD_APLL_CTRL */
> >  #define APLL_NDPLL_SWITCH	(1 << 0)
> >  
> > +static int omap_1510_usb_ohci_notifier(struct notifier_block *nb,
> > +		unsigned long event, void *data)
> > +{
> > +	struct device *dev = data;
> > +
> > +	if (event != BUS_NOTIFY_ADD_DEVICE)
> > +		return NOTIFY_DONE;
> > +
> > +	if (strncmp(dev_name(dev), "ohci", 4) == 0 &&
> > +	    dma_direct_set_offset(dev, PHYS_OFFSET, OMAP1510_LB_OFFSET,
> > +			(u64)-1))
> > +		WARN_ONCE(1, "failed to set DMA offset\n");
> > +	return NOTIFY_OK;
> > +}
> > +
> > +static struct notifier_block omap_1510_usb_ohci_nb = {
> > +	.notifier_call		= omap_1510_usb_ohci_notifier,
> > +};
> > +
> >  static void __init omap_1510_usb_init(struct omap_usb_config *config)
> >  {
> >  	unsigned int val;
> > @@ -600,6 +620,8 @@ static void __init omap_1510_usb_init(struct omap_usb_config *config)
> >  	if (config->register_host) {
> >  		int status;
> >  
> > +		bus_register_notifier(&platform_bus_type,
> > +				      &omap_1510_usb_ohci_nb);
> >  		ohci_device.dev.platform_data = config;
> >  		status = platform_device_register(&ohci_device);
> >  		if (status)
> 




_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets
@ 2020-09-19 22:29       ` Janusz Krzysztofik
  0 siblings, 0 replies; 42+ messages in thread
From: Janusz Krzysztofik @ 2020-09-19 22:29 UTC (permalink / raw)
  To: Christoph Hellwig, Tony Lindgren
  Cc: Aaro Koskinen, linux-usb, linux-kernel, Russell King, iommu,
	linux-omap, Robin Murphy, linux-arm-kernel

Hi Tony,

On Friday, September 18, 2020 7:49:33 A.M. CEST Tony Lindgren wrote:
> * Christoph Hellwig <hch@lst.de> [200917 17:37]:
> > Switch the omap1510 platform ohci device to use dma_direct_set_offset
> > to set the DMA offset instead of using direct hooks into the DMA
> > mapping code and remove the now unused hooks.
> 
> Looks nice to me :) I still can't test this probably for few more weeks
> though but hopefully Aaro or Janusz (Added to Cc) can test it.

Works for me on Amstrad Delta (tested with a USB ethernet adapter).

Tested-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>

Thanks,
Janusz

> 
> Regards,
> 
> Tony
> 
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > ---
> >  arch/arm/include/asm/dma-direct.h         | 18 -------------
> >  arch/arm/mach-omap1/include/mach/memory.h | 31 -----------------------
> >  arch/arm/mach-omap1/usb.c                 | 22 ++++++++++++++++
> >  3 files changed, 22 insertions(+), 49 deletions(-)
> > 
> > diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h
> > index 436544aeb83405..77fcb7ee5ec907 100644
> > --- a/arch/arm/include/asm/dma-direct.h
> > +++ b/arch/arm/include/asm/dma-direct.h
> > @@ -9,7 +9,6 @@
> >   * functions used internally by the DMA-mapping API to provide DMA
> >   * addresses. They must not be used by drivers.
> >   */
> > -#ifndef __arch_pfn_to_dma
> >  static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
> >  {
> >  	if (dev && dev->dma_range_map)
> > @@ -34,23 +33,6 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
> >  	return (dma_addr_t)__virt_to_bus((unsigned long)(addr));
> >  }
> >  
> > -#else
> > -static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
> > -{
> > -	return __arch_pfn_to_dma(dev, pfn);
> > -}
> > -
> > -static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
> > -{
> > -	return __arch_dma_to_pfn(dev, addr);
> > -}
> > -
> > -static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
> > -{
> > -	return __arch_virt_to_dma(dev, addr);
> > -}
> > -#endif
> > -
> >  static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
> >  {
> >  	unsigned int offset = paddr & ~PAGE_MASK;
> > diff --git a/arch/arm/mach-omap1/include/mach/memory.h b/arch/arm/mach-omap1/include/mach/memory.h
> > index 1142560e0078f5..36bc0000cb6ab8 100644
> > --- a/arch/arm/mach-omap1/include/mach/memory.h
> > +++ b/arch/arm/mach-omap1/include/mach/memory.h
> > @@ -14,42 +14,11 @@
> >   * OMAP-1510 bus address is translated into a Local Bus address if the
> >   * OMAP bus type is lbus. We do the address translation based on the
> >   * device overriding the defaults used in the dma-mapping API.
> > - * Note that the is_lbus_device() test is not very efficient on 1510
> > - * because of the strncmp().
> >   */
> > -#if defined(CONFIG_ARCH_OMAP15XX) && !defined(__ASSEMBLER__)
> >  
> >  /*
> >   * OMAP-1510 Local Bus address offset
> >   */
> >  #define OMAP1510_LB_OFFSET	UL(0x30000000)
> >  
> > -#define virt_to_lbus(x)		((x) - PAGE_OFFSET + OMAP1510_LB_OFFSET)
> > -#define lbus_to_virt(x)		((x) - OMAP1510_LB_OFFSET + PAGE_OFFSET)
> > -#define is_lbus_device(dev)	(cpu_is_omap15xx() && dev && (strncmp(dev_name(dev), "ohci", 4) == 0))
> > -
> > -#define __arch_pfn_to_dma(dev, pfn)	\
> > -	({ dma_addr_t __dma = __pfn_to_phys(pfn); \
> > -	   if (is_lbus_device(dev)) \
> > -		__dma = __dma - PHYS_OFFSET + OMAP1510_LB_OFFSET; \
> > -	   __dma; })
> > -
> > -#define __arch_dma_to_pfn(dev, addr)	\
> > -	({ dma_addr_t __dma = addr;				\
> > -	   if (is_lbus_device(dev))				\
> > -		__dma += PHYS_OFFSET - OMAP1510_LB_OFFSET;	\
> > -	   __phys_to_pfn(__dma);				\
> > -	})
> > -
> > -#define __arch_dma_to_virt(dev, addr)	({ (void *) (is_lbus_device(dev) ? \
> > -						lbus_to_virt(addr) : \
> > -						__phys_to_virt(addr)); })
> > -
> > -#define __arch_virt_to_dma(dev, addr)	({ unsigned long __addr = (unsigned long)(addr); \
> > -					   (dma_addr_t) (is_lbus_device(dev) ? \
> > -						virt_to_lbus(__addr) : \
> > -						__virt_to_phys(__addr)); })
> > -
> > -#endif	/* CONFIG_ARCH_OMAP15XX */
> > -
> >  #endif
> > diff --git a/arch/arm/mach-omap1/usb.c b/arch/arm/mach-omap1/usb.c
> > index d8e9bbda8f7bdd..ba8566204ea9f4 100644
> > --- a/arch/arm/mach-omap1/usb.c
> > +++ b/arch/arm/mach-omap1/usb.c
> > @@ -9,6 +9,7 @@
> >  #include <linux/kernel.h>
> >  #include <linux/init.h>
> >  #include <linux/platform_device.h>
> > +#include <linux/dma-mapping.h>
> >  #include <linux/io.h>
> >  
> >  #include <asm/irq.h>
> > @@ -542,6 +543,25 @@ static u32 __init omap1_usb2_init(unsigned nwires, unsigned alt_pingroup)
> >  /* ULPD_APLL_CTRL */
> >  #define APLL_NDPLL_SWITCH	(1 << 0)
> >  
> > +static int omap_1510_usb_ohci_notifier(struct notifier_block *nb,
> > +		unsigned long event, void *data)
> > +{
> > +	struct device *dev = data;
> > +
> > +	if (event != BUS_NOTIFY_ADD_DEVICE)
> > +		return NOTIFY_DONE;
> > +
> > +	if (strncmp(dev_name(dev), "ohci", 4) == 0 &&
> > +	    dma_direct_set_offset(dev, PHYS_OFFSET, OMAP1510_LB_OFFSET,
> > +			(u64)-1))
> > +		WARN_ONCE(1, "failed to set DMA offset\n");
> > +	return NOTIFY_OK;
> > +}
> > +
> > +static struct notifier_block omap_1510_usb_ohci_nb = {
> > +	.notifier_call		= omap_1510_usb_ohci_notifier,
> > +};
> > +
> >  static void __init omap_1510_usb_init(struct omap_usb_config *config)
> >  {
> >  	unsigned int val;
> > @@ -600,6 +620,8 @@ static void __init omap_1510_usb_init(struct omap_usb_config *config)
> >  	if (config->register_host) {
> >  		int status;
> >  
> > +		bus_register_notifier(&platform_bus_type,
> > +				      &omap_1510_usb_ohci_nb);
> >  		ohci_device.dev.platform_data = config;
> >  		status = platform_device_register(&ohci_device);
> >  		if (status)
> 





_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets
  2020-09-19 22:29       ` Janusz Krzysztofik
  (?)
@ 2020-09-21  6:44         ` Tony Lindgren
  -1 siblings, 0 replies; 42+ messages in thread
From: Tony Lindgren @ 2020-09-21  6:44 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Christoph Hellwig, Russell King, Aaro Koskinen, Robin Murphy,
	iommu, linux-arm-kernel, linux-kernel, linux-omap, linux-usb

* Janusz Krzysztofik <jmkrzyszt@gmail.com> [200919 22:29]:
> Hi Tony,
> 
> On Friday, September 18, 2020 7:49:33 A.M. CEST Tony Lindgren wrote:
> > * Christoph Hellwig <hch@lst.de> [200917 17:37]:
> > > Switch the omap1510 platform ohci device to use dma_direct_set_offset
> > > to set the DMA offset instead of using direct hooks into the DMA
> > > mapping code and remove the now unused hooks.
> > 
> > Looks nice to me :) I still can't test this probably for few more weeks
> > though but hopefully Aaro or Janusz (Added to Cc) can test it.
> 
> Works for me on Amstrad Delta (tested with a USB ethernet adapter).
> 
> Tested-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>

Great, good to hear! And thanks for testing it.

Christoph, feel free to queue this along with the other patches:

Acked-by: Tony Lindgren <tony@atomide.com>

Or let me know if you want me to pick it up.

Regards,

Tony

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets
@ 2020-09-21  6:44         ` Tony Lindgren
  0 siblings, 0 replies; 42+ messages in thread
From: Tony Lindgren @ 2020-09-21  6:44 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Aaro Koskinen, linux-usb, Russell King, linux-kernel, iommu,
	linux-omap, Robin Murphy, Christoph Hellwig, linux-arm-kernel

* Janusz Krzysztofik <jmkrzyszt@gmail.com> [200919 22:29]:
> Hi Tony,
> 
> On Friday, September 18, 2020 7:49:33 A.M. CEST Tony Lindgren wrote:
> > * Christoph Hellwig <hch@lst.de> [200917 17:37]:
> > > Switch the omap1510 platform ohci device to use dma_direct_set_offset
> > > to set the DMA offset instead of using direct hooks into the DMA
> > > mapping code and remove the now unused hooks.
> > 
> > Looks nice to me :) I still can't test this probably for few more weeks
> > though but hopefully Aaro or Janusz (Added to Cc) can test it.
> 
> Works for me on Amstrad Delta (tested with a USB ethernet adapter).
> 
> Tested-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>

Great, good to hear! And thanks for testing it.

Christoph, feel free to queue this along with the other patches:

Acked-by: Tony Lindgren <tony@atomide.com>

Or let me know if you want me to pick it up.

Regards,

Tony
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets
@ 2020-09-21  6:44         ` Tony Lindgren
  0 siblings, 0 replies; 42+ messages in thread
From: Tony Lindgren @ 2020-09-21  6:44 UTC (permalink / raw)
  To: Janusz Krzysztofik
  Cc: Aaro Koskinen, linux-usb, Russell King, linux-kernel, iommu,
	linux-omap, Robin Murphy, Christoph Hellwig, linux-arm-kernel

* Janusz Krzysztofik <jmkrzyszt@gmail.com> [200919 22:29]:
> Hi Tony,
> 
> On Friday, September 18, 2020 7:49:33 A.M. CEST Tony Lindgren wrote:
> > * Christoph Hellwig <hch@lst.de> [200917 17:37]:
> > > Switch the omap1510 platform ohci device to use dma_direct_set_offset
> > > to set the DMA offset instead of using direct hooks into the DMA
> > > mapping code and remove the now unused hooks.
> > 
> > Looks nice to me :) I still can't test this probably for few more weeks
> > though but hopefully Aaro or Janusz (Added to Cc) can test it.
> 
> Works for me on Amstrad Delta (tested with a USB ethernet adapter).
> 
> Tested-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>

Great, good to hear! And thanks for testing it.

Christoph, feel free to queue this along with the other patches:

Acked-by: Tony Lindgren <tony@atomide.com>

Or let me know if you want me to pick it up.

Regards,

Tony

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets
  2020-09-21  6:44         ` Tony Lindgren
  (?)
@ 2020-09-21  6:47           ` Christoph Hellwig
  -1 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-21  6:47 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Janusz Krzysztofik, Christoph Hellwig, Russell King,
	Aaro Koskinen, Robin Murphy, iommu, linux-arm-kernel,
	linux-kernel, linux-omap, linux-usb

On Mon, Sep 21, 2020 at 09:44:18AM +0300, Tony Lindgren wrote:
> * Janusz Krzysztofik <jmkrzyszt@gmail.com> [200919 22:29]:
> > Hi Tony,
> > 
> > On Friday, September 18, 2020 7:49:33 A.M. CEST Tony Lindgren wrote:
> > > * Christoph Hellwig <hch@lst.de> [200917 17:37]:
> > > > Switch the omap1510 platform ohci device to use dma_direct_set_offset
> > > > to set the DMA offset instead of using direct hooks into the DMA
> > > > mapping code and remove the now unused hooks.
> > > 
> > > Looks nice to me :) I still can't test this probably for few more weeks
> > > though but hopefully Aaro or Janusz (Added to Cc) can test it.
> > 
> > Works for me on Amstrad Delta (tested with a USB ethernet adapter).
> > 
> > Tested-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
> 
> Great, good to hear! And thanks for testing it.
> 
> Christoph, feel free to queue this along with the other patches:
> 
> Acked-by: Tony Lindgren <tony@atomide.com>
> 
> Or let me know if you want me to pick it up.

I'd prefer to pick it up through the dma-mapping tree, but preferably
I'd pick the whole series up once Russell has tested footwinder.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets
@ 2020-09-21  6:47           ` Christoph Hellwig
  0 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-21  6:47 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Aaro Koskinen, linux-usb, Janusz Krzysztofik, Russell King,
	linux-kernel, iommu, linux-omap, Robin Murphy, Christoph Hellwig,
	linux-arm-kernel

On Mon, Sep 21, 2020 at 09:44:18AM +0300, Tony Lindgren wrote:
> * Janusz Krzysztofik <jmkrzyszt@gmail.com> [200919 22:29]:
> > Hi Tony,
> > 
> > On Friday, September 18, 2020 7:49:33 A.M. CEST Tony Lindgren wrote:
> > > * Christoph Hellwig <hch@lst.de> [200917 17:37]:
> > > > Switch the omap1510 platform ohci device to use dma_direct_set_offset
> > > > to set the DMA offset instead of using direct hooks into the DMA
> > > > mapping code and remove the now unused hooks.
> > > 
> > > Looks nice to me :) I still can't test this probably for few more weeks
> > > though but hopefully Aaro or Janusz (Added to Cc) can test it.
> > 
> > Works for me on Amstrad Delta (tested with a USB ethernet adapter).
> > 
> > Tested-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
> 
> Great, good to hear! And thanks for testing it.
> 
> Christoph, feel free to queue this along with the other patches:
> 
> Acked-by: Tony Lindgren <tony@atomide.com>
> 
> Or let me know if you want me to pick it up.

I'd prefer to pick it up through the dma-mapping tree, but preferably
I'd pick the whole series up once Russell has tested footwinder.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets
@ 2020-09-21  6:47           ` Christoph Hellwig
  0 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-21  6:47 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Aaro Koskinen, linux-usb, Janusz Krzysztofik, Russell King,
	linux-kernel, iommu, linux-omap, Robin Murphy, Christoph Hellwig,
	linux-arm-kernel

On Mon, Sep 21, 2020 at 09:44:18AM +0300, Tony Lindgren wrote:
> * Janusz Krzysztofik <jmkrzyszt@gmail.com> [200919 22:29]:
> > Hi Tony,
> > 
> > On Friday, September 18, 2020 7:49:33 A.M. CEST Tony Lindgren wrote:
> > > * Christoph Hellwig <hch@lst.de> [200917 17:37]:
> > > > Switch the omap1510 platform ohci device to use dma_direct_set_offset
> > > > to set the DMA offset instead of using direct hooks into the DMA
> > > > mapping code and remove the now unused hooks.
> > > 
> > > Looks nice to me :) I still can't test this probably for few more weeks
> > > though but hopefully Aaro or Janusz (Added to Cc) can test it.
> > 
> > Works for me on Amstrad Delta (tested with a USB ethernet adapter).
> > 
> > Tested-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
> 
> Great, good to hear! And thanks for testing it.
> 
> Christoph, feel free to queue this along with the other patches:
> 
> Acked-by: Tony Lindgren <tony@atomide.com>
> 
> Or let me know if you want me to pick it up.

I'd prefer to pick it up through the dma-mapping tree, but preferably
I'd pick the whole series up once Russell has tested footwinder.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets
  2020-09-21  6:47           ` Christoph Hellwig
  (?)
@ 2020-09-23 10:05             ` Russell King - ARM Linux admin
  -1 siblings, 0 replies; 42+ messages in thread
From: Russell King - ARM Linux admin @ 2020-09-23 10:05 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Tony Lindgren, Janusz Krzysztofik, Aaro Koskinen, Robin Murphy,
	iommu, linux-arm-kernel, linux-kernel, linux-omap, linux-usb

On Mon, Sep 21, 2020 at 08:47:23AM +0200, Christoph Hellwig wrote:
> On Mon, Sep 21, 2020 at 09:44:18AM +0300, Tony Lindgren wrote:
> > * Janusz Krzysztofik <jmkrzyszt@gmail.com> [200919 22:29]:
> > > Hi Tony,
> > > 
> > > On Friday, September 18, 2020 7:49:33 A.M. CEST Tony Lindgren wrote:
> > > > * Christoph Hellwig <hch@lst.de> [200917 17:37]:
> > > > > Switch the omap1510 platform ohci device to use dma_direct_set_offset
> > > > > to set the DMA offset instead of using direct hooks into the DMA
> > > > > mapping code and remove the now unused hooks.
> > > > 
> > > > Looks nice to me :) I still can't test this probably for few more weeks
> > > > though but hopefully Aaro or Janusz (Added to Cc) can test it.
> > > 
> > > Works for me on Amstrad Delta (tested with a USB ethernet adapter).
> > > 
> > > Tested-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
> > 
> > Great, good to hear! And thanks for testing it.
> > 
> > Christoph, feel free to queue this along with the other patches:
> > 
> > Acked-by: Tony Lindgren <tony@atomide.com>
> > 
> > Or let me know if you want me to pick it up.
> 
> I'd prefer to pick it up through the dma-mapping tree, but preferably
> I'd pick the whole series up once Russell has tested footwinder.

I don't think that's going to happen very soon... seems way too much
effort to pull down the appropriate tree to build and test.  Sorry.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets
@ 2020-09-23 10:05             ` Russell King - ARM Linux admin
  0 siblings, 0 replies; 42+ messages in thread
From: Russell King - ARM Linux admin @ 2020-09-23 10:05 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Aaro Koskinen, Tony Lindgren, linux-usb, Janusz Krzysztofik,
	linux-kernel, iommu, linux-omap, Robin Murphy, linux-arm-kernel

On Mon, Sep 21, 2020 at 08:47:23AM +0200, Christoph Hellwig wrote:
> On Mon, Sep 21, 2020 at 09:44:18AM +0300, Tony Lindgren wrote:
> > * Janusz Krzysztofik <jmkrzyszt@gmail.com> [200919 22:29]:
> > > Hi Tony,
> > > 
> > > On Friday, September 18, 2020 7:49:33 A.M. CEST Tony Lindgren wrote:
> > > > * Christoph Hellwig <hch@lst.de> [200917 17:37]:
> > > > > Switch the omap1510 platform ohci device to use dma_direct_set_offset
> > > > > to set the DMA offset instead of using direct hooks into the DMA
> > > > > mapping code and remove the now unused hooks.
> > > > 
> > > > Looks nice to me :) I still can't test this probably for few more weeks
> > > > though but hopefully Aaro or Janusz (Added to Cc) can test it.
> > > 
> > > Works for me on Amstrad Delta (tested with a USB ethernet adapter).
> > > 
> > > Tested-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
> > 
> > Great, good to hear! And thanks for testing it.
> > 
> > Christoph, feel free to queue this along with the other patches:
> > 
> > Acked-by: Tony Lindgren <tony@atomide.com>
> > 
> > Or let me know if you want me to pick it up.
> 
> I'd prefer to pick it up through the dma-mapping tree, but preferably
> I'd pick the whole series up once Russell has tested footwinder.

I don't think that's going to happen very soon... seems way too much
effort to pull down the appropriate tree to build and test.  Sorry.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets
@ 2020-09-23 10:05             ` Russell King - ARM Linux admin
  0 siblings, 0 replies; 42+ messages in thread
From: Russell King - ARM Linux admin @ 2020-09-23 10:05 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Aaro Koskinen, Tony Lindgren, linux-usb, Janusz Krzysztofik,
	linux-kernel, iommu, linux-omap, Robin Murphy, linux-arm-kernel

On Mon, Sep 21, 2020 at 08:47:23AM +0200, Christoph Hellwig wrote:
> On Mon, Sep 21, 2020 at 09:44:18AM +0300, Tony Lindgren wrote:
> > * Janusz Krzysztofik <jmkrzyszt@gmail.com> [200919 22:29]:
> > > Hi Tony,
> > > 
> > > On Friday, September 18, 2020 7:49:33 A.M. CEST Tony Lindgren wrote:
> > > > * Christoph Hellwig <hch@lst.de> [200917 17:37]:
> > > > > Switch the omap1510 platform ohci device to use dma_direct_set_offset
> > > > > to set the DMA offset instead of using direct hooks into the DMA
> > > > > mapping code and remove the now unused hooks.
> > > > 
> > > > Looks nice to me :) I still can't test this probably for few more weeks
> > > > though but hopefully Aaro or Janusz (Added to Cc) can test it.
> > > 
> > > Works for me on Amstrad Delta (tested with a USB ethernet adapter).
> > > 
> > > Tested-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
> > 
> > Great, good to hear! And thanks for testing it.
> > 
> > Christoph, feel free to queue this along with the other patches:
> > 
> > Acked-by: Tony Lindgren <tony@atomide.com>
> > 
> > Or let me know if you want me to pick it up.
> 
> I'd prefer to pick it up through the dma-mapping tree, but preferably
> I'd pick the whole series up once Russell has tested footwinder.

I don't think that's going to happen very soon... seems way too much
effort to pull down the appropriate tree to build and test.  Sorry.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets
  2020-09-21  6:44         ` Tony Lindgren
  (?)
@ 2020-09-25  4:16           ` Christoph Hellwig
  -1 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-25  4:16 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Janusz Krzysztofik, Christoph Hellwig, Russell King,
	Aaro Koskinen, Robin Murphy, iommu, linux-arm-kernel,
	linux-kernel, linux-omap, linux-usb

On Mon, Sep 21, 2020 at 09:44:18AM +0300, Tony Lindgren wrote:
> > > Looks nice to me :) I still can't test this probably for few more weeks
> > > though but hopefully Aaro or Janusz (Added to Cc) can test it.
> > 
> > Works for me on Amstrad Delta (tested with a USB ethernet adapter).
> > 
> > Tested-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
> 
> Great, good to hear! And thanks for testing it.
> 
> Christoph, feel free to queue this along with the other patches:
> 
> Acked-by: Tony Lindgren <tony@atomide.com>
> 
> Or let me know if you want me to pick it up.

I've pulled it in now that the other patches are unlikely to be
tested in time for 5.10.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets
@ 2020-09-25  4:16           ` Christoph Hellwig
  0 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-25  4:16 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Aaro Koskinen, linux-usb, Janusz Krzysztofik, Russell King,
	linux-kernel, iommu, linux-omap, Robin Murphy, Christoph Hellwig,
	linux-arm-kernel

On Mon, Sep 21, 2020 at 09:44:18AM +0300, Tony Lindgren wrote:
> > > Looks nice to me :) I still can't test this probably for few more weeks
> > > though but hopefully Aaro or Janusz (Added to Cc) can test it.
> > 
> > Works for me on Amstrad Delta (tested with a USB ethernet adapter).
> > 
> > Tested-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
> 
> Great, good to hear! And thanks for testing it.
> 
> Christoph, feel free to queue this along with the other patches:
> 
> Acked-by: Tony Lindgren <tony@atomide.com>
> 
> Or let me know if you want me to pick it up.

I've pulled it in now that the other patches are unlikely to be
tested in time for 5.10.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets
@ 2020-09-25  4:16           ` Christoph Hellwig
  0 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2020-09-25  4:16 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Aaro Koskinen, linux-usb, Janusz Krzysztofik, Russell King,
	linux-kernel, iommu, linux-omap, Robin Murphy, Christoph Hellwig,
	linux-arm-kernel

On Mon, Sep 21, 2020 at 09:44:18AM +0300, Tony Lindgren wrote:
> > > Looks nice to me :) I still can't test this probably for few more weeks
> > > though but hopefully Aaro or Janusz (Added to Cc) can test it.
> > 
> > Works for me on Amstrad Delta (tested with a USB ethernet adapter).
> > 
> > Tested-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
> 
> Great, good to hear! And thanks for testing it.
> 
> Christoph, feel free to queue this along with the other patches:
> 
> Acked-by: Tony Lindgren <tony@atomide.com>
> 
> Or let me know if you want me to pick it up.

I've pulled it in now that the other patches are unlikely to be
tested in time for 5.10.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 42+ messages in thread

end of thread, other threads:[~2020-09-25  4:17 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 17:32 RFC: remove the need for <asm/dma-direct.h> on ARM Christoph Hellwig
2020-09-17 17:32 ` Christoph Hellwig
2020-09-17 17:32 ` Christoph Hellwig
2020-09-17 17:32 ` [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets Christoph Hellwig
2020-09-17 17:32   ` Christoph Hellwig
2020-09-17 17:32   ` Christoph Hellwig
2020-09-18  5:49   ` Tony Lindgren
2020-09-18  5:49     ` Tony Lindgren
2020-09-18  5:49     ` Tony Lindgren
2020-09-19 22:29     ` Janusz Krzysztofik
2020-09-19 22:29       ` Janusz Krzysztofik
2020-09-19 22:29       ` Janusz Krzysztofik
2020-09-21  6:44       ` Tony Lindgren
2020-09-21  6:44         ` Tony Lindgren
2020-09-21  6:44         ` Tony Lindgren
2020-09-21  6:47         ` Christoph Hellwig
2020-09-21  6:47           ` Christoph Hellwig
2020-09-21  6:47           ` Christoph Hellwig
2020-09-23 10:05           ` Russell King - ARM Linux admin
2020-09-23 10:05             ` Russell King - ARM Linux admin
2020-09-23 10:05             ` Russell King - ARM Linux admin
2020-09-25  4:16         ` Christoph Hellwig
2020-09-25  4:16           ` Christoph Hellwig
2020-09-25  4:16           ` Christoph Hellwig
2020-09-17 17:32 ` [PATCH 2/4] ARM/footbridge: " Christoph Hellwig
2020-09-17 17:32   ` Christoph Hellwig
2020-09-17 17:32   ` Christoph Hellwig
2020-09-17 18:53   ` Russell King - ARM Linux admin
2020-09-17 18:53     ` Russell King - ARM Linux admin
2020-09-17 18:53     ` Russell King - ARM Linux admin
2020-09-17 17:32 ` [PATCH 3/4] ARM/dma-mapping: don't handle NULL devices in dma-direct.h Christoph Hellwig
2020-09-17 17:32   ` Christoph Hellwig
2020-09-17 17:32   ` Christoph Hellwig
2020-09-17 18:50   ` Russell King - ARM Linux admin
2020-09-17 18:50     ` Russell King - ARM Linux admin
2020-09-17 18:50     ` Russell King - ARM Linux admin
2020-09-18  5:10     ` Christoph Hellwig
2020-09-18  5:10       ` Christoph Hellwig
2020-09-18  5:10       ` Christoph Hellwig
2020-09-17 17:32 ` [PATCH 4/4] ARM/dma-mapping: remove the arm specific phys to dma translation helpers Christoph Hellwig
2020-09-17 17:32   ` Christoph Hellwig
2020-09-17 17:32   ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.