Skip to content

Commit 9618eda

Browse files
committed
powerpc: Fix event-scan code for 32-bit CHRP
On CHRP machines we are supposed to call into firmware (RTAS) periodically, to give it a chance to check for errors and other events. Under ppc we had some special code in timer_interrupt to do this, but that didn't get transferred over to arch/powerpc. Instead, we use an array of timer_list structs, one per CPU, and use add_timer_on to make sure each one gets called on the appropriate CPU. With this we can remove the heartbeat_* elements of the ppc_md struct. Signed-off-by: Paul Mackerras <paulus@samba.org>
1 parent d0cc0df commit 9618eda

3 files changed

Lines changed: 46 additions & 24 deletions

File tree

‎arch/powerpc/platforms/chrp/chrp.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ extern int chrp_set_rtc_time(struct rtc_time *);
88
extern long chrp_time_init(void);
99

1010
extern void chrp_find_bridges(void);
11-
extern void chrp_event_scan(void);
11+
extern void chrp_event_scan(unsigned long);

‎arch/powerpc/platforms/chrp/setup.c‎

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <linux/root_dev.h>
3636
#include <linux/initrd.h>
3737
#include <linux/module.h>
38+
#include <linux/timer.h>
3839

3940
#include <asm/io.h>
4041
#include <asm/pgtable.h>
@@ -61,6 +62,10 @@ EXPORT_SYMBOL(_chrp_type);
6162

6263
struct mpic *chrp_mpic;
6364

65+
/* Used for doing CHRP event-scans */
66+
DEFINE_PER_CPU(struct timer_list, heartbeat_timer);
67+
unsigned long event_scan_interval;
68+
6469
/*
6570
* XXX this should be in xmon.h, but putting it there means xmon.h
6671
* has to include <linux/interrupt.h> (to get irqreturn_t), which
@@ -229,8 +234,6 @@ void __init chrp_setup_arch(void)
229234
{
230235
struct device_node *root = find_path_device ("/");
231236
char *machine = NULL;
232-
struct device_node *device;
233-
unsigned int *p = NULL;
234237

235238
/* init to some ~sane value until calibrate_delay() runs */
236239
loops_per_jiffy = 50000000/HZ;
@@ -287,21 +290,6 @@ void __init chrp_setup_arch(void)
287290
*/
288291
sio_init();
289292

290-
/* Get the event scan rate for the rtas so we know how
291-
* often it expects a heartbeat. -- Cort
292-
*/
293-
device = find_devices("rtas");
294-
if (device)
295-
p = (unsigned int *) get_property
296-
(device, "rtas-event-scan-rate", NULL);
297-
if (p && *p) {
298-
ppc_md.heartbeat = chrp_event_scan;
299-
ppc_md.heartbeat_reset = HZ / (*p * 30) - 1;
300-
ppc_md.heartbeat_count = 1;
301-
printk("RTAS Event Scan Rate: %u (%lu jiffies)\n",
302-
*p, ppc_md.heartbeat_reset);
303-
}
304-
305293
pci_create_OF_bus_map();
306294

307295
/*
@@ -312,15 +300,16 @@ void __init chrp_setup_arch(void)
312300
}
313301

314302
void
315-
chrp_event_scan(void)
303+
chrp_event_scan(unsigned long unused)
316304
{
317305
unsigned char log[1024];
318306
int ret = 0;
319307

320308
/* XXX: we should loop until the hardware says no more error logs -- Cort */
321309
rtas_call(rtas_token("event-scan"), 4, 1, &ret, 0xffffffff, 0,
322310
__pa(log), 1024);
323-
ppc_md.heartbeat_count = ppc_md.heartbeat_reset;
311+
mod_timer(&__get_cpu_var(heartbeat_timer),
312+
jiffies + event_scan_interval);
324313
}
325314

326315
/*
@@ -465,6 +454,9 @@ void __init chrp_init_IRQ(void)
465454
void __init
466455
chrp_init2(void)
467456
{
457+
struct device_node *device;
458+
unsigned int *p = NULL;
459+
468460
#ifdef CONFIG_NVRAM
469461
chrp_nvram_init();
470462
#endif
@@ -476,6 +468,40 @@ chrp_init2(void)
476468
request_region(0x80,0x10,"dma page reg");
477469
request_region(0xc0,0x20,"dma2");
478470

471+
/* Get the event scan rate for the rtas so we know how
472+
* often it expects a heartbeat. -- Cort
473+
*/
474+
device = find_devices("rtas");
475+
if (device)
476+
p = (unsigned int *) get_property
477+
(device, "rtas-event-scan-rate", NULL);
478+
if (p && *p) {
479+
/*
480+
* Arrange to call chrp_event_scan at least *p times
481+
* per minute. We use 59 rather than 60 here so that
482+
* the rate will be slightly higher than the minimum.
483+
* This all assumes we don't do hotplug CPU on any
484+
* machine that needs the event scans done.
485+
*/
486+
unsigned long interval, offset;
487+
int cpu, ncpus;
488+
struct timer_list *timer;
489+
490+
interval = HZ * 59 / *p;
491+
offset = HZ;
492+
ncpus = num_online_cpus();
493+
event_scan_interval = ncpus * interval;
494+
for (cpu = 0; cpu < ncpus; ++cpu) {
495+
timer = &per_cpu(heartbeat_timer, cpu);
496+
setup_timer(timer, chrp_event_scan, 0);
497+
timer->expires = jiffies + offset;
498+
add_timer_on(timer, cpu);
499+
offset += interval;
500+
}
501+
printk("RTAS Event Scan Rate: %u (%lu jiffies)\n",
502+
*p, interval);
503+
}
504+
479505
if (ppc_md.progress)
480506
ppc_md.progress(" Have fun! ", 0x7777);
481507
}

‎include/asm-powerpc/machdep.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,6 @@ struct machdep_calls {
176176
May be NULL. */
177177
void (*init)(void);
178178

179-
void (*heartbeat)(void);
180-
unsigned long heartbeat_reset;
181-
unsigned long heartbeat_count;
182-
183179
void (*setup_io_mappings)(void);
184180

185181
void (*early_serial_map)(void);

0 commit comments

Comments
 (0)