diff mbox series

[v5,4/5] target/ppc: Introduce 'PowerPCCPUClass::logical_pvr'

Message ID 20240606121657.254308-5-adityag@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series Power11 support for QEMU [PSeries] | expand

Commit Message

Aditya Gupta June 6, 2024, 12:16 p.m. UTC
Introduce 'PnvChipClass::logical_pvr' to know corresponding logical PVR
of a PowerPC CPU.
This helps to have a one-to-one mapping between PVR and logical PVR for
a CPU, and used in a later commit to handle cases where PCR of two
generations of Power chip is same, which causes regressions with compat-mode.

Cc: Cédric Le Goater <clg@kaod.org>
Cc: Daniel Henrique Barboza <danielhb413@gmail.com>
Cc: Harsh Prateek Bora <harshpb@linux.ibm.com>
Cc: Mahesh J Salgaonkar <mahesh@linux.ibm.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Aditya Gupta <adityag@linux.ibm.com>
---
 target/ppc/cpu.h      | 1 +
 target/ppc/cpu_init.c | 5 +++++
 2 files changed, 6 insertions(+)

Comments

Nicholas Piggin July 23, 2024, 5:13 a.m. UTC | #1
On Thu Jun 6, 2024 at 10:16 PM AEST, Aditya Gupta wrote:
> Introduce 'PnvChipClass::logical_pvr' to know corresponding logical PVR
> of a PowerPC CPU.
> This helps to have a one-to-one mapping between PVR and logical PVR for
> a CPU, and used in a later commit to handle cases where PCR of two
> generations of Power chip is same, which causes regressions with compat-mode.

>
> Cc: Cédric Le Goater <clg@kaod.org>
> Cc: Daniel Henrique Barboza <danielhb413@gmail.com>
> Cc: Harsh Prateek Bora <harshpb@linux.ibm.com>
> Cc: Mahesh J Salgaonkar <mahesh@linux.ibm.com>
> Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
> Cc: Nicholas Piggin <npiggin@gmail.com>
> Signed-off-by: Aditya Gupta <adityag@linux.ibm.com>
> ---
>  target/ppc/cpu.h      | 1 +
>  target/ppc/cpu_init.c | 5 +++++
>  2 files changed, 6 insertions(+)
>
> diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
> index 2015e603d4e0..ff43e3645228 100644
> --- a/target/ppc/cpu.h
> +++ b/target/ppc/cpu.h
> @@ -1504,6 +1504,7 @@ struct PowerPCCPUClass {
>      void (*parent_parse_features)(const char *type, char *str, Error **errp);
>  
>      uint32_t pvr;
> +    uint32_t logical_pvr;
>      /*
>       * If @best is false, match if pcc is in the family of pvr
>       * Else match only if pcc is the best match for pvr in this family.

I suppose so. pvr_match() is for hardware PVR, not logical. It's all
quite a maze.

I'll get you to re-post the series with paches 4-5 reordered ahead
of the power11 addition, so you can do the renaming and tweaking :)
Maybe call this 'spapr_logical_pvr' so it's clearly separate from the
other pvr matching.

Reviewed-by: Nicholas Piggin <npiggin@gmail.com>

> diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
> index 9aa098935d05..50f136cca7f0 100644
> --- a/target/ppc/cpu_init.c
> +++ b/target/ppc/cpu_init.c
> @@ -6152,6 +6152,7 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)
>  
>      dc->fw_name = "PowerPC,POWER7";
>      dc->desc = "POWER7";
> +    pcc->logical_pvr = CPU_POWERPC_LOGICAL_2_06_PLUS;
>      pcc->pvr_match = ppc_pvr_match_power7;
>      pcc->pcr_mask = PCR_VEC_DIS | PCR_VSX_DIS | PCR_COMPAT_2_05;
>      pcc->pcr_supported = PCR_COMPAT_2_06 | PCR_COMPAT_2_05;
> @@ -6315,6 +6316,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)
>  
>      dc->fw_name = "PowerPC,POWER8";
>      dc->desc = "POWER8";
> +    pcc->logical_pvr = CPU_POWERPC_LOGICAL_2_07;
>      pcc->pvr_match = ppc_pvr_match_power8;
>      pcc->pcr_mask = PCR_TM_DIS | PCR_COMPAT_2_06 | PCR_COMPAT_2_05;
>      pcc->pcr_supported = PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_COMPAT_2_05;
> @@ -6508,6 +6510,7 @@ POWERPC_FAMILY(POWER9)(ObjectClass *oc, void *data)
>  
>      dc->fw_name = "PowerPC,POWER9";
>      dc->desc = "POWER9";
> +    pcc->logical_pvr = CPU_POWERPC_LOGICAL_3_00;
>      pcc->pvr_match = ppc_pvr_match_power9;
>      pcc->pcr_mask = POWERPC_POWER9_PCC_PCR_MASK;
>      pcc->pcr_supported = POWERPC_POWER9_PCC_PCR_SUPPORTED;
> @@ -6642,6 +6645,7 @@ POWERPC_FAMILY(POWER10)(ObjectClass *oc, void *data)
>  
>      dc->fw_name = "PowerPC,POWER10";
>      dc->desc = "POWER10";
> +    pcc->logical_pvr = CPU_POWERPC_LOGICAL_3_10;
>      pcc->pvr_match = ppc_pvr_match_power10;
>      pcc->pcr_mask = POWERPC_POWER10_PCC_PCR_MASK;
>      pcc->pcr_supported = POWERPC_POWER10_PCC_PCR_SUPPORTED;
> @@ -6696,6 +6700,7 @@ POWERPC_FAMILY(POWER11)(ObjectClass *oc, void *data)
>  
>      dc->fw_name = "PowerPC,POWER11";
>      dc->desc = "POWER11";
> +    pcc->logical_pvr = CPU_POWERPC_LOGICAL_3_10_PLUS;
>      pcc->pvr_match = ppc_pvr_match_power11;
>      pcc->pcr_mask = POWERPC_POWER10_PCC_PCR_MASK;
>      pcc->pcr_supported = POWERPC_POWER10_PCC_PCR_SUPPORTED;
Aditya Gupta July 23, 2024, 5:42 a.m. UTC | #2
On 23/07/24 10:43, Nicholas Piggin wrote:
> On Thu Jun 6, 2024 at 10:16 PM AEST, Aditya Gupta wrote:
>> Introduce 'PnvChipClass::logical_pvr' to know corresponding logical PVR
>> of a PowerPC CPU.
>> This helps to have a one-to-one mapping between PVR and logical PVR for
>> a CPU, and used in a later commit to handle cases where PCR of two
>> generations of Power chip is same, which causes regressions with compat-mode.
>> Cc: Cédric Le Goater <clg@kaod.org>
>> Cc: Daniel Henrique Barboza <danielhb413@gmail.com>
>> Cc: Harsh Prateek Bora <harshpb@linux.ibm.com>
>> Cc: Mahesh J Salgaonkar <mahesh@linux.ibm.com>
>> Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
>> Cc: Nicholas Piggin <npiggin@gmail.com>
>> Signed-off-by: Aditya Gupta <adityag@linux.ibm.com>
>> ---
>>   target/ppc/cpu.h      | 1 +
>>   target/ppc/cpu_init.c | 5 +++++
>>   2 files changed, 6 insertions(+)
>>
>> diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
>> index 2015e603d4e0..ff43e3645228 100644
>> --- a/target/ppc/cpu.h
>> +++ b/target/ppc/cpu.h
>> @@ -1504,6 +1504,7 @@ struct PowerPCCPUClass {
>>       void (*parent_parse_features)(const char *type, char *str, Error **errp);
>>   
>>       uint32_t pvr;
>> +    uint32_t logical_pvr;
>>       /*
>>        * If @best is false, match if pcc is in the family of pvr
>>        * Else match only if pcc is the best match for pvr in this family.
> I suppose so. pvr_match() is for hardware PVR, not logical. It's all
> quite a maze.
>
> I'll get you to re-post the series with paches 4-5 reordered ahead
> of the power11 addition, so you can do the renaming and tweaking :)
> Maybe call this 'spapr_logical_pvr' so it's clearly separate from the
> other pvr matching.

Sure, I am reading your reviews about the renaming. Will do them, should 
send next version by today.

Thanks for all reviews !


- Aditya Gupta

>
> Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
>
>> diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
>> index 9aa098935d05..50f136cca7f0 100644
>> --- a/target/ppc/cpu_init.c
>> +++ b/target/ppc/cpu_init.c
>> @@ -6152,6 +6152,7 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)
>>   
>>       dc->fw_name = "PowerPC,POWER7";
>>       dc->desc = "POWER7";
>> +    pcc->logical_pvr = CPU_POWERPC_LOGICAL_2_06_PLUS;
>>       pcc->pvr_match = ppc_pvr_match_power7;
>>       pcc->pcr_mask = PCR_VEC_DIS | PCR_VSX_DIS | PCR_COMPAT_2_05;
>>       pcc->pcr_supported = PCR_COMPAT_2_06 | PCR_COMPAT_2_05;
>> @@ -6315,6 +6316,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)
>>   
>>       dc->fw_name = "PowerPC,POWER8";
>>       dc->desc = "POWER8";
>> +    pcc->logical_pvr = CPU_POWERPC_LOGICAL_2_07;
>>       pcc->pvr_match = ppc_pvr_match_power8;
>>       pcc->pcr_mask = PCR_TM_DIS | PCR_COMPAT_2_06 | PCR_COMPAT_2_05;
>>       pcc->pcr_supported = PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_COMPAT_2_05;
>> @@ -6508,6 +6510,7 @@ POWERPC_FAMILY(POWER9)(ObjectClass *oc, void *data)
>>   
>>       dc->fw_name = "PowerPC,POWER9";
>>       dc->desc = "POWER9";
>> +    pcc->logical_pvr = CPU_POWERPC_LOGICAL_3_00;
>>       pcc->pvr_match = ppc_pvr_match_power9;
>>       pcc->pcr_mask = POWERPC_POWER9_PCC_PCR_MASK;
>>       pcc->pcr_supported = POWERPC_POWER9_PCC_PCR_SUPPORTED;
>> @@ -6642,6 +6645,7 @@ POWERPC_FAMILY(POWER10)(ObjectClass *oc, void *data)
>>   
>>       dc->fw_name = "PowerPC,POWER10";
>>       dc->desc = "POWER10";
>> +    pcc->logical_pvr = CPU_POWERPC_LOGICAL_3_10;
>>       pcc->pvr_match = ppc_pvr_match_power10;
>>       pcc->pcr_mask = POWERPC_POWER10_PCC_PCR_MASK;
>>       pcc->pcr_supported = POWERPC_POWER10_PCC_PCR_SUPPORTED;
>> @@ -6696,6 +6700,7 @@ POWERPC_FAMILY(POWER11)(ObjectClass *oc, void *data)
>>   
>>       dc->fw_name = "PowerPC,POWER11";
>>       dc->desc = "POWER11";
>> +    pcc->logical_pvr = CPU_POWERPC_LOGICAL_3_10_PLUS;
>>       pcc->pvr_match = ppc_pvr_match_power11;
>>       pcc->pcr_mask = POWERPC_POWER10_PCC_PCR_MASK;
>>       pcc->pcr_supported = POWERPC_POWER10_PCC_PCR_SUPPORTED;
diff mbox series

Patch

diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index 2015e603d4e0..ff43e3645228 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -1504,6 +1504,7 @@  struct PowerPCCPUClass {
     void (*parent_parse_features)(const char *type, char *str, Error **errp);
 
     uint32_t pvr;
+    uint32_t logical_pvr;
     /*
      * If @best is false, match if pcc is in the family of pvr
      * Else match only if pcc is the best match for pvr in this family.
diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index 9aa098935d05..50f136cca7f0 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -6152,6 +6152,7 @@  POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)
 
     dc->fw_name = "PowerPC,POWER7";
     dc->desc = "POWER7";
+    pcc->logical_pvr = CPU_POWERPC_LOGICAL_2_06_PLUS;
     pcc->pvr_match = ppc_pvr_match_power7;
     pcc->pcr_mask = PCR_VEC_DIS | PCR_VSX_DIS | PCR_COMPAT_2_05;
     pcc->pcr_supported = PCR_COMPAT_2_06 | PCR_COMPAT_2_05;
@@ -6315,6 +6316,7 @@  POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)
 
     dc->fw_name = "PowerPC,POWER8";
     dc->desc = "POWER8";
+    pcc->logical_pvr = CPU_POWERPC_LOGICAL_2_07;
     pcc->pvr_match = ppc_pvr_match_power8;
     pcc->pcr_mask = PCR_TM_DIS | PCR_COMPAT_2_06 | PCR_COMPAT_2_05;
     pcc->pcr_supported = PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_COMPAT_2_05;
@@ -6508,6 +6510,7 @@  POWERPC_FAMILY(POWER9)(ObjectClass *oc, void *data)
 
     dc->fw_name = "PowerPC,POWER9";
     dc->desc = "POWER9";
+    pcc->logical_pvr = CPU_POWERPC_LOGICAL_3_00;
     pcc->pvr_match = ppc_pvr_match_power9;
     pcc->pcr_mask = POWERPC_POWER9_PCC_PCR_MASK;
     pcc->pcr_supported = POWERPC_POWER9_PCC_PCR_SUPPORTED;
@@ -6642,6 +6645,7 @@  POWERPC_FAMILY(POWER10)(ObjectClass *oc, void *data)
 
     dc->fw_name = "PowerPC,POWER10";
     dc->desc = "POWER10";
+    pcc->logical_pvr = CPU_POWERPC_LOGICAL_3_10;
     pcc->pvr_match = ppc_pvr_match_power10;
     pcc->pcr_mask = POWERPC_POWER10_PCC_PCR_MASK;
     pcc->pcr_supported = POWERPC_POWER10_PCC_PCR_SUPPORTED;
@@ -6696,6 +6700,7 @@  POWERPC_FAMILY(POWER11)(ObjectClass *oc, void *data)
 
     dc->fw_name = "PowerPC,POWER11";
     dc->desc = "POWER11";
+    pcc->logical_pvr = CPU_POWERPC_LOGICAL_3_10_PLUS;
     pcc->pvr_match = ppc_pvr_match_power11;
     pcc->pcr_mask = POWERPC_POWER10_PCC_PCR_MASK;
     pcc->pcr_supported = POWERPC_POWER10_PCC_PCR_SUPPORTED;