diff mbox

[RFC] opal: Extract sw checkstop fir address from HDAT.

Message ID 150289150546.16215.15391010178561823123.stgit@jupiter.in.ibm.com
State Superseded
Headers show

Commit Message

Mahesh J Salgaonkar Aug. 16, 2017, 1:51 p.m. UTC
From: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>

Extract sw checkstop fir address info from HDAT and populate device tree
node ibm,sw-checkstop-fir.

This patch is required for OPAL_CEC_REBOOT2 OPAL call to work as expected
on p9.

This is an RFC patch need to be tested.

Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
---
 hdata/spira.c |   25 ++++++++++++++++++++++++-
 hdata/spira.h |    4 ++++
 2 files changed, 28 insertions(+), 1 deletion(-)

Comments

Vasant Hegde Aug. 21, 2017, 9:19 a.m. UTC | #1
On 08/16/2017 07:21 PM, Mahesh J Salgaonkar wrote:
> From: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
>
> Extract sw checkstop fir address info from HDAT and populate device tree
> node ibm,sw-checkstop-fir.
>
> This patch is required for OPAL_CEC_REBOOT2 OPAL call to work as expected
> on p9.
>
> This is an RFC patch need to be tested.
>
> Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>

I've verified. At least HDAT is getting populated.


hexdump -C ibm,sw-checkstop-fir
00000000  05 01 20 00 00 00 00 1f                           |.. .....|
00000008


Tested-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>

-Vasant
Stewart Smith Aug. 22, 2017, 1:51 a.m. UTC | #2
Vasant Hegde <hegdevasant@linux.vnet.ibm.com> writes:
> On 08/16/2017 07:21 PM, Mahesh J Salgaonkar wrote:
>> From: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
>>
>> Extract sw checkstop fir address info from HDAT and populate device tree
>> node ibm,sw-checkstop-fir.
>>
>> This patch is required for OPAL_CEC_REBOOT2 OPAL call to work as expected
>> on p9.
>>
>> This is an RFC patch need to be tested.
>>
>> Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
>
> I've verified. At least HDAT is getting populated.
>
>
> hexdump -C ibm,sw-checkstop-fir
> 00000000  05 01 20 00 00 00 00 1f                           |.. .....|
> 00000008

Mahesh - let me know when this is no longer RFC, I know a bunch of folk
are waiting on this.
Mahesh J Salgaonkar Aug. 22, 2017, 2:41 a.m. UTC | #3
On 08/22/2017 07:21 AM, Stewart Smith wrote:
> Vasant Hegde <hegdevasant@linux.vnet.ibm.com> writes:
>> On 08/16/2017 07:21 PM, Mahesh J Salgaonkar wrote:
>>> From: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
>>>
>>> Extract sw checkstop fir address info from HDAT and populate device tree
>>> node ibm,sw-checkstop-fir.
>>>
>>> This patch is required for OPAL_CEC_REBOOT2 OPAL call to work as expected
>>> on p9.
>>>
>>> This is an RFC patch need to be tested.
>>>
>>> Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
>>
>> I've verified. At least HDAT is getting populated.
>>
>>
>> hexdump -C ibm,sw-checkstop-fir
>> 00000000  05 01 20 00 00 00 00 1f                           |.. .....|
>> 00000008
> 
> Mahesh - let me know when this is no longer RFC, I know a bunch of folk
> are waiting on this.
> 

Stewart, This patch is working as per expectation. No further changes
are required from OPAL side. I have respin this patch with minor changes
in patch description at http://patchwork.ozlabs.org/patch/804235/

Thanks,
-Mahesh.
diff mbox

Patch

diff --git a/hdata/spira.c b/hdata/spira.c
index d5e6984..676daf9 100644
--- a/hdata/spira.c
+++ b/hdata/spira.c
@@ -425,9 +425,10 @@  static bool add_xscom_sppcrd(uint64_t xscom_base)
 	for_each_ntuple_idx(&spira.ntuples.proc_chip, hdif, i,
 			    SPPCRD_HDIF_SIG) {
 		const struct sppcrd_chip_info *cinfo;
+		unsigned int csize;
 		u32 ve, version;
 
-		cinfo = HDIF_get_idata(hdif, SPPCRD_IDATA_CHIP_INFO, NULL);
+		cinfo = HDIF_get_idata(hdif, SPPCRD_IDATA_CHIP_INFO, &csize);
 		if (!CHECK_SPPTR(cinfo)) {
 			prerror("XSCOM: Bad ChipID data %d\n", i);
 			continue;
@@ -487,6 +488,28 @@  static bool add_xscom_sppcrd(uint64_t xscom_base)
 			parse_i2c_devs(hdif, SPPCRD_IDATA_HOST_I2C, np);
 			add_vas_node(np, i);
 		}
+
+		/*
+		 * Add sw checkstop scom address (ibm,sw-checkstop-fir)
+		 *
+		 * The latest HDAT versions have sw checkstop scom address
+		 * info.  But not sure from which version onwards (at least
+		 * HDAT spec do not mention that explicitly). Hence use the
+		 * sppcrd struct size returned by HDIF_get_idata to figure out
+		 * whether it contains sw checkstop scom address info. Also
+		 * check if sw_xstop_fir_scom address is non-zero.
+		 */
+		if ((csize >= (offsetof(struct sppcrd_chip_info,
+					sw_xstop_fir_bitpos) + 1)) &&
+						cinfo->sw_xstop_fir_scom) {
+			__be32 fir_bit = cinfo->sw_xstop_fir_bitpos;
+
+			if (!dt_find_property(dt_root, "ibm,sw-checkstop-fir"))
+				dt_add_property_cells(dt_root,
+					"ibm,sw-checkstop-fir",
+					be32_to_cpu(cinfo->sw_xstop_fir_scom),
+					be32_to_cpu(fir_bit));
+		}
 	}
 
 	return i > 0;
diff --git a/hdata/spira.h b/hdata/spira.h
index 4867b6d..0276d4a 100644
--- a/hdata/spira.h
+++ b/hdata/spira.h
@@ -1035,6 +1035,10 @@  struct sppcrd_chip_info {
 	__be32 capp1_func_state;
 	/* *possibly* from Version 0x20 - check spec */
 	__be32 stop_levels;
+	/* From latest version (possibly 0x21 and later) */
+	__be32 sw_xstop_fir_scom;
+	uint8_t sw_xstop_fir_bitpos;
+	uint8_t	reserved_1[3];
 } __packed;
 
 /* Idata index 1 : Chip TOD */