Skip to contentSkip to conversation

MIPS: BMIPS: fix bmips_wr_vec()

PATCH In review Petri Gynther 4 participants 8 messages May 27, 2015 – May 28, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIPS: BMIPS: fix bmips_wr_vec()

bmips_wr_vec() copies exception vector code from start to dst.

The call to dma_cache_wback() needs to flush (end-start) bytes, starting at dst, from write-back cache to memory.

---
 arch/mips/kernel/smp-bmips.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/smp-bmips.c +1 -1
index fd528d7..336708a 100644
@@ -444,7 +444,7 @@ struct plat_smp_ops bmips5000_smp_ops = {
 static void bmips_wr_vec(unsigned long dst, char *start, char *end)
 {
 	memcpy((void *)dst, start, end - start);
-	dma_cache_wback((unsigned long)start, end - start);
+	dma_cache_wback(dst, end - start);
 	local_flush_icache_range(dst, dst + (end - start));
 	instruction_hazard();
 }
Signature · 1 line
2.2.0.rc0.207.ga3a616c
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Petri Gynther

bmips_wr_vec() copies exception vector code from start to dst.

The call to dma_cache_wback() needs to flush (end-start) bytes, starting at dst, from write-back cache to memory.

Fixes df0ac8a406718 ("MIPS: BMIPS: Add SMP support code for

BMIPS43xx/BMIPS5000")
CC: [email protected] # 3.4+

Quoted 18 lines
---
 arch/mips/kernel/smp-bmips.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/smp-bmips.c +1 -1
index fd528d7..336708a 100644
@@ -444,7 +444,7 @@ struct plat_smp_ops bmips5000_smp_ops = {
 static void bmips_wr_vec(unsigned long dst, char *start, char *end)
 {
 	memcpy((void *)dst, start, end - start);
-	dma_cache_wback((unsigned long)start, end - start);
+	dma_cache_wback(dst, end - start);
 	local_flush_icache_range(dst, dst + (end - start));
 	instruction_hazard();
 }
Signature · 1 line
Florian
Reviewed-by on v1 1/1
#3 lore raw
In reply to Petri Gynther
Quoted 24 lines · Petri Gynther

bmips_wr_vec() copies exception vector code from start to dst.

The call to dma_cache_wback() needs to flush (end-start) bytes, starting at dst, from write-back cache to memory.

---
 arch/mips/kernel/smp-bmips.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/smp-bmips.c +1 -2
index fd528d7..336708a 100644
@@ -444,7 +444,7 @@ struct plat_smp_ops bmips5000_smp_ops = {
 static void bmips_wr_vec(unsigned long dst, char *start, char *end)
 {
        memcpy((void *)dst, start, end - start);
-       dma_cache_wback((unsigned long)start, end - start);
+       dma_cache_wback(dst, end - start);
        local_flush_icache_range(dst, dst + (end - start));
        instruction_hazard();
 }
--
Quoted 1 line

2.2.0.rc0.207.ga3a616c

Thanks Petri for catching this.

#4 lore raw
In reply to Petri Gynther
Quoted 15 lines · Petri Gynther

bmips_wr_vec() copies exception vector code from start to dst.

The call to dma_cache_wback() needs to flush (end-start) bytes, starting at dst, from write-back cache to memory.

---
 arch/mips/kernel/smp-bmips.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/smp-bmips.c +0 -0
index fd528d7..336708a 100644

arch/mips/kernel/smp-bmips.c struct plat_smp_ops bmips5000_smp_ops = { · line 447

Quoted 5 lines
arch/mips/kernel/smp-bmips.c +1 -1
@@ -444,7 +444,7 @@ struct plat_smp_ops bmips5000_smp_ops = {
 static void bmips_wr_vec(unsigned long dst, char *start, char *end)
 {
 	memcpy((void *)dst, start, end - start);
-	dma_cache_wback((unsigned long)start, end - start);
+	dma_cache_wback(dst, end - start);

dma_cache_wback is a guess what - DMA function. It doesn't handle I-caches at all and on some platforms might actually do nothing at all. or use other optimizations that only work for DMA buffers and it's not SMP aware - nor will it. So if it ever worked for your case then just because you're lucky. This really should use flush_icache_range which also conveniently for your code takes an end pointer as argument.

Ralf

#2 lore raw
In reply to Florian Fainelli
Quoted 6 lines · Florian Fainelli
Quoted 5 lines · Petri Gynther

bmips_wr_vec() copies exception vector code from start to dst.

The call to dma_cache_wback() needs to flush (end-start) bytes, starting at dst, from write-back cache to memory.

Quoted 6 lines
Quoted 1 line
Fixes df0ac8a406718 ("MIPS: BMIPS: Add SMP support code for

BMIPS43xx/BMIPS5000")
CC: [email protected] # 3.4+

Actually 3.3+ I think.

Ralf

#5 lore raw
In reply to Ralf Baechle
Quoted 21 lines · Ralf Baechle
Quoted 19 lines · Petri Gynther

bmips_wr_vec() copies exception vector code from start to dst.

The call to dma_cache_wback() needs to flush (end-start) bytes, starting at dst, from write-back cache to memory.

---
 arch/mips/kernel/smp-bmips.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/smp-bmips.c +0 -1
index fd528d7..336708a 100644
@@ -444,7 +444,7 @@ struct plat_smp_ops bmips5000_smp_ops = {
 static void bmips_wr_vec(unsigned long dst, char *start, char *end)
 {
      memcpy((void *)dst, start, end - start);
-     dma_cache_wback((unsigned long)start, end - start);
Quoted 8 lines

arch/mips/kernel/smp-bmips.c struct plat_smp_ops bmips5000_smp_ops = { · line 447

Quoted 1 line
arch/mips/kernel/smp-bmips.c +1 -0
+     dma_cache_wback(dst, end - start);

dma_cache_wback is a guess what - DMA function. It doesn't handle I-caches at all and on some platforms might actually do nothing at all. or use other optimizations that only work for DMA buffers and it's not SMP aware - nor will it. So if it ever worked for your case then just because you're lucky. This really should use flush_icache_range which also conveniently for your code takes an end pointer as argument.

This flush isn't intended to handle I$. It is intended to flush the newly written code all the way out to DRAM (not just to L2) so that it can be executed through an uncached kseg1 alias. On initial boot, a BMIPS secondary CPU comes up with its I$ disabled (5000) or in an uninitialized state (43xx).

#6 lore raw
Quoted 31 lines · Kevin Cernekee
Quoted 21 lines · Ralf Baechle
Quoted 19 lines · Petri Gynther

bmips_wr_vec() copies exception vector code from start to dst.

The call to dma_cache_wback() needs to flush (end-start) bytes, starting at dst, from write-back cache to memory.

---
 arch/mips/kernel/smp-bmips.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/smp-bmips.c +0 -1
index fd528d7..336708a 100644
@@ -444,7 +444,7 @@ struct plat_smp_ops bmips5000_smp_ops = {
 static void bmips_wr_vec(unsigned long dst, char *start, char *end)
 {
      memcpy((void *)dst, start, end - start);
-     dma_cache_wback((unsigned long)start, end - start);
Quoted 8 lines

arch/mips/kernel/smp-bmips.c struct plat_smp_ops bmips5000_smp_ops = { · line 447

Quoted 1 line
arch/mips/kernel/smp-bmips.c +1 -0
+     dma_cache_wback(dst, end - start);

dma_cache_wback is a guess what - DMA function. It doesn't handle I-caches at all and on some platforms might actually do nothing at all. or use other optimizations that only work for DMA buffers and it's not SMP aware - nor will it. So if it ever worked for your case then just because you're lucky. This really should use flush_icache_range which also conveniently for your code takes an end pointer as argument.

Quoted 5 lines

This flush isn't intended to handle I$. It is intended to flush the newly written code all the way out to DRAM (not just to L2) so that it can be executed through an uncached kseg1 alias. On initial boot, a BMIPS secondary CPU comes up with its I$ disabled (5000) or in an uninitialized state (43xx).

Just wondering if we should just use:
r4k_blast_dcache()
r4k_blast_scache()

here instead? r4k_blast_dcache() is currently exported, but r4k_blast_scache() is not.

#7 lore raw
Quoted 38 lines · Petri Gynther
Quoted 31 lines · Kevin Cernekee
Quoted 21 lines · Ralf Baechle
Quoted 19 lines · Petri Gynther

bmips_wr_vec() copies exception vector code from start to dst.

The call to dma_cache_wback() needs to flush (end-start) bytes, starting at dst, from write-back cache to memory.

---
 arch/mips/kernel/smp-bmips.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/smp-bmips.c +0 -1
index fd528d7..336708a 100644
@@ -444,7 +444,7 @@ struct plat_smp_ops bmips5000_smp_ops = {
 static void bmips_wr_vec(unsigned long dst, char *start, char *end)
 {
      memcpy((void *)dst, start, end - start);
-     dma_cache_wback((unsigned long)start, end - start);
Quoted 8 lines

arch/mips/kernel/smp-bmips.c struct plat_smp_ops bmips5000_smp_ops = { · line 447

Quoted 1 line
arch/mips/kernel/smp-bmips.c +1 -0
+     dma_cache_wback(dst, end - start);

dma_cache_wback is a guess what - DMA function. It doesn't handle I-caches at all and on some platforms might actually do nothing at all. or use other optimizations that only work for DMA buffers and it's not SMP aware - nor will it. So if it ever worked for your case then just because you're lucky. This really should use flush_icache_range which also conveniently for your code takes an end pointer as argument.

Quoted 5 lines

This flush isn't intended to handle I$. It is intended to flush the newly written code all the way out to DRAM (not just to L2) so that it can be executed through an uncached kseg1 alias. On initial boot, a BMIPS secondary CPU comes up with its I$ disabled (5000) or in an uninitialized state (43xx).

Quoted 6 lines

Just wondering if we should just use:
r4k_blast_dcache()
r4k_blast_scache()

here instead? r4k_blast_dcache() is currently exported, but r4k_blast_scache() is not.

There's simply no user of r4k_blast_scache() outside of c-r4k.c so far but I don't mind exporting the function. But Kevin has already convinced me that this is a special use for which none of the existing functions fits well and it certainly isn't worth to invent a new flush function for this use, so I've applied your patch.

Ralf