Commit fdff0a85 authored by Ashutosh Dixit's avatar Ashutosh Dixit Committed by Rodrigo Vivi

drm/i915/gt: Expose per-gt RPS defaults in sysfs

Add the following sysfs files to gt/gtN/.defaults/:
* rps_min_freq_mhz
* rps_max_freq_mhz

v2: Correct gt/gtN/.defaults/* file names in commit message
v3: Remove rps_boost_freq_mhz since it is not consumed by userspace

Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Cc: Andi Shyti <andi.shyti@linux.intel.com>
Signed-off-by: default avatarAshutosh Dixit <ashutosh.dixit@intel.com>
Reviewed-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/cf6e483bf79f871c2c8c74af6005bf6a83a3a1ce.1658192398.git.ashutosh.dixit@intel.com
parent 5dca122f
...@@ -22,11 +22,6 @@ bool is_object_gt(struct kobject *kobj) ...@@ -22,11 +22,6 @@ bool is_object_gt(struct kobject *kobj)
return !strncmp(kobj->name, "gt", 2); return !strncmp(kobj->name, "gt", 2);
} }
static struct intel_gt *kobj_to_gt(struct kobject *kobj)
{
return container_of(kobj, struct intel_gt, sysfs_gt);
}
struct intel_gt *intel_gt_sysfs_get_drvdata(struct device *dev, struct intel_gt *intel_gt_sysfs_get_drvdata(struct device *dev,
const char *name) const char *name)
{ {
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <linux/kobject.h> #include <linux/kobject.h>
#include "i915_gem.h" /* GEM_BUG_ON() */ #include "i915_gem.h" /* GEM_BUG_ON() */
#include "intel_gt_types.h"
struct intel_gt; struct intel_gt;
...@@ -22,6 +23,11 @@ intel_gt_create_kobj(struct intel_gt *gt, ...@@ -22,6 +23,11 @@ intel_gt_create_kobj(struct intel_gt *gt,
struct kobject *dir, struct kobject *dir,
const char *name); const char *name);
static inline struct intel_gt *kobj_to_gt(struct kobject *kobj)
{
return container_of(kobj, struct intel_gt, sysfs_gt);
}
void intel_gt_sysfs_register(struct intel_gt *gt); void intel_gt_sysfs_register(struct intel_gt *gt);
void intel_gt_sysfs_unregister(struct intel_gt *gt); void intel_gt_sysfs_unregister(struct intel_gt *gt);
struct intel_gt *intel_gt_sysfs_get_drvdata(struct device *dev, struct intel_gt *intel_gt_sysfs_get_drvdata(struct device *dev,
......
...@@ -727,6 +727,34 @@ static const struct attribute *media_perf_power_attrs[] = { ...@@ -727,6 +727,34 @@ static const struct attribute *media_perf_power_attrs[] = {
NULL NULL
}; };
static ssize_t
default_min_freq_mhz_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
{
struct intel_gt *gt = kobj_to_gt(kobj->parent);
return sysfs_emit(buf, "%u\n", gt->defaults.min_freq);
}
static struct kobj_attribute default_min_freq_mhz =
__ATTR(rps_min_freq_mhz, 0444, default_min_freq_mhz_show, NULL);
static ssize_t
default_max_freq_mhz_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
{
struct intel_gt *gt = kobj_to_gt(kobj->parent);
return sysfs_emit(buf, "%u\n", gt->defaults.max_freq);
}
static struct kobj_attribute default_max_freq_mhz =
__ATTR(rps_max_freq_mhz, 0444, default_max_freq_mhz_show, NULL);
static const struct attribute * const rps_defaults_attrs[] = {
&default_min_freq_mhz.attr,
&default_max_freq_mhz.attr,
NULL
};
static int intel_sysfs_rps_init(struct intel_gt *gt, struct kobject *kobj, static int intel_sysfs_rps_init(struct intel_gt *gt, struct kobject *kobj,
const struct attribute * const *attrs) const struct attribute * const *attrs)
{ {
...@@ -776,4 +804,10 @@ void intel_gt_sysfs_pm_init(struct intel_gt *gt, struct kobject *kobj) ...@@ -776,4 +804,10 @@ void intel_gt_sysfs_pm_init(struct intel_gt *gt, struct kobject *kobj)
"failed to create gt%u media_perf_power_attrs sysfs (%pe)\n", "failed to create gt%u media_perf_power_attrs sysfs (%pe)\n",
gt->info.id, ERR_PTR(ret)); gt->info.id, ERR_PTR(ret));
} }
ret = sysfs_create_files(gt->sysfs_defaults, rps_defaults_attrs);
if (ret)
drm_warn(&gt->i915->drm,
"failed to add gt%u rps defaults (%pe)\n",
gt->info.id, ERR_PTR(ret));
} }
...@@ -76,6 +76,8 @@ enum intel_submission_method { ...@@ -76,6 +76,8 @@ enum intel_submission_method {
}; };
struct gt_defaults { struct gt_defaults {
u32 min_freq;
u32 max_freq;
}; };
struct intel_gt { struct intel_gt {
......
...@@ -1979,7 +1979,9 @@ void intel_rps_init(struct intel_rps *rps) ...@@ -1979,7 +1979,9 @@ void intel_rps_init(struct intel_rps *rps)
/* Derive initial user preferences/limits from the hardware limits */ /* Derive initial user preferences/limits from the hardware limits */
rps->max_freq_softlimit = rps->max_freq; rps->max_freq_softlimit = rps->max_freq;
rps_to_gt(rps)->defaults.max_freq = rps->max_freq_softlimit;
rps->min_freq_softlimit = rps->min_freq; rps->min_freq_softlimit = rps->min_freq;
rps_to_gt(rps)->defaults.min_freq = rps->min_freq_softlimit;
/* After setting max-softlimit, find the overclock max freq */ /* After setting max-softlimit, find the overclock max freq */
if (GRAPHICS_VER(i915) == 6 || IS_IVYBRIDGE(i915) || IS_HASWELL(i915)) { if (GRAPHICS_VER(i915) == 6 || IS_IVYBRIDGE(i915) || IS_HASWELL(i915)) {
......
...@@ -575,20 +575,24 @@ static int slpc_set_softlimits(struct intel_guc_slpc *slpc) ...@@ -575,20 +575,24 @@ static int slpc_set_softlimits(struct intel_guc_slpc *slpc)
* unless they have deviated from defaults, in which case, * unless they have deviated from defaults, in which case,
* we retain the values and set min/max accordingly. * we retain the values and set min/max accordingly.
*/ */
if (!slpc->max_freq_softlimit) if (!slpc->max_freq_softlimit) {
slpc->max_freq_softlimit = slpc->rp0_freq; slpc->max_freq_softlimit = slpc->rp0_freq;
else if (slpc->max_freq_softlimit != slpc->rp0_freq) slpc_to_gt(slpc)->defaults.max_freq = slpc->max_freq_softlimit;
} else if (slpc->max_freq_softlimit != slpc->rp0_freq) {
ret = intel_guc_slpc_set_max_freq(slpc, ret = intel_guc_slpc_set_max_freq(slpc,
slpc->max_freq_softlimit); slpc->max_freq_softlimit);
}
if (unlikely(ret)) if (unlikely(ret))
return ret; return ret;
if (!slpc->min_freq_softlimit) if (!slpc->min_freq_softlimit) {
slpc->min_freq_softlimit = slpc->min_freq; slpc->min_freq_softlimit = slpc->min_freq;
else if (slpc->min_freq_softlimit != slpc->min_freq) slpc_to_gt(slpc)->defaults.min_freq = slpc->min_freq_softlimit;
} else if (slpc->min_freq_softlimit != slpc->min_freq) {
return intel_guc_slpc_set_min_freq(slpc, return intel_guc_slpc_set_min_freq(slpc,
slpc->min_freq_softlimit); slpc->min_freq_softlimit);
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment