Skip to contentSkip to conversation

csky: syscache: Fixup duplicate cache flush

PATCH In review [email protected] 2 participants 2 messages May 4, 2021

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 csky: syscache: Fixup duplicate cache flush

From: Guo Ren <[email protected]>

The current csky logic of sys_cacheflush is wrong, it'll cause icache flush call dcache flush again. Now fixup it with a conditional "break & fallthrough".

Fixes 997153b9a75c ("csky: Add flush_icache_mm to defer flush icache all")
Fixes 0679d29d3e23 ("csky: fix syscache.c fallthrough warning")
Cc Randy Dunlap <[email protected]>
Cc Arnd Bergmann <[email protected]>
---
 arch/csky/mm/syscache.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
arch/csky/mm/syscache.c +8 -5
index 4e51d63..a7b53b0 100644
@@ -12,15 +12,18 @@ SYSCALL_DEFINE3(cacheflush,
 		int, cache)
 {
 	switch (cache) {
-	case ICACHE:
 	case BCACHE:
-		flush_icache_mm_range(current->mm,
-				(unsigned long)addr,
-				(unsigned long)addr + bytes);
-		fallthrough;
 	case DCACHE:
 		dcache_wb_range((unsigned long)addr,
 				(unsigned long)addr + bytes);
+		if (cache == BCACHE)
+			fallthrough;
+		else
+			break;
+	case ICACHE:
+		flush_icache_mm_range(current->mm,
+				(unsigned long)addr,
+				(unsigned long)addr + bytes);
 		break;
 	default:
 		return -EINVAL;
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · On 5/4/21 12:14 AM, [email protected] wrote:

From: Guo Ren <[email protected]>

The current csky logic of sys_cacheflush is wrong, it'll cause icache flush call dcache flush again. Now fixup it with a conditional "break & fallthrough".

Fixes 997153b9a75c ("csky: Add flush_icache_mm to defer flush icache all")
Fixes 0679d29d3e23 ("csky: fix syscache.c fallthrough warning")
Cc Randy Dunlap <[email protected]>
Cc Arnd Bergmann <[email protected]>

more below:

Quoted 15 lines
---
 arch/csky/mm/syscache.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
arch/csky/mm/syscache.c +0 -2
index 4e51d63..a7b53b0 100644
@@ -12,15 +12,18 @@ SYSCALL_DEFINE3(cacheflush,
 		int, cache)
 {
 	switch (cache) {
-	case ICACHE:
 	case BCACHE:
-		flush_icache_mm_range(current->mm,

arch/csky/mm/syscache.c SYSCALL_DEFINE3(cacheflush, · line 22

Quoted 10 lines
arch/csky/mm/syscache.c +4 -3
-				(unsigned long)addr,
-				(unsigned long)addr + bytes);
-		fallthrough;
 	case DCACHE:
 		dcache_wb_range((unsigned long)addr,
 				(unsigned long)addr + bytes);
+		if (cache == BCACHE)
+			fallthrough;
+		else
+			break;

I think the above would be more readable as:

		if (cache != BCACHE)
			break;
		fallthrough;

fwiw.

arch/csky/mm/syscache.c SYSCALL_DEFINE3(cacheflush, · line 29

Quoted 8 lines
arch/csky/mm/syscache.c +4 -0
+	case ICACHE:
+		flush_icache_mm_range(current->mm,
+				(unsigned long)addr,
+				(unsigned long)addr + bytes);
 		break;
 	default:
 		return -EINVAL;

thanks.

Signature · 1 line
~Randy