* [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM
@ 2015-03-05 21:49 Lucas Stach
2015-03-05 21:49 ` [PATCH v2 01/27] usb: gadget: include common.h in header Lucas Stach
` (29 more replies)
0 siblings, 30 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:49 UTC (permalink / raw)
To: barebox
This series introduces to Barebox the streaming DMA ops and implements
them for the ARM architecture. This will make it a lot easier to
get common cache maintenance operations for all architectures and in
turn allows for wider reuse of driver across architectures.
I've tested this on a Tegra124 which is known to fall over in all sorts
of funny ways if cache maintenance is broken. No odd behavior spotted.
The series is bisect-clean and I've compile tested it on some defconfigs,
but please go wild and TEST. I'll take any complaints.
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
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 01/27] usb: gadget: include common.h in header
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
@ 2015-03-05 21:49 ` Lucas Stach
2015-03-05 21:49 ` [PATCH v2 02/27] NIOS2: use dma_addr_t in dma_alloc_coherent Lucas Stach
` (28 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:49 UTC (permalink / raw)
To: barebox
It is needed for container_of() and this header falls
over if we change the include order.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
include/usb/gadget.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/usb/gadget.h b/include/usb/gadget.h
index f663e98..80418a9 100644
--- a/include/usb/gadget.h
+++ b/include/usb/gadget.h
@@ -15,6 +15,7 @@
#ifndef __LINUX_USB_GADGET_H
#define __LINUX_USB_GADGET_H
+#include <common.h>
#include <malloc.h>
#include <driver.h>
#include <linux/list.h>
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 02/27] NIOS2: use dma_addr_t in dma_alloc_coherent
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
2015-03-05 21:49 ` [PATCH v2 01/27] usb: gadget: include common.h in header Lucas Stach
@ 2015-03-05 21:49 ` Lucas Stach
2015-03-05 21:49 ` [PATCH v2 03/27] MIPS: change dma_alloc/free_coherent to common prototypes Lucas Stach
` (27 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:49 UTC (permalink / raw)
To: barebox
This allows to consolidate the prototype of this function across
architectures. Also guard against calles that pass in NULL as the
dma handle pointer.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
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(-)
diff --git a/arch/nios2/include/asm/dma-mapping.h b/arch/nios2/include/asm/dma-mapping.h
index 620c207..5ecc1ed 100644
--- a/arch/nios2/include/asm/dma-mapping.h
+++ b/arch/nios2/include/asm/dma-mapping.h
@@ -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
diff --git a/arch/nios2/include/asm/types.h b/arch/nios2/include/asm/types.h
index 1f613d1..21c3415 100644
--- a/arch/nios2/include/asm/types.h
+++ b/arch/nios2/include/asm/types.h
@@ -3,5 +3,7 @@
#include <asm/int-ll64.h>
+typedef u32 dma_addr_t;
+
#endif
diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c
index ecbb9f8..3c49c09 100644
--- a/drivers/net/altera_tse.c
+++ b/drivers/net/altera_tse.c
@@ -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) {
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 03/27] MIPS: change dma_alloc/free_coherent to common prototypes
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
2015-03-05 21:49 ` [PATCH v2 01/27] usb: gadget: include common.h in header Lucas Stach
2015-03-05 21:49 ` [PATCH v2 02/27] NIOS2: use dma_addr_t in dma_alloc_coherent Lucas Stach
@ 2015-03-05 21:49 ` Lucas Stach
2015-03-05 21:49 ` [PATCH v2 04/27] ARM: change dma_alloc/free_coherent to match other architectures Lucas Stach
` (26 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:49 UTC (permalink / raw)
To: barebox
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
arch/mips/include/asm/dma-mapping.h | 6 ++++--
arch/mips/include/asm/dma.h | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/arch/mips/include/asm/dma-mapping.h b/arch/mips/include/asm/dma-mapping.h
index 555efa5..6395112 100644
--- a/arch/mips/include/asm/dma-mapping.h
+++ b/arch/mips/include/asm/dma-mapping.h
@@ -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);
}
diff --git a/arch/mips/include/asm/dma.h b/arch/mips/include/asm/dma.h
index 27d269f..30a58c7 100644
--- a/arch/mips/include/asm/dma.h
+++ b/arch/mips/include/asm/dma.h
@@ -8,6 +8,6 @@
#ifndef __ASM_DMA_H
#define __ASM_DMA_H
-/* empty */
+#include "asm/dma-mapping.h"
#endif /* __ASM_DMA_H */
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 04/27] ARM: change dma_alloc/free_coherent to match other architectures
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (2 preceding siblings ...)
2015-03-05 21:49 ` [PATCH v2 03/27] MIPS: change dma_alloc/free_coherent to common prototypes Lucas Stach
@ 2015-03-05 21:49 ` Lucas Stach
2015-03-05 21:49 ` [PATCH v2 04/27] ARM: move virt<->phys translation to io.h Lucas Stach
` (25 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:49 UTC (permalink / raw)
To: barebox
As 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.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
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(-)
diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index aaf66d4..c480e07 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -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);
diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h
index c6e425f..f01c003 100644
--- a/arch/arm/include/asm/mmu.h
+++ b/arch/arm/include/asm/mmu.h
@@ -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);
}
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 346ab98..d299ac6 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -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;
}
diff --git a/drivers/dma/apbh_dma.c b/drivers/dma/apbh_dma.c
index cd218f4..5692c50 100644
--- a/drivers/dma/apbh_dma.c
+++ b/drivers/dma/apbh_dma.c
@@ -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;
diff --git a/drivers/mci/dw_mmc.c b/drivers/mci/dw_mmc.c
index 365b60d..18fb45d 100644
--- a/drivers/mci/dw_mmc.c
+++ b/drivers/mci/dw_mmc.c
@@ -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;
diff --git a/drivers/mtd/nand/nand_mxs.c b/drivers/mtd/nand/nand_mxs.c
index 4e38e09..98fd9f2 100644
--- a/drivers/mtd/nand/nand_mxs.c
+++ b/drivers/mtd/nand/nand_mxs.c
@@ -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");
diff --git a/drivers/net/arc_emac.c b/drivers/net/arc_emac.c
index 1770506..0520649 100644
--- a/drivers/net/arc_emac.c
+++ b/drivers/net/arc_emac.c
@@ -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 */
diff --git a/drivers/net/at91_ether.c b/drivers/net/at91_ether.c
index e09ea83..20aa045 100644
--- a/drivers/net/at91_ether.c
+++ b/drivers/net/at91_ether.c
@@ -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;
diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 49ed0b1..e0e348f 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -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);
diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index c1fa151..c12b26b 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -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;
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 8e67aec..9cdb7d8 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -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);
diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 8042e90..32ba726 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -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);
diff --git a/drivers/net/orion-gbe.c b/drivers/net/orion-gbe.c
index 3fbc1df..5104f87 100644
--- a/drivers/net/orion-gbe.c
+++ b/drivers/net/orion-gbe.c
@@ -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);
diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c
index f8a6500..bab20e8 100644
--- a/drivers/net/rtl8169.c
+++ b/drivers/net/rtl8169.c
@@ -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);
diff --git a/drivers/net/xgmac.c b/drivers/net/xgmac.c
index cc22d0e..240684e 100644
--- a/drivers/net/xgmac.c
+++ b/drivers/net/xgmac.c
@@ -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;
diff --git a/drivers/usb/gadget/fsl_udc.c b/drivers/usb/gadget/fsl_udc.c
index d067f03..ed7c318 100644
--- a/drivers/usb/gadget/fsl_udc.c
+++ b/drivers/usb/gadget/fsl_udc.c
@@ -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);
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 7b91327..c033842 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -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;
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 622f5c3..bbd0bd6 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -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));
diff --git a/drivers/usb/host/xhci-hcd.c b/drivers/usb/host/xhci-hcd.c
index 9253419..0a4601c 100644
--- a/drivers/usb/host/xhci-hcd.c
+++ b/drivers/usb/host/xhci-hcd.c
@@ -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;
diff --git a/drivers/video/atmel_lcdfb_core.c b/drivers/video/atmel_lcdfb_core.c
index 420ccbe..a0a822c 100644
--- a/drivers/video/atmel_lcdfb_core.c
+++ b/drivers/video/atmel_lcdfb_core.c
@@ -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) {
diff --git a/drivers/video/imx-ipu-fb.c b/drivers/video/imx-ipu-fb.c
index a69df50..eb913b1 100644
--- a/drivers/video/imx-ipu-fb.c
+++ b/drivers/video/imx-ipu-fb.c
@@ -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;
}
diff --git a/drivers/video/imx-ipu-v3/ipufb.c b/drivers/video/imx-ipu-v3/ipufb.c
index 14a099e..d9c81b2 100644
--- a/drivers/video/imx-ipu-v3/ipufb.c
+++ b/drivers/video/imx-ipu-v3/ipufb.c
@@ -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;
diff --git a/drivers/video/omap.c b/drivers/video/omap.c
index bd66c92..91f9e24 100644
--- a/drivers/video/omap.c
+++ b/drivers/video/omap.c
@@ -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,
diff --git a/drivers/video/pxa.c b/drivers/video/pxa.c
index d6d11ae..61ce0a5 100644
--- a/drivers/video/pxa.c
+++ b/drivers/video/pxa.c
@@ -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);
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 04/27] ARM: move virt<->phys translation to io.h
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (3 preceding siblings ...)
2015-03-05 21:49 ` [PATCH v2 04/27] ARM: change dma_alloc/free_coherent to match other architectures Lucas Stach
@ 2015-03-05 21:49 ` Lucas Stach
2015-03-05 21:49 ` [PATCH v2 05/27] " Lucas Stach
` (24 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:49 UTC (permalink / raw)
To: barebox
That's the place where Linux has them and other architectures would
implement this.
This will help in phasing out the direct usage of the ARM asm/mmu.h
header.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
arch/arm/include/asm/io.h | 15 +++++++++++++++
arch/arm/include/asm/mmu.h | 12 ------------
2 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index 850a99c..eebf093 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -69,4 +69,19 @@ extern void memset_io(volatile void __iomem *, int, size_t);
#define setbits_8(addr, set) setbits(8, addr, set)
#define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
+#ifdef CONFIG_MMU
+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 */
diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h
index c6e425f..3d87588 100644
--- a/arch/arm/include/asm/mmu.h
+++ b/arch/arm/include/asm/mmu.h
@@ -39,8 +39,6 @@ void dma_free_coherent(void *mem, size_t size);
void dma_clean_range(unsigned long, unsigned long);
void dma_flush_range(unsigned long, unsigned long);
void dma_inv_range(unsigned long, unsigned long);
-unsigned long virt_to_phys(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)
{
}
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 05/27] ARM: move virt<->phys translation to io.h
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (4 preceding siblings ...)
2015-03-05 21:49 ` [PATCH v2 04/27] ARM: move virt<->phys translation to io.h Lucas Stach
@ 2015-03-05 21:49 ` Lucas Stach
2015-03-05 21:49 ` [PATCH v2 05/27] dma: add streaming DMA ops Lucas Stach
` (23 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:49 UTC (permalink / raw)
To: barebox
That's the place where Linux has them and other architectures would
implement this.
This will help in phasing out the direct usage of the ARM asm/mmu.h
header.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
arch/arm/include/asm/io.h | 15 +++++++++++++++
arch/arm/include/asm/mmu.h | 12 ------------
2 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index 850a99c..eebf093 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -69,4 +69,19 @@ extern void memset_io(volatile void __iomem *, int, size_t);
#define setbits_8(addr, set) setbits(8, addr, set)
#define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
+#ifdef CONFIG_MMU
+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 */
diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h
index f01c003..d0a644b 100644
--- a/arch/arm/include/asm/mmu.h
+++ b/arch/arm/include/asm/mmu.h
@@ -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)
{
}
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 05/27] dma: add streaming DMA ops
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (5 preceding siblings ...)
2015-03-05 21:49 ` [PATCH v2 05/27] " Lucas Stach
@ 2015-03-05 21:49 ` Lucas Stach
2015-03-05 21:49 ` [PATCH v2 06/27] ARM: change dma_alloc/free_coherent to match other architectures Lucas Stach
` (22 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:49 UTC (permalink / raw)
To: barebox
This will allow us to implement cache maintenance in a platform
agnostic way.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
include/dma-dir.h | 6 ++++++
include/dma.h | 11 +++++++++++
2 files changed, 17 insertions(+)
create mode 100644 include/dma-dir.h
diff --git a/include/dma-dir.h b/include/dma-dir.h
new file mode 100644
index 0000000..ba107f1
--- /dev/null
+++ b/include/dma-dir.h
@@ -0,0 +1,6 @@
+enum dma_data_direction {
+ DMA_BIDIRECTIONAL = 0,
+ DMA_TO_DEVICE = 1,
+ DMA_FROM_DEVICE = 2,
+ DMA_NONE = 3,
+};
diff --git a/include/dma.h b/include/dma.h
index 899f831..fb75eec 100644
--- a/include/dma.h
+++ b/include/dma.h
@@ -11,6 +11,7 @@
#include <malloc.h>
#include <xfuncs.h>
+#include <dma-dir.h>
#include <asm/dma.h>
#ifndef dma_alloc
@@ -27,4 +28,14 @@ static inline void dma_free(void *mem)
}
#endif
+/* streaming DMA - implement the below calls to support HAS_DMA */
+void dma_sync_single_for_cpu(unsigned long address, size_t size,
+ enum dma_data_direction dir);
+
+void dma_sync_single_for_device(unsigned long address, size_t size,
+ enum dma_data_direction dir);
+
+void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle);
+void dma_free_coherent(void *mem, dma_addr_t dma_handle, size_t size);
+
#endif /* __DMA_H */
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 06/27] ARM: change dma_alloc/free_coherent to match other architectures
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (6 preceding siblings ...)
2015-03-05 21:49 ` [PATCH v2 05/27] dma: add streaming DMA ops Lucas Stach
@ 2015-03-05 21:49 ` Lucas Stach
2015-03-05 21:50 ` [PATCH v2 06/27] dma: add streaming DMA ops Lucas Stach
` (21 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:49 UTC (permalink / raw)
To: barebox
As 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.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
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(-)
diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index aaf66d4..c480e07 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -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);
diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h
index 3d87588..d0a644b 100644
--- a/arch/arm/include/asm/mmu.h
+++ b/arch/arm/include/asm/mmu.h
@@ -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);
}
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 346ab98..d299ac6 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -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;
}
diff --git a/drivers/dma/apbh_dma.c b/drivers/dma/apbh_dma.c
index cd218f4..5692c50 100644
--- a/drivers/dma/apbh_dma.c
+++ b/drivers/dma/apbh_dma.c
@@ -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;
diff --git a/drivers/mci/dw_mmc.c b/drivers/mci/dw_mmc.c
index 365b60d..18fb45d 100644
--- a/drivers/mci/dw_mmc.c
+++ b/drivers/mci/dw_mmc.c
@@ -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;
diff --git a/drivers/mtd/nand/nand_mxs.c b/drivers/mtd/nand/nand_mxs.c
index 4e38e09..98fd9f2 100644
--- a/drivers/mtd/nand/nand_mxs.c
+++ b/drivers/mtd/nand/nand_mxs.c
@@ -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");
diff --git a/drivers/net/arc_emac.c b/drivers/net/arc_emac.c
index 1770506..0520649 100644
--- a/drivers/net/arc_emac.c
+++ b/drivers/net/arc_emac.c
@@ -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 */
diff --git a/drivers/net/at91_ether.c b/drivers/net/at91_ether.c
index e09ea83..20aa045 100644
--- a/drivers/net/at91_ether.c
+++ b/drivers/net/at91_ether.c
@@ -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;
diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 49ed0b1..e0e348f 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -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);
diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index c1fa151..c12b26b 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -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;
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 8e67aec..9cdb7d8 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -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);
diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 8042e90..32ba726 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -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);
diff --git a/drivers/net/orion-gbe.c b/drivers/net/orion-gbe.c
index 3fbc1df..5104f87 100644
--- a/drivers/net/orion-gbe.c
+++ b/drivers/net/orion-gbe.c
@@ -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);
diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c
index f8a6500..bab20e8 100644
--- a/drivers/net/rtl8169.c
+++ b/drivers/net/rtl8169.c
@@ -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);
diff --git a/drivers/net/xgmac.c b/drivers/net/xgmac.c
index cc22d0e..240684e 100644
--- a/drivers/net/xgmac.c
+++ b/drivers/net/xgmac.c
@@ -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;
diff --git a/drivers/usb/gadget/fsl_udc.c b/drivers/usb/gadget/fsl_udc.c
index d067f03..ed7c318 100644
--- a/drivers/usb/gadget/fsl_udc.c
+++ b/drivers/usb/gadget/fsl_udc.c
@@ -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);
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 7b91327..c033842 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -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;
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 622f5c3..bbd0bd6 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -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));
diff --git a/drivers/usb/host/xhci-hcd.c b/drivers/usb/host/xhci-hcd.c
index 9253419..0a4601c 100644
--- a/drivers/usb/host/xhci-hcd.c
+++ b/drivers/usb/host/xhci-hcd.c
@@ -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;
diff --git a/drivers/video/atmel_lcdfb_core.c b/drivers/video/atmel_lcdfb_core.c
index 420ccbe..a0a822c 100644
--- a/drivers/video/atmel_lcdfb_core.c
+++ b/drivers/video/atmel_lcdfb_core.c
@@ -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) {
diff --git a/drivers/video/imx-ipu-fb.c b/drivers/video/imx-ipu-fb.c
index a69df50..eb913b1 100644
--- a/drivers/video/imx-ipu-fb.c
+++ b/drivers/video/imx-ipu-fb.c
@@ -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;
}
diff --git a/drivers/video/imx-ipu-v3/ipufb.c b/drivers/video/imx-ipu-v3/ipufb.c
index 14a099e..d9c81b2 100644
--- a/drivers/video/imx-ipu-v3/ipufb.c
+++ b/drivers/video/imx-ipu-v3/ipufb.c
@@ -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;
diff --git a/drivers/video/omap.c b/drivers/video/omap.c
index bd66c92..91f9e24 100644
--- a/drivers/video/omap.c
+++ b/drivers/video/omap.c
@@ -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,
diff --git a/drivers/video/pxa.c b/drivers/video/pxa.c
index d6d11ae..61ce0a5 100644
--- a/drivers/video/pxa.c
+++ b/drivers/video/pxa.c
@@ -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);
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 06/27] dma: add streaming DMA ops
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (7 preceding siblings ...)
2015-03-05 21:49 ` [PATCH v2 06/27] ARM: change dma_alloc/free_coherent to match other architectures Lucas Stach
@ 2015-03-05 21:50 ` Lucas Stach
2015-03-05 21:50 ` [PATCH v2 07/27] ARM: move DMA alloc functions to dma.h Lucas Stach
` (20 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:50 UTC (permalink / raw)
To: barebox
This will allow us to implement cache maintenance in a platform
agnostic way.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
include/dma-dir.h | 6 ++++++
include/dma.h | 11 +++++++++++
2 files changed, 17 insertions(+)
create mode 100644 include/dma-dir.h
diff --git a/include/dma-dir.h b/include/dma-dir.h
new file mode 100644
index 0000000..ba107f1
--- /dev/null
+++ b/include/dma-dir.h
@@ -0,0 +1,6 @@
+enum dma_data_direction {
+ DMA_BIDIRECTIONAL = 0,
+ DMA_TO_DEVICE = 1,
+ DMA_FROM_DEVICE = 2,
+ DMA_NONE = 3,
+};
diff --git a/include/dma.h b/include/dma.h
index 899f831..fb75eec 100644
--- a/include/dma.h
+++ b/include/dma.h
@@ -11,6 +11,7 @@
#include <malloc.h>
#include <xfuncs.h>
+#include <dma-dir.h>
#include <asm/dma.h>
#ifndef dma_alloc
@@ -27,4 +28,14 @@ static inline void dma_free(void *mem)
}
#endif
+/* streaming DMA - implement the below calls to support HAS_DMA */
+void dma_sync_single_for_cpu(unsigned long address, size_t size,
+ enum dma_data_direction dir);
+
+void dma_sync_single_for_device(unsigned long address, size_t size,
+ enum dma_data_direction dir);
+
+void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle);
+void dma_free_coherent(void *mem, dma_addr_t dma_handle, size_t size);
+
#endif /* __DMA_H */
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 07/27] ARM: move DMA alloc functions to dma.h
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (8 preceding siblings ...)
2015-03-05 21:50 ` [PATCH v2 06/27] dma: add streaming DMA ops Lucas Stach
@ 2015-03-05 21:50 ` Lucas Stach
2015-03-05 21:50 ` [PATCH v2 08/27] ARM: implement streaming DMA ops Lucas Stach
` (19 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:50 UTC (permalink / raw)
To: barebox
This better separates the DMA from the MMU functionality.
Also move all drivers that only depends on asm/mmu.h for the alloc
functions over to the common header.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
arch/arm/include/asm/dma.h | 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(-)
diff --git a/arch/arm/include/asm/dma.h b/arch/arm/include/asm/dma.h
index cb9cd1b..48a9c6e 100644
--- a/arch/arm/include/asm/dma.h
+++ b/arch/arm/include/asm/dma.h
@@ -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
diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h
index d0a644b..01c20bd 100644
--- a/arch/arm/include/asm/mmu.h
+++ b/arch/arm/include/asm/mmu.h
@@ -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)
{
}
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index d299ac6..2c121d7 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -21,6 +21,7 @@
*/
#include <common.h>
+#include <dma.h>
#include <init.h>
#include <errno.h>
#include <io.h>
diff --git a/drivers/dma/apbh_dma.c b/drivers/dma/apbh_dma.c
index 5692c50..ebfc647 100644
--- a/drivers/dma/apbh_dma.c
+++ b/drivers/dma/apbh_dma.c
@@ -20,13 +20,13 @@
#include <linux/list.h>
#include <linux/err.h>
#include <common.h>
+#include <dma.h>
#include <driver.h>
#include <malloc.h>
#include <errno.h>
#include <init.h>
#include <io.h>
-#include <asm/mmu.h>
#define HW_APBHX_CTRL0 0x000
#define BM_APBH_CTRL0_APB_BURST8_EN (1 << 29)
diff --git a/drivers/mci/dw_mmc.c b/drivers/mci/dw_mmc.c
index 18fb45d..0ec37b6 100644
--- a/drivers/mci/dw_mmc.c
+++ b/drivers/mci/dw_mmc.c
@@ -18,6 +18,7 @@
*/
#include <common.h>
+#include <dma.h>
#include <driver.h>
#include <malloc.h>
#include <clock.h>
diff --git a/drivers/mtd/nand/nand_mxs.c b/drivers/mtd/nand/nand_mxs.c
index 98fd9f2..d5d64f3 100644
--- a/drivers/mtd/nand/nand_mxs.c
+++ b/drivers/mtd/nand/nand_mxs.c
@@ -26,6 +26,7 @@
#include <linux/err.h>
#include <of_mtd.h>
#include <common.h>
+#include <dma.h>
#include <malloc.h>
#include <errno.h>
#include <driver.h>
@@ -33,7 +34,6 @@
#include <io.h>
#include <dma/apbh-dma.h>
#include <stmp-device.h>
-#include <asm/mmu.h>
#include <mach/generic.h>
#define MX28_BLOCK_SFTRST (1 << 31)
diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c
index 3c49c09..385a715 100644
--- a/drivers/net/altera_tse.c
+++ b/drivers/net/altera_tse.c
@@ -21,6 +21,7 @@
*/
#include <common.h>
+#include <dma.h>
#include <net.h>
#include <init.h>
#include <clock.h>
diff --git a/drivers/net/arc_emac.c b/drivers/net/arc_emac.c
index 0520649..40516a5 100644
--- a/drivers/net/arc_emac.c
+++ b/drivers/net/arc_emac.c
@@ -19,6 +19,7 @@
#include <asm/mmu.h>
#include <clock.h>
#include <common.h>
+#include <dma.h>
#include <net.h>
#include <io.h>
#include <init.h>
diff --git a/drivers/net/at91_ether.c b/drivers/net/at91_ether.c
index 20aa045..9597639 100644
--- a/drivers/net/at91_ether.c
+++ b/drivers/net/at91_ether.c
@@ -20,6 +20,7 @@
*/
#include <common.h>
+#include <dma.h>
#include <net.h>
#include <clock.h>
#include <malloc.h>
diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index e0e348f..0428a8c 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -22,6 +22,7 @@
*/
#include <common.h>
+#include <dma.h>
#include <init.h>
#include <io.h>
#include <net.h>
diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index c12b26b..266357e 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -15,6 +15,7 @@
*/
#include <common.h>
+#include <dma.h>
#include <malloc.h>
#include <net.h>
#include <init.h>
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 9cdb7d8..1ed5c0e 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -38,6 +38,7 @@
#include <net.h>
#include <clock.h>
+#include <dma.h>
#include <malloc.h>
#include <xfuncs.h>
#include <init.h>
diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 32ba726..f2948e4 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -24,6 +24,7 @@
*/
#include <common.h>
+#include <dma.h>
#include <init.h>
#include <io.h>
#include <net.h>
diff --git a/drivers/net/orion-gbe.c b/drivers/net/orion-gbe.c
index 5104f87..8792e75 100644
--- a/drivers/net/orion-gbe.c
+++ b/drivers/net/orion-gbe.c
@@ -27,6 +27,7 @@
* MA 02110-1301 USA
*/
#include <common.h>
+#include <dma.h>
#include <init.h>
#include <io.h>
#include <net.h>
diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c
index b24a083..d57c706 100644
--- a/drivers/net/rtl8139.c
+++ b/drivers/net/rtl8139.c
@@ -1,4 +1,5 @@
#include <common.h>
+#include <dma.h>
#include <net.h>
#include <malloc.h>
#include <init.h>
diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c
index bab20e8..e465e23 100644
--- a/drivers/net/rtl8169.c
+++ b/drivers/net/rtl8169.c
@@ -16,6 +16,7 @@
#include <asm/mmu.h>
#include <common.h>
+#include <dma.h>
#include <init.h>
#include <net.h>
#include <malloc.h>
diff --git a/drivers/net/xgmac.c b/drivers/net/xgmac.c
index 240684e..c597110 100644
--- a/drivers/net/xgmac.c
+++ b/drivers/net/xgmac.c
@@ -16,6 +16,7 @@
*/
#include <common.h>
+#include <dma.h>
#include <net.h>
#include <clock.h>
#include <malloc.h>
diff --git a/drivers/spi/mxs_spi.c b/drivers/spi/mxs_spi.c
index 8932103..9fe2fd4 100644
--- a/drivers/spi/mxs_spi.c
+++ b/drivers/spi/mxs_spi.c
@@ -23,7 +23,6 @@
#include <stmp-device.h>
#include <linux/clk.h>
#include <linux/err.h>
-#include <asm/mmu.h>
#include <mach/generic.h>
#include <mach/clock.h>
#include <mach/ssp.h>
diff --git a/drivers/usb/gadget/fsl_udc.c b/drivers/usb/gadget/fsl_udc.c
index ed7c318..f6004b4 100644
--- a/drivers/usb/gadget/fsl_udc.c
+++ b/drivers/usb/gadget/fsl_udc.c
@@ -1,4 +1,5 @@
#include <common.h>
+#include <dma.h>
#include <errno.h>
#include <dma.h>
#include <init.h>
@@ -10,6 +11,8 @@
#include <asm/byteorder.h>
#include <linux/err.h>
+#include <asm/mmu.h>
+
/* ### define USB registers here
*/
#define USB_MAX_CTRL_PAYLOAD 64
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index c033842..89a8ffb 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -18,6 +18,7 @@
*/
/*#define DEBUG */
#include <common.h>
+#include <dma.h>
#include <asm/byteorder.h>
#include <usb/usb.h>
#include <io.h>
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index bbd0bd6..010ba35 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -41,6 +41,7 @@
* to activate workaround for bug #41 or this driver will NOT work!
*/
#include <common.h>
+#include <dma.h>
#include <clock.h>
#include <malloc.h>
#include <usb/usb.h>
diff --git a/drivers/usb/host/xhci-hcd.c b/drivers/usb/host/xhci-hcd.c
index 0a4601c..c3d623e 100644
--- a/drivers/usb/host/xhci-hcd.c
+++ b/drivers/usb/host/xhci-hcd.c
@@ -12,9 +12,9 @@
* warranty of any kind, whether express or implied.
*/
//#define DEBUG
-#include <asm/mmu.h>
#include <clock.h>
#include <common.h>
+#include <dma.h>
#include <init.h>
#include <io.h>
#include <linux/err.h>
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index bf95257..5ae16f5 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -14,7 +14,6 @@
* warranty of any kind, whether express or implied.
*/
//#define DEBUG
-#include <asm/mmu.h>
#include <clock.h>
#include <common.h>
#include <io.h>
diff --git a/drivers/video/atmel_hlcdfb.c b/drivers/video/atmel_hlcdfb.c
index 26db758..f7aab7f 100644
--- a/drivers/video/atmel_hlcdfb.c
+++ b/drivers/video/atmel_hlcdfb.c
@@ -27,7 +27,6 @@
#include <mach/io.h>
#include <mach/cpu.h>
#include <errno.h>
-#include <asm/mmu.h>
#include "atmel_lcdfb.h"
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c
index bb302bd..20204c1 100644
--- a/drivers/video/atmel_lcdfb.c
+++ b/drivers/video/atmel_lcdfb.c
@@ -25,7 +25,6 @@
#include <mach/io.h>
#include <mach/cpu.h>
#include <errno.h>
-#include <asm/mmu.h>
#include <linux/clk.h>
#include "atmel_lcdfb.h"
diff --git a/drivers/video/atmel_lcdfb_core.c b/drivers/video/atmel_lcdfb_core.c
index a0a822c..76116af 100644
--- a/drivers/video/atmel_lcdfb_core.c
+++ b/drivers/video/atmel_lcdfb_core.c
@@ -19,11 +19,11 @@
*/
#include <common.h>
+#include <dma.h>
#include <io.h>
#include <linux/err.h>
#include <linux/clk.h>
#include <malloc.h>
-#include <asm/mmu.h>
#include "atmel_lcdfb.h"
diff --git a/drivers/video/imx-ipu-fb.c b/drivers/video/imx-ipu-fb.c
index eb913b1..b566582 100644
--- a/drivers/video/imx-ipu-fb.c
+++ b/drivers/video/imx-ipu-fb.c
@@ -18,6 +18,7 @@
*/
#include <common.h>
+#include <dma.h>
#include <init.h>
#include <io.h>
#include <mach/imx35-regs.h>
diff --git a/drivers/video/imx-ipu-v3/ipu-common.c b/drivers/video/imx-ipu-v3/ipu-common.c
index f13cf01..5c85f86 100644
--- a/drivers/video/imx-ipu-v3/ipu-common.c
+++ b/drivers/video/imx-ipu-v3/ipu-common.c
@@ -19,7 +19,6 @@
#include <clock.h>
#include <driver.h>
#include <init.h>
-#include <asm/mmu.h>
#include <mach/generic.h>
#include <mach/imx6-regs.h>
#include <mach/imx53-regs.h>
diff --git a/drivers/video/imx-ipu-v3/ipufb.c b/drivers/video/imx-ipu-v3/ipufb.c
index d9c81b2..7ee4ae3 100644
--- a/drivers/video/imx-ipu-v3/ipufb.c
+++ b/drivers/video/imx-ipu-v3/ipufb.c
@@ -12,6 +12,7 @@
#define pr_fmt(fmt) "IPU: " fmt
#include <common.h>
+#include <dma.h>
#include <fb.h>
#include <io.h>
#include <driver.h>
@@ -21,7 +22,6 @@
#include <linux/clk.h>
#include <linux/err.h>
#include <asm-generic/div64.h>
-#include <asm/mmu.h>
#include "imx-ipu-v3.h"
#include "ipuv3-plane.h"
diff --git a/drivers/video/omap.c b/drivers/video/omap.c
index 91f9e24..3603ad2 100644
--- a/drivers/video/omap.c
+++ b/drivers/video/omap.c
@@ -19,6 +19,7 @@
*/
#include <driver.h>
+#include <dma.h>
#include <fb.h>
#include <errno.h>
#include <xfuncs.h>
diff --git a/drivers/video/pxa.c b/drivers/video/pxa.c
index 61ce0a5..e76404d 100644
--- a/drivers/video/pxa.c
+++ b/drivers/video/pxa.c
@@ -24,6 +24,7 @@
*/
#include <common.h>
+#include <dma.h>
#include <driver.h>
#include <errno.h>
#include <fb.h>
@@ -37,7 +38,6 @@
#include <mach/pxafb.h>
#include <asm/io.h>
-#include <asm/mmu.h>
#include <asm-generic/div64.h>
/* PXA LCD DMA descriptor */
diff --git a/include/dma.h b/include/dma.h
index fb75eec..800d8b1 100644
--- a/include/dma.h
+++ b/include/dma.h
@@ -14,6 +14,8 @@
#include <dma-dir.h>
#include <asm/dma.h>
+#define DMA_ADDRESS_BROKEN NULL
+
#ifndef dma_alloc
static inline void *dma_alloc(size_t size)
{
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 08/27] ARM: implement streaming DMA ops
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (9 preceding siblings ...)
2015-03-05 21:50 ` [PATCH v2 07/27] ARM: move DMA alloc functions to dma.h Lucas Stach
@ 2015-03-05 21:50 ` Lucas Stach
2015-03-05 21:50 ` [PATCH v2 09/27] AHCI: convert to " Lucas Stach
` (18 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:50 UTC (permalink / raw)
To: barebox
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
arch/arm/cpu/mmu.c | 24 ++++++++++++++++++++++++
arch/arm/include/asm/dma.h | 10 ++++++++++
2 files changed, 34 insertions(+)
diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index c480e07..f1ebd29 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -18,6 +18,7 @@
#define pr_fmt(fmt) "mmu: " fmt
#include <common.h>
+#include <dma-dir.h>
#include <init.h>
#include <asm/mmu.h>
#include <errno.h>
@@ -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);
+ }
+}
diff --git a/arch/arm/include/asm/dma.h b/arch/arm/include/asm/dma.h
index 48a9c6e..d9bce3d 100644
--- a/arch/arm/include/asm/dma.h
+++ b/arch/arm/include/asm/dma.h
@@ -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
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 09/27] AHCI: convert to streaming DMA ops
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (10 preceding siblings ...)
2015-03-05 21:50 ` [PATCH v2 08/27] ARM: implement streaming DMA ops Lucas Stach
@ 2015-03-05 21:50 ` Lucas Stach
2015-03-05 21:50 ` [PATCH v2 10/27] MCI: dw-mmc: " Lucas Stach
` (17 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:50 UTC (permalink / raw)
To: barebox
Move to the common streaming DMA ops in order to get rid of
the direct usage of the ARM MMU functions for the cache
maintenance.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
drivers/ata/ahci.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 2c121d7..4e42180 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -31,7 +31,6 @@
#include <linux/ctype.h>
#include <linux/err.h>
#include <disks.h>
-#include <asm/mmu.h>
#include <ata_drive.h>
#include <linux/sizes.h>
#include <clock.h>
@@ -170,7 +169,11 @@ static int ahci_io(struct ahci_port *ahci_port, u8 *fis, int fis_len, void *rbuf
return -EIO;
if (wbuf)
- dma_flush_range((unsigned long)wbuf, (unsigned long)wbuf + buf_len);
+ dma_sync_single_for_device((unsigned long)wbuf, buf_len,
+ DMA_TO_DEVICE);
+ if (rbuf)
+ dma_sync_single_for_device((unsigned long)rbuf, buf_len,
+ DMA_FROM_DEVICE);
memcpy((unsigned char *)ahci_port->cmd_tbl, fis, fis_len);
@@ -187,8 +190,12 @@ static int ahci_io(struct ahci_port *ahci_port, u8 *fis, int fis_len, void *rbuf
if (ret)
return -ETIMEDOUT;
+ if (wbuf)
+ dma_sync_single_for_cpu((unsigned long)wbuf, buf_len,
+ DMA_TO_DEVICE);
if (rbuf)
- dma_inv_range((unsigned long)rbuf, (unsigned long)rbuf + buf_len);
+ dma_sync_single_for_cpu((unsigned long)rbuf, buf_len,
+ DMA_FROM_DEVICE);
return 0;
}
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 10/27] MCI: dw-mmc: convert to streaming DMA ops
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (11 preceding siblings ...)
2015-03-05 21:50 ` [PATCH v2 09/27] AHCI: convert to " Lucas Stach
@ 2015-03-05 21:50 ` Lucas Stach
2015-03-05 21:50 ` [PATCH v2 11/27] MCI: imx: " Lucas Stach
` (16 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:50 UTC (permalink / raw)
To: barebox
Move to the common streaming DMA ops in order to get rid of
the direct usage of the ARM MMU functions for the cache
maintenance.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
drivers/mci/Kconfig | 2 +-
drivers/mci/dw_mmc.c | 24 ++++++++++++------------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig
index dbcc38d..a5cf2fe 100644
--- a/drivers/mci/Kconfig
+++ b/drivers/mci/Kconfig
@@ -36,7 +36,7 @@ comment "--- MCI host drivers ---"
config MCI_DW
bool "Synopsys DesignWare Memory Card Interface"
- depends on ARM
+ depends on HAS_DMA
help
This selects support for the Synopsys DesignWare Mobile Storage IP
block, this provides host support for SD and MMC interfaces, in both
diff --git a/drivers/mci/dw_mmc.c b/drivers/mci/dw_mmc.c
index 0ec37b6..ac940e8 100644
--- a/drivers/mci/dw_mmc.c
+++ b/drivers/mci/dw_mmc.c
@@ -29,7 +29,6 @@
#include <linux/clk.h>
#include <linux/err.h>
#include <asm-generic/errno.h>
-#include <asm/mmu.h>
#define DWMCI_CTRL 0x000
#define DWMCI_PWREN 0x004
@@ -282,7 +281,6 @@ dwmci_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
uint64_t start;
int ret;
unsigned int num_bytes = 0;
- const void *writebuf = NULL;
start = get_time_ns();
while (1) {
@@ -300,12 +298,12 @@ dwmci_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
if (data) {
num_bytes = data->blocks * data->blocksize;
- if (data->flags & MMC_DATA_WRITE) {
- dma_flush_range((unsigned long)data->src,
- (unsigned long)(data->src + data->blocks * 512));
-
- writebuf = data->src;
- }
+ if (data->flags & MMC_DATA_WRITE)
+ dma_sync_single_for_device((unsigned long)data->src,
+ num_bytes, DMA_TO_DEVICE);
+ else
+ dma_sync_single_for_device((unsigned long)data->dest,
+ num_bytes, DMA_FROM_DEVICE);
ret = dwmci_prepare_data(host, data);
if (ret)
@@ -389,10 +387,12 @@ dwmci_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
ctrl &= ~(DWMCI_DMA_EN);
dwmci_writel(host, DWMCI_CTRL, ctrl);
- if (data->flags & MMC_DATA_READ) {
- dma_inv_range((unsigned long)data->dest,
- (unsigned long)(data->dest + data->blocks * 512));
- }
+ if (data->flags & MMC_DATA_WRITE)
+ dma_sync_single_for_cpu((unsigned long)data->src,
+ num_bytes, DMA_TO_DEVICE);
+ else
+ dma_sync_single_for_cpu((unsigned long)data->dest,
+ num_bytes, DMA_FROM_DEVICE);
}
udelay(100);
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 11/27] MCI: imx: convert to streaming DMA ops
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (12 preceding siblings ...)
2015-03-05 21:50 ` [PATCH v2 10/27] MCI: dw-mmc: " Lucas Stach
@ 2015-03-05 21:50 ` Lucas Stach
2015-03-05 21:50 ` [PATCH v2 12/27] MCI: tegra-sdmmc: " Lucas Stach
` (15 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:50 UTC (permalink / raw)
To: barebox
Move to the common streaming DMA ops in order to get rid of
the direct usage of the ARM MMU functions for the cache
maintenance.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
drivers/mci/imx-esdhc.c | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c
index 23bdc1f..8b45500 100644
--- a/drivers/mci/imx-esdhc.c
+++ b/drivers/mci/imx-esdhc.c
@@ -22,6 +22,7 @@
*/
#include <config.h>
#include <common.h>
+#include <dma.h>
#include <driver.h>
#include <init.h>
#include <of.h>
@@ -31,7 +32,6 @@
#include <io.h>
#include <linux/clk.h>
#include <linux/err.h>
-#include <asm/mmu.h>
#include <mach/generic.h>
#include <mach/esdhc.h>
#include <gpio.h>
@@ -211,6 +211,7 @@ esdhc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
u32 irqstat;
struct fsl_esdhc_host *host = to_fsl_esdhc(mci);
void __iomem *regs = host->regs;
+ unsigned int num_bytes = 0;
int ret;
esdhc_write32(regs + SDHCI_INT_STATUS, -1);
@@ -225,12 +226,15 @@ esdhc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
err = esdhc_setup_data(mci, data);
if(err)
return err;
- if (data->flags & MMC_DATA_WRITE) {
- dma_flush_range((unsigned long)data->src,
- (unsigned long)(data->src + data->blocks * 512));
- } else
- dma_clean_range((unsigned long)data->src,
- (unsigned long)(data->src + data->blocks * 512));
+
+ num_bytes = data->blocks * data->blocksize;
+
+ if (data->flags & MMC_DATA_WRITE)
+ dma_sync_single_for_device((unsigned long)data->src,
+ num_bytes, DMA_TO_DEVICE);
+ else
+ dma_sync_single_for_device((unsigned long)data->dest,
+ num_bytes, DMA_FROM_DEVICE);
}
@@ -313,10 +317,12 @@ esdhc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
} while (!(irqstat & IRQSTAT_TC) &&
(esdhc_read32(regs + SDHCI_PRESENT_STATE) & PRSSTAT_DLA));
- if (data->flags & MMC_DATA_READ) {
- dma_inv_range((unsigned long)data->dest,
- (unsigned long)(data->dest + data->blocks * 512));
- }
+ if (data->flags & MMC_DATA_WRITE)
+ dma_sync_single_for_cpu((unsigned long)data->src,
+ num_bytes, DMA_TO_DEVICE);
+ else
+ dma_sync_single_for_cpu((unsigned long)data->dest,
+ num_bytes, DMA_FROM_DEVICE);
#endif
}
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 12/27] MCI: tegra-sdmmc: convert to streaming DMA ops
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (13 preceding siblings ...)
2015-03-05 21:50 ` [PATCH v2 11/27] MCI: imx: " Lucas Stach
@ 2015-03-05 21:50 ` Lucas Stach
2015-03-05 21:50 ` [PATCH v2 13/27] net: arc-emac: " Lucas Stach
` (14 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:50 UTC (permalink / raw)
To: barebox
Move to the common streaming DMA ops in order to get rid of
the direct usage of the ARM MMU functions for the cache
maintenance.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
drivers/mci/tegra-sdmmc.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/drivers/mci/tegra-sdmmc.c b/drivers/mci/tegra-sdmmc.c
index 0e23d6f..670c280 100644
--- a/drivers/mci/tegra-sdmmc.c
+++ b/drivers/mci/tegra-sdmmc.c
@@ -17,10 +17,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <asm/mmu.h>
#include <common.h>
#include <clock.h>
#include <driver.h>
+#include <dma.h>
#include <gpio.h>
#include <init.h>
#include <io.h>
@@ -100,6 +100,7 @@ static int tegra_sdmmc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
struct mci_data *data)
{
struct tegra_sdmmc_host *host = to_tegra_sdmmc_host(mci);
+ unsigned int num_bytes = 0;
u32 val = 0;
int ret;
@@ -109,15 +110,15 @@ static int tegra_sdmmc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
/* Set up for a data transfer if we have one */
if (data) {
+ num_bytes = data->blocks * data->blocksize;
+
if (data->flags & MMC_DATA_WRITE) {
- dma_flush_range((unsigned long)data->src,
- (unsigned long)(data->src +
- data->blocks * 512));
+ dma_sync_single_for_device((unsigned long)data->src,
+ num_bytes, DMA_TO_DEVICE);
writel((u32)data->src, host->regs + SDHCI_DMA_ADDRESS);
} else {
- dma_clean_range((unsigned long)data->src,
- (unsigned long)(data->src +
- data->blocks * 512));
+ dma_sync_single_for_device((unsigned long)data->dest,
+ num_bytes, DMA_FROM_DEVICE);
writel((u32)data->dest, host->regs + SDHCI_DMA_ADDRESS);
}
@@ -255,11 +256,12 @@ static int tegra_sdmmc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
}
writel(val, host->regs + SDHCI_INT_STATUS);
- if (data->flags & MMC_DATA_READ) {
- dma_inv_range((unsigned long)data->dest,
- (unsigned long)(data->dest +
- data->blocks * 512));
- }
+ if (data->flags & MMC_DATA_WRITE)
+ dma_sync_single_for_cpu((unsigned long)data->src,
+ num_bytes, DMA_TO_DEVICE);
+ else
+ dma_sync_single_for_cpu((unsigned long)data->dest,
+ num_bytes, DMA_FROM_DEVICE);
}
return 0;
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 13/27] net: arc-emac: convert to streaming DMA ops
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (14 preceding siblings ...)
2015-03-05 21:50 ` [PATCH v2 12/27] MCI: tegra-sdmmc: " Lucas Stach
@ 2015-03-05 21:50 ` Lucas Stach
2015-03-05 21:50 ` [PATCH v2 14/27] net: cpsw: " Lucas Stach
` (13 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:50 UTC (permalink / raw)
To: barebox
Move to the common streaming DMA ops in order to get rid of
the direct usage of the ARM MMU functions for the cache
maintenance.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
drivers/net/arc_emac.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/net/arc_emac.c b/drivers/net/arc_emac.c
index 40516a5..2d6215e 100644
--- a/drivers/net/arc_emac.c
+++ b/drivers/net/arc_emac.c
@@ -16,7 +16,6 @@
* GNU General Public License for more details.
*/
-#include <asm/mmu.h>
#include <clock.h>
#include <common.h>
#include <dma.h>
@@ -195,6 +194,8 @@ static int arc_emac_open(struct eth_device *edev)
rxbd->data = cpu_to_le32(rxbuf);
/* Return ownership to EMAC */
+ dma_sync_single_for_device((unsigned long)rxbuf, PKTSIZE,
+ DMA_FROM_DEVICE);
rxbd->info = cpu_to_le32(FOR_EMAC | PKTSIZE);
*last_rx_bd = (*last_rx_bd + 1) % RX_BD_NUM;
@@ -244,7 +245,7 @@ static int arc_emac_send(struct eth_device *edev, void *data, int length)
length = EMAC_ZLEN;
}
- dma_flush_range((unsigned long)data, (unsigned long)data + length);
+ dma_sync_single_for_device((unsigned long)data, length, DMA_TO_DEVICE);
bd->data = cpu_to_le32(data);
bd->info = cpu_to_le32(FOR_EMAC | FIRST_OR_LAST_MASK | length);
@@ -253,6 +254,8 @@ static int arc_emac_send(struct eth_device *edev, void *data, int length)
ret = wait_on_timeout(20 * MSECOND,
(arc_reg_get(priv, R_STATUS) & TXINT_MASK) != 0);
+ dma_sync_single_for_cpu((unsigned long)data, length, DMA_TO_DEVICE);
+
if (ret) {
dev_err(&edev->dev, "transmit timeout\n");
return ret;
@@ -294,18 +297,19 @@ static int arc_emac_recv(struct eth_device *edev)
printk(KERN_DEBUG "incomplete packet received\n");
/* Return ownership to EMAC */
- rxbd->info = cpu_to_le32(FOR_EMAC | PKTSIZE);
continue;
}
pktlen = info & LEN_MASK;
- /* invalidate current receive buffer */
- dma_inv_range((unsigned long)rxbd->data,
- (unsigned long)rxbd->data + pktlen);
+ dma_sync_single_for_cpu((unsigned long)rxbd->data, pktlen,
+ DMA_FROM_DEVICE);
net_receive(edev, (unsigned char *)rxbd->data, pktlen);
+ dma_sync_single_for_device((unsigned long)rxbd->data, pktlen,
+ DMA_FROM_DEVICE);
+
rxbd->info = cpu_to_le32(FOR_EMAC | PKTSIZE);
}
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 14/27] net: cpsw: convert to streaming DMA ops
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (15 preceding siblings ...)
2015-03-05 21:50 ` [PATCH v2 13/27] net: arc-emac: " Lucas Stach
@ 2015-03-05 21:50 ` Lucas Stach
2015-03-05 21:50 ` [PATCH v2 15/27] net: at91_ether: " Lucas Stach
` (12 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:50 UTC (permalink / raw)
To: barebox
Move to the common streaming DMA ops in order to get rid of
the direct usage of the ARM MMU functions for the cache
maintenance.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
drivers/net/cpsw.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index 799fac8..3f8ffa0 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -21,6 +21,7 @@
#include <init.h>
#include <command.h>
+#include <dma.h>
#include <net.h>
#include <malloc.h>
#include <net.h>
@@ -32,7 +33,6 @@
#include <of_net.h>
#include <of_address.h>
#include <xfuncs.h>
-#include <asm/mmu.h>
#include <asm/system.h>
#include <linux/err.h>
@@ -871,9 +871,9 @@ static int cpsw_send(struct eth_device *edev, void *packet, int length)
dev_dbg(&slave->dev, "%s: %i bytes @ 0x%p\n", __func__, length, packet);
- dma_flush_range((ulong) packet, (ulong)packet + length);
-
+ dma_sync_single_for_device((unsigned long)packet, length, DMA_TO_DEVICE);
ret = cpdma_submit(priv, &priv->tx_chan, packet, length);
+ dma_sync_single_for_cpu((unsigned long)packet, length, DMA_TO_DEVICE);
return ret;
}
@@ -886,8 +886,11 @@ static int cpsw_recv(struct eth_device *edev)
int len;
while (cpdma_process(priv, &priv->rx_chan, &buffer, &len) >= 0) {
- dma_inv_range((ulong)buffer, (ulong)buffer + len);
+ dma_sync_single_for_cpu((unsigned long)buffer, len,
+ DMA_FROM_DEVICE);
net_receive(edev, buffer, len);
+ dma_sync_single_for_device((unsigned long)buffer, len,
+ DMA_FROM_DEVICE);
cpdma_submit(priv, &priv->rx_chan, buffer, PKTSIZE);
}
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 15/27] net: at91_ether: convert to streaming DMA ops
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (16 preceding siblings ...)
2015-03-05 21:50 ` [PATCH v2 14/27] net: cpsw: " Lucas Stach
@ 2015-03-05 21:50 ` Lucas Stach
2015-03-05 21:50 ` [PATCH v2 16/27] net: davinci_emac: " Lucas Stach
` (11 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:50 UTC (permalink / raw)
To: barebox
Move to the common streaming DMA ops in order to get rid of
the direct usage of the ARM MMU functions for the cache
maintenance.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
drivers/net/at91_ether.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/net/at91_ether.c b/drivers/net/at91_ether.c
index 9597639..5a74837 100644
--- a/drivers/net/at91_ether.c
+++ b/drivers/net/at91_ether.c
@@ -35,7 +35,6 @@
#include <linux/clk.h>
#include <linux/mii.h>
#include <errno.h>
-#include <asm/mmu.h>
#include <linux/phy.h>
#include "at91_ether.h"
@@ -200,7 +199,8 @@ static int at91_ether_send(struct eth_device *edev, void *packet, int length)
{
while (!(at91_emac_read(AT91_EMAC_TSR) & AT91_EMAC_TSR_BNQ));
- dma_flush_range((ulong) packet, (ulong)packet + length);
+ dma_sync_single_for_device((unsigned long)packet, length, DMA_TO_DEVICE);
+
/* Set address of the data in the Transmit Address register */
at91_emac_write(AT91_EMAC_TAR, (unsigned long) packet);
/* Set length of the packet in the Transmit Control register */
@@ -211,6 +211,8 @@ static int at91_ether_send(struct eth_device *edev, void *packet, int length)
at91_emac_write(AT91_EMAC_TSR,
at91_emac_read(AT91_EMAC_TSR) | AT91_EMAC_TSR_COMP);
+ dma_sync_single_for_cpu((unsigned long)packet, length, DMA_TO_DEVICE);
+
return 0;
}
@@ -225,7 +227,11 @@ static int at91_ether_rx(struct eth_device *edev)
size = rbfp->size & RBF_SIZE;
+ dma_sync_single_for_cpu((unsigned long)rbfp->addr, size,
+ DMA_FROM_DEVICE);
net_receive(edev, (unsigned char *)(rbfp->addr & RBF_ADDR), size);
+ dma_sync_single_for_device((unsigned long)rbfp->addr, size,
+ DMA_FROM_DEVICE);
rbfp->addr &= ~RBF_OWNER;
if (rbfp->addr & RBF_WRAP)
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 16/27] net: davinci_emac: convert to streaming DMA ops
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (17 preceding siblings ...)
2015-03-05 21:50 ` [PATCH v2 15/27] net: at91_ether: " Lucas Stach
@ 2015-03-05 21:50 ` Lucas Stach
2015-03-05 21:50 ` [PATCH v2 17/27] net: designware: " Lucas Stach
` (10 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:50 UTC (permalink / raw)
To: barebox
Move to the common streaming DMA ops in order to get rid of
the direct usage of the ARM MMU functions for the cache
maintenance.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
drivers/net/davinci_emac.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index ce367a3..056ffe2 100644
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -40,12 +40,12 @@
*/
#include <common.h>
+#include <dma.h>
#include <io.h>
#include <clock.h>
#include <net.h>
#include <malloc.h>
#include <init.h>
-#include <asm/mmu.h>
#include <asm/system.h>
#include <linux/phy.h>
#include <mach/emac_defs.h>
@@ -411,7 +411,7 @@ static int davinci_emac_send(struct eth_device *edev, void *packet, int length)
EMAC_CPPI_OWNERSHIP_BIT |
EMAC_CPPI_EOP_BIT),
priv->emac_tx_desc + EMAC_DESC_PKT_FLAG_LEN);
- dma_flush_range((ulong) packet, (ulong)packet + length);
+ dma_sync_single_for_device((unsigned long)packet, length, DMA_TO_DEVICE);
/* Send the packet */
writel(BD_TO_HW(priv->emac_tx_desc), priv->adap_emac + EMAC_TX0HDP);
@@ -429,6 +429,7 @@ static int davinci_emac_send(struct eth_device *edev, void *packet, int length)
break;
}
}
+ dma_sync_single_for_cpu((unsigned long)packet, length, DMA_TO_DEVICE);
dev_dbg(priv->dev, "- emac_send (ret_status %i)\n", ret_status);
return ret_status;
@@ -460,9 +461,9 @@ static int davinci_emac_recv(struct eth_device *edev)
pkt = (unsigned char *)readl(rx_curr_desc + EMAC_DESC_BUFFER);
len = readl(rx_curr_desc + EMAC_DESC_BUFF_OFF_LEN) & 0xffff;
dev_dbg(priv->dev, "| emac_recv got packet (length %i)\n", len);
- dma_inv_range((ulong)pkt,
- (ulong)readl(rx_curr_desc + EMAC_DESC_BUFFER) + len);
+ dma_sync_single_for_cpu((unsigned long)pkt, len, DMA_FROM_DEVICE);
net_receive(edev, pkt, len);
+ dma_sync_single_for_device((unsigned long)pkt, len, DMA_FROM_DEVICE);
ret = len;
}
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 17/27] net: designware: convert to streaming DMA ops
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (18 preceding siblings ...)
2015-03-05 21:50 ` [PATCH v2 16/27] net: davinci_emac: " Lucas Stach
@ 2015-03-05 21:50 ` Lucas Stach
2015-03-05 21:50 ` [PATCH v2 18/27] net: fec: " Lucas Stach
` (9 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:50 UTC (permalink / raw)
To: barebox
Move to the common streaming DMA ops in order to get rid of
the direct usage of the ARM MMU functions for the cache
maintenance.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
drivers/net/designware.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 0428a8c..985bb5f 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -27,7 +27,6 @@
#include <io.h>
#include <net.h>
#include <of_net.h>
-#include <asm/mmu.h>
#include <net/designware.h>
#include <linux/phy.h>
#include <linux/err.h>
@@ -197,8 +196,8 @@ static void rx_descs_init(struct eth_device *dev)
else
desc_p->dmamac_cntl |= DESC_RXCTRL_RXCHAIN;
- dma_inv_range((unsigned long)desc_p->dmamac_addr,
- (unsigned long)desc_p->dmamac_addr + CONFIG_ETH_BUFSIZE);
+ dma_sync_single_for_cpu((unsigned long)desc_p->dmamac_addr,
+ CONFIG_ETH_BUFSIZE, DMA_FROM_DEVICE);
desc_p->txrx_status = DESC_RXSTS_OWNBYDMA;
}
@@ -302,8 +301,8 @@ static int dwc_ether_send(struct eth_device *dev, void *packet, int length)
}
memcpy((void *)desc_p->dmamac_addr, packet, length);
- dma_flush_range((unsigned long)desc_p->dmamac_addr,
- (unsigned long)desc_p->dmamac_addr + length);
+ dma_sync_single_for_device((unsigned long)desc_p->dmamac_addr, length,
+ DMA_TO_DEVICE);
if (priv->enh_desc) {
desc_p->txrx_status |= DESC_ENH_TXSTS_TXFIRST | DESC_ENH_TXSTS_TXLAST;
@@ -328,6 +327,9 @@ static int dwc_ether_send(struct eth_device *dev, void *packet, int length)
/* Start the transmission */
writel(POLL_DATA, &dma_p->txpolldemand);
+ dma_sync_single_for_cpu((unsigned long)desc_p->dmamac_addr, length,
+ DMA_TO_DEVICE);
+
return 0;
}
@@ -351,10 +353,11 @@ static int dwc_ether_rx(struct eth_device *dev)
* Make the current descriptor valid again and go to
* the next one
*/
- dma_inv_range((unsigned long)desc_p->dmamac_addr,
- (unsigned long)desc_p->dmamac_addr + length);
-
+ dma_sync_single_for_cpu((unsigned long)desc_p->dmamac_addr, length,
+ DMA_FROM_DEVICE);
net_receive(dev, desc_p->dmamac_addr, length);
+ dma_sync_single_for_device((unsigned long)desc_p->dmamac_addr, length,
+ DMA_FROM_DEVICE);
desc_p->txrx_status |= DESC_RXSTS_OWNBYDMA;
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 18/27] net: fec: convert to streaming DMA ops
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (19 preceding siblings ...)
2015-03-05 21:50 ` [PATCH v2 17/27] net: designware: " Lucas Stach
@ 2015-03-05 21:50 ` Lucas Stach
2015-03-05 21:50 ` [PATCH v2 19/27] net: macb: " Lucas Stach
` (8 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:50 UTC (permalink / raw)
To: barebox
Move to the common streaming DMA ops in order to get rid of
the direct usage of the ARM MMU functions for the cache
maintenance.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
drivers/net/fec_imx.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index 266357e..875905a 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -31,8 +31,6 @@
#include <of_gpio.h>
#include <gpio.h>
-#include <asm/mmu.h>
-
#include "fec_imx.h"
struct fec_frame {
@@ -479,8 +477,9 @@ static int fec_send(struct eth_device *dev, void *eth_data, int data_length)
writew(data_length, &fec->tbd_base[fec->tbd_index].data_length);
writel((uint32_t)(eth_data), &fec->tbd_base[fec->tbd_index].data_pointer);
- dma_flush_range((unsigned long)eth_data,
- (unsigned long)(eth_data + data_length));
+
+ dma_sync_single_for_device((unsigned long)eth_data, data_length,
+ DMA_TO_DEVICE);
/*
* update BD's status now
* This block:
@@ -503,6 +502,8 @@ static int fec_send(struct eth_device *dev, void *eth_data, int data_length)
break;
}
}
+ dma_sync_single_for_cpu((unsigned long)eth_data, data_length,
+ DMA_TO_DEVICE);
/* for next transmission use the other buffer */
if (fec->tbd_index)
@@ -576,7 +577,11 @@ static int fec_recv(struct eth_device *dev)
*/
frame = phys_to_virt(readl(&rbd->data_pointer));
frame_length = readw(&rbd->data_length) - 4;
+ dma_sync_single_for_cpu((unsigned long)frame->data,
+ frame_length, DMA_FROM_DEVICE);
net_receive(dev, frame->data, frame_length);
+ dma_sync_single_for_device((unsigned long)frame->data,
+ frame_length, DMA_FROM_DEVICE);
len = frame_length;
} else {
if (bd_status & FEC_RBD_ERR) {
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 19/27] net: macb: convert to streaming DMA ops
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (20 preceding siblings ...)
2015-03-05 21:50 ` [PATCH v2 18/27] net: fec: " Lucas Stach
@ 2015-03-05 21:50 ` Lucas Stach
2015-03-05 21:50 ` [PATCH v2 20/27] net: orion-gbe: " Lucas Stach
` (7 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:50 UTC (permalink / raw)
To: barebox
Move to the common streaming DMA ops in order to get rid of
the direct usage of the ARM MMU functions for the cache
maintenance.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
drivers/net/macb.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 1ed5c0e..2ac00f3 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -47,7 +47,6 @@
#include <platform_data/macb.h>
#include <linux/clk.h>
#include <linux/err.h>
-#include <asm/mmu.h>
#include <linux/phy.h>
#include "macb.h"
@@ -122,7 +121,7 @@ static int macb_send(struct eth_device *edev, void *packet,
macb->tx_ring[tx_head].ctrl = ctrl;
macb->tx_ring[tx_head].addr = (ulong)packet;
barrier();
- dma_flush_range((ulong) packet, (ulong)packet + length);
+ dma_sync_single_for_device((unsigned long)packet, length, DMA_TO_DEVICE);
macb_writel(macb, NCR, MACB_BIT(TE) | MACB_BIT(RE) | MACB_BIT(TSTART));
start = get_time_ns();
@@ -135,6 +134,7 @@ static int macb_send(struct eth_device *edev, void *packet,
break;
}
} while (!is_timeout(start, 100 * MSECOND));
+ dma_sync_single_for_cpu((unsigned long)packet, length, DMA_TO_DEVICE);
if (ctrl & MACB_BIT(TX_UNDERRUN))
dev_err(macb->dev, "TX underrun\n");
@@ -188,7 +188,11 @@ static int gem_recv(struct eth_device *edev)
status = macb->rx_ring[macb->rx_tail].ctrl;
length = MACB_BFEXT(RX_FRMLEN, status);
buffer = macb->rx_buffer + macb->rx_buffer_size * macb->rx_tail;
+ dma_sync_single_for_cpu((unsigned long)buffer, length,
+ DMA_FROM_DEVICE);
net_receive(edev, buffer, length);
+ dma_sync_single_for_device((unsigned long)buffer, length,
+ DMA_FROM_DEVICE);
macb->rx_ring[macb->rx_tail].addr &= ~MACB_BIT(RX_USED);
barrier();
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 20/27] net: orion-gbe: convert to streaming DMA ops
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (21 preceding siblings ...)
2015-03-05 21:50 ` [PATCH v2 19/27] net: macb: " Lucas Stach
@ 2015-03-05 21:50 ` Lucas Stach
2015-03-05 21:50 ` [PATCH v2 21/27] net: rtl8169: " Lucas Stach
` (6 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:50 UTC (permalink / raw)
To: barebox
Move to the common streaming DMA ops in order to get rid of
the direct usage of the ARM MMU functions for the cache
maintenance.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
drivers/net/orion-gbe.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/net/orion-gbe.c b/drivers/net/orion-gbe.c
index 8792e75..97ffff2 100644
--- a/drivers/net/orion-gbe.c
+++ b/drivers/net/orion-gbe.c
@@ -33,7 +33,6 @@
#include <net.h>
#include <of_net.h>
#include <linux/sizes.h>
-#include <asm/mmu.h>
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/mbus.h>
@@ -243,7 +242,7 @@ static int port_send(struct eth_device *edev, void *data, int len)
int ret;
/* flush transmit data */
- dma_flush_range((unsigned long)data, (unsigned long)data+len);
+ dma_sync_single_for_device((unsigned long)data, len, DMA_TO_DEVICE);
txdesc->cmd_sts = TXDESC_OWNED_BY_DMA;
txdesc->cmd_sts |= TXDESC_FIRST | TXDESC_LAST;
@@ -258,6 +257,7 @@ static int port_send(struct eth_device *edev, void *data, int len)
/* wait for packet transmit completion */
ret = wait_on_timeout(TRANSFER_TIMEOUT,
(readl(&txdesc->cmd_sts) & TXDESC_OWNED_BY_DMA) == 0);
+ dma_sync_single_for_cpu((unsigned long)data, len, DMA_TO_DEVICE);
if (ret) {
dev_err(&edev->dev, "transmit timeout\n");
return ret;
@@ -301,12 +301,15 @@ static int port_recv(struct eth_device *edev)
}
/* invalidate current receive buffer */
- dma_inv_range((unsigned long)rxdesc->buf_ptr,
- (unsigned long)rxdesc->buf_ptr +
- ALIGN(PKTSIZE, 8));
+ dma_sync_single_for_cpu((unsigned long)rxdesc->buf_ptr,
+ ALIGN(PKTSIZE, 8), DMA_FROM_DEVICE);
/* received packet is padded with two null bytes */
net_receive(edev, rxdesc->buf_ptr + 0x2, rxdesc->byte_cnt - 0x2);
+
+ dma_sync_single_for_device((unsigned long)rxdesc->buf_ptr,
+ ALIGN(PKTSIZE, 8), DMA_FROM_DEVICE);
+
ret = 0;
recv_err:
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 21/27] net: rtl8169: convert to streaming DMA ops
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (22 preceding siblings ...)
2015-03-05 21:50 ` [PATCH v2 20/27] net: orion-gbe: " Lucas Stach
@ 2015-03-05 21:50 ` Lucas Stach
2015-03-05 21:50 ` [PATCH v2 22/27] net: xgmac: " Lucas Stach
` (5 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:50 UTC (permalink / raw)
To: barebox
Move to the common streaming DMA ops in order to get rid of
the direct usage of the ARM MMU functions for the cache
maintenance.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
drivers/net/Kconfig | 1 +
drivers/net/rtl8169.c | 30 +++++++++++++-----------------
2 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index adb7008..42ffa65 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -167,6 +167,7 @@ config DRIVER_NET_RTL8139
config DRIVER_NET_RTL8169
bool "RealTek RTL-8169 PCI Ethernet driver"
depends on PCI
+ depends on HAS_DMA
select PHYLIB
help
This is a driver for the Fast Ethernet PCI network cards based on
diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c
index e465e23..d6a7610 100644
--- a/drivers/net/rtl8169.c
+++ b/drivers/net/rtl8169.c
@@ -14,7 +14,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <asm/mmu.h>
#include <common.h>
#include <dma.h>
#include <init.h>
@@ -234,8 +233,8 @@ static void rtl8169_init_ring(struct rtl8169_priv *priv)
priv->rx_desc = dma_alloc_coherent(NUM_RX_DESC *
sizeof(struct bufdesc), 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 |
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 22/27] net: xgmac: convert to streaming DMA ops
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (23 preceding siblings ...)
2015-03-05 21:50 ` [PATCH v2 21/27] net: rtl8169: " Lucas Stach
@ 2015-03-05 21:50 ` Lucas Stach
2015-03-05 21:50 ` [PATCH v2 23/27] usb: gadget: fsl_udc: " Lucas Stach
` (4 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:50 UTC (permalink / raw)
To: barebox
Move to the common streaming DMA ops in order to get rid of
the direct usage of the ARM MMU functions for the cache
maintenance.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
drivers/net/xgmac.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/net/xgmac.c b/drivers/net/xgmac.c
index c597110..3b2273f 100644
--- a/drivers/net/xgmac.c
+++ b/drivers/net/xgmac.c
@@ -25,7 +25,6 @@
#include <errno.h>
#include <io.h>
#include <linux/err.h>
-#include <asm/mmu.h>
#define TX_NUM_DESC 1
#define RX_NUM_DESC 32
@@ -587,7 +586,7 @@ static int xgmac_send(struct eth_device *edev, void *packet, int length)
struct xgmac_dma_desc *txdesc = &priv->tx_chain[currdesc];
int ret;
- dma_flush_range((ulong) packet, (ulong)packet + length);
+ dma_sync_single_for_device((unsigned long)packet, length, DMA_TO_DEVICE);
desc_set_buf_addr_and_size(txdesc, packet, length);
desc_set_tx_owner(txdesc, TXDESC_FIRST_SEG |
TXDESC_LAST_SEG | TXDESC_CRC_EN_APPEND);
@@ -596,6 +595,7 @@ static int xgmac_send(struct eth_device *edev, void *packet, int length)
writel(1, priv->base + XGMAC_DMA_TX_POLL);
ret = wait_on_timeout(1 * SECOND, !desc_get_owner(txdesc));
+ dma_sync_single_for_cpu((unsigned long)packet, length, DMA_TO_DEVICE);
if (ret) {
dev_err(priv->dev, "TX timeout\n");
return ret;
@@ -611,14 +611,19 @@ static int xgmac_recv(struct eth_device *edev)
u32 currdesc = priv->rx_currdesc;
struct xgmac_dma_desc *rxdesc = &priv->rx_chain[currdesc];
int length = 0;
+ void *buf_addr;
/* check if the host has the desc */
if (desc_get_owner(rxdesc))
return -1; /* something bad happened */
length = desc_get_rx_frame_len(rxdesc);
+ buf_addr = desc_get_buf_addr(rxdesc);
- net_receive(edev, desc_get_buf_addr(rxdesc), length);
+ dma_sync_single_for_cpu((unsigned long)buf_addr, length, DMA_FROM_DEVICE);
+ net_receive(edev, 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);
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 23/27] usb: gadget: fsl_udc: convert to streaming DMA ops
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (24 preceding siblings ...)
2015-03-05 21:50 ` [PATCH v2 22/27] net: xgmac: " Lucas Stach
@ 2015-03-05 21:50 ` Lucas Stach
2015-03-05 21:50 ` [PATCH v2 24/27] usb: host: ehci: " Lucas Stach
` (3 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:50 UTC (permalink / raw)
To: barebox
Move to the common streaming DMA ops in order to get rid of
the direct usage of the ARM MMU functions for the cache
maintenance.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
drivers/usb/gadget/fsl_udc.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/gadget/fsl_udc.c b/drivers/usb/gadget/fsl_udc.c
index f6004b4..19f3da6 100644
--- a/drivers/usb/gadget/fsl_udc.c
+++ b/drivers/usb/gadget/fsl_udc.c
@@ -568,8 +568,8 @@ static void done(struct fsl_ep *ep, struct fsl_req *req, int status)
dma_free_coherent(curr_td, 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;
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 24/27] usb: host: ehci: convert to streaming DMA ops
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (25 preceding siblings ...)
2015-03-05 21:50 ` [PATCH v2 23/27] usb: gadget: fsl_udc: " Lucas Stach
@ 2015-03-05 21:50 ` Lucas Stach
2015-03-05 21:50 ` [PATCH v2 25/27] usb: host: ohci: " Lucas Stach
` (2 subsequent siblings)
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:50 UTC (permalink / raw)
To: barebox
Move to the common streaming DMA ops in order to get rid of
the direct usage of the ARM MMU functions for the cache
maintenance.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
drivers/usb/host/ehci-hcd.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 89a8ffb..abaeaf2 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -30,7 +30,6 @@
#include <errno.h>
#include <of.h>
#include <usb/ehci.h>
-#include <asm/mmu.h>
#include <linux/err.h>
#include "ehci.h"
@@ -331,7 +330,9 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
struct qTD *qtd = &ehci->td[i];
if (!qtd->qtd_dma)
continue;
- dma_flush_range(qtd->qtd_dma, qtd->qtd_dma + qtd->length);
+ dma_sync_single_for_device((unsigned long)qtd->qtd_dma,
+ qtd->length,
+ DMA_BIDIRECTIONAL);
}
}
@@ -372,7 +373,8 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
struct qTD *qtd = &ehci->td[i];
if (!qtd->qtd_dma)
continue;
- dma_inv_range(qtd->qtd_dma, qtd->qtd_dma + qtd->length);
+ dma_sync_single_for_cpu((unsigned long)qtd->qtd_dma,
+ qtd->length, DMA_BIDIRECTIONAL);
}
}
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 25/27] usb: host: ohci: convert to streaming DMA ops
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (26 preceding siblings ...)
2015-03-05 21:50 ` [PATCH v2 24/27] usb: host: ehci: " Lucas Stach
@ 2015-03-05 21:50 ` Lucas Stach
2015-03-05 21:50 ` [PATCH v2 26/27] ARM: bcm2835: mbox: " Lucas Stach
2015-03-05 21:50 ` [PATCH v2 27/27] ARM: MMU: unexport cache maintenance functions Lucas Stach
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:50 UTC (permalink / raw)
To: barebox
Move to the common streaming DMA ops in order to get rid of
the direct usage of the ARM MMU functions for the cache
maintenance.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
drivers/usb/host/ohci-hcd.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 010ba35..1d511b7 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -43,6 +43,7 @@
#include <common.h>
#include <dma.h>
#include <clock.h>
+#include <dma.h>
#include <malloc.h>
#include <usb/usb.h>
#include <usb/usb_defs.h>
@@ -52,7 +53,6 @@
#include <asm/byteorder.h>
#include <io.h>
-#include <asm/mmu.h>
#include "ohci.h"
@@ -857,7 +857,7 @@ static void td_fill(struct ohci *ohci, unsigned int info,
td->hwNextTD = virt_to_phys((void *)m32_swap((unsigned long)td_pt));
- dma_flush_range((unsigned long)data, (unsigned long)(data + len));
+ dma_sync_single_for_device((unsigned long)data, len, DMA_BIDIRECTIONAL);
/* append to queue */
td->ed->hwTailP = td->hwNextTD;
@@ -1093,7 +1093,8 @@ static int dl_done_list(struct ohci *ohci)
unsigned long ptdphys = virt_to_phys(ptd);
struct td *td_list;
- dma_clean_range(ptdphys, ptdphys + (sizeof(struct td) * NUM_TD));
+ dma_sync_single_for_device((unsigned long)ptdphys,
+ sizeof(struct td) * NUM_TD, DMA_BIDIRECTIONAL);
td_list = dl_reverse_done_list(ohci);
@@ -1529,7 +1530,8 @@ static int submit_common_msg(struct usb_device *dev, unsigned long pipe, void *b
dev->status = stat;
dev->act_len = urb->actual_length;
- dma_inv_range((unsigned long)buffer, (unsigned long)(buffer + transfer_len));
+ dma_sync_single_for_cpu((unsigned long)buffer, transfer_len,
+ DMA_BIDIRECTIONAL);
pkt_print(urb, dev, pipe, buffer, transfer_len,
setup, "RET(ctlr)", usb_pipein(pipe));
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 26/27] ARM: bcm2835: mbox: convert to streaming DMA ops
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (27 preceding siblings ...)
2015-03-05 21:50 ` [PATCH v2 25/27] usb: host: ohci: " Lucas Stach
@ 2015-03-05 21:50 ` Lucas Stach
2015-03-05 21:50 ` [PATCH v2 27/27] ARM: MMU: unexport cache maintenance functions Lucas Stach
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:50 UTC (permalink / raw)
To: barebox
Move to the common streaming DMA ops in order to get rid of
the direct usage of the ARM MMU functions for the cache
maintenance.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
arch/arm/mach-bcm2835/mbox.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-bcm2835/mbox.c b/arch/arm/mach-bcm2835/mbox.c
index 1a80771..9d69bc8 100644
--- a/arch/arm/mach-bcm2835/mbox.c
+++ b/arch/arm/mach-bcm2835/mbox.c
@@ -7,9 +7,9 @@
*/
#include <asm/io.h>
-#include <asm/mmu.h>
#include <common.h>
#include <clock.h>
+#include <dma.h>
#include <mach/mbox.h>
@@ -55,7 +55,8 @@ static int bcm2835_mbox_call_raw(u32 chan, struct bcm2835_mbox_hdr *buffer,
/* Send the request */
val = BCM2835_MBOX_PACK(chan, send);
debug("mbox: TX raw: 0x%08x\n", val);
- dma_flush_range(send, send + buffer->buf_size);
+ dma_sync_single_for_device((unsigned long)send, buffer->buf_size,
+ DMA_BIDIRECTIONAL);
writel(val, ®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) {
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 27/27] ARM: MMU: unexport cache maintenance functions
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
` (28 preceding siblings ...)
2015-03-05 21:50 ` [PATCH v2 26/27] ARM: bcm2835: mbox: " Lucas Stach
@ 2015-03-05 21:50 ` Lucas Stach
29 siblings, 0 replies; 31+ messages in thread
From: Lucas Stach @ 2015-03-05 21:50 UTC (permalink / raw)
To: barebox
Those should only be used internally. All users should rather
use the streaming DMA API, which does proper cache maintenance.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
arch/arm/cpu/mmu.c | 35 ++++++++++++++---------------------
arch/arm/include/asm/mmu.h | 14 --------------
2 files changed, 14 insertions(+), 35 deletions(-)
diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index f1ebd29..ba48010 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -159,6 +159,20 @@ static u32 *find_pte(unsigned long adr)
return &table[(adr >> PAGE_SHIFT) & 0xff];
}
+static void dma_flush_range(unsigned long start, unsigned long end)
+{
+ if (outer_cache.flush_range)
+ outer_cache.flush_range(start, end);
+ __dma_flush_range(start, end);
+}
+
+static void dma_inv_range(unsigned long start, unsigned long end)
+{
+ if (outer_cache.inv_range)
+ outer_cache.inv_range(start, end);
+ __dma_inv_range(start, end);
+}
+
void remap_range(void *_start, size_t size, uint32_t flags)
{
unsigned long start = (unsigned long)_start;
@@ -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)
{
diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h
index 01c20bd..97bb0db 100644
--- a/arch/arm/include/asm/mmu.h
+++ b/arch/arm/include/asm/mmu.h
@@ -27,26 +27,12 @@ static inline void setup_dma_coherent(unsigned long offset)
}
#ifdef CONFIG_MMU
-void dma_clean_range(unsigned long, unsigned long);
-void dma_flush_range(unsigned long, unsigned long);
-void dma_inv_range(unsigned long, unsigned long);
void remap_range(void *_start, size_t size, uint32_t flags);
void *map_io_sections(unsigned long physaddr, void *start, size_t size);
uint32_t mmu_get_pte_cached_flags(void);
uint32_t mmu_get_pte_uncached_flags(void);
#else
-static inline void dma_clean_range(unsigned long s, unsigned long e)
-{
-}
-
-static inline void dma_flush_range(unsigned long s, unsigned long e)
-{
-}
-
-static inline void dma_inv_range(unsigned long s, unsigned long e)
-{
-}
static inline void remap_range(void *_start, size_t size, uint32_t flags)
{
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 31+ messages in thread
end of thread, other threads:[~2015-03-05 21:53 UTC | newest]
Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-05 21:49 [PATCH v2 00/27] Phasing out direct usage of asm/mmu.h on ARM Lucas Stach
2015-03-05 21:49 ` [PATCH v2 01/27] usb: gadget: include common.h in header Lucas Stach
2015-03-05 21:49 ` [PATCH v2 02/27] NIOS2: use dma_addr_t in dma_alloc_coherent Lucas Stach
2015-03-05 21:49 ` [PATCH v2 03/27] MIPS: change dma_alloc/free_coherent to common prototypes Lucas Stach
2015-03-05 21:49 ` [PATCH v2 04/27] ARM: change dma_alloc/free_coherent to match other architectures Lucas Stach
2015-03-05 21:49 ` [PATCH v2 04/27] ARM: move virt<->phys translation to io.h Lucas Stach
2015-03-05 21:49 ` [PATCH v2 05/27] " Lucas Stach
2015-03-05 21:49 ` [PATCH v2 05/27] dma: add streaming DMA ops Lucas Stach
2015-03-05 21:49 ` [PATCH v2 06/27] ARM: change dma_alloc/free_coherent to match other architectures Lucas Stach
2015-03-05 21:50 ` [PATCH v2 06/27] dma: add streaming DMA ops Lucas Stach
2015-03-05 21:50 ` [PATCH v2 07/27] ARM: move DMA alloc functions to dma.h Lucas Stach
2015-03-05 21:50 ` [PATCH v2 08/27] ARM: implement streaming DMA ops Lucas Stach
2015-03-05 21:50 ` [PATCH v2 09/27] AHCI: convert to " Lucas Stach
2015-03-05 21:50 ` [PATCH v2 10/27] MCI: dw-mmc: " Lucas Stach
2015-03-05 21:50 ` [PATCH v2 11/27] MCI: imx: " Lucas Stach
2015-03-05 21:50 ` [PATCH v2 12/27] MCI: tegra-sdmmc: " Lucas Stach
2015-03-05 21:50 ` [PATCH v2 13/27] net: arc-emac: " Lucas Stach
2015-03-05 21:50 ` [PATCH v2 14/27] net: cpsw: " Lucas Stach
2015-03-05 21:50 ` [PATCH v2 15/27] net: at91_ether: " Lucas Stach
2015-03-05 21:50 ` [PATCH v2 16/27] net: davinci_emac: " Lucas Stach
2015-03-05 21:50 ` [PATCH v2 17/27] net: designware: " Lucas Stach
2015-03-05 21:50 ` [PATCH v2 18/27] net: fec: " Lucas Stach
2015-03-05 21:50 ` [PATCH v2 19/27] net: macb: " Lucas Stach
2015-03-05 21:50 ` [PATCH v2 20/27] net: orion-gbe: " Lucas Stach
2015-03-05 21:50 ` [PATCH v2 21/27] net: rtl8169: " Lucas Stach
2015-03-05 21:50 ` [PATCH v2 22/27] net: xgmac: " Lucas Stach
2015-03-05 21:50 ` [PATCH v2 23/27] usb: gadget: fsl_udc: " Lucas Stach
2015-03-05 21:50 ` [PATCH v2 24/27] usb: host: ehci: " Lucas Stach
2015-03-05 21:50 ` [PATCH v2 25/27] usb: host: ohci: " Lucas Stach
2015-03-05 21:50 ` [PATCH v2 26/27] ARM: bcm2835: mbox: " Lucas Stach
2015-03-05 21:50 ` [PATCH v2 27/27] ARM: MMU: unexport cache maintenance functions Lucas Stach
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox