summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/xe/xe_guc_pc.c
diff options
context:
space:
mode:
authorRiana Tauro <riana.tauro@intel.com>2023-06-23 08:24:30 +0300
committerRodrigo Vivi <rodrigo.vivi@intel.com>2023-12-21 19:35:00 +0300
commit1c2097bbde107effe2183891f92c060aa64bfa8b (patch)
tree1d02530c5ae0087e042b128a98a39814dae0ec7a /drivers/gpu/drm/xe/xe_guc_pc.c
parent513e82627931d0ac6b74b9c2595008b3573a5158 (diff)
downloadlinux-1c2097bbde107effe2183891f92c060aa64bfa8b.tar.xz
drm/xe: add a new sysfs directory for gtidle properties
1) Add a new sysfs directory under devices/gt#/ called gtidle to contain idle properties of GT such as name, idle_status, idle_residency_ms 2) Remove forcewake calls for residency counter v2: - abstract using function pointers (Anshuman) - remove forcewake calls for residency counter - use device_attr (Badal) - move rc functions to guc_pc - change name to gt_idle (Rodrigo) v3: - return error for drmm_add_action_or_reset - replace file and functions with gt_idle prefix to gt_idle_sysfs (Himal) - use enum for gt idle state - move multiplier to gt idle and initialize (Anshuman) - correct doc annotation (Rodrigo) - remove return variable - use kobj_gt instead of new gtidle kobj - move residency_ms to gtidle file - retain xe_guc_pc prefix for functions in guc_rc file (Michal) v4: - fix doc errors in xe_guc_pc file - change u64 to u32 for reading residency counter - keep gtidle states generic GT_IDLE_C[0/6] (Anshuman) v5: - update commit message to include removal of forcewake calls (Anshuman) - return void from sysfs initialization function and add warnings (Andi) v6: - remove extra lines (Anshuman) Signed-off-by: Riana Tauro <riana.tauro@intel.com> Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Reviewed-by: Anshuman Gupta <anshuman.gupta@intel.com> Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Diffstat (limited to 'drivers/gpu/drm/xe/xe_guc_pc.c')
-rw-r--r--drivers/gpu/drm/xe/xe_guc_pc.c45
1 files changed, 16 insertions, 29 deletions
diff --git a/drivers/gpu/drm/xe/xe_guc_pc.c b/drivers/gpu/drm/xe/xe_guc_pc.c
index 5d5cf4b0d508..f02bf1641380 100644
--- a/drivers/gpu/drm/xe/xe_guc_pc.c
+++ b/drivers/gpu/drm/xe/xe_guc_pc.c
@@ -76,12 +76,7 @@
*
* Render-C states is also a GuC PC feature that is now enabled in Xe for
* all platforms.
- * Xe's GuC PC provides a sysfs API for Render-C States:
*
- * device/gt#/rc* *read-only* files:
- * - rc_status: Provide the actual immediate status of Render-C: (rc0 or rc6)
- * - rc6_residency: Provide the rc6_residency counter in units of 1.28 uSec.
- * Prone to overflows.
*/
static struct xe_guc *
@@ -572,10 +567,12 @@ out:
}
static DEVICE_ATTR_RW(freq_max);
-static ssize_t rc_status_show(struct device *dev,
- struct device_attribute *attr, char *buff)
+/**
+ * xe_guc_pc_rc_status - get the current Render C state
+ * @pc: XE_GuC_PC instance
+ */
+enum xe_gt_idle_state xe_guc_pc_rc_status(struct xe_guc_pc *pc)
{
- struct xe_guc_pc *pc = dev_to_pc(dev);
struct xe_gt *gt = pc_to_gt(pc);
u32 reg;
@@ -585,37 +582,29 @@ static ssize_t rc_status_show(struct device *dev,
switch (REG_FIELD_GET(RCN_MASK, reg)) {
case GT_RC6:
- return sysfs_emit(buff, "rc6\n");
+ return GT_IDLE_C6;
case GT_RC0:
- return sysfs_emit(buff, "rc0\n");
+ return GT_IDLE_C0;
default:
- return -ENOENT;
+ return GT_IDLE_UNKNOWN;
}
}
-static DEVICE_ATTR_RO(rc_status);
-static ssize_t rc6_residency_show(struct device *dev,
- struct device_attribute *attr, char *buff)
+/**
+ * xe_guc_pc_rc6_residency - rc6 residency counter
+ * @pc: Xe_GuC_PC instance
+ */
+u64 xe_guc_pc_rc6_residency(struct xe_guc_pc *pc)
{
- struct xe_guc_pc *pc = dev_to_pc(dev);
struct xe_gt *gt = pc_to_gt(pc);
u32 reg;
- ssize_t ret;
-
- xe_device_mem_access_get(pc_to_xe(pc));
- ret = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
- if (ret)
- goto out;
+ xe_device_mem_access_get(gt_to_xe(gt));
reg = xe_mmio_read32(gt, GT_GFX_RC6);
- ret = sysfs_emit(buff, "%u\n", reg);
+ xe_device_mem_access_put(gt_to_xe(gt));
- XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
-out:
- xe_device_mem_access_put(pc_to_xe(pc));
- return ret;
+ return reg;
}
-static DEVICE_ATTR_RO(rc6_residency);
static const struct attribute *pc_attrs[] = {
&dev_attr_freq_act.attr,
@@ -625,8 +614,6 @@ static const struct attribute *pc_attrs[] = {
&dev_attr_freq_rpn.attr,
&dev_attr_freq_min.attr,
&dev_attr_freq_max.attr,
- &dev_attr_rc_status.attr,
- &dev_attr_rc6_residency.attr,
NULL
};