Skip to contentSkip to conversation

fsi: occ: Use PutOCCSRAM in circular mode for OCC attention

PATCH In review Andrew Jeffery 3 participants 3 messages Apr 27, 2018 – Apr 30, 2018 FSI

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 fsi: occ: Use PutOCCSRAM in circular mode for OCC attention

We can't do SCOMs from the BMC when the host is booted in secure mode, and without triggering the attention of the OCC our commands won't be processed. Further, the SCOM operation fails, which causes the OCC driver's probe to fail, which leads the BMC to think that the OCC has failed.

We have an alternative to the SCOM though: We can trigger the OCC by writing the correct attention magic in circular buffer mode.

The PutOCCSRAM operation returns the written data length in the response payload before the 0xCODE word, so the condition testing the success of the operation is rearranged.

---

v3:
* Address Matt Spinler's feedback that the address field is ignored in mode 3

Tested on two Witherspoon systems, one with secure-boot enabled and one without

v2:
* Minor typo and documentation cleanups

 drivers/fsi/fsi-occ.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)
drivers/fsi/fsi-occ.c +9 -13
index 45ae13cd7a3d..938601fd7347 100644
@@ -575,19 +575,16 @@ static int occ_putsram(struct device *sbefifo, u32 address, u8 *data,
 static int occ_trigger_attn(struct device *sbefifo)
 {
 	int rc;
-	__be32 buf[6];
+	__be32 buf[7];
 	struct sbefifo_client *client;
 
-	/*
-	 * Magic sequence to do SBE putscom command. SBE will write 8 bytes to
-	 * specified SCOM address.
-	 */
-	buf[0] = cpu_to_be32(0x6);
-	buf[1] = cpu_to_be32(0xa202);
-	buf[2] = 0;
-	buf[3] = cpu_to_be32(0x6D035);
-	buf[4] = cpu_to_be32(0x20010000);	/* trigger occ attention */
-	buf[5] = 0;
+	buf[0] = cpu_to_be32(0x5 + 0x2);        /* Chip-op length in words */
+	buf[1] = cpu_to_be32(0xa404);           /* PutOCCSRAM */
+	buf[2] = cpu_to_be32(0x3);              /* Mode: Circular */
+	buf[3] = cpu_to_be32(0x0);              /* Address: ignored in mode 3 */
+	buf[4] = cpu_to_be32(0x8);              /* Data length in bytes */
+	buf[5] = cpu_to_be32(0x20010000);       /* Trigger OCC attention */
+	buf[6] = 0;
 
 	client = sbefifo_drv_open(sbefifo, 0);
 	if (!client)
@@ -602,8 +599,7 @@ static int occ_trigger_attn(struct device *sbefifo)
 		goto done;
 
 	/* check for good response */
-	if ((be32_to_cpu(buf[0]) != 0xC0DEA202) ||
-	    (be32_to_cpu(buf[1]) & 0x0FFFFFFF))
+	if ((be32_to_cpu(buf[0]) != 8) || (be32_to_cpu(buf[1]) != 0xC0DEA404))
 		rc = -EBADMSG;
 
 done:
Signature · 1 line
2.14.1
Reviewed-by on v3 1/1
#1 lore raw
Quoted 73 lines · Andrew Jeffery

We can't do SCOMs from the BMC when the host is booted in secure mode, and without triggering the attention of the OCC our commands won't be processed. Further, the SCOM operation fails, which causes the OCC driver's probe to fail, which leads the BMC to think that the OCC has failed.

We have an alternative to the SCOM though: We can trigger the OCC by writing the correct attention magic in circular buffer mode.

The PutOCCSRAM operation returns the written data length in the response payload before the 0xCODE word, so the condition testing the success of the operation is rearranged.

---

v3:
* Address Matt Spinler's feedback that the address field is ignored in mode 3

Tested on two Witherspoon systems, one with secure-boot enabled and one without

v2:
* Minor typo and documentation cleanups

 drivers/fsi/fsi-occ.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)
drivers/fsi/fsi-occ.c +1 -3
index 45ae13cd7a3d..938601fd7347 100644
@@ -575,19 +575,16 @@ static int occ_putsram(struct device *sbefifo,
 u32 address, u8 *data,
 static int occ_trigger_attn(struct device *sbefifo)
 {
 	int rc;
-	__be32 buf[6];
+	__be32 buf[7];
 	struct sbefifo_client *client;
 
-	/*
-	 * Magic sequence to do SBE putscom command. SBE will write 8 bytes 

to

drivers/fsi/fsi-occ.c +4 -8
-	 * specified SCOM address.
-	 */
-	buf[0] = cpu_to_be32(0x6);
-	buf[1] = cpu_to_be32(0xa202);
-	buf[2] = 0;
-	buf[3] = cpu_to_be32(0x6D035);
-	buf[4] = cpu_to_be32(0x20010000);	/* trigger occ attention */
-	buf[5] = 0;
+	buf[0] = cpu_to_be32(0x5 + 0x2);        /* Chip-op length in words */
+	buf[1] = cpu_to_be32(0xa404);           /* PutOCCSRAM */
+	buf[2] = cpu_to_be32(0x3);              /* Mode: Circular */
+	buf[3] = cpu_to_be32(0x0);              /* Address: ignored in mode 3 

*/

drivers/fsi/fsi-occ.c +4 -2
+	buf[4] = cpu_to_be32(0x8);              /* Data length in bytes */
+	buf[5] = cpu_to_be32(0x20010000);       /* Trigger OCC attention */
+	buf[6] = 0;
 
 	client = sbefifo_drv_open(sbefifo, 0);
 	if (!client)
@@ -602,8 +599,7 @@ static int occ_trigger_attn(struct device *sbefifo)
 		goto done;
 
 	/* check for good response */
-	if ((be32_to_cpu(buf[0]) != 0xC0DEA202) ||
-	    (be32_to_cpu(buf[1]) & 0x0FFFFFFF))
+	if ((be32_to_cpu(buf[0]) != 8) || (be32_to_cpu(buf[1]) != 
 0xC0DEA404))
 		rc = -EBADMSG;
 

done:

Reviewed-by
#2 lore raw
Quoted 15 lines · Matt Spinler
Quoted 12 lines · Andrew Jeffery

We can't do SCOMs from the BMC when the host is booted in secure mode, and without triggering the attention of the OCC our commands won't be processed. Further, the SCOM operation fails, which causes the OCC driver's probe to fail, which leads the BMC to think that the OCC has failed.

We have an alternative to the SCOM though: We can trigger the OCC by writing the correct attention magic in circular buffer mode.

The PutOCCSRAM operation returns the written data length in the response payload before the 0xCODE word, so the condition testing the success of the operation is rearranged.

Thanks Andrew, looks good.

Quoted 63 lines
Quoted 62 lines

---

v3:
* Address Matt Spinler's feedback that the address field is ignored in mode 3

Tested on two Witherspoon systems, one with secure-boot enabled and one without

v2:
* Minor typo and documentation cleanups

 drivers/fsi/fsi-occ.c | 22 +++++++++-------------

 1 file changed, 9 insertions(+), 13 deletions(-)
drivers/fsi/fsi-occ.c +1 -3
index 45ae13cd7a3d..938601fd7347 100644
@@ -575,19 +575,16 @@ static int occ_putsram(struct device *sbefifo,
 u32 address, u8 *data,
  static int occ_trigger_attn(struct device *sbefifo)
  {
      int rc;
-    __be32 buf[6];
+    __be32 buf[7];
      struct sbefifo_client *client;
 
-    /*
-     * Magic sequence to do SBE putscom command. SBE will write 8 

bytes to
-     * specified SCOM address.
-     */
-    buf[0] = cpu_to_be32(0x6);
-    buf[1] = cpu_to_be32(0xa202);
-    buf[2] = 0;
-    buf[3] = cpu_to_be32(0x6D035);
-    buf[4] = cpu_to_be32(0x20010000);    /* trigger occ attention */ -    buf[5] = 0;
+    buf[0] = cpu_to_be32(0x5 + 0x2);        /* Chip-op length in words */
+    buf[1] = cpu_to_be32(0xa404);           /* PutOCCSRAM */ +    buf[2] = cpu_to_be32(0x3);              /* Mode: Circular */ +    buf[3] = cpu_to_be32(0x0);              /* Address: ignored in mode 3 */
+    buf[4] = cpu_to_be32(0x8);              /* Data length in bytes */ +    buf[5] = cpu_to_be32(0x20010000);       /* Trigger OCC attention */ +    buf[6] = 0;

     client = sbefifo_drv_open(sbefifo, 0);
     if (!client)

drivers/fsi/fsi-occ.c +1 -2
@@ -602,8 +599,7 @@ static int occ_trigger_attn(struct device *sbefifo)
          goto done;
 
      /* check for good response */
-    if ((be32_to_cpu(buf[0]) != 0xC0DEA202) ||
-        (be32_to_cpu(buf[1]) & 0x0FFFFFFF))
+    if ((be32_to_cpu(buf[0]) != 8) || (be32_to_cpu(buf[1]) != 
 0xC0DEA404))
          rc = -EBADMSG;
 

 done: