linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] hwmon: (occ) Add various poll response data in sysfs
@ 2022-02-15 15:10 Eddie James
  2022-02-15 15:10 ` [PATCH 1/4] hwmon: (occ) Add sysfs entry for IPS (Idle Power Saver) status Eddie James
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Eddie James @ 2022-02-15 15:10 UTC (permalink / raw)
  To: linux-hwmon; +Cc: linux-kernel, jdelvare, linux, joel, eajames

BMC control applications need to check various additional bits in the
extended status in the poll response, as well as the OCC mode and IPS
status bytes. Export all those through sysfs. In addition, add the "soft"
minimum power cap attribute through hwmon.

Eddie James (4):
  hwmon: (occ) Add sysfs entry for IPS (Idle Power Saver) status
  hwmon: (occ) Add sysfs entry for OCC mode
  hwmon: (occ) Add sysfs entries for additional extended status bits
  hwmon: (occ) Add soft minimum power cap attribute

 drivers/hwmon/occ/common.c | 19 +++++++++++++---
 drivers/hwmon/occ/common.h |  2 ++
 drivers/hwmon/occ/sysfs.c  | 46 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+), 3 deletions(-)

-- 
2.27.0


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/4] hwmon: (occ) Add sysfs entry for IPS (Idle Power Saver) status
  2022-02-15 15:10 [PATCH 0/4] hwmon: (occ) Add various poll response data in sysfs Eddie James
@ 2022-02-15 15:10 ` Eddie James
  2022-02-16  6:10   ` Joel Stanley
  2022-02-19 14:36   ` Guenter Roeck
  2022-02-15 15:10 ` [PATCH 2/4] hwmon: (occ) Add sysfs entry for OCC mode Eddie James
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 15+ messages in thread
From: Eddie James @ 2022-02-15 15:10 UTC (permalink / raw)
  To: linux-hwmon; +Cc: linux-kernel, jdelvare, linux, joel, eajames

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] 15+ messages in thread

* [PATCH 2/4] hwmon: (occ) Add sysfs entry for OCC mode
  2022-02-15 15:10 [PATCH 0/4] hwmon: (occ) Add various poll response data in sysfs Eddie James
  2022-02-15 15:10 ` [PATCH 1/4] hwmon: (occ) Add sysfs entry for IPS (Idle Power Saver) status Eddie James
@ 2022-02-15 15:10 ` Eddie James
  2022-02-16  6:11   ` Joel Stanley
  2022-02-19 14:37   ` Guenter Roeck
  2022-02-15 15:10 ` [PATCH 3/4] hwmon: (occ) Add sysfs entries for additional extended status bits Eddie James
  2022-02-15 15:10 ` [PATCH 4/4] hwmon: (occ) Add soft minimum power cap attribute Eddie James
  3 siblings, 2 replies; 15+ messages in thread
From: Eddie James @ 2022-02-15 15:10 UTC (permalink / raw)
  To: linux-hwmon; +Cc: linux-kernel, jdelvare, linux, joel, eajames

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] 15+ messages in thread

* [PATCH 3/4] hwmon: (occ) Add sysfs entries for additional extended status bits
  2022-02-15 15:10 [PATCH 0/4] hwmon: (occ) Add various poll response data in sysfs Eddie James
  2022-02-15 15:10 ` [PATCH 1/4] hwmon: (occ) Add sysfs entry for IPS (Idle Power Saver) status Eddie James
  2022-02-15 15:10 ` [PATCH 2/4] hwmon: (occ) Add sysfs entry for OCC mode Eddie James
@ 2022-02-15 15:10 ` Eddie James
  2022-02-16  6:12   ` Joel Stanley
  2022-02-19 14:37   ` Guenter Roeck
  2022-02-15 15:10 ` [PATCH 4/4] hwmon: (occ) Add soft minimum power cap attribute Eddie James
  3 siblings, 2 replies; 15+ messages in thread
From: Eddie James @ 2022-02-15 15:10 UTC (permalink / raw)
  To: linux-hwmon; +Cc: linux-kernel, jdelvare, linux, joel, eajames

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] 15+ messages in thread

* [PATCH 4/4] hwmon: (occ) Add soft minimum power cap attribute
  2022-02-15 15:10 [PATCH 0/4] hwmon: (occ) Add various poll response data in sysfs Eddie James
                   ` (2 preceding siblings ...)
  2022-02-15 15:10 ` [PATCH 3/4] hwmon: (occ) Add sysfs entries for additional extended status bits Eddie James
@ 2022-02-15 15:10 ` Eddie James
  2022-02-16  6:33   ` Joel Stanley
  2022-02-22 16:52   ` Guenter Roeck
  3 siblings, 2 replies; 15+ messages in thread
From: Eddie James @ 2022-02-15 15:10 UTC (permalink / raw)
  To: linux-hwmon; +Cc: linux-kernel, jdelvare, linux, joel, eajames

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] 15+ messages in thread

* Re: [PATCH 1/4] hwmon: (occ) Add sysfs entry for IPS (Idle Power Saver) status
  2022-02-15 15:10 ` [PATCH 1/4] hwmon: (occ) Add sysfs entry for IPS (Idle Power Saver) status Eddie James
@ 2022-02-16  6:10   ` Joel Stanley
  2022-02-19 14:36   ` Guenter Roeck
  1 sibling, 0 replies; 15+ messages in thread
From: Joel Stanley @ 2022-02-16  6:10 UTC (permalink / raw)
  To: Eddie James
  Cc: linux-hwmon, Linux Kernel Mailing List, Jean Delvare, Guenter Roeck

On Tue, 15 Feb 2022 at 15:11, Eddie James <eajames@linux.ibm.com> wrote:
>
> 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>

Reviewed-by: Joel Stanley <joel@jms.id.au>

> ---
>  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	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/4] hwmon: (occ) Add sysfs entry for OCC mode
  2022-02-15 15:10 ` [PATCH 2/4] hwmon: (occ) Add sysfs entry for OCC mode Eddie James
@ 2022-02-16  6:11   ` Joel Stanley
  2022-02-19 14:37   ` Guenter Roeck
  1 sibling, 0 replies; 15+ messages in thread
From: Joel Stanley @ 2022-02-16  6:11 UTC (permalink / raw)
  To: Eddie James
  Cc: linux-hwmon, Linux Kernel Mailing List, Jean Delvare, Guenter Roeck

On Tue, 15 Feb 2022 at 15:11, Eddie James <eajames@linux.ibm.com> wrote:
>
> 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>

Reviewed-by: Joel Stanley <joel@jms.id.au>

> ---
>  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	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/4] hwmon: (occ) Add sysfs entries for additional extended status bits
  2022-02-15 15:10 ` [PATCH 3/4] hwmon: (occ) Add sysfs entries for additional extended status bits Eddie James
@ 2022-02-16  6:12   ` Joel Stanley
  2022-02-19 14:37   ` Guenter Roeck
  1 sibling, 0 replies; 15+ messages in thread
From: Joel Stanley @ 2022-02-16  6:12 UTC (permalink / raw)
  To: Eddie James
  Cc: linux-hwmon, Linux Kernel Mailing List, Jean Delvare, Guenter Roeck

On Tue, 15 Feb 2022 at 15:11, Eddie James <eajames@linux.ibm.com> wrote:
>
> 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>

Reviewed-by: Joel Stanley <joel@jms.id.au>

> ---
>  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	[flat|nested] 15+ messages in thread

* Re: [PATCH 4/4] hwmon: (occ) Add soft minimum power cap attribute
  2022-02-15 15:10 ` [PATCH 4/4] hwmon: (occ) Add soft minimum power cap attribute Eddie James
@ 2022-02-16  6:33   ` Joel Stanley
  2022-02-16 20:09     ` Eddie James
  2022-02-22 16:52   ` Guenter Roeck
  1 sibling, 1 reply; 15+ messages in thread
From: Joel Stanley @ 2022-02-16  6:33 UTC (permalink / raw)
  To: Eddie James
  Cc: linux-hwmon, Linux Kernel Mailing List, Jean Delvare, Guenter Roeck

On Tue, 15 Feb 2022 at 15:11, Eddie James <eajames@linux.ibm.com> wrote:
>
> 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);

How do we know this changed from 8 to 9?

We should start adding links to the occ source code, or a similar
reference, when making these changes so they can be reviewed.

> +               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	[flat|nested] 15+ messages in thread

* Re: [PATCH 4/4] hwmon: (occ) Add soft minimum power cap attribute
  2022-02-16  6:33   ` Joel Stanley
@ 2022-02-16 20:09     ` Eddie James
  2022-02-21  7:39       ` Joel Stanley
  0 siblings, 1 reply; 15+ messages in thread
From: Eddie James @ 2022-02-16 20:09 UTC (permalink / raw)
  To: Joel Stanley
  Cc: linux-hwmon, Linux Kernel Mailing List, Jean Delvare, Guenter Roeck


On 2/16/22 00:33, Joel Stanley wrote:
> On Tue, 15 Feb 2022 at 15:11, Eddie James <eajames@linux.ibm.com> wrote:
>> 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);
> How do we know this changed from 8 to 9?


Well we made the structure change a while back when adding P10 support, 
but didn't bother to export the "soft min" field. Now it's needed.


>
> We should start adding links to the occ source code, or a similar
> reference, when making these changes so they can be reviewed.


I would but it doesn't appear to be public for P10 yet... at least, no 
one has updated the P9 OCC spec hosted in the open-power repo: 
https://github.com/open-power/docs


Thanks,

Eddie


>
>> +               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	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/4] hwmon: (occ) Add sysfs entry for IPS (Idle Power Saver) status
  2022-02-15 15:10 ` [PATCH 1/4] hwmon: (occ) Add sysfs entry for IPS (Idle Power Saver) status Eddie James
  2022-02-16  6:10   ` Joel Stanley
@ 2022-02-19 14:36   ` Guenter Roeck
  1 sibling, 0 replies; 15+ messages in thread
From: Guenter Roeck @ 2022-02-19 14:36 UTC (permalink / raw)
  To: Eddie James; +Cc: linux-hwmon, linux-kernel, jdelvare, joel

On Tue, Feb 15, 2022 at 09:10:19AM -0600, Eddie James wrote:
> 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>
> Reviewed-by: Joel Stanley <joel@jms.id.au>

Applied to hwmon-next.

Thanks,
Guenter

> ---
>  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)

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/4] hwmon: (occ) Add sysfs entry for OCC mode
  2022-02-15 15:10 ` [PATCH 2/4] hwmon: (occ) Add sysfs entry for OCC mode Eddie James
  2022-02-16  6:11   ` Joel Stanley
@ 2022-02-19 14:37   ` Guenter Roeck
  1 sibling, 0 replies; 15+ messages in thread
From: Guenter Roeck @ 2022-02-19 14:37 UTC (permalink / raw)
  To: Eddie James; +Cc: linux-hwmon, linux-kernel, jdelvare, joel

On Tue, Feb 15, 2022 at 09:10:20AM -0600, Eddie James wrote:
> 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>
> Reviewed-by: Joel Stanley <joel@jms.id.au>

Applied to hwmon-next.

Thanks,
Guenter

> ---
>  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)

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/4] hwmon: (occ) Add sysfs entries for additional extended status bits
  2022-02-15 15:10 ` [PATCH 3/4] hwmon: (occ) Add sysfs entries for additional extended status bits Eddie James
  2022-02-16  6:12   ` Joel Stanley
@ 2022-02-19 14:37   ` Guenter Roeck
  1 sibling, 0 replies; 15+ messages in thread
From: Guenter Roeck @ 2022-02-19 14:37 UTC (permalink / raw)
  To: Eddie James; +Cc: linux-hwmon, linux-kernel, jdelvare, joel

On Tue, Feb 15, 2022 at 09:10:21AM -0600, Eddie James wrote:
> 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>
> Reviewed-by: Joel Stanley <joel@jms.id.au>

Applied to hwmon-next.

Thanks,
Guenter

> ---
>  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;

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 4/4] hwmon: (occ) Add soft minimum power cap attribute
  2022-02-16 20:09     ` Eddie James
@ 2022-02-21  7:39       ` Joel Stanley
  0 siblings, 0 replies; 15+ messages in thread
From: Joel Stanley @ 2022-02-21  7:39 UTC (permalink / raw)
  To: Eddie James
  Cc: linux-hwmon, Linux Kernel Mailing List, Jean Delvare, Guenter Roeck

On Wed, 16 Feb 2022 at 20:09, Eddie James <eajames@linux.ibm.com> wrote:
>
>
> On 2/16/22 00:33, Joel Stanley wrote:
> > On Tue, 15 Feb 2022 at 15:11, Eddie James <eajames@linux.ibm.com> wrote:
> >> 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);
> > How do we know this changed from 8 to 9?
>
>
> Well we made the structure change a while back when adding P10 support,
> but didn't bother to export the "soft min" field. Now it's needed.
>
>
> >
> > We should start adding links to the occ source code, or a similar
> > reference, when making these changes so they can be reviewed.
>
>
> I would but it doesn't appear to be public for P10 yet... at least, no
> one has updated the P9 OCC spec hosted in the open-power repo:
> https://github.com/open-power/docs

Ok. Lets follow that up internally. For this patch:

Reviewed-by: Joel Stanley <joel@jms.id.au>

Cheers,

Joel

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 4/4] hwmon: (occ) Add soft minimum power cap attribute
  2022-02-15 15:10 ` [PATCH 4/4] hwmon: (occ) Add soft minimum power cap attribute Eddie James
  2022-02-16  6:33   ` Joel Stanley
@ 2022-02-22 16:52   ` Guenter Roeck
  1 sibling, 0 replies; 15+ messages in thread
From: Guenter Roeck @ 2022-02-22 16:52 UTC (permalink / raw)
  To: Eddie James; +Cc: linux-hwmon, linux-kernel, jdelvare, joel

On Tue, Feb 15, 2022 at 09:10:22AM -0600, Eddie James wrote:
> Export the power caps data for the soft minimum power cap through hwmon.
> 
> Signed-off-by: Eddie James <eajames@linux.ibm.com>
> Reviewed-by: Joel Stanley <joel@jms.id.au>

Applied to hwmon-next.

Thanks,
Guenter

> ---
>  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++;
> +			}
>  		}
>  	}
>  

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2022-02-22 16:52 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-15 15:10 [PATCH 0/4] hwmon: (occ) Add various poll response data in sysfs Eddie James
2022-02-15 15:10 ` [PATCH 1/4] hwmon: (occ) Add sysfs entry for IPS (Idle Power Saver) status Eddie James
2022-02-16  6:10   ` Joel Stanley
2022-02-19 14:36   ` Guenter Roeck
2022-02-15 15:10 ` [PATCH 2/4] hwmon: (occ) Add sysfs entry for OCC mode Eddie James
2022-02-16  6:11   ` Joel Stanley
2022-02-19 14:37   ` Guenter Roeck
2022-02-15 15:10 ` [PATCH 3/4] hwmon: (occ) Add sysfs entries for additional extended status bits Eddie James
2022-02-16  6:12   ` Joel Stanley
2022-02-19 14:37   ` Guenter Roeck
2022-02-15 15:10 ` [PATCH 4/4] hwmon: (occ) Add soft minimum power cap attribute Eddie James
2022-02-16  6:33   ` Joel Stanley
2022-02-16 20:09     ` Eddie James
2022-02-21  7:39       ` Joel Stanley
2022-02-22 16:52   ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).