Lines Matching +full:ipmi +full:- +full:ipmb
1 // SPDX-License-Identifier: GPL-2.0+
5 * The interface to the IPMI driver for the system interfaces (KCS, SMIC,
40 #include <linux/ipmi.h>
65 /* FIXME - add watchdog stuff. */
68 /* Some BT-specific defines we need here. */
73 /* 'invalid' to allow a firmware-specified interface to be disabled */
112 /* Number of IPMI events received from the hardware. */
138 * IPMI
143 * Per-OEM handler, called from handle_flags(). Returns 1
144 * when handle_flags() needs to be re-run or 0 indicating it
199 * memory. Once that situation clears up, it will re-enable
249 atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
251 ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
272 dev_dbg(smi_info->io.dev, "**%s: %lld.%9.9ld\n", in debug_timestamp()
289 ipmi_smi_msg_received(smi_info->intf, msg); in deliver_recv_msg()
294 struct ipmi_smi_msg *msg = smi_info->curr_msg; in return_hosed_msg()
301 msg->rsp[0] = msg->data[0] | 4; in return_hosed_msg()
302 msg->rsp[1] = msg->data[1]; in return_hosed_msg()
303 msg->rsp[2] = cCode; in return_hosed_msg()
304 msg->rsp_size = 3; in return_hosed_msg()
306 smi_info->curr_msg = NULL; in return_hosed_msg()
314 if (!smi_info->waiting_msg) { in start_next_msg()
315 smi_info->curr_msg = NULL; in start_next_msg()
320 smi_info->curr_msg = smi_info->waiting_msg; in start_next_msg()
321 smi_info->waiting_msg = NULL; in start_next_msg()
329 err = smi_info->handlers->start_transaction( in start_next_msg()
330 smi_info->si_sm, in start_next_msg()
331 smi_info->curr_msg->data, in start_next_msg()
332 smi_info->curr_msg->data_size); in start_next_msg()
344 if (!smi_info->timer_can_start) in smi_mod_timer()
346 smi_info->last_timeout_jiffies = jiffies; in smi_mod_timer()
347 mod_timer(&smi_info->si_timer, new_val); in smi_mod_timer()
348 smi_info->timer_running = true; in smi_mod_timer()
359 if (smi_info->thread) in start_new_msg()
360 wake_up_process(smi_info->thread); in start_new_msg()
362 smi_info->handlers->start_transaction(smi_info->si_sm, msg, size); in start_new_msg()
373 smi_info->si_state = SI_CHECKING_ENABLES; in start_check_enables()
380 /* Make sure the watchdog pre-timeout flag is not set at startup. */ in start_clear_flags()
386 smi_info->si_state = SI_CLEARING_FLAGS; in start_clear_flags()
391 smi_info->curr_msg->data[0] = (IPMI_NETFN_APP_REQUEST << 2); in start_getting_msg_queue()
392 smi_info->curr_msg->data[1] = IPMI_GET_MSG_CMD; in start_getting_msg_queue()
393 smi_info->curr_msg->data_size = 2; in start_getting_msg_queue()
395 start_new_msg(smi_info, smi_info->curr_msg->data, in start_getting_msg_queue()
396 smi_info->curr_msg->data_size); in start_getting_msg_queue()
397 smi_info->si_state = SI_GETTING_MESSAGES; in start_getting_msg_queue()
402 smi_info->curr_msg->data[0] = (IPMI_NETFN_APP_REQUEST << 2); in start_getting_events()
403 smi_info->curr_msg->data[1] = IPMI_READ_EVENT_MSG_BUFFER_CMD; in start_getting_events()
404 smi_info->curr_msg->data_size = 2; in start_getting_events()
406 start_new_msg(smi_info, smi_info->curr_msg->data, in start_getting_events()
407 smi_info->curr_msg->data_size); in start_getting_events()
408 smi_info->si_state = SI_GETTING_EVENTS; in start_getting_events()
415 * memory, we will re-enable the interrupt.
422 if ((smi_info->io.irq) && (!smi_info->interrupt_disabled)) { in disable_si_irq()
423 smi_info->interrupt_disabled = true; in disable_si_irq()
432 if ((smi_info->io.irq) && (smi_info->interrupt_disabled)) { in enable_si_irq()
433 smi_info->interrupt_disabled = false; in enable_si_irq()
453 smi_info->si_state = SI_NORMAL; in alloc_msg_handle_irq()
464 if (smi_info->msg_flags & WDT_PRE_TIMEOUT_INT) { in handle_flags()
465 /* Watchdog pre-timeout */ in handle_flags()
469 smi_info->msg_flags &= ~WDT_PRE_TIMEOUT_INT; in handle_flags()
470 ipmi_smi_watchdog_pretimeout(smi_info->intf); in handle_flags()
471 } else if (smi_info->msg_flags & RECEIVE_MSG_AVAIL) { in handle_flags()
473 smi_info->curr_msg = alloc_msg_handle_irq(smi_info); in handle_flags()
474 if (!smi_info->curr_msg) in handle_flags()
478 } else if (smi_info->msg_flags & EVENT_MSG_BUFFER_FULL) { in handle_flags()
480 smi_info->curr_msg = alloc_msg_handle_irq(smi_info); in handle_flags()
481 if (!smi_info->curr_msg) in handle_flags()
485 } else if (smi_info->msg_flags & OEM_DATA_AVAIL && in handle_flags()
486 smi_info->oem_data_avail_handler) { in handle_flags()
487 if (smi_info->oem_data_avail_handler(smi_info)) in handle_flags()
490 smi_info->si_state = SI_NORMAL; in handle_flags()
504 if (smi_info->supports_event_msg_buff) in current_global_enables()
507 if (((smi_info->io.irq && !smi_info->interrupt_disabled) || in current_global_enables()
508 smi_info->cannot_disable_irq) && in current_global_enables()
509 !smi_info->irq_enable_broken) in current_global_enables()
512 if (smi_info->supports_event_msg_buff && in current_global_enables()
513 smi_info->io.irq && !smi_info->interrupt_disabled && in current_global_enables()
514 !smi_info->irq_enable_broken) in current_global_enables()
524 u8 irqstate = smi_info->io.inputb(&smi_info->io, IPMI_BT_INTMASK_REG); in check_bt_irq()
532 smi_info->io.outputb(&smi_info->io, IPMI_BT_INTMASK_REG, in check_bt_irq()
535 smi_info->io.outputb(&smi_info->io, IPMI_BT_INTMASK_REG, 0); in check_bt_irq()
543 switch (smi_info->si_state) { in handle_transaction_done()
545 if (!smi_info->curr_msg) in handle_transaction_done()
548 smi_info->curr_msg->rsp_size in handle_transaction_done()
549 = smi_info->handlers->get_result( in handle_transaction_done()
550 smi_info->si_sm, in handle_transaction_done()
551 smi_info->curr_msg->rsp, in handle_transaction_done()
559 msg = smi_info->curr_msg; in handle_transaction_done()
560 smi_info->curr_msg = NULL; in handle_transaction_done()
570 len = smi_info->handlers->get_result(smi_info->si_sm, msg, 4); in handle_transaction_done()
573 smi_info->si_state = SI_NORMAL; in handle_transaction_done()
579 smi_info->si_state = SI_NORMAL; in handle_transaction_done()
581 smi_info->msg_flags = msg[3]; in handle_transaction_done()
592 smi_info->handlers->get_result(smi_info->si_sm, msg, 3); in handle_transaction_done()
595 dev_warn_ratelimited(smi_info->io.dev, in handle_transaction_done()
598 smi_info->si_state = SI_NORMAL; in handle_transaction_done()
604 smi_info->curr_msg->rsp_size in handle_transaction_done()
605 = smi_info->handlers->get_result( in handle_transaction_done()
606 smi_info->si_sm, in handle_transaction_done()
607 smi_info->curr_msg->rsp, in handle_transaction_done()
615 msg = smi_info->curr_msg; in handle_transaction_done()
616 smi_info->curr_msg = NULL; in handle_transaction_done()
617 if (msg->rsp[2] != 0) { in handle_transaction_done()
619 msg->done(msg); in handle_transaction_done()
622 smi_info->msg_flags &= ~EVENT_MSG_BUFFER_FULL; in handle_transaction_done()
642 smi_info->curr_msg->rsp_size in handle_transaction_done()
643 = smi_info->handlers->get_result( in handle_transaction_done()
644 smi_info->si_sm, in handle_transaction_done()
645 smi_info->curr_msg->rsp, in handle_transaction_done()
653 msg = smi_info->curr_msg; in handle_transaction_done()
654 smi_info->curr_msg = NULL; in handle_transaction_done()
655 if (msg->rsp[2] != 0) { in handle_transaction_done()
657 msg->done(msg); in handle_transaction_done()
660 smi_info->msg_flags &= ~RECEIVE_MSG_AVAIL; in handle_transaction_done()
685 smi_info->handlers->get_result(smi_info->si_sm, msg, 4); in handle_transaction_done()
687 dev_warn_ratelimited(smi_info->io.dev, in handle_transaction_done()
689 "Maybe ok, but ipmi might run very slowly.\n", in handle_transaction_done()
691 smi_info->si_state = SI_NORMAL; in handle_transaction_done()
695 if (smi_info->io.si_type == SI_BT) in handle_transaction_done()
703 smi_info->handlers->start_transaction( in handle_transaction_done()
704 smi_info->si_sm, msg, 3); in handle_transaction_done()
705 smi_info->si_state = SI_SETTING_ENABLES; in handle_transaction_done()
706 } else if (smi_info->supports_event_msg_buff) { in handle_transaction_done()
707 smi_info->curr_msg = ipmi_alloc_smi_msg(); in handle_transaction_done()
708 if (!smi_info->curr_msg) { in handle_transaction_done()
709 smi_info->si_state = SI_NORMAL; in handle_transaction_done()
714 smi_info->si_state = SI_NORMAL; in handle_transaction_done()
723 smi_info->handlers->get_result(smi_info->si_sm, msg, 4); in handle_transaction_done()
725 dev_warn_ratelimited(smi_info->io.dev, in handle_transaction_done()
729 if (smi_info->supports_event_msg_buff) { in handle_transaction_done()
730 smi_info->curr_msg = ipmi_alloc_smi_msg(); in handle_transaction_done()
731 if (!smi_info->curr_msg) { in handle_transaction_done()
732 smi_info->si_state = SI_NORMAL; in handle_transaction_done()
737 smi_info->si_state = SI_NORMAL; in handle_transaction_done()
763 si_sm_result = smi_info->handlers->event(smi_info->si_sm, time); in smi_event_handler()
766 si_sm_result = smi_info->handlers->event(smi_info->si_sm, 0); in smi_event_handler()
780 smi_info->si_state = SI_NORMAL; in smi_event_handler()
781 if (smi_info->curr_msg != NULL) { in smi_event_handler()
796 if (si_sm_result == SI_SM_ATTN || smi_info->got_attn) { in smi_event_handler()
799 if (smi_info->si_state != SI_NORMAL) { in smi_event_handler()
804 smi_info->got_attn = true; in smi_event_handler()
806 smi_info->got_attn = false; in smi_event_handler()
820 smi_info->si_state = SI_GETTING_FLAGS; in smi_event_handler()
835 && (atomic_read(&smi_info->req_events))) { in smi_event_handler()
840 atomic_set(&smi_info->req_events, 0); in smi_event_handler()
848 if (smi_info->supports_event_msg_buff || smi_info->io.irq) { in smi_event_handler()
851 smi_info->curr_msg = alloc_msg_handle_irq(smi_info); in smi_event_handler()
852 if (!smi_info->curr_msg) in smi_event_handler()
860 if (si_sm_result == SI_SM_IDLE && smi_info->timer_running) { in smi_event_handler()
862 if (del_timer(&smi_info->si_timer)) in smi_event_handler()
863 smi_info->timer_running = false; in smi_event_handler()
872 if (smi_info->si_state == SI_NORMAL && smi_info->curr_msg == NULL) { in check_start_timer_thread()
875 if (smi_info->thread) in check_start_timer_thread()
876 wake_up_process(smi_info->thread); in check_start_timer_thread()
889 * Currently, this function is called only in run-to-completion in flush_messages()
890 * mode. This means we are single-threaded, no need for locks. in flush_messages()
907 if (smi_info->run_to_completion) { in sender()
912 smi_info->waiting_msg = msg; in sender()
916 spin_lock_irqsave(&smi_info->si_lock, flags); in sender()
924 BUG_ON(smi_info->waiting_msg); in sender()
925 smi_info->waiting_msg = msg; in sender()
927 spin_unlock_irqrestore(&smi_info->si_lock, flags); in sender()
934 smi_info->run_to_completion = i_run_to_completion; in set_run_to_completion()
940 * Use -1 as a special constant to tell that we are spinning in kipmid
943 #define IPMI_TIME_NOT_BUSY ns_to_ktime(-1ull)
950 if (smi_info->si_num < num_max_busy_us) in ipmi_thread_busy_wait()
951 max_busy_us = kipmid_max_busy_us[smi_info->si_num]; in ipmi_thread_busy_wait()
967 * A busy-waiting loop for speeding up IPMI operation.
973 * Documentation/driver-api/ipmi.rst for details.
986 spin_lock_irqsave(&(smi_info->si_lock), flags); in ipmi_thread()
996 if (smi_result != SI_SM_IDLE && !smi_info->timer_running) in ipmi_thread()
999 spin_unlock_irqrestore(&(smi_info->si_lock), flags); in ipmi_thread()
1011 if (smi_info->in_maintenance_mode) in ipmi_thread()
1016 if (atomic_read(&smi_info->need_watch)) { in ipmi_thread()
1035 bool run_to_completion = smi_info->run_to_completion; in poll()
1043 spin_lock_irqsave(&smi_info->si_lock, flags); in poll()
1046 spin_unlock_irqrestore(&smi_info->si_lock, flags); in poll()
1053 if (!smi_info->has_event_buffer) in request_events()
1056 atomic_set(&smi_info->req_events, 1); in request_events()
1067 atomic_set(&smi_info->need_watch, enable); in set_need_watch()
1068 spin_lock_irqsave(&smi_info->si_lock, flags); in set_need_watch()
1070 spin_unlock_irqrestore(&smi_info->si_lock, flags); in set_need_watch()
1082 spin_lock_irqsave(&(smi_info->si_lock), flags); in smi_timeout()
1086 time_diff = (((long)jiffies_now - (long)smi_info->last_timeout_jiffies) in smi_timeout()
1090 if ((smi_info->io.irq) && (!smi_info->interrupt_disabled)) { in smi_timeout()
1113 smi_info->timer_running = false; in smi_timeout()
1114 spin_unlock_irqrestore(&(smi_info->si_lock), flags); in smi_timeout()
1122 if (smi_info->io.si_type == SI_BT) in ipmi_si_irq_handler()
1124 smi_info->io.outputb(&smi_info->io, IPMI_BT_INTMASK_REG, in ipmi_si_irq_handler()
1128 spin_lock_irqsave(&(smi_info->si_lock), flags); in ipmi_si_irq_handler()
1135 spin_unlock_irqrestore(&(smi_info->si_lock), flags); in ipmi_si_irq_handler()
1145 new_smi->intf = intf; in smi_start_processing()
1148 timer_setup(&new_smi->si_timer, smi_timeout, 0); in smi_start_processing()
1149 new_smi->timer_can_start = true; in smi_start_processing()
1153 if (new_smi->io.irq_setup) { in smi_start_processing()
1154 new_smi->io.irq_handler_data = new_smi; in smi_start_processing()
1155 new_smi->io.irq_setup(&new_smi->io); in smi_start_processing()
1161 if (new_smi->si_num < num_force_kipmid) in smi_start_processing()
1162 enable = force_kipmid[new_smi->si_num]; in smi_start_processing()
1167 else if ((new_smi->io.si_type != SI_BT) && (!new_smi->io.irq)) in smi_start_processing()
1171 new_smi->thread = kthread_run(ipmi_thread, new_smi, in smi_start_processing()
1172 "kipmi%d", new_smi->si_num); in smi_start_processing()
1173 if (IS_ERR(new_smi->thread)) { in smi_start_processing()
1174 dev_notice(new_smi->io.dev, in smi_start_processing()
1176 PTR_ERR(new_smi->thread)); in smi_start_processing()
1177 new_smi->thread = NULL; in smi_start_processing()
1188 data->addr_src = smi->io.addr_source; in get_smi_info()
1189 data->dev = smi->io.dev; in get_smi_info()
1190 data->addr_info = smi->io.addr_info; in get_smi_info()
1191 get_device(smi->io.dev); in get_smi_info()
1201 atomic_set(&smi_info->req_events, 0); in set_maintenance_mode()
1202 smi_info->in_maintenance_mode = enable; in set_maintenance_mode()
1228 …"Force the kipmi daemon to be enabled (1) or disabled(0). Normally the IPMI driver auto-detects t…
1234 …"Max time (in microseconds) to busy-wait for IPMI data before sleeping. 0 (default) means to wait …
1238 if (io->si_type == SI_BT) in ipmi_irq_finish_setup()
1240 io->outputb(io, IPMI_BT_INTMASK_REG, in ipmi_irq_finish_setup()
1246 if (io->si_type == SI_BT) in ipmi_irq_start_cleanup()
1248 io->outputb(io, IPMI_BT_INTMASK_REG, 0); in ipmi_irq_start_cleanup()
1254 free_irq(io->irq, io->irq_handler_data); in std_irq_cleanup()
1261 if (!io->irq) in ipmi_std_irq_setup()
1264 rv = request_irq(io->irq, in ipmi_std_irq_setup()
1268 io->irq_handler_data); in ipmi_std_irq_setup()
1270 dev_warn(io->dev, "%s unable to claim interrupt %d, running polled\n", in ipmi_std_irq_setup()
1271 SI_DEVICE_NAME, io->irq); in ipmi_std_irq_setup()
1272 io->irq = 0; in ipmi_std_irq_setup()
1274 io->irq_cleanup = std_irq_cleanup; in ipmi_std_irq_setup()
1276 dev_info(io->dev, "Using irq %d\n", io->irq); in ipmi_std_irq_setup()
1286 smi_result = smi_info->handlers->event(smi_info->si_sm, 0); in wait_for_msg_done()
1291 smi_result = smi_info->handlers->event( in wait_for_msg_done()
1292 smi_info->si_sm, jiffies_to_usecs(1)); in wait_for_msg_done()
1294 smi_result = smi_info->handlers->event( in wait_for_msg_done()
1295 smi_info->si_sm, 0); in wait_for_msg_done()
1302 * the port is probably not an IPMI SMI interface. in wait_for_msg_done()
1304 return -ENODEV; in wait_for_msg_done()
1319 return -ENOMEM; in try_get_dev_id()
1329 smi_info->handlers->start_transaction(smi_info->si_sm, msg, 2); in try_get_dev_id()
1335 resp_len = smi_info->handlers->get_result(smi_info->si_sm, in try_get_dev_id()
1340 resp + 2, resp_len - 2, &smi_info->device_id); in try_get_dev_id()
1347 dev_warn_ratelimited(smi_info->io.dev, in try_get_dev_id()
1368 return -ENOMEM; in get_global_enables()
1372 smi_info->handlers->start_transaction(smi_info->si_sm, msg, 2); in get_global_enables()
1376 dev_warn(smi_info->io.dev, in get_global_enables()
1382 resp_len = smi_info->handlers->get_result(smi_info->si_sm, in get_global_enables()
1389 dev_warn(smi_info->io.dev, in get_global_enables()
1392 rv = -EINVAL; in get_global_enables()
1415 return -ENOMEM; in set_global_enables()
1420 smi_info->handlers->start_transaction(smi_info->si_sm, msg, 3); in set_global_enables()
1424 dev_warn(smi_info->io.dev, in set_global_enables()
1430 resp_len = smi_info->handlers->get_result(smi_info->si_sm, in set_global_enables()
1436 dev_warn(smi_info->io.dev, in set_global_enables()
1439 rv = -EINVAL; in set_global_enables()
1472 dev_err(smi_info->io.dev, in check_clr_rcv_irq()
1482 dev_warn(smi_info->io.dev, in check_clr_rcv_irq()
1484 smi_info->cannot_disable_irq = true; in check_clr_rcv_irq()
1498 if (!smi_info->io.irq) in check_set_rcv_irq()
1508 dev_err(smi_info->io.dev, in check_set_rcv_irq()
1518 dev_warn(smi_info->io.dev, in check_set_rcv_irq()
1520 smi_info->cannot_disable_irq = true; in check_set_rcv_irq()
1521 smi_info->irq_enable_broken = true; in check_set_rcv_irq()
1534 return -ENOMEM; in try_enable_event_buffer()
1538 smi_info->handlers->start_transaction(smi_info->si_sm, msg, 2); in try_enable_event_buffer()
1546 resp_len = smi_info->handlers->get_result(smi_info->si_sm, in try_enable_event_buffer()
1554 rv = -EINVAL; in try_enable_event_buffer()
1560 smi_info->supports_event_msg_buff = true; in try_enable_event_buffer()
1567 smi_info->handlers->start_transaction(smi_info->si_sm, msg, 3); in try_enable_event_buffer()
1575 resp_len = smi_info->handlers->get_result(smi_info->si_sm, in try_enable_event_buffer()
1582 rv = -EINVAL; in try_enable_event_buffer()
1591 rv = -ENOENT; in try_enable_event_buffer()
1593 smi_info->supports_event_msg_buff = true; in try_enable_event_buffer()
1617 return sysfs_emit(buf, "%s\n", si_to_str[smi_info->io.si_type]); in type_show()
1626 int enabled = smi_info->io.irq && !smi_info->interrupt_disabled; in interrupts_enabled_show()
1651 "%s,%s,0x%lx,rsp=%d,rsi=%d,rsh=%d,irq=%d,ipmb=%d\n", in params_show()
1652 si_to_str[smi_info->io.si_type], in params_show()
1653 addr_space_to_str[smi_info->io.addr_space], in params_show()
1654 smi_info->io.addr_data, in params_show()
1655 smi_info->io.regspacing, in params_show()
1656 smi_info->io.regsize, in params_show()
1657 smi_info->io.regshift, in params_show()
1658 smi_info->io.irq, in params_show()
1659 smi_info->io.slave_addr); in params_show()
1687 * @info - smi_info structure with msg_flags set
1690 * Returns 1 indicating need to re-run handle_flags().
1694 smi_info->msg_flags = ((smi_info->msg_flags & ~OEM_DATA_AVAIL) | in oem_data_avail_to_receive_msg_avail()
1701 * @info - smi_info.device_id must be populated
1705 * it's safe to do so. Such systems will de-assert OEM1_DATA_AVAIL
1709 * As Dell has no plans to release IPMI 1.5 firmware that *ever*
1717 * IPMI Version = 0x51 IPMI 1.5
1720 * Additionally, PowerEdge systems with IPMI < 1.5 may also assert
1730 struct ipmi_device_id *id = &smi_info->device_id; in setup_dell_poweredge_oem_data_handler()
1731 if (id->manufacturer_id == DELL_IANA_MFR_ID) { in setup_dell_poweredge_oem_data_handler()
1732 if (id->device_id == DELL_POWEREDGE_8G_BMC_DEVICE_ID && in setup_dell_poweredge_oem_data_handler()
1733 id->device_revision == DELL_POWEREDGE_8G_BMC_DEVICE_REV && in setup_dell_poweredge_oem_data_handler()
1734 id->ipmi_version == DELL_POWEREDGE_8G_BMC_IPMI_VERSION) { in setup_dell_poweredge_oem_data_handler()
1735 smi_info->oem_data_avail_handler = in setup_dell_poweredge_oem_data_handler()
1740 smi_info->oem_data_avail_handler = in setup_dell_poweredge_oem_data_handler()
1749 struct ipmi_smi_msg *msg = smi_info->curr_msg; in return_hosed_msg_badsize()
1752 msg->rsp[0] = msg->data[0] | 4; in return_hosed_msg_badsize()
1753 msg->rsp[1] = msg->data[1]; in return_hosed_msg_badsize()
1754 msg->rsp[2] = CANNOT_RETURN_REQUESTED_LENGTH; in return_hosed_msg_badsize()
1755 msg->rsp_size = 3; in return_hosed_msg_badsize()
1756 smi_info->curr_msg = NULL; in return_hosed_msg_badsize()
1762 * @info - smi_info.device_id must be populated
1768 * callers to try again with a different-sized buffer, which succeeds.
1778 unsigned char *data = smi_info->curr_msg->data; in dell_poweredge_bt_xaction_handler()
1779 unsigned int size = smi_info->curr_msg->data_size; in dell_poweredge_bt_xaction_handler()
1796 * @info - smi_info.device_id must be filled in already
1804 struct ipmi_device_id *id = &smi_info->device_id; in setup_dell_poweredge_bt_xaction_handler()
1805 if (id->manufacturer_id == DELL_IANA_MFR_ID && in setup_dell_poweredge_bt_xaction_handler()
1806 smi_info->io.si_type == SI_BT) in setup_dell_poweredge_bt_xaction_handler()
1812 * @info - smi_info.device_id must be filled in already
1836 if (smi_info->thread != NULL) { in stop_timer_and_thread()
1837 kthread_stop(smi_info->thread); in stop_timer_and_thread()
1838 smi_info->thread = NULL; in stop_timer_and_thread()
1841 smi_info->timer_can_start = false; in stop_timer_and_thread()
1842 del_timer_sync(&smi_info->si_timer); in stop_timer_and_thread()
1850 if (e->io.addr_space != info->io.addr_space) in find_dup_si()
1852 if (e->io.addr_data == info->io.addr_data) { in find_dup_si()
1858 if (info->io.slave_addr && !e->io.slave_addr) in find_dup_si()
1859 e->io.slave_addr = info->io.slave_addr; in find_dup_si()
1873 * If the user gave us a hard-coded device at the same in ipmi_si_add_smi()
1877 if (io->addr_source != SI_HARDCODED && io->addr_source != SI_HOTMOD && in ipmi_si_add_smi()
1878 ipmi_si_hardcode_match(io->addr_space, io->addr_data)) { in ipmi_si_add_smi()
1879 dev_info(io->dev, in ipmi_si_add_smi()
1880 "Hard-coded device at this address already exists"); in ipmi_si_add_smi()
1881 return -ENODEV; in ipmi_si_add_smi()
1884 if (!io->io_setup) { in ipmi_si_add_smi()
1885 if (io->addr_space == IPMI_IO_ADDR_SPACE) { in ipmi_si_add_smi()
1886 io->io_setup = ipmi_si_port_setup; in ipmi_si_add_smi()
1887 } else if (io->addr_space == IPMI_MEM_ADDR_SPACE) { in ipmi_si_add_smi()
1888 io->io_setup = ipmi_si_mem_setup; in ipmi_si_add_smi()
1890 return -EINVAL; in ipmi_si_add_smi()
1896 return -ENOMEM; in ipmi_si_add_smi()
1897 spin_lock_init(&new_smi->si_lock); in ipmi_si_add_smi()
1899 new_smi->io = *io; in ipmi_si_add_smi()
1904 if (new_smi->io.addr_source == SI_ACPI && in ipmi_si_add_smi()
1905 dup->io.addr_source == SI_SMBIOS) { in ipmi_si_add_smi()
1907 dev_info(dup->io.dev, in ipmi_si_add_smi()
1908 "Removing SMBIOS-specified %s state machine in favor of ACPI\n", in ipmi_si_add_smi()
1909 si_to_str[new_smi->io.si_type]); in ipmi_si_add_smi()
1912 dev_info(new_smi->io.dev, in ipmi_si_add_smi()
1913 "%s-specified %s state machine: duplicate\n", in ipmi_si_add_smi()
1914 ipmi_addr_src_to_str(new_smi->io.addr_source), in ipmi_si_add_smi()
1915 si_to_str[new_smi->io.si_type]); in ipmi_si_add_smi()
1916 rv = -EBUSY; in ipmi_si_add_smi()
1922 pr_info("Adding %s-specified %s state machine\n", in ipmi_si_add_smi()
1923 ipmi_addr_src_to_str(new_smi->io.addr_source), in ipmi_si_add_smi()
1924 si_to_str[new_smi->io.si_type]); in ipmi_si_add_smi()
1926 list_add_tail(&new_smi->link, &smi_infos); in ipmi_si_add_smi()
1945 pr_info("Trying %s-specified %s state machine at %s address 0x%lx, slave address 0x%x, irq %d\n", in try_smi_init()
1946 ipmi_addr_src_to_str(new_smi->io.addr_source), in try_smi_init()
1947 si_to_str[new_smi->io.si_type], in try_smi_init()
1948 addr_space_to_str[new_smi->io.addr_space], in try_smi_init()
1949 new_smi->io.addr_data, in try_smi_init()
1950 new_smi->io.slave_addr, new_smi->io.irq); in try_smi_init()
1952 switch (new_smi->io.si_type) { in try_smi_init()
1954 new_smi->handlers = &kcs_smi_handlers; in try_smi_init()
1958 new_smi->handlers = &smic_smi_handlers; in try_smi_init()
1962 new_smi->handlers = &bt_smi_handlers; in try_smi_init()
1967 rv = -EIO; in try_smi_init()
1971 new_smi->si_num = smi_num; in try_smi_init()
1974 if (!new_smi->io.dev) { in try_smi_init()
1975 pr_err("IPMI interface added with no device\n"); in try_smi_init()
1976 rv = -EIO; in try_smi_init()
1981 new_smi->si_sm = kmalloc(new_smi->handlers->size(), GFP_KERNEL); in try_smi_init()
1982 if (!new_smi->si_sm) { in try_smi_init()
1983 rv = -ENOMEM; in try_smi_init()
1986 new_smi->io.io_size = new_smi->handlers->init_data(new_smi->si_sm, in try_smi_init()
1987 &new_smi->io); in try_smi_init()
1990 rv = new_smi->io.io_setup(&new_smi->io); in try_smi_init()
1992 dev_err(new_smi->io.dev, "Could not set up I/O space\n"); in try_smi_init()
1996 /* Do low-level detection first. */ in try_smi_init()
1997 if (new_smi->handlers->detect(new_smi->si_sm)) { in try_smi_init()
1998 if (new_smi->io.addr_source) in try_smi_init()
1999 dev_err(new_smi->io.dev, in try_smi_init()
2001 rv = -ENODEV; in try_smi_init()
2011 if (new_smi->io.addr_source) in try_smi_init()
2012 dev_err(new_smi->io.dev, in try_smi_init()
2021 new_smi->waiting_msg = NULL; in try_smi_init()
2022 new_smi->curr_msg = NULL; in try_smi_init()
2023 atomic_set(&new_smi->req_events, 0); in try_smi_init()
2024 new_smi->run_to_completion = false; in try_smi_init()
2026 atomic_set(&new_smi->stats[i], 0); in try_smi_init()
2028 new_smi->interrupt_disabled = true; in try_smi_init()
2029 atomic_set(&new_smi->need_watch, 0); in try_smi_init()
2033 new_smi->has_event_buffer = true; in try_smi_init()
2042 * IRQ is defined to be set when non-zero. req_events will in try_smi_init()
2045 if (new_smi->io.irq) { in try_smi_init()
2046 new_smi->interrupt_disabled = false; in try_smi_init()
2047 atomic_set(&new_smi->req_events, 1); in try_smi_init()
2050 dev_set_drvdata(new_smi->io.dev, new_smi); in try_smi_init()
2051 rv = device_add_group(new_smi->io.dev, &ipmi_si_dev_attr_group); in try_smi_init()
2053 dev_err(new_smi->io.dev, in try_smi_init()
2058 new_smi->dev_group_added = true; in try_smi_init()
2062 new_smi->io.dev, in try_smi_init()
2063 new_smi->io.slave_addr); in try_smi_init()
2065 dev_err(new_smi->io.dev, in try_smi_init()
2074 dev_info(new_smi->io.dev, "IPMI %s interface initialized\n", in try_smi_init()
2075 si_to_str[new_smi->io.si_type]); in try_smi_init()
2077 WARN_ON(new_smi->io.dev->init_name != NULL); in try_smi_init()
2080 if (rv && new_smi->io.io_cleanup) { in try_smi_init()
2081 new_smi->io.io_cleanup(&new_smi->io); in try_smi_init()
2082 new_smi->io.io_cleanup = NULL; in try_smi_init()
2098 pr_info("IPMI System Interface driver\n"); in init_ipmi_si()
2115 if (e->io.irq && (!type || e->io.addr_source == type)) { in init_ipmi_si()
2117 type = e->io.addr_source; in init_ipmi_si()
2129 if (!e->io.irq && (!type || e->io.addr_source == type)) { in init_ipmi_si()
2131 type = e->io.addr_source; in init_ipmi_si()
2148 return -ENODEV; in init_ipmi_si()
2160 if (smi_info->dev_group_added) { in shutdown_smi()
2161 device_remove_group(smi_info->io.dev, &ipmi_si_dev_attr_group); in shutdown_smi()
2162 smi_info->dev_group_added = false; in shutdown_smi()
2164 if (smi_info->io.dev) in shutdown_smi()
2165 dev_set_drvdata(smi_info->io.dev, NULL); in shutdown_smi()
2171 smi_info->interrupt_disabled = true; in shutdown_smi()
2172 if (smi_info->io.irq_cleanup) { in shutdown_smi()
2173 smi_info->io.irq_cleanup(&smi_info->io); in shutdown_smi()
2174 smi_info->io.irq_cleanup = NULL; in shutdown_smi()
2190 while (smi_info->curr_msg || (smi_info->si_state != SI_NORMAL)) { in shutdown_smi()
2194 if (smi_info->handlers) in shutdown_smi()
2196 while (smi_info->curr_msg || (smi_info->si_state != SI_NORMAL)) { in shutdown_smi()
2200 if (smi_info->handlers) in shutdown_smi()
2201 smi_info->handlers->cleanup(smi_info->si_sm); in shutdown_smi()
2203 if (smi_info->io.io_cleanup) { in shutdown_smi()
2204 smi_info->io.io_cleanup(&smi_info->io); in shutdown_smi()
2205 smi_info->io.io_cleanup = NULL; in shutdown_smi()
2208 kfree(smi_info->si_sm); in shutdown_smi()
2209 smi_info->si_sm = NULL; in shutdown_smi()
2211 smi_info->intf = NULL; in shutdown_smi()
2216 * smi_info->intf check.
2223 list_del(&smi_info->link); in cleanup_one_si()
2224 ipmi_unregister_smi(smi_info->intf); in cleanup_one_si()
2234 if (e->io.dev == dev) { in ipmi_si_remove_by_dev()
2251 if (e->io.addr_space != addr_space) in ipmi_si_remove_by_data()
2253 if (e->io.si_type != si_type) in ipmi_si_remove_by_data()
2255 if (e->io.addr_data == addr) { in ipmi_si_remove_by_data()
2256 dev = get_device(e->io.dev); in ipmi_si_remove_by_data()
2288 MODULE_ALIAS("platform:dmi-ipmi-si");
2291 MODULE_DESCRIPTION("Interface to the IPMI driver for the KCS, SMIC, and BT system interfaces.");