Skip to contentSkip to conversation

nvme: enable smart AEN

PATCH In review zhenwei pi 3 participants 9 messages May 7, 2022 – May 11, 2022 NVMe

lore
Share & tools
lore

zhenwei pi

author
#0 lore raw

cover nvme: enable smart AEN

Hi,

There are several changes in this series:
- Add missing NVME_SMART_CRIT_PMR_UNRELIABLE enum type.
- Add missing NVME_AEN_CFG_SMART_CRIT_* enum types.
- Enable smart AEN.

zhenwei pi (3):
nvme: introduce bit 5 of smart critical warning
nvme: introduce smart bits of aen cfg
nvme: enable smart AEN

 drivers/nvme/host/core.c |  6 +++++-
 include/linux/nvme.h     | 20 ++++++++++++++++----
 2 files changed, 21 insertions(+), 5 deletions(-)
Signature · 1 line
2.20.1
author
#1 lore raw

PATCH 1/3 nvme: introduce bit 5 of smart critical warning

According to NVM Express v1.4, Section 5.14.1.2 ("SMART / Health Information"), introduce bit 5 for "Persistent Memory Region has become read-only or unreliable".

---
 include/linux/nvme.h | 1 +
 1 file changed, 1 insertion(+)
include/linux/nvme.h +1 -0
index f626a445d1a8..882ad7523127 100644
@@ -662,6 +662,7 @@ enum {
 	NVME_SMART_CRIT_RELIABILITY	= 1 << 2,
 	NVME_SMART_CRIT_MEDIA		= 1 << 3,
 	NVME_SMART_CRIT_VOLATILE_MEMORY	= 1 << 4,
+	NVME_SMART_CRIT_PMR_UNRELIABLE	= 1 << 5,
 };
 
 enum {
Signature · 1 line
2.20.1
#2 lore raw

Re: [PATCH 1/3] nvme: introduce bit 5 of smart critical warning

Quoted 3 lines · zhenwei pi

According to NVM Express v1.4, Section 5.14.1.2 ("SMART / Health Information"), introduce bit 5 for "Persistent Memory Region has become read-only or unreliable".

Given that Linux does not support the PMR, do we really need this?

author
#3 lore raw

Re: Re: [PATCH 1/3] nvme: introduce bit 5 of smart critical warning

Quoted 6 lines · Christoph Hellwig
Quoted 3 lines · zhenwei pi

According to NVM Express v1.4, Section 5.14.1.2 ("SMART / Health Information"), introduce bit 5 for "Persistent Memory Region has become read-only or unreliable".

Given that Linux does not support the PMR, do we really need this?

OK, let's drop this change.

Klaus Jensen corrected me about OAES[7:0]. Sorry, I misunderstand this.

Signature · 1 line
zhenwei pi
author
#4 lore raw

PATCH 2/3 nvme: introduce smart bits of aen cfg

In reply to zhenwei pi

According to NVM Express v1.4, Section 5.21.1.11 (Asynchronous Event Configuration), introduce bit 0 ~ bit 5.

---
 include/linux/nvme.h | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
include/linux/nvme.h +15 -4
index 882ad7523127..e9f1563ab878 100644
@@ -688,10 +688,21 @@ enum {
 };
 
 enum {
-	NVME_AEN_CFG_NS_ATTR		= 1 << NVME_AEN_BIT_NS_ATTR,
-	NVME_AEN_CFG_FW_ACT		= 1 << NVME_AEN_BIT_FW_ACT,
-	NVME_AEN_CFG_ANA_CHANGE		= 1 << NVME_AEN_BIT_ANA_CHANGE,
-	NVME_AEN_CFG_DISC_CHANGE	= 1 << NVME_AEN_BIT_DISC_CHANGE,
+	/*
+	 * NVMe SPEC 1.4: 5.21.1.11 Asynchronous Event Configuration
+	 * bits 07:00: SMART / Health Critical Warnings
+	 */
+	NVME_AEN_CFG_SMART_CRIT_SPARE		= NVME_SMART_CRIT_SPARE,
+	NVME_AEN_CFG_SMART_CRIT_TEMPERATURE	= NVME_SMART_CRIT_TEMPERATURE,
+	NVME_AEN_CFG_SMART_CRIT_RELIABILITY	= NVME_SMART_CRIT_RELIABILITY,
+	NVME_AEN_CFG_SMART_CRIT_MEDIA		= NVME_SMART_CRIT_MEDIA,
+	NVME_AEN_CFG_SMART_CRIT_VOLATILE_MEMORY	= NVME_SMART_CRIT_VOLATILE_MEMORY,
+	NVME_AEN_CFG_SMART_CRIT_PMR_UNRELIABLE	= NVME_SMART_CRIT_PMR_UNRELIABLE,
+
+	NVME_AEN_CFG_NS_ATTR			= 1 << NVME_AEN_BIT_NS_ATTR,
+	NVME_AEN_CFG_FW_ACT			= 1 << NVME_AEN_BIT_FW_ACT,
+	NVME_AEN_CFG_ANA_CHANGE			= 1 << NVME_AEN_BIT_ANA_CHANGE,
+	NVME_AEN_CFG_DISC_CHANGE		= 1 << NVME_AEN_BIT_DISC_CHANGE,
 };
 
 struct nvme_lba_range_type {
Signature · 1 line
2.20.1
author
#5 lore raw

PATCH 3/3 nvme: enable smart AEN

In reply to zhenwei pi

Try to enable AEN on host side, this is helpful to minitor the critical warning from the NVMe controller.

---
 drivers/nvme/host/core.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +5 -1
index e1846d04817f..f386a4f1d434 100644
@@ -1490,8 +1490,12 @@ int nvme_set_queue_count(struct nvme_ctrl *ctrl, int *count)
 }
 EXPORT_SYMBOL_GPL(nvme_set_queue_count);
 
+#define NVME_AEN_SMART \
+	(NVME_AEN_CFG_SMART_CRIT_SPARE | NVME_AEN_CFG_SMART_CRIT_TEMPERATURE | \
+	 NVME_AEN_CFG_SMART_CRIT_RELIABILITY | NVME_AEN_CFG_SMART_CRIT_MEDIA | \
+	 NVME_AEN_CFG_SMART_CRIT_VOLATILE_MEMORY | NVME_AEN_CFG_SMART_CRIT_PMR_UNRELIABLE)
 #define NVME_AEN_SUPPORTED \
-	(NVME_AEN_CFG_NS_ATTR | NVME_AEN_CFG_FW_ACT | \
+	(NVME_AEN_SMART | NVME_AEN_CFG_NS_ATTR | NVME_AEN_CFG_FW_ACT | \
 	 NVME_AEN_CFG_ANA_CHANGE | NVME_AEN_CFG_DISC_CHANGE)
 
 static void nvme_enable_aen(struct nvme_ctrl *ctrl)
Signature · 1 line
2.20.1
author
#6 lore raw
In reply to zhenwei pi

Hi,

Sorry, I misunderstand OAES[7:0], only the first patch "nvme: introduce bit 5 of smart critical warning" is available.

Quoted 16 lines · zhenwei pi

Hi,

There are several changes in this series:
- Add missing NVME_SMART_CRIT_PMR_UNRELIABLE enum type.
- Add missing NVME_AEN_CFG_SMART_CRIT_* enum types.
- Enable smart AEN.

zhenwei pi (3):
nvme: introduce bit 5 of smart critical warning
nvme: introduce smart bits of aen cfg
nvme: enable smart AEN

  drivers/nvme/host/core.c |  6 +++++-
  include/linux/nvme.h     | 20 ++++++++++++++++----
  2 files changed, 21 insertions(+), 5 deletions(-)
Signature · 1 line
zhenwei pi
maintainer
#7 lore raw
In reply to zhenwei pi
Quoted 7 lines

Hi,

There are several changes in this series:
- Add missing NVME_SMART_CRIT_PMR_UNRELIABLE enum type.
- Add missing NVME_AEN_CFG_SMART_CRIT_* enum types.
- Enable smart AEN.

Is there another side to this patchset? meaning some userland agent that listens to these events and does something with these?

author
#8 lore raw
Quoted 10 lines · Sagi Grimberg
Quoted 7 lines

Hi,

There are several changes in this series:
- Add missing NVME_SMART_CRIT_PMR_UNRELIABLE enum type.
- Add missing NVME_AEN_CFG_SMART_CRIT_* enum types.
- Enable smart AEN.

Is there another side to this patchset? meaning some userland agent that listens to these events and does something with these?

I tried to test SMART AEN end to end by QEMU NVMe emulation. I did not realize that the SMART AEN CFG is not optional.

Also sent this to QEMU(Klaus corrected me):
https://patchwork.kernel.org/project/qemu-devel/cover/[email protected]/

Signature · 1 line
zhenwei pi