diff options
Diffstat (limited to 'arch/ia64/kernel/salinfo.c')
-rw-r--r-- | arch/ia64/kernel/salinfo.c | 65 |
1 files changed, 36 insertions, 29 deletions
diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c index d227fabecd02..ca68e6e44a72 100644 --- a/arch/ia64/kernel/salinfo.c +++ b/arch/ia64/kernel/salinfo.c | |||
@@ -22,6 +22,11 @@ | |||
22 | * | 22 | * |
23 | * Dec 5 2004 kaos@sgi.com | 23 | * Dec 5 2004 kaos@sgi.com |
24 | * Standardize which records are cleared automatically. | 24 | * Standardize which records are cleared automatically. |
25 | * | ||
26 | * Aug 18 2005 kaos@sgi.com | ||
27 | * mca.c may not pass a buffer, a NULL buffer just indicates that a new | ||
28 | * record is available in SAL. | ||
29 | * Replace some NR_CPUS by cpus_online, for hotplug cpu. | ||
25 | */ | 30 | */ |
26 | 31 | ||
27 | #include <linux/types.h> | 32 | #include <linux/types.h> |
@@ -143,7 +148,8 @@ struct salinfo_data { | |||
143 | 148 | ||
144 | static struct salinfo_data salinfo_data[ARRAY_SIZE(salinfo_log_name)]; | 149 | static struct salinfo_data salinfo_data[ARRAY_SIZE(salinfo_log_name)]; |
145 | 150 | ||
146 | static spinlock_t data_lock, data_saved_lock; | 151 | static DEFINE_SPINLOCK(data_lock); |
152 | static DEFINE_SPINLOCK(data_saved_lock); | ||
147 | 153 | ||
148 | /** salinfo_platform_oemdata - optional callback to decode oemdata from an error | 154 | /** salinfo_platform_oemdata - optional callback to decode oemdata from an error |
149 | * record. | 155 | * record. |
@@ -192,7 +198,7 @@ shift1_data_saved (struct salinfo_data *data, int shift) | |||
192 | * The buffer passed from mca.c points to the output from ia64_log_get. This is | 198 | * The buffer passed from mca.c points to the output from ia64_log_get. This is |
193 | * a persistent buffer but its contents can change between the interrupt and | 199 | * a persistent buffer but its contents can change between the interrupt and |
194 | * when user space processes the record. Save the record id to identify | 200 | * when user space processes the record. Save the record id to identify |
195 | * changes. | 201 | * changes. If the buffer is NULL then just update the bitmap. |
196 | */ | 202 | */ |
197 | void | 203 | void |
198 | salinfo_log_wakeup(int type, u8 *buffer, u64 size, int irqsafe) | 204 | salinfo_log_wakeup(int type, u8 *buffer, u64 size, int irqsafe) |
@@ -205,27 +211,29 @@ salinfo_log_wakeup(int type, u8 *buffer, u64 size, int irqsafe) | |||
205 | 211 | ||
206 | BUG_ON(type >= ARRAY_SIZE(salinfo_log_name)); | 212 | BUG_ON(type >= ARRAY_SIZE(salinfo_log_name)); |
207 | 213 | ||
208 | if (irqsafe) | 214 | if (buffer) { |
209 | spin_lock_irqsave(&data_saved_lock, flags); | 215 | if (irqsafe) |
210 | for (i = 0, data_saved = data->data_saved; i < saved_size; ++i, ++data_saved) { | 216 | spin_lock_irqsave(&data_saved_lock, flags); |
211 | if (!data_saved->buffer) | 217 | for (i = 0, data_saved = data->data_saved; i < saved_size; ++i, ++data_saved) { |
212 | break; | 218 | if (!data_saved->buffer) |
213 | } | 219 | break; |
214 | if (i == saved_size) { | 220 | } |
215 | if (!data->saved_num) { | 221 | if (i == saved_size) { |
216 | shift1_data_saved(data, 0); | 222 | if (!data->saved_num) { |
217 | data_saved = data->data_saved + saved_size - 1; | 223 | shift1_data_saved(data, 0); |
218 | } else | 224 | data_saved = data->data_saved + saved_size - 1; |
219 | data_saved = NULL; | 225 | } else |
220 | } | 226 | data_saved = NULL; |
221 | if (data_saved) { | 227 | } |
222 | data_saved->cpu = smp_processor_id(); | 228 | if (data_saved) { |
223 | data_saved->id = ((sal_log_record_header_t *)buffer)->id; | 229 | data_saved->cpu = smp_processor_id(); |
224 | data_saved->size = size; | 230 | data_saved->id = ((sal_log_record_header_t *)buffer)->id; |
225 | data_saved->buffer = buffer; | 231 | data_saved->size = size; |
232 | data_saved->buffer = buffer; | ||
233 | } | ||
234 | if (irqsafe) | ||
235 | spin_unlock_irqrestore(&data_saved_lock, flags); | ||
226 | } | 236 | } |
227 | if (irqsafe) | ||
228 | spin_unlock_irqrestore(&data_saved_lock, flags); | ||
229 | 237 | ||
230 | if (!test_and_set_bit(smp_processor_id(), &data->cpu_event)) { | 238 | if (!test_and_set_bit(smp_processor_id(), &data->cpu_event)) { |
231 | if (irqsafe) | 239 | if (irqsafe) |
@@ -243,7 +251,7 @@ salinfo_timeout_check(struct salinfo_data *data) | |||
243 | int i; | 251 | int i; |
244 | if (!data->open) | 252 | if (!data->open) |
245 | return; | 253 | return; |
246 | for (i = 0; i < NR_CPUS; ++i) { | 254 | for_each_online_cpu(i) { |
247 | if (test_bit(i, &data->cpu_event)) { | 255 | if (test_bit(i, &data->cpu_event)) { |
248 | /* double up() is not a problem, user space will see no | 256 | /* double up() is not a problem, user space will see no |
249 | * records for the additional "events". | 257 | * records for the additional "events". |
@@ -290,7 +298,7 @@ retry: | |||
290 | 298 | ||
291 | n = data->cpu_check; | 299 | n = data->cpu_check; |
292 | for (i = 0; i < NR_CPUS; i++) { | 300 | for (i = 0; i < NR_CPUS; i++) { |
293 | if (test_bit(n, &data->cpu_event)) { | 301 | if (test_bit(n, &data->cpu_event) && cpu_online(n)) { |
294 | cpu = n; | 302 | cpu = n; |
295 | break; | 303 | break; |
296 | } | 304 | } |
@@ -584,11 +592,10 @@ salinfo_init(void) | |||
584 | 592 | ||
585 | /* we missed any events before now */ | 593 | /* we missed any events before now */ |
586 | online = 0; | 594 | online = 0; |
587 | for (j = 0; j < NR_CPUS; j++) | 595 | for_each_online_cpu(j) { |
588 | if (cpu_online(j)) { | 596 | set_bit(j, &data->cpu_event); |
589 | set_bit(j, &data->cpu_event); | 597 | ++online; |
590 | ++online; | 598 | } |
591 | } | ||
592 | sema_init(&data->sem, online); | 599 | sema_init(&data->sem, online); |
593 | 600 | ||
594 | *sdir++ = dir; | 601 | *sdir++ = dir; |