@@ -1031,6 +1031,88 @@ static void intel_pstate_update_limits(unsigned int cpu)
mutex_unlock(&intel_pstate_driver_lock);
}
+/************************** debugfs begin ************************/
+static void intel_pstate_reset_vlp(struct cpudata *cpu);
+
+static int vlp_param_set(void *data, u64 val)
+{
+ unsigned int cpu;
+
+ *(u32 *)data = val;
+ for_each_possible_cpu(cpu) {
+ if (all_cpu_data[cpu])
+ intel_pstate_reset_vlp(all_cpu_data[cpu]);
+ }
+
+ WARN_ONCE(1, "Unsupported P-state VLP parameter update via debugging interface");
+
+ return 0;
+}
+
+static int vlp_param_get(void *data, u64 *val)
+{
+ *val = *(u32 *)data;
+ return 0;
+}
+DEFINE_DEBUGFS_ATTRIBUTE(fops_vlp_param, vlp_param_get, vlp_param_set,
+ "%llu\n");
+
+static struct dentry *debugfs_parent;
+
+struct vlp_param {
+ char *name;
+ void *value;
+ struct dentry *dentry;
+};
+
+static struct vlp_param vlp_files[] = {
+ {"vlp_sample_interval_ms", &vlp_params.sample_interval_ms, },
+ {"vlp_setpoint_0_pml", &vlp_params.setpoint_0_pml, },
+ {"vlp_setpoint_aggr_pml", &vlp_params.setpoint_aggr_pml, },
+ {"vlp_avg_hz", &vlp_params.avg_hz, },
+ {"vlp_realtime_gain_pml", &vlp_params.realtime_gain_pml, },
+ {"vlp_debug", &vlp_params.debug, },
+ {NULL, NULL, }
+};
+
+static void intel_pstate_debug_expose_params(void)
+{
+ int i;
+
+ debugfs_parent = debugfs_create_dir("pstate_snb", NULL);
+ if (IS_ERR_OR_NULL(debugfs_parent))
+ return;
+
+ for (i = 0; vlp_files[i].name; i++) {
+ struct dentry *dentry;
+
+ dentry = debugfs_create_file_unsafe(vlp_files[i].name, 0660,
+ debugfs_parent,
+ vlp_files[i].value,
+ &fops_vlp_param);
+ if (!IS_ERR(dentry))
+ vlp_files[i].dentry = dentry;
+ }
+}
+
+static void intel_pstate_debug_hide_params(void)
+{
+ int i;
+
+ if (IS_ERR_OR_NULL(debugfs_parent))
+ return;
+
+ for (i = 0; vlp_files[i].name; i++) {
+ debugfs_remove(vlp_files[i].dentry);
+ vlp_files[i].dentry = NULL;
+ }
+
+ debugfs_remove(debugfs_parent);
+ debugfs_parent = NULL;
+}
+
+/************************** debugfs end ************************/
+
/************************** sysfs begin ************************/
#define show_one(file_name, object) \
static ssize_t show_##file_name \
@@ -2977,6 +3059,8 @@ static int intel_pstate_register_driver(struct cpufreq_driver *driver)
global.min_perf_pct = min_perf_pct_min();
+ intel_pstate_debug_expose_params();
+
return 0;
}
@@ -2985,6 +3069,8 @@ static int intel_pstate_unregister_driver(void)
if (hwp_active)
return -EBUSY;
+ intel_pstate_debug_hide_params();
+
cpufreq_unregister_driver(intel_pstate_driver);
intel_pstate_driver_cleanup();