mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] LoongArch: Update the flush cache policy
@ 2024-05-06  9:24 Li Jun
  2024-05-06  9:28 ` Xi Ruoyao
  2024-05-07  6:06 ` kernel test robot
  0 siblings, 2 replies; 9+ messages in thread
From: Li Jun @ 2024-05-06  9:24 UTC (permalink / raw)
  To: chenhuacai, kernel, lvjianmin, dongbiao, zhangbaoqi
  Cc: lijun01, loongarch, linux-kernel

fix when LoongArch s3 resume, Can't find image information

Signed-off-by: Li Jun <lijun01@kylinos.cn>
Signed-off-by: Baoqi Zhang <zhangbaoqi@loongson.cn>
Signed-off-by: Jianmin Lv <lvjianmin@loongson.cn>
Signed-off-by: Biao Dong <dongbiao@loongson.cn>
---
 arch/loongarch/mm/cache.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/arch/loongarch/mm/cache.c b/arch/loongarch/mm/cache.c
index 6be04d36ca07..52872fa0e5d8 100644
--- a/arch/loongarch/mm/cache.c
+++ b/arch/loongarch/mm/cache.c
@@ -63,6 +63,28 @@ static void flush_cache_leaf(unsigned int leaf)
 	} while (--nr_nodes > 0);
 }
 
+static void flush_cache_last_level(unsigned int leaf)
+{
+	u64 addr;
+	int i, j, nr_nodes, way_size;
+	struct cache_desc *cdesc = current_cpu_data.cache_leaves + leaf;
+
+	nr_nodes = loongson_sysconf.nr_nodes;
+
+	addr = CSR_DMW1_BASE;
+	iocsr_write32(0x1, 0x280);
+	way_size = cdesc->sets * cdesc->linesz;
+	do {
+		for (i = 0; i < (cdesc->ways * 3); i++) {
+			for (j = 0; j < (cdesc->sets); j++) {
+				*(volatile u32 *)addr;
+				addr += cdesc->linesz;
+			}
+		}
+		addr += 0x100000000000;
+	} while (--nr_nodes > 0);
+}
+
 asmlinkage __visible void __flush_cache_all(void)
 {
 	int leaf;
@@ -71,7 +93,7 @@ asmlinkage __visible void __flush_cache_all(void)
 
 	leaf = cache_present - 1;
 	if (cache_inclusive(cdesc + leaf)) {
-		flush_cache_leaf(leaf);
+		flush_cache_last_level(leaf);
 		return;
 	}
 
-- 
2.34.1


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

end of thread, other threads:[~2024-05-07  7:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-06  9:24 [PATCH] LoongArch: Update the flush cache policy Li Jun
2024-05-06  9:28 ` Xi Ruoyao
2024-05-06 10:08   ` lijun
2024-05-06 10:17     ` Xi Ruoyao
2024-05-07  0:53       ` lijun
2024-05-07  3:55         ` Xi Ruoyao
2024-05-07  6:38           ` lijun
2024-05-07  7:48             ` Xi Ruoyao
2024-05-07  6:06 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®