drm/i915/hwmon: expose fan speed
Subsystems (3)
PATCH v2 1/1 drm/i915/hwmon: expose fan speed
Add hwmon support for fan1_input attribute, which will expose fan speed in RPM. With this in place we can monitor fan speed using lm-sensors tool.
$ sensors i915-pci-0300 Adapter: PCI adapter in0: 653.00 mV fan1: 3833 RPM power1: N/A (max = 43.00 W) energy1: 32.02 kJ
v2:
- Add mutex protection
- Handle overflow
- Add ABI documentation
- Aesthetic adjustments
--- .../ABI/testing/sysfs-driver-intel-i915-hwmon | 8 ++ drivers/gpu/drm/i915/gt/intel_gt_regs.h | 2 + drivers/gpu/drm/i915/i915_hwmon.c | 87 +++++++++++++++++++ 3 files changed, 97 insertions(+)
Documentation/ABI/testing/sysfs-driver-intel-i915-hwmon +8 -0
@@ -75,3 +75,11 @@ Description: RO. Energy input of device or gt in microjoules. for the gt. Only supported for particular Intel i915 graphics platforms. + +What: /sys/bus/pci/drivers/i915/.../hwmon/hwmon<i>/fan1_input +Date: August 2024 +KernelVersion: 6.11 +Contact: [email protected] +Description: RO. Fan speed of device in RPM. + + Only supported for particular Intel i915 graphics platforms.
drivers/gpu/drm/i915/gt/intel_gt_regs.h +2 -0
@@ -1553,6 +1553,8 @@#define VLV_RENDER_C0_COUNT _MMIO(0x138118)#define VLV_MEDIA_C0_COUNT _MMIO(0x13811c) +#define PCU_PWM_FAN_SPEED _MMIO(0x138140) +#define GEN12_RPSTAT1 _MMIO(0x1381b4)#define GEN12_VOLTAGE_MASK REG_GENMASK(10, 0)#define GEN12_CAGF_MASK REG_GENMASK(19, 11)
drivers/gpu/drm/i915/i915_hwmon.c +87 -0
146 lines not on this page · raw message
Signature · 1 line
2.34.1
Patchwork
CI✗ Fi.CI.BAT: failure for drm/i915/hwmon: expose fan speed (rev2)
== Series Details ==
== Series Details ==
Series: drm/i915/hwmon: expose fan speed (rev2)
URL : https://patchwork.freedesktop.org/series/136036/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_15151 -> Patchwork_136036v2
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with Patchwork_136036v2 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes
introduced in Patchwork_136036v2, please notify your bug team ([email protected]) to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136036v2/index.html
Participating hosts (41 -> 42)
------------------------------
Additional (2): fi-tgl-1115g4 fi-elk-e7500
Missing (1): fi-snb-2520m
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_136036v2:
### IGT changes ###
#### Possible regressions ####
* igt@runner@aborted:
- fi-elk-e7500: NOTRUN -> [FAIL][1]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136036v2/fi-elk-e7500/igt@[email protected]
- fi-tgl-1115g4: NOTRUN -> [FAIL][2]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136036v2/fi-tgl-1115g4/igt@[email protected]
#### Warnings ####
* igt@runner@aborted:
- fi-kbl-x1275: [FAIL][3] ([i915#11781]) -> [FAIL][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15151/fi-kbl-x1275/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136036v2/fi-kbl-x1275/igt@[email protected]
- fi-cfl-8109u: [FAIL][5] ([i915#11781]) -> [FAIL][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15151/fi-cfl-8109u/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136036v2/fi-cfl-8109u/igt@[email protected]
- fi-ivb-3770: [FAIL][7] ([i915#11781]) -> [FAIL][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15151/fi-ivb-3770/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136036v2/fi-ivb-3770/igt@[email protected]
- fi-kbl-guc: [FAIL][9] ([i915#11781]) -> [FAIL][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15151/fi-kbl-guc/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136036v2/fi-kbl-guc/igt@[email protected]
- fi-ilk-650: [FAIL][11] ([i915#11781]) -> [FAIL][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15151/fi-ilk-650/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136036v2/fi-ilk-650/igt@[email protected]
- fi-blb-e6850: [FAIL][13] ([i915#11781]) -> [FAIL][14]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15151/fi-blb-e6850/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136036v2/fi-blb-e6850/igt@[email protected]
- fi-bsw-n3050: [FAIL][15] ([i915#11781]) -> [FAIL][16]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15151/fi-bsw-n3050/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136036v2/fi-bsw-n3050/igt@[email protected]
- fi-pnv-d510: [FAIL][17] ([i915#11781]) -> [FAIL][18]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15151/fi-pnv-d510/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136036v2/fi-pnv-d510/igt@[email protected]
- fi-glk-j4005: [FAIL][19] ([i915#11781]) -> [FAIL][20]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15151/fi-glk-j4005/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136036v2/fi-glk-j4005/igt@[email protected]
- fi-kbl-7567u: [FAIL][21] ([i915#11781]) -> [FAIL][22]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15151/fi-kbl-7567u/igt@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136036v2/fi-kbl-7567u/igt@[email protected]
- bat-apl-1: [FAIL][23] ([i915#11781]) -> [FAIL][24]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15151/bat-apl-1/igt@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136036v2/bat-apl-1/igt@[email protected]
- bat-atsm-1: [FAIL][25] ([i915#11781]) -> [FAIL][26]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15151/bat-atsm-1/igt@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136036v2/bat-atsm-1/igt@[email protected]
- fi-cfl-guc: [FAIL][27] ([i915#11781]) -> [FAIL][28]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15151/fi-cfl-guc/igt@[email protected]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136036v2/fi-cfl-guc/igt@[email protected]
Known issues
------------
Here are the changes found in Patchwork_136036v2 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@i915_selftest@live@hangcheck:
- bat-arls-2: [PASS][29] -> [DMESG-WARN][30] ([i915#11349] / [i915#11378])
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15151/bat-arls-2/igt@i915_selftest@[email protected]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136036v2/bat-arls-2/igt@i915_selftest@[email protected]
#### Possible fixes ####
* igt@i915_selftest@live@gt_lrc:
- bat-twl-2: [INCOMPLETE][31] ([i915#9413]) -> [PASS][32]
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15151/bat-twl-2/igt@i915_selftest@live@gt_lrc.html
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136036v2/bat-twl-2/igt@i915_selftest@live@gt_lrc.html
* igt@i915_selftest@live@gt_mocs:
- {bat-arlh-3}: [INCOMPLETE][33] ([i915#11775]) -> [PASS][34]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15151/bat-arlh-3/igt@i915_selftest@live@gt_mocs.html
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136036v2/bat-arlh-3/igt@i915_selftest@live@gt_mocs.html
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[i915#11349]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11349
[i915#11378]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11378
[i915#11775]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11775
[i915#11781]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11781
[i915#9413]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/9413
Build changes
-------------
* Linux: CI_DRM_15151 -> Patchwork_136036v2
CI-20190529: 20190529
CI_DRM_15151: b6f9528c7fffc2f65c8e4969d35d9346fd503c9b @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7942: 0f02dc176959e6296866b1bafd3982e277a5e44b @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_136036v2: b6f9528c7fffc2f65c8e4969d35d9346fd503c9b @ git://anongit.freedesktop.org/gfx-ci/linux
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136036v2/index.html
Hi Raag
Quoted 11 lines · Raag Jadav
Add hwmon support for
fan1_inputattribute, which will expose fan speed in RPM. With this in place we can monitor fan speed using lm-sensors tool.$ sensors i915-pci-0300 Adapter: PCI adapter in0: 653.00 mV fan1: 3833 RPM power1: N/A (max = 43.00 W) energy1: 32.02 kJ
Quoted 7 lines
v2:
- Add mutex protection
- Handle overflow
- Add ABI documentation
- Aesthetic adjustmentsSigned-off-by Raag Jadav <[email protected]>
Add the name in front of the comments given by reviewer in version history
With that
Quoted 193 lines
--- .../ABI/testing/sysfs-driver-intel-i915-hwmon | 8 ++ drivers/gpu/drm/i915/gt/intel_gt_regs.h | 2 + drivers/gpu/drm/i915/i915_hwmon.c | 87 +++++++++++++++++++ 3 files changed, 97 insertions(+)Documentation/ABI/testing/sysfs-driver-intel-i915-hwmon +8
-0@@ -75,3 +75,11 @@ Description: RO. Energy input of device or gt in microjoules. for the gt. Only supported for particular Intel i915 graphics platforms. + +What: /sys/bus/pci/drivers/i915/.../hwmon/hwmon<i>/fan1_input +Date: August 2024 +KernelVersion: 6.11 +Contact: [email protected] +Description: RO. Fan speed of device in RPM. + + Only supported for particular Intel i915 graphics platforms.drivers/gpu/drm/i915/gt/intel_gt_regs.h +2
-0@@ -1553,6 +1553,8 @@#define VLV_RENDER_C0_COUNT _MMIO(0x138118)#define VLV_MEDIA_C0_COUNT _MMIO(0x13811c) +#define PCU_PWM_FAN_SPEED _MMIO(0x138140) +#define GEN12_RPSTAT1 _MMIO(0x1381b4)#define GEN12_VOLTAGE_MASK REG_GENMASK(10, 0)#define GEN12_CAGF_MASK REG_GENMASK(19, 11)drivers/gpu/drm/i915/i915_hwmon.c +87
-0@@ -36,6 +36,7 @@ struct hwm_reg {i915_reg_t pkg_rapl_limit;i915_reg_t energy_status_all;i915_reg_t energy_status_tile; +i915_reg_t fan_speed; };struct hwm_energy_info {@@ -43,11 +44,17 @@ struct hwm_energy_info {long accum_energy;/* Accumulated energy for energy1_input */ }; +struct hwm_fan_info { +u32 reg_val_prev; +u32 time_prev; +}; +struct hwm_drvdata {struct i915_hwmon *hwmon;struct intel_uncore *uncore;struct device *hwmon_dev;struct hwm_energy_info ei;/* Energy info for energy1_input */ +struct hwm_fan_info fi;/* Fan info for fan1_input */ char name[12 ];int gt_n;bool reset_in_progress;@@ -276,6 +283,7 @@ static const struct hwmon_channel_info * const hwm_info[] = {HWMON_CHANNEL_INFO (power,HWMON_P_MAX |HWMON_P_RATED_MAX |HWMON_P_CRIT ),HWMON_CHANNEL_INFO (energy,HWMON_E_INPUT ),HWMON_CHANNEL_INFO (curr,HWMON_C_CRIT ), +HWMON_CHANNEL_INFO (fan,HWMON_F_INPUT ), NULL };@@ -613,6 +621,69 @@ hwm_curr_write(struct hwm_drvdata *ddat, u32 attr, long val) } } +static umode_t +hwm_fan_is_visible (const struct hwm_drvdata *ddat,u32 attr) +{ +struct i915_hwmon *hwmon = ddat->hwmon; + +switch (attr) { +case hwmon_fan_input: +return i915_mmio_reg_valid (hwmon->rg.fan_speed) ?0444 :0 ; +default : +return 0 ; + } +} + +static int +hwm_fan_read (struct hwm_drvdata *ddat,u32 attr,long *val) +{ +struct i915_hwmon *hwmon = ddat->hwmon; +struct hwm_fan_info *fi = &ddat->fi; +u32 reg_val, rotations, pulses, time, time_now; +intel_wakeref_t wakeref; +int ret =0 ; + +switch (attr) { +case hwmon_fan_input: + with_intel_runtime_pm(ddat->uncore->rpm, wakeref) { +mutex_lock (&hwmon->hwmon_lock); + + reg_val =intel_uncore_read (ddat->uncore, hwmon->rg.fan_speed); + time_now =jiffies_to_msecs (jiffies); + +/* Handle overflow */ +if (reg_val >= fi->reg_val_prev) + pulses = reg_val - fi->reg_val_prev; +else + pulses =UINT_MAX - fi->reg_val_prev + reg_val; + +/* +* HW register value is accumulated count of pulses from +* PWM fan with the scale of 2 pulses per rotation. +*/ + rotations = pulses >>1 ; + time = time_now - fi->time_prev; + +if (unlikely (!time)) { + ret = -EAGAIN ; +mutex_unlock (&hwmon->hwmon_lock); +break ; + } + +/* Convert to minutes for calculating RPM */ + *val =DIV_ROUND_UP ((long )rotations * (60 *MSEC_PER_SEC ), time); + + fi->reg_val_prev = reg_val; + fi->time_prev = time_now; + +mutex_unlock (&hwmon->hwmon_lock); + } +return ret; +default : +return -EOPNOTSUPP ; + } +} +static umode_t hwm_is_visible (const void *drvdata,enum hwmon_sensor_types type,u32 attr,int channel)@@ -628,6 +699,8 @@ hwm_is_visible(const void *drvdata, enum hwmon_sensor_types type,return hwm_energy_is_visible (ddat, attr);case hwmon_curr:return hwm_curr_is_visible (ddat, attr); +case hwmon_fan: +return hwm_fan_is_visible (ddat, attr);default :return 0 ; }@@ -648,6 +721,8 @@ hwm_read(struct device *dev, enum hwmon_sensor_types type, u32 attr,return hwm_energy_read (ddat, attr, val);case hwmon_curr:return hwm_curr_read (ddat, attr, val); +case hwmon_fan: +return hwm_fan_read (ddat, attr, val);default :return -EOPNOTSUPP ; }@@ -739,12 +814,14 @@ hwm_get_preregistration_info(struct drm_i915_private *i915) hwmon->rg.pkg_rapl_limit =PCU_PACKAGE_RAPL_LIMIT ; hwmon->rg.energy_status_all =PCU_PACKAGE_ENERGY_STATUS ; hwmon->rg.energy_status_tile =INVALID_MMIO_REG ; + hwmon->rg.fan_speed =PCU_PWM_FAN_SPEED ; }else { hwmon->rg.pkg_power_sku_unit =INVALID_MMIO_REG ; hwmon->rg.pkg_power_sku =INVALID_MMIO_REG ; hwmon->rg.pkg_rapl_limit =INVALID_MMIO_REG ; hwmon->rg.energy_status_all =INVALID_MMIO_REG ; hwmon->rg.energy_status_tile =INVALID_MMIO_REG ; + hwmon->rg.fan_speed =INVALID_MMIO_REG ; } with_intel_runtime_pm(uncore->rpm, wakeref) {@@ -755,6 +832,16 @@ hwm_get_preregistration_info(struct drm_i915_private *i915)if (i915_mmio_reg_valid (hwmon->rg.pkg_power_sku_unit)) val_sku_unit =intel_uncore_read (uncore, hwmon->rg.pkg_power_sku_unit); + +/* +* Store the initial fan register value, so that we can use it for +* initial fan speed calculation. +*/ +if (i915_mmio_reg_valid (hwmon->rg.fan_speed)) { + ddat->fi.reg_val_prev =intel_uncore_read (uncore, + hwmon->rg.fan_speed); + ddat->fi.time_prev =jiffies_to_msecs (jiffies); + } } hwmon->scl_shift_power =REG_FIELD_GET (PKG_PWR_UNIT , val_sku_unit);