[PATCH v2 03/11] target/xtensa: Finalize config in xtensa_register_core()

Philippe Mathieu-Daudé posted 11 patches 12 months ago
There is a newer version of this series
[PATCH v2 03/11] target/xtensa: Finalize config in xtensa_register_core()
Posted by Philippe Mathieu-Daudé 12 months ago
Make XtensaConfigList::config not const. Only modify
XtensaConfig within xtensa_register_core(), when the
class is registered, not when it is initialized.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
Cc: Max Filippov <jcmvbkbc@gmail.com>
---
 target/xtensa/cpu.h    | 2 +-
 target/xtensa/helper.c | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
index 0e6302c5bd3..8d70bfc0cd4 100644
--- a/target/xtensa/cpu.h
+++ b/target/xtensa/cpu.h
@@ -490,7 +490,7 @@ typedef struct XtensaConfig {
 } XtensaConfig;
 
 typedef struct XtensaConfigList {
-    const XtensaConfig *config;
+    XtensaConfig *config;
     struct XtensaConfigList *next;
 } XtensaConfigList;
 
diff --git a/target/xtensa/helper.c b/target/xtensa/helper.c
index 2978c471c1f..f64699b116d 100644
--- a/target/xtensa/helper.c
+++ b/target/xtensa/helper.c
@@ -173,9 +173,8 @@ static void xtensa_core_class_init(ObjectClass *oc, void *data)
 {
     CPUClass *cc = CPU_CLASS(oc);
     XtensaCPUClass *xcc = XTENSA_CPU_CLASS(oc);
-    XtensaConfig *config = data;
+    const XtensaConfig *config = data;
 
-    xtensa_finalize_config(config);
     xcc->config = config;
 
     /*
@@ -195,6 +194,8 @@ void xtensa_register_core(XtensaConfigList *node)
         .class_data = (void *)node->config,
     };
 
+    xtensa_finalize_config(node->config);
+
     node->next = xtensa_cores;
     xtensa_cores = node;
     type.name = g_strdup_printf(XTENSA_CPU_TYPE_NAME("%s"), node->config->name);
-- 
2.47.1


Re: [PATCH v2 03/11] target/xtensa: Finalize config in xtensa_register_core()
Posted by Richard Henderson 12 months ago
On 2/10/25 05:31, Philippe Mathieu-Daudé wrote:
> Make XtensaConfigList::config not const. Only modify
> XtensaConfig within xtensa_register_core(), when the
> class is registered, not when it is initialized.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> Cc: Max Filippov <jcmvbkbc@gmail.com>
> ---
>   target/xtensa/cpu.h    | 2 +-
>   target/xtensa/helper.c | 5 +++--
>   2 files changed, 4 insertions(+), 3 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~

Re: [PATCH v2 03/11] target/xtensa: Finalize config in xtensa_register_core()
Posted by Max Filippov 12 months ago
On Mon, Feb 10, 2025 at 8:30 AM Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> On 2/10/25 05:31, Philippe Mathieu-Daudé wrote:
> > Make XtensaConfigList::config not const. Only modify
> > XtensaConfig within xtensa_register_core(), when the
> > class is registered, not when it is initialized.
> >
> > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> > ---
> > Cc: Max Filippov <jcmvbkbc@gmail.com>
> > ---
> >   target/xtensa/cpu.h    | 2 +-
> >   target/xtensa/helper.c | 5 +++--
> >   2 files changed, 4 insertions(+), 3 deletions(-)
>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

Acked-by: Max Filippov <jcmvbkbc@gmail.com>

-- 
Thanks.
-- Max