[PATCH v3 1/1] nvme-hwmon: notify hwmon alarms on the SMART / Health Status AEN
Nilay Shroff
nilay at linux.ibm.com
Tue Nov 24 00:08:36 PST 2026
On 11/23/26 4:53 PM, Guixin Liu wrote:
> +static void nvme_hwmon_smart_notify(struct work_struct *work)
> +{
> + struct nvme_ctrl *ctrl =
> + container_of(work, struct nvme_ctrl, smart_work);
> + struct nvme_hwmon_data *data;
> + struct device *hwmon;
> + bool warn = false;
> +
> + if (nvme_ctrl_state(ctrl) != NVME_CTRL_LIVE)
> + return;
> +
> + hwmon = ctrl->hwmon_device;
> + if (!hwmon)
> + return;
> + data = dev_get_drvdata(hwmon);
> +
> + mutex_lock(&data->read_lock);
> + if (!nvme_hwmon_get_smart_log(data))
> + warn = data->log->critical_warning & NVME_SMART_CRIT_TEMPERATURE;
> + mutex_unlock(&data->read_lock);
> +
> + if (warn)
> + hwmon_notify_event(hwmon, hwmon_temp, hwmon_temp_alarm, 0);
> +}
> +
We only generate the notification if the NVME_SMART_CRIT_TEMPERATURE bit is set
in the SMART/Health log page. However, consider the following scenario:
the host receives a SMART/Health asynchronous event and schedules smart_work, but
by the time the work executes and reads the SMART/Health log page, the temperature
has already returned to the normal range.
In that case, the returned log page may no longer have the
NVME_SMART_CRIT_TEMPERATURE bit set, causing us to skip the notification
even though a temperature-threshold event was reported.
Perhaps we should also examine aer_subtype and, when it indicates a temperature-
threshold event, generate the hwmon notification regardless of whether the
corresponding temperature bit is currently set in the SMART/Health log page.
Other than this, the rest of the changes look good to me.
Thanks,
--Nilay
More information about the Linux-nvme
mailing list