Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-linus-6.18-1' of https://github.com/cminyard/linux-ipmi

Pull IPMI updates from Corey Minyard:
"Bug fixes and enhancements for IPMI

This fixes a number of small bugs, but has some more major changes:

- Loongson-2K BMC support is added. This is an MFD device and is
dependent on the changes coming from that tree.

The way the driver handles BMCs that have become non-functional has
been completely redone. A number of changes in the past have
attempted to handle various issues around this, but nothing has
been very good. After working with some people on this, the code
has been reworked to disable the driver and fail all pending
operations if the BMC becomes non functional. It will retry the BMC
once a second to see if it's back up"

* tag 'for-linus-6.18-1' of https://github.com/cminyard/linux-ipmi:
ipmi: Add Loongson-2K BMC support
ipmi:si: Gracefully handle if the BMC is non-functional
ipmi: Rename "user_data" to "recv_msg" in an SMI message
ipmi: Allow an SMI sender to return an error
ipmi:si: Move flags get start to its own function
ipmi:si: Merge some if statements
ipmi: Set a timer for maintenance mode
ipmi: Add a maintenance mode sysfs file
ipmi: Disable sysfs access and requests in maintenance mode
ipmi: Differentiate between reset and firmware update in maintenance
dt-bindings: ipmi: aspeed,ast2400-kcs-bmc: Add missing "clocks" property
ipmi: Rework user message limit handling
Revert "ipmi: fix msg stack when IPMI is disconnected"
ipmi:msghandler:Change seq_lock to a mutex

+603 -341
+3
Documentation/devicetree/bindings/ipmi/aspeed,ast2400-kcs-bmc.yaml
··· 40 40 - description: ODR register 41 41 - description: STR register 42 42 43 + clocks: 44 + maxItems: 1 45 + 43 46 aspeed,lpc-io-reg: 44 47 $ref: /schemas/types.yaml#/definitions/uint32-array 45 48 minItems: 1
+7
drivers/char/ipmi/Kconfig
··· 84 84 bus, and it also supports direct messaging on the bus using 85 85 IPMB direct messages. This module requires I2C support. 86 86 87 + config IPMI_LS2K 88 + bool 'Loongson-2K IPMI interface' 89 + depends on LOONGARCH 90 + select MFD_LS2K_BMC_CORE 91 + help 92 + Provides a driver for Loongson-2K IPMI interfaces. 93 + 87 94 config IPMI_POWERNV 88 95 depends on PPC_POWERNV 89 96 tristate 'POWERNV (OPAL firmware) IPMI interface'
+1
drivers/char/ipmi/Makefile
··· 8 8 ipmi_si_mem_io.o 9 9 ipmi_si-$(CONFIG_HAS_IOPORT) += ipmi_si_port_io.o 10 10 ipmi_si-$(CONFIG_PCI) += ipmi_si_pci.o 11 + ipmi_si-$(CONFIG_IPMI_LS2K) += ipmi_si_ls2k.o 11 12 ipmi_si-$(CONFIG_PARISC) += ipmi_si_parisc.o 12 13 13 14 obj-$(CONFIG_IPMI_HANDLER) += ipmi_msghandler.o
+2 -2
drivers/char/ipmi/ipmi_ipmb.c
··· 404 404 ipmi_ipmb_stop_thread(iidev); 405 405 } 406 406 407 - static void ipmi_ipmb_sender(void *send_info, 408 - struct ipmi_smi_msg *msg) 407 + static int ipmi_ipmb_sender(void *send_info, struct ipmi_smi_msg *msg) 409 408 { 410 409 struct ipmi_ipmb_dev *iidev = send_info; 411 410 unsigned long flags; ··· 416 417 spin_unlock_irqrestore(&iidev->lock, flags); 417 418 418 419 up(&iidev->wake_thread); 420 + return IPMI_CC_NO_ERROR; 419 421 } 420 422 421 423 static void ipmi_ipmb_request_events(void *send_info)
+5 -11
drivers/char/ipmi/ipmi_kcs_sm.c
··· 122 122 unsigned long error0_timeout; 123 123 }; 124 124 125 - static unsigned int init_kcs_data_with_state(struct si_sm_data *kcs, 126 - struct si_sm_io *io, enum kcs_states state) 125 + static unsigned int init_kcs_data(struct si_sm_data *kcs, 126 + struct si_sm_io *io) 127 127 { 128 - kcs->state = state; 128 + kcs->state = KCS_IDLE; 129 129 kcs->io = io; 130 130 kcs->write_pos = 0; 131 131 kcs->write_count = 0; ··· 138 138 139 139 /* Reserve 2 I/O bytes. */ 140 140 return 2; 141 - } 142 - 143 - static unsigned int init_kcs_data(struct si_sm_data *kcs, 144 - struct si_sm_io *io) 145 - { 146 - return init_kcs_data_with_state(kcs, io, KCS_IDLE); 147 141 } 148 142 149 143 static inline unsigned char read_status(struct si_sm_data *kcs) ··· 270 276 if (size > MAX_KCS_WRITE_SIZE) 271 277 return IPMI_REQ_LEN_EXCEEDED_ERR; 272 278 273 - if (kcs->state != KCS_IDLE) { 279 + if ((kcs->state != KCS_IDLE) && (kcs->state != KCS_HOSED)) { 274 280 dev_warn(kcs->io->dev, "KCS in invalid state %d\n", kcs->state); 275 281 return IPMI_NOT_IN_MY_STATE_ERR; 276 282 } ··· 495 501 } 496 502 497 503 if (kcs->state == KCS_HOSED) { 498 - init_kcs_data_with_state(kcs, kcs->io, KCS_ERROR0); 504 + init_kcs_data(kcs, kcs->io); 499 505 return SI_SM_HOSED; 500 506 } 501 507
+323 -288
drivers/char/ipmi/ipmi_msghandler.c
··· 38 38 39 39 #define IPMI_DRIVER_VERSION "39.2" 40 40 41 - static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void); 41 + static struct ipmi_recv_msg *ipmi_alloc_recv_msg(struct ipmi_user *user); 42 + static void ipmi_set_recv_msg_user(struct ipmi_recv_msg *msg, 43 + struct ipmi_user *user); 42 44 static int ipmi_init_msghandler(void); 43 45 static void smi_work(struct work_struct *t); 44 46 static void handle_new_recv_msgs(struct ipmi_smi *intf); ··· 51 49 52 50 static bool initialized; 53 51 static bool drvregistered; 52 + 53 + static struct timer_list ipmi_timer; 54 54 55 55 /* Numbers in this enumerator should be mapped to ipmi_panic_event_str */ 56 56 enum ipmi_panic_event_op { ··· 436 432 atomic_t nr_users; 437 433 struct device_attribute nr_users_devattr; 438 434 struct device_attribute nr_msgs_devattr; 435 + struct device_attribute maintenance_mode_devattr; 439 436 440 437 441 438 /* Used for wake ups at startup. */ ··· 469 464 * interface to match them up with their responses. A routine 470 465 * is called periodically to time the items in this list. 471 466 */ 472 - spinlock_t seq_lock; 467 + struct mutex seq_lock; 473 468 struct seq_table seq_table[IPMI_IPMB_NUM_SEQ]; 474 469 int curr_seq; 475 470 ··· 544 539 545 540 /* For handling of maintenance mode. */ 546 541 int maintenance_mode; 547 - bool maintenance_mode_enable; 542 + 543 + #define IPMI_MAINTENANCE_MODE_STATE_OFF 0 544 + #define IPMI_MAINTENANCE_MODE_STATE_FIRMWARE 1 545 + #define IPMI_MAINTENANCE_MODE_STATE_RESET 2 546 + int maintenance_mode_state; 548 547 int auto_maintenance_timeout; 549 548 spinlock_t maintenance_mode_lock; /* Used in a timer... */ 550 549 ··· 964 955 * risk. At this moment, simply skip it in that case. 965 956 */ 966 957 ipmi_free_recv_msg(msg); 967 - atomic_dec(&msg->user->nr_msgs); 968 958 } else { 969 959 /* 970 960 * Deliver it in smi_work. The message will hold a ··· 1124 1116 struct ipmi_recv_msg **recv_msg) 1125 1117 { 1126 1118 int rv = -ENODEV; 1127 - unsigned long flags; 1128 1119 1129 1120 if (seq >= IPMI_IPMB_NUM_SEQ) 1130 1121 return -EINVAL; 1131 1122 1132 - spin_lock_irqsave(&intf->seq_lock, flags); 1123 + mutex_lock(&intf->seq_lock); 1133 1124 if (intf->seq_table[seq].inuse) { 1134 1125 struct ipmi_recv_msg *msg = intf->seq_table[seq].recv_msg; 1135 1126 ··· 1141 1134 rv = 0; 1142 1135 } 1143 1136 } 1144 - spin_unlock_irqrestore(&intf->seq_lock, flags); 1137 + mutex_unlock(&intf->seq_lock); 1145 1138 1146 1139 return rv; 1147 1140 } ··· 1152 1145 long msgid) 1153 1146 { 1154 1147 int rv = -ENODEV; 1155 - unsigned long flags; 1156 1148 unsigned char seq; 1157 1149 unsigned long seqid; 1158 1150 1159 1151 1160 1152 GET_SEQ_FROM_MSGID(msgid, seq, seqid); 1161 1153 1162 - spin_lock_irqsave(&intf->seq_lock, flags); 1154 + mutex_lock(&intf->seq_lock); 1163 1155 /* 1164 1156 * We do this verification because the user can be deleted 1165 1157 * while a message is outstanding. ··· 1169 1163 ent->timeout = ent->orig_timeout; 1170 1164 rv = 0; 1171 1165 } 1172 - spin_unlock_irqrestore(&intf->seq_lock, flags); 1166 + mutex_unlock(&intf->seq_lock); 1173 1167 1174 1168 return rv; 1175 1169 } ··· 1180 1174 unsigned int err) 1181 1175 { 1182 1176 int rv = -ENODEV; 1183 - unsigned long flags; 1184 1177 unsigned char seq; 1185 1178 unsigned long seqid; 1186 1179 struct ipmi_recv_msg *msg = NULL; ··· 1187 1182 1188 1183 GET_SEQ_FROM_MSGID(msgid, seq, seqid); 1189 1184 1190 - spin_lock_irqsave(&intf->seq_lock, flags); 1185 + mutex_lock(&intf->seq_lock); 1191 1186 /* 1192 1187 * We do this verification because the user can be deleted 1193 1188 * while a message is outstanding. ··· 1201 1196 msg = ent->recv_msg; 1202 1197 rv = 0; 1203 1198 } 1204 - spin_unlock_irqrestore(&intf->seq_lock, flags); 1199 + mutex_unlock(&intf->seq_lock); 1205 1200 1206 1201 if (msg) 1207 1202 deliver_err_response(intf, msg, err); ··· 1214 1209 void *handler_data, 1215 1210 struct ipmi_user **user) 1216 1211 { 1217 - unsigned long flags; 1218 1212 struct ipmi_user *new_user = NULL; 1219 1213 int rv = 0; 1220 1214 struct ipmi_smi *intf; ··· 1281 1277 new_user->gets_events = false; 1282 1278 1283 1279 mutex_lock(&intf->users_mutex); 1284 - spin_lock_irqsave(&intf->seq_lock, flags); 1280 + mutex_lock(&intf->seq_lock); 1285 1281 list_add(&new_user->link, &intf->users); 1286 - spin_unlock_irqrestore(&intf->seq_lock, flags); 1282 + mutex_unlock(&intf->seq_lock); 1287 1283 mutex_unlock(&intf->users_mutex); 1288 1284 1289 1285 if (handler->ipmi_watchdog_pretimeout) ··· 1329 1325 { 1330 1326 struct ipmi_smi *intf = user->intf; 1331 1327 int i; 1332 - unsigned long flags; 1333 1328 struct cmd_rcvr *rcvr; 1334 1329 struct cmd_rcvr *rcvrs = NULL; 1335 1330 struct ipmi_recv_msg *msg, *msg2; ··· 1349 1346 list_del(&user->link); 1350 1347 atomic_dec(&intf->nr_users); 1351 1348 1352 - spin_lock_irqsave(&intf->seq_lock, flags); 1349 + mutex_lock(&intf->seq_lock); 1353 1350 for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) { 1354 1351 if (intf->seq_table[i].inuse 1355 1352 && (intf->seq_table[i].recv_msg->user == user)) { ··· 1358 1355 ipmi_free_recv_msg(intf->seq_table[i].recv_msg); 1359 1356 } 1360 1357 } 1361 - spin_unlock_irqrestore(&intf->seq_lock, flags); 1358 + mutex_unlock(&intf->seq_lock); 1362 1359 1363 1360 /* 1364 1361 * Remove the user from the command receiver's table. First ··· 1537 1534 static void maintenance_mode_update(struct ipmi_smi *intf) 1538 1535 { 1539 1536 if (intf->handlers->set_maintenance_mode) 1537 + /* 1538 + * Lower level drivers only care about firmware mode 1539 + * as it affects their timing. They don't care about 1540 + * reset, which disables all commands for a while. 1541 + */ 1540 1542 intf->handlers->set_maintenance_mode( 1541 - intf->send_info, intf->maintenance_mode_enable); 1543 + intf->send_info, 1544 + (intf->maintenance_mode_state == 1545 + IPMI_MAINTENANCE_MODE_STATE_FIRMWARE)); 1542 1546 } 1543 1547 1544 1548 int ipmi_set_maintenance_mode(struct ipmi_user *user, int mode) ··· 1562 1552 if (intf->maintenance_mode != mode) { 1563 1553 switch (mode) { 1564 1554 case IPMI_MAINTENANCE_MODE_AUTO: 1565 - intf->maintenance_mode_enable 1566 - = (intf->auto_maintenance_timeout > 0); 1555 + /* Just leave it alone. */ 1567 1556 break; 1568 1557 1569 1558 case IPMI_MAINTENANCE_MODE_OFF: 1570 - intf->maintenance_mode_enable = false; 1559 + intf->maintenance_mode_state = 1560 + IPMI_MAINTENANCE_MODE_STATE_OFF; 1571 1561 break; 1572 1562 1573 1563 case IPMI_MAINTENANCE_MODE_ON: 1574 - intf->maintenance_mode_enable = true; 1564 + intf->maintenance_mode_state = 1565 + IPMI_MAINTENANCE_MODE_STATE_FIRMWARE; 1575 1566 break; 1576 1567 1577 1568 default: ··· 1627 1616 } 1628 1617 1629 1618 list_for_each_entry_safe(msg, msg2, &msgs, link) { 1630 - msg->user = user; 1631 - kref_get(&user->refcount); 1619 + ipmi_set_recv_msg_user(msg, user); 1632 1620 deliver_local_response(intf, msg); 1633 1621 } 1634 1622 } ··· 1932 1922 1933 1923 if (is_maintenance_mode_cmd(msg)) { 1934 1924 unsigned long flags; 1925 + int newst; 1926 + 1927 + if (msg->netfn == IPMI_NETFN_FIRMWARE_REQUEST) 1928 + newst = IPMI_MAINTENANCE_MODE_STATE_FIRMWARE; 1929 + else 1930 + newst = IPMI_MAINTENANCE_MODE_STATE_RESET; 1935 1931 1936 1932 spin_lock_irqsave(&intf->maintenance_mode_lock, flags); 1937 - intf->auto_maintenance_timeout 1938 - = maintenance_mode_timeout_ms; 1933 + intf->auto_maintenance_timeout = maintenance_mode_timeout_ms; 1939 1934 if (!intf->maintenance_mode 1940 - && !intf->maintenance_mode_enable) { 1941 - intf->maintenance_mode_enable = true; 1935 + && intf->maintenance_mode_state < newst) { 1936 + intf->maintenance_mode_state = newst; 1942 1937 maintenance_mode_update(intf); 1938 + mod_timer(&ipmi_timer, jiffies + IPMI_TIMEOUT_JIFFIES); 1943 1939 } 1944 1940 spin_unlock_irqrestore(&intf->maintenance_mode_lock, 1945 1941 flags); ··· 1959 1943 smi_msg->data[0] = (msg->netfn << 2) | (smi_addr->lun & 0x3); 1960 1944 smi_msg->data[1] = msg->cmd; 1961 1945 smi_msg->msgid = msgid; 1962 - smi_msg->user_data = recv_msg; 1946 + smi_msg->recv_msg = recv_msg; 1963 1947 if (msg->data_len > 0) 1964 1948 memcpy(&smi_msg->data[2], msg->data, msg->data_len); 1965 1949 smi_msg->data_size = msg->data_len + 2; ··· 2040 2024 * Save the receive message so we can use it 2041 2025 * to deliver the response. 2042 2026 */ 2043 - smi_msg->user_data = recv_msg; 2027 + smi_msg->recv_msg = recv_msg; 2044 2028 } else { 2045 - /* It's a command, so get a sequence for it. */ 2046 - unsigned long flags; 2047 - 2048 - spin_lock_irqsave(&intf->seq_lock, flags); 2029 + mutex_lock(&intf->seq_lock); 2049 2030 2050 2031 if (is_maintenance_mode_cmd(msg)) 2051 2032 intf->ipmb_maintenance_mode_timeout = ··· 2100 2087 * to be correct. 2101 2088 */ 2102 2089 out_err: 2103 - spin_unlock_irqrestore(&intf->seq_lock, flags); 2090 + mutex_unlock(&intf->seq_lock); 2104 2091 } 2105 2092 2106 2093 return rv; ··· 2153 2140 memcpy(smi_msg->data + 4, msg->data, msg->data_len); 2154 2141 smi_msg->data_size = msg->data_len + 4; 2155 2142 2156 - smi_msg->user_data = recv_msg; 2143 + smi_msg->recv_msg = recv_msg; 2157 2144 2158 2145 return 0; 2159 2146 } ··· 2216 2203 * Save the receive message so we can use it 2217 2204 * to deliver the response. 2218 2205 */ 2219 - smi_msg->user_data = recv_msg; 2206 + smi_msg->recv_msg = recv_msg; 2220 2207 } else { 2221 - /* It's a command, so get a sequence for it. */ 2222 - unsigned long flags; 2223 - 2224 - spin_lock_irqsave(&intf->seq_lock, flags); 2208 + mutex_lock(&intf->seq_lock); 2225 2209 2226 2210 /* 2227 2211 * Create a sequence number with a 1 second ··· 2267 2257 * to be correct. 2268 2258 */ 2269 2259 out_err: 2270 - spin_unlock_irqrestore(&intf->seq_lock, flags); 2260 + mutex_unlock(&intf->seq_lock); 2271 2261 } 2272 2262 2273 2263 return rv; ··· 2298 2288 int run_to_completion = READ_ONCE(intf->run_to_completion); 2299 2289 int rv = 0; 2300 2290 2301 - if (user) { 2302 - if (atomic_add_return(1, &user->nr_msgs) > max_msgs_per_user) { 2303 - /* Decrement will happen at the end of the routine. */ 2304 - rv = -EBUSY; 2305 - goto out; 2306 - } 2307 - } 2308 - 2309 - if (supplied_recv) 2291 + if (supplied_recv) { 2310 2292 recv_msg = supplied_recv; 2311 - else { 2312 - recv_msg = ipmi_alloc_recv_msg(); 2313 - if (recv_msg == NULL) { 2314 - rv = -ENOMEM; 2315 - goto out; 2316 - } 2293 + recv_msg->user = user; 2294 + if (user) 2295 + atomic_inc(&user->nr_msgs); 2296 + } else { 2297 + recv_msg = ipmi_alloc_recv_msg(user); 2298 + if (IS_ERR(recv_msg)) 2299 + return PTR_ERR(recv_msg); 2317 2300 } 2318 2301 recv_msg->user_msg_data = user_msg_data; 2319 2302 ··· 2317 2314 if (smi_msg == NULL) { 2318 2315 if (!supplied_recv) 2319 2316 ipmi_free_recv_msg(recv_msg); 2320 - rv = -ENOMEM; 2321 - goto out; 2317 + return -ENOMEM; 2322 2318 } 2323 2319 } 2324 2320 2325 2321 if (!run_to_completion) 2326 2322 mutex_lock(&intf->users_mutex); 2323 + if (intf->maintenance_mode_state == IPMI_MAINTENANCE_MODE_STATE_RESET) { 2324 + /* No messages while the BMC is in reset. */ 2325 + rv = -EBUSY; 2326 + goto out_err; 2327 + } 2327 2328 if (intf->in_shutdown) { 2328 2329 rv = -ENODEV; 2329 2330 goto out_err; 2330 2331 } 2331 2332 2332 - recv_msg->user = user; 2333 - if (user) 2334 - /* The put happens when the message is freed. */ 2335 - kref_get(&user->refcount); 2336 2333 recv_msg->msgid = msgid; 2337 2334 /* 2338 2335 * Store the message to send in the receive message so timeout ··· 2361 2358 2362 2359 if (rv) { 2363 2360 out_err: 2364 - ipmi_free_smi_msg(smi_msg); 2365 - ipmi_free_recv_msg(recv_msg); 2361 + if (!supplied_smi) 2362 + ipmi_free_smi_msg(smi_msg); 2363 + if (!supplied_recv) 2364 + ipmi_free_recv_msg(recv_msg); 2366 2365 } else { 2367 2366 dev_dbg(intf->si_dev, "Send: %*ph\n", 2368 2367 smi_msg->data_size, smi_msg->data); ··· 2374 2369 if (!run_to_completion) 2375 2370 mutex_unlock(&intf->users_mutex); 2376 2371 2377 - out: 2378 - if (rv && user) 2379 - atomic_dec(&user->nr_msgs); 2380 2372 return rv; 2381 2373 } 2382 2374 ··· 2623 2621 if (intf->in_bmc_register || 2624 2622 (bmc->dyn_id_set && time_is_after_jiffies(bmc->dyn_id_expiry))) 2625 2623 goto out_noprocessing; 2624 + 2625 + /* Don't allow sysfs access when in maintenance mode. */ 2626 + if (intf->maintenance_mode_state) { 2627 + rv = -EBUSY; 2628 + goto out_noprocessing; 2629 + } 2626 2630 2627 2631 prev_guid_set = bmc->dyn_guid_set; 2628 2632 __get_guid(intf); ··· 3525 3517 } 3526 3518 static DEVICE_ATTR_RO(nr_msgs); 3527 3519 3520 + static ssize_t maintenance_mode_show(struct device *dev, 3521 + struct device_attribute *attr, 3522 + char *buf) 3523 + { 3524 + struct ipmi_smi *intf = container_of(attr, 3525 + struct ipmi_smi, 3526 + maintenance_mode_devattr); 3527 + 3528 + return sysfs_emit(buf, "%u %d\n", intf->maintenance_mode_state, 3529 + intf->auto_maintenance_timeout); 3530 + } 3531 + static DEVICE_ATTR_RO(maintenance_mode); 3532 + 3528 3533 static void redo_bmc_reg(struct work_struct *work) 3529 3534 { 3530 3535 struct ipmi_smi *intf = container_of(work, struct ipmi_smi, ··· 3596 3575 atomic_set(&intf->nr_users, 0); 3597 3576 intf->handlers = handlers; 3598 3577 intf->send_info = send_info; 3599 - spin_lock_init(&intf->seq_lock); 3578 + mutex_init(&intf->seq_lock); 3600 3579 for (j = 0; j < IPMI_IPMB_NUM_SEQ; j++) { 3601 3580 intf->seq_table[j].inuse = 0; 3602 3581 intf->seq_table[j].seqid = 0; ··· 3669 3648 intf->nr_msgs_devattr = dev_attr_nr_msgs; 3670 3649 sysfs_attr_init(&intf->nr_msgs_devattr.attr); 3671 3650 rv = device_create_file(intf->si_dev, &intf->nr_msgs_devattr); 3651 + if (rv) { 3652 + device_remove_file(intf->si_dev, &intf->nr_users_devattr); 3653 + goto out_err_bmc_reg; 3654 + } 3655 + 3656 + intf->maintenance_mode_devattr = dev_attr_maintenance_mode; 3657 + sysfs_attr_init(&intf->maintenance_mode_devattr.attr); 3658 + rv = device_create_file(intf->si_dev, &intf->maintenance_mode_devattr); 3672 3659 if (rv) { 3673 3660 device_remove_file(intf->si_dev, &intf->nr_users_devattr); 3674 3661 goto out_err_bmc_reg; ··· 3789 3760 if (intf->handlers->shutdown) 3790 3761 intf->handlers->shutdown(intf->send_info); 3791 3762 3763 + device_remove_file(intf->si_dev, &intf->maintenance_mode_devattr); 3792 3764 device_remove_file(intf->si_dev, &intf->nr_msgs_devattr); 3793 3765 device_remove_file(intf->si_dev, &intf->nr_users_devattr); 3794 3766 ··· 3892 3862 unsigned char chan; 3893 3863 struct ipmi_user *user = NULL; 3894 3864 struct ipmi_ipmb_addr *ipmb_addr; 3895 - struct ipmi_recv_msg *recv_msg; 3865 + struct ipmi_recv_msg *recv_msg = NULL; 3896 3866 3897 3867 if (msg->rsp_size < 10) { 3898 3868 /* Message not big enough, just ignore it. */ ··· 3913 3883 rcvr = find_cmd_rcvr(intf, netfn, cmd, chan); 3914 3884 if (rcvr) { 3915 3885 user = rcvr->user; 3916 - kref_get(&user->refcount); 3917 - } else 3918 - user = NULL; 3886 + recv_msg = ipmi_alloc_recv_msg(user); 3887 + } 3919 3888 rcu_read_unlock(); 3920 3889 3921 3890 if (user == NULL) { ··· 3944 3915 * causes it to not be freed or queued. 3945 3916 */ 3946 3917 rv = -1; 3918 + } else if (!IS_ERR(recv_msg)) { 3919 + /* Extract the source address from the data. */ 3920 + ipmb_addr = (struct ipmi_ipmb_addr *) &recv_msg->addr; 3921 + ipmb_addr->addr_type = IPMI_IPMB_ADDR_TYPE; 3922 + ipmb_addr->slave_addr = msg->rsp[6]; 3923 + ipmb_addr->lun = msg->rsp[7] & 3; 3924 + ipmb_addr->channel = msg->rsp[3] & 0xf; 3925 + 3926 + /* 3927 + * Extract the rest of the message information 3928 + * from the IPMB header. 3929 + */ 3930 + recv_msg->recv_type = IPMI_CMD_RECV_TYPE; 3931 + recv_msg->msgid = msg->rsp[7] >> 2; 3932 + recv_msg->msg.netfn = msg->rsp[4] >> 2; 3933 + recv_msg->msg.cmd = msg->rsp[8]; 3934 + recv_msg->msg.data = recv_msg->msg_data; 3935 + 3936 + /* 3937 + * We chop off 10, not 9 bytes because the checksum 3938 + * at the end also needs to be removed. 3939 + */ 3940 + recv_msg->msg.data_len = msg->rsp_size - 10; 3941 + memcpy(recv_msg->msg_data, &msg->rsp[9], 3942 + msg->rsp_size - 10); 3943 + if (deliver_response(intf, recv_msg)) 3944 + ipmi_inc_stat(intf, unhandled_commands); 3945 + else 3946 + ipmi_inc_stat(intf, handled_commands); 3947 3947 } else { 3948 - recv_msg = ipmi_alloc_recv_msg(); 3949 - if (!recv_msg) { 3950 - /* 3951 - * We couldn't allocate memory for the 3952 - * message, so requeue it for handling 3953 - * later. 3954 - */ 3955 - rv = 1; 3956 - kref_put(&user->refcount, free_ipmi_user); 3957 - } else { 3958 - /* Extract the source address from the data. */ 3959 - ipmb_addr = (struct ipmi_ipmb_addr *) &recv_msg->addr; 3960 - ipmb_addr->addr_type = IPMI_IPMB_ADDR_TYPE; 3961 - ipmb_addr->slave_addr = msg->rsp[6]; 3962 - ipmb_addr->lun = msg->rsp[7] & 3; 3963 - ipmb_addr->channel = msg->rsp[3] & 0xf; 3964 - 3965 - /* 3966 - * Extract the rest of the message information 3967 - * from the IPMB header. 3968 - */ 3969 - recv_msg->user = user; 3970 - recv_msg->recv_type = IPMI_CMD_RECV_TYPE; 3971 - recv_msg->msgid = msg->rsp[7] >> 2; 3972 - recv_msg->msg.netfn = msg->rsp[4] >> 2; 3973 - recv_msg->msg.cmd = msg->rsp[8]; 3974 - recv_msg->msg.data = recv_msg->msg_data; 3975 - 3976 - /* 3977 - * We chop off 10, not 9 bytes because the checksum 3978 - * at the end also needs to be removed. 3979 - */ 3980 - recv_msg->msg.data_len = msg->rsp_size - 10; 3981 - memcpy(recv_msg->msg_data, &msg->rsp[9], 3982 - msg->rsp_size - 10); 3983 - if (deliver_response(intf, recv_msg)) 3984 - ipmi_inc_stat(intf, unhandled_commands); 3985 - else 3986 - ipmi_inc_stat(intf, handled_commands); 3987 - } 3948 + /* 3949 + * We couldn't allocate memory for the message, so 3950 + * requeue it for handling later. 3951 + */ 3952 + rv = 1; 3988 3953 } 3989 3954 3990 3955 return rv; ··· 3991 3968 int rv = 0; 3992 3969 struct ipmi_user *user = NULL; 3993 3970 struct ipmi_ipmb_direct_addr *daddr; 3994 - struct ipmi_recv_msg *recv_msg; 3971 + struct ipmi_recv_msg *recv_msg = NULL; 3995 3972 unsigned char netfn = msg->rsp[0] >> 2; 3996 3973 unsigned char cmd = msg->rsp[3]; 3997 3974 ··· 4000 3977 rcvr = find_cmd_rcvr(intf, netfn, cmd, 0); 4001 3978 if (rcvr) { 4002 3979 user = rcvr->user; 4003 - kref_get(&user->refcount); 4004 - } else 4005 - user = NULL; 3980 + recv_msg = ipmi_alloc_recv_msg(user); 3981 + } 4006 3982 rcu_read_unlock(); 4007 3983 4008 3984 if (user == NULL) { ··· 4023 4001 * causes it to not be freed or queued. 4024 4002 */ 4025 4003 rv = -1; 4004 + } else if (!IS_ERR(recv_msg)) { 4005 + /* Extract the source address from the data. */ 4006 + daddr = (struct ipmi_ipmb_direct_addr *)&recv_msg->addr; 4007 + daddr->addr_type = IPMI_IPMB_DIRECT_ADDR_TYPE; 4008 + daddr->channel = 0; 4009 + daddr->slave_addr = msg->rsp[1]; 4010 + daddr->rs_lun = msg->rsp[0] & 3; 4011 + daddr->rq_lun = msg->rsp[2] & 3; 4012 + 4013 + /* 4014 + * Extract the rest of the message information 4015 + * from the IPMB header. 4016 + */ 4017 + recv_msg->recv_type = IPMI_CMD_RECV_TYPE; 4018 + recv_msg->msgid = (msg->rsp[2] >> 2); 4019 + recv_msg->msg.netfn = msg->rsp[0] >> 2; 4020 + recv_msg->msg.cmd = msg->rsp[3]; 4021 + recv_msg->msg.data = recv_msg->msg_data; 4022 + 4023 + recv_msg->msg.data_len = msg->rsp_size - 4; 4024 + memcpy(recv_msg->msg_data, msg->rsp + 4, 4025 + msg->rsp_size - 4); 4026 + if (deliver_response(intf, recv_msg)) 4027 + ipmi_inc_stat(intf, unhandled_commands); 4028 + else 4029 + ipmi_inc_stat(intf, handled_commands); 4026 4030 } else { 4027 - recv_msg = ipmi_alloc_recv_msg(); 4028 - if (!recv_msg) { 4029 - /* 4030 - * We couldn't allocate memory for the 4031 - * message, so requeue it for handling 4032 - * later. 4033 - */ 4034 - rv = 1; 4035 - kref_put(&user->refcount, free_ipmi_user); 4036 - } else { 4037 - /* Extract the source address from the data. */ 4038 - daddr = (struct ipmi_ipmb_direct_addr *)&recv_msg->addr; 4039 - daddr->addr_type = IPMI_IPMB_DIRECT_ADDR_TYPE; 4040 - daddr->channel = 0; 4041 - daddr->slave_addr = msg->rsp[1]; 4042 - daddr->rs_lun = msg->rsp[0] & 3; 4043 - daddr->rq_lun = msg->rsp[2] & 3; 4044 - 4045 - /* 4046 - * Extract the rest of the message information 4047 - * from the IPMB header. 4048 - */ 4049 - recv_msg->user = user; 4050 - recv_msg->recv_type = IPMI_CMD_RECV_TYPE; 4051 - recv_msg->msgid = (msg->rsp[2] >> 2); 4052 - recv_msg->msg.netfn = msg->rsp[0] >> 2; 4053 - recv_msg->msg.cmd = msg->rsp[3]; 4054 - recv_msg->msg.data = recv_msg->msg_data; 4055 - 4056 - recv_msg->msg.data_len = msg->rsp_size - 4; 4057 - memcpy(recv_msg->msg_data, msg->rsp + 4, 4058 - msg->rsp_size - 4); 4059 - if (deliver_response(intf, recv_msg)) 4060 - ipmi_inc_stat(intf, unhandled_commands); 4061 - else 4062 - ipmi_inc_stat(intf, handled_commands); 4063 - } 4031 + /* 4032 + * We couldn't allocate memory for the message, so 4033 + * requeue it for handling later. 4034 + */ 4035 + rv = 1; 4064 4036 } 4065 4037 4066 4038 return rv; ··· 4066 4050 struct ipmi_recv_msg *recv_msg; 4067 4051 struct ipmi_ipmb_direct_addr *daddr; 4068 4052 4069 - recv_msg = msg->user_data; 4053 + recv_msg = msg->recv_msg; 4070 4054 if (recv_msg == NULL) { 4071 4055 dev_warn(intf->si_dev, 4072 4056 "IPMI direct message received with no owner. This could be because of a malformed message, or because of a hardware error. Contact your hardware vendor for assistance.\n"); ··· 4168 4152 unsigned char chan; 4169 4153 struct ipmi_user *user = NULL; 4170 4154 struct ipmi_lan_addr *lan_addr; 4171 - struct ipmi_recv_msg *recv_msg; 4155 + struct ipmi_recv_msg *recv_msg = NULL; 4172 4156 4173 4157 if (msg->rsp_size < 12) { 4174 4158 /* Message not big enough, just ignore it. */ ··· 4189 4173 rcvr = find_cmd_rcvr(intf, netfn, cmd, chan); 4190 4174 if (rcvr) { 4191 4175 user = rcvr->user; 4192 - kref_get(&user->refcount); 4193 - } else 4194 - user = NULL; 4176 + recv_msg = ipmi_alloc_recv_msg(user); 4177 + } 4195 4178 rcu_read_unlock(); 4196 4179 4197 4180 if (user == NULL) { ··· 4221 4206 * causes it to not be freed or queued. 4222 4207 */ 4223 4208 rv = -1; 4209 + } else if (!IS_ERR(recv_msg)) { 4210 + /* Extract the source address from the data. */ 4211 + lan_addr = (struct ipmi_lan_addr *) &recv_msg->addr; 4212 + lan_addr->addr_type = IPMI_LAN_ADDR_TYPE; 4213 + lan_addr->session_handle = msg->rsp[4]; 4214 + lan_addr->remote_SWID = msg->rsp[8]; 4215 + lan_addr->local_SWID = msg->rsp[5]; 4216 + lan_addr->lun = msg->rsp[9] & 3; 4217 + lan_addr->channel = msg->rsp[3] & 0xf; 4218 + lan_addr->privilege = msg->rsp[3] >> 4; 4219 + 4220 + /* 4221 + * Extract the rest of the message information 4222 + * from the IPMB header. 4223 + */ 4224 + recv_msg->recv_type = IPMI_CMD_RECV_TYPE; 4225 + recv_msg->msgid = msg->rsp[9] >> 2; 4226 + recv_msg->msg.netfn = msg->rsp[6] >> 2; 4227 + recv_msg->msg.cmd = msg->rsp[10]; 4228 + recv_msg->msg.data = recv_msg->msg_data; 4229 + 4230 + /* 4231 + * We chop off 12, not 11 bytes because the checksum 4232 + * at the end also needs to be removed. 4233 + */ 4234 + recv_msg->msg.data_len = msg->rsp_size - 12; 4235 + memcpy(recv_msg->msg_data, &msg->rsp[11], 4236 + msg->rsp_size - 12); 4237 + if (deliver_response(intf, recv_msg)) 4238 + ipmi_inc_stat(intf, unhandled_commands); 4239 + else 4240 + ipmi_inc_stat(intf, handled_commands); 4224 4241 } else { 4225 - recv_msg = ipmi_alloc_recv_msg(); 4226 - if (!recv_msg) { 4227 - /* 4228 - * We couldn't allocate memory for the 4229 - * message, so requeue it for handling later. 4230 - */ 4231 - rv = 1; 4232 - kref_put(&user->refcount, free_ipmi_user); 4233 - } else { 4234 - /* Extract the source address from the data. */ 4235 - lan_addr = (struct ipmi_lan_addr *) &recv_msg->addr; 4236 - lan_addr->addr_type = IPMI_LAN_ADDR_TYPE; 4237 - lan_addr->session_handle = msg->rsp[4]; 4238 - lan_addr->remote_SWID = msg->rsp[8]; 4239 - lan_addr->local_SWID = msg->rsp[5]; 4240 - lan_addr->lun = msg->rsp[9] & 3; 4241 - lan_addr->channel = msg->rsp[3] & 0xf; 4242 - lan_addr->privilege = msg->rsp[3] >> 4; 4243 - 4244 - /* 4245 - * Extract the rest of the message information 4246 - * from the IPMB header. 4247 - */ 4248 - recv_msg->user = user; 4249 - recv_msg->recv_type = IPMI_CMD_RECV_TYPE; 4250 - recv_msg->msgid = msg->rsp[9] >> 2; 4251 - recv_msg->msg.netfn = msg->rsp[6] >> 2; 4252 - recv_msg->msg.cmd = msg->rsp[10]; 4253 - recv_msg->msg.data = recv_msg->msg_data; 4254 - 4255 - /* 4256 - * We chop off 12, not 11 bytes because the checksum 4257 - * at the end also needs to be removed. 4258 - */ 4259 - recv_msg->msg.data_len = msg->rsp_size - 12; 4260 - memcpy(recv_msg->msg_data, &msg->rsp[11], 4261 - msg->rsp_size - 12); 4262 - if (deliver_response(intf, recv_msg)) 4263 - ipmi_inc_stat(intf, unhandled_commands); 4264 - else 4265 - ipmi_inc_stat(intf, handled_commands); 4266 - } 4242 + /* 4243 + * We couldn't allocate memory for the message, so 4244 + * requeue it for handling later. 4245 + */ 4246 + rv = 1; 4267 4247 } 4268 4248 4269 4249 return rv; ··· 4280 4270 unsigned char chan; 4281 4271 struct ipmi_user *user = NULL; 4282 4272 struct ipmi_system_interface_addr *smi_addr; 4283 - struct ipmi_recv_msg *recv_msg; 4273 + struct ipmi_recv_msg *recv_msg = NULL; 4284 4274 4285 4275 /* 4286 4276 * We expect the OEM SW to perform error checking ··· 4309 4299 rcvr = find_cmd_rcvr(intf, netfn, cmd, chan); 4310 4300 if (rcvr) { 4311 4301 user = rcvr->user; 4312 - kref_get(&user->refcount); 4313 - } else 4314 - user = NULL; 4302 + recv_msg = ipmi_alloc_recv_msg(user); 4303 + } 4315 4304 rcu_read_unlock(); 4316 4305 4317 4306 if (user == NULL) { ··· 4323 4314 */ 4324 4315 4325 4316 rv = 0; 4317 + } else if (!IS_ERR(recv_msg)) { 4318 + /* 4319 + * OEM Messages are expected to be delivered via 4320 + * the system interface to SMS software. We might 4321 + * need to visit this again depending on OEM 4322 + * requirements 4323 + */ 4324 + smi_addr = ((struct ipmi_system_interface_addr *) 4325 + &recv_msg->addr); 4326 + smi_addr->addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; 4327 + smi_addr->channel = IPMI_BMC_CHANNEL; 4328 + smi_addr->lun = msg->rsp[0] & 3; 4329 + 4330 + recv_msg->user_msg_data = NULL; 4331 + recv_msg->recv_type = IPMI_OEM_RECV_TYPE; 4332 + recv_msg->msg.netfn = msg->rsp[0] >> 2; 4333 + recv_msg->msg.cmd = msg->rsp[1]; 4334 + recv_msg->msg.data = recv_msg->msg_data; 4335 + 4336 + /* 4337 + * The message starts at byte 4 which follows the 4338 + * Channel Byte in the "GET MESSAGE" command 4339 + */ 4340 + recv_msg->msg.data_len = msg->rsp_size - 4; 4341 + memcpy(recv_msg->msg_data, &msg->rsp[4], 4342 + msg->rsp_size - 4); 4343 + if (deliver_response(intf, recv_msg)) 4344 + ipmi_inc_stat(intf, unhandled_commands); 4345 + else 4346 + ipmi_inc_stat(intf, handled_commands); 4326 4347 } else { 4327 - recv_msg = ipmi_alloc_recv_msg(); 4328 - if (!recv_msg) { 4329 - /* 4330 - * We couldn't allocate memory for the 4331 - * message, so requeue it for handling 4332 - * later. 4333 - */ 4334 - rv = 1; 4335 - kref_put(&user->refcount, free_ipmi_user); 4336 - } else { 4337 - /* 4338 - * OEM Messages are expected to be delivered via 4339 - * the system interface to SMS software. We might 4340 - * need to visit this again depending on OEM 4341 - * requirements 4342 - */ 4343 - smi_addr = ((struct ipmi_system_interface_addr *) 4344 - &recv_msg->addr); 4345 - smi_addr->addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; 4346 - smi_addr->channel = IPMI_BMC_CHANNEL; 4347 - smi_addr->lun = msg->rsp[0] & 3; 4348 - 4349 - recv_msg->user = user; 4350 - recv_msg->user_msg_data = NULL; 4351 - recv_msg->recv_type = IPMI_OEM_RECV_TYPE; 4352 - recv_msg->msg.netfn = msg->rsp[0] >> 2; 4353 - recv_msg->msg.cmd = msg->rsp[1]; 4354 - recv_msg->msg.data = recv_msg->msg_data; 4355 - 4356 - /* 4357 - * The message starts at byte 4 which follows the 4358 - * Channel Byte in the "GET MESSAGE" command 4359 - */ 4360 - recv_msg->msg.data_len = msg->rsp_size - 4; 4361 - memcpy(recv_msg->msg_data, &msg->rsp[4], 4362 - msg->rsp_size - 4); 4363 - if (deliver_response(intf, recv_msg)) 4364 - ipmi_inc_stat(intf, unhandled_commands); 4365 - else 4366 - ipmi_inc_stat(intf, handled_commands); 4367 - } 4348 + /* 4349 + * We couldn't allocate memory for the message, so 4350 + * requeue it for handling later. 4351 + */ 4352 + rv = 1; 4368 4353 } 4369 4354 4370 4355 return rv; ··· 4416 4413 if (!user->gets_events) 4417 4414 continue; 4418 4415 4419 - recv_msg = ipmi_alloc_recv_msg(); 4420 - if (!recv_msg) { 4416 + recv_msg = ipmi_alloc_recv_msg(user); 4417 + if (IS_ERR(recv_msg)) { 4421 4418 mutex_unlock(&intf->users_mutex); 4422 4419 list_for_each_entry_safe(recv_msg, recv_msg2, &msgs, 4423 4420 link) { ··· 4438 4435 deliver_count++; 4439 4436 4440 4437 copy_event_into_recv_msg(recv_msg, msg); 4441 - recv_msg->user = user; 4442 - kref_get(&user->refcount); 4443 4438 list_add_tail(&recv_msg->link, &msgs); 4444 4439 } 4445 4440 mutex_unlock(&intf->users_mutex); ··· 4453 4452 * No one to receive the message, put it in queue if there's 4454 4453 * not already too many things in the queue. 4455 4454 */ 4456 - recv_msg = ipmi_alloc_recv_msg(); 4457 - if (!recv_msg) { 4455 + recv_msg = ipmi_alloc_recv_msg(NULL); 4456 + if (IS_ERR(recv_msg)) { 4458 4457 /* 4459 4458 * We couldn't allocate memory for the 4460 4459 * message, so requeue it for handling ··· 4489 4488 struct ipmi_recv_msg *recv_msg; 4490 4489 struct ipmi_system_interface_addr *smi_addr; 4491 4490 4492 - recv_msg = msg->user_data; 4491 + recv_msg = msg->recv_msg; 4493 4492 if (recv_msg == NULL) { 4494 4493 dev_warn(intf->si_dev, 4495 4494 "IPMI SMI message received with no owner. This could be because of a malformed message, or because of a hardware error. Contact your hardware vendor for assistance.\n"); ··· 4530 4529 4531 4530 if (msg->rsp_size < 2) { 4532 4531 /* Message is too small to be correct. */ 4533 - dev_warn(intf->si_dev, 4534 - "BMC returned too small a message for netfn %x cmd %x, got %d bytes\n", 4535 - (msg->data[0] >> 2) | 1, msg->data[1], msg->rsp_size); 4532 + dev_warn_ratelimited(intf->si_dev, 4533 + "BMC returned too small a message for netfn %x cmd %x, got %d bytes\n", 4534 + (msg->data[0] >> 2) | 1, 4535 + msg->data[1], msg->rsp_size); 4536 4536 4537 4537 return_unspecified: 4538 4538 /* Generate an error response for the message. */ ··· 4563 4561 } else if ((msg->data_size >= 2) 4564 4562 && (msg->data[0] == (IPMI_NETFN_APP_REQUEST << 2)) 4565 4563 && (msg->data[1] == IPMI_SEND_MSG_CMD) 4566 - && (msg->user_data == NULL)) { 4564 + && (msg->recv_msg == NULL)) { 4567 4565 4568 4566 if (intf->in_shutdown || intf->run_to_completion) 4569 4567 goto out; 4570 4568 4571 4569 /* 4572 4570 * This is the local response to a command send, start 4573 - * the timer for these. The user_data will not be 4571 + * the timer for these. The recv_msg will not be 4574 4572 * NULL if this is a response send, and we will let 4575 4573 * response sends just go through. 4576 4574 */ ··· 4630 4628 requeue = handle_ipmb_direct_rcv_rsp(intf, msg); 4631 4629 } else if ((msg->rsp[0] == ((IPMI_NETFN_APP_REQUEST|1) << 2)) 4632 4630 && (msg->rsp[1] == IPMI_SEND_MSG_CMD) 4633 - && (msg->user_data != NULL)) { 4631 + && (msg->recv_msg != NULL)) { 4634 4632 /* 4635 4633 * It's a response to a response we sent. For this we 4636 4634 * deliver a send message response to the user. ··· 4647 4645 cc = msg->rsp[2]; 4648 4646 4649 4647 process_response_response: 4650 - recv_msg = msg->user_data; 4648 + recv_msg = msg->recv_msg; 4651 4649 4652 4650 requeue = 0; 4653 4651 if (!recv_msg) ··· 4803 4801 int run_to_completion = READ_ONCE(intf->run_to_completion); 4804 4802 struct ipmi_smi_msg *newmsg = NULL; 4805 4803 struct ipmi_recv_msg *msg, *msg2; 4804 + int cc; 4806 4805 4807 4806 /* 4808 4807 * Start the next message if available. ··· 4812 4809 * because the lower layer is allowed to hold locks while calling 4813 4810 * message delivery. 4814 4811 */ 4815 - 4812 + restart: 4816 4813 if (!run_to_completion) 4817 4814 spin_lock_irqsave(&intf->xmit_msgs_lock, flags); 4818 4815 if (intf->curr_msg == NULL && !intf->in_shutdown) { ··· 4833 4830 if (!run_to_completion) 4834 4831 spin_unlock_irqrestore(&intf->xmit_msgs_lock, flags); 4835 4832 4836 - if (newmsg) 4837 - intf->handlers->sender(intf->send_info, newmsg); 4833 + if (newmsg) { 4834 + cc = intf->handlers->sender(intf->send_info, newmsg); 4835 + if (cc) { 4836 + if (newmsg->recv_msg) 4837 + deliver_err_response(intf, 4838 + newmsg->recv_msg, cc); 4839 + else 4840 + ipmi_free_smi_msg(newmsg); 4841 + goto restart; 4842 + } 4843 + } 4838 4844 4839 4845 handle_new_recv_msgs(intf); 4840 4846 ··· 4880 4868 4881 4869 list_del(&msg->link); 4882 4870 4883 - if (refcount_read(&user->destroyed) == 0) { 4871 + if (refcount_read(&user->destroyed) == 0) 4884 4872 ipmi_free_recv_msg(msg); 4885 - } else { 4886 - atomic_dec(&user->nr_msgs); 4873 + else 4887 4874 user->handler->ipmi_recv_hndl(msg, user->handler_data); 4888 - } 4889 4875 } 4890 4876 mutex_unlock(&intf->user_msgs_mutex); 4891 4877 ··· 4961 4951 static void check_msg_timeout(struct ipmi_smi *intf, struct seq_table *ent, 4962 4952 struct list_head *timeouts, 4963 4953 unsigned long timeout_period, 4964 - int slot, unsigned long *flags, 4965 - bool *need_timer) 4954 + int slot, bool *need_timer) 4966 4955 { 4967 4956 struct ipmi_recv_msg *msg; 4968 4957 ··· 5013 5004 return; 5014 5005 } 5015 5006 5016 - spin_unlock_irqrestore(&intf->seq_lock, *flags); 5007 + mutex_unlock(&intf->seq_lock); 5017 5008 5018 5009 /* 5019 5010 * Send the new message. We send with a zero ··· 5034 5025 } else 5035 5026 ipmi_free_smi_msg(smi_msg); 5036 5027 5037 - spin_lock_irqsave(&intf->seq_lock, *flags); 5028 + mutex_lock(&intf->seq_lock); 5038 5029 } 5039 5030 } 5040 5031 ··· 5061 5052 * list. 5062 5053 */ 5063 5054 INIT_LIST_HEAD(&timeouts); 5064 - spin_lock_irqsave(&intf->seq_lock, flags); 5055 + mutex_lock(&intf->seq_lock); 5065 5056 if (intf->ipmb_maintenance_mode_timeout) { 5066 5057 if (intf->ipmb_maintenance_mode_timeout <= timeout_period) 5067 5058 intf->ipmb_maintenance_mode_timeout = 0; ··· 5071 5062 for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) 5072 5063 check_msg_timeout(intf, &intf->seq_table[i], 5073 5064 &timeouts, timeout_period, i, 5074 - &flags, &need_timer); 5075 - spin_unlock_irqrestore(&intf->seq_lock, flags); 5065 + &need_timer); 5066 + mutex_unlock(&intf->seq_lock); 5076 5067 5077 5068 list_for_each_entry_safe(msg, msg2, &timeouts, link) 5078 5069 deliver_err_response(intf, msg, IPMI_TIMEOUT_COMPLETION_CODE); ··· 5092 5083 -= timeout_period; 5093 5084 if (!intf->maintenance_mode 5094 5085 && (intf->auto_maintenance_timeout <= 0)) { 5095 - intf->maintenance_mode_enable = false; 5086 + intf->maintenance_mode_state = 5087 + IPMI_MAINTENANCE_MODE_STATE_OFF; 5088 + intf->auto_maintenance_timeout = 0; 5096 5089 maintenance_mode_update(intf); 5097 5090 } 5098 5091 } ··· 5110 5099 static void ipmi_request_event(struct ipmi_smi *intf) 5111 5100 { 5112 5101 /* No event requests when in maintenance mode. */ 5113 - if (intf->maintenance_mode_enable) 5102 + if (intf->maintenance_mode_state) 5114 5103 return; 5115 5104 5116 5105 if (!intf->in_shutdown) 5117 5106 intf->handlers->request_events(intf->send_info); 5118 5107 } 5119 - 5120 - static struct timer_list ipmi_timer; 5121 5108 5122 5109 static atomic_t stop_operation; 5123 5110 ··· 5140 5131 } 5141 5132 need_timer = true; 5142 5133 } 5134 + if (intf->maintenance_mode_state) 5135 + need_timer = true; 5143 5136 5144 5137 need_timer |= ipmi_timeout_handler(intf, IPMI_TIMEOUT_TIME); 5145 5138 } ··· 5185 5174 rv = kmalloc(sizeof(struct ipmi_smi_msg), GFP_ATOMIC); 5186 5175 if (rv) { 5187 5176 rv->done = free_smi_msg; 5188 - rv->user_data = NULL; 5177 + rv->recv_msg = NULL; 5189 5178 rv->type = IPMI_SMI_MSG_TYPE_NORMAL; 5190 5179 atomic_inc(&smi_msg_inuse_count); 5191 5180 } ··· 5201 5190 kfree(msg); 5202 5191 } 5203 5192 5204 - static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void) 5193 + static struct ipmi_recv_msg *ipmi_alloc_recv_msg(struct ipmi_user *user) 5205 5194 { 5206 5195 struct ipmi_recv_msg *rv; 5207 5196 5208 - rv = kmalloc(sizeof(struct ipmi_recv_msg), GFP_ATOMIC); 5209 - if (rv) { 5210 - rv->user = NULL; 5211 - rv->done = free_recv_msg; 5212 - atomic_inc(&recv_msg_inuse_count); 5197 + if (user) { 5198 + if (atomic_add_return(1, &user->nr_msgs) > max_msgs_per_user) { 5199 + atomic_dec(&user->nr_msgs); 5200 + return ERR_PTR(-EBUSY); 5201 + } 5213 5202 } 5203 + 5204 + rv = kmalloc(sizeof(struct ipmi_recv_msg), GFP_ATOMIC); 5205 + if (!rv) { 5206 + if (user) 5207 + atomic_dec(&user->nr_msgs); 5208 + return ERR_PTR(-ENOMEM); 5209 + } 5210 + 5211 + rv->user = user; 5212 + rv->done = free_recv_msg; 5213 + if (user) 5214 + kref_get(&user->refcount); 5215 + atomic_inc(&recv_msg_inuse_count); 5214 5216 return rv; 5215 5217 } 5216 5218 5217 5219 void ipmi_free_recv_msg(struct ipmi_recv_msg *msg) 5218 5220 { 5219 - if (msg->user && !oops_in_progress) 5221 + if (msg->user && !oops_in_progress) { 5222 + atomic_dec(&msg->user->nr_msgs); 5220 5223 kref_put(&msg->user->refcount, free_ipmi_user); 5224 + } 5221 5225 msg->done(msg); 5222 5226 } 5223 5227 EXPORT_SYMBOL(ipmi_free_recv_msg); 5228 + 5229 + static void ipmi_set_recv_msg_user(struct ipmi_recv_msg *msg, 5230 + struct ipmi_user *user) 5231 + { 5232 + WARN_ON_ONCE(msg->user); /* User should not be set. */ 5233 + msg->user = user; 5234 + atomic_inc(&user->nr_msgs); 5235 + kref_get(&user->refcount); 5236 + } 5224 5237 5225 5238 static atomic_t panic_done_count = ATOMIC_INIT(0); 5226 5239
+9 -8
drivers/char/ipmi/ipmi_powernv.c
··· 51 51 ipmi_smi_msg_received(smi->intf, msg); 52 52 } 53 53 54 - static void ipmi_powernv_send(void *send_info, struct ipmi_smi_msg *msg) 54 + static int ipmi_powernv_send(void *send_info, struct ipmi_smi_msg *msg) 55 55 { 56 56 struct ipmi_smi_powernv *smi = send_info; 57 57 struct opal_ipmi_msg *opal_msg; ··· 93 93 smi->interface_id, opal_msg, size); 94 94 rc = opal_ipmi_send(smi->interface_id, opal_msg, size); 95 95 pr_devel("%s: -> %d\n", __func__, rc); 96 - 97 - if (!rc) { 98 - smi->cur_msg = msg; 99 - spin_unlock_irqrestore(&smi->msg_lock, flags); 100 - return; 96 + if (rc) { 97 + comp = IPMI_ERR_UNSPECIFIED; 98 + goto err_unlock; 101 99 } 102 100 103 - comp = IPMI_ERR_UNSPECIFIED; 101 + smi->cur_msg = msg; 102 + spin_unlock_irqrestore(&smi->msg_lock, flags); 103 + return IPMI_CC_NO_ERROR; 104 + 104 105 err_unlock: 105 106 spin_unlock_irqrestore(&smi->msg_lock, flags); 106 107 err: 107 - send_error_reply(smi, msg, comp); 108 + return comp; 108 109 } 109 110 110 111 static int ipmi_powernv_recv(struct ipmi_smi_powernv *smi)
+7
drivers/char/ipmi/ipmi_si.h
··· 101 101 static inline void ipmi_si_pci_init(void) { } 102 102 static inline void ipmi_si_pci_shutdown(void) { } 103 103 #endif 104 + #ifdef CONFIG_IPMI_LS2K 105 + void ipmi_si_ls2k_init(void); 106 + void ipmi_si_ls2k_shutdown(void); 107 + #else 108 + static inline void ipmi_si_ls2k_init(void) { } 109 + static inline void ipmi_si_ls2k_shutdown(void) { } 110 + #endif 104 111 #ifdef CONFIG_PARISC 105 112 void ipmi_si_parisc_init(void); 106 113 void ipmi_si_parisc_shutdown(void);
+48 -26
drivers/char/ipmi/ipmi_si_intf.c
··· 53 53 #define SI_TIMEOUT_JIFFIES (SI_TIMEOUT_TIME_USEC/SI_USEC_PER_JIFFY) 54 54 #define SI_SHORT_TIMEOUT_USEC 250 /* .25ms when the SM request a 55 55 short timeout */ 56 + #define SI_TIMEOUT_HOSED (HZ) /* 1 second when in hosed state. */ 56 57 57 58 enum si_intf_state { 58 59 SI_NORMAL, ··· 62 61 SI_CLEARING_FLAGS, 63 62 SI_GETTING_MESSAGES, 64 63 SI_CHECKING_ENABLES, 65 - SI_SETTING_ENABLES 64 + SI_SETTING_ENABLES, 65 + SI_HOSED 66 66 /* FIXME - add watchdog stuff. */ 67 67 }; 68 68 ··· 315 313 316 314 static enum si_sm_result start_next_msg(struct smi_info *smi_info) 317 315 { 318 - int rv; 316 + int rv; 319 317 320 318 if (!smi_info->waiting_msg) { 321 319 smi_info->curr_msg = NULL; ··· 390 388 391 389 start_new_msg(smi_info, msg, 3); 392 390 smi_info->si_state = SI_CLEARING_FLAGS; 391 + } 392 + 393 + static void start_get_flags(struct smi_info *smi_info) 394 + { 395 + unsigned char msg[2]; 396 + 397 + msg[0] = (IPMI_NETFN_APP_REQUEST << 2); 398 + msg[1] = IPMI_GET_MSG_FLAGS_CMD; 399 + 400 + start_new_msg(smi_info, msg, 2); 401 + smi_info->si_state = SI_GETTING_FLAGS; 393 402 } 394 403 395 404 static void start_getting_msg_queue(struct smi_info *smi_info) ··· 755 742 } 756 743 break; 757 744 } 745 + case SI_HOSED: /* Shouldn't happen. */ 746 + break; 758 747 } 759 748 } 760 749 ··· 771 756 enum si_sm_result si_sm_result; 772 757 773 758 restart: 759 + if (smi_info->si_state == SI_HOSED) 760 + /* Just in case, hosed state is only left from the timeout. */ 761 + return SI_SM_HOSED; 762 + 774 763 /* 775 764 * There used to be a loop here that waited a little while 776 765 * (around 25us) before giving up. That turned out to be ··· 798 779 799 780 /* 800 781 * Do the before return_hosed_msg, because that 801 - * releases the lock. 782 + * releases the lock. We just disable operations for 783 + * a while and retry in hosed state. 802 784 */ 803 - smi_info->si_state = SI_NORMAL; 785 + smi_info->si_state = SI_HOSED; 804 786 if (smi_info->curr_msg != NULL) { 805 787 /* 806 788 * If we were handling a user message, format 807 789 * a response to send to the upper layer to 808 790 * tell it about the error. 809 791 */ 810 - return_hosed_msg(smi_info, IPMI_ERR_UNSPECIFIED); 792 + return_hosed_msg(smi_info, IPMI_BUS_ERR); 811 793 } 812 - goto restart; 794 + smi_mod_timer(smi_info, jiffies + SI_TIMEOUT_HOSED); 795 + goto out; 813 796 } 814 797 815 798 /* ··· 819 798 * this if there is not yet an upper layer to handle anything. 820 799 */ 821 800 if (si_sm_result == SI_SM_ATTN || smi_info->got_attn) { 822 - unsigned char msg[2]; 823 - 824 801 if (smi_info->si_state != SI_NORMAL) { 825 802 /* 826 803 * We got an ATTN, but we are doing something else. ··· 836 817 * interrupts work with the SMI, that's not really 837 818 * possible. 838 819 */ 839 - msg[0] = (IPMI_NETFN_APP_REQUEST << 2); 840 - msg[1] = IPMI_GET_MSG_FLAGS_CMD; 841 - 842 - start_new_msg(smi_info, msg, 2); 843 - smi_info->si_state = SI_GETTING_FLAGS; 820 + start_get_flags(smi_info); 844 821 goto restart; 845 822 } 846 823 } ··· 909 894 * mode. This means we are single-threaded, no need for locks. 910 895 */ 911 896 result = smi_event_handler(smi_info, 0); 912 - while (result != SI_SM_IDLE) { 897 + while (result != SI_SM_IDLE && result != SI_SM_HOSED) { 913 898 udelay(SI_SHORT_TIMEOUT_USEC); 914 899 result = smi_event_handler(smi_info, SI_SHORT_TIMEOUT_USEC); 915 900 } 916 901 } 917 902 918 - static void sender(void *send_info, 919 - struct ipmi_smi_msg *msg) 903 + static int sender(void *send_info, struct ipmi_smi_msg *msg) 920 904 { 921 905 struct smi_info *smi_info = send_info; 922 906 unsigned long flags; 923 907 924 908 debug_timestamp(smi_info, "Enqueue"); 909 + 910 + if (smi_info->si_state == SI_HOSED) 911 + return IPMI_BUS_ERR; 925 912 926 913 if (smi_info->run_to_completion) { 927 914 /* ··· 931 914 * layer will call flush_messages to clear it out. 932 915 */ 933 916 smi_info->waiting_msg = msg; 934 - return; 917 + return IPMI_CC_NO_ERROR; 935 918 } 936 919 937 920 spin_lock_irqsave(&smi_info->si_lock, flags); ··· 946 929 smi_info->waiting_msg = msg; 947 930 check_start_timer_thread(smi_info); 948 931 spin_unlock_irqrestore(&smi_info->si_lock, flags); 932 + return IPMI_CC_NO_ERROR; 949 933 } 950 934 951 935 static void set_run_to_completion(void *send_info, bool i_run_to_completion) ··· 1105 1087 spin_lock_irqsave(&(smi_info->si_lock), flags); 1106 1088 debug_timestamp(smi_info, "Timer"); 1107 1089 1090 + if (smi_info->si_state == SI_HOSED) 1091 + /* Try something to see if the BMC is now operational. */ 1092 + start_get_flags(smi_info); 1093 + 1108 1094 jiffies_now = jiffies; 1109 1095 time_diff = (((long)jiffies_now - (long)smi_info->last_timeout_jiffies) 1110 1096 * SI_USEC_PER_JIFFY); ··· 1118 1096 /* Running with interrupts, only do long timeouts. */ 1119 1097 timeout = jiffies + SI_TIMEOUT_JIFFIES; 1120 1098 smi_inc_stat(smi_info, long_timeouts); 1121 - goto do_mod_timer; 1122 - } 1123 - 1124 - /* 1125 - * If the state machine asks for a short delay, then shorten 1126 - * the timer timeout. 1127 - */ 1128 - if (smi_result == SI_SM_CALL_WITH_DELAY) { 1099 + } else if (smi_result == SI_SM_CALL_WITH_DELAY) { 1100 + /* 1101 + * If the state machine asks for a short delay, then shorten 1102 + * the timer timeout. 1103 + */ 1129 1104 smi_inc_stat(smi_info, short_timeouts); 1130 1105 timeout = jiffies + 1; 1131 1106 } else { ··· 1130 1111 timeout = jiffies + SI_TIMEOUT_JIFFIES; 1131 1112 } 1132 1113 1133 - do_mod_timer: 1134 1114 if (smi_result != SI_SM_IDLE) 1135 1115 smi_mod_timer(smi_info, timeout); 1136 1116 else ··· 2138 2120 2139 2121 ipmi_si_pci_init(); 2140 2122 2123 + ipmi_si_ls2k_init(); 2124 + 2141 2125 ipmi_si_parisc_init(); 2142 2126 2143 2127 mutex_lock(&smi_infos_lock); ··· 2350 2330 return; 2351 2331 2352 2332 ipmi_si_pci_shutdown(); 2333 + 2334 + ipmi_si_ls2k_shutdown(); 2353 2335 2354 2336 ipmi_si_parisc_shutdown(); 2355 2337
+189
drivers/char/ipmi/ipmi_si_ls2k.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * Driver for Loongson-2K BMC IPMI interface 4 + * 5 + * Copyright (C) 2024-2025 Loongson Technology Corporation Limited. 6 + * 7 + * Authors: 8 + * Chong Qiao <qiaochong@loongson.cn> 9 + * Binbin Zhou <zhoubinbin@loongson.cn> 10 + */ 11 + 12 + #include <linux/bitfield.h> 13 + #include <linux/ioport.h> 14 + #include <linux/module.h> 15 + #include <linux/types.h> 16 + 17 + #include "ipmi_si.h" 18 + 19 + #define LS2K_KCS_FIFO_IBFH 0x0 20 + #define LS2K_KCS_FIFO_IBFT 0x1 21 + #define LS2K_KCS_FIFO_OBFH 0x2 22 + #define LS2K_KCS_FIFO_OBFT 0x3 23 + 24 + /* KCS registers */ 25 + #define LS2K_KCS_REG_STS 0x4 26 + #define LS2K_KCS_REG_DATA_OUT 0x5 27 + #define LS2K_KCS_REG_DATA_IN 0x6 28 + #define LS2K_KCS_REG_CMD 0x8 29 + 30 + #define LS2K_KCS_CMD_DATA 0xa 31 + #define LS2K_KCS_VERSION 0xb 32 + #define LS2K_KCS_WR_REQ 0xc 33 + #define LS2K_KCS_WR_ACK 0x10 34 + 35 + #define LS2K_KCS_STS_OBF BIT(0) 36 + #define LS2K_KCS_STS_IBF BIT(1) 37 + #define LS2K_KCS_STS_SMS_ATN BIT(2) 38 + #define LS2K_KCS_STS_CMD BIT(3) 39 + 40 + #define LS2K_KCS_DATA_MASK (LS2K_KCS_STS_OBF | LS2K_KCS_STS_IBF | LS2K_KCS_STS_CMD) 41 + 42 + static bool ls2k_registered; 43 + 44 + static unsigned char ls2k_mem_inb_v0(const struct si_sm_io *io, unsigned int offset) 45 + { 46 + void __iomem *addr = io->addr; 47 + int reg_offset; 48 + 49 + if (offset & BIT(0)) { 50 + reg_offset = LS2K_KCS_REG_STS; 51 + } else { 52 + writeb(readb(addr + LS2K_KCS_REG_STS) & ~LS2K_KCS_STS_OBF, addr + LS2K_KCS_REG_STS); 53 + reg_offset = LS2K_KCS_REG_DATA_OUT; 54 + } 55 + 56 + return readb(addr + reg_offset); 57 + } 58 + 59 + static unsigned char ls2k_mem_inb_v1(const struct si_sm_io *io, unsigned int offset) 60 + { 61 + void __iomem *addr = io->addr; 62 + unsigned char inb = 0, cmd; 63 + bool obf, ibf; 64 + 65 + obf = readb(addr + LS2K_KCS_FIFO_OBFH) ^ readb(addr + LS2K_KCS_FIFO_OBFT); 66 + ibf = readb(addr + LS2K_KCS_FIFO_IBFH) ^ readb(addr + LS2K_KCS_FIFO_IBFT); 67 + cmd = readb(addr + LS2K_KCS_CMD_DATA); 68 + 69 + if (offset & BIT(0)) { 70 + inb = readb(addr + LS2K_KCS_REG_STS) & ~LS2K_KCS_DATA_MASK; 71 + inb |= FIELD_PREP(LS2K_KCS_STS_OBF, obf) 72 + | FIELD_PREP(LS2K_KCS_STS_IBF, ibf) 73 + | FIELD_PREP(LS2K_KCS_STS_CMD, cmd); 74 + } else { 75 + inb = readb(addr + LS2K_KCS_REG_DATA_OUT); 76 + writeb(readb(addr + LS2K_KCS_FIFO_OBFH), addr + LS2K_KCS_FIFO_OBFT); 77 + } 78 + 79 + return inb; 80 + } 81 + 82 + static void ls2k_mem_outb_v0(const struct si_sm_io *io, unsigned int offset, 83 + unsigned char val) 84 + { 85 + void __iomem *addr = io->addr; 86 + unsigned char sts = readb(addr + LS2K_KCS_REG_STS); 87 + int reg_offset; 88 + 89 + if (sts & LS2K_KCS_STS_IBF) 90 + return; 91 + 92 + if (offset & BIT(0)) { 93 + reg_offset = LS2K_KCS_REG_CMD; 94 + sts |= LS2K_KCS_STS_CMD; 95 + } else { 96 + reg_offset = LS2K_KCS_REG_DATA_IN; 97 + sts &= ~LS2K_KCS_STS_CMD; 98 + } 99 + 100 + writew(val, addr + reg_offset); 101 + writeb(sts | LS2K_KCS_STS_IBF, addr + LS2K_KCS_REG_STS); 102 + writel(readl(addr + LS2K_KCS_WR_REQ) + 1, addr + LS2K_KCS_WR_REQ); 103 + } 104 + 105 + static void ls2k_mem_outb_v1(const struct si_sm_io *io, unsigned int offset, 106 + unsigned char val) 107 + { 108 + void __iomem *addr = io->addr; 109 + unsigned char ibfh, ibft; 110 + int reg_offset; 111 + 112 + ibfh = readb(addr + LS2K_KCS_FIFO_IBFH); 113 + ibft = readb(addr + LS2K_KCS_FIFO_IBFT); 114 + 115 + if (ibfh ^ ibft) 116 + return; 117 + 118 + reg_offset = (offset & BIT(0)) ? LS2K_KCS_REG_CMD : LS2K_KCS_REG_DATA_IN; 119 + writew(val, addr + reg_offset); 120 + 121 + writeb(offset & BIT(0), addr + LS2K_KCS_CMD_DATA); 122 + writeb(!ibft, addr + LS2K_KCS_FIFO_IBFH); 123 + writel(readl(addr + LS2K_KCS_WR_REQ) + 1, addr + LS2K_KCS_WR_REQ); 124 + } 125 + 126 + static void ls2k_mem_cleanup(struct si_sm_io *io) 127 + { 128 + if (io->addr) 129 + iounmap(io->addr); 130 + } 131 + 132 + static int ipmi_ls2k_mem_setup(struct si_sm_io *io) 133 + { 134 + unsigned char version; 135 + 136 + io->addr = ioremap(io->addr_data, io->regspacing); 137 + if (!io->addr) 138 + return -EIO; 139 + 140 + version = readb(io->addr + LS2K_KCS_VERSION); 141 + 142 + io->inputb = version ? ls2k_mem_inb_v1 : ls2k_mem_inb_v0; 143 + io->outputb = version ? ls2k_mem_outb_v1 : ls2k_mem_outb_v0; 144 + io->io_cleanup = ls2k_mem_cleanup; 145 + 146 + return 0; 147 + } 148 + 149 + static int ipmi_ls2k_probe(struct platform_device *pdev) 150 + { 151 + struct si_sm_io io; 152 + 153 + memset(&io, 0, sizeof(io)); 154 + 155 + io.si_info = &ipmi_kcs_si_info; 156 + io.io_setup = ipmi_ls2k_mem_setup; 157 + io.addr_data = pdev->resource[0].start; 158 + io.regspacing = resource_size(&pdev->resource[0]); 159 + io.dev = &pdev->dev; 160 + 161 + dev_dbg(&pdev->dev, "addr 0x%lx, spacing %d.\n", io.addr_data, io.regspacing); 162 + 163 + return ipmi_si_add_smi(&io); 164 + } 165 + 166 + static void ipmi_ls2k_remove(struct platform_device *pdev) 167 + { 168 + ipmi_si_remove_by_dev(&pdev->dev); 169 + } 170 + 171 + struct platform_driver ipmi_ls2k_platform_driver = { 172 + .driver = { 173 + .name = "ls2k-ipmi-si", 174 + }, 175 + .probe = ipmi_ls2k_probe, 176 + .remove = ipmi_ls2k_remove, 177 + }; 178 + 179 + void ipmi_si_ls2k_init(void) 180 + { 181 + platform_driver_register(&ipmi_ls2k_platform_driver); 182 + ls2k_registered = true; 183 + } 184 + 185 + void ipmi_si_ls2k_shutdown(void) 186 + { 187 + if (ls2k_registered) 188 + platform_driver_unregister(&ipmi_ls2k_platform_driver); 189 + }
+2 -2
drivers/char/ipmi/ipmi_ssif.c
··· 1068 1068 } 1069 1069 } 1070 1070 1071 - static void sender(void *send_info, 1072 - struct ipmi_smi_msg *msg) 1071 + static int sender(void *send_info, struct ipmi_smi_msg *msg) 1073 1072 { 1074 1073 struct ssif_info *ssif_info = send_info; 1075 1074 unsigned long oflags, *flags; ··· 1088 1089 msg->data[0], msg->data[1], 1089 1090 (long long)t.tv_sec, (long)t.tv_nsec / NSEC_PER_USEC); 1090 1091 } 1092 + return IPMI_CC_NO_ERROR; 1091 1093 } 1092 1094 1093 1095 static int get_smi_info(void *send_info, struct ipmi_smi_info *data)
+7 -4
include/linux/ipmi_smi.h
··· 109 109 110 110 enum ipmi_smi_msg_type type; 111 111 112 - long msgid; 113 - void *user_data; 112 + long msgid; 113 + /* Response to this message, will be NULL if not from a user request. */ 114 + struct ipmi_recv_msg *recv_msg; 114 115 115 116 int data_size; 116 117 unsigned char data[IPMI_MAX_MSG_LENGTH]; ··· 169 168 * are held when this is run. Message are delivered one at 170 169 * a time by the message handler, a new message will not be 171 170 * delivered until the previous message is returned. 171 + * 172 + * This can return an error if the SMI is not in a state where it 173 + * can send a message. 172 174 */ 173 - void (*sender)(void *send_info, 174 - struct ipmi_smi_msg *msg); 175 + int (*sender)(void *send_info, struct ipmi_smi_msg *msg); 175 176 176 177 /* 177 178 * Called by the upper layer to request that we try to get