mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM
@ 2015-02-12 21:39 Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 01/24] usb: gadget: include common.h in header Lucas Stach
                   ` (24 more replies)
  0 siblings, 25 replies; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

This series introduces to Barebox the streaming DMA ops and implements
them for the ARM architecture. This will make it a lot easier to
get common cache maintenance operations for all architectures and in
turn allows for wider reuse of driver across architectures.

I've tested this on a Tegra124 which is known to fall over in all sorts
of funny ways if cache maintenance is broken. No odd behavior spotted.

The series is bisect-clean and I've compile tested it on some defconfigs,
but please go wild and TEST. I'll take any complaints.

Regards,
Lucas

Lucas Stach (24):
  usb: gadget: include common.h in header
  ARM: move virt<->phys translation to io.h
  dma: add streaming DMA ops
  ARM: move DMA alloc functions to dma.h
  ARM: implement streaming DMA ops
  AHCI: convert to streaming DMA ops
  MCI: dw-mmc: convert to streaming DMA ops
  MCI: imx: convert to streaming DMA ops
  MCI: tegra-sdmmc: convert to streaming DMA ops
  net: arc-emac: convert to streaming DMA ops
  net: cpsw: convert to streaming DMA ops
  net: at91_ether: convert to streaming DMA ops
  net: davinci_emac: convert to streaming DMA ops
  net: designware: convert to streaming DMA ops
  net: fec: convert to streaming DMA ops
  net: macb: convert to streaming DMA ops
  net: orion-gbe: convert to streaming DMA ops
  net: rtl8169: convert to streaming DMA ops
  net: xgmac: convert to streaming DMA ops
  usb: gadget: fsl_udc: convert to streaming DMA ops
  usb: host: ehci: convert to streaming DMA ops
  usb: host: ohci: convert to streaming DMA ops
  ARM: bcm2835: mbox: convert to streaming DMA ops
  ARM: MMU: unexport cache maintenance functions

 arch/arm/cpu/mmu.c                    | 49 +++++++++++++++++++++++------------
 arch/arm/include/asm/dma.h            | 30 ++++++++++++++++++++-
 arch/arm/include/asm/io.h             | 15 +++++++++++
 arch/arm/include/asm/mmu.h            | 45 --------------------------------
 arch/arm/mach-bcm2835/mbox.c          |  8 +++---
 drivers/ata/ahci.c                    | 14 +++++++---
 drivers/dma/apbh_dma.c                |  2 +-
 drivers/mci/Kconfig                   |  2 +-
 drivers/mci/dw_mmc.c                  | 25 +++++++++---------
 drivers/mci/imx-esdhc.c               | 28 ++++++++++++--------
 drivers/mci/tegra-sdmmc.c             | 26 ++++++++++---------
 drivers/mtd/nand/nand_mxs.c           |  2 +-
 drivers/net/Kconfig                   |  1 +
 drivers/net/altera_tse.c              |  1 +
 drivers/net/arc_emac.c                | 17 +++++++-----
 drivers/net/at91_ether.c              | 11 ++++++--
 drivers/net/cpsw.c                    | 11 +++++---
 drivers/net/davinci_emac.c            |  9 ++++---
 drivers/net/designware.c              | 20 ++++++++------
 drivers/net/fec_imx.c                 | 14 +++++++---
 drivers/net/macb.c                    |  9 +++++--
 drivers/net/mvneta.c                  |  1 +
 drivers/net/orion-gbe.c               | 14 ++++++----
 drivers/net/rtl8139.c                 |  1 +
 drivers/net/rtl8169.c                 | 31 ++++++++++------------
 drivers/net/xgmac.c                   | 12 ++++++---
 drivers/spi/mxs_spi.c                 |  1 -
 drivers/usb/gadget/fsl_udc.c          | 11 +++++---
 drivers/usb/host/ehci-hcd.c           |  9 ++++---
 drivers/usb/host/ohci-hcd.c           | 11 +++++---
 drivers/usb/host/xhci-hcd.c           |  2 +-
 drivers/usb/host/xhci-hub.c           |  1 -
 drivers/video/atmel_hlcdfb.c          |  1 -
 drivers/video/atmel_lcdfb.c           |  1 -
 drivers/video/atmel_lcdfb_core.c      |  2 +-
 drivers/video/imx-ipu-fb.c            |  2 +-
 drivers/video/imx-ipu-v3/ipu-common.c |  1 -
 drivers/video/imx-ipu-v3/ipufb.c      |  2 +-
 drivers/video/omap.c                  |  3 +--
 drivers/video/pxa.c                   |  2 +-
 include/dma-dir.h                     |  6 +++++
 include/dma.h                         | 11 ++++++++
 include/usb/gadget.h                  |  1 +
 43 files changed, 281 insertions(+), 184 deletions(-)
 create mode 100644 include/dma-dir.h

-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 01/24] usb: gadget: include common.h in header
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
@ 2015-02-12 21:39 ` Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 02/24] ARM: move virt<->phys translation to io.h Lucas Stach
                   ` (23 subsequent siblings)
  24 siblings, 0 replies; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

It is needed for container_of() and this header falls
over if we change the include order.

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 include/usb/gadget.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/usb/gadget.h b/include/usb/gadget.h
index f663e98..80418a9 100644
--- a/include/usb/gadget.h
+++ b/include/usb/gadget.h
@@ -15,6 +15,7 @@
 #ifndef __LINUX_USB_GADGET_H
 #define __LINUX_USB_GADGET_H
 
+#include <common.h>
 #include <malloc.h>
 #include <driver.h>
 #include <linux/list.h>
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 02/24] ARM: move virt<->phys translation to io.h
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 01/24] usb: gadget: include common.h in header Lucas Stach
@ 2015-02-12 21:39 ` Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 03/24] dma: add streaming DMA ops Lucas Stach
                   ` (22 subsequent siblings)
  24 siblings, 0 replies; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

That's the place where Linux has them and other architectures would
implement this.

This will help in phasing out the direct usage of the ARM asm/mmu.h
header.

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 arch/arm/include/asm/io.h  | 15 +++++++++++++++
 arch/arm/include/asm/mmu.h | 12 ------------
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index 850a99c..0f938ec 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -69,4 +69,19 @@ extern void memset_io(volatile void __iomem *, int, size_t);
 #define setbits_8(addr, set) setbits(8, addr, set)
 #define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
 
+#ifdef CONFIG_MMU
+unsigned long virt_to_phys(void *virt);
+void *phys_to_virt(unsigned long phys);
+#else
+static inline void *phys_to_virt(unsigned long phys)
+{
+	return (void *)phys;
+}
+
+static inline unsigned long virt_to_phys(void *mem)
+{
+	return (unsigned long)mem;
+}
+#endif
+
 #endif	/* __ASM_ARM_IO_H */
diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h
index 4234979..3d87588 100644
--- a/arch/arm/include/asm/mmu.h
+++ b/arch/arm/include/asm/mmu.h
@@ -39,8 +39,6 @@ void dma_free_coherent(void *mem, size_t size);
 void dma_clean_range(unsigned long, unsigned long);
 void dma_flush_range(unsigned long, unsigned long);
 void dma_inv_range(unsigned long, unsigned long);
-unsigned long virt_to_phys(void *virt);
-void *phys_to_virt(unsigned long phys);
 void remap_range(void *_start, size_t size, uint32_t flags);
 void *map_io_sections(unsigned long physaddr, void *start, size_t size);
 uint32_t mmu_get_pte_cached_flags(void);
@@ -57,16 +55,6 @@ static inline void dma_free_coherent(void *mem, size_t size)
 	free(mem);
 }
 
-static inline void *phys_to_virt(unsigned long phys)
-{
-	return (void *)phys;
-}
-
-static inline unsigned long virt_to_phys(void *mem)
-{
-	return (unsigned long)mem;
-}
-
 static inline void dma_clean_range(unsigned long s, unsigned long e)
 {
 }
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 03/24] dma: add streaming DMA ops
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 01/24] usb: gadget: include common.h in header Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 02/24] ARM: move virt<->phys translation to io.h Lucas Stach
@ 2015-02-12 21:39 ` Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 04/24] ARM: move DMA alloc functions to dma.h Lucas Stach
                   ` (21 subsequent siblings)
  24 siblings, 0 replies; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

This will allow us to implement cache maintenance in a platform
agnostic way.

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 include/dma-dir.h |  6 ++++++
 include/dma.h     | 11 +++++++++++
 2 files changed, 17 insertions(+)
 create mode 100644 include/dma-dir.h

diff --git a/include/dma-dir.h b/include/dma-dir.h
new file mode 100644
index 0000000..ba107f1
--- /dev/null
+++ b/include/dma-dir.h
@@ -0,0 +1,6 @@
+enum dma_data_direction {
+	DMA_BIDIRECTIONAL = 0,
+	DMA_TO_DEVICE = 1,
+	DMA_FROM_DEVICE = 2,
+	DMA_NONE = 3,
+};
diff --git a/include/dma.h b/include/dma.h
index 899f831..4274520 100644
--- a/include/dma.h
+++ b/include/dma.h
@@ -11,6 +11,7 @@
 #include <malloc.h>
 #include <xfuncs.h>
 
+#include <dma-dir.h>
 #include <asm/dma.h>
 
 #ifndef dma_alloc
@@ -27,4 +28,14 @@ static inline void dma_free(void *mem)
 }
 #endif
 
+/* streaming DMA - implement the below calls to support HAS_DMA */
+void dma_sync_single_for_cpu(unsigned long address, size_t size,
+			     enum dma_data_direction dir);
+
+void dma_sync_single_for_device(unsigned long address, size_t size,
+				enum dma_data_direction dir);
+
+void *dma_alloc_coherent(size_t size);
+void dma_free_coherent(void *mem, size_t size);
+
 #endif /* __DMA_H */
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 04/24] ARM: move DMA alloc functions to dma.h
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
                   ` (2 preceding siblings ...)
  2015-02-12 21:39 ` [PATCH RFT 03/24] dma: add streaming DMA ops Lucas Stach
@ 2015-02-12 21:39 ` Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 05/24] ARM: implement streaming DMA ops Lucas Stach
                   ` (20 subsequent siblings)
  24 siblings, 0 replies; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

This better separates the DMA from the MMU functionality.

Also move all drivers that only depends on asm/mmu.h for the alloc
functions over to the common header.

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 arch/arm/include/asm/dma.h            | 20 +++++++++++++++++++-
 arch/arm/include/asm/mmu.h            | 19 -------------------
 drivers/ata/ahci.c                    |  1 +
 drivers/dma/apbh_dma.c                |  2 +-
 drivers/mci/dw_mmc.c                  |  1 +
 drivers/mtd/nand/nand_mxs.c           |  2 +-
 drivers/net/altera_tse.c              |  1 +
 drivers/net/arc_emac.c                |  1 +
 drivers/net/at91_ether.c              |  1 +
 drivers/net/designware.c              |  1 +
 drivers/net/fec_imx.c                 |  1 +
 drivers/net/macb.c                    |  1 +
 drivers/net/mvneta.c                  |  1 +
 drivers/net/orion-gbe.c               |  1 +
 drivers/net/rtl8139.c                 |  1 +
 drivers/net/rtl8169.c                 |  1 +
 drivers/net/xgmac.c                   |  1 +
 drivers/spi/mxs_spi.c                 |  1 -
 drivers/usb/gadget/fsl_udc.c          |  3 +++
 drivers/usb/host/ehci-hcd.c           |  1 +
 drivers/usb/host/ohci-hcd.c           |  1 +
 drivers/usb/host/xhci-hcd.c           |  2 +-
 drivers/usb/host/xhci-hub.c           |  1 -
 drivers/video/atmel_hlcdfb.c          |  1 -
 drivers/video/atmel_lcdfb.c           |  1 -
 drivers/video/atmel_lcdfb_core.c      |  2 +-
 drivers/video/imx-ipu-fb.c            |  2 +-
 drivers/video/imx-ipu-v3/ipu-common.c |  1 -
 drivers/video/imx-ipu-v3/ipufb.c      |  2 +-
 drivers/video/omap.c                  |  3 +--
 drivers/video/pxa.c                   |  2 +-
 31 files changed, 45 insertions(+), 34 deletions(-)

diff --git a/arch/arm/include/asm/dma.h b/arch/arm/include/asm/dma.h
index cb9cd1b..47e6a91 100644
--- a/arch/arm/include/asm/dma.h
+++ b/arch/arm/include/asm/dma.h
@@ -5,4 +5,22 @@
  *
  */
 
-#include <asm/mmu.h>
+#include <common.h>
+
+#define dma_alloc dma_alloc
+static inline void *dma_alloc(size_t size)
+{
+	return xmemalign(64, ALIGN(size, 64));
+}
+
+#ifndef CONFIG_MMU
+static inline void *dma_alloc_coherent(size_t size)
+{
+	return xmemalign(4096, size);
+}
+
+static inline void dma_free_coherent(void *mem, size_t size)
+{
+	free(mem);
+}
+#endif
diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h
index 3d87588..01c20bd 100644
--- a/arch/arm/include/asm/mmu.h
+++ b/arch/arm/include/asm/mmu.h
@@ -26,16 +26,7 @@ static inline void setup_dma_coherent(unsigned long offset)
 {
 }
 
-#define dma_alloc dma_alloc
-static inline void *dma_alloc(size_t size)
-{
-	return xmemalign(64, ALIGN(size, 64));
-}
-
 #ifdef CONFIG_MMU
-void *dma_alloc_coherent(size_t size);
-void dma_free_coherent(void *mem, size_t size);
-
 void dma_clean_range(unsigned long, unsigned long);
 void dma_flush_range(unsigned long, unsigned long);
 void dma_inv_range(unsigned long, unsigned long);
@@ -45,16 +36,6 @@ uint32_t mmu_get_pte_cached_flags(void);
 uint32_t mmu_get_pte_uncached_flags(void);
 
 #else
-static inline void *dma_alloc_coherent(size_t size)
-{
-	return xmemalign(4096, size);
-}
-
-static inline void dma_free_coherent(void *mem, size_t size)
-{
-	free(mem);
-}
-
 static inline void dma_clean_range(unsigned long s, unsigned long e)
 {
 }
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 346ab98..1894e47 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -21,6 +21,7 @@
  */
 
 #include <common.h>
+#include <dma.h>
 #include <init.h>
 #include <errno.h>
 #include <io.h>
diff --git a/drivers/dma/apbh_dma.c b/drivers/dma/apbh_dma.c
index cd218f4..9069ada 100644
--- a/drivers/dma/apbh_dma.c
+++ b/drivers/dma/apbh_dma.c
@@ -20,13 +20,13 @@
 #include <linux/list.h>
 #include <linux/err.h>
 #include <common.h>
+#include <dma.h>
 #include <driver.h>
 #include <malloc.h>
 #include <errno.h>
 #include <init.h>
 #include <io.h>
 
-#include <asm/mmu.h>
 
 #define HW_APBHX_CTRL0				0x000
 #define BM_APBH_CTRL0_APB_BURST8_EN		(1 << 29)
diff --git a/drivers/mci/dw_mmc.c b/drivers/mci/dw_mmc.c
index 365b60d..3992815 100644
--- a/drivers/mci/dw_mmc.c
+++ b/drivers/mci/dw_mmc.c
@@ -18,6 +18,7 @@
  */
 
 #include <common.h>
+#include <dma.h>
 #include <driver.h>
 #include <malloc.h>
 #include <clock.h>
diff --git a/drivers/mtd/nand/nand_mxs.c b/drivers/mtd/nand/nand_mxs.c
index 4e38e09..d9a50a5 100644
--- a/drivers/mtd/nand/nand_mxs.c
+++ b/drivers/mtd/nand/nand_mxs.c
@@ -26,6 +26,7 @@
 #include <linux/err.h>
 #include <of_mtd.h>
 #include <common.h>
+#include <dma.h>
 #include <malloc.h>
 #include <errno.h>
 #include <driver.h>
@@ -33,7 +34,6 @@
 #include <io.h>
 #include <dma/apbh-dma.h>
 #include <stmp-device.h>
-#include <asm/mmu.h>
 #include <mach/generic.h>
 
 #define	MX28_BLOCK_SFTRST				(1 << 31)
diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c
index ecbb9f8..3beeb26 100644
--- a/drivers/net/altera_tse.c
+++ b/drivers/net/altera_tse.c
@@ -21,6 +21,7 @@
  */
 
 #include <common.h>
+#include <dma.h>
 #include <net.h>
 #include <init.h>
 #include <clock.h>
diff --git a/drivers/net/arc_emac.c b/drivers/net/arc_emac.c
index 1770506..e050199 100644
--- a/drivers/net/arc_emac.c
+++ b/drivers/net/arc_emac.c
@@ -19,6 +19,7 @@
 #include <asm/mmu.h>
 #include <clock.h>
 #include <common.h>
+#include <dma.h>
 #include <net.h>
 #include <io.h>
 #include <init.h>
diff --git a/drivers/net/at91_ether.c b/drivers/net/at91_ether.c
index e09ea83..2ef24cc 100644
--- a/drivers/net/at91_ether.c
+++ b/drivers/net/at91_ether.c
@@ -20,6 +20,7 @@
  */
 
 #include <common.h>
+#include <dma.h>
 #include <net.h>
 #include <clock.h>
 #include <malloc.h>
diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 49ed0b1..2bc4471 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -22,6 +22,7 @@
  */
 
 #include <common.h>
+#include <dma.h>
 #include <init.h>
 #include <io.h>
 #include <net.h>
diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index c1fa151..5761256 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -15,6 +15,7 @@
  */
 
 #include <common.h>
+#include <dma.h>
 #include <malloc.h>
 #include <net.h>
 #include <init.h>
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 8e67aec..b941c27 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -38,6 +38,7 @@
 
 #include <net.h>
 #include <clock.h>
+#include <dma.h>
 #include <malloc.h>
 #include <xfuncs.h>
 #include <init.h>
diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 8042e90..0d6a80f 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -24,6 +24,7 @@
  */
 
 #include <common.h>
+#include <dma.h>
 #include <init.h>
 #include <io.h>
 #include <net.h>
diff --git a/drivers/net/orion-gbe.c b/drivers/net/orion-gbe.c
index 3fbc1df..ad1fc66 100644
--- a/drivers/net/orion-gbe.c
+++ b/drivers/net/orion-gbe.c
@@ -27,6 +27,7 @@
  * MA 02110-1301 USA
  */
 #include <common.h>
+#include <dma.h>
 #include <init.h>
 #include <io.h>
 #include <net.h>
diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c
index b24a083..d57c706 100644
--- a/drivers/net/rtl8139.c
+++ b/drivers/net/rtl8139.c
@@ -1,4 +1,5 @@
 #include <common.h>
+#include <dma.h>
 #include <net.h>
 #include <malloc.h>
 #include <init.h>
diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c
index 19f5763..093a312 100644
--- a/drivers/net/rtl8169.c
+++ b/drivers/net/rtl8169.c
@@ -16,6 +16,7 @@
 
 #include <asm/mmu.h>
 #include <common.h>
+#include <dma.h>
 #include <init.h>
 #include <net.h>
 #include <malloc.h>
diff --git a/drivers/net/xgmac.c b/drivers/net/xgmac.c
index cc22d0e..c1e4da8 100644
--- a/drivers/net/xgmac.c
+++ b/drivers/net/xgmac.c
@@ -16,6 +16,7 @@
  */
 
 #include <common.h>
+#include <dma.h>
 #include <net.h>
 #include <clock.h>
 #include <malloc.h>
diff --git a/drivers/spi/mxs_spi.c b/drivers/spi/mxs_spi.c
index 8932103..9fe2fd4 100644
--- a/drivers/spi/mxs_spi.c
+++ b/drivers/spi/mxs_spi.c
@@ -23,7 +23,6 @@
 #include <stmp-device.h>
 #include <linux/clk.h>
 #include <linux/err.h>
-#include <asm/mmu.h>
 #include <mach/generic.h>
 #include <mach/clock.h>
 #include <mach/ssp.h>
diff --git a/drivers/usb/gadget/fsl_udc.c b/drivers/usb/gadget/fsl_udc.c
index d067f03..f9e58bb 100644
--- a/drivers/usb/gadget/fsl_udc.c
+++ b/drivers/usb/gadget/fsl_udc.c
@@ -1,4 +1,5 @@
 #include <common.h>
+#include <dma.h>
 #include <errno.h>
 #include <dma.h>
 #include <init.h>
@@ -10,6 +11,8 @@
 #include <asm/byteorder.h>
 #include <linux/err.h>
 
+#include <asm/mmu.h>
+
 /* ### define USB registers here
  */
 #define USB_MAX_CTRL_PAYLOAD		64
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 7b91327..7f59774 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -18,6 +18,7 @@
  */
 /*#define DEBUG */
 #include <common.h>
+#include <dma.h>
 #include <asm/byteorder.h>
 #include <usb/usb.h>
 #include <io.h>
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 622f5c3..0cdcbb5 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -41,6 +41,7 @@
  *     to activate workaround for bug #41 or this driver will NOT work!
  */
 #include <common.h>
+#include <dma.h>
 #include <clock.h>
 #include <malloc.h>
 #include <usb/usb.h>
diff --git a/drivers/usb/host/xhci-hcd.c b/drivers/usb/host/xhci-hcd.c
index 9253419..2d2f59e 100644
--- a/drivers/usb/host/xhci-hcd.c
+++ b/drivers/usb/host/xhci-hcd.c
@@ -12,9 +12,9 @@
  * warranty of any kind, whether express or implied.
  */
 //#define DEBUG
-#include <asm/mmu.h>
 #include <clock.h>
 #include <common.h>
+#include <dma.h>
 #include <init.h>
 #include <io.h>
 #include <linux/err.h>
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index bf95257..5ae16f5 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -14,7 +14,6 @@
  * warranty of any kind, whether express or implied.
  */
 //#define DEBUG
-#include <asm/mmu.h>
 #include <clock.h>
 #include <common.h>
 #include <io.h>
diff --git a/drivers/video/atmel_hlcdfb.c b/drivers/video/atmel_hlcdfb.c
index 26db758..f7aab7f 100644
--- a/drivers/video/atmel_hlcdfb.c
+++ b/drivers/video/atmel_hlcdfb.c
@@ -27,7 +27,6 @@
 #include <mach/io.h>
 #include <mach/cpu.h>
 #include <errno.h>
-#include <asm/mmu.h>
 
 #include "atmel_lcdfb.h"
 
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c
index bb302bd..20204c1 100644
--- a/drivers/video/atmel_lcdfb.c
+++ b/drivers/video/atmel_lcdfb.c
@@ -25,7 +25,6 @@
 #include <mach/io.h>
 #include <mach/cpu.h>
 #include <errno.h>
-#include <asm/mmu.h>
 #include <linux/clk.h>
 
 #include "atmel_lcdfb.h"
diff --git a/drivers/video/atmel_lcdfb_core.c b/drivers/video/atmel_lcdfb_core.c
index 420ccbe..ef2e271 100644
--- a/drivers/video/atmel_lcdfb_core.c
+++ b/drivers/video/atmel_lcdfb_core.c
@@ -19,11 +19,11 @@
  */
 
 #include <common.h>
+#include <dma.h>
 #include <io.h>
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <malloc.h>
-#include <asm/mmu.h>
 
 #include "atmel_lcdfb.h"
 
diff --git a/drivers/video/imx-ipu-fb.c b/drivers/video/imx-ipu-fb.c
index a69df50..ac4fb9f 100644
--- a/drivers/video/imx-ipu-fb.c
+++ b/drivers/video/imx-ipu-fb.c
@@ -18,6 +18,7 @@
  */
 
 #include <common.h>
+#include <dma.h>
 #include <init.h>
 #include <io.h>
 #include <mach/imx35-regs.h>
@@ -26,7 +27,6 @@
 #include <malloc.h>
 #include <errno.h>
 #include <asm-generic/div64.h>
-#include <asm/mmu.h>
 #include <mach/imx-ipu-fb.h>
 #include <linux/clk.h>
 #include <linux/err.h>
diff --git a/drivers/video/imx-ipu-v3/ipu-common.c b/drivers/video/imx-ipu-v3/ipu-common.c
index f13cf01..5c85f86 100644
--- a/drivers/video/imx-ipu-v3/ipu-common.c
+++ b/drivers/video/imx-ipu-v3/ipu-common.c
@@ -19,7 +19,6 @@
 #include <clock.h>
 #include <driver.h>
 #include <init.h>
-#include <asm/mmu.h>
 #include <mach/generic.h>
 #include <mach/imx6-regs.h>
 #include <mach/imx53-regs.h>
diff --git a/drivers/video/imx-ipu-v3/ipufb.c b/drivers/video/imx-ipu-v3/ipufb.c
index 14a099e..8ec55e4 100644
--- a/drivers/video/imx-ipu-v3/ipufb.c
+++ b/drivers/video/imx-ipu-v3/ipufb.c
@@ -12,6 +12,7 @@
 #define pr_fmt(fmt) "IPU: " fmt
 
 #include <common.h>
+#include <dma.h>
 #include <fb.h>
 #include <io.h>
 #include <driver.h>
@@ -21,7 +22,6 @@
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <asm-generic/div64.h>
-#include <asm/mmu.h>
 
 #include "imx-ipu-v3.h"
 #include "ipuv3-plane.h"
diff --git a/drivers/video/omap.c b/drivers/video/omap.c
index bd66c92..8a2f3dd 100644
--- a/drivers/video/omap.c
+++ b/drivers/video/omap.c
@@ -19,6 +19,7 @@
  */
 
 #include <driver.h>
+#include <dma.h>
 #include <fb.h>
 #include <errno.h>
 #include <xfuncs.h>
@@ -34,8 +35,6 @@
 #include <mach/omap4-silicon.h>
 #include <mach/omap-fb.h>
 
-#include <asm/mmu.h>
-
 #include "omap.h"
 
 struct omapfb_device {
diff --git a/drivers/video/pxa.c b/drivers/video/pxa.c
index d6d11ae..a92a5ee 100644
--- a/drivers/video/pxa.c
+++ b/drivers/video/pxa.c
@@ -24,6 +24,7 @@
  */
 
 #include <common.h>
+#include <dma.h>
 #include <driver.h>
 #include <errno.h>
 #include <fb.h>
@@ -37,7 +38,6 @@
 #include <mach/pxafb.h>
 
 #include <asm/io.h>
-#include <asm/mmu.h>
 #include <asm-generic/div64.h>
 
 /* PXA LCD DMA descriptor */
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 05/24] ARM: implement streaming DMA ops
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
                   ` (3 preceding siblings ...)
  2015-02-12 21:39 ` [PATCH RFT 04/24] ARM: move DMA alloc functions to dma.h Lucas Stach
@ 2015-02-12 21:39 ` Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 06/24] AHCI: convert to " Lucas Stach
                   ` (19 subsequent siblings)
  24 siblings, 0 replies; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 arch/arm/cpu/mmu.c         | 24 ++++++++++++++++++++++++
 arch/arm/include/asm/dma.h | 10 ++++++++++
 2 files changed, 34 insertions(+)

diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index e733ec4..e3c06cd 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -18,6 +18,7 @@
 #define pr_fmt(fmt)	"mmu: " fmt
 
 #include <common.h>
+#include <dma-dir.h>
 #include <init.h>
 #include <asm/mmu.h>
 #include <errno.h>
@@ -432,3 +433,26 @@ void dma_inv_range(unsigned long start, unsigned long end)
 	__dma_inv_range(start, end);
 }
 
+void dma_sync_single_for_cpu(unsigned long address, size_t size,
+			     enum dma_data_direction dir)
+{
+	if (dir != DMA_TO_DEVICE) {
+		if (outer_cache.inv_range)
+			outer_cache.inv_range(address, address + size);
+		__dma_inv_range(address, address + size);
+	}
+}
+
+void dma_sync_single_for_device(unsigned long address, size_t size,
+				enum dma_data_direction dir)
+{
+	if (dir == DMA_FROM_DEVICE) {
+		__dma_inv_range(address, address + size);
+		if (outer_cache.inv_range)
+			outer_cache.inv_range(address, address + size);
+	} else {
+		__dma_clean_range(address, address + size);
+		if (outer_cache.clean_range)
+			outer_cache.clean_range(address, address + size);
+	}
+}
diff --git a/arch/arm/include/asm/dma.h b/arch/arm/include/asm/dma.h
index 47e6a91..897c2ed 100644
--- a/arch/arm/include/asm/dma.h
+++ b/arch/arm/include/asm/dma.h
@@ -23,4 +23,14 @@ static inline void dma_free_coherent(void *mem, size_t size)
 {
 	free(mem);
 }
+
+static inline void dma_sync_single_for_cpu(unsigned long address, size_t size,
+					   enum dma_data_direction dir)
+{
+}
+
+static inline void dma_sync_single_for_device(unsigned long address, size_t size,
+					      enum dma_data_direction dir)
+{
+}
 #endif
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 06/24] AHCI: convert to streaming DMA ops
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
                   ` (4 preceding siblings ...)
  2015-02-12 21:39 ` [PATCH RFT 05/24] ARM: implement streaming DMA ops Lucas Stach
@ 2015-02-12 21:39 ` Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 07/24] MCI: dw-mmc: " Lucas Stach
                   ` (18 subsequent siblings)
  24 siblings, 0 replies; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 drivers/ata/ahci.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 1894e47..e4310fc 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -31,7 +31,6 @@
 #include <linux/ctype.h>
 #include <linux/err.h>
 #include <disks.h>
-#include <asm/mmu.h>
 #include <ata_drive.h>
 #include <linux/sizes.h>
 #include <clock.h>
@@ -170,7 +169,11 @@ static int ahci_io(struct ahci_port *ahci_port, u8 *fis, int fis_len, void *rbuf
 		return -EIO;
 
 	if (wbuf)
-		dma_flush_range((unsigned long)wbuf, (unsigned long)wbuf + buf_len);
+		dma_sync_single_for_device((unsigned long)wbuf, buf_len,
+					   DMA_TO_DEVICE);
+	if (rbuf)
+		dma_sync_single_for_device((unsigned long)rbuf, buf_len,
+					   DMA_FROM_DEVICE);
 
 	memcpy((unsigned char *)ahci_port->cmd_tbl, fis, fis_len);
 
@@ -187,8 +190,12 @@ static int ahci_io(struct ahci_port *ahci_port, u8 *fis, int fis_len, void *rbuf
 	if (ret)
 		return -ETIMEDOUT;
 
+	if (wbuf)
+		dma_sync_single_for_cpu((unsigned long)wbuf, buf_len,
+					DMA_TO_DEVICE);
 	if (rbuf)
-		dma_inv_range((unsigned long)rbuf, (unsigned long)rbuf + buf_len);
+		dma_sync_single_for_cpu((unsigned long)rbuf, buf_len,
+					DMA_FROM_DEVICE);
 
 	return 0;
 }
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 07/24] MCI: dw-mmc: convert to streaming DMA ops
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
                   ` (5 preceding siblings ...)
  2015-02-12 21:39 ` [PATCH RFT 06/24] AHCI: convert to " Lucas Stach
@ 2015-02-12 21:39 ` Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 08/24] MCI: imx: " Lucas Stach
                   ` (17 subsequent siblings)
  24 siblings, 0 replies; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 drivers/mci/Kconfig  |  2 +-
 drivers/mci/dw_mmc.c | 24 ++++++++++++------------
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig
index dbcc38d..a5cf2fe 100644
--- a/drivers/mci/Kconfig
+++ b/drivers/mci/Kconfig
@@ -36,7 +36,7 @@ comment "--- MCI host drivers ---"
 
 config MCI_DW
 	bool "Synopsys DesignWare Memory Card Interface"
-	depends on ARM
+	depends on HAS_DMA
 	help
 	  This selects support for the Synopsys DesignWare Mobile Storage IP
 	  block, this provides host support for SD and MMC interfaces, in both
diff --git a/drivers/mci/dw_mmc.c b/drivers/mci/dw_mmc.c
index 3992815..f02ea62 100644
--- a/drivers/mci/dw_mmc.c
+++ b/drivers/mci/dw_mmc.c
@@ -29,7 +29,6 @@
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <asm-generic/errno.h>
-#include <asm/mmu.h>
 
 #define DWMCI_CTRL		0x000
 #define	DWMCI_PWREN		0x004
@@ -282,7 +281,6 @@ dwmci_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
 	uint64_t start;
 	int ret;
 	unsigned int num_bytes = 0;
-	const void *writebuf = NULL;
 
 	start = get_time_ns();
 	while (1) {
@@ -300,12 +298,12 @@ dwmci_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
 	if (data) {
 		num_bytes = data->blocks * data->blocksize;
 
-		if (data->flags & MMC_DATA_WRITE) {
-			dma_flush_range((unsigned long)data->src,
-				(unsigned long)(data->src + data->blocks * 512));
-
-			writebuf = data->src;
-		}
+		if (data->flags & MMC_DATA_WRITE)
+			dma_sync_single_for_device((unsigned long)data->src,
+						   num_bytes, DMA_TO_DEVICE);
+		else
+			dma_sync_single_for_device((unsigned long)data->dest,
+						   num_bytes, DMA_FROM_DEVICE);
 
 		ret = dwmci_prepare_data(host, data);
 		if (ret)
@@ -389,10 +387,12 @@ dwmci_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
 		ctrl &= ~(DWMCI_DMA_EN);
 		dwmci_writel(host, DWMCI_CTRL, ctrl);
 
-		if (data->flags & MMC_DATA_READ) {
-			dma_inv_range((unsigned long)data->dest,
-					(unsigned long)(data->dest + data->blocks * 512));
-		}
+		if (data->flags & MMC_DATA_WRITE)
+			dma_sync_single_for_cpu((unsigned long)data->src,
+						num_bytes, DMA_TO_DEVICE);
+		else
+			dma_sync_single_for_cpu((unsigned long)data->dest,
+						num_bytes, DMA_FROM_DEVICE);
 	}
 
 	udelay(100);
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 08/24] MCI: imx: convert to streaming DMA ops
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
                   ` (6 preceding siblings ...)
  2015-02-12 21:39 ` [PATCH RFT 07/24] MCI: dw-mmc: " Lucas Stach
@ 2015-02-12 21:39 ` Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 09/24] MCI: tegra-sdmmc: " Lucas Stach
                   ` (16 subsequent siblings)
  24 siblings, 0 replies; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 drivers/mci/imx-esdhc.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c
index 23bdc1f..8b45500 100644
--- a/drivers/mci/imx-esdhc.c
+++ b/drivers/mci/imx-esdhc.c
@@ -22,6 +22,7 @@
  */
 #include <config.h>
 #include <common.h>
+#include <dma.h>
 #include <driver.h>
 #include <init.h>
 #include <of.h>
@@ -31,7 +32,6 @@
 #include <io.h>
 #include <linux/clk.h>
 #include <linux/err.h>
-#include <asm/mmu.h>
 #include <mach/generic.h>
 #include <mach/esdhc.h>
 #include <gpio.h>
@@ -211,6 +211,7 @@ esdhc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
 	u32	irqstat;
 	struct fsl_esdhc_host *host = to_fsl_esdhc(mci);
 	void __iomem *regs = host->regs;
+	unsigned int num_bytes = 0;
 	int ret;
 
 	esdhc_write32(regs + SDHCI_INT_STATUS, -1);
@@ -225,12 +226,15 @@ esdhc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
 		err = esdhc_setup_data(mci, data);
 		if(err)
 			return err;
-		if (data->flags & MMC_DATA_WRITE) {
-			dma_flush_range((unsigned long)data->src,
-				(unsigned long)(data->src + data->blocks * 512));
-		} else
-			dma_clean_range((unsigned long)data->src,
-				(unsigned long)(data->src + data->blocks * 512));
+
+		num_bytes = data->blocks * data->blocksize;
+
+		if (data->flags & MMC_DATA_WRITE)
+			dma_sync_single_for_device((unsigned long)data->src,
+						   num_bytes, DMA_TO_DEVICE);
+		else
+			dma_sync_single_for_device((unsigned long)data->dest,
+						   num_bytes, DMA_FROM_DEVICE);
 
 	}
 
@@ -313,10 +317,12 @@ esdhc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
 		} while (!(irqstat & IRQSTAT_TC) &&
 				(esdhc_read32(regs + SDHCI_PRESENT_STATE) & PRSSTAT_DLA));
 
-		if (data->flags & MMC_DATA_READ) {
-			dma_inv_range((unsigned long)data->dest,
-					(unsigned long)(data->dest + data->blocks * 512));
-		}
+		if (data->flags & MMC_DATA_WRITE)
+			dma_sync_single_for_cpu((unsigned long)data->src,
+						num_bytes, DMA_TO_DEVICE);
+		else
+			dma_sync_single_for_cpu((unsigned long)data->dest,
+						num_bytes, DMA_FROM_DEVICE);
 #endif
 	}
 
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 09/24] MCI: tegra-sdmmc: convert to streaming DMA ops
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
                   ` (7 preceding siblings ...)
  2015-02-12 21:39 ` [PATCH RFT 08/24] MCI: imx: " Lucas Stach
@ 2015-02-12 21:39 ` Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 10/24] net: arc-emac: " Lucas Stach
                   ` (15 subsequent siblings)
  24 siblings, 0 replies; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 drivers/mci/tegra-sdmmc.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/mci/tegra-sdmmc.c b/drivers/mci/tegra-sdmmc.c
index 0e23d6f..670c280 100644
--- a/drivers/mci/tegra-sdmmc.c
+++ b/drivers/mci/tegra-sdmmc.c
@@ -17,10 +17,10 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <asm/mmu.h>
 #include <common.h>
 #include <clock.h>
 #include <driver.h>
+#include <dma.h>
 #include <gpio.h>
 #include <init.h>
 #include <io.h>
@@ -100,6 +100,7 @@ static int tegra_sdmmc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
 				struct mci_data *data)
 {
 	struct tegra_sdmmc_host *host = to_tegra_sdmmc_host(mci);
+	unsigned int num_bytes = 0;
 	u32 val = 0;
 	int ret;
 
@@ -109,15 +110,15 @@ static int tegra_sdmmc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
 
 	/* Set up for a data transfer if we have one */
 	if (data) {
+		num_bytes = data->blocks * data->blocksize;
+
 		if (data->flags & MMC_DATA_WRITE) {
-			dma_flush_range((unsigned long)data->src,
-			                (unsigned long)(data->src +
-			                data->blocks * 512));
+			dma_sync_single_for_device((unsigned long)data->src,
+						   num_bytes, DMA_TO_DEVICE);
 			writel((u32)data->src, host->regs + SDHCI_DMA_ADDRESS);
 		} else {
-			dma_clean_range((unsigned long)data->src,
-			                (unsigned long)(data->src +
-			                data->blocks * 512));
+			dma_sync_single_for_device((unsigned long)data->dest,
+						   num_bytes, DMA_FROM_DEVICE);
 			writel((u32)data->dest, host->regs + SDHCI_DMA_ADDRESS);
 		}
 
@@ -255,11 +256,12 @@ static int tegra_sdmmc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
 		}
 		writel(val, host->regs + SDHCI_INT_STATUS);
 
-		if (data->flags & MMC_DATA_READ) {
-			dma_inv_range((unsigned long)data->dest,
-			              (unsigned long)(data->dest +
-			              data->blocks * 512));
-		}
+		if (data->flags & MMC_DATA_WRITE)
+			dma_sync_single_for_cpu((unsigned long)data->src,
+						num_bytes, DMA_TO_DEVICE);
+		else
+			dma_sync_single_for_cpu((unsigned long)data->dest,
+						num_bytes, DMA_FROM_DEVICE);
 	}
 
 	return 0;
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 10/24] net: arc-emac: convert to streaming DMA ops
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
                   ` (8 preceding siblings ...)
  2015-02-12 21:39 ` [PATCH RFT 09/24] MCI: tegra-sdmmc: " Lucas Stach
@ 2015-02-12 21:39 ` Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 11/24] net: cpsw: " Lucas Stach
                   ` (14 subsequent siblings)
  24 siblings, 0 replies; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 drivers/net/arc_emac.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/net/arc_emac.c b/drivers/net/arc_emac.c
index e050199..4bf456e 100644
--- a/drivers/net/arc_emac.c
+++ b/drivers/net/arc_emac.c
@@ -16,7 +16,6 @@
  * GNU General Public License for more details.
  */
 
-#include <asm/mmu.h>
 #include <clock.h>
 #include <common.h>
 #include <dma.h>
@@ -195,6 +194,8 @@ static int arc_emac_open(struct eth_device *edev)
 		rxbd->data = cpu_to_le32(rxbuf);
 
 		/* Return ownership to EMAC */
+		dma_sync_single_for_device((unsigned long)rxbuf, PKTSIZE,
+					   DMA_FROM_DEVICE);
 		rxbd->info = cpu_to_le32(FOR_EMAC | PKTSIZE);
 
 		*last_rx_bd = (*last_rx_bd + 1) % RX_BD_NUM;
@@ -244,7 +245,7 @@ static int arc_emac_send(struct eth_device *edev, void *data, int length)
 		length = EMAC_ZLEN;
 	}
 
-	dma_flush_range((unsigned long)data, (unsigned long)data + length);
+	dma_sync_single_for_device((unsigned long)data, length, DMA_TO_DEVICE);
 
 	bd->data = cpu_to_le32(data);
 	bd->info = cpu_to_le32(FOR_EMAC | FIRST_OR_LAST_MASK | length);
@@ -253,6 +254,8 @@ static int arc_emac_send(struct eth_device *edev, void *data, int length)
 	ret = wait_on_timeout(20 * MSECOND,
 			      (arc_reg_get(priv, R_STATUS) & TXINT_MASK) != 0);
 
+	dma_sync_single_for_cpu((unsigned long)data, length, DMA_TO_DEVICE);
+
 	if (ret) {
 		dev_err(&edev->dev, "transmit timeout\n");
 		return ret;
@@ -294,18 +297,19 @@ static int arc_emac_recv(struct eth_device *edev)
 			printk(KERN_DEBUG "incomplete packet received\n");
 
 			/* Return ownership to EMAC */
-			rxbd->info = cpu_to_le32(FOR_EMAC | PKTSIZE);
 			continue;
 		}
 
 		pktlen = info & LEN_MASK;
 
-		/* invalidate current receive buffer */
-		dma_inv_range((unsigned long)rxbd->data,
-			      (unsigned long)rxbd->data + pktlen);
+		dma_sync_single_for_cpu((unsigned long)rxbd->data, pktlen,
+					DMA_FROM_DEVICE);
 
 		net_receive(edev, (unsigned char *)rxbd->data, pktlen);
 
+		dma_sync_single_for_device((unsigned long)rxbd->data, pktlen,
+					   DMA_FROM_DEVICE);
+
 		rxbd->info = cpu_to_le32(FOR_EMAC | PKTSIZE);
 	}
 
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 11/24] net: cpsw: convert to streaming DMA ops
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
                   ` (9 preceding siblings ...)
  2015-02-12 21:39 ` [PATCH RFT 10/24] net: arc-emac: " Lucas Stach
@ 2015-02-12 21:39 ` Lucas Stach
  2015-02-13 19:44   ` Sascha Hauer
  2015-02-12 21:39 ` [PATCH RFT 12/24] net: at91_ether: " Lucas Stach
                   ` (13 subsequent siblings)
  24 siblings, 1 reply; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 drivers/net/cpsw.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index 799fac8..5c28aa4 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -21,6 +21,7 @@
 #include <init.h>
 
 #include <command.h>
+#include <dma.h
 #include <net.h>
 #include <malloc.h>
 #include <net.h>
@@ -32,7 +33,6 @@
 #include <of_net.h>
 #include <of_address.h>
 #include <xfuncs.h>
-#include <asm/mmu.h>
 #include <asm/system.h>
 #include <linux/err.h>
 
@@ -871,9 +871,9 @@ static int cpsw_send(struct eth_device *edev, void *packet, int length)
 
 	dev_dbg(&slave->dev, "%s: %i bytes @ 0x%p\n", __func__, length, packet);
 
-	dma_flush_range((ulong) packet, (ulong)packet + length);
-
+	dma_sync_single_for_device((unsigned long)packet, length, DMA_TO_DEVICE);
 	ret = cpdma_submit(priv, &priv->tx_chan, packet, length);
+	dma_sync_single_for_cpu((unsigned long)packet, length, DMA_TO_DEVICE);
 
 	return ret;
 }
@@ -886,8 +886,11 @@ static int cpsw_recv(struct eth_device *edev)
 	int len;
 
 	while (cpdma_process(priv, &priv->rx_chan, &buffer, &len) >= 0) {
-		dma_inv_range((ulong)buffer, (ulong)buffer + len);
+		dma_sync_single_for_cpu((unsigned long)buffer, len,
+					DMA_FROM_DEVICE);
 		net_receive(edev, buffer, len);
+		dma_sync_single_for_device((unsigned long)buffer, len,
+					   DMA_FROM_DEVICE);
 		cpdma_submit(priv, &priv->rx_chan, buffer, PKTSIZE);
 	}
 
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 12/24] net: at91_ether: convert to streaming DMA ops
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
                   ` (10 preceding siblings ...)
  2015-02-12 21:39 ` [PATCH RFT 11/24] net: cpsw: " Lucas Stach
@ 2015-02-12 21:39 ` Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 13/24] net: davinci_emac: " Lucas Stach
                   ` (12 subsequent siblings)
  24 siblings, 0 replies; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 drivers/net/at91_ether.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/at91_ether.c b/drivers/net/at91_ether.c
index 2ef24cc..d596834 100644
--- a/drivers/net/at91_ether.c
+++ b/drivers/net/at91_ether.c
@@ -35,7 +35,6 @@
 #include <linux/clk.h>
 #include <linux/mii.h>
 #include <errno.h>
-#include <asm/mmu.h>
 #include <linux/phy.h>
 
 #include "at91_ether.h"
@@ -200,7 +199,8 @@ static int at91_ether_send(struct eth_device *edev, void *packet, int length)
 {
 	while (!(at91_emac_read(AT91_EMAC_TSR) & AT91_EMAC_TSR_BNQ));
 
-	dma_flush_range((ulong) packet, (ulong)packet + length);
+	dma_sync_single_for_device((unsigned long)packet, length, DMA_TO_DEVICE);
+
 	/* Set address of the data in the Transmit Address register */
 	at91_emac_write(AT91_EMAC_TAR, (unsigned long) packet);
 	/* Set length of the packet in the Transmit Control register */
@@ -211,6 +211,8 @@ static int at91_ether_send(struct eth_device *edev, void *packet, int length)
 	at91_emac_write(AT91_EMAC_TSR,
 		at91_emac_read(AT91_EMAC_TSR) | AT91_EMAC_TSR_COMP);
 
+	dma_sync_single_for_cpu((unsigned long)packet, length, DMA_TO_DEVICE);
+
 	return 0;
 }
 
@@ -225,7 +227,11 @@ static int at91_ether_rx(struct eth_device *edev)
 
 	size = rbfp->size & RBF_SIZE;
 
+	dma_sync_single_for_cpu((unsigned long)rbfp->addr, size,
+				DMA_FROM_DEVICE);
 	net_receive(edev, (unsigned char *)(rbfp->addr & RBF_ADDR), size);
+	dma_sync_single_for_device((unsigned long)rbfp->addr, size,
+				   DMA_FROM_DEVICE);
 
 	rbfp->addr &= ~RBF_OWNER;
 	if (rbfp->addr & RBF_WRAP)
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 13/24] net: davinci_emac: convert to streaming DMA ops
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
                   ` (11 preceding siblings ...)
  2015-02-12 21:39 ` [PATCH RFT 12/24] net: at91_ether: " Lucas Stach
@ 2015-02-12 21:39 ` Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 14/24] net: designware: " Lucas Stach
                   ` (11 subsequent siblings)
  24 siblings, 0 replies; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 drivers/net/davinci_emac.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index ce367a3..056ffe2 100644
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -40,12 +40,12 @@
  */
 
 #include <common.h>
+#include <dma.h>
 #include <io.h>
 #include <clock.h>
 #include <net.h>
 #include <malloc.h>
 #include <init.h>
-#include <asm/mmu.h>
 #include <asm/system.h>
 #include <linux/phy.h>
 #include <mach/emac_defs.h>
@@ -411,7 +411,7 @@ static int davinci_emac_send(struct eth_device *edev, void *packet, int length)
 				    EMAC_CPPI_OWNERSHIP_BIT |
 				    EMAC_CPPI_EOP_BIT),
 		priv->emac_tx_desc + EMAC_DESC_PKT_FLAG_LEN);
-	dma_flush_range((ulong) packet, (ulong)packet + length);
+	dma_sync_single_for_device((unsigned long)packet, length, DMA_TO_DEVICE);
 	/* Send the packet */
 	writel(BD_TO_HW(priv->emac_tx_desc), priv->adap_emac + EMAC_TX0HDP);
 
@@ -429,6 +429,7 @@ static int davinci_emac_send(struct eth_device *edev, void *packet, int length)
 			break;
 		}
 	}
+	dma_sync_single_for_cpu((unsigned long)packet, length, DMA_TO_DEVICE);
 
 	dev_dbg(priv->dev, "- emac_send (ret_status %i)\n", ret_status);
 	return ret_status;
@@ -460,9 +461,9 @@ static int davinci_emac_recv(struct eth_device *edev)
 		pkt = (unsigned char *)readl(rx_curr_desc + EMAC_DESC_BUFFER);
 		len = readl(rx_curr_desc + EMAC_DESC_BUFF_OFF_LEN) & 0xffff;
 		dev_dbg(priv->dev, "| emac_recv got packet (length %i)\n", len);
-		dma_inv_range((ulong)pkt,
-				(ulong)readl(rx_curr_desc + EMAC_DESC_BUFFER) + len);
+		dma_sync_single_for_cpu((unsigned long)pkt, len, DMA_FROM_DEVICE);
 		net_receive(edev, pkt, len);
+		dma_sync_single_for_device((unsigned long)pkt, len, DMA_FROM_DEVICE);
 		ret = len;
 	}
 
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 14/24] net: designware: convert to streaming DMA ops
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
                   ` (12 preceding siblings ...)
  2015-02-12 21:39 ` [PATCH RFT 13/24] net: davinci_emac: " Lucas Stach
@ 2015-02-12 21:39 ` Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 15/24] net: fec: " Lucas Stach
                   ` (10 subsequent siblings)
  24 siblings, 0 replies; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 drivers/net/designware.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 2bc4471..1e1befd 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -27,7 +27,6 @@
 #include <io.h>
 #include <net.h>
 #include <of_net.h>
-#include <asm/mmu.h>
 #include <net/designware.h>
 #include <linux/phy.h>
 #include <linux/err.h>
@@ -197,8 +196,8 @@ static void rx_descs_init(struct eth_device *dev)
 		else
 			desc_p->dmamac_cntl |= DESC_RXCTRL_RXCHAIN;
 
-		dma_inv_range((unsigned long)desc_p->dmamac_addr,
-			      (unsigned long)desc_p->dmamac_addr + CONFIG_ETH_BUFSIZE);
+		dma_sync_single_for_cpu((unsigned long)desc_p->dmamac_addr,
+					CONFIG_ETH_BUFSIZE, DMA_FROM_DEVICE);
 		desc_p->txrx_status = DESC_RXSTS_OWNBYDMA;
 	}
 
@@ -302,8 +301,8 @@ static int dwc_ether_send(struct eth_device *dev, void *packet, int length)
 	}
 
 	memcpy((void *)desc_p->dmamac_addr, packet, length);
-	dma_flush_range((unsigned long)desc_p->dmamac_addr,
-			(unsigned long)desc_p->dmamac_addr + length);
+	dma_sync_single_for_device((unsigned long)desc_p->dmamac_addr, length,
+				   DMA_TO_DEVICE);
 
 	if (priv->enh_desc) {
 		desc_p->txrx_status |= DESC_ENH_TXSTS_TXFIRST | DESC_ENH_TXSTS_TXLAST;
@@ -328,6 +327,9 @@ static int dwc_ether_send(struct eth_device *dev, void *packet, int length)
 
 	/* Start the transmission */
 	writel(POLL_DATA, &dma_p->txpolldemand);
+	dma_sync_single_for_cpu((unsigned long)desc_p->dmamac_addr, length,
+				DMA_TO_DEVICE);
+
 	return 0;
 }
 
@@ -351,10 +353,11 @@ static int dwc_ether_rx(struct eth_device *dev)
 	 * Make the current descriptor valid again and go to
 	 * the next one
 	 */
-	dma_inv_range((unsigned long)desc_p->dmamac_addr,
-		      (unsigned long)desc_p->dmamac_addr + length);
-
+	dma_sync_single_for_cpu((unsigned long)desc_p->dmamac_addr, length,
+				DMA_FROM_DEVICE);
 	net_receive(dev, desc_p->dmamac_addr, length);
+	dma_sync_single_for_device((unsigned long)desc_p->dmamac_addr, length,
+				   DMA_FROM_DEVICE);
 
 	desc_p->txrx_status |= DESC_RXSTS_OWNBYDMA;
 
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 15/24] net: fec: convert to streaming DMA ops
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
                   ` (13 preceding siblings ...)
  2015-02-12 21:39 ` [PATCH RFT 14/24] net: designware: " Lucas Stach
@ 2015-02-12 21:39 ` Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 16/24] net: macb: " Lucas Stach
                   ` (9 subsequent siblings)
  24 siblings, 0 replies; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 drivers/net/fec_imx.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index 5761256..484ea0d 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -31,8 +31,6 @@
 #include <of_gpio.h>
 #include <gpio.h>
 
-#include <asm/mmu.h>
-
 #include "fec_imx.h"
 
 struct fec_frame {
@@ -479,8 +477,9 @@ static int fec_send(struct eth_device *dev, void *eth_data, int data_length)
 	writew(data_length, &fec->tbd_base[fec->tbd_index].data_length);
 
 	writel((uint32_t)(eth_data), &fec->tbd_base[fec->tbd_index].data_pointer);
-	dma_flush_range((unsigned long)eth_data,
-			(unsigned long)(eth_data + data_length));
+
+	dma_sync_single_for_device((unsigned long)eth_data, data_length,
+				   DMA_TO_DEVICE);
 	/*
 	 * update BD's status now
 	 * This block:
@@ -503,6 +502,8 @@ static int fec_send(struct eth_device *dev, void *eth_data, int data_length)
 			break;
 		}
 	}
+	dma_sync_single_for_cpu((unsigned long)eth_data, data_length,
+				DMA_TO_DEVICE);
 
 	/* for next transmission use the other buffer */
 	if (fec->tbd_index)
@@ -576,7 +577,11 @@ static int fec_recv(struct eth_device *dev)
 			 */
 			frame = phys_to_virt(readl(&rbd->data_pointer));
 			frame_length = readw(&rbd->data_length) - 4;
+			dma_sync_single_for_cpu((unsigned long)frame->data,
+						frame_length, DMA_FROM_DEVICE);
 			net_receive(dev, frame->data, frame_length);
+			dma_sync_single_for_device((unsigned long)frame->data,
+						   frame_length, DMA_FROM_DEVICE);
 			len = frame_length;
 		} else {
 			if (bd_status & FEC_RBD_ERR) {
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 16/24] net: macb: convert to streaming DMA ops
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
                   ` (14 preceding siblings ...)
  2015-02-12 21:39 ` [PATCH RFT 15/24] net: fec: " Lucas Stach
@ 2015-02-12 21:39 ` Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 17/24] net: orion-gbe: " Lucas Stach
                   ` (8 subsequent siblings)
  24 siblings, 0 replies; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 drivers/net/macb.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index b941c27..957e4a7 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -47,7 +47,6 @@
 #include <platform_data/macb.h>
 #include <linux/clk.h>
 #include <linux/err.h>
-#include <asm/mmu.h>
 #include <linux/phy.h>
 
 #include "macb.h"
@@ -122,7 +121,7 @@ static int macb_send(struct eth_device *edev, void *packet,
 	macb->tx_ring[tx_head].ctrl = ctrl;
 	macb->tx_ring[tx_head].addr = (ulong)packet;
 	barrier();
-	dma_flush_range((ulong) packet, (ulong)packet + length);
+	dma_sync_single_for_device((unsigned long)packet, length, DMA_TO_DEVICE);
 	macb_writel(macb, NCR, MACB_BIT(TE) | MACB_BIT(RE) | MACB_BIT(TSTART));
 
 	start = get_time_ns();
@@ -135,6 +134,7 @@ static int macb_send(struct eth_device *edev, void *packet,
 			break;
 		}
 	} while (!is_timeout(start, 100 * MSECOND));
+	dma_sync_single_for_cpu((unsigned long)packet, length, DMA_TO_DEVICE);
 
 	if (ctrl & MACB_BIT(TX_UNDERRUN))
 		dev_err(macb->dev, "TX underrun\n");
@@ -188,7 +188,11 @@ static int gem_recv(struct eth_device *edev)
 		status = macb->rx_ring[macb->rx_tail].ctrl;
 		length = MACB_BFEXT(RX_FRMLEN, status);
 		buffer = macb->rx_buffer + macb->rx_buffer_size * macb->rx_tail;
+		dma_sync_single_for_cpu((unsigned long)buffer, length,
+					DMA_FROM_DEVICE);
 		net_receive(edev, buffer, length);
+		dma_sync_single_for_device((unsigned long)buffer, length,
+					   DMA_FROM_DEVICE);
 		macb->rx_ring[macb->rx_tail].addr &= ~MACB_BIT(RX_USED);
 		barrier();
 
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 17/24] net: orion-gbe: convert to streaming DMA ops
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
                   ` (15 preceding siblings ...)
  2015-02-12 21:39 ` [PATCH RFT 16/24] net: macb: " Lucas Stach
@ 2015-02-12 21:39 ` Lucas Stach
  2015-02-12 22:40   ` Sebastian Hesselbarth
  2015-02-12 21:39 ` [PATCH RFT 18/24] net: rtl8169: " Lucas Stach
                   ` (7 subsequent siblings)
  24 siblings, 1 reply; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 drivers/net/orion-gbe.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/net/orion-gbe.c b/drivers/net/orion-gbe.c
index ad1fc66..4235122 100644
--- a/drivers/net/orion-gbe.c
+++ b/drivers/net/orion-gbe.c
@@ -33,7 +33,6 @@
 #include <net.h>
 #include <of_net.h>
 #include <linux/sizes.h>
-#include <asm/mmu.h>
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/mbus.h>
@@ -243,7 +242,7 @@ static int port_send(struct eth_device *edev, void *data, int len)
 	int ret;
 
 	/* flush transmit data */
-	dma_flush_range((unsigned long)data, (unsigned long)data+len);
+	dma_sync_single_for_device((unsigned long)data, len, DMA_TO_DEVICE);
 
 	txdesc->cmd_sts = TXDESC_OWNED_BY_DMA;
 	txdesc->cmd_sts |= TXDESC_FIRST | TXDESC_LAST;
@@ -258,6 +257,7 @@ static int port_send(struct eth_device *edev, void *data, int len)
 	/* wait for packet transmit completion */
 	ret = wait_on_timeout(TRANSFER_TIMEOUT,
 		      (readl(&txdesc->cmd_sts) & TXDESC_OWNED_BY_DMA) == 0);
+	dma_sync_single_for_cpu((unsigned long)data, len, DMA_TO_DEVICE);
 	if (ret) {
 		dev_err(&edev->dev, "transmit timeout\n");
 		return ret;
@@ -301,12 +301,15 @@ static int port_recv(struct eth_device *edev)
 	}
 
 	/* invalidate current receive buffer */
-	dma_inv_range((unsigned long)rxdesc->buf_ptr,
-		      (unsigned long)rxdesc->buf_ptr +
-		      ALIGN(PKTSIZE, 8));
+	dma_sync_single_for_cpu((unsigned long)rxdesc->buf_ptr,
+				ALIGN(PKTSIZE, 8), DMA_FROM_DEVICE);
 
 	/* received packet is padded with two null bytes */
 	net_receive(edev, rxdesc->buf_ptr + 0x2, rxdesc->byte_cnt - 0x2);
+
+	dma_sync_single_for_device((unsigned long)rxdesc->buf_ptr,
+				   ALIGN(PKTSIZE, 8), DMA_FROM_DEVICE);
+
 	ret = 0;
 
 recv_err:
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 18/24] net: rtl8169: convert to streaming DMA ops
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
                   ` (16 preceding siblings ...)
  2015-02-12 21:39 ` [PATCH RFT 17/24] net: orion-gbe: " Lucas Stach
@ 2015-02-12 21:39 ` Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 19/24] net: xgmac: " Lucas Stach
                   ` (6 subsequent siblings)
  24 siblings, 0 replies; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 drivers/net/Kconfig   |  1 +
 drivers/net/rtl8169.c | 30 +++++++++++++-----------------
 2 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index adb7008..42ffa65 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -167,6 +167,7 @@ config DRIVER_NET_RTL8139
 config DRIVER_NET_RTL8169
 	bool "RealTek RTL-8169 PCI Ethernet driver"
 	depends on PCI
+	depends on HAS_DMA
 	select PHYLIB
 	help
 	  This is a driver for the Fast Ethernet PCI network cards based on
diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c
index 093a312..ac22512 100644
--- a/drivers/net/rtl8169.c
+++ b/drivers/net/rtl8169.c
@@ -14,7 +14,6 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <asm/mmu.h>
 #include <common.h>
 #include <dma.h>
 #include <init.h>
@@ -234,8 +233,8 @@ static void rtl8169_init_ring(struct rtl8169_priv *priv)
 	priv->rx_desc = dma_alloc_coherent(NUM_RX_DESC *
 				sizeof(struct bufdesc));
 	priv->rx_buf = malloc(NUM_RX_DESC * PKT_BUF_SIZE);
-	dma_clean_range((unsigned long)priv->rx_buf,
-			(unsigned long)priv->rx_buf + NUM_RX_DESC * PKT_BUF_SIZE);
+	dma_sync_single_for_device((unsigned long)priv->rx_buf,
+				   NUM_RX_DESC * PKT_BUF_SIZE, DMA_FROM_DEVICE);
 
 	memset(priv->tx_desc, 0, NUM_TX_DESC * sizeof(struct bufdesc));
 	memset(priv->rx_desc, 0, NUM_RX_DESC * sizeof(struct bufdesc));
@@ -366,8 +365,8 @@ static int rtl8169_eth_send(struct eth_device *edev, void *packet,
 	if (packet_length < ETH_ZLEN)
 		memset(priv->tx_buf + entry * PKT_BUF_SIZE, 0, ETH_ZLEN);
 	memcpy(priv->tx_buf + entry * PKT_BUF_SIZE, packet, packet_length);
-	dma_flush_range((unsigned long)priv->tx_buf + entry * PKT_BUF_SIZE,
-			(unsigned long)priv->tx_buf + (entry + 1) * PKT_BUF_SIZE);
+	dma_sync_single_for_device((unsigned long)priv->tx_buf + entry *
+				   PKT_BUF_SIZE, PKT_BUF_SIZE, DMA_TO_DEVICE);
 
 	priv->tx_desc[entry].buf_Haddr = 0;
 	priv->tx_desc[entry].buf_addr =
@@ -388,6 +387,9 @@ static int rtl8169_eth_send(struct eth_device *edev, void *packet,
 	while (priv->tx_desc[entry].status & BD_STAT_OWN)
 		;
 
+	dma_sync_single_for_cpu((unsigned long)priv->tx_buf + entry *
+				PKT_BUF_SIZE, PKT_BUF_SIZE, DMA_TO_DEVICE);
+
 	priv->cur_tx++;
 
 	return 0;
@@ -405,22 +407,16 @@ static int rtl8169_eth_rx(struct eth_device *edev)
 		if (!(priv->rx_desc[entry].status & BD_STAT_RX_RES)) {
 			pkt_size = (priv->rx_desc[entry].status & 0x1fff) - 4;
 
-			dma_inv_range((unsigned long)priv->rx_buf
-			               + entry * PKT_BUF_SIZE,
-			              (unsigned long)priv->rx_buf
-			               + entry * PKT_BUF_SIZE + pkt_size);
+			dma_sync_single_for_cpu((unsigned long)priv->rx_buf
+						+ entry * PKT_BUF_SIZE,
+						pkt_size, DMA_FROM_DEVICE);
 
 			net_receive(edev, priv->rx_buf + entry * PKT_BUF_SIZE,
 			            pkt_size);
 
-			/*
-			 * the buffer is going to be reused by HW, make sure to
-			 * clean out any potentially modified data
-			 */
-			dma_clean_range((unsigned long)priv->rx_buf
-			               + entry * PKT_BUF_SIZE,
-			              (unsigned long)priv->rx_buf
-			               + entry * PKT_BUF_SIZE + pkt_size);
+			dma_sync_single_for_device((unsigned long)priv->rx_buf
+						   + entry * PKT_BUF_SIZE,
+						   pkt_size, DMA_FROM_DEVICE);
 
 			if (entry == NUM_RX_DESC - 1)
 				priv->rx_desc[entry].status = BD_STAT_OWN |
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 19/24] net: xgmac: convert to streaming DMA ops
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
                   ` (17 preceding siblings ...)
  2015-02-12 21:39 ` [PATCH RFT 18/24] net: rtl8169: " Lucas Stach
@ 2015-02-12 21:39 ` Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 20/24] usb: gadget: fsl_udc: " Lucas Stach
                   ` (5 subsequent siblings)
  24 siblings, 0 replies; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 drivers/net/xgmac.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/xgmac.c b/drivers/net/xgmac.c
index c1e4da8..3369a64 100644
--- a/drivers/net/xgmac.c
+++ b/drivers/net/xgmac.c
@@ -25,7 +25,6 @@
 #include <errno.h>
 #include <io.h>
 #include <linux/err.h>
-#include <asm/mmu.h>
 
 #define TX_NUM_DESC			1
 #define RX_NUM_DESC			32
@@ -587,7 +586,7 @@ static int xgmac_send(struct eth_device *edev, void *packet, int length)
 	struct xgmac_dma_desc *txdesc = &priv->tx_chain[currdesc];
 	int ret;
 
-	dma_flush_range((ulong) packet, (ulong)packet + length);
+	dma_sync_single_for_device((unsigned long)packet, length, DMA_TO_DEVICE);
 	desc_set_buf_addr_and_size(txdesc, packet, length);
 	desc_set_tx_owner(txdesc, TXDESC_FIRST_SEG |
 		TXDESC_LAST_SEG | TXDESC_CRC_EN_APPEND);
@@ -596,6 +595,7 @@ static int xgmac_send(struct eth_device *edev, void *packet, int length)
 	writel(1, priv->base + XGMAC_DMA_TX_POLL);
 
 	ret = wait_on_timeout(1 * SECOND, !desc_get_owner(txdesc));
+	dma_sync_single_for_cpu((unsigned long)packet, length, DMA_TO_DEVICE);
 	if (ret) {
 		dev_err(priv->dev, "TX timeout\n");
 		return ret;
@@ -611,14 +611,19 @@ static int xgmac_recv(struct eth_device *edev)
 	u32 currdesc = priv->rx_currdesc;
 	struct xgmac_dma_desc *rxdesc = &priv->rx_chain[currdesc];
 	int length = 0;
+	void *buf_addr;
 
 	/* check if the host has the desc */
 	if (desc_get_owner(rxdesc))
 		return -1; /* something bad happened */
 
 	length = desc_get_rx_frame_len(rxdesc);
+	buf_addr = desc_get_buf_addr(rxdesc);
 
-	net_receive(edev, desc_get_buf_addr(rxdesc), length);
+	dma_sync_single_for_cpu((unsigned long)buf_addr, length, DMA_FROM_DEVICE);
+	net_receive(edev, , length);
+	dma_sync_single_for_device((unsigned long)buf_addr, length,
+				   DMA_FROM_DEVICE);
 
 	/* set descriptor back to owned by XGMAC */
 	desc_set_rx_owner(rxdesc);
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 20/24] usb: gadget: fsl_udc: convert to streaming DMA ops
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
                   ` (18 preceding siblings ...)
  2015-02-12 21:39 ` [PATCH RFT 19/24] net: xgmac: " Lucas Stach
@ 2015-02-12 21:39 ` Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 21/24] usb: host: ehci: " Lucas Stach
                   ` (4 subsequent siblings)
  24 siblings, 0 replies; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 drivers/usb/gadget/fsl_udc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/fsl_udc.c b/drivers/usb/gadget/fsl_udc.c
index f9e58bb..9aa313a 100644
--- a/drivers/usb/gadget/fsl_udc.c
+++ b/drivers/usb/gadget/fsl_udc.c
@@ -568,8 +568,8 @@ static void done(struct fsl_ep *ep, struct fsl_req *req, int status)
 		dma_free_coherent(curr_td, sizeof(struct ep_td_struct));
 	}
 
-	dma_inv_range((unsigned long)req->req.buf,
-		(unsigned long)(req->req.buf + req->req.length));
+	dma_sync_single_for_cpu((unsigned long)req->req.buf, req->req.length,
+				DMA_BIDIRECTIONAL);
 
 	if (status && (status != -ESHUTDOWN))
 		VDBG("complete %s req %p stat %d len %u/%u",
@@ -1250,8 +1250,8 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req)
 
 	req->ep = ep;
 
-	dma_flush_range((unsigned long)req->req.buf,
-			(unsigned long)(req->req.buf + req->req.length));
+	dma_sync_single_for_device((unsigned long)req->req.buf, req->req.length,
+				   DMA_BIDIRECTIONAL);
 
 	req->req.status = -EINPROGRESS;
 	req->req.actual = 0;
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 21/24] usb: host: ehci: convert to streaming DMA ops
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
                   ` (19 preceding siblings ...)
  2015-02-12 21:39 ` [PATCH RFT 20/24] usb: gadget: fsl_udc: " Lucas Stach
@ 2015-02-12 21:39 ` Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 22/24] usb: host: ohci: " Lucas Stach
                   ` (3 subsequent siblings)
  24 siblings, 0 replies; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 drivers/usb/host/ehci-hcd.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 7f59774..ef1371f 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -30,7 +30,6 @@
 #include <errno.h>
 #include <of.h>
 #include <usb/ehci.h>
-#include <asm/mmu.h>
 #include <linux/err.h>
 
 #include "ehci.h"
@@ -331,7 +330,9 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
 			struct qTD *qtd = &ehci->td[i];
 			if (!qtd->qtd_dma)
 				continue;
-			dma_flush_range(qtd->qtd_dma, qtd->qtd_dma + qtd->length);
+			dma_sync_single_for_device((unsigned long)qtd->qtd_dma,
+						   qtd->length,
+						   DMA_BIDIRECTIONAL);
 		}
 	}
 
@@ -372,7 +373,8 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
 			struct qTD *qtd = &ehci->td[i];
 			if (!qtd->qtd_dma)
 				continue;
-			dma_inv_range(qtd->qtd_dma, qtd->qtd_dma + qtd->length);
+			dma_sync_single_for_cpu((unsigned long)qtd->qtd_dma,
+						qtd->length, DMA_BIDIRECTIONAL);
 		}
 	}
 
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 22/24] usb: host: ohci: convert to streaming DMA ops
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
                   ` (20 preceding siblings ...)
  2015-02-12 21:39 ` [PATCH RFT 21/24] usb: host: ehci: " Lucas Stach
@ 2015-02-12 21:39 ` Lucas Stach
  2015-02-12 21:39 ` [PATCH RFT 23/24] ARM: bcm2835: mbox: " Lucas Stach
                   ` (2 subsequent siblings)
  24 siblings, 0 replies; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 drivers/usb/host/ohci-hcd.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 0cdcbb5..ed3a00e 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -43,6 +43,7 @@
 #include <common.h>
 #include <dma.h>
 #include <clock.h>
+#include <dma.h>
 #include <malloc.h>
 #include <usb/usb.h>
 #include <usb/usb_defs.h>
@@ -52,7 +53,6 @@
 
 #include <asm/byteorder.h>
 #include <io.h>
-#include <asm/mmu.h>
 
 #include "ohci.h"
 
@@ -857,7 +857,7 @@ static void td_fill(struct ohci *ohci, unsigned int info,
 
 	td->hwNextTD = virt_to_phys((void *)m32_swap((unsigned long)td_pt));
 
-	dma_flush_range((unsigned long)data, (unsigned long)(data + len));
+	dma_sync_single_for_device((unsigned long)data, len, DMA_BIDIRECTIONAL);
 
 	/* append to queue */
 	td->ed->hwTailP = td->hwNextTD;
@@ -1093,7 +1093,8 @@ static int dl_done_list(struct ohci *ohci)
 	unsigned long ptdphys = virt_to_phys(ptd);
 	struct td *td_list;
 
-	dma_clean_range(ptdphys, ptdphys + (sizeof(struct td) * NUM_TD));
+	dma_sync_single_for_device((unsigned long)ptdphys,
+				sizeof(struct td) * NUM_TD, DMA_BIDIRECTIONAL);
 
 	td_list = dl_reverse_done_list(ohci);
 
@@ -1529,7 +1530,8 @@ static int submit_common_msg(struct usb_device *dev, unsigned long pipe, void *b
 	dev->status = stat;
 	dev->act_len = urb->actual_length;
 
-	dma_inv_range((unsigned long)buffer, (unsigned long)(buffer + transfer_len));
+	dma_sync_single_for_cpu((unsigned long)buffer, transfer_len,
+				DMA_BIDIRECTIONAL);
 
 	pkt_print(urb, dev, pipe, buffer, transfer_len,
 		  setup, "RET(ctlr)", usb_pipein(pipe));
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 23/24] ARM: bcm2835: mbox: convert to streaming DMA ops
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
                   ` (21 preceding siblings ...)
  2015-02-12 21:39 ` [PATCH RFT 22/24] usb: host: ohci: " Lucas Stach
@ 2015-02-12 21:39 ` Lucas Stach
  2015-02-12 21:40 ` [PATCH RFT 24/24] ARM: MMU: unexport cache maintenance functions Lucas Stach
  2015-02-13 19:48 ` [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Sascha Hauer
  24 siblings, 0 replies; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:39 UTC (permalink / raw)
  To: barebox

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 arch/arm/mach-bcm2835/mbox.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-bcm2835/mbox.c b/arch/arm/mach-bcm2835/mbox.c
index 1a80771..9d69bc8 100644
--- a/arch/arm/mach-bcm2835/mbox.c
+++ b/arch/arm/mach-bcm2835/mbox.c
@@ -7,9 +7,9 @@
  */
 
 #include <asm/io.h>
-#include <asm/mmu.h>
 #include <common.h>
 #include <clock.h>
+#include <dma.h>
 
 #include <mach/mbox.h>
 
@@ -55,7 +55,8 @@ static int bcm2835_mbox_call_raw(u32 chan, struct bcm2835_mbox_hdr *buffer,
 	/* Send the request */
 	val = BCM2835_MBOX_PACK(chan, send);
 	debug("mbox: TX raw: 0x%08x\n", val);
-	dma_flush_range(send, send + buffer->buf_size);
+	dma_sync_single_for_device((unsigned long)send, buffer->buf_size,
+				   DMA_BIDIRECTIONAL);
 	writel(val, &regs->write);
 
 	/* Wait for the response */
@@ -72,7 +73,8 @@ static int bcm2835_mbox_call_raw(u32 chan, struct bcm2835_mbox_hdr *buffer,
 	/* Read the response */
 	val = readl(&regs->read);
 	debug("mbox: RX raw: 0x%08x\n", val);
-	dma_inv_range(send, send + buffer->buf_size);
+	dma_sync_single_for_cpu((unsigned long)send, buffer->buf_size,
+				DMA_BIDIRECTIONAL);
 
 	/* Validate the response */
 	if (BCM2835_MBOX_UNPACK_CHAN(val) != chan) {
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH RFT 24/24] ARM: MMU: unexport cache maintenance functions
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
                   ` (22 preceding siblings ...)
  2015-02-12 21:39 ` [PATCH RFT 23/24] ARM: bcm2835: mbox: " Lucas Stach
@ 2015-02-12 21:40 ` Lucas Stach
  2015-02-13 19:48 ` [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Sascha Hauer
  24 siblings, 0 replies; 29+ messages in thread
From: Lucas Stach @ 2015-02-12 21:40 UTC (permalink / raw)
  To: barebox

Those should only be used internally. All users should rather
use the streaming DMA API, which does proper cache maintenance.

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 arch/arm/cpu/mmu.c         | 35 ++++++++++++++---------------------
 arch/arm/include/asm/mmu.h | 14 --------------
 2 files changed, 14 insertions(+), 35 deletions(-)

diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index e3c06cd..53d0446 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -159,6 +159,20 @@ static u32 *find_pte(unsigned long adr)
 	return &table[(adr >> PAGE_SHIFT) & 0xff];
 }
 
+static void dma_flush_range(unsigned long start, unsigned long end)
+{
+	if (outer_cache.flush_range)
+		outer_cache.flush_range(start, end);
+	__dma_flush_range(start, end);
+}
+
+static void dma_inv_range(unsigned long start, unsigned long end)
+{
+	if (outer_cache.inv_range)
+		outer_cache.inv_range(start, end);
+	__dma_inv_range(start, end);
+}
+
 void remap_range(void *_start, size_t size, uint32_t flags)
 {
 	unsigned long start = (unsigned long)_start;
@@ -412,27 +426,6 @@ void dma_free_coherent(void *mem, size_t size)
 	free(mem);
 }
 
-void dma_clean_range(unsigned long start, unsigned long end)
-{
-	if (outer_cache.clean_range)
-		outer_cache.clean_range(start, end);
-	__dma_clean_range(start, end);
-}
-
-void dma_flush_range(unsigned long start, unsigned long end)
-{
-	if (outer_cache.flush_range)
-		outer_cache.flush_range(start, end);
-	__dma_flush_range(start, end);
-}
-
-void dma_inv_range(unsigned long start, unsigned long end)
-{
-	if (outer_cache.inv_range)
-		outer_cache.inv_range(start, end);
-	__dma_inv_range(start, end);
-}
-
 void dma_sync_single_for_cpu(unsigned long address, size_t size,
 			     enum dma_data_direction dir)
 {
diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h
index 01c20bd..97bb0db 100644
--- a/arch/arm/include/asm/mmu.h
+++ b/arch/arm/include/asm/mmu.h
@@ -27,26 +27,12 @@ static inline void setup_dma_coherent(unsigned long offset)
 }
 
 #ifdef CONFIG_MMU
-void dma_clean_range(unsigned long, unsigned long);
-void dma_flush_range(unsigned long, unsigned long);
-void dma_inv_range(unsigned long, unsigned long);
 void remap_range(void *_start, size_t size, uint32_t flags);
 void *map_io_sections(unsigned long physaddr, void *start, size_t size);
 uint32_t mmu_get_pte_cached_flags(void);
 uint32_t mmu_get_pte_uncached_flags(void);
 
 #else
-static inline void dma_clean_range(unsigned long s, unsigned long e)
-{
-}
-
-static inline void dma_flush_range(unsigned long s, unsigned long e)
-{
-}
-
-static inline void dma_inv_range(unsigned long s, unsigned long e)
-{
-}
 
 static inline void remap_range(void *_start, size_t size, uint32_t flags)
 {
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH RFT 17/24] net: orion-gbe: convert to streaming DMA ops
  2015-02-12 21:39 ` [PATCH RFT 17/24] net: orion-gbe: " Lucas Stach
@ 2015-02-12 22:40   ` Sebastian Hesselbarth
  2015-02-16 10:45     ` Sebastian Hesselbarth
  0 siblings, 1 reply; 29+ messages in thread
From: Sebastian Hesselbarth @ 2015-02-12 22:40 UTC (permalink / raw)
  To: Lucas Stach, barebox

On 12.02.2015 22:39, Lucas Stach wrote:

Lucas,

I really enjoy reading commit logs, but I cannot find any on this
one. ;) Mind adding a few words for the final patch set?

I'll give it a go on Dove and Kirkwood in the next few days, but be
aware that there is still no cache support on both anyway.

Sebastian

> Signed-off-by: Lucas Stach <dev@lynxeye.de>
> ---
>   drivers/net/orion-gbe.c | 13 ++++++++-----
>   1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/orion-gbe.c b/drivers/net/orion-gbe.c
> index ad1fc66..4235122 100644
> --- a/drivers/net/orion-gbe.c
> +++ b/drivers/net/orion-gbe.c
> @@ -33,7 +33,6 @@
>   #include <net.h>
>   #include <of_net.h>
>   #include <linux/sizes.h>
> -#include <asm/mmu.h>
>   #include <linux/clk.h>
>   #include <linux/err.h>
>   #include <linux/mbus.h>
> @@ -243,7 +242,7 @@ static int port_send(struct eth_device *edev, void *data, int len)
>   	int ret;
>
>   	/* flush transmit data */
> -	dma_flush_range((unsigned long)data, (unsigned long)data+len);
> +	dma_sync_single_for_device((unsigned long)data, len, DMA_TO_DEVICE);
>
>   	txdesc->cmd_sts = TXDESC_OWNED_BY_DMA;
>   	txdesc->cmd_sts |= TXDESC_FIRST | TXDESC_LAST;
> @@ -258,6 +257,7 @@ static int port_send(struct eth_device *edev, void *data, int len)
>   	/* wait for packet transmit completion */
>   	ret = wait_on_timeout(TRANSFER_TIMEOUT,
>   		      (readl(&txdesc->cmd_sts) & TXDESC_OWNED_BY_DMA) == 0);
> +	dma_sync_single_for_cpu((unsigned long)data, len, DMA_TO_DEVICE);
>   	if (ret) {
>   		dev_err(&edev->dev, "transmit timeout\n");
>   		return ret;
> @@ -301,12 +301,15 @@ static int port_recv(struct eth_device *edev)
>   	}
>
>   	/* invalidate current receive buffer */
> -	dma_inv_range((unsigned long)rxdesc->buf_ptr,
> -		      (unsigned long)rxdesc->buf_ptr +
> -		      ALIGN(PKTSIZE, 8));
> +	dma_sync_single_for_cpu((unsigned long)rxdesc->buf_ptr,
> +				ALIGN(PKTSIZE, 8), DMA_FROM_DEVICE);
>
>   	/* received packet is padded with two null bytes */
>   	net_receive(edev, rxdesc->buf_ptr + 0x2, rxdesc->byte_cnt - 0x2);
> +
> +	dma_sync_single_for_device((unsigned long)rxdesc->buf_ptr,
> +				   ALIGN(PKTSIZE, 8), DMA_FROM_DEVICE);
> +
>   	ret = 0;
>
>   recv_err:
>


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH RFT 11/24] net: cpsw: convert to streaming DMA ops
  2015-02-12 21:39 ` [PATCH RFT 11/24] net: cpsw: " Lucas Stach
@ 2015-02-13 19:44   ` Sascha Hauer
  0 siblings, 0 replies; 29+ messages in thread
From: Sascha Hauer @ 2015-02-13 19:44 UTC (permalink / raw)
  To: Lucas Stach; +Cc: barebox

On Thu, Feb 12, 2015 at 10:39:47PM +0100, Lucas Stach wrote:
> Signed-off-by: Lucas Stach <dev@lynxeye.de>
> ---
>  drivers/net/cpsw.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
> index 799fac8..5c28aa4 100644
> --- a/drivers/net/cpsw.c
> +++ b/drivers/net/cpsw.c
> @@ -21,6 +21,7 @@
>  #include <init.h>
>  
>  #include <command.h>
> +#include <dma.h

'>' missing here.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM
  2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
                   ` (23 preceding siblings ...)
  2015-02-12 21:40 ` [PATCH RFT 24/24] ARM: MMU: unexport cache maintenance functions Lucas Stach
@ 2015-02-13 19:48 ` Sascha Hauer
  24 siblings, 0 replies; 29+ messages in thread
From: Sascha Hauer @ 2015-02-13 19:48 UTC (permalink / raw)
  To: Lucas Stach; +Cc: barebox

On Thu, Feb 12, 2015 at 10:39:36PM +0100, Lucas Stach wrote:
> This series introduces to Barebox the streaming DMA ops and implements
> them for the ARM architecture. This will make it a lot easier to
> get common cache maintenance operations for all architectures and in
> turn allows for wider reuse of driver across architectures.
> 
> I've tested this on a Tegra124 which is known to fall over in all sorts
> of funny ways if cache maintenance is broken. No odd behavior spotted.
> 
> The series is bisect-clean and I've compile tested it on some defconfigs,
> but please go wild and TEST. I'll take any complaints.

Nice work!

With the one missing '>' added I successfully tested it on i.MX with FEC
and SDHCI and on the beaglebone black with the cpsw driver.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH RFT 17/24] net: orion-gbe: convert to streaming DMA ops
  2015-02-12 22:40   ` Sebastian Hesselbarth
@ 2015-02-16 10:45     ` Sebastian Hesselbarth
  0 siblings, 0 replies; 29+ messages in thread
From: Sebastian Hesselbarth @ 2015-02-16 10:45 UTC (permalink / raw)
  To: Lucas Stach, barebox

On 12.02.2015 23:40, Sebastian Hesselbarth wrote:
> I really enjoy reading commit logs, but I cannot find any on this
> one. ;) Mind adding a few words for the final patch set?
>
> I'll give it a go on Dove and Kirkwood in the next few days, but be
> aware that there is still no cache support on both anyway.

As expected, the patches do no harm to the driver due to the missing
cache support for MVEBU.

Tested-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>

on SolidRun CuBox (Dove).

Thanks!

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2015-02-16 10:45 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-12 21:39 [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
2015-02-12 21:39 ` [PATCH RFT 01/24] usb: gadget: include common.h in header Lucas Stach
2015-02-12 21:39 ` [PATCH RFT 02/24] ARM: move virt<->phys translation to io.h Lucas Stach
2015-02-12 21:39 ` [PATCH RFT 03/24] dma: add streaming DMA ops Lucas Stach
2015-02-12 21:39 ` [PATCH RFT 04/24] ARM: move DMA alloc functions to dma.h Lucas Stach
2015-02-12 21:39 ` [PATCH RFT 05/24] ARM: implement streaming DMA ops Lucas Stach
2015-02-12 21:39 ` [PATCH RFT 06/24] AHCI: convert to " Lucas Stach
2015-02-12 21:39 ` [PATCH RFT 07/24] MCI: dw-mmc: " Lucas Stach
2015-02-12 21:39 ` [PATCH RFT 08/24] MCI: imx: " Lucas Stach
2015-02-12 21:39 ` [PATCH RFT 09/24] MCI: tegra-sdmmc: " Lucas Stach
2015-02-12 21:39 ` [PATCH RFT 10/24] net: arc-emac: " Lucas Stach
2015-02-12 21:39 ` [PATCH RFT 11/24] net: cpsw: " Lucas Stach
2015-02-13 19:44   ` Sascha Hauer
2015-02-12 21:39 ` [PATCH RFT 12/24] net: at91_ether: " Lucas Stach
2015-02-12 21:39 ` [PATCH RFT 13/24] net: davinci_emac: " Lucas Stach
2015-02-12 21:39 ` [PATCH RFT 14/24] net: designware: " Lucas Stach
2015-02-12 21:39 ` [PATCH RFT 15/24] net: fec: " Lucas Stach
2015-02-12 21:39 ` [PATCH RFT 16/24] net: macb: " Lucas Stach
2015-02-12 21:39 ` [PATCH RFT 17/24] net: orion-gbe: " Lucas Stach
2015-02-12 22:40   ` Sebastian Hesselbarth
2015-02-16 10:45     ` Sebastian Hesselbarth
2015-02-12 21:39 ` [PATCH RFT 18/24] net: rtl8169: " Lucas Stach
2015-02-12 21:39 ` [PATCH RFT 19/24] net: xgmac: " Lucas Stach
2015-02-12 21:39 ` [PATCH RFT 20/24] usb: gadget: fsl_udc: " Lucas Stach
2015-02-12 21:39 ` [PATCH RFT 21/24] usb: host: ehci: " Lucas Stach
2015-02-12 21:39 ` [PATCH RFT 22/24] usb: host: ohci: " Lucas Stach
2015-02-12 21:39 ` [PATCH RFT 23/24] ARM: bcm2835: mbox: " Lucas Stach
2015-02-12 21:40 ` [PATCH RFT 24/24] ARM: MMU: unexport cache maintenance functions Lucas Stach
2015-02-13 19:48 ` [PATCH RFT 00/24] Phasing out direct usage of asm/mmu.h on ARM Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox