2024-05-07 07:44:28

by lijun

[permalink] [raw]
Subject: [PATCH v2] LoongArch: Update the flush cache policy

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

Signed-off-by: Li Jun <[email protected]>
Signed-off-by: Baoqi Zhang <[email protected]>
Signed-off-by: Jianmin Lv <[email protected]>
Signed-off-by: Biao Dong <[email protected]>
---
arch/loongarch/mm/cache.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/arch/loongarch/mm/cache.c b/arch/loongarch/mm/cache.c
index 6be04d36ca07..89eeb9a97dd5 100644
--- a/arch/loongarch/mm/cache.c
+++ b/arch/loongarch/mm/cache.c
@@ -63,6 +63,27 @@ 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;
+ struct cache_desc *cdesc = current_cpu_data.cache_leaves + leaf;
+
+ nr_nodes = loongson_sysconf.nr_nodes;
+
+ addr = CSR_DMW1_BASE;
+ iocsr_write32(0x1, 0x280);
+ 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 +92,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



2024-05-08 00:45:09

by lijun

[permalink] [raw]
Subject: Re: [PATCH v2] LoongArch: Update the flush cache policy

Superseded.

在 2024/5/7 15:43, Li Jun 写道:
> fix when LoongArch s3 resume, Can't find image information
>
> Signed-off-by: Li Jun <[email protected]>
> Signed-off-by: Baoqi Zhang <[email protected]>
> Signed-off-by: Jianmin Lv <[email protected]>
> Signed-off-by: Biao Dong <[email protected]>
> ---
> arch/loongarch/mm/cache.c | 23 ++++++++++++++++++++++-
> 1 file changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/arch/loongarch/mm/cache.c b/arch/loongarch/mm/cache.c
> index 6be04d36ca07..89eeb9a97dd5 100644
> --- a/arch/loongarch/mm/cache.c
> +++ b/arch/loongarch/mm/cache.c
> @@ -63,6 +63,27 @@ 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;
> + struct cache_desc *cdesc = current_cpu_data.cache_leaves + leaf;
> +
> + nr_nodes = loongson_sysconf.nr_nodes;
> +
> + addr = CSR_DMW1_BASE;
> + iocsr_write32(0x1, 0x280);
> + 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 +92,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;
> }
>