mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
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 <raag.jadav@intel.com> Link: https://patch.msgid.link/20251029-gt-throttle-cri-v3-3-d1f5abbb8114@intel.com Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
#include <regs/xe_gt_regs.h>
|
||||
#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"
|
||||
@@ -56,33 +55,26 @@ dev_to_gt(struct device *dev)
|
||||
}
|
||||
|
||||
u32 xe_gt_throttle_get_limit_reasons(struct xe_gt *gt)
|
||||
{
|
||||
u32 reg;
|
||||
|
||||
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);
|
||||
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;
|
||||
struct xe_reg reg;
|
||||
u32 val, mask;
|
||||
|
||||
if (xe_gt_is_media_type(gt))
|
||||
reg = MTL_MEDIA_PERF_LIMIT_REASONS;
|
||||
else
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user