Skip to contentSkip to conversation

nvme-hwmon: add temperature threshold hysteresis feature

PATCH Superseded Tokunori Ikegami 1 participant 1 message Nov 9, 2024

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 nvme-hwmon: add temperature threshold hysteresis feature

The definition TMPTHH field supported by NVMe 2.1.

---
Changes since v1:
- Add hwmon temperature hysteresis sysfs files to use the hysteresis feature.

 drivers/nvme/host/core.c  |  1 +
 drivers/nvme/host/hwmon.c | 75 +++++++++++++++++++++++++++++++++++++++
 drivers/nvme/host/nvme.h  |  1 +
 include/linux/nvme.h      |  7 +++-
 4 files changed, 83 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +1 -0
index b149b638453f..59608e65bc1c 100644
@@ -3336,6 +3336,7 @@ static int nvme_init_identify(struct nvme_ctrl *ctrl)
 	ctrl->kas = le16_to_cpu(id->kas);
 	ctrl->max_namespaces = le32_to_cpu(id->mnan);
 	ctrl->ctratt = le32_to_cpu(id->ctratt);
+	ctrl->tmpthha = id->tmpthha;
 
 	ctrl->cntrltype = id->cntrltype;
 	ctrl->dctype = id->dctype;
drivers/nvme/host/hwmon.c +75 -0

105 lines not on this page · raw message

drivers/nvme/host/nvme.h +1 -0
index 093cb423f536..4824946abca3 100644
@@ -339,6 +339,7 @@ struct nvme_ctrl {
 	u32 oaes;
 	u32 aen_result;
 	u32 ctratt;
+	u8 tmpthha;
 	unsigned int shutdown_timeout;
 	unsigned int kato;
 	bool subsystem;
include/linux/nvme.h +6 -1
index b58d9405d65e..d2bf61f7080a 100644
@@ -332,7 +332,9 @@ struct nvme_id_ctrl {
 	__u8			anacap;
 	__le32			anagrpmax;
 	__le32			nanagrpid;
-	__u8			rsvd352[160];
+	__u8			rsvd352[32];
+	__u8			tmpthha;
+	__u8			rsvd385[127];
 	__u8			sqes;
 	__u8			cqes;
 	__le16			maxcmd;
@@ -388,6 +390,7 @@ enum {
 	NVME_CTRL_CTRATT_PREDICTABLE_LAT	= 1 << 5,
 	NVME_CTRL_CTRATT_NAMESPACE_GRANULARITY	= 1 << 7,
 	NVME_CTRL_CTRATT_UUID_LIST		= 1 << 9,
+	NVME_CTRL_TMPTHHA_TMPTHMH_MASK		= 7,
 };
 
 struct nvme_lbaf {
@@ -1121,6 +1124,8 @@ enum {
 	NVME_TEMP_THRESH_MASK		= 0xffff,
 	NVME_TEMP_THRESH_SELECT_SHIFT	= 16,
 	NVME_TEMP_THRESH_TYPE_UNDER	= 0x100000,
+	NVME_TEMP_THRESH_HYST_SHIFT	= 22,
+	NVME_TEMP_THRESH_HYST_MASK	= 0x7,
 };
 
 struct nvme_feat_auto_pst {
Signature · 1 line
2.45.2