Skip to contentSkip to conversation

nvme: hwmon: Add support for throttling temperature feature

PATCH In review Tokunori Ikegami 3 participants 7 messages Aug 6, 2022 – Aug 7, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme: hwmon: Add support for throttling temperature feature

NVMe drives support host controlled thermal management feature as optional. The thermal management temperature are different from the temperature threshold. So add functionality to set the throttling temperature values.

---
 drivers/hwmon/hwmon.c     |  2 ++
 drivers/nvme/host/core.c  |  1 +
 drivers/nvme/host/hwmon.c | 60 ++++++++++++++++++++++++++++++++++++++-
 drivers/nvme/host/nvme.h  |  1 +
 include/linux/hwmon.h     |  4 +++
 include/linux/nvme.h      |  7 ++++-
 6 files changed, 73 insertions(+), 2 deletions(-)
drivers/hwmon/hwmon.c +2 -0
index 2e2cd79d89eb..be756ed8b71c 100644
@@ -486,6 +486,8 @@ static const char * const hwmon_temp_attr_templates[] = {
 	[hwmon_temp_reset_history] = "temp%d_reset_history",
 	[hwmon_temp_rated_min] = "temp%d_rated_min",
 	[hwmon_temp_rated_max] = "temp%d_rated_max",
+	[hwmon_temp_throttle_low] = "temp%d_throttle_low",
+	[hwmon_temp_throttle_high] = "temp%d_throttle_high",
 };
 
 static const char * const hwmon_in_attr_templates[] = {
drivers/nvme/host/core.c +1 -0
index 2429b11eb9a8..7925f8d3bedf 100644
@@ -3142,6 +3142,7 @@ static int nvme_init_identify(struct nvme_ctrl *ctrl)
 	nvme_set_queue_limits(ctrl, ctrl->admin_q);
 	ctrl->sgls = le32_to_cpu(id->sgls);
 	ctrl->kas = le16_to_cpu(id->kas);
+	ctrl->hctma = le16_to_cpu(id->hctma);
 	ctrl->max_namespaces = le32_to_cpu(id->mnan);
 	ctrl->ctratt = le32_to_cpu(id->ctratt);
 
drivers/nvme/host/hwmon.c +59 -1

90 lines not on this page · raw message

drivers/nvme/host/nvme.h +1 -0
index bdc0ff7ed9ab..9f53f96c1206 100644
@@ -293,6 +293,7 @@ struct nvme_ctrl {
 	u32 vs;
 	u32 sgls;
 	u16 kas;
+	u16 hctma;
 	u8 npss;
 	u8 apsta;
 	u16 wctemp;
include/linux/hwmon.h +4 -0
index 14325f93c6b2..9377682c4b1a 100644
@@ -87,6 +87,8 @@ enum hwmon_temp_attributes {
 	hwmon_temp_reset_history,
 	hwmon_temp_rated_min,
 	hwmon_temp_rated_max,
+	hwmon_temp_throttle_low,
+	hwmon_temp_throttle_high,
 };
 
 #define HWMON_T_ENABLE		BIT(hwmon_temp_enable)
@@ -116,6 +118,8 @@ enum hwmon_temp_attributes {
 #define HWMON_T_RESET_HISTORY	BIT(hwmon_temp_reset_history)
 #define HWMON_T_RATED_MIN	BIT(hwmon_temp_rated_min)
 #define HWMON_T_RATED_MAX	BIT(hwmon_temp_rated_max)
+#define HWMON_T_THROTTLE_LOW	BIT(hwmon_temp_throttle_low)
+#define HWMON_T_THROTTLE_HIGH	BIT(hwmon_temp_throttle_high)
 
 enum hwmon_in_attributes {
 	hwmon_in_enable,
include/linux/nvme.h +6 -1
index ae53d74f3696..7f072fc2644d 100644
@@ -184,7 +184,7 @@ enum {
  * Submission and Completion Queue Entry Sizes for the NVM command set.
  * (In bytes and specified as a power of two (2^n)).
  */
-#define NVME_ADM_SQES       6
+#define NVME_ADM_SQES		6
 #define NVME_NVM_IOSQES		6
 #define NVME_NVM_IOCQES		4
 
@@ -1079,6 +1079,11 @@ enum {
 	NVME_HOST_MEM_RETURN	= (1 << 1),
 };
 
+struct nvme_feat_hctm {
+	__u16 tmt2;
+	__u16 tmt1;
+};
+
 struct nvme_feat_host_behavior {
 	__u8 acre;
 	__u8 etdas;
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 5 lines · Tokunori Ikegami

NVMe drives support host controlled thermal management feature as optional. The thermal management temperature are different from the temperature threshold. So add functionality to set the throttling temperature values.

NACK. There are several existing limit attributes which can be used for this purpose. I would suggest to use EMERGENCY and LCRIT attributes.

Furthermore, one can not just extend the hwmon ABI without discussion, much less as part of a patch introducing its use. Any attribute introduced into the ABI must benefit more than one device, and a matching implementation in the sensors command and the lm-sensors library is expected.

Guenter

#2 lore raw

Note: Sorry let me resend the mail below as text format since it was not delivered to the mailing lists as contained HTML subpart.

Hi,

Thanks for your comments.

Quoted 6 lines · Guenter Roeck
Quoted 5 lines · Tokunori Ikegami

NVMe drives support host controlled thermal management feature as optional. The thermal management temperature are different from the temperature threshold. So add functionality to set the throttling temperature values.

I think actually the suggested attributes are not met with the throttling temperatures as below.

  temp[1-*]_emergency: Temperature emergency max value, for chips supporting more than two upper temperature limits. temp[1-*]_lcrit: Temperature critical min value, typically lower than corresponding temp_min values.

  Thermal Management Temperature 1 (TMT1): This field specifies the temperature, in Kelvins, when the controller begins to transition to lower power active power states or performs vendor specific thermal management actions while minimizing the impact on performance (e.g., light throttling) in order to attempt to reduce the Composite Temperature. Thermal Management Temperature 2 (TMT2): This field specifies the temperature, in Kelvins, when the controller begins to transition to lower power active power states or perform vendor specific thermal management actions regardless of the impact on performance (e.g., heavy throttling) in order to attempt to reduce the Composite Temperature.

Quoted 8 lines

NACK. There are several existing limit attributes which can be used for this purpose. I would suggest to use EMERGENCY and LCRIT attributes.

Furthermore, one can not just extend the hwmon ABI without discussion, much less as part of a patch introducing its use. Any attribute introduced into the ABI must benefit more than one device, and a matching implementation in the sensors command and the lm-sensors library is expected.

Sorry I am not sure about the hwmon ABI situation but if possible could you please consider or discuss to extend the attributes from this patch review since the suggested attributes seem difficult to use instead? (Is it difficult?) By the way I have already created the lm-sensors pull request below.
  <https://github.com/lm-sensors/lm-sensors/pull/406>

Regards,
Ikegami

Quoted 2 lines

Guenter

#3 lore raw

Am 06.08.22 um 13:58 schrieb Tokunori Ikegami:

Quoted 25 lines

Note: Sorry let me resend the mail below as text format since it was not delivered to the mailing lists as contained HTML subpart.

Hi,

Thanks for your comments.

Quoted 8 lines · Guenter Roeck
Quoted 7 lines · Tokunori Ikegami

NVMe drives support host controlled thermal management feature as optional.
The thermal management temperature are different from the temperature threshold.
So add functionality to set the throttling temperature values.

I think actually the suggested attributes are not met with the throttling temperatures as below.

  temp[1-*]_emergency: Temperature emergency max value, for chips supporting more than two upper temperature limits. temp[1-*]_lcrit: Temperature critical min value, typically lower than corresponding temp_min values.

Quoted 13 lines

  Thermal Management Temperature 1 (TMT1): This field specifies the temperature, in Kelvins, when the controller begins to transition to lower power active power states or performs vendor specific thermal management actions while minimizing the impact on performance (e.g., light throttling) in order to attempt to reduce the Composite Temperature.
  Thermal Management Temperature 2 (TMT2): This field specifies the temperature, in Kelvins, when the controller begins to transition to lower power active power states or perform vendor specific thermal management actions regardless of the impact on performance (e.g., heavy throttling) in order to attempt to reduce the Composite Temperature.

Maybe those two throttle thresholds could be represented by tempX_crit and tempX_emergency, the special throttle effect could be documented in the drivers documentation.

Since tempX_crit is already used to report CCTEMP, maybe this value could be reported with tempX_rated_max instead?
As far as i know, CCTEMP is the maximum composite temperature rating of the NVME device, so reporting is as tempX_rated_max would make sense.

Armin Wolf

Quoted 22 lines
Quoted 9 lines

NACK. There are several existing limit attributes which can be used for this purpose. I would suggest to use EMERGENCY and LCRIT attributes.

Furthermore, one can not just extend the hwmon ABI without discussion, much less as part of a patch introducing its use. Any attribute introduced
into the ABI must benefit more than one device, and a matching implementation in the sensors command and the lm-sensors library is expected.

Sorry I am not sure about the hwmon ABI situation but if possible could you please consider or discuss to extend the attributes from this patch review since the suggested attributes seem difficult to use instead? (Is it difficult?)
By the way I have already created the lm-sensors pull request below.
  <https://github.com/lm-sensors/lm-sensors/pull/406>

Regards,
Ikegami

Quoted 2 lines

Guenter

#4 lore raw
Quoted 40 lines · Armin Wolf

Am 06.08.22 um 13:58 schrieb Tokunori Ikegami:

Quoted 25 lines

Note: Sorry let me resend the mail below as text format since it was not delivered to the mailing lists as contained HTML subpart.

Hi,

Thanks for your comments.

Quoted 8 lines · Guenter Roeck
Quoted 7 lines · Tokunori Ikegami

NVMe drives support host controlled thermal management feature as optional.
The thermal management temperature are different from the temperature threshold.
So add functionality to set the throttling temperature values.

I think actually the suggested attributes are not met with the throttling temperatures as below.

  temp[1-*]_emergency: Temperature emergency max value, for chips supporting more than two upper temperature limits. temp[1-*]_lcrit: Temperature critical min value, typically lower than corresponding temp_min values.

Quoted 13 lines

  Thermal Management Temperature 1 (TMT1): This field specifies the temperature, in Kelvins, when the controller begins to transition to lower power active power states or performs vendor specific thermal management actions while minimizing the impact on performance (e.g., light throttling) in order to attempt to reduce the Composite Temperature.
  Thermal Management Temperature 2 (TMT2): This field specifies the temperature, in Kelvins, when the controller begins to transition to lower power active power states or perform vendor specific thermal management actions regardless of the impact on performance (e.g., heavy throttling) in order to attempt to reduce the Composite Temperature.

Quoted 5 lines

Maybe those two throttle thresholds could be represented by tempX_crit and tempX_emergency, the special throttle effect could be documented in the drivers documentation.

Since tempX_crit is already used to report CCTEMP, maybe this value could be reported with tempX_rated_max instead?
As far as i know, CCTEMP is the maximum composite temperature rating of the NVME device, so reporting is as tempX_rated_max would make sense.

Thanks for your advice. But actually the throttle thresholds is lower than both the current tempX_max and tempX_crit by default so it seems that it is difficult to use the current tempX values for the throttle thresholds.

Regards,
Ikegami

Quoted 25 lines

Armin Wolf

Quoted 22 lines
Quoted 9 lines

NACK. There are several existing limit attributes which can be used for this purpose. I would suggest to use EMERGENCY and LCRIT attributes.

Furthermore, one can not just extend the hwmon ABI without discussion, much less as part of a patch introducing its use. Any attribute introduced
into the ABI must benefit more than one device, and a matching implementation in the sensors command and the lm-sensors library is expected.

Sorry I am not sure about the hwmon ABI situation but if possible could you please consider or discuss to extend the attributes from this patch review since the suggested attributes seem difficult to use instead? (Is it difficult?)
By the way I have already created the lm-sensors pull request below.
  <https://github.com/lm-sensors/lm-sensors/pull/406>

Regards,
Ikegami

Quoted 2 lines

Guenter

maintainer
#5 lore raw
In reply to Tokunori Ikegami
Quoted 23 lines · Tokunori Ikegami

Note: Sorry let me resend the mail below as text format since it was not delivered to the mailing lists as contained HTML subpart.

Hi,

Thanks for your comments.

Quoted 6 lines · Guenter Roeck
Quoted 5 lines · Tokunori Ikegami

NVMe drives support host controlled thermal management feature as optional. The thermal management temperature are different from the temperature threshold. So add functionality to set the throttling temperature values.

I think actually the suggested attributes are not met with the throttling temperatures as below.

  temp[1-*]_emergency: Temperature emergency max value, for chips supporting more than two upper temperature limits.
  temp[1-*]_lcrit: Temperature critical min value, typically lower than corresponding temp_min values.

Quoted 11 lines

  Thermal Management Temperature 1 (TMT1): This field specifies the temperature, in Kelvins, when the controller begins to transition to lower power active power states or performs vendor specific thermal management actions while minimizing the impact on performance (e.g., light throttling) in order to attempt to reduce the Composite Temperature. Thermal Management Temperature 2 (TMT2): This field specifies the temperature, in Kelvins, when the controller begins to transition to lower power active power states or perform vendor specific thermal management actions regardless of the impact on performance (e.g., heavy throttling) in order to attempt to reduce the Composite Temperature.

That happens a lot. That is neither a reason nor an argument to introducing new attributes to match chip descriptions. If we would do that, we would end up with lots and lots of different and unmanageable attributes.

Please note that the functionality is associated with thermal management, so you might want to discuss your attributes with the thermal subsystem maintainers.

Guenter

#6 lore raw
Quoted 34 lines · Guenter Roeck
Quoted 22 lines · Tokunori Ikegami

Note: Sorry let me resend the mail below as text format since it was not delivered to the mailing lists as contained HTML subpart.

Hi,

Thanks for your comments.

Quoted 6 lines · Guenter Roeck
Quoted 5 lines · Tokunori Ikegami

NVMe drives support host controlled thermal management feature as optional. The thermal management temperature are different from the temperature threshold. So add functionality to set the throttling temperature values.

I think actually the suggested attributes are not met with the throttling temperatures as below.

  temp[1-*]_emergency: Temperature emergency max value, for chips supporting
more than two upper temperature limits.
  temp[1-*]_lcrit: Temperature critical min value, typically lower than
corresponding temp_min values.

Quoted 11 lines

  Thermal Management Temperature 1 (TMT1): This field specifies the
temperature, in Kelvins, when the controller begins to transition to lower power active power states or performs vendor specific thermal management actions while minimizing the impact on performance (e.g., light throttling) in order to attempt to reduce the Composite Temperature.
  Thermal Management Temperature 2 (TMT2): This field specifies the
temperature, in Kelvins, when the controller begins to transition to lower power active power states or perform vendor specific thermal management actions regardless of the impact on performance (e.g., heavy throttling) in order to attempt to reduce the Composite Temperature.

Quoted 7 lines

That happens a lot. That is neither a reason nor an argument to introducing new attributes to match chip descriptions. If we would do that, we would end up with lots and lots of different and unmanageable attributes.

Please note that the functionality is associated with thermal management, so you might want to discuss your attributes with the thermal subsystem maintainers.

Okay I see and have understood as it is difficult to use hwmon attributes for the thermal management functionality.

Regards,
Ikegami

Quoted 2 lines

Guenter