diff options
author | Chen Gong <g.chen@freescale.com> | 2008-04-29 04:42:05 -0400 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2008-05-25 05:43:06 -0400 |
commit | f172ddc61ad7a7c444b2b3e08992a45c76b821f9 (patch) | |
tree | 6d04fd33c45f74737c3d7601b0bdb81c884eb0fc /drivers/watchdog | |
parent | 0b36086b5d7c397a128784bed6e332418e500af1 (diff) |
[WATCHDOG] Fix booke_wdt.c on MPC85xx SMP system's
On Book-E SMP systems each core has its own private watchdog. If only one
watchdog is enabled, when the core that doesn't enable the watchdog is hung,
system can't reset because no watchdog is running on it. That's bad. It
means we must enable watchdogs on both cores.
We can use smp_call_function() to send appropriate messages to all the other
cores to enable and update the watchdog.
Signed-off-by: Chen Gong <g.chen@freescale.com>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r-- | drivers/watchdog/booke_wdt.c | 88 |
1 files changed, 40 insertions, 48 deletions
diff --git a/drivers/watchdog/booke_wdt.c b/drivers/watchdog/booke_wdt.c index d362f5bf658a..c1ba0db48501 100644 --- a/drivers/watchdog/booke_wdt.c +++ b/drivers/watchdog/booke_wdt.c | |||
@@ -1,12 +1,10 @@ | |||
1 | /* | 1 | /* |
2 | * drivers/char/watchdog/booke_wdt.c | ||
3 | * | ||
4 | * Watchdog timer for PowerPC Book-E systems | 2 | * Watchdog timer for PowerPC Book-E systems |
5 | * | 3 | * |
6 | * Author: Matthew McClintock | 4 | * Author: Matthew McClintock |
7 | * Maintainer: Kumar Gala <galak@kernel.crashing.org> | 5 | * Maintainer: Kumar Gala <galak@kernel.crashing.org> |
8 | * | 6 | * |
9 | * Copyright 2005 Freescale Semiconductor Inc. | 7 | * Copyright 2005, 2008 Freescale Semiconductor Inc. |
10 | * | 8 | * |
11 | * This program is free software; you can redistribute it and/or modify it | 9 | * This program is free software; you can redistribute it and/or modify it |
12 | * under the terms of the GNU General Public License as published by the | 10 | * under the terms of the GNU General Public License as published by the |
@@ -16,6 +14,7 @@ | |||
16 | 14 | ||
17 | #include <linux/module.h> | 15 | #include <linux/module.h> |
18 | #include <linux/fs.h> | 16 | #include <linux/fs.h> |
17 | #include <linux/smp.h> | ||
19 | #include <linux/miscdevice.h> | 18 | #include <linux/miscdevice.h> |
20 | #include <linux/notifier.h> | 19 | #include <linux/notifier.h> |
21 | #include <linux/watchdog.h> | 20 | #include <linux/watchdog.h> |
@@ -38,7 +37,7 @@ | |||
38 | #define WDT_PERIOD_DEFAULT 3 /* Refer to the PPC40x and PPC4xx manuals */ | 37 | #define WDT_PERIOD_DEFAULT 3 /* Refer to the PPC40x and PPC4xx manuals */ |
39 | #endif /* for timing information */ | 38 | #endif /* for timing information */ |
40 | 39 | ||
41 | u32 booke_wdt_enabled = 0; | 40 | u32 booke_wdt_enabled; |
42 | u32 booke_wdt_period = WDT_PERIOD_DEFAULT; | 41 | u32 booke_wdt_period = WDT_PERIOD_DEFAULT; |
43 | 42 | ||
44 | #ifdef CONFIG_FSL_BOOKE | 43 | #ifdef CONFIG_FSL_BOOKE |
@@ -47,33 +46,31 @@ u32 booke_wdt_period = WDT_PERIOD_DEFAULT; | |||
47 | #define WDTP(x) (TCR_WP(x)) | 46 | #define WDTP(x) (TCR_WP(x)) |
48 | #endif | 47 | #endif |
49 | 48 | ||
50 | /* | 49 | static DEFINE_SPINLOCK(booke_wdt_lock); |
51 | * booke_wdt_ping: | 50 | |
52 | */ | 51 | static void __booke_wdt_ping(void *data) |
53 | static __inline__ void booke_wdt_ping(void) | ||
54 | { | 52 | { |
55 | mtspr(SPRN_TSR, TSR_ENW|TSR_WIS); | 53 | mtspr(SPRN_TSR, TSR_ENW|TSR_WIS); |
56 | } | 54 | } |
57 | 55 | ||
58 | /* | 56 | static void booke_wdt_ping(void) |
59 | * booke_wdt_enable: | 57 | { |
60 | */ | 58 | on_each_cpu(__booke_wdt_ping, NULL, 0, 0); |
61 | static __inline__ void booke_wdt_enable(void) | 59 | } |
60 | |||
61 | static void __booke_wdt_enable(void *data) | ||
62 | { | 62 | { |
63 | u32 val; | 63 | u32 val; |
64 | 64 | ||
65 | /* clear status before enabling watchdog */ | 65 | /* clear status before enabling watchdog */ |
66 | booke_wdt_ping(); | 66 | __booke_wdt_ping(NULL); |
67 | val = mfspr(SPRN_TCR); | 67 | val = mfspr(SPRN_TCR); |
68 | val |= (TCR_WIE|TCR_WRC(WRC_CHIP)|WDTP(booke_wdt_period)); | 68 | val |= (TCR_WIE|TCR_WRC(WRC_CHIP)|WDTP(booke_wdt_period)); |
69 | 69 | ||
70 | mtspr(SPRN_TCR, val); | 70 | mtspr(SPRN_TCR, val); |
71 | } | 71 | } |
72 | 72 | ||
73 | /* | 73 | static ssize_t booke_wdt_write(struct file *file, const char __user *buf, |
74 | * booke_wdt_write: | ||
75 | */ | ||
76 | static ssize_t booke_wdt_write (struct file *file, const char __user *buf, | ||
77 | size_t count, loff_t *ppos) | 74 | size_t count, loff_t *ppos) |
78 | { | 75 | { |
79 | booke_wdt_ping(); | 76 | booke_wdt_ping(); |
@@ -81,15 +78,11 @@ static ssize_t booke_wdt_write (struct file *file, const char __user *buf, | |||
81 | } | 78 | } |
82 | 79 | ||
83 | static struct watchdog_info ident = { | 80 | static struct watchdog_info ident = { |
84 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, | 81 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, |
85 | .firmware_version = 0, | 82 | .identity = "PowerPC Book-E Watchdog", |
86 | .identity = "PowerPC Book-E Watchdog", | ||
87 | }; | 83 | }; |
88 | 84 | ||
89 | /* | 85 | static int booke_wdt_ioctl(struct inode *inode, struct file *file, |
90 | * booke_wdt_ioctl: | ||
91 | */ | ||
92 | static int booke_wdt_ioctl (struct inode *inode, struct file *file, | ||
93 | unsigned int cmd, unsigned long arg) | 86 | unsigned int cmd, unsigned long arg) |
94 | { | 87 | { |
95 | u32 tmp = 0; | 88 | u32 tmp = 0; |
@@ -97,7 +90,7 @@ static int booke_wdt_ioctl (struct inode *inode, struct file *file, | |||
97 | 90 | ||
98 | switch (cmd) { | 91 | switch (cmd) { |
99 | case WDIOC_GETSUPPORT: | 92 | case WDIOC_GETSUPPORT: |
100 | if (copy_to_user ((struct watchdog_info __user *) arg, &ident, | 93 | if (copy_to_user((struct watchdog_info __user *)arg, &ident, |
101 | sizeof(struct watchdog_info))) | 94 | sizeof(struct watchdog_info))) |
102 | return -EFAULT; | 95 | return -EFAULT; |
103 | case WDIOC_GETSTATUS: | 96 | case WDIOC_GETSTATUS: |
@@ -132,33 +125,33 @@ static int booke_wdt_ioctl (struct inode *inode, struct file *file, | |||
132 | 125 | ||
133 | return 0; | 126 | return 0; |
134 | } | 127 | } |
135 | /* | 128 | |
136 | * booke_wdt_open: | 129 | static int booke_wdt_open(struct inode *inode, struct file *file) |
137 | */ | ||
138 | static int booke_wdt_open (struct inode *inode, struct file *file) | ||
139 | { | 130 | { |
131 | spin_lock(&booke_wdt_lock); | ||
140 | if (booke_wdt_enabled == 0) { | 132 | if (booke_wdt_enabled == 0) { |
141 | booke_wdt_enabled = 1; | 133 | booke_wdt_enabled = 1; |
142 | booke_wdt_enable(); | 134 | on_each_cpu(__booke_wdt_enable, NULL, 0, 0); |
143 | printk (KERN_INFO "PowerPC Book-E Watchdog Timer Enabled (wdt_period=%d)\n", | 135 | printk(KERN_INFO "PowerPC Book-E Watchdog Timer Enabled " |
144 | booke_wdt_period); | 136 | "(wdt_period=%d)\n", booke_wdt_period); |
145 | } | 137 | } |
138 | spin_unlock(&booke_wdt_lock); | ||
146 | 139 | ||
147 | return nonseekable_open(inode, file); | 140 | return nonseekable_open(inode, file); |
148 | } | 141 | } |
149 | 142 | ||
150 | static const struct file_operations booke_wdt_fops = { | 143 | static const struct file_operations booke_wdt_fops = { |
151 | .owner = THIS_MODULE, | 144 | .owner = THIS_MODULE, |
152 | .llseek = no_llseek, | 145 | .llseek = no_llseek, |
153 | .write = booke_wdt_write, | 146 | .write = booke_wdt_write, |
154 | .ioctl = booke_wdt_ioctl, | 147 | .ioctl = booke_wdt_ioctl, |
155 | .open = booke_wdt_open, | 148 | .open = booke_wdt_open, |
156 | }; | 149 | }; |
157 | 150 | ||
158 | static struct miscdevice booke_wdt_miscdev = { | 151 | static struct miscdevice booke_wdt_miscdev = { |
159 | .minor = WATCHDOG_MINOR, | 152 | .minor = WATCHDOG_MINOR, |
160 | .name = "watchdog", | 153 | .name = "watchdog", |
161 | .fops = &booke_wdt_fops, | 154 | .fops = &booke_wdt_fops, |
162 | }; | 155 | }; |
163 | 156 | ||
164 | static void __exit booke_wdt_exit(void) | 157 | static void __exit booke_wdt_exit(void) |
@@ -166,28 +159,27 @@ static void __exit booke_wdt_exit(void) | |||
166 | misc_deregister(&booke_wdt_miscdev); | 159 | misc_deregister(&booke_wdt_miscdev); |
167 | } | 160 | } |
168 | 161 | ||
169 | /* | ||
170 | * booke_wdt_init: | ||
171 | */ | ||
172 | static int __init booke_wdt_init(void) | 162 | static int __init booke_wdt_init(void) |
173 | { | 163 | { |
174 | int ret = 0; | 164 | int ret = 0; |
175 | 165 | ||
176 | printk (KERN_INFO "PowerPC Book-E Watchdog Timer Loaded\n"); | 166 | printk(KERN_INFO "PowerPC Book-E Watchdog Timer Loaded\n"); |
177 | ident.firmware_version = cur_cpu_spec->pvr_value; | 167 | ident.firmware_version = cur_cpu_spec->pvr_value; |
178 | 168 | ||
179 | ret = misc_register(&booke_wdt_miscdev); | 169 | ret = misc_register(&booke_wdt_miscdev); |
180 | if (ret) { | 170 | if (ret) { |
181 | printk (KERN_CRIT "Cannot register miscdev on minor=%d (err=%d)\n", | 171 | printk(KERN_CRIT "Cannot register miscdev on minor=%d: %d\n", |
182 | WATCHDOG_MINOR, ret); | 172 | WATCHDOG_MINOR, ret); |
183 | return ret; | 173 | return ret; |
184 | } | 174 | } |
185 | 175 | ||
176 | spin_lock(&booke_wdt_lock); | ||
186 | if (booke_wdt_enabled == 1) { | 177 | if (booke_wdt_enabled == 1) { |
187 | printk (KERN_INFO "PowerPC Book-E Watchdog Timer Enabled (wdt_period=%d)\n", | 178 | printk(KERN_INFO "PowerPC Book-E Watchdog Timer Enabled " |
188 | booke_wdt_period); | 179 | "(wdt_period=%d)\n", booke_wdt_period); |
189 | booke_wdt_enable(); | 180 | on_each_cpu(__booke_wdt_enable, NULL, 0, 0); |
190 | } | 181 | } |
182 | spin_unlock(&booke_wdt_lock); | ||
191 | 183 | ||
192 | return ret; | 184 | return ret; |
193 | } | 185 | } |