* [PATCH linux dev-5.15 1/4] hwmon: (occ) Add sysfs entry for IPS (Idle Power Saver) status
2022-02-14 23:00 [PATCH linux dev-5.15 0/4] hwmon: (occ) Add various poll response data in sysfs Eddie James
@ 2022-02-14 23:00 ` Eddie James
2022-02-14 23:00 ` [PATCH linux dev-5.15 2/4] hwmon: (occ) Add sysfs entry for OCC mode Eddie James
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Eddie James @ 2022-02-14 23:00 UTC (permalink / raw)
To: openbmc; +Cc: baileysh, Eddie James, cjcain
BMC control applications need to check the Idle Power Saver status
byte returned by the OCC poll response, so export it in sysfs with
the other OCC-specific data.
Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
drivers/hwmon/occ/common.h | 1 +
drivers/hwmon/occ/sysfs.c | 11 +++++++++++
2 files changed, 12 insertions(+)
diff --git a/drivers/hwmon/occ/common.h b/drivers/hwmon/occ/common.h
index 5020117be740..a88c66d36e38 100644
--- a/drivers/hwmon/occ/common.h
+++ b/drivers/hwmon/occ/common.h
@@ -119,6 +119,7 @@ struct occ {
u8 prev_stat;
u8 prev_ext_stat;
u8 prev_occs_present;
+ u8 prev_ips_status;
};
int occ_setup(struct occ *occ, const char *name);
diff --git a/drivers/hwmon/occ/sysfs.c b/drivers/hwmon/occ/sysfs.c
index 03b16abef67f..6dc69c9aa4c2 100644
--- a/drivers/hwmon/occ/sysfs.c
+++ b/drivers/hwmon/occ/sysfs.c
@@ -63,6 +63,9 @@ static ssize_t occ_sysfs_show(struct device *dev,
else
val = 1;
break;
+ case 8:
+ val = header->ips_status;
+ break;
default:
return -EINVAL;
}
@@ -88,6 +91,7 @@ static SENSOR_DEVICE_ATTR(occ_mem_throttle, 0444, occ_sysfs_show, NULL, 4);
static SENSOR_DEVICE_ATTR(occ_quick_pwr_drop, 0444, occ_sysfs_show, NULL, 5);
static SENSOR_DEVICE_ATTR(occ_state, 0444, occ_sysfs_show, NULL, 6);
static SENSOR_DEVICE_ATTR(occs_present, 0444, occ_sysfs_show, NULL, 7);
+static SENSOR_DEVICE_ATTR(occ_ips_status, 0444, occ_sysfs_show, NULL, 8);
static DEVICE_ATTR_RO(occ_error);
static struct attribute *occ_attributes[] = {
@@ -99,6 +103,7 @@ static struct attribute *occ_attributes[] = {
&sensor_dev_attr_occ_quick_pwr_drop.dev_attr.attr,
&sensor_dev_attr_occ_state.dev_attr.attr,
&sensor_dev_attr_occs_present.dev_attr.attr,
+ &sensor_dev_attr_occ_ips_status.dev_attr.attr,
&dev_attr_occ_error.attr,
NULL
};
@@ -162,6 +167,11 @@ void occ_sysfs_poll_done(struct occ *occ)
sysfs_notify(&occ->bus_dev->kobj, NULL, name);
}
+ if (header->ips_status != occ->prev_ips_status) {
+ name = sensor_dev_attr_occ_ips_status.dev_attr.attr.name;
+ sysfs_notify(&occ->bus_dev->kobj, NULL, name);
+ }
+
if (occ->error && occ->error != occ->prev_error) {
name = dev_attr_occ_error.attr.name;
sysfs_notify(&occ->bus_dev->kobj, NULL, name);
@@ -174,6 +184,7 @@ void occ_sysfs_poll_done(struct occ *occ)
occ->prev_stat = header->status;
occ->prev_ext_stat = header->ext_status;
occ->prev_occs_present = header->occs_present;
+ occ->prev_ips_status = header->ips_status;
}
int occ_setup_sysfs(struct occ *occ)
--
2.27.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH linux dev-5.15 2/4] hwmon: (occ) Add sysfs entry for OCC mode
2022-02-14 23:00 [PATCH linux dev-5.15 0/4] hwmon: (occ) Add various poll response data in sysfs Eddie James
2022-02-14 23:00 ` [PATCH linux dev-5.15 1/4] hwmon: (occ) Add sysfs entry for IPS (Idle Power Saver) status Eddie James
@ 2022-02-14 23:00 ` Eddie James
2022-02-14 23:00 ` [PATCH linux dev-5.15 3/4] hwmon: (occ) Add sysfs entries for additional extended status bits Eddie James
2022-02-14 23:00 ` [PATCH linux dev-5.15 4/4] hwmon: (occ) Add soft minimum power cap attribute Eddie James
3 siblings, 0 replies; 5+ messages in thread
From: Eddie James @ 2022-02-14 23:00 UTC (permalink / raw)
To: openbmc; +Cc: baileysh, Eddie James, cjcain
BMC control applications need to check the OCC mode returned by the
OCC poll response, so export it in sysfs with the other OCC-specific
data.
Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
drivers/hwmon/occ/common.h | 1 +
drivers/hwmon/occ/sysfs.c | 11 +++++++++++
2 files changed, 12 insertions(+)
diff --git a/drivers/hwmon/occ/common.h b/drivers/hwmon/occ/common.h
index a88c66d36e38..2dd4a4d240c0 100644
--- a/drivers/hwmon/occ/common.h
+++ b/drivers/hwmon/occ/common.h
@@ -120,6 +120,7 @@ struct occ {
u8 prev_ext_stat;
u8 prev_occs_present;
u8 prev_ips_status;
+ u8 prev_mode;
};
int occ_setup(struct occ *occ, const char *name);
diff --git a/drivers/hwmon/occ/sysfs.c b/drivers/hwmon/occ/sysfs.c
index 6dc69c9aa4c2..88f655887c95 100644
--- a/drivers/hwmon/occ/sysfs.c
+++ b/drivers/hwmon/occ/sysfs.c
@@ -66,6 +66,9 @@ static ssize_t occ_sysfs_show(struct device *dev,
case 8:
val = header->ips_status;
break;
+ case 9:
+ val = header->mode;
+ break;
default:
return -EINVAL;
}
@@ -92,6 +95,7 @@ static SENSOR_DEVICE_ATTR(occ_quick_pwr_drop, 0444, occ_sysfs_show, NULL, 5);
static SENSOR_DEVICE_ATTR(occ_state, 0444, occ_sysfs_show, NULL, 6);
static SENSOR_DEVICE_ATTR(occs_present, 0444, occ_sysfs_show, NULL, 7);
static SENSOR_DEVICE_ATTR(occ_ips_status, 0444, occ_sysfs_show, NULL, 8);
+static SENSOR_DEVICE_ATTR(occ_mode, 0444, occ_sysfs_show, NULL, 9);
static DEVICE_ATTR_RO(occ_error);
static struct attribute *occ_attributes[] = {
@@ -104,6 +108,7 @@ static struct attribute *occ_attributes[] = {
&sensor_dev_attr_occ_state.dev_attr.attr,
&sensor_dev_attr_occs_present.dev_attr.attr,
&sensor_dev_attr_occ_ips_status.dev_attr.attr,
+ &sensor_dev_attr_occ_mode.dev_attr.attr,
&dev_attr_occ_error.attr,
NULL
};
@@ -172,6 +177,11 @@ void occ_sysfs_poll_done(struct occ *occ)
sysfs_notify(&occ->bus_dev->kobj, NULL, name);
}
+ if (header->mode != occ->prev_mode) {
+ name = sensor_dev_attr_occ_mode.dev_attr.attr.name;
+ sysfs_notify(&occ->bus_dev->kobj, NULL, name);
+ }
+
if (occ->error && occ->error != occ->prev_error) {
name = dev_attr_occ_error.attr.name;
sysfs_notify(&occ->bus_dev->kobj, NULL, name);
@@ -185,6 +195,7 @@ void occ_sysfs_poll_done(struct occ *occ)
occ->prev_ext_stat = header->ext_status;
occ->prev_occs_present = header->occs_present;
occ->prev_ips_status = header->ips_status;
+ occ->prev_mode = header->mode;
}
int occ_setup_sysfs(struct occ *occ)
--
2.27.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH linux dev-5.15 3/4] hwmon: (occ) Add sysfs entries for additional extended status bits
2022-02-14 23:00 [PATCH linux dev-5.15 0/4] hwmon: (occ) Add various poll response data in sysfs Eddie James
2022-02-14 23:00 ` [PATCH linux dev-5.15 1/4] hwmon: (occ) Add sysfs entry for IPS (Idle Power Saver) status Eddie James
2022-02-14 23:00 ` [PATCH linux dev-5.15 2/4] hwmon: (occ) Add sysfs entry for OCC mode Eddie James
@ 2022-02-14 23:00 ` Eddie James
2022-02-14 23:00 ` [PATCH linux dev-5.15 4/4] hwmon: (occ) Add soft minimum power cap attribute Eddie James
3 siblings, 0 replies; 5+ messages in thread
From: Eddie James @ 2022-02-14 23:00 UTC (permalink / raw)
To: openbmc; +Cc: baileysh, Eddie James, cjcain
Add sysfs entries for DVFS due to a VRM Vdd over-temperature condition,
and add the GPU throttling condition bits (such that if bit 1 is set,
GPU1 is throttling).
Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
drivers/hwmon/occ/sysfs.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/drivers/hwmon/occ/sysfs.c b/drivers/hwmon/occ/sysfs.c
index 88f655887c95..b2f788a77746 100644
--- a/drivers/hwmon/occ/sysfs.c
+++ b/drivers/hwmon/occ/sysfs.c
@@ -19,6 +19,8 @@
#define OCC_EXT_STAT_DVFS_POWER BIT(6)
#define OCC_EXT_STAT_MEM_THROTTLE BIT(5)
#define OCC_EXT_STAT_QUICK_DROP BIT(4)
+#define OCC_EXT_STAT_DVFS_VDD BIT(3)
+#define OCC_EXT_STAT_GPU_THROTTLE GENMASK(2, 0)
static ssize_t occ_sysfs_show(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -69,6 +71,12 @@ static ssize_t occ_sysfs_show(struct device *dev,
case 9:
val = header->mode;
break;
+ case 10:
+ val = !!(header->ext_status & OCC_EXT_STAT_DVFS_VDD);
+ break;
+ case 11:
+ val = header->ext_status & OCC_EXT_STAT_GPU_THROTTLE;
+ break;
default:
return -EINVAL;
}
@@ -96,6 +104,8 @@ static SENSOR_DEVICE_ATTR(occ_state, 0444, occ_sysfs_show, NULL, 6);
static SENSOR_DEVICE_ATTR(occs_present, 0444, occ_sysfs_show, NULL, 7);
static SENSOR_DEVICE_ATTR(occ_ips_status, 0444, occ_sysfs_show, NULL, 8);
static SENSOR_DEVICE_ATTR(occ_mode, 0444, occ_sysfs_show, NULL, 9);
+static SENSOR_DEVICE_ATTR(occ_dvfs_vdd, 0444, occ_sysfs_show, NULL, 10);
+static SENSOR_DEVICE_ATTR(occ_gpu_throttle, 0444, occ_sysfs_show, NULL, 11);
static DEVICE_ATTR_RO(occ_error);
static struct attribute *occ_attributes[] = {
@@ -109,6 +119,8 @@ static struct attribute *occ_attributes[] = {
&sensor_dev_attr_occs_present.dev_attr.attr,
&sensor_dev_attr_occ_ips_status.dev_attr.attr,
&sensor_dev_attr_occ_mode.dev_attr.attr,
+ &sensor_dev_attr_occ_dvfs_vdd.dev_attr.attr,
+ &sensor_dev_attr_occ_gpu_throttle.dev_attr.attr,
&dev_attr_occ_error.attr,
NULL
};
@@ -166,6 +178,18 @@ void occ_sysfs_poll_done(struct occ *occ)
sysfs_notify(&occ->bus_dev->kobj, NULL, name);
}
+ if ((header->ext_status & OCC_EXT_STAT_DVFS_VDD) !=
+ (occ->prev_ext_stat & OCC_EXT_STAT_DVFS_VDD)) {
+ name = sensor_dev_attr_occ_dvfs_vdd.dev_attr.attr.name;
+ sysfs_notify(&occ->bus_dev->kobj, NULL, name);
+ }
+
+ if ((header->ext_status & OCC_EXT_STAT_GPU_THROTTLE) !=
+ (occ->prev_ext_stat & OCC_EXT_STAT_GPU_THROTTLE)) {
+ name = sensor_dev_attr_occ_gpu_throttle.dev_attr.attr.name;
+ sysfs_notify(&occ->bus_dev->kobj, NULL, name);
+ }
+
if ((header->status & OCC_STAT_MASTER) &&
header->occs_present != occ->prev_occs_present) {
name = sensor_dev_attr_occs_present.dev_attr.attr.name;
--
2.27.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH linux dev-5.15 4/4] hwmon: (occ) Add soft minimum power cap attribute
2022-02-14 23:00 [PATCH linux dev-5.15 0/4] hwmon: (occ) Add various poll response data in sysfs Eddie James
` (2 preceding siblings ...)
2022-02-14 23:00 ` [PATCH linux dev-5.15 3/4] hwmon: (occ) Add sysfs entries for additional extended status bits Eddie James
@ 2022-02-14 23:00 ` Eddie James
3 siblings, 0 replies; 5+ messages in thread
From: Eddie James @ 2022-02-14 23:00 UTC (permalink / raw)
To: openbmc; +Cc: baileysh, Eddie James, cjcain
Export the power caps data for the soft minimum power cap through hwmon.
Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
drivers/hwmon/occ/common.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c
index 0cb4a0a6cbc1..f00cd59f1d19 100644
--- a/drivers/hwmon/occ/common.c
+++ b/drivers/hwmon/occ/common.c
@@ -674,6 +674,9 @@ static ssize_t occ_show_caps_3(struct device *dev,
case 7:
val = caps->user_source;
break;
+ case 8:
+ val = get_unaligned_be16(&caps->soft_min) * 1000000ULL;
+ break;
default:
return -EINVAL;
}
@@ -835,12 +838,13 @@ static int occ_setup_sensor_attrs(struct occ *occ)
case 1:
num_attrs += (sensors->caps.num_sensors * 7);
break;
- case 3:
- show_caps = occ_show_caps_3;
- fallthrough;
case 2:
num_attrs += (sensors->caps.num_sensors * 8);
break;
+ case 3:
+ show_caps = occ_show_caps_3;
+ num_attrs += (sensors->caps.num_sensors * 9);
+ break;
default:
sensors->caps.num_sensors = 0;
}
@@ -1047,6 +1051,15 @@ static int occ_setup_sensor_attrs(struct occ *occ)
attr->sensor = OCC_INIT_ATTR(attr->name, 0444,
show_caps, NULL, 7, 0);
attr++;
+
+ if (sensors->caps.version > 2) {
+ snprintf(attr->name, sizeof(attr->name),
+ "power%d_cap_min_soft", s);
+ attr->sensor = OCC_INIT_ATTR(attr->name, 0444,
+ show_caps, NULL,
+ 8, 0);
+ attr++;
+ }
}
}
--
2.27.0
^ permalink raw reply related [flat|nested] 5+ messages in thread