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-4.1-1' of git://git.code.sf.net/p/openipmi/linux-ipmi

Pull IPMI fixes from Corey Minyard:
"Lots of minor IPMI fixes, especially ones that have have come up since
the SSIF driver has been in the main kernel for a while"

* tag 'for-linus-4.1-1' of git://git.code.sf.net/p/openipmi/linux-ipmi:
ipmi: Fix multi-part message handling
ipmi: Add alert handling to SSIF
ipmi: Fix a problem that messages are not issued in run_to_completion mode
ipmi: Report an error if ACPI _IFT doesn't exist
ipmi: Remove unused including <linux/version.h>
ipmi: Don't report err in the SI driver for SSIF devices
ipmi: Remove incorrect use of seq_has_overflowed
ipmi:ssif: Ignore spaces when comparing I2C adapter names
ipmi_ssif: Fix the logic on user-supplied addresses

+193 -45
+4 -1
Documentation/IPMI.txt
··· 505 505 506 506 The addresses are normal I2C addresses. The adapter is the string 507 507 name of the adapter, as shown in /sys/class/i2c-adapter/i2c-<n>/name. 508 - It is *NOT* i2c-<n> itself. 508 + It is *NOT* i2c-<n> itself. Also, the comparison is done ignoring 509 + spaces, so if the name is "This is an I2C chip" you can say 510 + adapter_name=ThisisanI2cchip. This is because it's hard to pass in 511 + spaces in kernel parameters. 509 512 510 513 The debug flags are bit flags for each BMC found, they are: 511 514 IPMI messages: 1, driver state: 2, timing: 4, I2C probe: 8
+2 -2
drivers/char/ipmi/ipmi_msghandler.c
··· 2000 2000 seq_printf(m, " %x", intf->channels[i].address); 2001 2001 seq_putc(m, '\n'); 2002 2002 2003 - return seq_has_overflowed(m); 2003 + return 0; 2004 2004 } 2005 2005 2006 2006 static int smi_ipmb_proc_open(struct inode *inode, struct file *file) ··· 2023 2023 ipmi_version_major(&intf->bmc->id), 2024 2024 ipmi_version_minor(&intf->bmc->id)); 2025 2025 2026 - return seq_has_overflowed(m); 2026 + return 0; 2027 2027 } 2028 2028 2029 2029 static int smi_version_proc_open(struct inode *inode, struct file *file)
+9 -7
drivers/char/ipmi/ipmi_si_intf.c
··· 942 942 * If we are running to completion, start it and run 943 943 * transactions until everything is clear. 944 944 */ 945 - smi_info->curr_msg = msg; 946 - smi_info->waiting_msg = NULL; 945 + smi_info->waiting_msg = msg; 947 946 948 947 /* 949 948 * Run to completion means we are single-threaded, no ··· 2243 2244 acpi_handle handle; 2244 2245 acpi_status status; 2245 2246 unsigned long long tmp; 2246 - int rv; 2247 + int rv = -EINVAL; 2247 2248 2248 2249 acpi_dev = pnp_acpi_device(dev); 2249 2250 if (!acpi_dev) ··· 2261 2262 2262 2263 /* _IFT tells us the interface type: KCS, BT, etc */ 2263 2264 status = acpi_evaluate_integer(handle, "_IFT", NULL, &tmp); 2264 - if (ACPI_FAILURE(status)) 2265 + if (ACPI_FAILURE(status)) { 2266 + dev_err(&dev->dev, "Could not find ACPI IPMI interface type\n"); 2265 2267 goto err_free; 2268 + } 2266 2269 2267 2270 switch (tmp) { 2268 2271 case 1: ··· 2277 2276 info->si_type = SI_BT; 2278 2277 break; 2279 2278 case 4: /* SSIF, just ignore */ 2279 + rv = -ENODEV; 2280 2280 goto err_free; 2281 2281 default: 2282 2282 dev_info(&dev->dev, "unknown IPMI type %lld\n", tmp); ··· 2338 2336 2339 2337 err_free: 2340 2338 kfree(info); 2341 - return -EINVAL; 2339 + return rv; 2342 2340 } 2343 2341 2344 2342 static void ipmi_pnp_remove(struct pnp_dev *dev) ··· 3082 3080 3083 3081 seq_printf(m, "%s\n", si_to_str[smi->si_type]); 3084 3082 3085 - return seq_has_overflowed(m); 3083 + return 0; 3086 3084 } 3087 3085 3088 3086 static int smi_type_proc_open(struct inode *inode, struct file *file) ··· 3155 3153 smi->irq, 3156 3154 smi->slave_addr); 3157 3155 3158 - return seq_has_overflowed(m); 3156 + return 0; 3159 3157 } 3160 3158 3161 3159 static int smi_params_proc_open(struct inode *inode, struct file *file)
+178 -35
drivers/char/ipmi/ipmi_ssif.c
··· 31 31 * interface into the I2C driver, I believe. 32 32 */ 33 33 34 - #include <linux/version.h> 35 34 #if defined(MODVERSIONS) 36 35 #include <linux/modversions.h> 37 36 #endif ··· 165 166 /* Number of watchdog pretimeouts. */ 166 167 SSIF_STAT_watchdog_pretimeouts, 167 168 169 + /* Number of alers received. */ 170 + SSIF_STAT_alerts, 171 + 168 172 /* Always add statistics before this value, it must be last. */ 169 173 SSIF_NUM_STATS 170 174 }; ··· 216 214 #define WDT_PRE_TIMEOUT_INT 0x08 217 215 unsigned char msg_flags; 218 216 217 + u8 global_enables; 219 218 bool has_event_buffer; 219 + bool supports_alert; 220 + 221 + /* 222 + * Used to tell what we should do with alerts. If we are 223 + * waiting on a response, read the data immediately. 224 + */ 225 + bool got_alert; 226 + bool waiting_alert; 220 227 221 228 /* 222 229 * If set to true, this will request events the next time the ··· 489 478 490 479 if (ssif_info->i2c_read_write == I2C_SMBUS_WRITE) { 491 480 result = i2c_smbus_write_block_data( 492 - ssif_info->client, SSIF_IPMI_REQUEST, 481 + ssif_info->client, ssif_info->i2c_command, 493 482 ssif_info->i2c_data[0], 494 483 ssif_info->i2c_data + 1); 495 484 ssif_info->done_handler(ssif_info, result, NULL, 0); 496 485 } else { 497 486 result = i2c_smbus_read_block_data( 498 - ssif_info->client, SSIF_IPMI_RESPONSE, 487 + ssif_info->client, ssif_info->i2c_command, 499 488 ssif_info->i2c_data); 500 489 if (result < 0) 501 490 ssif_info->done_handler(ssif_info, result, ··· 529 518 static void msg_done_handler(struct ssif_info *ssif_info, int result, 530 519 unsigned char *data, unsigned int len); 531 520 532 - static void retry_timeout(unsigned long data) 521 + static void start_get(struct ssif_info *ssif_info) 533 522 { 534 - struct ssif_info *ssif_info = (void *) data; 535 523 int rv; 536 524 537 - if (ssif_info->stopping) 538 - return; 539 - 540 525 ssif_info->rtc_us_timer = 0; 526 + ssif_info->multi_pos = 0; 541 527 542 528 rv = ssif_i2c_send(ssif_info, msg_done_handler, I2C_SMBUS_READ, 543 529 SSIF_IPMI_RESPONSE, ··· 546 538 547 539 msg_done_handler(ssif_info, -EIO, NULL, 0); 548 540 } 541 + } 542 + 543 + static void retry_timeout(unsigned long data) 544 + { 545 + struct ssif_info *ssif_info = (void *) data; 546 + unsigned long oflags, *flags; 547 + bool waiting; 548 + 549 + if (ssif_info->stopping) 550 + return; 551 + 552 + flags = ipmi_ssif_lock_cond(ssif_info, &oflags); 553 + waiting = ssif_info->waiting_alert; 554 + ssif_info->waiting_alert = false; 555 + ipmi_ssif_unlock_cond(ssif_info, flags); 556 + 557 + if (waiting) 558 + start_get(ssif_info); 559 + } 560 + 561 + 562 + static void ssif_alert(struct i2c_client *client, unsigned int data) 563 + { 564 + struct ssif_info *ssif_info = i2c_get_clientdata(client); 565 + unsigned long oflags, *flags; 566 + bool do_get = false; 567 + 568 + ssif_inc_stat(ssif_info, alerts); 569 + 570 + flags = ipmi_ssif_lock_cond(ssif_info, &oflags); 571 + if (ssif_info->waiting_alert) { 572 + ssif_info->waiting_alert = false; 573 + del_timer(&ssif_info->retry_timer); 574 + do_get = true; 575 + } else if (ssif_info->curr_msg) { 576 + ssif_info->got_alert = true; 577 + } 578 + ipmi_ssif_unlock_cond(ssif_info, flags); 579 + if (do_get) 580 + start_get(ssif_info); 549 581 } 550 582 551 583 static int start_resend(struct ssif_info *ssif_info); ··· 607 559 if (ssif_info->retries_left > 0) { 608 560 ssif_inc_stat(ssif_info, receive_retries); 609 561 562 + flags = ipmi_ssif_lock_cond(ssif_info, &oflags); 563 + ssif_info->waiting_alert = true; 564 + ssif_info->rtc_us_timer = SSIF_MSG_USEC; 610 565 mod_timer(&ssif_info->retry_timer, 611 566 jiffies + SSIF_MSG_JIFFIES); 612 - ssif_info->rtc_us_timer = SSIF_MSG_USEC; 567 + ipmi_ssif_unlock_cond(ssif_info, flags); 613 568 return; 614 569 } 615 570 ··· 632 581 ssif_inc_stat(ssif_info, received_message_parts); 633 582 634 583 /* Remove the multi-part read marker. */ 635 - for (i = 0; i < (len-2); i++) 636 - ssif_info->data[i] = data[i+2]; 637 584 len -= 2; 585 + for (i = 0; i < len; i++) 586 + ssif_info->data[i] = data[i+2]; 638 587 ssif_info->multi_len = len; 639 588 ssif_info->multi_pos = 1; 640 589 ··· 661 610 goto continue_op; 662 611 } 663 612 664 - blocknum = data[ssif_info->multi_len]; 613 + blocknum = data[0]; 665 614 666 - if (ssif_info->multi_len+len-1 > IPMI_MAX_MSG_LENGTH) { 615 + if (ssif_info->multi_len + len - 1 > IPMI_MAX_MSG_LENGTH) { 667 616 /* Received message too big, abort the operation. */ 668 617 result = -E2BIG; 669 618 if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) ··· 673 622 } 674 623 675 624 /* Remove the blocknum from the data. */ 676 - for (i = 0; i < (len-1); i++) 677 - ssif_info->data[i+ssif_info->multi_len] = data[i+1]; 678 625 len--; 626 + for (i = 0; i < len; i++) 627 + ssif_info->data[i + ssif_info->multi_len] = data[i + 1]; 679 628 ssif_info->multi_len += len; 680 629 if (blocknum == 0xff) { 681 630 /* End of read */ 682 631 len = ssif_info->multi_len; 683 632 data = ssif_info->data; 684 - } else if ((blocknum+1) != ssif_info->multi_pos) { 633 + } else if (blocknum + 1 != ssif_info->multi_pos) { 685 634 /* 686 635 * Out of sequence block, just abort. Block 687 636 * numbers start at zero for the second block, ··· 701 650 if (rv < 0) { 702 651 if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) 703 652 pr_info(PFX 704 - "Error from i2c_non_blocking_op(2)\n"); 653 + "Error from ssif_i2c_send\n"); 705 654 706 655 result = -EIO; 707 656 } else ··· 881 830 } 882 831 883 832 if (ssif_info->multi_data) { 884 - /* In the middle of a multi-data write. */ 833 + /* 834 + * In the middle of a multi-data write. See the comment 835 + * in the SSIF_MULTI_n_PART case in the probe function 836 + * for details on the intricacies of this. 837 + */ 885 838 int left; 886 839 887 840 ssif_inc_stat(ssif_info, sent_messages_parts); ··· 919 864 msg_done_handler(ssif_info, -EIO, NULL, 0); 920 865 } 921 866 } else { 867 + unsigned long oflags, *flags; 868 + bool got_alert; 869 + 922 870 ssif_inc_stat(ssif_info, sent_messages); 923 871 ssif_inc_stat(ssif_info, sent_messages_parts); 924 872 925 - /* Wait a jiffie then request the next message */ 926 - ssif_info->retries_left = SSIF_RECV_RETRIES; 927 - ssif_info->rtc_us_timer = SSIF_MSG_PART_USEC; 928 - mod_timer(&ssif_info->retry_timer, 929 - jiffies + SSIF_MSG_PART_JIFFIES); 930 - return; 873 + flags = ipmi_ssif_lock_cond(ssif_info, &oflags); 874 + got_alert = ssif_info->got_alert; 875 + if (got_alert) { 876 + ssif_info->got_alert = false; 877 + ssif_info->waiting_alert = false; 878 + } 879 + 880 + if (got_alert) { 881 + ipmi_ssif_unlock_cond(ssif_info, flags); 882 + /* The alert already happened, try now. */ 883 + retry_timeout((unsigned long) ssif_info); 884 + } else { 885 + /* Wait a jiffie then request the next message */ 886 + ssif_info->waiting_alert = true; 887 + ssif_info->retries_left = SSIF_RECV_RETRIES; 888 + ssif_info->rtc_us_timer = SSIF_MSG_PART_USEC; 889 + mod_timer(&ssif_info->retry_timer, 890 + jiffies + SSIF_MSG_PART_JIFFIES); 891 + ipmi_ssif_unlock_cond(ssif_info, flags); 892 + } 931 893 } 932 894 } 933 895 ··· 952 880 { 953 881 int rv; 954 882 int command; 883 + 884 + ssif_info->got_alert = false; 955 885 956 886 if (ssif_info->data_len > 32) { 957 887 command = SSIF_IPMI_MULTI_PART_REQUEST_START; ··· 989 915 return -E2BIG; 990 916 991 917 ssif_info->retries_left = SSIF_SEND_RETRIES; 992 - memcpy(ssif_info->data+1, data, len); 918 + memcpy(ssif_info->data + 1, data, len); 993 919 ssif_info->data_len = len; 994 920 return start_resend(ssif_info); 995 921 } ··· 1274 1200 { 1275 1201 seq_puts(m, "ssif\n"); 1276 1202 1277 - return seq_has_overflowed(m); 1203 + return 0; 1278 1204 } 1279 1205 1280 1206 static int smi_type_proc_open(struct inode *inode, struct file *file) ··· 1317 1243 ssif_get_stat(ssif_info, events)); 1318 1244 seq_printf(m, "watchdog_pretimeouts: %u\n", 1319 1245 ssif_get_stat(ssif_info, watchdog_pretimeouts)); 1246 + seq_printf(m, "alerts: %u\n", 1247 + ssif_get_stat(ssif_info, alerts)); 1320 1248 return 0; 1321 1249 } 1322 1250 ··· 1334 1258 .release = single_release, 1335 1259 }; 1336 1260 1261 + static int strcmp_nospace(char *s1, char *s2) 1262 + { 1263 + while (*s1 && *s2) { 1264 + while (isspace(*s1)) 1265 + s1++; 1266 + while (isspace(*s2)) 1267 + s2++; 1268 + if (*s1 > *s2) 1269 + return 1; 1270 + if (*s1 < *s2) 1271 + return -1; 1272 + s1++; 1273 + s2++; 1274 + } 1275 + return 0; 1276 + } 1277 + 1337 1278 static struct ssif_addr_info *ssif_info_find(unsigned short addr, 1338 1279 char *adapter_name, 1339 1280 bool match_null_name) ··· 1365 1272 /* One is NULL and one is not */ 1366 1273 continue; 1367 1274 } 1368 - if (strcmp(info->adapter_name, adapter_name)) 1369 - /* Names to not match */ 1275 + if (adapter_name && 1276 + strcmp_nospace(info->adapter_name, 1277 + adapter_name)) 1278 + /* Names do not match */ 1370 1279 continue; 1371 1280 } 1372 1281 found = info; ··· 1400 1305 #endif 1401 1306 return false; 1402 1307 } 1308 + 1309 + /* 1310 + * Global enables we care about. 1311 + */ 1312 + #define GLOBAL_ENABLES_MASK (IPMI_BMC_EVT_MSG_BUFF | IPMI_BMC_RCV_MSG_INTR | \ 1313 + IPMI_BMC_EVT_MSG_INTR) 1403 1314 1404 1315 static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id) 1405 1316 { ··· 1492 1391 break; 1493 1392 1494 1393 case SSIF_MULTI_2_PART: 1495 - if (ssif_info->max_xmit_msg_size > 64) 1496 - ssif_info->max_xmit_msg_size = 64; 1394 + if (ssif_info->max_xmit_msg_size > 63) 1395 + ssif_info->max_xmit_msg_size = 63; 1497 1396 if (ssif_info->max_recv_msg_size > 62) 1498 1397 ssif_info->max_recv_msg_size = 62; 1499 1398 break; 1500 1399 1501 1400 case SSIF_MULTI_n_PART: 1401 + /* 1402 + * The specification is rather confusing at 1403 + * this point, but I think I understand what 1404 + * is meant. At least I have a workable 1405 + * solution. With multi-part messages, you 1406 + * cannot send a message that is a multiple of 1407 + * 32-bytes in length, because the start and 1408 + * middle messages are 32-bytes and the end 1409 + * message must be at least one byte. You 1410 + * can't fudge on an extra byte, that would 1411 + * screw up things like fru data writes. So 1412 + * we limit the length to 63 bytes. That way 1413 + * a 32-byte message gets sent as a single 1414 + * part. A larger message will be a 32-byte 1415 + * start and the next message is always going 1416 + * to be 1-31 bytes in length. Not ideal, but 1417 + * it should work. 1418 + */ 1419 + if (ssif_info->max_xmit_msg_size > 63) 1420 + ssif_info->max_xmit_msg_size = 63; 1502 1421 break; 1503 1422 1504 1423 default: ··· 1528 1407 } else { 1529 1408 no_support: 1530 1409 /* Assume no multi-part or PEC support */ 1531 - pr_info(PFX "Error fetching SSIF: %d %d %2.2x, your system probably doesn't support this command so using defaults\n", 1410 + pr_info(PFX "Error fetching SSIF: %d %d %2.2x, your system probably doesn't support this command so using defaults\n", 1532 1411 rv, len, resp[2]); 1533 1412 1534 1413 ssif_info->max_xmit_msg_size = 32; ··· 1557 1436 goto found; 1558 1437 } 1559 1438 1439 + ssif_info->global_enables = resp[3]; 1440 + 1560 1441 if (resp[3] & IPMI_BMC_EVT_MSG_BUFF) { 1561 1442 ssif_info->has_event_buffer = true; 1562 1443 /* buffer is already enabled, nothing to do. */ ··· 1567 1444 1568 1445 msg[0] = IPMI_NETFN_APP_REQUEST << 2; 1569 1446 msg[1] = IPMI_SET_BMC_GLOBAL_ENABLES_CMD; 1570 - msg[2] = resp[3] | IPMI_BMC_EVT_MSG_BUFF; 1447 + msg[2] = ssif_info->global_enables | IPMI_BMC_EVT_MSG_BUFF; 1571 1448 rv = do_cmd(client, 3, msg, &len, resp); 1572 1449 if (rv || (len < 2)) { 1573 - pr_warn(PFX "Error getting global enables: %d %d %2.2x\n", 1450 + pr_warn(PFX "Error setting global enables: %d %d %2.2x\n", 1574 1451 rv, len, resp[2]); 1575 1452 rv = 0; /* Not fatal */ 1576 1453 goto found; 1577 1454 } 1578 1455 1579 - if (resp[2] == 0) 1456 + if (resp[2] == 0) { 1580 1457 /* A successful return means the event buffer is supported. */ 1581 1458 ssif_info->has_event_buffer = true; 1459 + ssif_info->global_enables |= IPMI_BMC_EVT_MSG_BUFF; 1460 + } 1461 + 1462 + msg[0] = IPMI_NETFN_APP_REQUEST << 2; 1463 + msg[1] = IPMI_SET_BMC_GLOBAL_ENABLES_CMD; 1464 + msg[2] = ssif_info->global_enables | IPMI_BMC_RCV_MSG_INTR; 1465 + rv = do_cmd(client, 3, msg, &len, resp); 1466 + if (rv || (len < 2)) { 1467 + pr_warn(PFX "Error setting global enables: %d %d %2.2x\n", 1468 + rv, len, resp[2]); 1469 + rv = 0; /* Not fatal */ 1470 + goto found; 1471 + } 1472 + 1473 + if (resp[2] == 0) { 1474 + /* A successful return means the alert is supported. */ 1475 + ssif_info->supports_alert = true; 1476 + ssif_info->global_enables |= IPMI_BMC_RCV_MSG_INTR; 1477 + } 1582 1478 1583 1479 found: 1584 1480 ssif_info->intf_num = atomic_inc_return(&next_intf); ··· 1955 1813 }, 1956 1814 .probe = ssif_probe, 1957 1815 .remove = ssif_remove, 1816 + .alert = ssif_alert, 1958 1817 .id_table = ssif_id, 1959 1818 .detect = ssif_detect 1960 1819 }; ··· 1975 1832 rv = new_ssif_client(addr[i], adapter_name[i], 1976 1833 dbg[i], slave_addrs[i], 1977 1834 SI_HARDCODED); 1978 - if (!rv) 1835 + if (rv) 1979 1836 pr_err(PFX 1980 1837 "Couldn't add hardcoded device at addr 0x%x\n", 1981 1838 addr[i]);