Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions arch/x86/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <linux/acpi.h>
#include <linux/console.h>
#include <linux/cpu.h>
#include <linux/percpu.h>
#include <linux/device.h>
#include <linux/crash_dump.h>
#include <linux/dma-map-ops.h>
#include <linux/efi.h>
Expand Down Expand Up @@ -1311,3 +1313,43 @@ bool arch_cpu_is_hotpluggable(int cpu)
return cpu > 0;
}
#endif /* CONFIG_HOTPLUG_CPU */

/* bodge: overwrite arch_register_cpu to add a tsc sysfs entry post-init of the cpu.
* i doubt this is the right spot for it to live, but it's at least justifiable as
* it's next to arch_cpu_is_hotpluggable.
*/
static ssize_t tsc_freq_khz_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
return sysfs_emit(buf, "%lu\n", tsc_khz);
}

static DEVICE_ATTR_RO(tsc_freq_khz);

int arch_register_cpu(int cpu)
{
struct cpu *c = &per_cpu(cpu_devices, cpu);
int register_result;

c->hotpluggable = arch_cpu_is_hotpluggable(cpu);

register_result = register_cpu(c, cpu);

if (!register_result) {
device_create_file(&c->dev, &dev_attr_tsc_freq_khz);
}

return register_result;
}

#ifdef CONFIG_HOTPLUG_CPU
void arch_unregister_cpu(int cpu)
{
struct cpu *c = &per_cpu(cpu_devices, cpu);

device_remove_file(&c->dev, &dev_attr_tsc_freq_khz);

unregister_cpu(c);
}
#endif /* CONFIG_HOTPLUG_CPU */