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