linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] csky: syscache: Fixup duplicate cache flush
@ 2021-05-04  7:14 guoren
  2021-05-04 17:21 ` Randy Dunlap
  0 siblings, 1 reply; 2+ messages in thread
From: guoren @ 2021-05-04  7:14 UTC (permalink / raw)
  To: guoren, arnd; +Cc: linux-kernel, linux-csky, linux-arch, Guo Ren, Randy Dunlap

From: Guo Ren <guoren@linux.alibaba.com>

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")
Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Arnd Bergmann <arnd@arndb.de>
---
 arch/csky/mm/syscache.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/arch/csky/mm/syscache.c b/arch/csky/mm/syscache.c
index 4e51d63..a7b53b0 100644
--- a/arch/csky/mm/syscache.c
+++ b/arch/csky/mm/syscache.c
@@ -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;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] csky: syscache: Fixup duplicate cache flush
  2021-05-04  7:14 [PATCH] csky: syscache: Fixup duplicate cache flush guoren
@ 2021-05-04 17:21 ` Randy Dunlap
  0 siblings, 0 replies; 2+ messages in thread
From: Randy Dunlap @ 2021-05-04 17:21 UTC (permalink / raw)
  To: guoren, arnd; +Cc: linux-kernel, linux-csky, linux-arch, Guo Ren

On 5/4/21 12:14 AM, guoren@kernel.org wrote:
> From: Guo Ren <guoren@linux.alibaba.com>
> 
> 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")
> Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
> Cc: Randy Dunlap <rdunlap@infradead.org>
> Cc: Arnd Bergmann <arnd@arndb.de>

Acked-by: Randy Dunlap <rdunlap@infradead.org>

more below:

> ---
>  arch/csky/mm/syscache.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/csky/mm/syscache.c b/arch/csky/mm/syscache.c
> index 4e51d63..a7b53b0 100644
> --- a/arch/csky/mm/syscache.c
> +++ b/arch/csky/mm/syscache.c
> @@ -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;

I think the above would be more readable as:

		if (cache != BCACHE)
			break;
		fallthrough;

fwiw.

> +	case ICACHE:
> +		flush_icache_mm_range(current->mm,
> +				(unsigned long)addr,
> +				(unsigned long)addr + bytes);
>  		break;
>  	default:
>  		return -EINVAL;
> 

thanks.
-- 
~Randy


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-04 17:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-04  7:14 [PATCH] csky: syscache: Fixup duplicate cache flush guoren
2021-05-04 17:21 ` Randy Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).