mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-03 20:34:23 -04:00
platform/x86/intel-uncore-freq: Get rid of uncore_read_freq driver API
Get rid of uncore_read_freq driver API. Instead, add a new entry to the enumerated read interface and use this. No functional change intended. Signed-off-by: Tero Kristo <tero.kristo@linux.intel.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Link: https://lore.kernel.org/r/20240617060708.892981-6-tero.kristo@linux.intel.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
This commit is contained in:
committed by
Ilpo Järvinen
parent
69207a0f17
commit
d766abfbea
@@ -21,7 +21,6 @@ static DEFINE_IDA(intel_uncore_ida);
|
||||
/* callbacks for actual HW read/write */
|
||||
static int (*uncore_read)(struct uncore_data *data, unsigned int *value, enum uncore_index index);
|
||||
static int (*uncore_write)(struct uncore_data *data, unsigned int input, enum uncore_index index);
|
||||
static int (*uncore_read_freq)(struct uncore_data *data, unsigned int *freq);
|
||||
|
||||
static ssize_t show_domain_id(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
|
||||
{
|
||||
@@ -85,7 +84,7 @@ static ssize_t show_perf_status_freq_khz(struct uncore_data *data, char *buf)
|
||||
int ret;
|
||||
|
||||
mutex_lock(&uncore_lock);
|
||||
ret = uncore_read_freq(data, &freq);
|
||||
ret = uncore_read(data, &freq, UNCORE_INDEX_CURRENT_FREQ);
|
||||
mutex_unlock(&uncore_lock);
|
||||
if (ret)
|
||||
return ret;
|
||||
@@ -195,7 +194,7 @@ static int create_attr_group(struct uncore_data *data, char *name)
|
||||
data->uncore_attrs[index++] = &data->initial_min_freq_khz_kobj_attr.attr;
|
||||
data->uncore_attrs[index++] = &data->initial_max_freq_khz_kobj_attr.attr;
|
||||
|
||||
ret = uncore_read_freq(data, &freq);
|
||||
ret = uncore_read(data, &freq, UNCORE_INDEX_CURRENT_FREQ);
|
||||
if (!ret)
|
||||
data->uncore_attrs[index++] = &data->current_freq_khz_kobj_attr.attr;
|
||||
|
||||
@@ -267,17 +266,15 @@ void uncore_freq_remove_die_entry(struct uncore_data *data)
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(uncore_freq_remove_die_entry, INTEL_UNCORE_FREQUENCY);
|
||||
|
||||
int uncore_freq_common_init(int (*read_control_freq)(struct uncore_data *data, unsigned int *value,
|
||||
enum uncore_index index),
|
||||
int (*write_control_freq)(struct uncore_data *data, unsigned int input,
|
||||
enum uncore_index index),
|
||||
int (*read_freq)(struct uncore_data *data, unsigned int *freq))
|
||||
int uncore_freq_common_init(int (*read)(struct uncore_data *data, unsigned int *value,
|
||||
enum uncore_index index),
|
||||
int (*write)(struct uncore_data *data, unsigned int input,
|
||||
enum uncore_index index))
|
||||
{
|
||||
mutex_lock(&uncore_lock);
|
||||
|
||||
uncore_read = read_control_freq;
|
||||
uncore_write = write_control_freq;
|
||||
uncore_read_freq = read_freq;
|
||||
uncore_read = read;
|
||||
uncore_write = write;
|
||||
|
||||
if (!uncore_root_kobj) {
|
||||
struct device *dev_root = bus_get_dev_root(&cpu_subsys);
|
||||
|
||||
@@ -69,13 +69,13 @@ struct uncore_data {
|
||||
enum uncore_index {
|
||||
UNCORE_INDEX_MIN_FREQ,
|
||||
UNCORE_INDEX_MAX_FREQ,
|
||||
UNCORE_INDEX_CURRENT_FREQ,
|
||||
};
|
||||
|
||||
int uncore_freq_common_init(int (*read_control_freq)(struct uncore_data *data, unsigned int *value,
|
||||
enum uncore_index index),
|
||||
int (*write_control_freq)(struct uncore_data *data, unsigned int input,
|
||||
enum uncore_index index),
|
||||
int (*uncore_read_freq)(struct uncore_data *data, unsigned int *freq));
|
||||
int uncore_freq_common_init(int (*read)(struct uncore_data *data, unsigned int *value,
|
||||
enum uncore_index index),
|
||||
int (*write)(struct uncore_data *data, unsigned int input,
|
||||
enum uncore_index index));
|
||||
void uncore_freq_common_exit(void);
|
||||
int uncore_freq_add_entry(struct uncore_data *data, int cpu);
|
||||
void uncore_freq_remove_die_entry(struct uncore_data *data);
|
||||
|
||||
@@ -91,7 +91,7 @@ static void read_control_freq(struct tpmi_uncore_cluster_info *cluster_info,
|
||||
|
||||
#define UNCORE_MAX_RATIO FIELD_MAX(UNCORE_MAX_RATIO_MASK)
|
||||
|
||||
/* Callback for sysfs read for max/min frequencies. Called under mutex locks */
|
||||
/* Helper for sysfs read for max/min frequencies. Called under mutex locks */
|
||||
static int uncore_read_control_freq(struct uncore_data *data, unsigned int *value,
|
||||
enum uncore_index index)
|
||||
{
|
||||
@@ -207,7 +207,7 @@ static int uncore_write_control_freq(struct uncore_data *data, unsigned int inpu
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Callback for sysfs read for the current uncore frequency. Called under mutex locks */
|
||||
/* Helper for sysfs read for the current uncore frequency. Called under mutex locks */
|
||||
static int uncore_read_freq(struct uncore_data *data, unsigned int *freq)
|
||||
{
|
||||
struct tpmi_uncore_cluster_info *cluster_info;
|
||||
@@ -223,6 +223,24 @@ static int uncore_read_freq(struct uncore_data *data, unsigned int *freq)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Callback for sysfs read for TPMI uncore values. Called under mutex locks. */
|
||||
static int uncore_read(struct uncore_data *data, unsigned int *value, enum uncore_index index)
|
||||
{
|
||||
switch (index) {
|
||||
case UNCORE_INDEX_MIN_FREQ:
|
||||
case UNCORE_INDEX_MAX_FREQ:
|
||||
return uncore_read_control_freq(data, value, index);
|
||||
|
||||
case UNCORE_INDEX_CURRENT_FREQ:
|
||||
return uncore_read_freq(data, value);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
static void remove_cluster_entries(struct tpmi_uncore_struct *tpmi_uncore)
|
||||
{
|
||||
int i;
|
||||
@@ -273,8 +291,7 @@ static int uncore_probe(struct auxiliary_device *auxdev, const struct auxiliary_
|
||||
return -EINVAL;
|
||||
|
||||
/* Register callbacks to uncore core */
|
||||
ret = uncore_freq_common_init(uncore_read_control_freq, uncore_write_control_freq,
|
||||
uncore_read_freq);
|
||||
ret = uncore_freq_common_init(uncore_read, uncore_write_control_freq);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
||||
@@ -114,6 +114,23 @@ static int uncore_read_freq(struct uncore_data *data, unsigned int *freq)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uncore_read(struct uncore_data *data, unsigned int *value, enum uncore_index index)
|
||||
{
|
||||
switch (index) {
|
||||
case UNCORE_INDEX_MIN_FREQ:
|
||||
case UNCORE_INDEX_MAX_FREQ:
|
||||
return uncore_read_control_freq(data, value, index);
|
||||
|
||||
case UNCORE_INDEX_CURRENT_FREQ:
|
||||
return uncore_read_freq(data, value);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
/* Caller provides protection */
|
||||
static struct uncore_data *uncore_get_instance(unsigned int cpu)
|
||||
{
|
||||
@@ -256,8 +273,7 @@ static int __init intel_uncore_init(void)
|
||||
if (!uncore_instances)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = uncore_freq_common_init(uncore_read_control_freq, uncore_write_control_freq,
|
||||
uncore_read_freq);
|
||||
ret = uncore_freq_common_init(uncore_read, uncore_write_control_freq);
|
||||
if (ret)
|
||||
goto err_free;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user