From: maobibo <maobibo@loongson.cn>
To: Song Gao <gaosong@loongson.cn>, qemu-devel@nongnu.org
Cc: richard.henderson@linaro.org, philmd@linaro.org
Subject: Re: [PATCH] target/loongarch: Set CSR_PRCFG1 and CSR_PRCFG2 values
Date: Thu, 4 Jul 2024 20:47:53 +0800 [thread overview]
Message-ID: <5d7ff632-4d78-bb81-0969-a1ab656e22bc@loongson.cn> (raw)
In-Reply-To: <20240704111218.712654-1-gaosong@loongson.cn>
On 2024/7/4 下午7:12, Song Gao wrote:
> We set the value of register CSR_PRCFG3, but left out CSR_PRCFG1
> and CSR_PRCFG2. Set CSR_PRCFG1 and CSR_PRCFG2 according to the
> default values of the physical machine.
>
> Signed-off-by: Song Gao <gaosong@loongson.cn>
> ---
> target/loongarch/cpu.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
> index 270f711f11..ad40750701 100644
> --- a/target/loongarch/cpu.c
> +++ b/target/loongarch/cpu.c
> @@ -538,6 +538,12 @@ static void loongarch_cpu_reset_hold(Object *obj, ResetType type)
> env->CSR_MERRCTL = FIELD_DP64(env->CSR_MERRCTL, CSR_MERRCTL, ISMERR, 0);
> env->CSR_TID = cs->cpu_index;
>
> + env->CSR_PRCFG1 = FIELD_DP64(env->CSR_PRCFG1, CSR_PRCFG1, SAVE_NUM, 8);
> + env->CSR_PRCFG1 = FIELD_DP64(env->CSR_PRCFG1, CSR_PRCFG1, TIMER_BITS, 0x2f);
> + env->CSR_PRCFG1 = FIELD_DP64(env->CSR_PRCFG1, CSR_PRCFG1, VSMAX, 7);
> +
> + env->CSR_PRCFG2 = 0x3ffff000;
> +
> env->CSR_PRCFG3 = FIELD_DP64(env->CSR_PRCFG3, CSR_PRCFG3, TLB_TYPE, 2);
> env->CSR_PRCFG3 = FIELD_DP64(env->CSR_PRCFG3, CSR_PRCFG3, MTLB_ENTRY, 63);
> env->CSR_PRCFG3 = FIELD_DP64(env->CSR_PRCFG3, CSR_PRCFG3, STLB_WAYS, 7);
>
For the function, it looks good to me. There are some nits:
For PRCFG1-PRCFG3, it is constant. I thinks it had better be put at cpu
instance_init() or instance_finalize().
Also it is strange that most of cpu_state should be cleared with 0
besides cpucfg/prcfg etc, such as end_reset_fields marker in other
architectures.
Maybe it will better if there is double check with cpu state change
callback such as init/reset etc :)
Regards
Bibo Mao
next prev parent reply other threads:[~2024-07-04 12:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-04 11:12 [PATCH] target/loongarch: Set CSR_PRCFG1 and CSR_PRCFG2 values Song Gao
2024-07-04 12:47 ` maobibo [this message]
2024-07-05 1:56 ` gaosong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5d7ff632-4d78-bb81-0969-a1ab656e22bc@loongson.cn \
--to=maobibo@loongson.cn \
--cc=gaosong@loongson.cn \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).