MIPS: BMIPS: fix bmips_wr_vec()
Subsystems (2)
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
@@ -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
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.Signed-off-by Petri Gynther <[email protected]>
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@@ -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
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
Signed-off-by Petri Gynther <[email protected]>Acked-by Florian Fainelli <[email protected]>Fixes df0ac8a406718 ("MIPS: BMIPS: Add SMP support code forBMIPS43xx/BMIPS5000")
CC: [email protected] # 3.4+
Actually 3.3+ I think.
Ralf
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.Signed-off-by Petri Gynther <[email protected]>--- arch/mips/kernel/smp-bmips.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/mips/kernel/smp-bmips.c +1
-2@@ -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.
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.Signed-off-by Petri Gynther <[email protected]>--- arch/mips/kernel/smp-bmips.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/mips/kernel/smp-bmips.c +0
-0
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
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.Signed-off-by Petri Gynther <[email protected]>--- arch/mips/kernel/smp-bmips.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/mips/kernel/smp-bmips.c +0
-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);
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_wbackis 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 useflush_icache_rangewhich 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).
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.Signed-off-by Petri Gynther <[email protected]>--- arch/mips/kernel/smp-bmips.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/mips/kernel/smp-bmips.c +0
-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);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_wbackis 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 useflush_icache_rangewhich 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.
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.Signed-off-by Petri Gynther <[email protected]>--- arch/mips/kernel/smp-bmips.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/mips/kernel/smp-bmips.c +0
-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);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_wbackis 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 useflush_icache_rangewhich 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, butr4k_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