diff options
Diffstat (limited to 'drivers/watchdog/intel_scu_watchdog.c')
| -rw-r--r-- | drivers/watchdog/intel_scu_watchdog.c | 71 |
1 files changed, 34 insertions, 37 deletions
diff --git a/drivers/watchdog/intel_scu_watchdog.c b/drivers/watchdog/intel_scu_watchdog.c index 1abdc0454c54..9dda2d08af91 100644 --- a/drivers/watchdog/intel_scu_watchdog.c +++ b/drivers/watchdog/intel_scu_watchdog.c | |||
| @@ -22,6 +22,8 @@ | |||
| 22 | * | 22 | * |
| 23 | */ | 23 | */ |
| 24 | 24 | ||
| 25 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 26 | |||
| 25 | #include <linux/compiler.h> | 27 | #include <linux/compiler.h> |
| 26 | #include <linux/module.h> | 28 | #include <linux/module.h> |
| 27 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
| @@ -96,15 +98,14 @@ static struct intel_scu_watchdog_dev watchdog_device; | |||
| 96 | static void watchdog_fire(void) | 98 | static void watchdog_fire(void) |
| 97 | { | 99 | { |
| 98 | if (force_boot) { | 100 | if (force_boot) { |
| 99 | printk(KERN_CRIT PFX "Initiating system reboot.\n"); | 101 | pr_crit("Initiating system reboot\n"); |
| 100 | emergency_restart(); | 102 | emergency_restart(); |
| 101 | printk(KERN_CRIT PFX "Reboot didn't ?????\n"); | 103 | pr_crit("Reboot didn't ?????\n"); |
| 102 | } | 104 | } |
| 103 | 105 | ||
| 104 | else { | 106 | else { |
| 105 | printk(KERN_CRIT PFX "Immediate Reboot Disabled\n"); | 107 | pr_crit("Immediate Reboot Disabled\n"); |
| 106 | printk(KERN_CRIT PFX | 108 | pr_crit("System will reset when watchdog timer times out!\n"); |
| 107 | "System will reset when watchdog timer times out!\n"); | ||
| 108 | } | 109 | } |
| 109 | } | 110 | } |
| 110 | 111 | ||
| @@ -112,8 +113,8 @@ static int check_timer_margin(int new_margin) | |||
| 112 | { | 113 | { |
| 113 | if ((new_margin < MIN_TIME_CYCLE) || | 114 | if ((new_margin < MIN_TIME_CYCLE) || |
| 114 | (new_margin > MAX_TIME - timer_set)) { | 115 | (new_margin > MAX_TIME - timer_set)) { |
| 115 | pr_debug("Watchdog timer: value of new_margin %d is out of the range %d to %d\n", | 116 | pr_debug("value of new_margin %d is out of the range %d to %d\n", |
| 116 | new_margin, MIN_TIME_CYCLE, MAX_TIME - timer_set); | 117 | new_margin, MIN_TIME_CYCLE, MAX_TIME - timer_set); |
| 117 | return -EINVAL; | 118 | return -EINVAL; |
| 118 | } | 119 | } |
| 119 | return 0; | 120 | return 0; |
| @@ -156,14 +157,14 @@ static irqreturn_t watchdog_timer_interrupt(int irq, void *dev_id) | |||
| 156 | int int_status; | 157 | int int_status; |
| 157 | int_status = ioread32(watchdog_device.timer_interrupt_status_addr); | 158 | int_status = ioread32(watchdog_device.timer_interrupt_status_addr); |
| 158 | 159 | ||
| 159 | pr_debug("Watchdog timer: irq, int_status: %x\n", int_status); | 160 | pr_debug("irq, int_status: %x\n", int_status); |
| 160 | 161 | ||
| 161 | if (int_status != 0) | 162 | if (int_status != 0) |
| 162 | return IRQ_NONE; | 163 | return IRQ_NONE; |
| 163 | 164 | ||
| 164 | /* has the timer been started? If not, then this is spurious */ | 165 | /* has the timer been started? If not, then this is spurious */ |
| 165 | if (watchdog_device.timer_started == 0) { | 166 | if (watchdog_device.timer_started == 0) { |
| 166 | pr_debug("Watchdog timer: spurious interrupt received\n"); | 167 | pr_debug("spurious interrupt received\n"); |
| 167 | return IRQ_HANDLED; | 168 | return IRQ_HANDLED; |
| 168 | } | 169 | } |
| 169 | 170 | ||
| @@ -220,16 +221,15 @@ static int intel_scu_set_heartbeat(u32 t) | |||
| 220 | (watchdog_device.timer_set - timer_margin) | 221 | (watchdog_device.timer_set - timer_margin) |
| 221 | * watchdog_device.timer_tbl_ptr->freq_hz; | 222 | * watchdog_device.timer_tbl_ptr->freq_hz; |
| 222 | 223 | ||
| 223 | pr_debug("Watchdog timer: set_heartbeat: timer freq is %d\n", | 224 | pr_debug("set_heartbeat: timer freq is %d\n", |
| 224 | watchdog_device.timer_tbl_ptr->freq_hz); | 225 | watchdog_device.timer_tbl_ptr->freq_hz); |
| 225 | pr_debug("Watchdog timer: set_heartbeat: timer_set is %x (hex)\n", | 226 | pr_debug("set_heartbeat: timer_set is %x (hex)\n", |
| 226 | watchdog_device.timer_set); | 227 | watchdog_device.timer_set); |
| 227 | pr_debug("Watchdog timer: set_hearbeat: timer_margin is %x (hex)\n", | 228 | pr_debug("set_hearbeat: timer_margin is %x (hex)\n", timer_margin); |
| 228 | timer_margin); | 229 | pr_debug("set_heartbeat: threshold is %x (hex)\n", |
| 229 | pr_debug("Watchdog timer: set_heartbeat: threshold is %x (hex)\n", | 230 | watchdog_device.threshold); |
| 230 | watchdog_device.threshold); | 231 | pr_debug("set_heartbeat: soft_threshold is %x (hex)\n", |
| 231 | pr_debug("Watchdog timer: set_heartbeat: soft_threshold is %x (hex)\n", | 232 | watchdog_device.soft_threshold); |
| 232 | watchdog_device.soft_threshold); | ||
| 233 | 233 | ||
| 234 | /* Adjust thresholds by FREQ_ADJUSTMENT factor, to make the */ | 234 | /* Adjust thresholds by FREQ_ADJUSTMENT factor, to make the */ |
| 235 | /* watchdog timing come out right. */ | 235 | /* watchdog timing come out right. */ |
| @@ -264,7 +264,7 @@ static int intel_scu_set_heartbeat(u32 t) | |||
| 264 | 264 | ||
| 265 | if (MAX_RETRY < retry_count++) { | 265 | if (MAX_RETRY < retry_count++) { |
| 266 | /* Unable to set timer value */ | 266 | /* Unable to set timer value */ |
| 267 | pr_err("Watchdog timer: Unable to set timer\n"); | 267 | pr_err("Unable to set timer\n"); |
| 268 | return -ENODEV; | 268 | return -ENODEV; |
| 269 | } | 269 | } |
| 270 | 270 | ||
| @@ -321,18 +321,17 @@ static int intel_scu_release(struct inode *inode, struct file *file) | |||
| 321 | */ | 321 | */ |
| 322 | 322 | ||
| 323 | if (!test_and_clear_bit(0, &watchdog_device.driver_open)) { | 323 | if (!test_and_clear_bit(0, &watchdog_device.driver_open)) { |
| 324 | pr_debug("Watchdog timer: intel_scu_release, without open\n"); | 324 | pr_debug("intel_scu_release, without open\n"); |
| 325 | return -ENOTTY; | 325 | return -ENOTTY; |
| 326 | } | 326 | } |
| 327 | 327 | ||
| 328 | if (!watchdog_device.timer_started) { | 328 | if (!watchdog_device.timer_started) { |
| 329 | /* Just close, since timer has not been started */ | 329 | /* Just close, since timer has not been started */ |
| 330 | pr_debug("Watchdog timer: closed, without starting timer\n"); | 330 | pr_debug("closed, without starting timer\n"); |
| 331 | return 0; | 331 | return 0; |
| 332 | } | 332 | } |
| 333 | 333 | ||
| 334 | printk(KERN_CRIT PFX | 334 | pr_crit("Unexpected close of /dev/watchdog!\n"); |
| 335 | "Unexpected close of /dev/watchdog!\n"); | ||
| 336 | 335 | ||
| 337 | /* Since the timer was started, prevent future reopens */ | 336 | /* Since the timer was started, prevent future reopens */ |
| 338 | watchdog_device.driver_closed = 1; | 337 | watchdog_device.driver_closed = 1; |
| @@ -454,9 +453,8 @@ static int __init intel_scu_watchdog_init(void) | |||
| 454 | /* Check value of timer_set boot parameter */ | 453 | /* Check value of timer_set boot parameter */ |
| 455 | if ((timer_set < MIN_TIME_CYCLE) || | 454 | if ((timer_set < MIN_TIME_CYCLE) || |
| 456 | (timer_set > MAX_TIME - MIN_TIME_CYCLE)) { | 455 | (timer_set > MAX_TIME - MIN_TIME_CYCLE)) { |
| 457 | pr_err("Watchdog timer: value of timer_set %x (hex) " | 456 | pr_err("value of timer_set %x (hex) is out of range from %x to %x (hex)\n", |
| 458 | "is out of range from %x to %x (hex)\n", | 457 | timer_set, MIN_TIME_CYCLE, MAX_TIME - MIN_TIME_CYCLE); |
| 459 | timer_set, MIN_TIME_CYCLE, MAX_TIME - MIN_TIME_CYCLE); | ||
| 460 | return -EINVAL; | 458 | return -EINVAL; |
| 461 | } | 459 | } |
| 462 | 460 | ||
| @@ -467,19 +465,18 @@ static int __init intel_scu_watchdog_init(void) | |||
| 467 | watchdog_device.timer_tbl_ptr = sfi_get_mtmr(sfi_mtimer_num-1); | 465 | watchdog_device.timer_tbl_ptr = sfi_get_mtmr(sfi_mtimer_num-1); |
| 468 | 466 | ||
| 469 | if (watchdog_device.timer_tbl_ptr == NULL) { | 467 | if (watchdog_device.timer_tbl_ptr == NULL) { |
| 470 | pr_debug("Watchdog timer - Intel SCU watchdog: timer is not available\n"); | 468 | pr_debug("timer is not available\n"); |
| 471 | return -ENODEV; | 469 | return -ENODEV; |
| 472 | } | 470 | } |
| 473 | /* make sure the timer exists */ | 471 | /* make sure the timer exists */ |
| 474 | if (watchdog_device.timer_tbl_ptr->phys_addr == 0) { | 472 | if (watchdog_device.timer_tbl_ptr->phys_addr == 0) { |
| 475 | pr_debug("Watchdog timer - Intel SCU watchdog - timer %d does not have valid physical memory\n", | 473 | pr_debug("timer %d does not have valid physical memory\n", |
| 476 | sfi_mtimer_num); | 474 | sfi_mtimer_num); |
| 477 | return -ENODEV; | 475 | return -ENODEV; |
| 478 | } | 476 | } |
| 479 | 477 | ||
| 480 | if (watchdog_device.timer_tbl_ptr->irq == 0) { | 478 | if (watchdog_device.timer_tbl_ptr->irq == 0) { |
| 481 | pr_debug("Watchdog timer: timer %d invalid irq\n", | 479 | pr_debug("timer %d invalid irq\n", sfi_mtimer_num); |
| 482 | sfi_mtimer_num); | ||
| 483 | return -ENODEV; | 480 | return -ENODEV; |
| 484 | } | 481 | } |
| 485 | 482 | ||
| @@ -487,7 +484,7 @@ static int __init intel_scu_watchdog_init(void) | |||
| 487 | 20); | 484 | 20); |
| 488 | 485 | ||
| 489 | if (tmp_addr == NULL) { | 486 | if (tmp_addr == NULL) { |
| 490 | pr_debug("Watchdog timer: timer unable to ioremap\n"); | 487 | pr_debug("timer unable to ioremap\n"); |
| 491 | return -ENOMEM; | 488 | return -ENOMEM; |
| 492 | } | 489 | } |
| 493 | 490 | ||
| @@ -512,7 +509,7 @@ static int __init intel_scu_watchdog_init(void) | |||
| 512 | 509 | ||
| 513 | ret = register_reboot_notifier(&watchdog_device.intel_scu_notifier); | 510 | ret = register_reboot_notifier(&watchdog_device.intel_scu_notifier); |
| 514 | if (ret) { | 511 | if (ret) { |
| 515 | pr_err("Watchdog timer: cannot register notifier %d)\n", ret); | 512 | pr_err("cannot register notifier %d)\n", ret); |
| 516 | goto register_reboot_error; | 513 | goto register_reboot_error; |
| 517 | } | 514 | } |
| 518 | 515 | ||
| @@ -522,8 +519,8 @@ static int __init intel_scu_watchdog_init(void) | |||
| 522 | 519 | ||
| 523 | ret = misc_register(&watchdog_device.miscdev); | 520 | ret = misc_register(&watchdog_device.miscdev); |
| 524 | if (ret) { | 521 | if (ret) { |
| 525 | pr_err("Watchdog timer: cannot register miscdev %d err =%d\n", | 522 | pr_err("cannot register miscdev %d err =%d\n", |
| 526 | WATCHDOG_MINOR, ret); | 523 | WATCHDOG_MINOR, ret); |
| 527 | goto misc_register_error; | 524 | goto misc_register_error; |
| 528 | } | 525 | } |
| 529 | 526 | ||
| @@ -532,7 +529,7 @@ static int __init intel_scu_watchdog_init(void) | |||
| 532 | IRQF_SHARED, "watchdog", | 529 | IRQF_SHARED, "watchdog", |
| 533 | &watchdog_device.timer_load_count_addr); | 530 | &watchdog_device.timer_load_count_addr); |
| 534 | if (ret) { | 531 | if (ret) { |
| 535 | pr_err("Watchdog timer: error requesting irq %d\n", ret); | 532 | pr_err("error requesting irq %d\n", ret); |
| 536 | goto request_irq_error; | 533 | goto request_irq_error; |
| 537 | } | 534 | } |
| 538 | /* Make sure timer is disabled before returning */ | 535 | /* Make sure timer is disabled before returning */ |
