aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc64/kernel/sysfs.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@hutch.davemloft.net>2007-06-02 23:46:36 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-06-05 00:49:51 -0400
commitd1f253e60aefe4d3a3e708b3c2a082f3ec1be6f4 (patch)
tree7a56cb74de76203790bab5151e1f7488ca32230e /arch/sparc64/kernel/sysfs.c
parenteff3414b7277c4792debfa227f5408238d925f16 (diff)
[SPARC64]: Export basic cpu properties via sysfs.
Cache sizes, udelay_val, and clock_tick. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc64/kernel/sysfs.c')
-rw-r--r--arch/sparc64/kernel/sysfs.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/arch/sparc64/kernel/sysfs.c b/arch/sparc64/kernel/sysfs.c
index 0808c214dc73..a684a79ece44 100644
--- a/arch/sparc64/kernel/sysfs.c
+++ b/arch/sparc64/kernel/sysfs.c
@@ -10,14 +10,100 @@
10 10
11static DEFINE_PER_CPU(struct cpu, cpu_devices); 11static DEFINE_PER_CPU(struct cpu, cpu_devices);
12 12
13#define SHOW_ULONG_NAME(NAME, MEMBER) \
14static ssize_t show_##NAME(struct sys_device *dev, char *buf) \
15{ \
16 struct cpu *cpu = container_of(dev, struct cpu, sysdev); \
17 cpuinfo_sparc *c = &cpu_data(cpu->sysdev.id); \
18 return sprintf(buf, "%lu\n", c->MEMBER); \
19}
20
21#define SHOW_UINT_NAME(NAME, MEMBER) \
22static ssize_t show_##NAME(struct sys_device *dev, char *buf) \
23{ \
24 struct cpu *cpu = container_of(dev, struct cpu, sysdev); \
25 cpuinfo_sparc *c = &cpu_data(cpu->sysdev.id); \
26 return sprintf(buf, "%u\n", c->MEMBER); \
27}
28
29SHOW_ULONG_NAME(clock_tick, clock_tick);
30SHOW_ULONG_NAME(udelay_val, udelay_val);
31SHOW_UINT_NAME(l1_dcache_size, dcache_size);
32SHOW_UINT_NAME(l1_dcache_line_size, dcache_line_size);
33SHOW_UINT_NAME(l1_icache_size, icache_size);
34SHOW_UINT_NAME(l1_icache_line_size, icache_line_size);
35SHOW_UINT_NAME(l2_cache_size, ecache_size);
36SHOW_UINT_NAME(l2_cache_line_size, ecache_line_size);
37
38static struct sysdev_attribute cpu_core_attrs[] = {
39 _SYSDEV_ATTR(clock_tick, 0444, show_clock_tick, NULL),
40 _SYSDEV_ATTR(udelay_val, 0444, show_udelay_val, NULL),
41 _SYSDEV_ATTR(l1_dcache_size, 0444, show_l1_dcache_size, NULL),
42 _SYSDEV_ATTR(l1_dcache_line_size, 0444, show_l1_dcache_line_size, NULL),
43 _SYSDEV_ATTR(l1_icache_size, 0444, show_l1_icache_size, NULL),
44 _SYSDEV_ATTR(l1_icache_line_size, 0444, show_l1_icache_line_size, NULL),
45 _SYSDEV_ATTR(l2_cache_size, 0444, show_l2_cache_size, NULL),
46 _SYSDEV_ATTR(l2_cache_line_size, 0444, show_l2_cache_line_size, NULL),
47};
48
49static void register_cpu_online(unsigned int cpu)
50{
51 struct cpu *c = &per_cpu(cpu_devices, cpu);
52 struct sys_device *s = &c->sysdev;
53 int i;
54
55 for (i = 0; i < ARRAY_SIZE(cpu_core_attrs); i++)
56 sysdev_create_file(s, &cpu_core_attrs[i]);
57}
58
59#ifdef CONFIG_HOTPLUG_CPU
60static void unregister_cpu_online(unsigned int cpu)
61{
62 struct cpu *c = &per_cpu(cpu_devices, cpu);
63 struct sys_device *s = &c->sysdev;
64 int i;
65
66 for (i = 0; i < ARRAY_SIZE(cpu_core_attrs); i++)
67 sysdev_remove_file(s, &cpu_core_attrs[i]);
68}
69#endif
70
71static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
72 unsigned long action, void *hcpu)
73{
74 unsigned int cpu = (unsigned int)(long)hcpu;
75
76 switch (action) {
77 case CPU_ONLINE:
78 case CPU_ONLINE_FROZEN:
79 register_cpu_online(cpu);
80 break;
81#ifdef CONFIG_HOTPLUG_CPU
82 case CPU_DEAD:
83 case CPU_DEAD_FROZEN:
84 unregister_cpu_online(cpu);
85 break;
86#endif
87 }
88 return NOTIFY_OK;
89}
90
91static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
92 .notifier_call = sysfs_cpu_notify,
93};
94
13static int __init topology_init(void) 95static int __init topology_init(void)
14{ 96{
15 int cpu; 97 int cpu;
16 98
99 register_cpu_notifier(&sysfs_cpu_nb);
100
17 for_each_possible_cpu(cpu) { 101 for_each_possible_cpu(cpu) {
18 struct cpu *c = &per_cpu(cpu_devices, cpu); 102 struct cpu *c = &per_cpu(cpu_devices, cpu);
19 103
20 register_cpu(c, cpu); 104 register_cpu(c, cpu);
105 if (cpu_online(cpu))
106 register_cpu_online(cpu);
21 } 107 }
22 108
23 return 0; 109 return 0;