aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-11-19 21:14:47 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-11-19 21:14:47 -0500
commitcd6caf550a2adc763c6301ecc0be01f422fb2aea (patch)
treec627d3f3826892d2aefc8ec494ca6133521b7595
parent8bdddfae6590ecbc4a48e1a5b93386d6b8956fe5 (diff)
parentc7f42c63901b964833eb23a9bda873b799e7f308 (diff)
Merge tag 'for-linus-4.4' of git://git.code.sf.net/p/openipmi/linux-ipmi
Pull IPMI updates from Corey Minyard: "Some fixes for small IPMI problems. The most significant is that the driver wasn't starting the timer for some messages, which would result in problems if that message failed for some reason. The others are small optimizations or making things a little neater" * tag 'for-linus-4.4' of git://git.code.sf.net/p/openipmi/linux-ipmi: ipmi watchdog : add panic_wdt_timeout parameter char: ipmi: Move MODULE_DEVICE_TABLE() to follow struct ipmi: Stop the timer immediately if idle ipmi: Start the timer and thread on internal msgs
-rw-r--r--Documentation/IPMI.txt7
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c82
-rw-r--r--drivers/char/ipmi/ipmi_watchdog.c8
3 files changed, 64 insertions, 33 deletions
diff --git a/Documentation/IPMI.txt b/Documentation/IPMI.txt
index 31d1d658827f..c0d8788e75d3 100644
--- a/Documentation/IPMI.txt
+++ b/Documentation/IPMI.txt
@@ -587,7 +587,7 @@ used to control it:
587 587
588 modprobe ipmi_watchdog timeout=<t> pretimeout=<t> action=<action type> 588 modprobe ipmi_watchdog timeout=<t> pretimeout=<t> action=<action type>
589 preaction=<preaction type> preop=<preop type> start_now=x 589 preaction=<preaction type> preop=<preop type> start_now=x
590 nowayout=x ifnum_to_use=n 590 nowayout=x ifnum_to_use=n panic_wdt_timeout=<t>
591 591
592ifnum_to_use specifies which interface the watchdog timer should use. 592ifnum_to_use specifies which interface the watchdog timer should use.
593The default is -1, which means to pick the first one registered. 593The default is -1, which means to pick the first one registered.
@@ -597,7 +597,9 @@ is the amount of seconds before the reset that the pre-timeout panic will
597occur (if pretimeout is zero, then pretimeout will not be enabled). Note 597occur (if pretimeout is zero, then pretimeout will not be enabled). Note
598that the pretimeout is the time before the final timeout. So if the 598that the pretimeout is the time before the final timeout. So if the
599timeout is 50 seconds and the pretimeout is 10 seconds, then the pretimeout 599timeout is 50 seconds and the pretimeout is 10 seconds, then the pretimeout
600will occur in 40 second (10 seconds before the timeout). 600will occur in 40 second (10 seconds before the timeout). The panic_wdt_timeout
601is the value of timeout which is set on kernel panic, in order to let actions
602such as kdump to occur during panic.
601 603
602The action may be "reset", "power_cycle", or "power_off", and 604The action may be "reset", "power_cycle", or "power_off", and
603specifies what to do when the timer times out, and defaults to 605specifies what to do when the timer times out, and defaults to
@@ -634,6 +636,7 @@ for configuring the watchdog:
634 ipmi_watchdog.preop=<preop type> 636 ipmi_watchdog.preop=<preop type>
635 ipmi_watchdog.start_now=x 637 ipmi_watchdog.start_now=x
636 ipmi_watchdog.nowayout=x 638 ipmi_watchdog.nowayout=x
639 ipmi_watchdog.panic_wdt_timeout=<t>
637 640
638The options are the same as the module parameter options. 641The options are the same as the module parameter options.
639 642
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 654f6f36a071..55fe9020459f 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -412,18 +412,42 @@ static enum si_sm_result start_next_msg(struct smi_info *smi_info)
412 return rv; 412 return rv;
413} 413}
414 414
415static void start_check_enables(struct smi_info *smi_info) 415static void smi_mod_timer(struct smi_info *smi_info, unsigned long new_val)
416{
417 smi_info->last_timeout_jiffies = jiffies;
418 mod_timer(&smi_info->si_timer, new_val);
419 smi_info->timer_running = true;
420}
421
422/*
423 * Start a new message and (re)start the timer and thread.
424 */
425static void start_new_msg(struct smi_info *smi_info, unsigned char *msg,
426 unsigned int size)
427{
428 smi_mod_timer(smi_info, jiffies + SI_TIMEOUT_JIFFIES);
429
430 if (smi_info->thread)
431 wake_up_process(smi_info->thread);
432
433 smi_info->handlers->start_transaction(smi_info->si_sm, msg, size);
434}
435
436static void start_check_enables(struct smi_info *smi_info, bool start_timer)
416{ 437{
417 unsigned char msg[2]; 438 unsigned char msg[2];
418 439
419 msg[0] = (IPMI_NETFN_APP_REQUEST << 2); 440 msg[0] = (IPMI_NETFN_APP_REQUEST << 2);
420 msg[1] = IPMI_GET_BMC_GLOBAL_ENABLES_CMD; 441 msg[1] = IPMI_GET_BMC_GLOBAL_ENABLES_CMD;
421 442
422 smi_info->handlers->start_transaction(smi_info->si_sm, msg, 2); 443 if (start_timer)
444 start_new_msg(smi_info, msg, 2);
445 else
446 smi_info->handlers->start_transaction(smi_info->si_sm, msg, 2);
423 smi_info->si_state = SI_CHECKING_ENABLES; 447 smi_info->si_state = SI_CHECKING_ENABLES;
424} 448}
425 449
426static void start_clear_flags(struct smi_info *smi_info) 450static void start_clear_flags(struct smi_info *smi_info, bool start_timer)
427{ 451{
428 unsigned char msg[3]; 452 unsigned char msg[3];
429 453
@@ -432,7 +456,10 @@ static void start_clear_flags(struct smi_info *smi_info)
432 msg[1] = IPMI_CLEAR_MSG_FLAGS_CMD; 456 msg[1] = IPMI_CLEAR_MSG_FLAGS_CMD;
433 msg[2] = WDT_PRE_TIMEOUT_INT; 457 msg[2] = WDT_PRE_TIMEOUT_INT;
434 458
435 smi_info->handlers->start_transaction(smi_info->si_sm, msg, 3); 459 if (start_timer)
460 start_new_msg(smi_info, msg, 3);
461 else
462 smi_info->handlers->start_transaction(smi_info->si_sm, msg, 3);
436 smi_info->si_state = SI_CLEARING_FLAGS; 463 smi_info->si_state = SI_CLEARING_FLAGS;
437} 464}
438 465
@@ -442,10 +469,8 @@ static void start_getting_msg_queue(struct smi_info *smi_info)
442 smi_info->curr_msg->data[1] = IPMI_GET_MSG_CMD; 469 smi_info->curr_msg->data[1] = IPMI_GET_MSG_CMD;
443 smi_info->curr_msg->data_size = 2; 470 smi_info->curr_msg->data_size = 2;
444 471
445 smi_info->handlers->start_transaction( 472 start_new_msg(smi_info, smi_info->curr_msg->data,
446 smi_info->si_sm, 473 smi_info->curr_msg->data_size);
447 smi_info->curr_msg->data,
448 smi_info->curr_msg->data_size);
449 smi_info->si_state = SI_GETTING_MESSAGES; 474 smi_info->si_state = SI_GETTING_MESSAGES;
450} 475}
451 476
@@ -455,20 +480,11 @@ static void start_getting_events(struct smi_info *smi_info)
455 smi_info->curr_msg->data[1] = IPMI_READ_EVENT_MSG_BUFFER_CMD; 480 smi_info->curr_msg->data[1] = IPMI_READ_EVENT_MSG_BUFFER_CMD;
456 smi_info->curr_msg->data_size = 2; 481 smi_info->curr_msg->data_size = 2;
457 482
458 smi_info->handlers->start_transaction( 483 start_new_msg(smi_info, smi_info->curr_msg->data,
459 smi_info->si_sm, 484 smi_info->curr_msg->data_size);
460 smi_info->curr_msg->data,
461 smi_info->curr_msg->data_size);
462 smi_info->si_state = SI_GETTING_EVENTS; 485 smi_info->si_state = SI_GETTING_EVENTS;
463} 486}
464 487
465static void smi_mod_timer(struct smi_info *smi_info, unsigned long new_val)
466{
467 smi_info->last_timeout_jiffies = jiffies;
468 mod_timer(&smi_info->si_timer, new_val);
469 smi_info->timer_running = true;
470}
471
472/* 488/*
473 * When we have a situtaion where we run out of memory and cannot 489 * When we have a situtaion where we run out of memory and cannot
474 * allocate messages, we just leave them in the BMC and run the system 490 * allocate messages, we just leave them in the BMC and run the system
@@ -478,11 +494,11 @@ static void smi_mod_timer(struct smi_info *smi_info, unsigned long new_val)
478 * Note that we cannot just use disable_irq(), since the interrupt may 494 * Note that we cannot just use disable_irq(), since the interrupt may
479 * be shared. 495 * be shared.
480 */ 496 */
481static inline bool disable_si_irq(struct smi_info *smi_info) 497static inline bool disable_si_irq(struct smi_info *smi_info, bool start_timer)
482{ 498{
483 if ((smi_info->irq) && (!smi_info->interrupt_disabled)) { 499 if ((smi_info->irq) && (!smi_info->interrupt_disabled)) {
484 smi_info->interrupt_disabled = true; 500 smi_info->interrupt_disabled = true;
485 start_check_enables(smi_info); 501 start_check_enables(smi_info, start_timer);
486 return true; 502 return true;
487 } 503 }
488 return false; 504 return false;
@@ -492,7 +508,7 @@ static inline bool enable_si_irq(struct smi_info *smi_info)
492{ 508{
493 if ((smi_info->irq) && (smi_info->interrupt_disabled)) { 509 if ((smi_info->irq) && (smi_info->interrupt_disabled)) {
494 smi_info->interrupt_disabled = false; 510 smi_info->interrupt_disabled = false;
495 start_check_enables(smi_info); 511 start_check_enables(smi_info, true);
496 return true; 512 return true;
497 } 513 }
498 return false; 514 return false;
@@ -510,7 +526,7 @@ static struct ipmi_smi_msg *alloc_msg_handle_irq(struct smi_info *smi_info)
510 526
511 msg = ipmi_alloc_smi_msg(); 527 msg = ipmi_alloc_smi_msg();
512 if (!msg) { 528 if (!msg) {
513 if (!disable_si_irq(smi_info)) 529 if (!disable_si_irq(smi_info, true))
514 smi_info->si_state = SI_NORMAL; 530 smi_info->si_state = SI_NORMAL;
515 } else if (enable_si_irq(smi_info)) { 531 } else if (enable_si_irq(smi_info)) {
516 ipmi_free_smi_msg(msg); 532 ipmi_free_smi_msg(msg);
@@ -526,7 +542,7 @@ static void handle_flags(struct smi_info *smi_info)
526 /* Watchdog pre-timeout */ 542 /* Watchdog pre-timeout */
527 smi_inc_stat(smi_info, watchdog_pretimeouts); 543 smi_inc_stat(smi_info, watchdog_pretimeouts);
528 544
529 start_clear_flags(smi_info); 545 start_clear_flags(smi_info, true);
530 smi_info->msg_flags &= ~WDT_PRE_TIMEOUT_INT; 546 smi_info->msg_flags &= ~WDT_PRE_TIMEOUT_INT;
531 if (smi_info->intf) 547 if (smi_info->intf)
532 ipmi_smi_watchdog_pretimeout(smi_info->intf); 548 ipmi_smi_watchdog_pretimeout(smi_info->intf);
@@ -879,8 +895,7 @@ static enum si_sm_result smi_event_handler(struct smi_info *smi_info,
879 msg[0] = (IPMI_NETFN_APP_REQUEST << 2); 895 msg[0] = (IPMI_NETFN_APP_REQUEST << 2);
880 msg[1] = IPMI_GET_MSG_FLAGS_CMD; 896 msg[1] = IPMI_GET_MSG_FLAGS_CMD;
881 897
882 smi_info->handlers->start_transaction( 898 start_new_msg(smi_info, msg, 2);
883 smi_info->si_sm, msg, 2);
884 smi_info->si_state = SI_GETTING_FLAGS; 899 smi_info->si_state = SI_GETTING_FLAGS;
885 goto restart; 900 goto restart;
886 } 901 }
@@ -910,7 +925,7 @@ static enum si_sm_result smi_event_handler(struct smi_info *smi_info,
910 * disable and messages disabled. 925 * disable and messages disabled.
911 */ 926 */
912 if (smi_info->supports_event_msg_buff || smi_info->irq) { 927 if (smi_info->supports_event_msg_buff || smi_info->irq) {
913 start_check_enables(smi_info); 928 start_check_enables(smi_info, true);
914 } else { 929 } else {
915 smi_info->curr_msg = alloc_msg_handle_irq(smi_info); 930 smi_info->curr_msg = alloc_msg_handle_irq(smi_info);
916 if (!smi_info->curr_msg) 931 if (!smi_info->curr_msg)
@@ -920,6 +935,13 @@ static enum si_sm_result smi_event_handler(struct smi_info *smi_info,
920 } 935 }
921 goto restart; 936 goto restart;
922 } 937 }
938
939 if (si_sm_result == SI_SM_IDLE && smi_info->timer_running) {
940 /* Ok it if fails, the timer will just go off. */
941 if (del_timer(&smi_info->si_timer))
942 smi_info->timer_running = false;
943 }
944
923 out: 945 out:
924 return si_sm_result; 946 return si_sm_result;
925} 947}
@@ -2560,6 +2582,7 @@ static const struct of_device_id of_ipmi_match[] = {
2560 .data = (void *)(unsigned long) SI_BT }, 2582 .data = (void *)(unsigned long) SI_BT },
2561 {}, 2583 {},
2562}; 2584};
2585MODULE_DEVICE_TABLE(of, of_ipmi_match);
2563 2586
2564static int of_ipmi_probe(struct platform_device *dev) 2587static int of_ipmi_probe(struct platform_device *dev)
2565{ 2588{
@@ -2646,7 +2669,6 @@ static int of_ipmi_probe(struct platform_device *dev)
2646 } 2669 }
2647 return 0; 2670 return 0;
2648} 2671}
2649MODULE_DEVICE_TABLE(of, of_ipmi_match);
2650#else 2672#else
2651#define of_ipmi_match NULL 2673#define of_ipmi_match NULL
2652static int of_ipmi_probe(struct platform_device *dev) 2674static int of_ipmi_probe(struct platform_device *dev)
@@ -3613,7 +3635,7 @@ static int try_smi_init(struct smi_info *new_smi)
3613 * Start clearing the flags before we enable interrupts or the 3635 * Start clearing the flags before we enable interrupts or the
3614 * timer to avoid racing with the timer. 3636 * timer to avoid racing with the timer.
3615 */ 3637 */
3616 start_clear_flags(new_smi); 3638 start_clear_flags(new_smi, false);
3617 3639
3618 /* 3640 /*
3619 * IRQ is defined to be set when non-zero. req_events will 3641 * IRQ is defined to be set when non-zero. req_events will
@@ -3908,7 +3930,7 @@ static void cleanup_one_si(struct smi_info *to_clean)
3908 poll(to_clean); 3930 poll(to_clean);
3909 schedule_timeout_uninterruptible(1); 3931 schedule_timeout_uninterruptible(1);
3910 } 3932 }
3911 disable_si_irq(to_clean); 3933 disable_si_irq(to_clean, false);
3912 while (to_clean->curr_msg || (to_clean->si_state != SI_NORMAL)) { 3934 while (to_clean->curr_msg || (to_clean->si_state != SI_NORMAL)) {
3913 poll(to_clean); 3935 poll(to_clean);
3914 schedule_timeout_uninterruptible(1); 3936 schedule_timeout_uninterruptible(1);
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index 0ac3bd1a5497..096f0cef4da1 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -153,6 +153,9 @@ static int timeout = 10;
153/* The pre-timeout is disabled by default. */ 153/* The pre-timeout is disabled by default. */
154static int pretimeout; 154static int pretimeout;
155 155
156/* Default timeout to set on panic */
157static int panic_wdt_timeout = 255;
158
156/* Default action is to reset the board on a timeout. */ 159/* Default action is to reset the board on a timeout. */
157static unsigned char action_val = WDOG_TIMEOUT_RESET; 160static unsigned char action_val = WDOG_TIMEOUT_RESET;
158 161
@@ -293,6 +296,9 @@ MODULE_PARM_DESC(timeout, "Timeout value in seconds.");
293module_param(pretimeout, timeout, 0644); 296module_param(pretimeout, timeout, 0644);
294MODULE_PARM_DESC(pretimeout, "Pretimeout value in seconds."); 297MODULE_PARM_DESC(pretimeout, "Pretimeout value in seconds.");
295 298
299module_param(panic_wdt_timeout, timeout, 0644);
300MODULE_PARM_DESC(timeout, "Timeout value on kernel panic in seconds.");
301
296module_param_cb(action, &param_ops_str, action_op, 0644); 302module_param_cb(action, &param_ops_str, action_op, 0644);
297MODULE_PARM_DESC(action, "Timeout action. One of: " 303MODULE_PARM_DESC(action, "Timeout action. One of: "
298 "reset, none, power_cycle, power_off."); 304 "reset, none, power_cycle, power_off.");
@@ -1189,7 +1195,7 @@ static int wdog_panic_handler(struct notifier_block *this,
1189 /* Make sure we do this only once. */ 1195 /* Make sure we do this only once. */
1190 panic_event_handled = 1; 1196 panic_event_handled = 1;
1191 1197
1192 timeout = 255; 1198 timeout = panic_wdt_timeout;
1193 pretimeout = 0; 1199 pretimeout = 0;
1194 panic_halt_ipmi_set_timeout(); 1200 panic_halt_ipmi_set_timeout();
1195 } 1201 }