Skip to content

Commit

Permalink
drm/i915/gt: Add sysfs RAPL PL1 interface
Browse files Browse the repository at this point in the history
Adding sysfs attribute rapl_pl1_freq_mhz. This shows the RAPL PL1
FREQUENCY LIMIT.

Signed-off-by: Sujaritha Sundaresan <sujaritha.sundaresan@intel.com>
  • Loading branch information
sujarith authored and intel-lab-lkp committed Jan 31, 2023
1 parent d98d1a1 commit 562c575
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/gpu/drm/i915/gt/intel_gt_regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1656,6 +1656,10 @@
#define GT0_PACKAGE_POWER_SKU_UNIT _MMIO(0x250068)
#define GT0_PLATFORM_ENERGY_STATUS _MMIO(0x25006c)

#define XEHPSDV_RAPL_PL1_FREQ_LIMIT _MMIO(0x250070)
#define MTL_RAPL_PL1_FREQ_LIMIT _MMIO(0x281070)
#define RAPL_PL1_FREQ_LIMIT_MASK REG_GENMASK(15, 0)

/*
* Standalone Media's non-engine GT registers are located at their regular GT
* offsets plus 0x380000. This extra offset is stored inside the intel_uncore
Expand Down
15 changes: 15 additions & 0 deletions drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,16 @@ static ssize_t punit_req_freq_mhz_show(struct kobject *kobj,
return sysfs_emit(buff, "%u\n", preq);
}

static ssize_t rapl_pl1_freq_mhz_show(struct kobject *kobj,
struct kobj_attribute *attr,
char *buff)
{
struct intel_gt *gt = intel_gt_sysfs_get_drvdata(kobj, attr->attr.name);
u32 rapl_pl1 = intel_rps_read_rapl_pl1(&gt->rps);

return sysfs_emit(buff, "%u\n", rapl_pl1);
}

struct intel_gt_bool_throttle_attr {
struct attribute attr;
ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,
Expand Down Expand Up @@ -480,6 +490,7 @@ struct intel_gt_bool_throttle_attr attr_##sysfs_func__ = { \
}

INTEL_GT_ATTR_RO(punit_req_freq_mhz);
INTEL_GT_ATTR_RO(rapl_pl1_freq_mhz);
static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_status, GT0_PERF_LIMIT_REASONS_MASK);
static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_pl1, POWER_LIMIT_1_MASK);
static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_pl2, POWER_LIMIT_2_MASK);
Expand Down Expand Up @@ -744,6 +755,10 @@ void intel_gt_sysfs_pm_init(struct intel_gt *gt, struct kobject *kobj)
if (ret)
gt_warn(gt, "failed to create punit_req_freq_mhz sysfs (%pe)", ERR_PTR(ret));

ret = sysfs_create_file(kobj, &attr_rapl_pl1_freq_mhz.attr);
if (ret)
gt_warn(gt, "failed to create rapl_pl1_freq_mhz sysfs (%pe)", ERR_PTR(ret));

if (i915_mmio_reg_valid(intel_gt_perf_limit_reasons_reg(gt))) {
ret = sysfs_create_files(kobj, throttle_reason_attrs);
if (ret)
Expand Down
18 changes: 18 additions & 0 deletions drivers/gpu/drm/i915/gt/intel_rps.c
Original file line number Diff line number Diff line change
Expand Up @@ -2202,6 +2202,24 @@ u32 intel_rps_get_max_frequency(struct intel_rps *rps)
return intel_gpu_freq(rps, rps->max_freq_softlimit);
}

u32 intel_rps_read_rapl_pl1(struct intel_rps *rps)
{
struct drm_i915_private *i915 = rps_to_i915(rps);
u32 rapl_pl1;
u32 rapl;

if (IS_METEORLAKE(i915))
rapl_pl1 = intel_uncore_read(rps_to_gt(rps)->uncore, MTL_RAPL_PL1_FREQ_LIMIT);
else if (IS_XEHPSDV(i915))
rapl_pl1 = intel_uncore_read(rps_to_gt(rps)->uncore, XEHPSDV_RAPL_PL1_FREQ_LIMIT);


if (IS_METEORLAKE(i915) || IS_XEHPSDV(i915))
rapl = REG_FIELD_GET(RAPL_PL1_FREQ_LIMIT_MASK, rapl_pl1);

return rapl;
}

/**
* intel_rps_get_max_raw_freq - returns the max frequency in some raw format.
* @rps: the intel_rps structure
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/i915/gt/intel_rps.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ u32 intel_rps_get_rp1_frequency(struct intel_rps *rps);
u32 intel_rps_get_rpn_frequency(struct intel_rps *rps);
u32 intel_rps_read_punit_req(struct intel_rps *rps);
u32 intel_rps_read_punit_req_frequency(struct intel_rps *rps);
u32 intel_rps_read_rapl_pl1(struct intel_rps *rps);
u32 intel_rps_read_rpstat(struct intel_rps *rps);
u32 intel_rps_read_rpstat_fw(struct intel_rps *rps);
void gen6_rps_get_freq_caps(struct intel_rps *rps, struct intel_rps_freq_caps *caps);
Expand Down

0 comments on commit 562c575

Please sign in to comment.