Index: sys/powerpc/powernv/opal.h =================================================================== --- sys/powerpc/powernv/opal.h +++ sys/powerpc/powernv/opal.h @@ -138,15 +138,37 @@ #define OPAL_SUCCESS 0 #define OPAL_PARAMETER -1 #define OPAL_BUSY -2 +#define OPAL_PARTIAL -3 +#define OPAL_CONSTRAINED -4 #define OPAL_CLOSED -5 #define OPAL_HARDWARE -6 #define OPAL_UNSUPPORTED -7 +#define OPAL_PERMISSION -8 +#define OPAL_NO_MEM -9 #define OPAL_RESOURCE -10 +#define OPAL_INTERNAL_ERROR -11 #define OPAL_BUSY_EVENT -12 +#define OPAL_HARDWARE_FROZEN -13 +#define OPAL_WRONG_STATE -14 #define OPAL_ASYNC_COMPLETION -15 #define OPAL_EMPTY -16 +#define OPAL_I2C_TIMEOUT -17 +#define OPAL_I2C_INVALID_CMD -18 +#define OPAL_I2C_LBUS_PARITY -19 +#define OPAL_I2C_BKEND_OVERRUN -20 +#define OPAL_I2C_BKEND_ACCESS -21 +#define OPAL_I2C_ARBT_LOST -22 +#define OPAL_I2C_NACK_RCVD -23 +#define OPAL_I2C_STOP_ERR -24 +#define OPAL_XSCOM_PARTIAL_GOOD -25 +#define OPAL_XSCOM_ADDR_ERROR -26 +#define OPAL_XSCOM_CLOCK_ERROR -27 +#define OPAL_XSCOM_PARITY_ERROR -28 +#define OPAL_XSCOM_TIMEOUT -29 +#define OPAL_XSCOM_CTR_OFFLINED -30 #define OPAL_XIVE_PROVISIONING -31 #define OPAL_XIVE_FREE_ACTIVE -32 +#define OPAL_TIMEOUT -33 #define OPAL_TOKEN_ABSENT 0 #define OPAL_TOKEN_PRESENT 1 Index: sys/powerpc/powernv/opal_dev.c =================================================================== --- sys/powerpc/powernv/opal_dev.c +++ sys/powerpc/powernv/opal_dev.c @@ -382,8 +382,22 @@ rv = opal_call(OPAL_GET_MSG, vtophys(&msg), sizeof(msg)); - if (rv != OPAL_SUCCESS) + switch (rv) { + case OPAL_SUCCESS: + break; + case OPAL_RESOURCE: + /* no available messages - return */ + return; + case OPAL_PARAMETER: + printf("%s error: invalid buffer. Please file a bug report.\n", __func__); + return; + case OPAL_PARTIAL: + printf("%s error: buffer is too small and messages was discarded. Please file a bug report.\n", __func__); return; + default: + printf("%s opal_call returned unknown result <%lu>\n", __func__, rv); + return; + } type = be32toh(msg.msg_type); switch (type) { @@ -406,7 +420,7 @@ EVENTHANDLER_DIRECT_INVOKE(OPAL_OCC, &msg); break; default: - printf("Unknown OPAL message type %d\n", type); + printf("%s Unknown OPAL message type %d\n", __func__, type); } } @@ -418,7 +432,7 @@ opal_call(OPAL_HANDLE_INTERRUPT, (uint32_t)(uint64_t)xintr, vtophys(&events)); /* Wake up the heartbeat, if it's been setup. */ - if (events != 0 && opal_hb_proc != NULL) + if (be64toh(events) != 0 && opal_hb_proc != NULL) wakeup(opal_hb_proc); } Index: sys/powerpc/powernv/opal_sensor.c =================================================================== --- sys/powerpc/powernv/opal_sensor.c +++ sys/powerpc/powernv/opal_sensor.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -114,7 +115,7 @@ SENSOR_UNLOCK(sc); if (rv == OPAL_SUCCESS) - *val = val32; + *val = be32toh(val32); else rv = EIO; @@ -218,7 +219,7 @@ SYSCTL_ADD_STRING(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "label", CTLFLAG_RD, sc->sc_label, 0, ""); - if (OF_getprop(node, "sensor-data-min", + if (OF_getencprop(node, "sensor-data-min", &sensor_id, sizeof(sensor_id)) > 0) { sc->sc_min_handle = sensor_id; SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, @@ -228,7 +229,7 @@ "minimum value"); } - if (OF_getprop(node, "sensor-data-max", + if (OF_getencprop(node, "sensor-data-max", &sensor_id, sizeof(sensor_id)) > 0) { sc->sc_max_handle = sensor_id; SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,