[U-Boot] [PATCH 0/3] Fix conflicting definitions of flush_dcache

nios2 and a couple of network drivers have been using a non defined API to flush the data cache (flush_dcache(ulong, ulong)), this is problematic since it conflicts with other architectures definitions of flush_dcache.
This series cleans that up by letting the two network drivers use the defined flush_dcache_range(ulong, ulong) API. It also adds this function to the nios2 architecture to avoid breakage.
Stefan Kristiansson (3): net/ethoc: use flush_dcache_range instead of flush_dcache net/altera_tse: use flush_dcache_range instead of flush_dcache nios2: add flush_dcache_range function
arch/nios2/lib/cache.S | 10 ++++++++++ drivers/net/altera_tse.c | 9 ++++++--- drivers/net/ethoc.c | 6 +++--- 3 files changed, 19 insertions(+), 6 deletions(-)

flush_dcache is not declared in the common.h API, flush_dcache_range however is
Signed-off-by: Stefan Kristiansson stefan.kristiansson@saunalahti.fi Cc: Ben Warren biggerbadderben@gmail.com Cc: Thomas Chou thomas@wytron.com.tw --- drivers/net/ethoc.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c index 7ac9025..cb79753 100644 --- a/drivers/net/ethoc.c +++ b/drivers/net/ethoc.c @@ -272,7 +272,7 @@ static int ethoc_init_ring(struct eth_device *dev) if (i == priv->num_rx - 1) bd.stat |= RX_BD_WRAP;
- flush_dcache(bd.addr, PKTSIZE_ALIGN); + flush_dcache_range(bd.addr, bd.addr + PKTSIZE_ALIGN); ethoc_write_bd(dev, priv->num_tx + i, &bd); }
@@ -377,7 +377,7 @@ static int ethoc_rx(struct eth_device *dev, int limit) }
/* clear the buffer descriptor so it can be reused */ - flush_dcache(bd.addr, PKTSIZE_ALIGN); + flush_dcache_range(bd.addr, bd.addr + PKTSIZE_ALIGN); bd.stat &= ~RX_BD_STATS; bd.stat |= RX_BD_EMPTY; ethoc_write_bd(dev, entry, &bd); @@ -431,7 +431,7 @@ static int ethoc_send(struct eth_device *dev, volatile void *packet, int length) bd.stat &= ~TX_BD_PAD; bd.addr = (u32)packet;
- flush_dcache(bd.addr, length); + flush_dcache_range(bd.addr, bd.addr + length); bd.stat &= ~(TX_BD_STATS | TX_BD_LEN_MASK); bd.stat |= TX_BD_LEN(length); ethoc_write_bd(dev, entry, &bd);

On 11/04/2011 08:38 PM, Stefan Kristiansson wrote:
flush_dcache is not declared in the common.h API, flush_dcache_range however is
Signed-off-by: Stefan Kristianssonstefan.kristiansson@saunalahti.fi Cc: Ben Warrenbiggerbadderben@gmail.com Cc: Thomas Chouthomas@wytron.com.tw
drivers/net/ethoc.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
Acked-by: Thomas Chou thomas@wytron.com.tw
diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c index 7ac9025..cb79753 100644 --- a/drivers/net/ethoc.c +++ b/drivers/net/ethoc.c @@ -272,7 +272,7 @@ static int ethoc_init_ring(struct eth_device *dev) if (i == priv->num_rx - 1) bd.stat |= RX_BD_WRAP;
flush_dcache(bd.addr, PKTSIZE_ALIGN);
ethoc_write_bd(dev, priv->num_tx + i,&bd); }flush_dcache_range(bd.addr, bd.addr + PKTSIZE_ALIGN);
@@ -377,7 +377,7 @@ static int ethoc_rx(struct eth_device *dev, int limit) }
/* clear the buffer descriptor so it can be reused */
flush_dcache(bd.addr, PKTSIZE_ALIGN);
bd.stat&= ~RX_BD_STATS; bd.stat |= RX_BD_EMPTY; ethoc_write_bd(dev, entry,&bd);flush_dcache_range(bd.addr, bd.addr + PKTSIZE_ALIGN);
@@ -431,7 +431,7 @@ static int ethoc_send(struct eth_device *dev, volatile void *packet, int length) bd.stat&= ~TX_BD_PAD; bd.addr = (u32)packet;
- flush_dcache(bd.addr, length);
- flush_dcache_range(bd.addr, bd.addr + length); bd.stat&= ~(TX_BD_STATS | TX_BD_LEN_MASK); bd.stat |= TX_BD_LEN(length); ethoc_write_bd(dev, entry,&bd);

Dear Stefan Kristiansson,
In message 1320410288-15008-2-git-send-email-stefan.kristiansson@saunalahti.fi you wrote:
flush_dcache is not declared in the common.h API, flush_dcache_range however is
Signed-off-by: Stefan Kristiansson stefan.kristiansson@saunalahti.fi Cc: Ben Warren biggerbadderben@gmail.com Cc: Thomas Chou thomas@wytron.com.tw
drivers/net/ethoc.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

flush_dcache is not declared in the common.h API, flush_dcache_range however is
Signed-off-by: Stefan Kristiansson stefan.kristiansson@saunalahti.fi Cc: Ben Warren biggerbadderben@gmail.com Cc: Thomas Chou thomas@wytron.com.tw --- drivers/net/altera_tse.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c index 5b00717..0e6aac7 100644 --- a/drivers/net/altera_tse.c +++ b/drivers/net/altera_tse.c @@ -268,7 +268,8 @@ static int tse_eth_send(struct eth_device *dev, volatile struct alt_sgdma_descriptor *tx_desc_cur = (volatile struct alt_sgdma_descriptor *)&tx_desc[0];
- flush_dcache((unsigned long)packet, length); + flush_dcache_range((unsigned long)packet, + (unsigned long)packet + length); alt_sgdma_construct_descriptor_burst( (volatile struct alt_sgdma_descriptor *)&tx_desc[0], (volatile struct alt_sgdma_descriptor *)&tx_desc[1], @@ -306,7 +307,8 @@ static int tse_eth_rx(struct eth_device *dev) NetReceive(NetRxPackets[0], packet_length);
/* start descriptor again */ - flush_dcache((unsigned long)(NetRxPackets[0]), PKTSIZE_ALIGN); + flush_dcache_range((unsigned long)(NetRxPackets[0]), + (unsigned long)(NetRxPackets[0]) + PKTSIZE_ALIGN); alt_sgdma_construct_descriptor_burst( (volatile struct alt_sgdma_descriptor *)&rx_desc[0], (volatile struct alt_sgdma_descriptor *)&rx_desc[1], @@ -834,7 +836,8 @@ static int tse_eth_init(struct eth_device *dev, bd_t * bd) 0x0 /* channel */ ); debug("Configuring rx desc\n"); - flush_dcache((unsigned long)(NetRxPackets[0]), PKTSIZE_ALIGN); + flush_dcache_range((unsigned long)(NetRxPackets[0]), + (unsigned long)(NetRxPackets[0]) + PKTSIZE_ALIGN); alt_sgdma_construct_descriptor_burst( (volatile struct alt_sgdma_descriptor *)&rx_desc[0], (volatile struct alt_sgdma_descriptor *)&rx_desc[1],

On 11/04/2011 08:38 PM, Stefan Kristiansson wrote:
flush_dcache is not declared in the common.h API, flush_dcache_range however is
Signed-off-by: Stefan Kristianssonstefan.kristiansson@saunalahti.fi Cc: Ben Warrenbiggerbadderben@gmail.com Cc: Thomas Chouthomas@wytron.com.tw
drivers/net/altera_tse.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)
Acked-by: Thomas Chou thomas@wytron.com.tw
diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c index 5b00717..0e6aac7 100644 --- a/drivers/net/altera_tse.c +++ b/drivers/net/altera_tse.c @@ -268,7 +268,8 @@ static int tse_eth_send(struct eth_device *dev, volatile struct alt_sgdma_descriptor *tx_desc_cur = (volatile struct alt_sgdma_descriptor *)&tx_desc[0];
- flush_dcache((unsigned long)packet, length);
- flush_dcache_range((unsigned long)packet,
alt_sgdma_construct_descriptor_burst( (volatile struct alt_sgdma_descriptor *)&tx_desc[0], (volatile struct alt_sgdma_descriptor *)&tx_desc[1],(unsigned long)packet + length);
@@ -306,7 +307,8 @@ static int tse_eth_rx(struct eth_device *dev) NetReceive(NetRxPackets[0], packet_length);
/* start descriptor again */
flush_dcache((unsigned long)(NetRxPackets[0]), PKTSIZE_ALIGN);
flush_dcache_range((unsigned long)(NetRxPackets[0]),
alt_sgdma_construct_descriptor_burst( (volatile struct alt_sgdma_descriptor *)&rx_desc[0], (volatile struct alt_sgdma_descriptor *)&rx_desc[1],(unsigned long)(NetRxPackets[0]) + PKTSIZE_ALIGN);
@@ -834,7 +836,8 @@ static int tse_eth_init(struct eth_device *dev, bd_t * bd) 0x0 /* channel */ ); debug("Configuring rx desc\n");
- flush_dcache((unsigned long)(NetRxPackets[0]), PKTSIZE_ALIGN);
- flush_dcache_range((unsigned long)(NetRxPackets[0]),
alt_sgdma_construct_descriptor_burst( (volatile struct alt_sgdma_descriptor *)&rx_desc[0], (volatile struct alt_sgdma_descriptor *)&rx_desc[1],(unsigned long)(NetRxPackets[0]) + PKTSIZE_ALIGN);

Dear Stefan Kristiansson,
In message 1320410288-15008-3-git-send-email-stefan.kristiansson@saunalahti.fi you wrote:
flush_dcache is not declared in the common.h API, flush_dcache_range however is
Signed-off-by: Stefan Kristiansson stefan.kristiansson@saunalahti.fi Cc: Ben Warren biggerbadderben@gmail.com Cc: Thomas Chou thomas@wytron.com.tw
drivers/net/altera_tse.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

exposes functionality to flush dcache according to the common.h API
Signed-off-by: Stefan Kristiansson stefan.kristiansson@saunalahti.fi Cc: Thomas Chou thomas@wytron.com.tw --- arch/nios2/lib/cache.S | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/arch/nios2/lib/cache.S b/arch/nios2/lib/cache.S index ee3b4b7..b952d0c 100644 --- a/arch/nios2/lib/cache.S +++ b/arch/nios2/lib/cache.S @@ -48,6 +48,16 @@ flush_icache: bltu r4, r5, 1b ret
+ .global flush_dcache_range + +flush_dcache_range: + movhi r8, %hi(CONFIG_SYS_DCACHELINE_SIZE) + ori r8, r8, %lo(CONFIG_SYS_DCACHELINE_SIZE) +0: flushd 0(r4) + add r4, r4, r8 + bltu r4, r5, 0b + ret + .global flush_cache
flush_cache:

On 11/04/2011 08:38 PM, Stefan Kristiansson wrote:
exposes functionality to flush dcache according to the common.h API
Signed-off-by: Stefan Kristianssonstefan.kristiansson@saunalahti.fi Cc: Thomas Chouthomas@wytron.com.tw
arch/nios2/lib/cache.S | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
Hi Stefan,
Applied to nios next branch. Thanks.
Best regards, Thomas
diff --git a/arch/nios2/lib/cache.S b/arch/nios2/lib/cache.S index ee3b4b7..b952d0c 100644 --- a/arch/nios2/lib/cache.S +++ b/arch/nios2/lib/cache.S @@ -48,6 +48,16 @@ flush_icache: bltu r4, r5, 1b ret
- .global flush_dcache_range
+flush_dcache_range:
- movhi r8, %hi(CONFIG_SYS_DCACHELINE_SIZE)
- ori r8, r8, %lo(CONFIG_SYS_DCACHELINE_SIZE)
+0: flushd 0(r4)
add r4, r4, r8
bltu r4, r5, 0b
ret
.global flush_cache
flush_cache:
participants (3)
-
Stefan Kristiansson
-
Thomas Chou
-
Wolfgang Denk