From: Guixin Liu <kanie@linux.alibaba.com>
To: Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
Nilay Shroff <nilay@linux.ibm.com>,
Daniel Wagner <dwagner@suse.de>, Hannes Reinecke <hare@suse.de>
Cc: linux-nvme@lists.infradead.org
Subject: [PATCH v3 0/1] nvme: make SMART / Health Status AENs reach hwmon alarms
Date: Mon, 23 Nov 2026 19:23:41 +0800 [thread overview]
Message-ID: <20261123112342.2761131-1-kanie@linux.alibaba.com> (raw)
The NVMe hwmon support exposes the temperature alarm as a plain sysfs
attribute, so monitoring tools have to poll temp1_alarm to learn about
a critical temperature condition. The device does send a SMART / Health
Status asynchronous event when a critical warning is raised, but the
host never enables it in the Asynchronous Event Configuration, and the
completion path silently drops the event.
The temperature warning is subscribed unconditionally when hwmon is
present (it has no OAES capability bit), a work item embedded in
nvme_ctrl re-reads the SMART log to clear the latched event -- the
same shape as the namespace scan reading the changed namespace list --
and the alarm is announced with hwmon_notify_event(), which also feeds
the registered thermal zone.
Testing: verified end to end against QEMU's nvme emulation: injecting
smart_critical_warning over QMP delivers the AEN, poll(2) on
temp1_alarm wakes immediately with EPOLLERR|EPOLLPRI and reads alarm=1;
clearing the warning produces no event and no spurious wake;
re-injecting the bit wakes again; enabling the spare-block warning
through an admin passthrough delivers the AEN without waking the
temperature alarm; a controller modeled to reject the critical warning
subscription with Invalid Field in Command falls back to the
notice-only mask, which a Get Features of the Asynchronous Event
Configuration confirms.
Changes since v2:
- exclude transports that do not implement asynchronous event
requests from the subscription: apple-nvme reports no OAES support
but registers hwmon, which would have queued the async event work
and dereferenced a NULL submit_async_event callback (sashiko)
- embed the SMART work in nvme_ctrl and only queue it while the
controller is live, so that a work item left over from before a
reset does not issue a blocking admin command against a quiesced
queue, and the work memory is tied to the controller lifetime
(sashiko)
- only notify temp1_alarm when the re-read SMART log has the
temperature critical warning set, so non-temperature events
enabled through passthrough do not produce false alarms (sashiko)
- fall back to the notice-only Asynchronous Event Configuration
when the controller rejects the critical warning subscription
with Invalid Field in Command -- the SHCW bits have no capability
field to probe, so the subscription itself is the only probe --
and return early when the reduced mask is empty, so the notice
events are not lost with the subscription (sashiko)
- drain the SMART work before freeing its data during controller
teardown, so that a late asynchronous event completion cannot
dereference freed memory (sashiko)
Link: https://lore.kernel.org/all/20261110110737.3965373-1-kanie@linux.alibaba.com/
Changes since v1:
- drop the uapi patch defining an OAES bit for the SMART event: OAES
bits 7:0 are reserved; the warning is configured through the
SMART / Health Critical Warnings field of the Asynchronous Event
Configuration feature (sashiko)
- subscribe to the temperature warning unconditionally when hwmon is
present, instead of masking against ctrl->oaes (sashiko)
- re-read the SMART log in the deferred work to clear the latched
event, like the namespace scan does for the changed namespace
list (sashiko)
- call hwmon_notify_event() instead of sysfs_notify(), so the thermal
zone registered with HWMON_C_REGISTER_TZ is fed as well (sashiko)
- correct the cover letter: temp1_alarm reflects the temperature
warning only, not the spare-block condition
Link: https://lore.kernel.org/all/20261109120207.1352165-1-kanie@linux.alibaba.com/
Guixin Liu (1):
nvme-hwmon: notify hwmon alarms on the SMART / Health Status AEN
drivers/nvme/host/core.c | 26 +++++++++++++++++++++++++-
drivers/nvme/host/hwmon.c | 32 ++++++++++++++++++++++++++++
drivers/nvme/host/nvme.h | 16 +++++++++++++
3 files changed, 73 insertions(+), 1 deletion(-)
--
2.43.7
next reply other threads:[~2026-11-23 11:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 11:23 Guixin Liu [this message]
2026-11-23 11:23 ` [PATCH v3 1/1] nvme-hwmon: notify hwmon alarms on the SMART / Health Status AEN Guixin Liu
2026-11-24 8:08 ` Nilay Shroff
2026-11-24 11:23 ` Guixin Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261123112342.2761131-1-kanie@linux.alibaba.com \
--to=kanie@linux.alibaba.com \
--cc=axboe@kernel.dk \
--cc=dwagner@suse.de \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=nilay@linux.ibm.com \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox