From: Karthik Poosa <karthik.poosa@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: anshuman.gupta@intel.com, badal.nilawar@intel.com,
Karthik Poosa <karthik.poosa@intel.com>
Subject: [PATCH] drm/xe/hwmon: Add label support
Date: Thu, 1 Feb 2024 23:28:46 +0530 [thread overview]
Message-ID: <20240201175846.434392-1-karthik.poosa@intel.com> (raw)
Add label for power and energy attributes.
Signed-off-by: Karthik Poosa <karthik.poosa@intel.com>
---
drivers/gpu/drm/xe/xe_hwmon.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c
index 89c6f7f84b5a..9fd70bff3435 100644
--- a/drivers/gpu/drm/xe/xe_hwmon.c
+++ b/drivers/gpu/drm/xe/xe_hwmon.c
@@ -403,10 +403,10 @@ static const struct attribute_group *hwmon_groups[] = {
};
static const struct hwmon_channel_info * const hwmon_info[] = {
- HWMON_CHANNEL_INFO(power, HWMON_P_MAX | HWMON_P_RATED_MAX | HWMON_P_CRIT),
+ HWMON_CHANNEL_INFO(power, HWMON_P_MAX | HWMON_P_RATED_MAX | HWMON_P_CRIT | HWMON_P_LABEL),
HWMON_CHANNEL_INFO(curr, HWMON_C_CRIT),
HWMON_CHANNEL_INFO(in, HWMON_I_INPUT),
- HWMON_CHANNEL_INFO(energy, HWMON_E_INPUT),
+ HWMON_CHANNEL_INFO(energy, HWMON_E_INPUT | HWMON_E_LABEL),
NULL
};
@@ -484,6 +484,8 @@ xe_hwmon_power_is_visible(struct xe_hwmon *hwmon, u32 attr, int chan)
case hwmon_power_crit:
return (xe_hwmon_pcode_read_i1(hwmon->gt, &uval) ||
!(uval & POWER_SETUP_I1_WATTS)) ? 0 : 0644;
+ case hwmon_power_label:
+ return 0444;
default:
return 0;
}
@@ -584,6 +586,8 @@ xe_hwmon_energy_is_visible(struct xe_hwmon *hwmon, u32 attr)
switch (attr) {
case hwmon_energy_input:
return xe_hwmon_get_reg(hwmon, REG_PKG_ENERGY_STATUS) ? 0444 : 0;
+ case hwmon_energy_label:
+ return 0444;
default:
return 0;
}
@@ -691,10 +695,26 @@ xe_hwmon_write(struct device *dev, enum hwmon_sensor_types type, u32 attr,
return ret;
}
+static int xe_hwmon_read_label(struct device *dev,
+ enum hwmon_sensor_types type,
+ u32 attr, int channel, const char **str)
+{
+ switch (type) {
+ case hwmon_power:
+ case hwmon_energy:
+ *str = "card";
+ return 0;
+ default:
+ return -EOPNOTSUPP;
+ }
+}
+
+
static const struct hwmon_ops hwmon_ops = {
.is_visible = xe_hwmon_is_visible,
.read = xe_hwmon_read,
.write = xe_hwmon_write,
+ .read_string = xe_hwmon_read_label,
};
static const struct hwmon_chip_info hwmon_chip_info = {
--
2.25.1
next reply other threads:[~2024-02-01 17:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 17:58 Karthik Poosa [this message]
2024-02-01 18:10 ` ✓ CI.Patch_applied: success for drm/xe/hwmon: Add label support Patchwork
2024-02-01 18:10 ` ✗ CI.checkpatch: warning " Patchwork
2024-02-01 18:11 ` ✓ CI.KUnit: success " Patchwork
2024-02-01 18:18 ` ✓ CI.Build: " Patchwork
2024-02-01 18:18 ` ✓ CI.Hooks: " Patchwork
2024-02-01 18:20 ` ✓ CI.checksparse: " Patchwork
2024-02-01 18:43 ` ✓ CI.BAT: " Patchwork
2024-02-02 11:52 ` [PATCH] " Nilawar, Badal
2024-02-06 5:47 ` Poosa, Karthik
2024-02-06 7:13 ` Riana Tauro
2024-02-06 15:40 ` Poosa, Karthik
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=20240201175846.434392-1-karthik.poosa@intel.com \
--to=karthik.poosa@intel.com \
--cc=anshuman.gupta@intel.com \
--cc=badal.nilawar@intel.com \
--cc=intel-xe@lists.freedesktop.org \
/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