@@ -20,8 +20,13 @@
#include <stdint.h>
#include "libsbefifo.h"
+/*
+ * Long running commands will set a long (30 second) timeout when the kernel
+ * supports it.
+ */
+
#define SBEFIFO_CMD_CLASS_CONTROL 0xA100
-#define SBEFIFO_CMD_EXECUTE_ISTEP 0x01
+#define SBEFIFO_CMD_EXECUTE_ISTEP 0x01 /* long running */
#define SBEFIFO_CMD_SUSPEND_IO 0x02
#define SBEFIFO_CMD_CLASS_SCOM 0xA200
@@ -29,28 +34,28 @@
#define SBEFIFO_CMD_PUT_SCOM 0x02
#define SBEFIFO_CMD_MODIFY_SCOM 0x03
#define SBEFIFO_CMD_PUT_SCOM_MASK 0x04
-#define SBEFIFO_CMD_MULTI_SCOM 0x05
+#define SBEFIFO_CMD_MULTI_SCOM 0x05 /* long running */
#define SBEFIFO_CMD_CLASS_RING 0xA300
-#define SBEFIFO_CMD_GET_RING 0x01
-#define SBEFIFO_CMD_PUT_RING 0x02
+#define SBEFIFO_CMD_GET_RING 0x01 /* long running */
+#define SBEFIFO_CMD_PUT_RING 0x02 /* long running */
#define SBEFIFO_CMD_PUT_RING_IMAGE 0x03
#define SBEFIFO_CMD_CLASS_MEMORY 0xA400
-#define SBEFIFO_CMD_GET_MEMORY 0x01
-#define SBEFIFO_CMD_PUT_MEMORY 0x02
-#define SBEFIFO_CMD_GET_SRAM 0x03
-#define SBEFIFO_CMD_PUT_SRAM 0x04
+#define SBEFIFO_CMD_GET_MEMORY 0x01 /* long running */
+#define SBEFIFO_CMD_PUT_MEMORY 0x02 /* long running */
+#define SBEFIFO_CMD_GET_SRAM 0x03 /* long running */
+#define SBEFIFO_CMD_PUT_SRAM 0x04 /* long running */
#define SBEFIFO_CMD_CLASS_REGISTER 0xA500
-#define SBEFIFO_CMD_GET_REGISTER 0x01
-#define SBEFIFO_CMD_PUT_REGISTER 0x02
+#define SBEFIFO_CMD_GET_REGISTER 0x01 /* long running */
+#define SBEFIFO_CMD_PUT_REGISTER 0x02 /* long running */
#define SBEFIFO_CMD_GET_HW_REGISTER 0x03
#define SBEFIFO_CMD_PUT_HW_REGISTER 0x04
#define SBEFIFO_CMD_CLASS_ARRAY 0xA600
-#define SBEFIFO_CMD_FAST_ARRAY 0x01
-#define SBEFIFO_CMD_TRACE_ARRAY 0x02
+#define SBEFIFO_CMD_FAST_ARRAY 0x01 /* long running */
+#define SBEFIFO_CMD_TRACE_ARRAY 0x02 /* long running */
#define SBEFIFO_CMD_CLASS_INSTRUCTION 0xA700
#define SBEFIFO_CMD_CONTROL_INSN 0x01
@@ -58,15 +63,15 @@
#define SBEFIFO_CMD_CLASS_GENERIC 0xA800
#define SBEFIFO_CMD_GET_FFDC 0x01
#define SBEFIFO_CMD_GET_CAPABILITY 0x02
-#define SBEFIFO_CMD_QUIESCE 0x03
+#define SBEFIFO_CMD_QUIESCE 0x03 /* long running */
/* missing ids */
#define SBEFIFO_CMD_LPC_TIMEOUT 0x08
#define SBEFIFO_CMD_CLASS_MPIPL 0xA900
-#define SBEFIFO_CMD_ENTER_MPIPL 0x01
-#define SBEFIFO_CMD_CONTINUE_MPIPL 0x02
+#define SBEFIFO_CMD_ENTER_MPIPL 0x01 /* long running */
+#define SBEFIFO_CMD_CONTINUE_MPIPL 0x02 /* long running */
#define SBEFIFO_CMD_STOP_CLOCKS 0x03
-#define SBEFIFO_CMD_GET_TI_INFO 0x04
+#define SBEFIFO_CMD_GET_TI_INFO 0x04 /* long running */
#define SBEFIFO_CMD_CLASS_DUMP 0xAA00
#define SBEFIFO_CMD_GET_DUMP 0x01
@@ -69,8 +69,15 @@ int sbefifo_control_fast_array(struct sbefifo_context *sctx, uint16_t target_typ
if (rc)
return rc;
+ rc = sbefifo_set_long_timeout(sctx);
+ if (rc) {
+ free(msg);
+ return rc;
+ }
+
out_len = 0;
rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len);
+ sbefifo_reset_timeout(sctx);
free(msg);
if (rc)
return rc;
@@ -136,9 +143,16 @@ int sbefifo_control_trace_array(struct sbefifo_context *sctx, uint16_t target_ty
if (rc)
return rc;
+ rc = sbefifo_set_long_timeout(sctx);
+ if (rc) {
+ free(msg);
+ return rc;
+ }
+
/* The size of returned data is just a guess */
out_len = 16 * sizeof(uint32_t);
rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len);
+ sbefifo_reset_timeout(sctx);
free(msg);
if (rc)
return rc;
@@ -64,8 +64,15 @@ int sbefifo_istep_execute(struct sbefifo_context *sctx, uint8_t major, uint8_t m
if (rc)
return rc;
+ rc = sbefifo_set_long_timeout(sctx);
+ if (rc) {
+ free(msg);
+ return rc;
+ }
+
out_len = 0;
rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len);
+ sbefifo_reset_timeout(sctx);
free(msg);
if (rc)
return rc;
@@ -199,8 +199,15 @@ int sbefifo_quiesce(struct sbefifo_context *sctx)
if (rc)
return rc;
+ rc = sbefifo_set_long_timeout(sctx);
+ if (rc) {
+ free(msg);
+ return rc;
+ }
+
out_len = 0;
rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len);
+ sbefifo_reset_timeout(sctx);
free(msg);
if (rc)
return rc;
@@ -125,6 +125,12 @@ int sbefifo_mem_get(struct sbefifo_context *sctx, uint64_t addr, uint32_t size,
if (rc)
return rc;
+ rc = sbefifo_set_long_timeout(sctx);
+ if (rc) {
+ free(msg);
+ return rc;
+ }
+
/* length is 6th word in the request */
len = be32toh(*(uint32_t *)(msg + 20));
extra_bytes = 0;
@@ -137,11 +143,11 @@ int sbefifo_mem_get(struct sbefifo_context *sctx, uint64_t addr, uint32_t size,
out_len = len + extra_bytes + 4;
rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len);
+ sbefifo_reset_timeout(sctx);
free(msg);
if (rc)
return rc;
-
rc = sbefifo_mem_get_pull(out, out_len, addr, size, flags, data);
if (out)
free(out);
@@ -206,8 +212,15 @@ int sbefifo_mem_put(struct sbefifo_context *sctx, uint64_t addr, uint8_t *data,
if (rc)
return rc;
+ rc = sbefifo_set_long_timeout(sctx);
+ if (rc) {
+ free(msg);
+ return rc;
+ }
+
out_len = 1 * 4;
rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len);
+ sbefifo_reset_timeout(sctx);
free(msg);
if (rc)
return rc;
@@ -295,11 +308,18 @@ int sbefifo_sram_get(struct sbefifo_context *sctx, uint16_t chiplet_id, uint64_t
if (rc)
return rc;
+ rc = sbefifo_set_long_timeout(sctx);
+ if (rc) {
+ free(msg);
+ return rc;
+ }
+
/* length is 6th word in the request */
len = be32toh(*(uint32_t *)(msg + 20));
out_len = len + 4;
rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len);
+ sbefifo_reset_timeout(sctx);
free(msg);
if (rc)
return rc;
@@ -375,8 +395,15 @@ int sbefifo_sram_put(struct sbefifo_context *sctx, uint16_t chiplet_id, uint64_t
if (rc)
return rc;
+ rc = sbefifo_set_long_timeout(sctx);
+ if (rc) {
+ free(msg);
+ return rc;
+ }
+
out_len = 4;
rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len);
+ sbefifo_reset_timeout(sctx);
free(msg);
if (rc)
return rc;
@@ -61,8 +61,15 @@ int sbefifo_mpipl_enter(struct sbefifo_context *sctx)
if (rc)
return rc;
+ rc = sbefifo_set_long_timeout(sctx);
+ if (rc) {
+ free(msg);
+ return rc;
+ }
+
out_len = 0;
rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len);
+ sbefifo_reset_timeout(sctx);
free(msg);
if (rc)
return rc;
@@ -112,8 +119,15 @@ int sbefifo_mpipl_continue(struct sbefifo_context *sctx)
if (rc)
return rc;
+ rc = sbefifo_set_long_timeout(sctx);
+ if (rc) {
+ free(msg);
+ return rc;
+ }
+
out_len = 0;
rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len);
+ sbefifo_reset_timeout(sctx);
free(msg);
if (rc)
return rc;
@@ -224,8 +238,15 @@ int sbefifo_mpipl_get_ti_info(struct sbefifo_context *sctx, uint8_t **data, uint
if (rc)
return rc;
+ rc = sbefifo_set_long_timeout(sctx);
+ if (rc) {
+ free(msg);
+ return rc;
+ }
+
out_len = 0;
rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len);
+ sbefifo_reset_timeout(sctx);
free(msg);
if (rc)
return rc;
@@ -88,12 +88,18 @@ int sbefifo_register_get(struct sbefifo_context *sctx, uint8_t core_id, uint8_t
if (rc)
return rc;
+ rc = sbefifo_set_long_timeout(sctx);
+ if (rc)
+ return rc;
+
out_len = reg_count * 8;
rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len);
free(msg);
if (rc)
return rc;
+ sbefifo_reset_timeout(sctx);
+
rc = sbefifo_register_get_pull(out, out_len, reg_count, value);
if (out)
free(out);
@@ -154,12 +160,18 @@ int sbefifo_register_put(struct sbefifo_context *sctx, uint8_t core_id, uint8_t
if (rc)
return rc;
+ rc = sbefifo_set_long_timeout(sctx);
+ if (rc)
+ return rc;
+
out_len = 0;
rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len);
free(msg);
if (rc)
return rc;
+ sbefifo_reset_timeout(sctx);
+
rc = sbefifo_register_put_pull(out, out_len);
if (out)
free(out);
@@ -71,9 +71,16 @@ int sbefifo_ring_get(struct sbefifo_context *sctx, uint32_t ring_addr, uint32_t
if (rc)
return rc;
+ rc = sbefifo_set_long_timeout(sctx);
+ if (rc) {
+ free(msg);
+ return rc;
+ }
+
/* multiples of 64 bits */
out_len = (ring_len_bits + 63) / 8;
rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len);
+ sbefifo_reset_timeout(sctx);
free(msg);
if (rc)
return rc;
@@ -125,8 +132,15 @@ int sbefifo_ring_put(struct sbefifo_context *sctx, uint16_t ring_mode, uint8_t *
if (rc)
return rc;
+ rc = sbefifo_set_long_timeout(sctx);
+ if (rc) {
+ free(msg);
+ return rc;
+ }
+
out_len = 0;
rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len);
+ sbefifo_reset_timeout(sctx);
free(msg);
if (rc)
return rc;
@@ -185,8 +199,15 @@ int sbefifo_ring_put_from_image(struct sbefifo_context *sctx, uint16_t target, u
if (rc)
return rc;
+ rc = sbefifo_set_long_timeout(sctx);
+ if (rc) {
+ free(msg);
+ return rc;
+ }
+
out_len = 0;
rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len);
+ sbefifo_reset_timeout(sctx);
free(out);
if (rc)
return rc;