diff mbox

hdat: add support for system and type strings

Message ID 1476088901-25654-1-git-send-email-oohall@gmail.com
State Changes Requested
Headers show

Commit Message

Oliver O'Halloran Oct. 10, 2016, 8:41 a.m. UTC
In P9 the compatible string is supplied by hostboot through the HDAT.
This patch add support for using these strings to set the compatible
property in the device tree rather than using the machine ID number
scheme traditionally used in the HDAT.

Cc: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 hdata/spira.c | 59 ++++++++++++++++++++++++++++++++++++-----------------------
 hdata/spira.h | 11 +++++++++++
 2 files changed, 47 insertions(+), 23 deletions(-)

Comments

Vasant Hegde Oct. 12, 2016, 5:09 a.m. UTC | #1
On 10/10/2016 02:11 PM, Oliver O'Halloran wrote:
> In P9 the compatible string is supplied by hostboot through the HDAT.
> This patch add support for using these strings to set the compatible
> property in the device tree rather than using the machine ID number
> scheme traditionally used in the HDAT.

.../...

> -	sys_type = be32_to_cpu(p->system_type);
> -	switch(sys_type >> 28) {
> -	case 0:
> -		sys_family = "ibm,squadrons";
> -		break;
> -	case 1:
> -		sys_family = "ibm,eclipz";
> -		break;
> -	case 2:
> -		sys_family = "ibm,apollo";
> -		break;
> -	case 3:
> -		sys_family = "ibm,firenze";
> -		break;
> -	default:
> -		sys_family = NULL;
> -		prerror("IPLPARAMS: Unknown system family\n");
> -		break;
> +	if (version >= 0x70) {

Though spec says about version, I'm not sure they have really implemented on 
that version. Better to check for Processor version here.

> +		dt_add_property_strings(dt_root, "compatible",
> +			"ibm,powernv", p->sys_family_str, p->sys_type_str);
> +	} else {
> +		u32 sys_type = be32_to_cpu(p->system_type);
> +		const char *sys_family;
> +
> +		switch(sys_type >> 28) {
> +		case 0:
> +			sys_family = "ibm,squadrons";
> +			break;
> +		case 1:
> +			sys_family = "ibm,eclipz";
> +			break;
> +		case 2:
> +			sys_family = "ibm,apollo";
> +			break;
> +		case 3:
> +		case 4: /* HACK: this is actually "ibm,p9", but there's no
> +			 * useful destinction between the two right now */
> +			sys_family = "ibm,firenze";

We will not enter else block on p9 and hence `case 4` is redundant. May be to 
start with we have to explicitly add "ibm,firenze" in if block itself, until we 
define machine type for P9.


-Vasant
Stewart Smith Dec. 20, 2016, 3:05 a.m. UTC | #2
Oliver O'Halloran <oohall@gmail.com> writes:

> In P9 the compatible string is supplied by hostboot through the HDAT.
> This patch add support for using these strings to set the compatible
> property in the device tree rather than using the machine ID number
> scheme traditionally used in the HDAT.
>
> Cc: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
> ---
>  hdata/spira.c | 59 ++++++++++++++++++++++++++++++++++++-----------------------
>  hdata/spira.h | 11 +++++++++++
>  2 files changed, 47 insertions(+), 23 deletions(-)
>
> diff --git a/hdata/spira.c b/hdata/spira.c
> index 592197e7685b..c83146ab0991 100644
> --- a/hdata/spira.c
> +++ b/hdata/spira.c
> @@ -752,8 +752,6 @@ static void add_nx(void)
>  static void add_iplparams_sys_params(const void *iplp, struct dt_node *node)
>  {
>  	const struct iplparams_sysparams *p;
> -	u32 sys_type;
> -	const char *sys_family;
>  	const struct HDIF_common_hdr *hdif = iplp;
>  	u16 version = be16_to_cpu(hdif->version);
>  
> @@ -772,29 +770,44 @@ static void add_iplparams_sys_params(const void *iplp, struct dt_node *node)
>  
>  	dt_add_property_nstr(node, "ibm,sys-model", p->sys_model, 4);
>  
> -	/* Compatible is 2 entries: ibm,powernv and ibm,<platform>
> +	/*
> +	 * Compatible has up to three entries:
> +	 * 	"ibm,powernv", the system family and system type.
> +	 *
> +	 * On P9 and above the family and type strings come from the HDAT
> +	 * directly. On P8 we find it from the system ID numbers.
>  	 */
> -	sys_type = be32_to_cpu(p->system_type);
> -	switch(sys_type >> 28) {
> -	case 0:
> -		sys_family = "ibm,squadrons";
> -		break;
> -	case 1:
> -		sys_family = "ibm,eclipz";
> -		break;
> -	case 2:
> -		sys_family = "ibm,apollo";
> -		break;
> -	case 3:
> -		sys_family = "ibm,firenze";
> -		break;
> -	default:
> -		sys_family = NULL;
> -		prerror("IPLPARAMS: Unknown system family\n");
> -		break;
> +	if (version >= 0x70) {
> +		dt_add_property_strings(dt_root, "compatible",
> +			"ibm,powernv", p->sys_family_str, p->sys_type_str);
> +	} else {
> +		u32 sys_type = be32_to_cpu(p->system_type);
> +		const char *sys_family;
> +
> +		switch(sys_type >> 28) {
> +		case 0:
> +			sys_family = "ibm,squadrons";
> +			break;
> +		case 1:
> +			sys_family = "ibm,eclipz";
> +			break;
> +		case 2:
> +			sys_family = "ibm,apollo";
> +			break;
> +		case 3:
> +		case 4: /* HACK: this is actually "ibm,p9", but there's no
> +			 * useful destinction between the two right now */
> +			sys_family = "ibm,firenze";
> +			break;
> +		default:
> +			sys_family = NULL;
> +			prerror("IPLPARAMS: Unknown system family\n");
> +			break;
> +		}
> +
> +		dt_add_property_strings(dt_root, "compatible", "ibm,powernv",
> +					sys_family);

I wonder if we should assert that sys_type == the string we expect?

or... could always construct a compatible string and add it as *well* as
what we have in the hdat string...

Just to, you know, be ultra super conservative on ensuring things boot
and work....

>  	}
> -	dt_add_property_strings(dt_root, "compatible", "ibm,powernv",
> -				sys_family);
>  
>  	/* Grab nest frequency when available */
>  	if (version >= 0x005b) {
> diff --git a/hdata/spira.h b/hdata/spira.h
> index eabf7f953ab7..b2863342f5a5 100644
> --- a/hdata/spira.h
> +++ b/hdata/spira.h
> @@ -321,6 +321,17 @@ struct iplparams_sysparams {
>  	uint8_t		hw_page_table_size;	/* >= 0x59 */
>  	__be16		hv_disp_wheel;		/* >= 0x58 */
>  	__be32		nest_freq_mhz;		/* >= 0x5b */
> +	uint8_t 	split_core_mode;	/* >= 0x5c */
> +	uint8_t		reserved1[3];
> +	uint8_t		vendor_name[64];	/* >= 0x5f */
> +	__be16		sys_sec_settings;	/* >= 0x60 */
> +	__be16		tpm_config;
> +	__be16		tmps_per_drawer;
> +	__be16		reserved2;
> +	uint8_t		hw_hash_keys;

This should be uint6_t[64] according to the 10.3g spec?
Oliver O'Halloran Dec. 20, 2016, 5:08 a.m. UTC | #3
On Tue, Dec 20, 2016 at 2:05 PM, Stewart Smith
<stewart@linux.vnet.ibm.com> wrote:
> Oliver O'Halloran <oohall@gmail.com> writes:
>
>> In P9 the compatible string is supplied by hostboot through the HDAT.
>> This patch add support for using these strings to set the compatible
>> property in the device tree rather than using the machine ID number
>> scheme traditionally used in the HDAT.
>>
>> Cc: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
>> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
>> ---
>>  hdata/spira.c | 59 ++++++++++++++++++++++++++++++++++++-----------------------
>>  hdata/spira.h | 11 +++++++++++
>>  2 files changed, 47 insertions(+), 23 deletions(-)
>>
>> diff --git a/hdata/spira.c b/hdata/spira.c
>> index 592197e7685b..c83146ab0991 100644
>> --- a/hdata/spira.c
>> +++ b/hdata/spira.c
>> @@ -752,8 +752,6 @@ static void add_nx(void)
>>  static void add_iplparams_sys_params(const void *iplp, struct dt_node *node)
>>  {
>>       const struct iplparams_sysparams *p;
>> -     u32 sys_type;
>> -     const char *sys_family;
>>       const struct HDIF_common_hdr *hdif = iplp;
>>       u16 version = be16_to_cpu(hdif->version);
>>
>> @@ -772,29 +770,44 @@ static void add_iplparams_sys_params(const void *iplp, struct dt_node *node)
>>
>>       dt_add_property_nstr(node, "ibm,sys-model", p->sys_model, 4);
>>
>> -     /* Compatible is 2 entries: ibm,powernv and ibm,<platform>
>> +     /*
>> +      * Compatible has up to three entries:
>> +      *      "ibm,powernv", the system family and system type.
>> +      *
>> +      * On P9 and above the family and type strings come from the HDAT
>> +      * directly. On P8 we find it from the system ID numbers.
>>        */
>> -     sys_type = be32_to_cpu(p->system_type);
>> -     switch(sys_type >> 28) {
>> -     case 0:
>> -             sys_family = "ibm,squadrons";
>> -             break;
>> -     case 1:
>> -             sys_family = "ibm,eclipz";
>> -             break;
>> -     case 2:
>> -             sys_family = "ibm,apollo";
>> -             break;
>> -     case 3:
>> -             sys_family = "ibm,firenze";
>> -             break;
>> -     default:
>> -             sys_family = NULL;
>> -             prerror("IPLPARAMS: Unknown system family\n");
>> -             break;
>> +     if (version >= 0x70) {
>> +             dt_add_property_strings(dt_root, "compatible",
>> +                     "ibm,powernv", p->sys_family_str, p->sys_type_str);
>> +     } else {
>> +             u32 sys_type = be32_to_cpu(p->system_type);
>> +             const char *sys_family;
>> +
>> +             switch(sys_type >> 28) {
>> +             case 0:
>> +                     sys_family = "ibm,squadrons";
>> +                     break;
>> +             case 1:
>> +                     sys_family = "ibm,eclipz";
>> +                     break;
>> +             case 2:
>> +                     sys_family = "ibm,apollo";
>> +                     break;
>> +             case 3:
>> +             case 4: /* HACK: this is actually "ibm,p9", but there's no
>> +                      * useful destinction between the two right now */
>> +                     sys_family = "ibm,firenze";
>> +                     break;
>> +             default:
>> +                     sys_family = NULL;
>> +                     prerror("IPLPARAMS: Unknown system family\n");
>> +                     break;
>> +             }
>> +
>> +             dt_add_property_strings(dt_root, "compatible", "ibm,powernv",
>> +                                     sys_family);
>
> I wonder if we should assert that sys_type == the string we expect?
>
> or... could always construct a compatible string and add it as *well* as
> what we have in the hdat string...

The issue is that there's no meaningful system_type numbers for
non-IBM systems. We can only rely on the system_type when running on
an IBM system, but we have no way of knowing when we are since this is
the code that's supposed to figure that out.

>>       }
>> -     dt_add_property_strings(dt_root, "compatible", "ibm,powernv",
>> -                             sys_family);
>>
>>       /* Grab nest frequency when available */
>>       if (version >= 0x005b) {
>> diff --git a/hdata/spira.h b/hdata/spira.h
>> index eabf7f953ab7..b2863342f5a5 100644
>> --- a/hdata/spira.h
>> +++ b/hdata/spira.h
>> @@ -321,6 +321,17 @@ struct iplparams_sysparams {
>>       uint8_t         hw_page_table_size;     /* >= 0x59 */
>>       __be16          hv_disp_wheel;          /* >= 0x58 */
>>       __be32          nest_freq_mhz;          /* >= 0x5b */
>> +     uint8_t         split_core_mode;        /* >= 0x5c */
>> +     uint8_t         reserved1[3];
>> +     uint8_t         vendor_name[64];        /* >= 0x5f */
>> +     __be16          sys_sec_settings;       /* >= 0x60 */
>> +     __be16          tpm_config;
>> +     __be16          tmps_per_drawer;
>> +     __be16          reserved2;
>> +     uint8_t         hw_hash_keys;
>
> This should be uint6_t[64] according to the 10.3g spec?
>
> --
> Stewart Smith
> OPAL Architect, IBM.
>
diff mbox

Patch

diff --git a/hdata/spira.c b/hdata/spira.c
index 592197e7685b..c83146ab0991 100644
--- a/hdata/spira.c
+++ b/hdata/spira.c
@@ -752,8 +752,6 @@  static void add_nx(void)
 static void add_iplparams_sys_params(const void *iplp, struct dt_node *node)
 {
 	const struct iplparams_sysparams *p;
-	u32 sys_type;
-	const char *sys_family;
 	const struct HDIF_common_hdr *hdif = iplp;
 	u16 version = be16_to_cpu(hdif->version);
 
@@ -772,29 +770,44 @@  static void add_iplparams_sys_params(const void *iplp, struct dt_node *node)
 
 	dt_add_property_nstr(node, "ibm,sys-model", p->sys_model, 4);
 
-	/* Compatible is 2 entries: ibm,powernv and ibm,<platform>
+	/*
+	 * Compatible has up to three entries:
+	 * 	"ibm,powernv", the system family and system type.
+	 *
+	 * On P9 and above the family and type strings come from the HDAT
+	 * directly. On P8 we find it from the system ID numbers.
 	 */
-	sys_type = be32_to_cpu(p->system_type);
-	switch(sys_type >> 28) {
-	case 0:
-		sys_family = "ibm,squadrons";
-		break;
-	case 1:
-		sys_family = "ibm,eclipz";
-		break;
-	case 2:
-		sys_family = "ibm,apollo";
-		break;
-	case 3:
-		sys_family = "ibm,firenze";
-		break;
-	default:
-		sys_family = NULL;
-		prerror("IPLPARAMS: Unknown system family\n");
-		break;
+	if (version >= 0x70) {
+		dt_add_property_strings(dt_root, "compatible",
+			"ibm,powernv", p->sys_family_str, p->sys_type_str);
+	} else {
+		u32 sys_type = be32_to_cpu(p->system_type);
+		const char *sys_family;
+
+		switch(sys_type >> 28) {
+		case 0:
+			sys_family = "ibm,squadrons";
+			break;
+		case 1:
+			sys_family = "ibm,eclipz";
+			break;
+		case 2:
+			sys_family = "ibm,apollo";
+			break;
+		case 3:
+		case 4: /* HACK: this is actually "ibm,p9", but there's no
+			 * useful destinction between the two right now */
+			sys_family = "ibm,firenze";
+			break;
+		default:
+			sys_family = NULL;
+			prerror("IPLPARAMS: Unknown system family\n");
+			break;
+		}
+
+		dt_add_property_strings(dt_root, "compatible", "ibm,powernv",
+					sys_family);
 	}
-	dt_add_property_strings(dt_root, "compatible", "ibm,powernv",
-				sys_family);
 
 	/* Grab nest frequency when available */
 	if (version >= 0x005b) {
diff --git a/hdata/spira.h b/hdata/spira.h
index eabf7f953ab7..b2863342f5a5 100644
--- a/hdata/spira.h
+++ b/hdata/spira.h
@@ -321,6 +321,17 @@  struct iplparams_sysparams {
 	uint8_t		hw_page_table_size;	/* >= 0x59 */
 	__be16		hv_disp_wheel;		/* >= 0x58 */
 	__be32		nest_freq_mhz;		/* >= 0x5b */
+	uint8_t 	split_core_mode;	/* >= 0x5c */
+	uint8_t		reserved1[3];
+	uint8_t		vendor_name[64];	/* >= 0x5f */
+	__be16		sys_sec_settings;	/* >= 0x60 */
+	__be16		tpm_config;
+	__be16		tmps_per_drawer;
+	__be16		reserved2;
+	uint8_t		hw_hash_keys;
+	uint8_t		sys_family_str[64];		/* >= 0x70 */
+	uint8_t		sys_type_str[64];
+
 } __packed;
 
 /* Idata index 1: IPL parameters */