Phasing out direct usage of asm/mmu.h on ARM
Subsystems (18)
cover Phasing out direct usage of asm/mmu.h on ARM
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
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/24 usb: gadget: include common.h in header
It is needed for container_of() and this header falls over if we change the include order.
--- include/usb/gadget.h | 1 + 1 file changed, 1 insertion(+)
include/usb/gadget.h +1 -0
@@ -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>
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/24 ARM: move virt<->phys translation to io.h
In reply to Lucas StachThat'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.
--- arch/arm/include/asm/io.h | 15 +++++++++++++++ arch/arm/include/asm/mmu.h | 12 ------------ 2 files changed, 15 insertions(+), 12 deletions(-)
arch/arm/include/asm/io.h +15 -0
@@ -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 */
arch/arm/include/asm/mmu.h +0 -12
@@ -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) { }
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 3/24 dma: add streaming DMA ops
In reply to Lucas StachThis will allow us to implement cache maintenance in a platform agnostic way.
--- include/dma-dir.h | 6 ++++++ include/dma.h | 11 +++++++++++ 2 files changed, 17 insertions(+) create mode 100644 include/dma-dir.h
include/dma-dir.h new file +6 -0
@@ -0,0 +1,6 @@ +enum dma_data_direction { +DMA_BIDIRECTIONAL =0 , +DMA_TO_DEVICE =1 , +DMA_FROM_DEVICE =2 , +DMA_NONE =3 , +};
include/dma.h +11 -0
@@ -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 */
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 4/24 ARM: move DMA alloc functions to dma.h
In reply to Lucas StachThis 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.
--- 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(-)
arch/arm/include/asm/dma.h +19 -1
@@ -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
arch/arm/include/asm/mmu.h +0 -19
@@ -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) { }
drivers/ata/ahci.c +1 -0
@@ -21,6 +21,7 @@*/ #include <common.h> +#include <dma.h> #include <init.h> #include <errno.h> #include <io.h>
drivers/dma/apbh_dma.c +1 -1
@@ -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)
drivers/mci/dw_mmc.c +1 -0
@@ -18,6 +18,7 @@*/ #include <common.h> +#include <dma.h> #include <driver.h> #include <malloc.h> #include <clock.h>
drivers/mtd/nand/nand_mxs.c +1 -1
@@ -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)
drivers/net/altera_tse.c +1 -0
@@ -21,6 +21,7 @@*/ #include <common.h> +#include <dma.h> #include <net.h> #include <init.h> #include <clock.h>
drivers/net/arc_emac.c +1 -0
@@ -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>
drivers/net/at91_ether.c +1 -0
@@ -20,6 +20,7 @@*/ #include <common.h> +#include <dma.h> #include <net.h> #include <clock.h> #include <malloc.h>
drivers/net/designware.c +1 -0
@@ -22,6 +22,7 @@*/ #include <common.h> +#include <dma.h> #include <init.h> #include <io.h> #include <net.h>
drivers/net/fec_imx.c +1 -0
@@ -15,6 +15,7 @@*/ #include <common.h> +#include <dma.h> #include <malloc.h> #include <net.h> #include <init.h>
drivers/net/macb.c +1 -0
@@ -38,6 +38,7 @@#include <net.h> #include <clock.h> +#include <dma.h> #include <malloc.h> #include <xfuncs.h> #include <init.h>
drivers/net/mvneta.c +1 -0
@@ -24,6 +24,7 @@*/ #include <common.h> +#include <dma.h> #include <init.h> #include <io.h> #include <net.h>
drivers/net/orion-gbe.c +1 -0
@@ -27,6 +27,7 @@* MA 02110-1301 USA */ #include <common.h> +#include <dma.h> #include <init.h> #include <io.h> #include <net.h>
drivers/net/rtl8139.c +1 -0
@@ -1,4 +1,5 @@#include <common.h> +#include <dma.h> #include <net.h> #include <malloc.h> #include <init.h>
drivers/net/rtl8169.c +1 -0
@@ -16,6 +16,7 @@#include <asm/mmu.h> #include <common.h> +#include <dma.h> #include <init.h> #include <net.h> #include <malloc.h>
drivers/net/xgmac.c +1 -0
@@ -16,6 +16,7 @@*/ #include <common.h> +#include <dma.h> #include <net.h> #include <clock.h> #include <malloc.h>
drivers/spi/mxs_spi.c +0 -1
@@ -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>
drivers/usb/gadget/fsl_udc.c +3 -0
@@ -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
drivers/usb/host/ehci-hcd.c +1 -0
@@ -18,6 +18,7 @@*/ /*#define DEBUG */ #include <common.h> +#include <dma.h> #include <asm/byteorder.h> #include <usb/usb.h> #include <io.h>
drivers/usb/host/ohci-hcd.c +1 -0
@@ -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>
drivers/usb/host/xhci-hcd.c +1 -1
@@ -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>
drivers/usb/host/xhci-hub.c +0 -1
@@ -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>
drivers/video/atmel_hlcdfb.c +0 -1
@@ -27,7 +27,6 @@#include <mach/io.h> #include <mach/cpu.h> #include <errno.h> -#include <asm/mmu.h> #include "atmel_lcdfb.h"
drivers/video/atmel_lcdfb.c +0 -1
@@ -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"
drivers/video/atmel_lcdfb_core.c +1 -1
@@ -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"
drivers/video/imx-ipu-fb.c +1 -1
@@ -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>
drivers/video/imx-ipu-v3/ipu-common.c +0 -1
@@ -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>
drivers/video/imx-ipu-v3/ipufb.c +1 -1
@@ -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"
drivers/video/omap.c +1 -2
@@ -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 {
drivers/video/pxa.c +1 -1
@@ -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 */
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 5/24 ARM: implement streaming DMA ops
In reply to Lucas Stach--- arch/arm/cpu/mmu.c | 24 ++++++++++++++++++++++++ arch/arm/include/asm/dma.h | 10 ++++++++++ 2 files changed, 34 insertions(+)
arch/arm/cpu/mmu.c +24 -0
@@ -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); + } +}
arch/arm/include/asm/dma.h +10 -0
@@ -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
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 6/24 AHCI: convert to streaming DMA ops
In reply to Lucas Stach--- drivers/ata/ahci.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/ata/ahci.c +10 -3
@@ -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 *rbufreturn -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 *rbufif (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 ; }
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 7/24 MCI: dw-mmc: convert to streaming DMA ops
In reply to Lucas Stach--- drivers/mci/Kconfig | 2 +- drivers/mci/dw_mmc.c | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-)
drivers/mci/Kconfig +1 -1
@@ -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
drivers/mci/dw_mmc.c +12 -12
@@ -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 );
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 8/24 MCI: imx: convert to streaming DMA ops
In reply to Lucas Stach--- drivers/mci/imx-esdhc.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-)
drivers/mci/imx-esdhc.c +17 -11
@@ -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 }
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 9/24 MCI: tegra-sdmmc: convert to streaming DMA ops
In reply to Lucas Stach--- drivers/mci/tegra-sdmmc.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
drivers/mci/tegra-sdmmc.c +14 -12
@@ -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 ;
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 10/24 net: arc-emac: convert to streaming DMA ops
In reply to Lucas Stach--- drivers/net/arc_emac.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/net/arc_emac.c +10 -6
@@ -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 ); }
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 11/24 net: cpsw: convert to streaming DMA ops
In reply to Lucas Stach--- drivers/net/cpsw.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/net/cpsw.c +7 -4
@@ -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 ); }
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
maintainerRe: [PATCH RFT 11/24] net: cpsw: convert to streaming DMA ops
Quoted 10 lines · Lucas Stach
Signed-off-by Lucas Stach <[email protected]>--- drivers/net/cpsw.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)drivers/net/cpsw.c +0
-0
drivers/net/cpsw.c line 24
Quoted 4 lines
drivers/net/cpsw.c +1
-0@@ -21,6 +21,7 @@#include <init.h> #include <command.h> +#include <dma.h
'>' missing here.
Sascha
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 12/24 net: at91_ether: convert to streaming DMA ops
In reply to Lucas Stach--- drivers/net/at91_ether.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/net/at91_ether.c +8 -2
@@ -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 )
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 13/24 net: davinci_emac: convert to streaming DMA ops
In reply to Lucas Stach--- drivers/net/davinci_emac.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/net/davinci_emac.c +5 -4
@@ -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; }
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 14/24 net: designware: convert to streaming DMA ops
In reply to Lucas Stach--- drivers/net/designware.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/net/designware.c +11 -8
@@ -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 ;
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 15/24 net: fec: convert to streaming DMA ops
In reply to Lucas Stach--- drivers/net/fec_imx.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/fec_imx.c +9 -4
@@ -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 ) {
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 16/24 net: macb: convert to streaming DMA ops
In reply to Lucas Stach--- drivers/net/macb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/macb.c +6 -2
@@ -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 ();
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 17/24 net: orion-gbe: convert to streaming DMA ops
In reply to Lucas Stach--- drivers/net/orion-gbe.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/net/orion-gbe.c +8 -5
@@ -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:
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH RFT 17/24] net: orion-gbe: convert to streaming DMA ops
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
Quoted 44 lines
Signed-off-by Lucas Stach <[email protected]>--- drivers/net/orion-gbe.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)drivers/net/orion-gbe.c +4
-5@@ -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 );
drivers/net/orion-gbe.c static int port_recv(struct eth_device *edev) · line 315
Quoted 10 lines
drivers/net/orion-gbe.c +4
-0/* 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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Sebastian Hesselbarth
Tested-byRe: [PATCH RFT 17/24] net: orion-gbe: convert to streaming DMA ops
Quoted 5 lines · Sebastian Hesselbarth
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.
on SolidRun CuBox (Dove).
Thanks!
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 18/24 net: rtl8169: convert to streaming DMA ops
In reply to Lucas Stach--- drivers/net/Kconfig | 1 + drivers/net/rtl8169.c | 30 +++++++++++++----------------- 2 files changed, 14 insertions(+), 17 deletions(-)
drivers/net/Kconfig +1 -0
@@ -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
drivers/net/rtl8169.c +13 -17
@@ -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 |
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 19/24 net: xgmac: convert to streaming DMA ops
In reply to Lucas Stach--- drivers/net/xgmac.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/xgmac.c +8 -3
@@ -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);
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 20/24 usb: gadget: fsl_udc: convert to streaming DMA ops
In reply to Lucas Stach--- drivers/usb/gadget/fsl_udc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/gadget/fsl_udc.c +4 -4
@@ -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 ;
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 21/24 usb: host: ehci: convert to streaming DMA ops
In reply to Lucas Stach--- drivers/usb/host/ehci-hcd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/usb/host/ehci-hcd.c +5 -3
@@ -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 ); } }
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 22/24 usb: host: ohci: convert to streaming DMA ops
In reply to Lucas Stach--- drivers/usb/host/ohci-hcd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/usb/host/ohci-hcd.c +6 -4
@@ -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));
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 23/24 ARM: bcm2835: mbox: convert to streaming DMA ops
In reply to Lucas Stach--- arch/arm/mach-bcm2835/mbox.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
arch/arm/mach-bcm2835/mbox.c +5 -3
@@ -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, ®s->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 (®s->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) {
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 24/24 ARM: MMU: unexport cache maintenance functions
In reply to Lucas StachThose should only be used internally. All users should rather use the streaming DMA API, which does proper cache maintenance.
--- arch/arm/cpu/mmu.c | 35 ++++++++++++++--------------------- arch/arm/include/asm/mmu.h | 14 -------------- 2 files changed, 14 insertions(+), 35 deletions(-)
arch/arm/cpu/mmu.c +14 -21
@@ -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) {
arch/arm/include/asm/mmu.h +0 -14
@@ -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) {
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
maintainerQuoted 10 lines · Lucas Stach
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
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox