Phasing out direct usage of asm/mmu.h on ARM
Subsystems (20)
v2 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.
Changes since RFT:
- rebased to current master
- now compile tested on all ARM defconfigs
- fixed a few compile errors by reordering stuff in patches
- A few more words in commit logs
Changes since v1:
- compile tested on MIPS and NIOS
- sync prototypes of the dma_coherent fucntion across all arches
- introduce DMA_ADDRESS_BROKEN in drivers that need fixing for arches without 1:1 virt:phys mapping
Regards,
Lucas
Lucas Stach (27):
usb: gadget: include common.h in header
NIOS2: use dma_addr_t in dma_alloc_coherent
MIPS: change dma_alloc/free_coherent to common prototypes
ARM: change dma_alloc/free_coherent to match other architectures
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 | 55 +++++++++++++++++++++++------------ arch/arm/include/asm/dma.h | 35 +++++++++++++++++++++- arch/arm/include/asm/io.h | 15 ++++++++++ arch/arm/include/asm/mmu.h | 45 ---------------------------- arch/arm/mach-bcm2835/mbox.c | 8 +++-- arch/mips/include/asm/dma-mapping.h | 6 ++-- arch/mips/include/asm/dma.h | 2 +- arch/nios2/include/asm/dma-mapping.h | 13 +++++---- arch/nios2/include/asm/types.h | 2 ++ drivers/ata/ahci.c | 29 ++++++++++++------ drivers/dma/apbh_dma.c | 5 ++-- drivers/mci/Kconfig | 2 +- drivers/mci/dw_mmc.c | 28 +++++++++--------- drivers/mci/imx-esdhc.c | 28 +++++++++++------- drivers/mci/tegra-sdmmc.c | 26 +++++++++-------- drivers/mtd/nand/nand_mxs.c | 7 +++-- drivers/net/Kconfig | 1 + drivers/net/altera_tse.c | 3 +- drivers/net/arc_emac.c | 23 ++++++++++----- drivers/net/at91_ether.c | 17 ++++++++--- drivers/net/cpsw.c | 11 ++++--- drivers/net/davinci_emac.c | 9 +++--- drivers/net/designware.c | 26 ++++++++++------- drivers/net/fec_imx.c | 18 ++++++++---- drivers/net/macb.c | 19 ++++++++---- drivers/net/mvneta.c | 7 +++-- drivers/net/orion-gbe.c | 20 ++++++++----- drivers/net/rtl8139.c | 1 + drivers/net/rtl8169.c | 35 ++++++++++------------ drivers/net/xgmac.c | 20 +++++++++---- drivers/spi/mxs_spi.c | 1 - drivers/usb/gadget/fsl_udc.c | 18 +++++++----- drivers/usb/host/ehci-hcd.c | 15 ++++++---- drivers/usb/host/ohci-hcd.c | 20 ++++++++----- drivers/usb/host/xhci-hcd.c | 8 ++--- 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 | 7 +++-- drivers/video/imx-ipu-fb.c | 4 ++- drivers/video/imx-ipu-v3/ipu-common.c | 1 - drivers/video/imx-ipu-v3/ipufb.c | 5 ++-- drivers/video/omap.c | 7 +++-- drivers/video/pxa.c | 9 +++--- include/dma-dir.h | 6 ++++ include/dma.h | 13 +++++++++ include/usb/gadget.h | 1 + 47 files changed, 389 insertions(+), 245 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 v2 1/27 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 v2 2/27 NIOS2: use dma_addr_t in dma_alloc_coherent
In reply to Lucas StachThis allows to consolidate the prototype of this function across architectures. Also guard against calles that pass in NULL as the dma handle pointer.
--- arch/nios2/include/asm/dma-mapping.h | 13 +++++++------ arch/nios2/include/asm/types.h | 2 ++ drivers/net/altera_tse.c | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-)
arch/nios2/include/asm/dma-mapping.h +7 -6
@@ -14,24 +14,25 @@*/ #if (DCACHE_SIZE !=0 ) -static inline void *dma_alloc_coherent (size_t len,unsigned long *handle) +static inline void *dma_alloc_coherent (size_t len,dma_addr_t *handle) {void *addr =malloc (len +DCACHE_LINE_SIZE );if (!addr)return 0 ;flush_dcache_range ((unsigned long )addr,(unsigned long )addr + len +DCACHE_LINE_SIZE ); - *handle = ((unsigned long )addr + - (DCACHE_LINE_SIZE -1 )) & - ~(DCACHE_LINE_SIZE -1 ) & ~(IO_REGION_BASE ); +if (handle) + *handle = ((dma_addr_t )addr + (DCACHE_LINE_SIZE -1 )) & + ~(DCACHE_LINE_SIZE -1 ) & ~(IO_REGION_BASE );return (void *)(*handle |IO_REGION_BASE ); }#else -static inline void *dma_alloc_coherent (size_t len,unsigned long *handle) +static inline void *dma_alloc_coherent (size_t len,dma_addr_t *handle) {void *addr =malloc (len);if (!addr)return 0 ; - *handle = (unsigned long )addr; +if (handle) + *handle = (dma_addr_t )addr;return (void *)(*handle |IO_REGION_BASE ); }#endif
arch/nios2/include/asm/types.h +2 -0
@@ -3,5 +3,7 @@#include <asm/int-ll64.h> +typedef u32 dma_addr_t ; +#endif
drivers/net/altera_tse.c +1 -1
@@ -520,7 +520,7 @@ static int tse_probe(struct device_d *dev)return PTR_ERR (tx_desc); rx_desc = tx_desc +2 ;#else - tx_desc =dma_alloc_coherent (sizeof (*tx_desc) * (3 +PKTBUFSRX ), (unsigned long *)&dma_handle); + tx_desc =dma_alloc_coherent (sizeof (*tx_desc) * (3 +PKTBUFSRX ), (dma_addr_t *)&dma_handle); rx_desc = tx_desc +2 ;if (!tx_desc) {
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 3/27 MIPS: change dma_alloc/free_coherent to common prototypes
In reply to Lucas Stach--- arch/mips/include/asm/dma-mapping.h | 6 ++++-- arch/mips/include/asm/dma.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-)
arch/mips/include/asm/dma-mapping.h +4 -2
@@ -12,12 +12,14 @@ static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle) ret =xmemalign (PAGE_SIZE , size); - *dma_handle =CPHYSADDR (ret); +if (dma_handle) + *dma_handle =CPHYSADDR (ret);return (void *)CKSEG1ADDR (ret); } -static inline void dma_free_coherent (void *vaddr) +static inline void dma_free_coherent (void *vaddr,dma_addr_t dma_handle, +size_t size) {free (vaddr); }
arch/mips/include/asm/dma.h +1 -1
@@ -8,6 +8,6 @@#ifndef __ASM_DMA_H#define __ASM_DMA_H -/* empty */ +#include "asm/dma-mapping.h" #endif /* __ASM_DMA_H */
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 4/27 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 +void *phys_to_virt (unsigned long phys); +unsigned long virt_to_phys (volatile void *virt); +#else +static inline void *phys_to_virt (unsigned long phys) +{ +return (void *)phys; +} + +static inline unsigned long virt_to_phys (volatile 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 (volatile 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 (volatile 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 v2 4/27 ARM: change dma_alloc/free_coherent to match other architectures
In reply to Lucas StachAs a lot drivers currently rely on the 1:1 virt->phys mapping on ARM we define DMA_ADDRESS_BROKEN to mark them. In order to use them on other architectures with a different mapping they need proper fixing.
--- arch/arm/cpu/mmu.c | 6 ++++-- arch/arm/include/asm/mmu.h | 17 ++++++++++++----- drivers/ata/ahci.c | 15 +++++++++------ drivers/dma/apbh_dma.c | 3 ++- drivers/mci/dw_mmc.c | 3 ++- drivers/mtd/nand/nand_mxs.c | 5 +++-- drivers/net/arc_emac.c | 6 ++++-- drivers/net/at91_ether.c | 6 ++++-- drivers/net/designware.c | 6 ++++-- drivers/net/fec_imx.c | 4 ++-- drivers/net/macb.c | 10 ++++++---- drivers/net/mvneta.c | 6 ++++-- drivers/net/orion-gbe.c | 6 ++++-- drivers/net/rtl8169.c | 4 ++-- drivers/net/xgmac.c | 8 +++++--- drivers/usb/gadget/fsl_udc.c | 7 ++++--- drivers/usb/host/ehci-hcd.c | 6 ++++-- drivers/usb/host/ohci-hcd.c | 9 ++++++--- drivers/usb/host/xhci-hcd.c | 6 +++--- drivers/video/atmel_lcdfb_core.c | 5 +++-- drivers/video/imx-ipu-fb.c | 3 ++- drivers/video/imx-ipu-v3/ipufb.c | 3 ++- drivers/video/omap.c | 6 +++--- drivers/video/pxa.c | 7 ++++--- 24 files changed, 98 insertions(+), 59 deletions(-)
arch/arm/cpu/mmu.c +4 -2
@@ -379,12 +379,14 @@ static int mmu_init(void) }mmu_initcall (mmu_init); -void *dma_alloc_coherent (size_t size) +void *dma_alloc_coherent (size_t size,dma_addr_t *dma_handle) {void *ret; size =PAGE_ALIGN (size); ret =xmemalign (PAGE_SIZE , size); +if (dma_handle) + *dma_handle = (dma_addr_t )ret;dma_inv_range ((unsigned long )ret, (unsigned long )ret + size);
@@ -403,7 +405,7 @@ void *phys_to_virt(unsigned long phys)return (void *)phys; } -void dma_free_coherent (void *mem,size_t size) +void dma_free_coherent (void *mem,dma_addr_t dma_handle,size_t size) { size =PAGE_ALIGN (size);remap_range (mem, size, pte_flags_cached);
arch/arm/include/asm/mmu.h +12 -5
@@ -11,6 +11,8 @@#define PMD_SECT_DEF_UNCACHED (PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | PMD_TYPE_SECT)#define PMD_SECT_DEF_CACHED (PMD_SECT_WB | PMD_SECT_DEF_UNCACHED) +#define DMA_ADDRESS_BROKEN NULL +struct arm_memory ;static inline void mmu_enable (void )
@@ -33,8 +35,8 @@ static inline void *dma_alloc(size_t size) }#ifdef CONFIG_MMU -void *dma_alloc_coherent (size_t size); -void dma_free_coherent (void *mem,size_t size); +void *dma_alloc_coherent (size_t size,dma_addr_t *dma_handle); +void dma_free_coherent (void *mem,dma_addr_t dma_handle,size_t size);void dma_clean_range (unsigned long ,unsigned long );void dma_flush_range (unsigned long ,unsigned long );
@@ -47,12 +49,17 @@ 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) +static inline void *dma_alloc_coherent (size_t size,dma_addr_t *dma_handle) { -return xmemalign (4096 , size); +void *ret =xmemalign (4096 , size); +if (dma_handle) + *dma_handle = (dma_addr_t )ret; + +return ret; } -static inline void dma_free_coherent (void *mem,size_t size) +static inline void dma_free_coherent (void *mem,dma_addr_t dma_handle, +size_t size) {free (mem); }
drivers/ata/ahci.c +9 -6
@@ -310,7 +310,8 @@ static int ahci_init_port(struct ahci_port *ahci_port)* First item in chunk of DMA memory: 32-slot command table, * 32 bytes each in size */ - ahci_port->cmd_slot =dma_alloc_coherent (AHCI_CMD_SLOT_SZ *32 ); + ahci_port->cmd_slot =dma_alloc_coherent (AHCI_CMD_SLOT_SZ *32 , +DMA_ADDRESS_BROKEN );if (!ahci_port->cmd_slot) { ret = -ENOMEM ; goto err_alloc;
@@ -321,7 +322,8 @@ static int ahci_init_port(struct ahci_port *ahci_port)/* * Second item: Received-FIS area */ - ahci_port->rx_fis = (unsigned long )dma_alloc_coherent (AHCI_RX_FIS_SZ ); + ahci_port->rx_fis = (unsigned long )dma_alloc_coherent (AHCI_RX_FIS_SZ , +DMA_ADDRESS_BROKEN );if (!ahci_port->rx_fis) { ret = -ENOMEM ; goto err_alloc1;
@@ -331,7 +333,8 @@ static int ahci_init_port(struct ahci_port *ahci_port)* Third item: data area for storing a single command * and its scatter-gather table */ - ahci_port->cmd_tbl =dma_alloc_coherent (AHCI_CMD_TBL_SZ ); + ahci_port->cmd_tbl =dma_alloc_coherent (AHCI_CMD_TBL_SZ , +DMA_ADDRESS_BROKEN );if (!ahci_port->cmd_tbl) { ret = -ENOMEM ; goto err_alloc2;
@@ -429,11 +432,11 @@ static int ahci_init_port(struct ahci_port *ahci_port) ret = -ENODEV ; err_init: -dma_free_coherent (ahci_port->cmd_tbl,AHCI_CMD_TBL_SZ ); +dma_free_coherent (ahci_port->cmd_tbl,0 ,AHCI_CMD_TBL_SZ ); err_alloc2: -dma_free_coherent ((void *)ahci_port->rx_fis,AHCI_RX_FIS_SZ ); +dma_free_coherent ((void *)ahci_port->rx_fis,0 ,AHCI_RX_FIS_SZ ); err_alloc1: -dma_free_coherent (ahci_port->cmd_slot,AHCI_CMD_SLOT_SZ *32 ); +dma_free_coherent (ahci_port->cmd_slot,0 ,AHCI_CMD_SLOT_SZ *32 ); err_alloc:return ret; }
drivers/dma/apbh_dma.c +2 -1
@@ -380,7 +380,8 @@ struct mxs_dma_desc *mxs_dma_desc_alloc(void) {struct mxs_dma_desc *pdesc; - pdesc =dma_alloc_coherent (sizeof (struct mxs_dma_desc )); + pdesc =dma_alloc_coherent (sizeof (struct mxs_dma_desc ), +DMA_ADDRESS_BROKEN );if (pdesc ==NULL )return NULL ;
drivers/mci/dw_mmc.c +2 -1
@@ -564,7 +564,8 @@ static int dw_mmc_probe(struct device_d *dev)/* divider is 0 based in pdata and 1 based in our private struct */ host->ciu_div++; - host->idmac =dma_alloc_coherent (sizeof (*host->idmac) *DW_MMC_NUM_IDMACS ); + host->idmac =dma_alloc_coherent (sizeof (*host->idmac) *DW_MMC_NUM_IDMACS , +DMA_ADDRESS_BROKEN ); host->mci.send_cmd = dwmci_cmd; host->mci.set_ios = dwmci_set_ios;
drivers/mtd/nand/nand_mxs.c +3 -2
@@ -1141,7 +1141,7 @@ int mxs_nand_alloc_buffers(struct mxs_nand_info *nand_info)const int size =NAND_MAX_PAGESIZE +NAND_MAX_OOBSIZE ;/* DMA buffers */ - buf =dma_alloc_coherent (size); + buf =dma_alloc_coherent (size,DMA_ADDRESS_BROKEN );if (!buf) {printf ("MXS NAND: Error allocating DMA buffers\n" );return -ENOMEM ;
@@ -1153,7 +1153,8 @@ int mxs_nand_alloc_buffers(struct mxs_nand_info *nand_info) nand_info->oob_buf = buf +NAND_MAX_PAGESIZE ;/* Command buffers */ - nand_info->cmd_buf =dma_alloc_coherent (MXS_NAND_COMMAND_BUFFER_SIZE ); + nand_info->cmd_buf =dma_alloc_coherent (MXS_NAND_COMMAND_BUFFER_SIZE , +DMA_ADDRESS_BROKEN );if (!nand_info->cmd_buf) {free (buf);printf ("MXS NAND: Error allocating command buffers\n" );
drivers/net/arc_emac.c +4 -2
@@ -430,8 +430,10 @@ static int arc_emac_probe(struct device_d *dev) miibus->parent = dev;/* allocate rx/tx descriptors */ - priv->rxbd =dma_alloc_coherent (RX_BD_NUM *sizeof (struct arc_emac_bd )); - priv->txbd =dma_alloc_coherent (TX_BD_NUM *sizeof (struct arc_emac_bd )); + priv->rxbd =dma_alloc_coherent (RX_BD_NUM *sizeof (struct arc_emac_bd ), +DMA_ADDRESS_BROKEN ); + priv->txbd =dma_alloc_coherent (TX_BD_NUM *sizeof (struct arc_emac_bd ), +DMA_ADDRESS_BROKEN ); priv->rxbuf =dma_alloc (RX_BD_NUM *PKTSIZE );/* Set poll rate so that it polls every 1 ms */
drivers/net/at91_ether.c +4 -2
@@ -320,8 +320,10 @@ static int at91_ether_probe(struct device_d *dev) edev->halt = at91_ether_halt; edev->get_ethaddr = at91_ether_get_ethaddr; edev->set_ethaddr = at91_ether_set_ethaddr; - ether_dev->rbf_framebuf =dma_alloc_coherent (MAX_RX_DESCR *MAX_RBUFF_SZ ); - ether_dev->rbfdt =dma_alloc_coherent (sizeof (struct rbf_t ) *MAX_RX_DESCR ); + ether_dev->rbf_framebuf =dma_alloc_coherent (MAX_RX_DESCR *MAX_RBUFF_SZ , +DMA_ADDRESS_BROKEN ); + ether_dev->rbfdt =dma_alloc_coherent (sizeof (struct rbf_t ) *MAX_RX_DESCR , +DMA_ADDRESS_BROKEN ); ether_dev->phy_addr = pdata->phy_addr; miibus->read = at91_ether_mii_read;
drivers/net/designware.c +4 -2
@@ -448,9 +448,11 @@ static int dwc_ether_probe(struct device_d *dev)dwc_version (dev,readl (&priv->mac_regs_p->version)); priv->dma_regs_p = base +DW_DMA_BASE_OFFSET ; priv->tx_mac_descrtable =dma_alloc_coherent ( -CONFIG_TX_DESCR_NUM *sizeof (struct dmamacdescr )); +CONFIG_TX_DESCR_NUM *sizeof (struct dmamacdescr ), +DMA_ADDRESS_BROKEN ); priv->rx_mac_descrtable =dma_alloc_coherent ( -CONFIG_RX_DESCR_NUM *sizeof (struct dmamacdescr )); +CONFIG_RX_DESCR_NUM *sizeof (struct dmamacdescr ), +DMA_ADDRESS_BROKEN ); priv->txbuffs =dma_alloc (TX_TOTAL_BUFSIZE ); priv->rxbuffs =dma_alloc (RX_TOTAL_BUFSIZE );
drivers/net/fec_imx.c +2 -2
@@ -600,7 +600,7 @@ static int fec_alloc_receive_packets(struct fec_priv *fec, int count, int size)int i;/* reserve data memory and consider alignment */ - p =dma_alloc_coherent (size * count); + p =dma_alloc_coherent (size * count,DMA_ADDRESS_BROKEN );if (!p)return -ENOMEM ;
@@ -698,7 +698,7 @@ static int fec_probe(struct device_d *dev)* Datasheet forces the startaddress of each chain is 16 byte aligned */ base =dma_alloc_coherent ((2 +FEC_RBD_NUM ) * -sizeof (struct buffer_descriptor )); +sizeof (struct buffer_descriptor ),DMA_ADDRESS_BROKEN ); fec->rbd_base = base; base +=FEC_RBD_NUM *sizeof (struct buffer_descriptor ); fec->tbd_base = base;
drivers/net/macb.c +6 -4
@@ -597,7 +597,8 @@ static void macb_init_rx_buffer_size(struct macb_device *bp, size_t size) bp->rx_buffer_size =roundup (bp->rx_buffer_size,RX_BUFFER_MULTIPLE ); } - bp->rx_buffer =dma_alloc_coherent (bp->rx_buffer_size * bp->rx_ring_size); + bp->rx_buffer =dma_alloc_coherent (bp->rx_buffer_size * bp->rx_ring_size, +DMA_ADDRESS_BROKEN ); } dev_dbg(bp->dev, "[%d] rx_buffer_size [%d]\n",
@@ -667,9 +668,10 @@ static int macb_probe(struct device_d *dev) edev->recv = macb_recv;macb_init_rx_buffer_size (macb,PKTSIZE ); - macb->rx_buffer =dma_alloc_coherent (macb->rx_buffer_size * macb->rx_ring_size); - macb->rx_ring =dma_alloc_coherent (RX_RING_BYTES (macb)); - macb->tx_ring =dma_alloc_coherent (TX_RING_BYTES ); + macb->rx_buffer =dma_alloc_coherent (macb->rx_buffer_size * macb->rx_ring_size, +DMA_ADDRESS_BROKEN ); + macb->rx_ring =dma_alloc_coherent (RX_RING_BYTES (macb),DMA_ADDRESS_BROKEN ); + macb->tx_ring =dma_alloc_coherent (TX_RING_BYTES ,DMA_ADDRESS_BROKEN );macb_reset_hw (macb); ncfgr =macb_mdc_clk_div (macb);
drivers/net/mvneta.c +4 -2
@@ -590,9 +590,11 @@ void mvneta_setup_tx_rx(struct mvneta_port *priv)u32 val;/* Allocate descriptors and buffers */ - priv->txdesc =dma_alloc_coherent (ALIGN (sizeof (*priv->txdesc),32 )); + priv->txdesc =dma_alloc_coherent (ALIGN (sizeof (*priv->txdesc),32 ), +DMA_ADDRESS_BROKEN ); priv->rxdesc =dma_alloc_coherent (RX_RING_SIZE * -ALIGN (sizeof (*priv->rxdesc),32 )); +ALIGN (sizeof (*priv->rxdesc),32 ), +DMA_ADDRESS_BROKEN ); priv->rxbuf =dma_alloc (RX_RING_SIZE *ALIGN (PKTSIZE ,8 ));mvneta_init_rx_ring (priv);
drivers/net/orion-gbe.c +4 -2
@@ -419,9 +419,11 @@ static int port_probe(struct device_d *parent, struct port_priv *port)return PTR_ERR (port->regs);/* allocate rx/tx descriptors and buffers */ - port->txdesc =dma_alloc_coherent (ALIGN (sizeof (*port->txdesc),16 )); + port->txdesc =dma_alloc_coherent (ALIGN (sizeof (*port->txdesc),16 ), +DMA_ADDRESS_BROKEN ); port->rxdesc =dma_alloc_coherent (RX_RING_SIZE * -ALIGN (sizeof (*port->rxdesc),16 )); +ALIGN (sizeof (*port->rxdesc),16 ), +DMA_ADDRESS_BROKEN ); port->rxbuf =dma_alloc (RX_RING_SIZE *ALIGN (PKTSIZE ,8 ));port_stop (port);
drivers/net/rtl8169.c +2 -2
@@ -228,10 +228,10 @@ static void rtl8169_init_ring(struct rtl8169_priv *priv) priv->cur_rx = priv->cur_tx =0 ; priv->tx_desc =dma_alloc_coherent (NUM_TX_DESC * -sizeof (struct bufdesc )); +sizeof (struct bufdesc ),DMA_ADDRESS_BROKEN ); priv->tx_buf =malloc (NUM_TX_DESC *PKT_BUF_SIZE ); priv->rx_desc =dma_alloc_coherent (NUM_RX_DESC * -sizeof (struct bufdesc )); +sizeof (struct bufdesc ),DMA_ADDRESS_BROKEN ); 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 );
drivers/net/xgmac.c +5 -3
@@ -698,9 +698,11 @@ static int hb_xgmac_probe(struct device_d *dev) priv->dev = dev; priv->base = base; - priv->rxbuffer =dma_alloc_coherent (RX_BUF_SZ ); - priv->rx_chain =dma_alloc_coherent (RX_NUM_DESC *sizeof (struct xgmac_dma_desc )); - priv->tx_chain =dma_alloc_coherent (TX_NUM_DESC *sizeof (struct xgmac_dma_desc )); + priv->rxbuffer =dma_alloc_coherent (RX_BUF_SZ ,DMA_ADDRESS_BROKEN ); + priv->rx_chain =dma_alloc_coherent (RX_NUM_DESC *sizeof (struct xgmac_dma_desc ), +DMA_ADDRESS_BROKEN ); + priv->tx_chain =dma_alloc_coherent (TX_NUM_DESC *sizeof (struct xgmac_dma_desc ), +DMA_ADDRESS_BROKEN ); edev = &priv->edev; edev->priv = priv;
drivers/usb/gadget/fsl_udc.c +4 -3
@@ -562,7 +562,7 @@ static void done(struct fsl_ep *ep, struct fsl_req *req, int status)if (j != req->dtd_count -1 ) { next_td = curr_td->next_td_virt; } -dma_free_coherent (curr_td,sizeof (struct ep_td_struct )); +dma_free_coherent (curr_td,0 ,sizeof (struct ep_td_struct )); } dma_inv_range((unsigned long)req->req.buf,
@@ -1135,7 +1135,8 @@ static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req, unsigned *length, *length =min (req->req.length - req->req.actual, (unsigned )EP_MAX_LENGTH_TRANSFER ); - dtd =dma_alloc_coherent (sizeof (struct ep_td_struct )); + dtd =dma_alloc_coherent (sizeof (struct ep_td_struct ), +DMA_ADDRESS_BROKEN );if (dtd ==NULL )return dtd;
@@ -2058,7 +2059,7 @@ static int struct_udc_setup(struct fsl_udc *udc, size &= ~(QH_ALIGNMENT -1 ); } - udc->ep_qh =dma_alloc_coherent (size); + udc->ep_qh =dma_alloc_coherent (size,DMA_ADDRESS_BROKEN );if (!udc->ep_qh) {ERR ("malloc QHs for udc failed\n" );kfree (udc->eps);
drivers/usb/host/ehci-hcd.c +4 -2
@@ -890,8 +890,10 @@ int ehci_register(struct device_d *dev, struct ehci_data *data) ehci->init = data->init; ehci->post_init = data->post_init; - ehci->qh_list =dma_alloc_coherent (sizeof (struct QH ) *NUM_TD ); - ehci->td =dma_alloc_coherent (sizeof (struct qTD ) *NUM_TD ); + ehci->qh_list =dma_alloc_coherent (sizeof (struct QH ) *NUM_TD , +DMA_ADDRESS_BROKEN ); + ehci->td =dma_alloc_coherent (sizeof (struct qTD ) *NUM_TD , +DMA_ADDRESS_BROKEN ); host->hw_dev = dev; host->init = ehci_init;
drivers/usb/host/ohci-hcd.c +6 -3
@@ -1758,7 +1758,8 @@ static int ohci_init(struct usb_host *host)info ("%s\n" , __func__); - ohci->ptd =dma_alloc_coherent (sizeof (struct td ) *NUM_TD ); + ohci->ptd =dma_alloc_coherent (sizeof (struct td ) *NUM_TD , +DMA_ADDRESS_BROKEN );if (!ohci->ptd)return -ENOMEM ;memset (ohci->ptd,0 ,sizeof (struct td ) *NUM_TD );
@@ -1801,11 +1802,13 @@ static int ohci_probe(struct device_d *dev) host->submit_control_msg = submit_control_msg; host->submit_bulk_msg = submit_bulk_msg; - ohci->hcca =dma_alloc_coherent (sizeof (*ohci->hcca)); + ohci->hcca =dma_alloc_coherent (sizeof (*ohci->hcca), +DMA_ADDRESS_BROKEN );if (!ohci->hcca)return -ENOMEM ; - ohci->ohci_dev =dma_alloc_coherent (sizeof (*ohci->ohci_dev)); + ohci->ohci_dev =dma_alloc_coherent (sizeof (*ohci->ohci_dev), +DMA_ADDRESS_BROKEN );if (!ohci->ohci_dev)return -ENOMEM ;memset (ohci->ohci_dev,0 ,sizeof (*ohci->ohci_dev));
drivers/usb/host/xhci-hcd.c +3 -3
@@ -444,7 +444,7 @@ static struct xhci_virtual_device *xhci_alloc_virtdev(struct xhci_hcd *xhci, sz_ictx =ALIGN (sz_ctx +HCC_CTX_SIZE (xhci->hcc_params),64 ); vdev->dma_size = sz_ictx + sz_dctx; - p = vdev->dma =dma_alloc_coherent (vdev->dma_size); + p = vdev->dma =dma_alloc_coherent (vdev->dma_size,DMA_ADDRESS_BROKEN );memset (vdev->dma,0 , vdev->dma_size); vdev->out_ctx = p; p += sz_dctx;
@@ -463,7 +463,7 @@ static void xhci_free_virtdev(struct xhci_virtual_device *vdev)xhci_put_endpoint_ring (xhci, vdev->ep[i]);list_del (&vdev->list); -dma_free_coherent (vdev->dma, vdev->dma_size); +dma_free_coherent (vdev->dma,0 , vdev->dma_size);free (vdev); }
@@ -1203,7 +1203,7 @@ static void xhci_dma_alloc(struct xhci_hcd *xhci) num_ep =max (MAX_EP_RINGS ,MIN_EP_RINGS + num_ep); xhci->dma_size += num_ep * sz_ep; - p = xhci->dma =dma_alloc_coherent (xhci->dma_size); + p = xhci->dma =dma_alloc_coherent (xhci->dma_size,DMA_ADDRESS_BROKEN );memset (xhci->dma,0 , xhci->dma_size); xhci->sp = p; p += sz_sp;
drivers/video/atmel_lcdfb_core.c +3 -2
@@ -200,7 +200,7 @@ static int atmel_lcdfb_alloc_video_memory(struct atmel_lcdfb_info *sinfo) * ((info->bits_per_pixel + 7) / 8)); smem_len =max (smem_len, sinfo->smem_len); - info->screen_base =dma_alloc_coherent (smem_len); + info->screen_base =dma_alloc_coherent (smem_len,DMA_ADDRESS_BROKEN );if (!info->screen_base)return -ENOMEM ;
@@ -289,7 +289,8 @@ int atmel_lcdc_register(struct device_d *dev, struct atmel_lcdfb_devdata *data)atmel_lcdfb_start_clock (sinfo);if (data->dma_desc_size) - sinfo->dma_desc =dma_alloc_coherent (data->dma_desc_size); + sinfo->dma_desc =dma_alloc_coherent (data->dma_desc_size, +DMA_ADDRESS_BROKEN ); ret =register_framebuffer (info);if (ret !=0 ) {
drivers/video/imx-ipu-fb.c +2 -1
@@ -1030,7 +1030,8 @@ static int imxfb_probe(struct device_d *dev) fbi->info.screen_size, mmu_get_pte_uncached_flags()); }else { - fbi->info.screen_base =dma_alloc_coherent (fbi->info.screen_size); + fbi->info.screen_base =dma_alloc_coherent (fbi->info.screen_size, +DMA_ADDRESS_BROKEN );if (!fbi->info.screen_base)return -ENOMEM ; }
drivers/video/imx-ipu-v3/ipufb.c +2 -1
@@ -203,7 +203,8 @@ static int ipufb_activate_var(struct fb_info *info) struct ipufb_info *fbi = container_of(info, struct ipufb_info, info); info->line_length = info->xres * (info->bits_per_pixel >>3 ); - fbi->info.screen_base =dma_alloc_coherent (info->line_length * info->yres); + fbi->info.screen_base =dma_alloc_coherent (info->line_length * info->yres, +DMA_ADDRESS_BROKEN );if (!fbi->info.screen_base)return -ENOMEM ;
drivers/video/omap.c +3 -3
@@ -126,7 +126,7 @@ static void omapfb_disable(struct fb_info *info)/* free frame buffer; but only when screen is not * preallocated */ if (info->screen_base) -dma_free_coherent (info->screen_base, fbi->dma_size); +dma_free_coherent (info->screen_base,0 , fbi->dma_size); } info->screen_base =NULL ;
@@ -270,13 +270,13 @@ static int omapfb_activate_var(struct fb_info *info)/*Free old screen buf*/ if (!fbi->prealloc_screen.addr && info->screen_base) -dma_free_coherent (info->screen_base, fbi->dma_size); +dma_free_coherent (info->screen_base,0 , fbi->dma_size); fbi->dma_size =PAGE_ALIGN (size);if (!fbi->prealloc_screen.addr) {/* case 1: no preallocated screen */ - info->screen_base =dma_alloc_coherent (size); + info->screen_base =dma_alloc_coherent (size,DMA_ADDRESS_BROKEN ); }else if (fbi->prealloc_screen.size < fbi->dma_size) {/* case 2: preallocated screen, but too small */ dev_err(fbi->dev,
drivers/video/pxa.c +4 -3
@@ -522,11 +522,12 @@ static int pxafb_probe(struct device_d *dev)else fbi->info.screen_base =PTR_ALIGN (dma_alloc_coherent (info->xres * info->yres * - (info->bits_per_pixel >>3 ) +PAGE_SIZE ), + (info->bits_per_pixel >>3 ) +PAGE_SIZE , +DMA_ADDRESS_BROKEN ),PAGE_SIZE ); - fbi->dma_buff =PTR_ALIGN (dma_alloc_coherent (sizeof (struct pxafb_dma_buff ) +16 ), -16 ); + fbi->dma_buff =PTR_ALIGN (dma_alloc_coherent (sizeof (struct pxafb_dma_buff ) +16 , +DMA_ADDRESS_BROKEN ),16 );pxafb_activate_var (fbi);
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 5/27 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,dma_addr_t *dma_handle); +void dma_free_coherent (void *mem,dma_addr_t dma_handle,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 v2 5/27 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 +void *phys_to_virt (unsigned long phys); +unsigned long virt_to_phys (volatile void *virt); +#else +static inline void *phys_to_virt (unsigned long phys) +{ +return (void *)phys; +} + +static inline unsigned long virt_to_phys (volatile void *mem) +{ +return (unsigned long )mem; +} +#endif +#endif /* __ASM_ARM_IO_H */
arch/arm/include/asm/mmu.h +0 -12
@@ -41,8 +41,6 @@ void dma_free_coherent(void *mem, dma_addr_t dma_handle, 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 (volatile 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 );
@@ -64,16 +62,6 @@ static inline void dma_free_coherent(void *mem, dma_addr_t dma_handle,free (mem); } -static inline void *phys_to_virt (unsigned long phys) -{ -return (void *)phys; -} - -static inline unsigned long virt_to_phys (volatile 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 v2 6/27 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,dma_addr_t *dma_handle); +void dma_free_coherent (void *mem,dma_addr_t dma_handle,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 v2 6/27 ARM: change dma_alloc/free_coherent to match other architectures
In reply to Lucas StachAs a lot drivers currently rely on the 1:1 virt->phys mapping on ARM we define DMA_ADDRESS_BROKEN to mark them. In order to use them on other architectures with a different mapping they need proper fixing.
--- arch/arm/cpu/mmu.c | 6 ++++-- arch/arm/include/asm/mmu.h | 17 ++++++++++++----- drivers/ata/ahci.c | 15 +++++++++------ drivers/dma/apbh_dma.c | 3 ++- drivers/mci/dw_mmc.c | 3 ++- drivers/mtd/nand/nand_mxs.c | 5 +++-- drivers/net/arc_emac.c | 6 ++++-- drivers/net/at91_ether.c | 6 ++++-- drivers/net/designware.c | 6 ++++-- drivers/net/fec_imx.c | 4 ++-- drivers/net/macb.c | 10 ++++++---- drivers/net/mvneta.c | 6 ++++-- drivers/net/orion-gbe.c | 6 ++++-- drivers/net/rtl8169.c | 4 ++-- drivers/net/xgmac.c | 8 +++++--- drivers/usb/gadget/fsl_udc.c | 7 ++++--- drivers/usb/host/ehci-hcd.c | 6 ++++-- drivers/usb/host/ohci-hcd.c | 9 ++++++--- drivers/usb/host/xhci-hcd.c | 6 +++--- drivers/video/atmel_lcdfb_core.c | 5 +++-- drivers/video/imx-ipu-fb.c | 3 ++- drivers/video/imx-ipu-v3/ipufb.c | 3 ++- drivers/video/omap.c | 6 +++--- drivers/video/pxa.c | 7 ++++--- 24 files changed, 98 insertions(+), 59 deletions(-)
arch/arm/cpu/mmu.c +4 -2
@@ -379,12 +379,14 @@ static int mmu_init(void) }mmu_initcall (mmu_init); -void *dma_alloc_coherent (size_t size) +void *dma_alloc_coherent (size_t size,dma_addr_t *dma_handle) {void *ret; size =PAGE_ALIGN (size); ret =xmemalign (PAGE_SIZE , size); +if (dma_handle) + *dma_handle = (dma_addr_t )ret;dma_inv_range ((unsigned long )ret, (unsigned long )ret + size);
@@ -403,7 +405,7 @@ void *phys_to_virt(unsigned long phys)return (void *)phys; } -void dma_free_coherent (void *mem,size_t size) +void dma_free_coherent (void *mem,dma_addr_t dma_handle,size_t size) { size =PAGE_ALIGN (size);remap_range (mem, size, pte_flags_cached);
arch/arm/include/asm/mmu.h +12 -5
@@ -11,6 +11,8 @@#define PMD_SECT_DEF_UNCACHED (PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | PMD_TYPE_SECT)#define PMD_SECT_DEF_CACHED (PMD_SECT_WB | PMD_SECT_DEF_UNCACHED) +#define DMA_ADDRESS_BROKEN NULL +struct arm_memory ;static inline void mmu_enable (void )
@@ -33,8 +35,8 @@ static inline void *dma_alloc(size_t size) }#ifdef CONFIG_MMU -void *dma_alloc_coherent (size_t size); -void dma_free_coherent (void *mem,size_t size); +void *dma_alloc_coherent (size_t size,dma_addr_t *dma_handle); +void dma_free_coherent (void *mem,dma_addr_t dma_handle,size_t size);void dma_clean_range (unsigned long ,unsigned long );void dma_flush_range (unsigned long ,unsigned long );
@@ -45,12 +47,17 @@ 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) +static inline void *dma_alloc_coherent (size_t size,dma_addr_t *dma_handle) { -return xmemalign (4096 , size); +void *ret =xmemalign (4096 , size); +if (dma_handle) + *dma_handle = (dma_addr_t )ret; + +return ret; } -static inline void dma_free_coherent (void *mem,size_t size) +static inline void dma_free_coherent (void *mem,dma_addr_t dma_handle, +size_t size) {free (mem); }
drivers/ata/ahci.c +9 -6
@@ -310,7 +310,8 @@ static int ahci_init_port(struct ahci_port *ahci_port)* First item in chunk of DMA memory: 32-slot command table, * 32 bytes each in size */ - ahci_port->cmd_slot =dma_alloc_coherent (AHCI_CMD_SLOT_SZ *32 ); + ahci_port->cmd_slot =dma_alloc_coherent (AHCI_CMD_SLOT_SZ *32 , +DMA_ADDRESS_BROKEN );if (!ahci_port->cmd_slot) { ret = -ENOMEM ; goto err_alloc;
@@ -321,7 +322,8 @@ static int ahci_init_port(struct ahci_port *ahci_port)/* * Second item: Received-FIS area */ - ahci_port->rx_fis = (unsigned long )dma_alloc_coherent (AHCI_RX_FIS_SZ ); + ahci_port->rx_fis = (unsigned long )dma_alloc_coherent (AHCI_RX_FIS_SZ , +DMA_ADDRESS_BROKEN );if (!ahci_port->rx_fis) { ret = -ENOMEM ; goto err_alloc1;
@@ -331,7 +333,8 @@ static int ahci_init_port(struct ahci_port *ahci_port)* Third item: data area for storing a single command * and its scatter-gather table */ - ahci_port->cmd_tbl =dma_alloc_coherent (AHCI_CMD_TBL_SZ ); + ahci_port->cmd_tbl =dma_alloc_coherent (AHCI_CMD_TBL_SZ , +DMA_ADDRESS_BROKEN );if (!ahci_port->cmd_tbl) { ret = -ENOMEM ; goto err_alloc2;
@@ -429,11 +432,11 @@ static int ahci_init_port(struct ahci_port *ahci_port) ret = -ENODEV ; err_init: -dma_free_coherent (ahci_port->cmd_tbl,AHCI_CMD_TBL_SZ ); +dma_free_coherent (ahci_port->cmd_tbl,0 ,AHCI_CMD_TBL_SZ ); err_alloc2: -dma_free_coherent ((void *)ahci_port->rx_fis,AHCI_RX_FIS_SZ ); +dma_free_coherent ((void *)ahci_port->rx_fis,0 ,AHCI_RX_FIS_SZ ); err_alloc1: -dma_free_coherent (ahci_port->cmd_slot,AHCI_CMD_SLOT_SZ *32 ); +dma_free_coherent (ahci_port->cmd_slot,0 ,AHCI_CMD_SLOT_SZ *32 ); err_alloc:return ret; }
drivers/dma/apbh_dma.c +2 -1
@@ -380,7 +380,8 @@ struct mxs_dma_desc *mxs_dma_desc_alloc(void) {struct mxs_dma_desc *pdesc; - pdesc =dma_alloc_coherent (sizeof (struct mxs_dma_desc )); + pdesc =dma_alloc_coherent (sizeof (struct mxs_dma_desc ), +DMA_ADDRESS_BROKEN );if (pdesc ==NULL )return NULL ;
drivers/mci/dw_mmc.c +2 -1
@@ -564,7 +564,8 @@ static int dw_mmc_probe(struct device_d *dev)/* divider is 0 based in pdata and 1 based in our private struct */ host->ciu_div++; - host->idmac =dma_alloc_coherent (sizeof (*host->idmac) *DW_MMC_NUM_IDMACS ); + host->idmac =dma_alloc_coherent (sizeof (*host->idmac) *DW_MMC_NUM_IDMACS , +DMA_ADDRESS_BROKEN ); host->mci.send_cmd = dwmci_cmd; host->mci.set_ios = dwmci_set_ios;
drivers/mtd/nand/nand_mxs.c +3 -2
@@ -1141,7 +1141,7 @@ int mxs_nand_alloc_buffers(struct mxs_nand_info *nand_info)const int size =NAND_MAX_PAGESIZE +NAND_MAX_OOBSIZE ;/* DMA buffers */ - buf =dma_alloc_coherent (size); + buf =dma_alloc_coherent (size,DMA_ADDRESS_BROKEN );if (!buf) {printf ("MXS NAND: Error allocating DMA buffers\n" );return -ENOMEM ;
@@ -1153,7 +1153,8 @@ int mxs_nand_alloc_buffers(struct mxs_nand_info *nand_info) nand_info->oob_buf = buf +NAND_MAX_PAGESIZE ;/* Command buffers */ - nand_info->cmd_buf =dma_alloc_coherent (MXS_NAND_COMMAND_BUFFER_SIZE ); + nand_info->cmd_buf =dma_alloc_coherent (MXS_NAND_COMMAND_BUFFER_SIZE , +DMA_ADDRESS_BROKEN );if (!nand_info->cmd_buf) {free (buf);printf ("MXS NAND: Error allocating command buffers\n" );
drivers/net/arc_emac.c +4 -2
@@ -430,8 +430,10 @@ static int arc_emac_probe(struct device_d *dev) miibus->parent = dev;/* allocate rx/tx descriptors */ - priv->rxbd =dma_alloc_coherent (RX_BD_NUM *sizeof (struct arc_emac_bd )); - priv->txbd =dma_alloc_coherent (TX_BD_NUM *sizeof (struct arc_emac_bd )); + priv->rxbd =dma_alloc_coherent (RX_BD_NUM *sizeof (struct arc_emac_bd ), +DMA_ADDRESS_BROKEN ); + priv->txbd =dma_alloc_coherent (TX_BD_NUM *sizeof (struct arc_emac_bd ), +DMA_ADDRESS_BROKEN ); priv->rxbuf =dma_alloc (RX_BD_NUM *PKTSIZE );/* Set poll rate so that it polls every 1 ms */
drivers/net/at91_ether.c +4 -2
@@ -320,8 +320,10 @@ static int at91_ether_probe(struct device_d *dev) edev->halt = at91_ether_halt; edev->get_ethaddr = at91_ether_get_ethaddr; edev->set_ethaddr = at91_ether_set_ethaddr; - ether_dev->rbf_framebuf =dma_alloc_coherent (MAX_RX_DESCR *MAX_RBUFF_SZ ); - ether_dev->rbfdt =dma_alloc_coherent (sizeof (struct rbf_t ) *MAX_RX_DESCR ); + ether_dev->rbf_framebuf =dma_alloc_coherent (MAX_RX_DESCR *MAX_RBUFF_SZ , +DMA_ADDRESS_BROKEN ); + ether_dev->rbfdt =dma_alloc_coherent (sizeof (struct rbf_t ) *MAX_RX_DESCR , +DMA_ADDRESS_BROKEN ); ether_dev->phy_addr = pdata->phy_addr; miibus->read = at91_ether_mii_read;
drivers/net/designware.c +4 -2
@@ -448,9 +448,11 @@ static int dwc_ether_probe(struct device_d *dev)dwc_version (dev,readl (&priv->mac_regs_p->version)); priv->dma_regs_p = base +DW_DMA_BASE_OFFSET ; priv->tx_mac_descrtable =dma_alloc_coherent ( -CONFIG_TX_DESCR_NUM *sizeof (struct dmamacdescr )); +CONFIG_TX_DESCR_NUM *sizeof (struct dmamacdescr ), +DMA_ADDRESS_BROKEN ); priv->rx_mac_descrtable =dma_alloc_coherent ( -CONFIG_RX_DESCR_NUM *sizeof (struct dmamacdescr )); +CONFIG_RX_DESCR_NUM *sizeof (struct dmamacdescr ), +DMA_ADDRESS_BROKEN ); priv->txbuffs =dma_alloc (TX_TOTAL_BUFSIZE ); priv->rxbuffs =dma_alloc (RX_TOTAL_BUFSIZE );
drivers/net/fec_imx.c +2 -2
@@ -600,7 +600,7 @@ static int fec_alloc_receive_packets(struct fec_priv *fec, int count, int size)int i;/* reserve data memory and consider alignment */ - p =dma_alloc_coherent (size * count); + p =dma_alloc_coherent (size * count,DMA_ADDRESS_BROKEN );if (!p)return -ENOMEM ;
@@ -698,7 +698,7 @@ static int fec_probe(struct device_d *dev)* Datasheet forces the startaddress of each chain is 16 byte aligned */ base =dma_alloc_coherent ((2 +FEC_RBD_NUM ) * -sizeof (struct buffer_descriptor )); +sizeof (struct buffer_descriptor ),DMA_ADDRESS_BROKEN ); fec->rbd_base = base; base +=FEC_RBD_NUM *sizeof (struct buffer_descriptor ); fec->tbd_base = base;
drivers/net/macb.c +6 -4
@@ -597,7 +597,8 @@ static void macb_init_rx_buffer_size(struct macb_device *bp, size_t size) bp->rx_buffer_size =roundup (bp->rx_buffer_size,RX_BUFFER_MULTIPLE ); } - bp->rx_buffer =dma_alloc_coherent (bp->rx_buffer_size * bp->rx_ring_size); + bp->rx_buffer =dma_alloc_coherent (bp->rx_buffer_size * bp->rx_ring_size, +DMA_ADDRESS_BROKEN ); } dev_dbg(bp->dev, "[%d] rx_buffer_size [%d]\n",
@@ -667,9 +668,10 @@ static int macb_probe(struct device_d *dev) edev->recv = macb_recv;macb_init_rx_buffer_size (macb,PKTSIZE ); - macb->rx_buffer =dma_alloc_coherent (macb->rx_buffer_size * macb->rx_ring_size); - macb->rx_ring =dma_alloc_coherent (RX_RING_BYTES (macb)); - macb->tx_ring =dma_alloc_coherent (TX_RING_BYTES ); + macb->rx_buffer =dma_alloc_coherent (macb->rx_buffer_size * macb->rx_ring_size, +DMA_ADDRESS_BROKEN ); + macb->rx_ring =dma_alloc_coherent (RX_RING_BYTES (macb),DMA_ADDRESS_BROKEN ); + macb->tx_ring =dma_alloc_coherent (TX_RING_BYTES ,DMA_ADDRESS_BROKEN );macb_reset_hw (macb); ncfgr =macb_mdc_clk_div (macb);
drivers/net/mvneta.c +4 -2
@@ -590,9 +590,11 @@ void mvneta_setup_tx_rx(struct mvneta_port *priv)u32 val;/* Allocate descriptors and buffers */ - priv->txdesc =dma_alloc_coherent (ALIGN (sizeof (*priv->txdesc),32 )); + priv->txdesc =dma_alloc_coherent (ALIGN (sizeof (*priv->txdesc),32 ), +DMA_ADDRESS_BROKEN ); priv->rxdesc =dma_alloc_coherent (RX_RING_SIZE * -ALIGN (sizeof (*priv->rxdesc),32 )); +ALIGN (sizeof (*priv->rxdesc),32 ), +DMA_ADDRESS_BROKEN ); priv->rxbuf =dma_alloc (RX_RING_SIZE *ALIGN (PKTSIZE ,8 ));mvneta_init_rx_ring (priv);
drivers/net/orion-gbe.c +4 -2
@@ -419,9 +419,11 @@ static int port_probe(struct device_d *parent, struct port_priv *port)return PTR_ERR (port->regs);/* allocate rx/tx descriptors and buffers */ - port->txdesc =dma_alloc_coherent (ALIGN (sizeof (*port->txdesc),16 )); + port->txdesc =dma_alloc_coherent (ALIGN (sizeof (*port->txdesc),16 ), +DMA_ADDRESS_BROKEN ); port->rxdesc =dma_alloc_coherent (RX_RING_SIZE * -ALIGN (sizeof (*port->rxdesc),16 )); +ALIGN (sizeof (*port->rxdesc),16 ), +DMA_ADDRESS_BROKEN ); port->rxbuf =dma_alloc (RX_RING_SIZE *ALIGN (PKTSIZE ,8 ));port_stop (port);
drivers/net/rtl8169.c +2 -2
@@ -228,10 +228,10 @@ static void rtl8169_init_ring(struct rtl8169_priv *priv) priv->cur_rx = priv->cur_tx =0 ; priv->tx_desc =dma_alloc_coherent (NUM_TX_DESC * -sizeof (struct bufdesc )); +sizeof (struct bufdesc ),DMA_ADDRESS_BROKEN ); priv->tx_buf =malloc (NUM_TX_DESC *PKT_BUF_SIZE ); priv->rx_desc =dma_alloc_coherent (NUM_RX_DESC * -sizeof (struct bufdesc )); +sizeof (struct bufdesc ),DMA_ADDRESS_BROKEN ); 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 );
drivers/net/xgmac.c +5 -3
@@ -698,9 +698,11 @@ static int hb_xgmac_probe(struct device_d *dev) priv->dev = dev; priv->base = base; - priv->rxbuffer =dma_alloc_coherent (RX_BUF_SZ ); - priv->rx_chain =dma_alloc_coherent (RX_NUM_DESC *sizeof (struct xgmac_dma_desc )); - priv->tx_chain =dma_alloc_coherent (TX_NUM_DESC *sizeof (struct xgmac_dma_desc )); + priv->rxbuffer =dma_alloc_coherent (RX_BUF_SZ ,DMA_ADDRESS_BROKEN ); + priv->rx_chain =dma_alloc_coherent (RX_NUM_DESC *sizeof (struct xgmac_dma_desc ), +DMA_ADDRESS_BROKEN ); + priv->tx_chain =dma_alloc_coherent (TX_NUM_DESC *sizeof (struct xgmac_dma_desc ), +DMA_ADDRESS_BROKEN ); edev = &priv->edev; edev->priv = priv;
drivers/usb/gadget/fsl_udc.c +4 -3
@@ -562,7 +562,7 @@ static void done(struct fsl_ep *ep, struct fsl_req *req, int status)if (j != req->dtd_count -1 ) { next_td = curr_td->next_td_virt; } -dma_free_coherent (curr_td,sizeof (struct ep_td_struct )); +dma_free_coherent (curr_td,0 ,sizeof (struct ep_td_struct )); } dma_inv_range((unsigned long)req->req.buf,
@@ -1135,7 +1135,8 @@ static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req, unsigned *length, *length =min (req->req.length - req->req.actual, (unsigned )EP_MAX_LENGTH_TRANSFER ); - dtd =dma_alloc_coherent (sizeof (struct ep_td_struct )); + dtd =dma_alloc_coherent (sizeof (struct ep_td_struct ), +DMA_ADDRESS_BROKEN );if (dtd ==NULL )return dtd;
@@ -2058,7 +2059,7 @@ static int struct_udc_setup(struct fsl_udc *udc, size &= ~(QH_ALIGNMENT -1 ); } - udc->ep_qh =dma_alloc_coherent (size); + udc->ep_qh =dma_alloc_coherent (size,DMA_ADDRESS_BROKEN );if (!udc->ep_qh) {ERR ("malloc QHs for udc failed\n" );kfree (udc->eps);
drivers/usb/host/ehci-hcd.c +4 -2
@@ -890,8 +890,10 @@ int ehci_register(struct device_d *dev, struct ehci_data *data) ehci->init = data->init; ehci->post_init = data->post_init; - ehci->qh_list =dma_alloc_coherent (sizeof (struct QH ) *NUM_TD ); - ehci->td =dma_alloc_coherent (sizeof (struct qTD ) *NUM_TD ); + ehci->qh_list =dma_alloc_coherent (sizeof (struct QH ) *NUM_TD , +DMA_ADDRESS_BROKEN ); + ehci->td =dma_alloc_coherent (sizeof (struct qTD ) *NUM_TD , +DMA_ADDRESS_BROKEN ); host->hw_dev = dev; host->init = ehci_init;
drivers/usb/host/ohci-hcd.c +6 -3
@@ -1758,7 +1758,8 @@ static int ohci_init(struct usb_host *host)info ("%s\n" , __func__); - ohci->ptd =dma_alloc_coherent (sizeof (struct td ) *NUM_TD ); + ohci->ptd =dma_alloc_coherent (sizeof (struct td ) *NUM_TD , +DMA_ADDRESS_BROKEN );if (!ohci->ptd)return -ENOMEM ;memset (ohci->ptd,0 ,sizeof (struct td ) *NUM_TD );
@@ -1801,11 +1802,13 @@ static int ohci_probe(struct device_d *dev) host->submit_control_msg = submit_control_msg; host->submit_bulk_msg = submit_bulk_msg; - ohci->hcca =dma_alloc_coherent (sizeof (*ohci->hcca)); + ohci->hcca =dma_alloc_coherent (sizeof (*ohci->hcca), +DMA_ADDRESS_BROKEN );if (!ohci->hcca)return -ENOMEM ; - ohci->ohci_dev =dma_alloc_coherent (sizeof (*ohci->ohci_dev)); + ohci->ohci_dev =dma_alloc_coherent (sizeof (*ohci->ohci_dev), +DMA_ADDRESS_BROKEN );if (!ohci->ohci_dev)return -ENOMEM ;memset (ohci->ohci_dev,0 ,sizeof (*ohci->ohci_dev));
drivers/usb/host/xhci-hcd.c +3 -3
@@ -444,7 +444,7 @@ static struct xhci_virtual_device *xhci_alloc_virtdev(struct xhci_hcd *xhci, sz_ictx =ALIGN (sz_ctx +HCC_CTX_SIZE (xhci->hcc_params),64 ); vdev->dma_size = sz_ictx + sz_dctx; - p = vdev->dma =dma_alloc_coherent (vdev->dma_size); + p = vdev->dma =dma_alloc_coherent (vdev->dma_size,DMA_ADDRESS_BROKEN );memset (vdev->dma,0 , vdev->dma_size); vdev->out_ctx = p; p += sz_dctx;
@@ -463,7 +463,7 @@ static void xhci_free_virtdev(struct xhci_virtual_device *vdev)xhci_put_endpoint_ring (xhci, vdev->ep[i]);list_del (&vdev->list); -dma_free_coherent (vdev->dma, vdev->dma_size); +dma_free_coherent (vdev->dma,0 , vdev->dma_size);free (vdev); }
@@ -1203,7 +1203,7 @@ static void xhci_dma_alloc(struct xhci_hcd *xhci) num_ep =max (MAX_EP_RINGS ,MIN_EP_RINGS + num_ep); xhci->dma_size += num_ep * sz_ep; - p = xhci->dma =dma_alloc_coherent (xhci->dma_size); + p = xhci->dma =dma_alloc_coherent (xhci->dma_size,DMA_ADDRESS_BROKEN );memset (xhci->dma,0 , xhci->dma_size); xhci->sp = p; p += sz_sp;
drivers/video/atmel_lcdfb_core.c +3 -2
@@ -200,7 +200,7 @@ static int atmel_lcdfb_alloc_video_memory(struct atmel_lcdfb_info *sinfo) * ((info->bits_per_pixel + 7) / 8)); smem_len =max (smem_len, sinfo->smem_len); - info->screen_base =dma_alloc_coherent (smem_len); + info->screen_base =dma_alloc_coherent (smem_len,DMA_ADDRESS_BROKEN );if (!info->screen_base)return -ENOMEM ;
@@ -289,7 +289,8 @@ int atmel_lcdc_register(struct device_d *dev, struct atmel_lcdfb_devdata *data)atmel_lcdfb_start_clock (sinfo);if (data->dma_desc_size) - sinfo->dma_desc =dma_alloc_coherent (data->dma_desc_size); + sinfo->dma_desc =dma_alloc_coherent (data->dma_desc_size, +DMA_ADDRESS_BROKEN ); ret =register_framebuffer (info);if (ret !=0 ) {
drivers/video/imx-ipu-fb.c +2 -1
@@ -1030,7 +1030,8 @@ static int imxfb_probe(struct device_d *dev) fbi->info.screen_size, mmu_get_pte_uncached_flags()); }else { - fbi->info.screen_base =dma_alloc_coherent (fbi->info.screen_size); + fbi->info.screen_base =dma_alloc_coherent (fbi->info.screen_size, +DMA_ADDRESS_BROKEN );if (!fbi->info.screen_base)return -ENOMEM ; }
drivers/video/imx-ipu-v3/ipufb.c +2 -1
@@ -203,7 +203,8 @@ static int ipufb_activate_var(struct fb_info *info) struct ipufb_info *fbi = container_of(info, struct ipufb_info, info); info->line_length = info->xres * (info->bits_per_pixel >>3 ); - fbi->info.screen_base =dma_alloc_coherent (info->line_length * info->yres); + fbi->info.screen_base =dma_alloc_coherent (info->line_length * info->yres, +DMA_ADDRESS_BROKEN );if (!fbi->info.screen_base)return -ENOMEM ;
drivers/video/omap.c +3 -3
@@ -126,7 +126,7 @@ static void omapfb_disable(struct fb_info *info)/* free frame buffer; but only when screen is not * preallocated */ if (info->screen_base) -dma_free_coherent (info->screen_base, fbi->dma_size); +dma_free_coherent (info->screen_base,0 , fbi->dma_size); } info->screen_base =NULL ;
@@ -270,13 +270,13 @@ static int omapfb_activate_var(struct fb_info *info)/*Free old screen buf*/ if (!fbi->prealloc_screen.addr && info->screen_base) -dma_free_coherent (info->screen_base, fbi->dma_size); +dma_free_coherent (info->screen_base,0 , fbi->dma_size); fbi->dma_size =PAGE_ALIGN (size);if (!fbi->prealloc_screen.addr) {/* case 1: no preallocated screen */ - info->screen_base =dma_alloc_coherent (size); + info->screen_base =dma_alloc_coherent (size,DMA_ADDRESS_BROKEN ); }else if (fbi->prealloc_screen.size < fbi->dma_size) {/* case 2: preallocated screen, but too small */ dev_err(fbi->dev,
drivers/video/pxa.c +4 -3
@@ -522,11 +522,12 @@ static int pxafb_probe(struct device_d *dev)else fbi->info.screen_base =PTR_ALIGN (dma_alloc_coherent (info->xres * info->yres * - (info->bits_per_pixel >>3 ) +PAGE_SIZE ), + (info->bits_per_pixel >>3 ) +PAGE_SIZE , +DMA_ADDRESS_BROKEN ),PAGE_SIZE ); - fbi->dma_buff =PTR_ALIGN (dma_alloc_coherent (sizeof (struct pxafb_dma_buff ) +16 ), -16 ); + fbi->dma_buff =PTR_ALIGN (dma_alloc_coherent (sizeof (struct pxafb_dma_buff ) +16 , +DMA_ADDRESS_BROKEN ),16 );pxafb_activate_var (fbi);
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 7/27 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 | 25 ++++++++++++++++++++++++- arch/arm/include/asm/mmu.h | 26 -------------------------- 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 | 1 + drivers/video/imx-ipu-v3/ipu-common.c | 1 - drivers/video/imx-ipu-v3/ipufb.c | 2 +- drivers/video/omap.c | 1 + drivers/video/pxa.c | 2 +- include/dma.h | 2 ++ 32 files changed, 52 insertions(+), 38 deletions(-)
arch/arm/include/asm/dma.h +24 -1
@@ -5,4 +5,27 @@* */ -#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,dma_addr_t *dma_handle) +{ +void *ret =xmemalign (4096 , size); +if (dma_handle) + *dma_handle = (dma_addr_t )ret; + +return ret; +} + +static inline void dma_free_coherent (void *mem,dma_addr_t dma_handle, +size_t size) +{ +free (mem); +} +#endif
arch/arm/include/asm/mmu.h +0 -26
@@ -11,8 +11,6 @@#define PMD_SECT_DEF_UNCACHED (PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | PMD_TYPE_SECT)#define PMD_SECT_DEF_CACHED (PMD_SECT_WB | PMD_SECT_DEF_UNCACHED) -#define DMA_ADDRESS_BROKEN NULL -struct arm_memory ;static inline void mmu_enable (void )
@@ -28,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,dma_addr_t *dma_handle); -void dma_free_coherent (void *mem,dma_addr_t dma_handle,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 );
@@ -47,21 +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,dma_addr_t *dma_handle) -{ -void *ret =xmemalign (4096 , size); -if (dma_handle) - *dma_handle = (dma_addr_t )ret; - -return ret; -} - -static inline void dma_free_coherent (void *mem,dma_addr_t dma_handle, -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 -0
@@ -18,6 +18,7 @@*/ #include <common.h> +#include <dma.h> #include <init.h> #include <io.h> #include <mach/imx35-regs.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 -0
@@ -19,6 +19,7 @@*/ #include <driver.h> +#include <dma.h> #include <fb.h> #include <errno.h> #include <xfuncs.h>
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 */
include/dma.h +2 -0
@@ -14,6 +14,8 @@#include <dma-dir.h> #include <asm/dma.h> +#define DMA_ADDRESS_BROKEN NULL +#ifndef dma_allocstatic inline void *dma_alloc (size_t size) {
Signature · 7 lines
2.1.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 8/27 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>
@@ -434,3 +435,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
@@ -28,4 +28,14 @@ static inline void dma_free_coherent(void *mem, dma_addr_t dma_handle, {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 v2 9/27 AHCI: convert to streaming DMA ops
In reply to Lucas StachMove to the common streaming DMA ops in order to get rid of the direct usage of the ARM MMU functions for the cache maintenance.
--- 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 v2 10/27 MCI: dw-mmc: convert to streaming DMA ops
In reply to Lucas StachMove to the common streaming DMA ops in order to get rid of the direct usage of the ARM MMU functions for the cache maintenance.
--- 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 v2 11/27 MCI: imx: convert to streaming DMA ops
In reply to Lucas StachMove to the common streaming DMA ops in order to get rid of the direct usage of the ARM MMU functions for the cache maintenance.
--- 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 v2 12/27 MCI: tegra-sdmmc: convert to streaming DMA ops
In reply to Lucas StachMove to the common streaming DMA ops in order to get rid of the direct usage of the ARM MMU functions for the cache maintenance.
--- 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 v2 13/27 net: arc-emac: convert to streaming DMA ops
In reply to Lucas StachMove to the common streaming DMA ops in order to get rid of the direct usage of the ARM MMU functions for the cache maintenance.
--- 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 v2 14/27 net: cpsw: convert to streaming DMA ops
In reply to Lucas StachMove to the common streaming DMA ops in order to get rid of the direct usage of the ARM MMU functions for the cache maintenance.
--- 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
PATCH v2 15/27 net: at91_ether: convert to streaming DMA ops
In reply to Lucas StachMove to the common streaming DMA ops in order to get rid of the direct usage of the ARM MMU functions for the cache maintenance.
--- 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 v2 16/27 net: davinci_emac: convert to streaming DMA ops
In reply to Lucas StachMove to the common streaming DMA ops in order to get rid of the direct usage of the ARM MMU functions for the cache maintenance.
--- 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 v2 17/27 net: designware: convert to streaming DMA ops
In reply to Lucas StachMove to the common streaming DMA ops in order to get rid of the direct usage of the ARM MMU functions for the cache maintenance.
--- 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 v2 18/27 net: fec: convert to streaming DMA ops
In reply to Lucas StachMove to the common streaming DMA ops in order to get rid of the direct usage of the ARM MMU functions for the cache maintenance.
--- 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 v2 19/27 net: macb: convert to streaming DMA ops
In reply to Lucas StachMove to the common streaming DMA ops in order to get rid of the direct usage of the ARM MMU functions for the cache maintenance.
--- 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 v2 20/27 net: orion-gbe: convert to streaming DMA ops
In reply to Lucas StachMove to the common streaming DMA ops in order to get rid of the direct usage of the ARM MMU functions for the cache maintenance.
--- 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
PATCH v2 21/27 net: rtl8169: convert to streaming DMA ops
In reply to Lucas StachMove to the common streaming DMA ops in order to get rid of the direct usage of the ARM MMU functions for the cache maintenance.
--- 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 ),DMA_ADDRESS_BROKEN ); 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 ((void *)priv->tx_desc,0 ,NUM_TX_DESC *sizeof (struct bufdesc ));memset ((void *)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 v2 22/27 net: xgmac: convert to streaming DMA ops
In reply to Lucas StachMove to the common streaming DMA ops in order to get rid of the direct usage of the ARM MMU functions for the cache maintenance.
--- 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, buf_addr, 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 v2 23/27 usb: gadget: fsl_udc: convert to streaming DMA ops
In reply to Lucas StachMove to the common streaming DMA ops in order to get rid of the direct usage of the ARM MMU functions for the cache maintenance.
--- 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,0 ,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",
@@ -1251,8 +1251,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 v2 24/27 usb: host: ehci: convert to streaming DMA ops
In reply to Lucas StachMove to the common streaming DMA ops in order to get rid of the direct usage of the ARM MMU functions for the cache maintenance.
--- 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 v2 25/27 usb: host: ohci: convert to streaming DMA ops
In reply to Lucas StachMove to the common streaming DMA ops in order to get rid of the direct usage of the ARM MMU functions for the cache maintenance.
--- 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 v2 26/27 ARM: bcm2835: mbox: convert to streaming DMA ops
In reply to Lucas StachMove to the common streaming DMA ops in order to get rid of the direct usage of the ARM MMU functions for the cache maintenance.
--- 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 v2 27/27 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;
@@ -414,27 +428,6 @@ void dma_free_coherent(void *mem, dma_addr_t dma_handle, 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