From: "Nilawar, Badal" <badal.nilawar@intel.com>
To: Raag Jadav <raag.jadav@intel.com>, <jani.nikula@linux.intel.com>,
<joonas.lahtinen@linux.intel.com>, <rodrigo.vivi@intel.com>,
<tursulin@ursulin.net>, <linux@roeck-us.net>,
<andi.shyti@linux.intel.com>, <andriy.shevchenko@linux.intel.com>
Cc: <intel-gfx@lists.freedesktop.org>, <linux-hwmon@vger.kernel.org>,
<anshuman.gupta@intel.com>, <riana.tauro@intel.com>,
<ashutosh.dixit@intel.com>, <karthik.poosa@intel.com>
Subject: Re: [PATCH v1] drm/i915/hwmon: expose package temperature
Date: Thu, 5 Sep 2024 11:56:15 +0530 [thread overview]
Message-ID: <07c01d49-aa9c-429e-bd4d-65cf2648329e@intel.com> (raw)
In-Reply-To: <20240828044512.2710381-1-raag.jadav@intel.com>
On 28-08-2024 10:15, Raag Jadav wrote:
> Add hwmon support for temp1_input attribute, which will expose package
> temperature in millidegree Celsius. With this in place we can monitor
> package temperature using lm-sensors tool.
>
> $ sensors
> i915-pci-0300
> Adapter: PCI adapter
> in0: 990.00 mV
> fan1: 1260 RPM
> temp1: +45.0°C
> power1: N/A (max = 35.00 W)
> energy1: 12.62 kJ
>
> Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11276
> Signed-off-by: Raag Jadav <raag.jadav@intel.com>
> ---
> .../ABI/testing/sysfs-driver-intel-i915-hwmon | 8 ++++
> drivers/gpu/drm/i915/i915_hwmon.c | 39 +++++++++++++++++++
> drivers/gpu/drm/i915/intel_mchbar_regs.h | 4 ++
> 3 files changed, 51 insertions(+)
>
> diff --git a/Documentation/ABI/testing/sysfs-driver-intel-i915-hwmon b/Documentation/ABI/testing/sysfs-driver-intel-i915-hwmon
> index be4141a7522f..a885e5316d02 100644
> --- a/Documentation/ABI/testing/sysfs-driver-intel-i915-hwmon
> +++ b/Documentation/ABI/testing/sysfs-driver-intel-i915-hwmon
> @@ -83,3 +83,11 @@ Contact: intel-gfx@lists.freedesktop.org
> Description: RO. Fan speed of device in RPM.
>
> Only supported for particular Intel i915 graphics platforms.
> +
> +What: /sys/bus/pci/drivers/i915/.../hwmon/hwmon<i>/temp1_input
> +Date: November 2024
> +KernelVersion: 6.12
> +Contact: intel-gfx@lists.freedesktop.org
> +Description: RO. GPU package temperature in millidegree Celsius.
> +
> + Only supported for particular Intel i915 graphics platforms.
> diff --git a/drivers/gpu/drm/i915/i915_hwmon.c b/drivers/gpu/drm/i915/i915_hwmon.c
> index 17d30f6b84b0..9f1a2300510b 100644
> --- a/drivers/gpu/drm/i915/i915_hwmon.c
> +++ b/drivers/gpu/drm/i915/i915_hwmon.c
> @@ -7,6 +7,7 @@
> #include <linux/hwmon-sysfs.h>
> #include <linux/jiffies.h>
> #include <linux/types.h>
> +#include <linux/units.h>
>
> #include "i915_drv.h"
> #include "i915_hwmon.h"
> @@ -32,6 +33,7 @@
>
> struct hwm_reg {
> i915_reg_t gt_perf_status;
> + i915_reg_t pkg_temp;
> i915_reg_t pkg_power_sku_unit;
> i915_reg_t pkg_power_sku;
> i915_reg_t pkg_rapl_limit;
> @@ -280,6 +282,7 @@ static const struct attribute_group *hwm_groups[] = {
> };
>
> static const struct hwmon_channel_info * const hwm_info[] = {
> + HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT),
> HWMON_CHANNEL_INFO(in, HWMON_I_INPUT),
> HWMON_CHANNEL_INFO(power, HWMON_P_MAX | HWMON_P_RATED_MAX | HWMON_P_CRIT),
> HWMON_CHANNEL_INFO(energy, HWMON_E_INPUT),
> @@ -310,6 +313,36 @@ static int hwm_pcode_write_i1(struct drm_i915_private *i915, u32 uval)
> POWER_SETUP_SUBCOMMAND_WRITE_I1, 0, uval);
> }
>
> +static umode_t
> +hwm_temp_is_visible(const struct hwm_drvdata *ddat, u32 attr)
> +{
> + struct i915_hwmon *hwmon = ddat->hwmon;
> +
> + if (attr == hwmon_temp_input && i915_mmio_reg_valid(hwmon->rg.pkg_temp))
> + return 0444;
> +
> + return 0;
> +}
> +
> +static int
> +hwm_temp_read(struct hwm_drvdata *ddat, u32 attr, long *val)
> +{
> + struct i915_hwmon *hwmon = ddat->hwmon;
> + intel_wakeref_t wakeref;
> + u32 reg_val;
> +
> + if (attr == hwmon_temp_input) {
> + with_intel_runtime_pm(ddat->uncore->rpm, wakeref)
> + reg_val = intel_uncore_read(ddat->uncore, hwmon->rg.pkg_temp);
> +
> + /* HW register value is in degrees, convert to millidegrees. */
> + *val = REG_FIELD_GET(TEMP_MASK, reg_val) * MILLIDEGREE_PER_DEGREE;
> + return 0;
> + }
> +
> + return -EOPNOTSUPP;
> +}
Let's try to have synergy between previous attribute, such as
hwm_fan_input, and this one.
Regards,
Badal
> +
> static umode_t
> hwm_in_is_visible(const struct hwm_drvdata *ddat, u32 attr)
> {
> @@ -692,6 +725,8 @@ hwm_is_visible(const void *drvdata, enum hwmon_sensor_types type,
> struct hwm_drvdata *ddat = (struct hwm_drvdata *)drvdata;
>
> switch (type) {
> + case hwmon_temp:
> + return hwm_temp_is_visible(ddat, attr);
> case hwmon_in:
> return hwm_in_is_visible(ddat, attr);
> case hwmon_power:
> @@ -714,6 +749,8 @@ hwm_read(struct device *dev, enum hwmon_sensor_types type, u32 attr,
> struct hwm_drvdata *ddat = dev_get_drvdata(dev);
>
> switch (type) {
> + case hwmon_temp:
> + return hwm_temp_read(ddat, attr, val);
> case hwmon_in:
> return hwm_in_read(ddat, attr, val);
> case hwmon_power:
> @@ -810,6 +847,7 @@ hwm_get_preregistration_info(struct drm_i915_private *i915)
> hwmon->rg.gt_perf_status = GEN12_RPSTAT1;
>
> if (IS_DG1(i915) || IS_DG2(i915)) {
> + hwmon->rg.pkg_temp = PCU_PACKAGE_TEMPERATURE;
> hwmon->rg.pkg_power_sku_unit = PCU_PACKAGE_POWER_SKU_UNIT;
> hwmon->rg.pkg_power_sku = PCU_PACKAGE_POWER_SKU;
> hwmon->rg.pkg_rapl_limit = PCU_PACKAGE_RAPL_LIMIT;
> @@ -817,6 +855,7 @@ hwm_get_preregistration_info(struct drm_i915_private *i915)
> hwmon->rg.energy_status_tile = INVALID_MMIO_REG;
> hwmon->rg.fan_speed = PCU_PWM_FAN_SPEED;
> } else {
> + hwmon->rg.pkg_temp = INVALID_MMIO_REG;
> 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;
> diff --git a/drivers/gpu/drm/i915/intel_mchbar_regs.h b/drivers/gpu/drm/i915/intel_mchbar_regs.h
> index 73900c098d59..dc2477179c3e 100644
> --- a/drivers/gpu/drm/i915/intel_mchbar_regs.h
> +++ b/drivers/gpu/drm/i915/intel_mchbar_regs.h
> @@ -207,6 +207,10 @@
> #define PCU_PACKAGE_ENERGY_STATUS _MMIO(MCHBAR_MIRROR_BASE_SNB + 0x593c)
>
> #define GEN6_GT_PERF_STATUS _MMIO(MCHBAR_MIRROR_BASE_SNB + 0x5948)
> +
> +#define PCU_PACKAGE_TEMPERATURE _MMIO(MCHBAR_MIRROR_BASE_SNB + 0x5978)
> +#define TEMP_MASK REG_GENMASK(7, 0)
> +
> #define GEN6_RP_STATE_LIMITS _MMIO(MCHBAR_MIRROR_BASE_SNB + 0x5994)
> #define GEN6_RP_STATE_CAP _MMIO(MCHBAR_MIRROR_BASE_SNB + 0x5998)
> #define RP0_CAP_MASK REG_GENMASK(7, 0)
next prev parent reply other threads:[~2024-09-05 6:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-28 4:45 [PATCH v1] drm/i915/hwmon: expose package temperature Raag Jadav
2024-08-28 4:34 ` ✗ Fi.CI.BUILD: failure for " Patchwork
2024-08-28 13:59 ` [PATCH v1] " Andy Shevchenko
2024-08-29 7:50 ` Raag Jadav
2024-09-03 20:03 ` ✗ Fi.CI.BAT: failure for drm/i915/hwmon: expose package temperature (rev2) Patchwork
2024-09-05 6:26 ` Nilawar, Badal [this message]
2024-09-05 8:55 ` [PATCH v1] drm/i915/hwmon: expose package temperature Raag Jadav
2024-09-05 14:09 ` Anshuman Gupta
2024-09-05 19:18 ` Raag Jadav
2024-09-06 6:26 ` Anshuman Gupta
2024-09-06 11:03 ` Nilawar, Badal
2024-09-07 11:18 ` Raag Jadav
2024-09-10 4:33 ` Nilawar, Badal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=07c01d49-aa9c-429e-bd4d-65cf2648329e@intel.com \
--to=badal.nilawar@intel.com \
--cc=andi.shyti@linux.intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=anshuman.gupta@intel.com \
--cc=ashutosh.dixit@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=karthik.poosa@intel.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=raag.jadav@intel.com \
--cc=riana.tauro@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=tursulin@ursulin.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox