diff options
author | Corey Minyard <cminyard@mvista.com> | 2018-04-04 10:15:23 -0400 |
---|---|---|
committer | Corey Minyard <cminyard@mvista.com> | 2018-04-18 11:22:42 -0400 |
commit | ce7fa1c38d07102d4dc4627f757a3f2467069d86 (patch) | |
tree | bdb1d13cc0c3745ab5c761e387ce5a2a057fe498 | |
parent | a27fc14219f2e3c4a46ba9177b04d9b52c875532 (diff) |
ipmi: Add a way to tune some timeouts
By default the retry timeout is 1 second. Allow that to be modified,
primarily for slow operations, like firmware writes.
Also, the timeout was driven by a 1 second timer, so 1 second really
meant between 0 and 1 second. Set the default to 2 seconds so it
means between 1 and 2 seconds.
Also allow the time the interface automatically stays in mainenance
mode to be modified from it's default 30 seconds.
Also consolidate some of the timeout and retry setup.
Signed-off-by: Corey Minyard <cminyard@mvista.com>
more
-rw-r--r-- | drivers/char/ipmi/ipmi_msghandler.c | 80 |
1 files changed, 48 insertions, 32 deletions
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 361148938801..add8130be517 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c | |||
@@ -116,17 +116,39 @@ MODULE_PARM_DESC(panic_op, "Sets if the IPMI driver will attempt to store panic | |||
116 | static struct proc_dir_entry *proc_ipmi_root; | 116 | static struct proc_dir_entry *proc_ipmi_root; |
117 | #endif /* CONFIG_IPMI_PROC_INTERFACE */ | 117 | #endif /* CONFIG_IPMI_PROC_INTERFACE */ |
118 | 118 | ||
119 | /* Remain in auto-maintenance mode for this amount of time (in ms). */ | ||
120 | #define IPMI_MAINTENANCE_MODE_TIMEOUT 30000 | ||
121 | |||
122 | #define MAX_EVENTS_IN_QUEUE 25 | 119 | #define MAX_EVENTS_IN_QUEUE 25 |
123 | 120 | ||
121 | /* Remain in auto-maintenance mode for this amount of time (in ms). */ | ||
122 | static unsigned long maintenance_mode_timeout_ms = 30000; | ||
123 | module_param(maintenance_mode_timeout_ms, ulong, 0644); | ||
124 | MODULE_PARM_DESC(maintenance_mode_timeout_ms, | ||
125 | "The time (milliseconds) after the last maintenance message that the connection stays in maintenance mode."); | ||
126 | |||
124 | /* | 127 | /* |
125 | * Don't let a message sit in a queue forever, always time it with at lest | 128 | * Don't let a message sit in a queue forever, always time it with at lest |
126 | * the max message timer. This is in milliseconds. | 129 | * the max message timer. This is in milliseconds. |
127 | */ | 130 | */ |
128 | #define MAX_MSG_TIMEOUT 60000 | 131 | #define MAX_MSG_TIMEOUT 60000 |
129 | 132 | ||
133 | /* | ||
134 | * Timeout times below are in milliseconds, and are done off a 1 | ||
135 | * second timer. So setting the value to 1000 would mean anything | ||
136 | * between 0 and 1000ms. So really the only reasonable minimum | ||
137 | * setting it 2000ms, which is between 1 and 2 seconds. | ||
138 | */ | ||
139 | |||
140 | /* The default timeout for message retries. */ | ||
141 | static unsigned long default_retry_ms = 2000; | ||
142 | module_param(default_retry_ms, ulong, 0644); | ||
143 | MODULE_PARM_DESC(default_retry_ms, | ||
144 | "The time (milliseconds) between retry sends"); | ||
145 | |||
146 | /* The default maximum number of retries */ | ||
147 | static unsigned int default_max_retries = 4; | ||
148 | module_param(default_max_retries, uint, 0644); | ||
149 | MODULE_PARM_DESC(default_max_retries, | ||
150 | "The time (milliseconds) between retry sends in maintenance mode"); | ||
151 | |||
130 | /* Call every ~1000 ms. */ | 152 | /* Call every ~1000 ms. */ |
131 | #define IPMI_TIMEOUT_TIME 1000 | 153 | #define IPMI_TIMEOUT_TIME 1000 |
132 | 154 | ||
@@ -884,6 +906,11 @@ static int intf_next_seq(ipmi_smi_t intf, | |||
884 | int rv = 0; | 906 | int rv = 0; |
885 | unsigned int i; | 907 | unsigned int i; |
886 | 908 | ||
909 | if (timeout == 0) | ||
910 | timeout = default_retry_ms; | ||
911 | if (retries < 0) | ||
912 | retries = default_max_retries; | ||
913 | |||
887 | for (i = intf->curr_seq; (i+1)%IPMI_IPMB_NUM_SEQ != intf->curr_seq; | 914 | for (i = intf->curr_seq; (i+1)%IPMI_IPMB_NUM_SEQ != intf->curr_seq; |
888 | i = (i+1)%IPMI_IPMB_NUM_SEQ) { | 915 | i = (i+1)%IPMI_IPMB_NUM_SEQ) { |
889 | if (!intf->seq_table[i].inuse) | 916 | if (!intf->seq_table[i].inuse) |
@@ -1636,6 +1663,14 @@ static void smi_send(ipmi_smi_t intf, const struct ipmi_smi_handlers *handlers, | |||
1636 | handlers->sender(intf->send_info, smi_msg); | 1663 | handlers->sender(intf->send_info, smi_msg); |
1637 | } | 1664 | } |
1638 | 1665 | ||
1666 | static bool is_maintenance_mode_cmd(struct kernel_ipmi_msg *msg) | ||
1667 | { | ||
1668 | return (((msg->netfn == IPMI_NETFN_APP_REQUEST) | ||
1669 | && ((msg->cmd == IPMI_COLD_RESET_CMD) | ||
1670 | || (msg->cmd == IPMI_WARM_RESET_CMD))) | ||
1671 | || (msg->netfn == IPMI_NETFN_FIRMWARE_REQUEST)); | ||
1672 | } | ||
1673 | |||
1639 | /* | 1674 | /* |
1640 | * Separate from ipmi_request so that the user does not have to be | 1675 | * Separate from ipmi_request so that the user does not have to be |
1641 | * supplied in certain circumstances (mainly at panic time). If | 1676 | * supplied in certain circumstances (mainly at panic time). If |
@@ -1728,13 +1763,10 @@ static int i_ipmi_request(ipmi_user_t user, | |||
1728 | goto out_err; | 1763 | goto out_err; |
1729 | } | 1764 | } |
1730 | 1765 | ||
1731 | if (((msg->netfn == IPMI_NETFN_APP_REQUEST) | 1766 | if (is_maintenance_mode_cmd(msg)) { |
1732 | && ((msg->cmd == IPMI_COLD_RESET_CMD) | ||
1733 | || (msg->cmd == IPMI_WARM_RESET_CMD))) | ||
1734 | || (msg->netfn == IPMI_NETFN_FIRMWARE_REQUEST)) { | ||
1735 | spin_lock_irqsave(&intf->maintenance_mode_lock, flags); | 1767 | spin_lock_irqsave(&intf->maintenance_mode_lock, flags); |
1736 | intf->auto_maintenance_timeout | 1768 | intf->auto_maintenance_timeout |
1737 | = IPMI_MAINTENANCE_MODE_TIMEOUT; | 1769 | = maintenance_mode_timeout_ms; |
1738 | if (!intf->maintenance_mode | 1770 | if (!intf->maintenance_mode |
1739 | && !intf->maintenance_mode_enable) { | 1771 | && !intf->maintenance_mode_enable) { |
1740 | intf->maintenance_mode_enable = true; | 1772 | intf->maintenance_mode_enable = true; |
@@ -1779,27 +1811,17 @@ static int i_ipmi_request(ipmi_user_t user, | |||
1779 | goto out_err; | 1811 | goto out_err; |
1780 | } | 1812 | } |
1781 | 1813 | ||
1782 | if (retries < 0) { | ||
1783 | if (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE) | ||
1784 | retries = 0; /* Don't retry broadcasts. */ | ||
1785 | else | ||
1786 | retries = 4; | ||
1787 | } | ||
1788 | if (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE) { | 1814 | if (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE) { |
1789 | /* | 1815 | /* |
1790 | * Broadcasts add a zero at the beginning of the | 1816 | * Broadcasts add a zero at the beginning of the |
1791 | * message, but otherwise is the same as an IPMB | 1817 | * message, but otherwise is the same as an IPMB |
1792 | * address. | 1818 | * address. |
1793 | */ | 1819 | */ |
1794 | addr->addr_type = IPMI_IPMB_ADDR_TYPE; | 1820 | addr->addr_type = IPMI_IPMB_ADDR_TYPE; |
1795 | broadcast = 1; | 1821 | broadcast = 1; |
1822 | retries = 0; /* Don't retry broadcasts. */ | ||
1796 | } | 1823 | } |
1797 | 1824 | ||
1798 | |||
1799 | /* Default to 1 second retries. */ | ||
1800 | if (retry_time_ms == 0) | ||
1801 | retry_time_ms = 1000; | ||
1802 | |||
1803 | /* | 1825 | /* |
1804 | * 9 for the header and 1 for the checksum, plus | 1826 | * 9 for the header and 1 for the checksum, plus |
1805 | * possibly one for the broadcast. | 1827 | * possibly one for the broadcast. |
@@ -1914,12 +1936,6 @@ static int i_ipmi_request(ipmi_user_t user, | |||
1914 | goto out_err; | 1936 | goto out_err; |
1915 | } | 1937 | } |
1916 | 1938 | ||
1917 | retries = 4; | ||
1918 | |||
1919 | /* Default to 1 second retries. */ | ||
1920 | if (retry_time_ms == 0) | ||
1921 | retry_time_ms = 1000; | ||
1922 | |||
1923 | /* 11 for the header and 1 for the checksum. */ | 1939 | /* 11 for the header and 1 for the checksum. */ |
1924 | if ((msg->data_len + 12) > IPMI_MAX_MSG_LENGTH) { | 1940 | if ((msg->data_len + 12) > IPMI_MAX_MSG_LENGTH) { |
1925 | ipmi_inc_stat(intf, sent_invalid_commands); | 1941 | ipmi_inc_stat(intf, sent_invalid_commands); |