diff options
author | David S. Miller <davem@hutch.davemloft.net> | 2007-06-02 23:46:36 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-06-05 00:49:51 -0400 |
commit | d1f253e60aefe4d3a3e708b3c2a082f3ec1be6f4 (patch) | |
tree | 7a56cb74de76203790bab5151e1f7488ca32230e | |
parent | eff3414b7277c4792debfa227f5408238d925f16 (diff) |
[SPARC64]: Export basic cpu properties via sysfs.
Cache sizes, udelay_val, and clock_tick.
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | arch/sparc64/kernel/sysfs.c | 86 |
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 | ||
11 | static DEFINE_PER_CPU(struct cpu, cpu_devices); | 11 | static DEFINE_PER_CPU(struct cpu, cpu_devices); |
12 | 12 | ||
13 | #define SHOW_ULONG_NAME(NAME, MEMBER) \ | ||
14 | static 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) \ | ||
22 | static 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 | |||
29 | SHOW_ULONG_NAME(clock_tick, clock_tick); | ||
30 | SHOW_ULONG_NAME(udelay_val, udelay_val); | ||
31 | SHOW_UINT_NAME(l1_dcache_size, dcache_size); | ||
32 | SHOW_UINT_NAME(l1_dcache_line_size, dcache_line_size); | ||
33 | SHOW_UINT_NAME(l1_icache_size, icache_size); | ||
34 | SHOW_UINT_NAME(l1_icache_line_size, icache_line_size); | ||
35 | SHOW_UINT_NAME(l2_cache_size, ecache_size); | ||
36 | SHOW_UINT_NAME(l2_cache_line_size, ecache_line_size); | ||
37 | |||
38 | static 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 | |||
49 | static 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 | ||
60 | static 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 | |||
71 | static 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 | |||
91 | static struct notifier_block __cpuinitdata sysfs_cpu_nb = { | ||
92 | .notifier_call = sysfs_cpu_notify, | ||
93 | }; | ||
94 | |||
13 | static int __init topology_init(void) | 95 | static 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; |