aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/cpu.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base/cpu.c')
-rw-r--r--drivers/base/cpu.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 281d26784d25..982e6583cd63 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -83,6 +83,33 @@ static inline void register_cpu_control(struct cpu *cpu)
83} 83}
84#endif /* CONFIG_HOTPLUG_CPU */ 84#endif /* CONFIG_HOTPLUG_CPU */
85 85
86#ifdef CONFIG_KEXEC
87#include <linux/kexec.h>
88
89static ssize_t show_crash_notes(struct sys_device *dev, char *buf)
90{
91 struct cpu *cpu = container_of(dev, struct cpu, sysdev);
92 ssize_t rc;
93 unsigned long long addr;
94 int cpunum;
95
96 cpunum = cpu->sysdev.id;
97
98 /*
99 * Might be reading other cpu's data based on which cpu read thread
100 * has been scheduled. But cpu data (memory) is allocated once during
101 * boot up and this data does not change there after. Hence this
102 * operation should be safe. No locking required.
103 */
104 get_cpu();
105 addr = __pa(per_cpu_ptr(crash_notes, cpunum));
106 rc = sprintf(buf, "%Lx\n", addr);
107 put_cpu();
108 return rc;
109}
110static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL);
111#endif
112
86/* 113/*
87 * register_cpu - Setup a driverfs device for a CPU. 114 * register_cpu - Setup a driverfs device for a CPU.
88 * @cpu - Callers can set the cpu->no_control field to 1, to indicate not to 115 * @cpu - Callers can set the cpu->no_control field to 1, to indicate not to
@@ -108,6 +135,11 @@ int __devinit register_cpu(struct cpu *cpu, int num, struct node *root)
108 register_cpu_control(cpu); 135 register_cpu_control(cpu);
109 if (!error) 136 if (!error)
110 cpu_sys_devices[num] = &cpu->sysdev; 137 cpu_sys_devices[num] = &cpu->sysdev;
138
139#ifdef CONFIG_KEXEC
140 if (!error)
141 error = sysdev_create_file(&cpu->sysdev, &attr_crash_notes);
142#endif
111 return error; 143 return error;
112} 144}
113 145