Reading current root sysfs entries gives a min/max of all GTs. Updating this so we return default (GT0) values when root level sysfs entries are accessed, instead of min/max for the card. Tests that are not multi GT capable will read incorrect sysfs values without this change on multi-GT platforms like MTL. Fixes: a8a4f0467d70 ("drm/i915: Fix CFI violations in gt_sysfs") Signed-off-by: Vinay Belgaumkar <vinay.belgaumkar@xxxxxxxxx> --- drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c | 47 +++------------------ 1 file changed, 6 insertions(+), 41 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c b/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c index cf71305ad586..395ae47483a7 100644 --- a/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c +++ b/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c @@ -28,77 +28,42 @@ sysfs_gt_attribute_w_func(struct kobject *kobj, struct attribute *attr, int (func)(struct intel_gt *gt, u32 val), u32 val) { struct intel_gt *gt; - int ret; if (!is_object_gt(kobj)) { - int i; struct device *dev = kobj_to_dev(kobj); struct drm_i915_private *i915 = kdev_minor_to_i915(dev); - for_each_gt(gt, i915, i) { - ret = func(gt, val); - if (ret) - break; - } + gt = to_gt(i915); } else { gt = intel_gt_sysfs_get_drvdata(kobj, attr->name); - ret = func(gt, val); } - return ret; + return func(gt, val); } static u32 sysfs_gt_attribute_r_func(struct kobject *kobj, struct attribute *attr, - u32 (func)(struct intel_gt *gt), - enum intel_gt_sysfs_op op) + u32 (func)(struct intel_gt *gt)) { struct intel_gt *gt; - u32 ret; - - ret = (op == INTEL_GT_SYSFS_MAX) ? 0 : (u32) -1; if (!is_object_gt(kobj)) { - int i; struct device *dev = kobj_to_dev(kobj); struct drm_i915_private *i915 = kdev_minor_to_i915(dev); - for_each_gt(gt, i915, i) { - u32 val = func(gt); - - switch (op) { - case INTEL_GT_SYSFS_MIN: - if (val < ret) - ret = val; - break; - - case INTEL_GT_SYSFS_MAX: - if (val > ret) - ret = val; - break; - } - } + gt = to_gt(i915); } else { gt = intel_gt_sysfs_get_drvdata(kobj, attr->name); - ret = func(gt); } - return ret; + return func(gt); } -/* RC6 interfaces will show the minimum RC6 residency value */ -#define sysfs_gt_attribute_r_min_func(d, a, f) \ - sysfs_gt_attribute_r_func(d, a, f, INTEL_GT_SYSFS_MIN) - -/* Frequency interfaces will show the maximum frequency value */ -#define sysfs_gt_attribute_r_max_func(d, a, f) \ - sysfs_gt_attribute_r_func(d, a, f, INTEL_GT_SYSFS_MAX) - #define INTEL_GT_SYSFS_SHOW(_name, _attr_type) \ static ssize_t _name##_show_common(struct kobject *kobj, \ struct attribute *attr, char *buff) \ { \ - u32 val = sysfs_gt_attribute_r_##_attr_type##_func(kobj, attr, \ + u32 val = sysfs_gt_attribute_r_func(kobj, attr, \ __##_name##_show); \ \ return sysfs_emit(buff, "%u\n", val); \ -- 2.38.1