From: Lucas De Marchi Date: Wed, 29 Oct 2025 23:45:05 +0000 (-0700) Subject: drm/xe/gt_throttle: Always read and mask X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=61e983e788bbe83f085890dd1bb4f2c9aed1e174;p=thirdparty%2Fkernel%2Flinux.git drm/xe/gt_throttle: Always read and mask Use a single function to read and mask the value the callers will be interested in. This reduces the risk of a caller using a plain call to xe_gt_throttle_get_limit_reasons() without applying any mask, which can return unexpected bits for future platforms. Select which reg and mask it's going to be used according to the platform and gt type and always use that one function. There was an odd xe_gt_dbg() when reading the status, which is not done for any other throttle/* sysfs file, so just make the status be as special as everybody else. Reviewed-by: Raag Jadav Link: https://patch.msgid.link/20251029-gt-throttle-cri-v3-3-d1f5abbb8114@intel.com Signed-off-by: Lucas De Marchi --- diff --git a/drivers/gpu/drm/xe/xe_gt_throttle.c b/drivers/gpu/drm/xe/xe_gt_throttle.c index c69710f2dbeb5..f743444f641a8 100644 --- a/drivers/gpu/drm/xe/xe_gt_throttle.c +++ b/drivers/gpu/drm/xe/xe_gt_throttle.c @@ -8,7 +8,6 @@ #include #include "xe_device.h" #include "xe_gt.h" -#include "xe_gt_printk.h" #include "xe_gt_sysfs.h" #include "xe_gt_throttle.h" #include "xe_mmio.h" @@ -57,32 +56,25 @@ dev_to_gt(struct device *dev) u32 xe_gt_throttle_get_limit_reasons(struct xe_gt *gt) { - u32 reg; + struct xe_device *xe = gt_to_xe(gt); + struct xe_reg reg; + u32 val, mask; - xe_pm_runtime_get(gt_to_xe(gt)); if (xe_gt_is_media_type(gt)) - reg = xe_mmio_read32(>->mmio, MTL_MEDIA_PERF_LIMIT_REASONS); + reg = MTL_MEDIA_PERF_LIMIT_REASONS; else - reg = xe_mmio_read32(>->mmio, GT0_PERF_LIMIT_REASONS); - xe_pm_runtime_put(gt_to_xe(gt)); - - return reg; -} - -static u32 read_status(struct xe_gt *gt) -{ - struct xe_device *xe = gt_to_xe(gt); - u32 status, mask; + reg = GT0_PERF_LIMIT_REASONS; if (xe->info.platform == XE_CRESCENTISLAND) mask = CRI_PERF_LIMIT_REASONS_MASK; else mask = GT0_PERF_LIMIT_REASONS_MASK; - status = xe_gt_throttle_get_limit_reasons(gt) & mask; - xe_gt_dbg(gt, "throttle reasons: 0x%08x\n", status); + xe_pm_runtime_get(xe); + val = xe_mmio_read32(>->mmio, reg) & mask; + xe_pm_runtime_put(xe); - return status; + return val; } static bool is_throttled_by(struct xe_gt *gt, u32 mask) @@ -96,7 +88,7 @@ static ssize_t status_show(struct kobject *kobj, struct device *dev = kobj_to_dev(kobj); struct xe_gt *gt = dev_to_gt(dev); - return sysfs_emit(buff, "%u\n", !!read_status(gt)); + return sysfs_emit(buff, "%u\n", is_throttled_by(gt, U32_MAX)); } static struct kobj_attribute attr_status = __ATTR_RO(status);