diff mbox series

[3/4] hwmon: (occ) Add sysfs entries for additional extended status bits

Message ID 20220215151022.7498-4-eajames@linux.ibm.com (mailing list archive)
State Accepted
Headers show
Series hwmon: (occ) Add various poll response data in sysfs | expand

Commit Message

Eddie James Feb. 15, 2022, 3:10 p.m. UTC
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(+)

Comments

Joel Stanley Feb. 16, 2022, 6:12 a.m. UTC | #1
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
>
Guenter Roeck Feb. 19, 2022, 2:37 p.m. UTC | #2
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;
diff mbox series

Patch

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;