diff options
author | Corey Minyard <cminyard@mvista.com> | 2008-04-29 04:01:12 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-29 11:06:15 -0400 |
commit | 36c7dc44409ecc4631de25a66f13d67873cfd563 (patch) | |
tree | fc86c1df3b33b0933aaa246221d129d8f31906af /drivers/char/ipmi/ipmi_watchdog.c | |
parent | c305e3d38e5f54a48a4618496cdc1ada970ebf68 (diff) |
IPMI: Style fixes in the misc code
Lots of style fixes for the miscellaneous IPMI files. No functional
changes. Basically fixes everything reported by checkpatch and fixes the
comment style.
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/ipmi/ipmi_watchdog.c')
-rw-r--r-- | drivers/char/ipmi/ipmi_watchdog.c | 244 |
1 files changed, 133 insertions, 111 deletions
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c index 8f45ca9235ad..1b9a87047817 100644 --- a/drivers/char/ipmi/ipmi_watchdog.c +++ b/drivers/char/ipmi/ipmi_watchdog.c | |||
@@ -54,13 +54,15 @@ | |||
54 | #include <asm/atomic.h> | 54 | #include <asm/atomic.h> |
55 | 55 | ||
56 | #ifdef CONFIG_X86 | 56 | #ifdef CONFIG_X86 |
57 | /* This is ugly, but I've determined that x86 is the only architecture | 57 | /* |
58 | that can reasonably support the IPMI NMI watchdog timeout at this | 58 | * This is ugly, but I've determined that x86 is the only architecture |
59 | time. If another architecture adds this capability somehow, it | 59 | * that can reasonably support the IPMI NMI watchdog timeout at this |
60 | will have to be a somewhat different mechanism and I have no idea | 60 | * time. If another architecture adds this capability somehow, it |
61 | how it will work. So in the unlikely event that another | 61 | * will have to be a somewhat different mechanism and I have no idea |
62 | architecture supports this, we can figure out a good generic | 62 | * how it will work. So in the unlikely event that another |
63 | mechanism for it at that time. */ | 63 | * architecture supports this, we can figure out a good generic |
64 | * mechanism for it at that time. | ||
65 | */ | ||
64 | #include <asm/kdebug.h> | 66 | #include <asm/kdebug.h> |
65 | #define HAVE_DIE_NMI | 67 | #define HAVE_DIE_NMI |
66 | #endif | 68 | #endif |
@@ -95,9 +97,8 @@ | |||
95 | /* Operations that can be performed on a pretimout. */ | 97 | /* Operations that can be performed on a pretimout. */ |
96 | #define WDOG_PREOP_NONE 0 | 98 | #define WDOG_PREOP_NONE 0 |
97 | #define WDOG_PREOP_PANIC 1 | 99 | #define WDOG_PREOP_PANIC 1 |
98 | #define WDOG_PREOP_GIVE_DATA 2 /* Cause data to be available to | 100 | /* Cause data to be available to read. Doesn't work in NMI mode. */ |
99 | read. Doesn't work in NMI | 101 | #define WDOG_PREOP_GIVE_DATA 2 |
100 | mode. */ | ||
101 | 102 | ||
102 | /* Actions to perform on a full timeout. */ | 103 | /* Actions to perform on a full timeout. */ |
103 | #define WDOG_SET_TIMEOUT_ACT(byte, use) \ | 104 | #define WDOG_SET_TIMEOUT_ACT(byte, use) \ |
@@ -108,8 +109,10 @@ | |||
108 | #define WDOG_TIMEOUT_POWER_DOWN 2 | 109 | #define WDOG_TIMEOUT_POWER_DOWN 2 |
109 | #define WDOG_TIMEOUT_POWER_CYCLE 3 | 110 | #define WDOG_TIMEOUT_POWER_CYCLE 3 |
110 | 111 | ||
111 | /* Byte 3 of the get command, byte 4 of the get response is the | 112 | /* |
112 | pre-timeout in seconds. */ | 113 | * Byte 3 of the get command, byte 4 of the get response is the |
114 | * pre-timeout in seconds. | ||
115 | */ | ||
113 | 116 | ||
114 | /* Bits for setting byte 4 of the set command, byte 5 of the get response. */ | 117 | /* Bits for setting byte 4 of the set command, byte 5 of the get response. */ |
115 | #define WDOG_EXPIRE_CLEAR_BIOS_FRB2 (1 << 1) | 118 | #define WDOG_EXPIRE_CLEAR_BIOS_FRB2 (1 << 1) |
@@ -118,11 +121,13 @@ | |||
118 | #define WDOG_EXPIRE_CLEAR_SMS_OS (1 << 4) | 121 | #define WDOG_EXPIRE_CLEAR_SMS_OS (1 << 4) |
119 | #define WDOG_EXPIRE_CLEAR_OEM (1 << 5) | 122 | #define WDOG_EXPIRE_CLEAR_OEM (1 << 5) |
120 | 123 | ||
121 | /* Setting/getting the watchdog timer value. This is for bytes 5 and | 124 | /* |
122 | 6 (the timeout time) of the set command, and bytes 6 and 7 (the | 125 | * Setting/getting the watchdog timer value. This is for bytes 5 and |
123 | timeout time) and 8 and 9 (the current countdown value) of the | 126 | * 6 (the timeout time) of the set command, and bytes 6 and 7 (the |
124 | response. The timeout value is given in seconds (in the command it | 127 | * timeout time) and 8 and 9 (the current countdown value) of the |
125 | is 100ms intervals). */ | 128 | * response. The timeout value is given in seconds (in the command it |
129 | * is 100ms intervals). | ||
130 | */ | ||
126 | #define WDOG_SET_TIMEOUT(byte1, byte2, val) \ | 131 | #define WDOG_SET_TIMEOUT(byte1, byte2, val) \ |
127 | (byte1) = (((val) * 10) & 0xff), (byte2) = (((val) * 10) >> 8) | 132 | (byte1) = (((val) * 10) & 0xff), (byte2) = (((val) * 10) >> 8) |
128 | #define WDOG_GET_TIMEOUT(byte1, byte2) \ | 133 | #define WDOG_GET_TIMEOUT(byte1, byte2) \ |
@@ -184,8 +189,10 @@ static int ipmi_set_timeout(int do_heartbeat); | |||
184 | static void ipmi_register_watchdog(int ipmi_intf); | 189 | static void ipmi_register_watchdog(int ipmi_intf); |
185 | static void ipmi_unregister_watchdog(int ipmi_intf); | 190 | static void ipmi_unregister_watchdog(int ipmi_intf); |
186 | 191 | ||
187 | /* If true, the driver will start running as soon as it is configured | 192 | /* |
188 | and ready. */ | 193 | * If true, the driver will start running as soon as it is configured |
194 | * and ready. | ||
195 | */ | ||
189 | static int start_now; | 196 | static int start_now; |
190 | 197 | ||
191 | static int set_param_int(const char *val, struct kernel_param *kp) | 198 | static int set_param_int(const char *val, struct kernel_param *kp) |
@@ -309,10 +316,12 @@ static int ipmi_ignore_heartbeat; | |||
309 | /* Is someone using the watchdog? Only one user is allowed. */ | 316 | /* Is someone using the watchdog? Only one user is allowed. */ |
310 | static unsigned long ipmi_wdog_open; | 317 | static unsigned long ipmi_wdog_open; |
311 | 318 | ||
312 | /* If set to 1, the heartbeat command will set the state to reset and | 319 | /* |
313 | start the timer. The timer doesn't normally run when the driver is | 320 | * If set to 1, the heartbeat command will set the state to reset and |
314 | first opened until the heartbeat is set the first time, this | 321 | * start the timer. The timer doesn't normally run when the driver is |
315 | variable is used to accomplish this. */ | 322 | * first opened until the heartbeat is set the first time, this |
323 | * variable is used to accomplish this. | ||
324 | */ | ||
316 | static int ipmi_start_timer_on_heartbeat; | 325 | static int ipmi_start_timer_on_heartbeat; |
317 | 326 | ||
318 | /* IPMI version of the BMC. */ | 327 | /* IPMI version of the BMC. */ |
@@ -329,10 +338,12 @@ static int nmi_handler_registered; | |||
329 | 338 | ||
330 | static int ipmi_heartbeat(void); | 339 | static int ipmi_heartbeat(void); |
331 | 340 | ||
332 | /* We use a mutex to make sure that only one thing can send a set | 341 | /* |
333 | timeout at one time, because we only have one copy of the data. | 342 | * We use a mutex to make sure that only one thing can send a set |
334 | The mutex is claimed when the set_timeout is sent and freed | 343 | * timeout at one time, because we only have one copy of the data. |
335 | when both messages are free. */ | 344 | * The mutex is claimed when the set_timeout is sent and freed |
345 | * when both messages are free. | ||
346 | */ | ||
336 | static atomic_t set_timeout_tofree = ATOMIC_INIT(0); | 347 | static atomic_t set_timeout_tofree = ATOMIC_INIT(0); |
337 | static DEFINE_MUTEX(set_timeout_lock); | 348 | static DEFINE_MUTEX(set_timeout_lock); |
338 | static DECLARE_COMPLETION(set_timeout_wait); | 349 | static DECLARE_COMPLETION(set_timeout_wait); |
@@ -346,15 +357,13 @@ static void set_timeout_free_recv(struct ipmi_recv_msg *msg) | |||
346 | if (atomic_dec_and_test(&set_timeout_tofree)) | 357 | if (atomic_dec_and_test(&set_timeout_tofree)) |
347 | complete(&set_timeout_wait); | 358 | complete(&set_timeout_wait); |
348 | } | 359 | } |
349 | static struct ipmi_smi_msg set_timeout_smi_msg = | 360 | static struct ipmi_smi_msg set_timeout_smi_msg = { |
350 | { | ||
351 | .done = set_timeout_free_smi | 361 | .done = set_timeout_free_smi |
352 | }; | 362 | }; |
353 | static struct ipmi_recv_msg set_timeout_recv_msg = | 363 | static struct ipmi_recv_msg set_timeout_recv_msg = { |
354 | { | ||
355 | .done = set_timeout_free_recv | 364 | .done = set_timeout_free_recv |
356 | }; | 365 | }; |
357 | 366 | ||
358 | static int i_ipmi_set_timeout(struct ipmi_smi_msg *smi_msg, | 367 | static int i_ipmi_set_timeout(struct ipmi_smi_msg *smi_msg, |
359 | struct ipmi_recv_msg *recv_msg, | 368 | struct ipmi_recv_msg *recv_msg, |
360 | int *send_heartbeat_now) | 369 | int *send_heartbeat_now) |
@@ -373,13 +382,14 @@ static int i_ipmi_set_timeout(struct ipmi_smi_msg *smi_msg, | |||
373 | WDOG_SET_TIMER_USE(data[0], WDOG_TIMER_USE_SMS_OS); | 382 | WDOG_SET_TIMER_USE(data[0], WDOG_TIMER_USE_SMS_OS); |
374 | 383 | ||
375 | if ((ipmi_version_major > 1) | 384 | if ((ipmi_version_major > 1) |
376 | || ((ipmi_version_major == 1) && (ipmi_version_minor >= 5))) | 385 | || ((ipmi_version_major == 1) && (ipmi_version_minor >= 5))) { |
377 | { | ||
378 | /* This is an IPMI 1.5-only feature. */ | 386 | /* This is an IPMI 1.5-only feature. */ |
379 | data[0] |= WDOG_DONT_STOP_ON_SET; | 387 | data[0] |= WDOG_DONT_STOP_ON_SET; |
380 | } else if (ipmi_watchdog_state != WDOG_TIMEOUT_NONE) { | 388 | } else if (ipmi_watchdog_state != WDOG_TIMEOUT_NONE) { |
381 | /* In ipmi 1.0, setting the timer stops the watchdog, we | 389 | /* |
382 | need to start it back up again. */ | 390 | * In ipmi 1.0, setting the timer stops the watchdog, we |
391 | * need to start it back up again. | ||
392 | */ | ||
383 | hbnow = 1; | 393 | hbnow = 1; |
384 | } | 394 | } |
385 | 395 | ||
@@ -465,12 +475,10 @@ static void panic_recv_free(struct ipmi_recv_msg *msg) | |||
465 | atomic_dec(&panic_done_count); | 475 | atomic_dec(&panic_done_count); |
466 | } | 476 | } |
467 | 477 | ||
468 | static struct ipmi_smi_msg panic_halt_heartbeat_smi_msg = | 478 | static struct ipmi_smi_msg panic_halt_heartbeat_smi_msg = { |
469 | { | ||
470 | .done = panic_smi_free | 479 | .done = panic_smi_free |
471 | }; | 480 | }; |
472 | static struct ipmi_recv_msg panic_halt_heartbeat_recv_msg = | 481 | static struct ipmi_recv_msg panic_halt_heartbeat_recv_msg = { |
473 | { | ||
474 | .done = panic_recv_free | 482 | .done = panic_recv_free |
475 | }; | 483 | }; |
476 | 484 | ||
@@ -480,8 +488,10 @@ static void panic_halt_ipmi_heartbeat(void) | |||
480 | struct ipmi_system_interface_addr addr; | 488 | struct ipmi_system_interface_addr addr; |
481 | int rv; | 489 | int rv; |
482 | 490 | ||
483 | /* Don't reset the timer if we have the timer turned off, that | 491 | /* |
484 | re-enables the watchdog. */ | 492 | * Don't reset the timer if we have the timer turned off, that |
493 | * re-enables the watchdog. | ||
494 | */ | ||
485 | if (ipmi_watchdog_state == WDOG_TIMEOUT_NONE) | 495 | if (ipmi_watchdog_state == WDOG_TIMEOUT_NONE) |
486 | return; | 496 | return; |
487 | 497 | ||
@@ -505,19 +515,19 @@ static void panic_halt_ipmi_heartbeat(void) | |||
505 | atomic_add(2, &panic_done_count); | 515 | atomic_add(2, &panic_done_count); |
506 | } | 516 | } |
507 | 517 | ||
508 | static struct ipmi_smi_msg panic_halt_smi_msg = | 518 | static struct ipmi_smi_msg panic_halt_smi_msg = { |
509 | { | ||
510 | .done = panic_smi_free | 519 | .done = panic_smi_free |
511 | }; | 520 | }; |
512 | static struct ipmi_recv_msg panic_halt_recv_msg = | 521 | static struct ipmi_recv_msg panic_halt_recv_msg = { |
513 | { | ||
514 | .done = panic_recv_free | 522 | .done = panic_recv_free |
515 | }; | 523 | }; |
516 | 524 | ||
517 | /* Special call, doesn't claim any locks. This is only to be called | 525 | /* |
518 | at panic or halt time, in run-to-completion mode, when the caller | 526 | * Special call, doesn't claim any locks. This is only to be called |
519 | is the only CPU and the only thing that will be going is these IPMI | 527 | * at panic or halt time, in run-to-completion mode, when the caller |
520 | calls. */ | 528 | * is the only CPU and the only thing that will be going is these IPMI |
529 | * calls. | ||
530 | */ | ||
521 | static void panic_halt_ipmi_set_timeout(void) | 531 | static void panic_halt_ipmi_set_timeout(void) |
522 | { | 532 | { |
523 | int send_heartbeat_now; | 533 | int send_heartbeat_now; |
@@ -540,10 +550,12 @@ static void panic_halt_ipmi_set_timeout(void) | |||
540 | ipmi_poll_interface(watchdog_user); | 550 | ipmi_poll_interface(watchdog_user); |
541 | } | 551 | } |
542 | 552 | ||
543 | /* We use a semaphore to make sure that only one thing can send a | 553 | /* |
544 | heartbeat at one time, because we only have one copy of the data. | 554 | * We use a mutex to make sure that only one thing can send a |
545 | The semaphore is claimed when the set_timeout is sent and freed | 555 | * heartbeat at one time, because we only have one copy of the data. |
546 | when both messages are free. */ | 556 | * The semaphore is claimed when the set_timeout is sent and freed |
557 | * when both messages are free. | ||
558 | */ | ||
547 | static atomic_t heartbeat_tofree = ATOMIC_INIT(0); | 559 | static atomic_t heartbeat_tofree = ATOMIC_INIT(0); |
548 | static DEFINE_MUTEX(heartbeat_lock); | 560 | static DEFINE_MUTEX(heartbeat_lock); |
549 | static DECLARE_COMPLETION(heartbeat_wait); | 561 | static DECLARE_COMPLETION(heartbeat_wait); |
@@ -557,15 +569,13 @@ static void heartbeat_free_recv(struct ipmi_recv_msg *msg) | |||
557 | if (atomic_dec_and_test(&heartbeat_tofree)) | 569 | if (atomic_dec_and_test(&heartbeat_tofree)) |
558 | complete(&heartbeat_wait); | 570 | complete(&heartbeat_wait); |
559 | } | 571 | } |
560 | static struct ipmi_smi_msg heartbeat_smi_msg = | 572 | static struct ipmi_smi_msg heartbeat_smi_msg = { |
561 | { | ||
562 | .done = heartbeat_free_smi | 573 | .done = heartbeat_free_smi |
563 | }; | 574 | }; |
564 | static struct ipmi_recv_msg heartbeat_recv_msg = | 575 | static struct ipmi_recv_msg heartbeat_recv_msg = { |
565 | { | ||
566 | .done = heartbeat_free_recv | 576 | .done = heartbeat_free_recv |
567 | }; | 577 | }; |
568 | 578 | ||
569 | static int ipmi_heartbeat(void) | 579 | static int ipmi_heartbeat(void) |
570 | { | 580 | { |
571 | struct kernel_ipmi_msg msg; | 581 | struct kernel_ipmi_msg msg; |
@@ -580,10 +590,12 @@ static int ipmi_heartbeat(void) | |||
580 | ipmi_watchdog_state = action_val; | 590 | ipmi_watchdog_state = action_val; |
581 | return ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB); | 591 | return ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB); |
582 | } else if (pretimeout_since_last_heartbeat) { | 592 | } else if (pretimeout_since_last_heartbeat) { |
583 | /* A pretimeout occurred, make sure we set the timeout. | 593 | /* |
584 | We don't want to set the action, though, we want to | 594 | * A pretimeout occurred, make sure we set the timeout. |
585 | leave that alone (thus it can't be combined with the | 595 | * We don't want to set the action, though, we want to |
586 | above operation. */ | 596 | * leave that alone (thus it can't be combined with the |
597 | * above operation. | ||
598 | */ | ||
587 | return ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY); | 599 | return ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY); |
588 | } | 600 | } |
589 | 601 | ||
@@ -591,8 +603,10 @@ static int ipmi_heartbeat(void) | |||
591 | 603 | ||
592 | atomic_set(&heartbeat_tofree, 2); | 604 | atomic_set(&heartbeat_tofree, 2); |
593 | 605 | ||
594 | /* Don't reset the timer if we have the timer turned off, that | 606 | /* |
595 | re-enables the watchdog. */ | 607 | * Don't reset the timer if we have the timer turned off, that |
608 | * re-enables the watchdog. | ||
609 | */ | ||
596 | if (ipmi_watchdog_state == WDOG_TIMEOUT_NONE) { | 610 | if (ipmi_watchdog_state == WDOG_TIMEOUT_NONE) { |
597 | mutex_unlock(&heartbeat_lock); | 611 | mutex_unlock(&heartbeat_lock); |
598 | return 0; | 612 | return 0; |
@@ -625,10 +639,12 @@ static int ipmi_heartbeat(void) | |||
625 | wait_for_completion(&heartbeat_wait); | 639 | wait_for_completion(&heartbeat_wait); |
626 | 640 | ||
627 | if (heartbeat_recv_msg.msg.data[0] != 0) { | 641 | if (heartbeat_recv_msg.msg.data[0] != 0) { |
628 | /* Got an error in the heartbeat response. It was already | 642 | /* |
629 | reported in ipmi_wdog_msg_handler, but we should return | 643 | * Got an error in the heartbeat response. It was already |
630 | an error here. */ | 644 | * reported in ipmi_wdog_msg_handler, but we should return |
631 | rv = -EINVAL; | 645 | * an error here. |
646 | */ | ||
647 | rv = -EINVAL; | ||
632 | } | 648 | } |
633 | 649 | ||
634 | mutex_unlock(&heartbeat_lock); | 650 | mutex_unlock(&heartbeat_lock); |
@@ -636,8 +652,7 @@ static int ipmi_heartbeat(void) | |||
636 | return rv; | 652 | return rv; |
637 | } | 653 | } |
638 | 654 | ||
639 | static struct watchdog_info ident = | 655 | static struct watchdog_info ident = { |
640 | { | ||
641 | .options = 0, /* WDIOF_SETTIMEOUT, */ | 656 | .options = 0, /* WDIOF_SETTIMEOUT, */ |
642 | .firmware_version = 1, | 657 | .firmware_version = 1, |
643 | .identity = "IPMI" | 658 | .identity = "IPMI" |
@@ -650,7 +665,7 @@ static int ipmi_ioctl(struct inode *inode, struct file *file, | |||
650 | int i; | 665 | int i; |
651 | int val; | 666 | int val; |
652 | 667 | ||
653 | switch(cmd) { | 668 | switch (cmd) { |
654 | case WDIOC_GETSUPPORT: | 669 | case WDIOC_GETSUPPORT: |
655 | i = copy_to_user(argp, &ident, sizeof(ident)); | 670 | i = copy_to_user(argp, &ident, sizeof(ident)); |
656 | return i ? -EFAULT : 0; | 671 | return i ? -EFAULT : 0; |
@@ -690,15 +705,13 @@ static int ipmi_ioctl(struct inode *inode, struct file *file, | |||
690 | i = copy_from_user(&val, argp, sizeof(int)); | 705 | i = copy_from_user(&val, argp, sizeof(int)); |
691 | if (i) | 706 | if (i) |
692 | return -EFAULT; | 707 | return -EFAULT; |
693 | if (val & WDIOS_DISABLECARD) | 708 | if (val & WDIOS_DISABLECARD) { |
694 | { | ||
695 | ipmi_watchdog_state = WDOG_TIMEOUT_NONE; | 709 | ipmi_watchdog_state = WDOG_TIMEOUT_NONE; |
696 | ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB); | 710 | ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB); |
697 | ipmi_start_timer_on_heartbeat = 0; | 711 | ipmi_start_timer_on_heartbeat = 0; |
698 | } | 712 | } |
699 | 713 | ||
700 | if (val & WDIOS_ENABLECARD) | 714 | if (val & WDIOS_ENABLECARD) { |
701 | { | ||
702 | ipmi_watchdog_state = action_val; | 715 | ipmi_watchdog_state = action_val; |
703 | ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB); | 716 | ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB); |
704 | } | 717 | } |
@@ -724,13 +737,13 @@ static ssize_t ipmi_write(struct file *file, | |||
724 | int rv; | 737 | int rv; |
725 | 738 | ||
726 | if (len) { | 739 | if (len) { |
727 | if (!nowayout) { | 740 | if (!nowayout) { |
728 | size_t i; | 741 | size_t i; |
729 | 742 | ||
730 | /* In case it was set long ago */ | 743 | /* In case it was set long ago */ |
731 | expect_close = 0; | 744 | expect_close = 0; |
732 | 745 | ||
733 | for (i = 0; i != len; i++) { | 746 | for (i = 0; i != len; i++) { |
734 | char c; | 747 | char c; |
735 | 748 | ||
736 | if (get_user(c, buf + i)) | 749 | if (get_user(c, buf + i)) |
@@ -758,15 +771,17 @@ static ssize_t ipmi_read(struct file *file, | |||
758 | if (count <= 0) | 771 | if (count <= 0) |
759 | return 0; | 772 | return 0; |
760 | 773 | ||
761 | /* Reading returns if the pretimeout has gone off, and it only does | 774 | /* |
762 | it once per pretimeout. */ | 775 | * Reading returns if the pretimeout has gone off, and it only does |
776 | * it once per pretimeout. | ||
777 | */ | ||
763 | spin_lock(&ipmi_read_lock); | 778 | spin_lock(&ipmi_read_lock); |
764 | if (!data_to_read) { | 779 | if (!data_to_read) { |
765 | if (file->f_flags & O_NONBLOCK) { | 780 | if (file->f_flags & O_NONBLOCK) { |
766 | rv = -EAGAIN; | 781 | rv = -EAGAIN; |
767 | goto out; | 782 | goto out; |
768 | } | 783 | } |
769 | 784 | ||
770 | init_waitqueue_entry(&wait, current); | 785 | init_waitqueue_entry(&wait, current); |
771 | add_wait_queue(&read_q, &wait); | 786 | add_wait_queue(&read_q, &wait); |
772 | while (!data_to_read) { | 787 | while (!data_to_read) { |
@@ -776,7 +791,7 @@ static ssize_t ipmi_read(struct file *file, | |||
776 | spin_lock(&ipmi_read_lock); | 791 | spin_lock(&ipmi_read_lock); |
777 | } | 792 | } |
778 | remove_wait_queue(&read_q, &wait); | 793 | remove_wait_queue(&read_q, &wait); |
779 | 794 | ||
780 | if (signal_pending(current)) { | 795 | if (signal_pending(current)) { |
781 | rv = -ERESTARTSYS; | 796 | rv = -ERESTARTSYS; |
782 | goto out; | 797 | goto out; |
@@ -799,25 +814,27 @@ static ssize_t ipmi_read(struct file *file, | |||
799 | 814 | ||
800 | static int ipmi_open(struct inode *ino, struct file *filep) | 815 | static int ipmi_open(struct inode *ino, struct file *filep) |
801 | { | 816 | { |
802 | switch (iminor(ino)) { | 817 | switch (iminor(ino)) { |
803 | case WATCHDOG_MINOR: | 818 | case WATCHDOG_MINOR: |
804 | if (test_and_set_bit(0, &ipmi_wdog_open)) | 819 | if (test_and_set_bit(0, &ipmi_wdog_open)) |
805 | return -EBUSY; | 820 | return -EBUSY; |
806 | 821 | ||
807 | /* Don't start the timer now, let it start on the | 822 | /* |
808 | first heartbeat. */ | 823 | * Don't start the timer now, let it start on the |
824 | * first heartbeat. | ||
825 | */ | ||
809 | ipmi_start_timer_on_heartbeat = 1; | 826 | ipmi_start_timer_on_heartbeat = 1; |
810 | return nonseekable_open(ino, filep); | 827 | return nonseekable_open(ino, filep); |
811 | 828 | ||
812 | default: | 829 | default: |
813 | return (-ENODEV); | 830 | return (-ENODEV); |
814 | } | 831 | } |
815 | } | 832 | } |
816 | 833 | ||
817 | static unsigned int ipmi_poll(struct file *file, poll_table *wait) | 834 | static unsigned int ipmi_poll(struct file *file, poll_table *wait) |
818 | { | 835 | { |
819 | unsigned int mask = 0; | 836 | unsigned int mask = 0; |
820 | 837 | ||
821 | poll_wait(file, &read_q, wait); | 838 | poll_wait(file, &read_q, wait); |
822 | 839 | ||
823 | spin_lock(&ipmi_read_lock); | 840 | spin_lock(&ipmi_read_lock); |
@@ -851,7 +868,7 @@ static int ipmi_close(struct inode *ino, struct file *filep) | |||
851 | clear_bit(0, &ipmi_wdog_open); | 868 | clear_bit(0, &ipmi_wdog_open); |
852 | } | 869 | } |
853 | 870 | ||
854 | ipmi_fasync (-1, filep, 0); | 871 | ipmi_fasync(-1, filep, 0); |
855 | expect_close = 0; | 872 | expect_close = 0; |
856 | 873 | ||
857 | return 0; | 874 | return 0; |
@@ -882,7 +899,7 @@ static void ipmi_wdog_msg_handler(struct ipmi_recv_msg *msg, | |||
882 | msg->msg.data[0], | 899 | msg->msg.data[0], |
883 | msg->msg.cmd); | 900 | msg->msg.cmd); |
884 | } | 901 | } |
885 | 902 | ||
886 | ipmi_free_recv_msg(msg); | 903 | ipmi_free_recv_msg(msg); |
887 | } | 904 | } |
888 | 905 | ||
@@ -902,14 +919,14 @@ static void ipmi_wdog_pretimeout_handler(void *handler_data) | |||
902 | } | 919 | } |
903 | } | 920 | } |
904 | 921 | ||
905 | /* On some machines, the heartbeat will give | 922 | /* |
906 | an error and not work unless we re-enable | 923 | * On some machines, the heartbeat will give an error and not |
907 | the timer. So do so. */ | 924 | * work unless we re-enable the timer. So do so. |
925 | */ | ||
908 | pretimeout_since_last_heartbeat = 1; | 926 | pretimeout_since_last_heartbeat = 1; |
909 | } | 927 | } |
910 | 928 | ||
911 | static struct ipmi_user_hndl ipmi_hndlrs = | 929 | static struct ipmi_user_hndl ipmi_hndlrs = { |
912 | { | ||
913 | .ipmi_recv_hndl = ipmi_wdog_msg_handler, | 930 | .ipmi_recv_hndl = ipmi_wdog_msg_handler, |
914 | .ipmi_watchdog_pretimeout = ipmi_wdog_pretimeout_handler | 931 | .ipmi_watchdog_pretimeout = ipmi_wdog_pretimeout_handler |
915 | }; | 932 | }; |
@@ -949,8 +966,10 @@ static void ipmi_register_watchdog(int ipmi_intf) | |||
949 | int old_timeout = timeout; | 966 | int old_timeout = timeout; |
950 | int old_preop_val = preop_val; | 967 | int old_preop_val = preop_val; |
951 | 968 | ||
952 | /* Set the pretimeout to go off in a second and give | 969 | /* |
953 | ourselves plenty of time to stop the timer. */ | 970 | * Set the pretimeout to go off in a second and give |
971 | * ourselves plenty of time to stop the timer. | ||
972 | */ | ||
954 | ipmi_watchdog_state = WDOG_TIMEOUT_RESET; | 973 | ipmi_watchdog_state = WDOG_TIMEOUT_RESET; |
955 | preop_val = WDOG_PREOP_NONE; /* Make sure nothing happens */ | 974 | preop_val = WDOG_PREOP_NONE; /* Make sure nothing happens */ |
956 | pretimeout = 99; | 975 | pretimeout = 99; |
@@ -974,7 +993,7 @@ static void ipmi_register_watchdog(int ipmi_intf) | |||
974 | " occur. The NMI pretimeout will" | 993 | " occur. The NMI pretimeout will" |
975 | " likely not work\n"); | 994 | " likely not work\n"); |
976 | } | 995 | } |
977 | out_restore: | 996 | out_restore: |
978 | testing_nmi = 0; | 997 | testing_nmi = 0; |
979 | preop_val = old_preop_val; | 998 | preop_val = old_preop_val; |
980 | pretimeout = old_pretimeout; | 999 | pretimeout = old_pretimeout; |
@@ -1009,9 +1028,11 @@ static void ipmi_unregister_watchdog(int ipmi_intf) | |||
1009 | /* Make sure no one can call us any more. */ | 1028 | /* Make sure no one can call us any more. */ |
1010 | misc_deregister(&ipmi_wdog_miscdev); | 1029 | misc_deregister(&ipmi_wdog_miscdev); |
1011 | 1030 | ||
1012 | /* Wait to make sure the message makes it out. The lower layer has | 1031 | /* |
1013 | pointers to our buffers, we want to make sure they are done before | 1032 | * Wait to make sure the message makes it out. The lower layer has |
1014 | we release our memory. */ | 1033 | * pointers to our buffers, we want to make sure they are done before |
1034 | * we release our memory. | ||
1035 | */ | ||
1015 | while (atomic_read(&set_timeout_tofree)) | 1036 | while (atomic_read(&set_timeout_tofree)) |
1016 | schedule_timeout_uninterruptible(1); | 1037 | schedule_timeout_uninterruptible(1); |
1017 | 1038 | ||
@@ -1052,15 +1073,17 @@ ipmi_nmi(struct notifier_block *self, unsigned long val, void *data) | |||
1052 | return NOTIFY_STOP; | 1073 | return NOTIFY_STOP; |
1053 | } | 1074 | } |
1054 | 1075 | ||
1055 | /* If we are not expecting a timeout, ignore it. */ | 1076 | /* If we are not expecting a timeout, ignore it. */ |
1056 | if (ipmi_watchdog_state == WDOG_TIMEOUT_NONE) | 1077 | if (ipmi_watchdog_state == WDOG_TIMEOUT_NONE) |
1057 | return NOTIFY_OK; | 1078 | return NOTIFY_OK; |
1058 | 1079 | ||
1059 | if (preaction_val != WDOG_PRETIMEOUT_NMI) | 1080 | if (preaction_val != WDOG_PRETIMEOUT_NMI) |
1060 | return NOTIFY_OK; | 1081 | return NOTIFY_OK; |
1061 | 1082 | ||
1062 | /* If no one else handled the NMI, we assume it was the IPMI | 1083 | /* |
1063 | watchdog. */ | 1084 | * If no one else handled the NMI, we assume it was the IPMI |
1085 | * watchdog. | ||
1086 | */ | ||
1064 | if (preop_val == WDOG_PREOP_PANIC) { | 1087 | if (preop_val == WDOG_PREOP_PANIC) { |
1065 | /* On some machines, the heartbeat will give | 1088 | /* On some machines, the heartbeat will give |
1066 | an error and not work unless we re-enable | 1089 | an error and not work unless we re-enable |
@@ -1082,7 +1105,7 @@ static int wdog_reboot_handler(struct notifier_block *this, | |||
1082 | unsigned long code, | 1105 | unsigned long code, |
1083 | void *unused) | 1106 | void *unused) |
1084 | { | 1107 | { |
1085 | static int reboot_event_handled = 0; | 1108 | static int reboot_event_handled; |
1086 | 1109 | ||
1087 | if ((watchdog_user) && (!reboot_event_handled)) { | 1110 | if ((watchdog_user) && (!reboot_event_handled)) { |
1088 | /* Make sure we only do this once. */ | 1111 | /* Make sure we only do this once. */ |
@@ -1115,7 +1138,7 @@ static int wdog_panic_handler(struct notifier_block *this, | |||
1115 | unsigned long event, | 1138 | unsigned long event, |
1116 | void *unused) | 1139 | void *unused) |
1117 | { | 1140 | { |
1118 | static int panic_event_handled = 0; | 1141 | static int panic_event_handled; |
1119 | 1142 | ||
1120 | /* On a panic, if we have a panic timeout, make sure to extend | 1143 | /* On a panic, if we have a panic timeout, make sure to extend |
1121 | the watchdog timer to a reasonable value to complete the | 1144 | the watchdog timer to a reasonable value to complete the |
@@ -1125,7 +1148,7 @@ static int wdog_panic_handler(struct notifier_block *this, | |||
1125 | ipmi_watchdog_state != WDOG_TIMEOUT_NONE) { | 1148 | ipmi_watchdog_state != WDOG_TIMEOUT_NONE) { |
1126 | /* Make sure we do this only once. */ | 1149 | /* Make sure we do this only once. */ |
1127 | panic_event_handled = 1; | 1150 | panic_event_handled = 1; |
1128 | 1151 | ||
1129 | timeout = 255; | 1152 | timeout = 255; |
1130 | pretimeout = 0; | 1153 | pretimeout = 0; |
1131 | panic_halt_ipmi_set_timeout(); | 1154 | panic_halt_ipmi_set_timeout(); |
@@ -1151,8 +1174,7 @@ static void ipmi_smi_gone(int if_num) | |||
1151 | ipmi_unregister_watchdog(if_num); | 1174 | ipmi_unregister_watchdog(if_num); |
1152 | } | 1175 | } |
1153 | 1176 | ||
1154 | static struct ipmi_smi_watcher smi_watcher = | 1177 | static struct ipmi_smi_watcher smi_watcher = { |
1155 | { | ||
1156 | .owner = THIS_MODULE, | 1178 | .owner = THIS_MODULE, |
1157 | .new_smi = ipmi_new_smi, | 1179 | .new_smi = ipmi_new_smi, |
1158 | .smi_gone = ipmi_smi_gone | 1180 | .smi_gone = ipmi_smi_gone |