Skip to content

Commit

Permalink
platform/x86: intel-uncore-freq: Conditionally create attribute for r…
Browse files Browse the repository at this point in the history
…ead frequency

When the current uncore frequency can't be read, don't create attribute
"current_freq_khz" as any read will fail later. Some user space
applications like turbostat fail to continue with the failure. So, check
error during attribute creation.

Fixes: 414eef2 ("platform/x86/intel/uncore-freq: Display uncore current frequency")
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20231004181915.1887913-1-srinivas.pandruvada@linux.intel.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  • Loading branch information
Srinivas Pandruvada authored and Hans de Goede committed Oct 11, 2023
1 parent a4fdebb commit 4d73c67
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ show_uncore_data(initial_max_freq_khz);

static int create_attr_group(struct uncore_data *data, char *name)
{
int ret, index = 0;
int ret, freq, index = 0;

init_attribute_rw(max_freq_khz);
init_attribute_rw(min_freq_khz);
Expand All @@ -197,7 +197,11 @@ static int create_attr_group(struct uncore_data *data, char *name)
data->uncore_attrs[index++] = &data->min_freq_khz_dev_attr.attr;
data->uncore_attrs[index++] = &data->initial_min_freq_khz_dev_attr.attr;
data->uncore_attrs[index++] = &data->initial_max_freq_khz_dev_attr.attr;
data->uncore_attrs[index++] = &data->current_freq_khz_dev_attr.attr;

ret = uncore_read_freq(data, &freq);
if (!ret)
data->uncore_attrs[index++] = &data->current_freq_khz_dev_attr.attr;

data->uncore_attrs[index] = NULL;

data->uncore_attr_group.name = name;
Expand Down

0 comments on commit 4d73c67

Please sign in to comment.