diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index ddfcedaedb06..d18acbd83588 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -917,6 +917,7 @@ struct adapter { int last_op_flags; int swintr; + int sensor_resets; struct callout ktls_tick; }; diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index a8093d6e05d3..7f39d58e9c0b 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -682,6 +682,7 @@ static int sysctl_autoneg(SYSCTL_HANDLER_ARGS); static int sysctl_handle_t4_reg64(SYSCTL_HANDLER_ARGS); static int sysctl_temperature(SYSCTL_HANDLER_ARGS); static int sysctl_vdd(SYSCTL_HANDLER_ARGS); +static int sysctl_reset_sensor(SYSCTL_HANDLER_ARGS); static int sysctl_loadavg(SYSCTL_HANDLER_ARGS); static int sysctl_cctrl(SYSCTL_HANDLER_ARGS); static int sysctl_cim_ibq_obq(SYSCTL_HANDLER_ARGS); @@ -6264,6 +6265,9 @@ t4_sysctls(struct adapter *sc) SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "temperature", CTLTYPE_INT | CTLFLAG_RD, sc, 0, sysctl_temperature, "I", "chip temperature (in Celsius)"); + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "reset_sensor", CTLTYPE_INT | + CTLFLAG_RW, sc, 0, sysctl_reset_sensor, "I", + "reset the chip's temperature sensor."); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "loadavg", CTLTYPE_STRING | CTLFLAG_RD, sc, 0, sysctl_loadavg, "A", @@ -7454,6 +7458,36 @@ sysctl_vdd(SYSCTL_HANDLER_ARGS) return (sysctl_handle_int(oidp, &sc->params.core_vdd, 0, req)); } +static int +sysctl_reset_sensor(SYSCTL_HANDLER_ARGS) +{ + struct adapter *sc = arg1; + int rc, v; + uint32_t param, val; + + v = sc->sensor_resets; + rc = sysctl_handle_int(oidp, &v, 0, req); + if (rc != 0 || req->newptr == NULL || v <= 0) + return (rc); + + if (sc->params.fw_vers < FW_VERSION32(1, 24, 7, 0) || + chip_id(sc) < CHELSIO_T5) + return (ENOTSUP); + + rc = begin_synchronized_op(sc, NULL, SLEEP_OK | INTR_OK, "t4srst"); + if (rc) + return (rc); + param = (V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DEV) | + V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_DIAG) | + V_FW_PARAMS_PARAM_Y(FW_PARAM_DEV_DIAG_RESET_TMP_SENSOR)); + val = 1; + rc = -t4_set_params(sc, sc->mbox, sc->pf, 0, 1, ¶m, &val); + end_synchronized_op(sc, 0); + if (rc == 0) + sc->sensor_resets++; + return (rc); +} + static int sysctl_loadavg(SYSCTL_HANDLER_ARGS) {