.. | .. |
---|
74 | 74 | /* |
---|
75 | 75 | * Timer values |
---|
76 | 76 | */ |
---|
77 | | -#define SSIF_MSG_USEC 20000 /* 20ms between message tries. */ |
---|
| 77 | +#define SSIF_MSG_USEC 60000 /* 60ms between message tries (T3). */ |
---|
| 78 | +#define SSIF_REQ_RETRY_USEC 60000 /* 60ms between send retries (T6). */ |
---|
78 | 79 | #define SSIF_MSG_PART_USEC 5000 /* 5ms for a message part */ |
---|
79 | 80 | |
---|
80 | 81 | /* How many times to we retry sending/receiving the message. */ |
---|
.. | .. |
---|
82 | 83 | #define SSIF_RECV_RETRIES 250 |
---|
83 | 84 | |
---|
84 | 85 | #define SSIF_MSG_MSEC (SSIF_MSG_USEC / 1000) |
---|
| 86 | +#define SSIF_REQ_RETRY_MSEC (SSIF_REQ_RETRY_USEC / 1000) |
---|
85 | 87 | #define SSIF_MSG_JIFFIES ((SSIF_MSG_USEC * 1000) / TICK_NSEC) |
---|
| 88 | +#define SSIF_REQ_RETRY_JIFFIES ((SSIF_REQ_RETRY_USEC * 1000) / TICK_NSEC) |
---|
86 | 89 | #define SSIF_MSG_PART_JIFFIES ((SSIF_MSG_PART_USEC * 1000) / TICK_NSEC) |
---|
87 | 90 | |
---|
88 | 91 | /* |
---|
.. | .. |
---|
92 | 95 | #define SSIF_WATCH_WATCHDOG_TIMEOUT msecs_to_jiffies(250) |
---|
93 | 96 | |
---|
94 | 97 | enum ssif_intf_state { |
---|
95 | | - SSIF_NORMAL, |
---|
| 98 | + SSIF_IDLE, |
---|
96 | 99 | SSIF_GETTING_FLAGS, |
---|
97 | 100 | SSIF_GETTING_EVENTS, |
---|
98 | 101 | SSIF_CLEARING_FLAGS, |
---|
.. | .. |
---|
100 | 103 | /* FIXME - add watchdog stuff. */ |
---|
101 | 104 | }; |
---|
102 | 105 | |
---|
103 | | -#define SSIF_IDLE(ssif) ((ssif)->ssif_state == SSIF_NORMAL \ |
---|
104 | | - && (ssif)->curr_msg == NULL) |
---|
| 106 | +#define IS_SSIF_IDLE(ssif) ((ssif)->ssif_state == SSIF_IDLE \ |
---|
| 107 | + && (ssif)->curr_msg == NULL) |
---|
105 | 108 | |
---|
106 | 109 | /* |
---|
107 | 110 | * Indexes into stats[] in ssif_info below. |
---|
.. | .. |
---|
229 | 232 | bool got_alert; |
---|
230 | 233 | bool waiting_alert; |
---|
231 | 234 | |
---|
| 235 | + /* Used to inform the timeout that it should do a resend. */ |
---|
| 236 | + bool do_resend; |
---|
| 237 | + |
---|
232 | 238 | /* |
---|
233 | 239 | * If set to true, this will request events the next time the |
---|
234 | 240 | * state machine is idle. |
---|
.. | .. |
---|
348 | 354 | |
---|
349 | 355 | /* |
---|
350 | 356 | * Must be called with the message lock held. This will release the |
---|
351 | | - * message lock. Note that the caller will check SSIF_IDLE and start a |
---|
352 | | - * new operation, so there is no need to check for new messages to |
---|
353 | | - * start in here. |
---|
| 357 | + * message lock. Note that the caller will check IS_SSIF_IDLE and |
---|
| 358 | + * start a new operation, so there is no need to check for new |
---|
| 359 | + * messages to start in here. |
---|
354 | 360 | */ |
---|
355 | 361 | static void start_clear_flags(struct ssif_info *ssif_info, unsigned long *flags) |
---|
356 | 362 | { |
---|
.. | .. |
---|
367 | 373 | |
---|
368 | 374 | if (start_send(ssif_info, msg, 3) != 0) { |
---|
369 | 375 | /* Error, just go to normal state. */ |
---|
370 | | - ssif_info->ssif_state = SSIF_NORMAL; |
---|
| 376 | + ssif_info->ssif_state = SSIF_IDLE; |
---|
371 | 377 | } |
---|
372 | 378 | } |
---|
373 | 379 | |
---|
.. | .. |
---|
382 | 388 | mb[0] = (IPMI_NETFN_APP_REQUEST << 2); |
---|
383 | 389 | mb[1] = IPMI_GET_MSG_FLAGS_CMD; |
---|
384 | 390 | if (start_send(ssif_info, mb, 2) != 0) |
---|
385 | | - ssif_info->ssif_state = SSIF_NORMAL; |
---|
| 391 | + ssif_info->ssif_state = SSIF_IDLE; |
---|
386 | 392 | } |
---|
387 | 393 | |
---|
388 | 394 | static void check_start_send(struct ssif_info *ssif_info, unsigned long *flags, |
---|
.. | .. |
---|
393 | 399 | |
---|
394 | 400 | flags = ipmi_ssif_lock_cond(ssif_info, &oflags); |
---|
395 | 401 | ssif_info->curr_msg = NULL; |
---|
396 | | - ssif_info->ssif_state = SSIF_NORMAL; |
---|
| 402 | + ssif_info->ssif_state = SSIF_IDLE; |
---|
397 | 403 | ipmi_ssif_unlock_cond(ssif_info, flags); |
---|
398 | 404 | ipmi_free_smi_msg(msg); |
---|
399 | 405 | } |
---|
.. | .. |
---|
407 | 413 | |
---|
408 | 414 | msg = ipmi_alloc_smi_msg(); |
---|
409 | 415 | if (!msg) { |
---|
410 | | - ssif_info->ssif_state = SSIF_NORMAL; |
---|
| 416 | + ssif_info->ssif_state = SSIF_IDLE; |
---|
411 | 417 | ipmi_ssif_unlock_cond(ssif_info, flags); |
---|
412 | 418 | return; |
---|
413 | 419 | } |
---|
.. | .. |
---|
430 | 436 | |
---|
431 | 437 | msg = ipmi_alloc_smi_msg(); |
---|
432 | 438 | if (!msg) { |
---|
433 | | - ssif_info->ssif_state = SSIF_NORMAL; |
---|
| 439 | + ssif_info->ssif_state = SSIF_IDLE; |
---|
434 | 440 | ipmi_ssif_unlock_cond(ssif_info, flags); |
---|
435 | 441 | return; |
---|
436 | 442 | } |
---|
.. | .. |
---|
448 | 454 | |
---|
449 | 455 | /* |
---|
450 | 456 | * Must be called with the message lock held. This will release the |
---|
451 | | - * message lock. Note that the caller will check SSIF_IDLE and start a |
---|
452 | | - * new operation, so there is no need to check for new messages to |
---|
453 | | - * start in here. |
---|
| 457 | + * message lock. Note that the caller will check IS_SSIF_IDLE and |
---|
| 458 | + * start a new operation, so there is no need to check for new |
---|
| 459 | + * messages to start in here. |
---|
454 | 460 | */ |
---|
455 | 461 | static void handle_flags(struct ssif_info *ssif_info, unsigned long *flags) |
---|
456 | 462 | { |
---|
.. | .. |
---|
466 | 472 | /* Events available. */ |
---|
467 | 473 | start_event_fetch(ssif_info, flags); |
---|
468 | 474 | else { |
---|
469 | | - ssif_info->ssif_state = SSIF_NORMAL; |
---|
| 475 | + ssif_info->ssif_state = SSIF_IDLE; |
---|
470 | 476 | ipmi_ssif_unlock_cond(ssif_info, flags); |
---|
471 | 477 | } |
---|
472 | 478 | } |
---|
.. | .. |
---|
510 | 516 | return 0; |
---|
511 | 517 | } |
---|
512 | 518 | |
---|
513 | | -static int ssif_i2c_send(struct ssif_info *ssif_info, |
---|
| 519 | +static void ssif_i2c_send(struct ssif_info *ssif_info, |
---|
514 | 520 | ssif_i2c_done handler, |
---|
515 | 521 | int read_write, int command, |
---|
516 | 522 | unsigned char *data, unsigned int size) |
---|
.. | .. |
---|
522 | 528 | ssif_info->i2c_data = data; |
---|
523 | 529 | ssif_info->i2c_size = size; |
---|
524 | 530 | complete(&ssif_info->wake_thread); |
---|
525 | | - return 0; |
---|
526 | 531 | } |
---|
527 | 532 | |
---|
528 | 533 | |
---|
.. | .. |
---|
531 | 536 | |
---|
532 | 537 | static void start_get(struct ssif_info *ssif_info) |
---|
533 | 538 | { |
---|
534 | | - int rv; |
---|
535 | | - |
---|
536 | 539 | ssif_info->rtc_us_timer = 0; |
---|
537 | 540 | ssif_info->multi_pos = 0; |
---|
538 | 541 | |
---|
539 | | - rv = ssif_i2c_send(ssif_info, msg_done_handler, I2C_SMBUS_READ, |
---|
540 | | - SSIF_IPMI_RESPONSE, |
---|
541 | | - ssif_info->recv, I2C_SMBUS_BLOCK_DATA); |
---|
542 | | - if (rv < 0) { |
---|
543 | | - /* request failed, just return the error. */ |
---|
544 | | - if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) |
---|
545 | | - dev_dbg(&ssif_info->client->dev, |
---|
546 | | - "Error from i2c_non_blocking_op(5)\n"); |
---|
547 | | - |
---|
548 | | - msg_done_handler(ssif_info, -EIO, NULL, 0); |
---|
549 | | - } |
---|
| 542 | + ssif_i2c_send(ssif_info, msg_done_handler, I2C_SMBUS_READ, |
---|
| 543 | + SSIF_IPMI_RESPONSE, |
---|
| 544 | + ssif_info->recv, I2C_SMBUS_BLOCK_DATA); |
---|
550 | 545 | } |
---|
| 546 | + |
---|
| 547 | +static void start_resend(struct ssif_info *ssif_info); |
---|
551 | 548 | |
---|
552 | 549 | static void retry_timeout(struct timer_list *t) |
---|
553 | 550 | { |
---|
554 | 551 | struct ssif_info *ssif_info = from_timer(ssif_info, t, retry_timer); |
---|
555 | 552 | unsigned long oflags, *flags; |
---|
556 | | - bool waiting; |
---|
| 553 | + bool waiting, resend; |
---|
557 | 554 | |
---|
558 | 555 | if (ssif_info->stopping) |
---|
559 | 556 | return; |
---|
560 | 557 | |
---|
561 | 558 | flags = ipmi_ssif_lock_cond(ssif_info, &oflags); |
---|
| 559 | + resend = ssif_info->do_resend; |
---|
| 560 | + ssif_info->do_resend = false; |
---|
562 | 561 | waiting = ssif_info->waiting_alert; |
---|
563 | 562 | ssif_info->waiting_alert = false; |
---|
564 | 563 | ipmi_ssif_unlock_cond(ssif_info, flags); |
---|
565 | 564 | |
---|
566 | 565 | if (waiting) |
---|
567 | 566 | start_get(ssif_info); |
---|
| 567 | + if (resend) { |
---|
| 568 | + start_resend(ssif_info); |
---|
| 569 | + ssif_inc_stat(ssif_info, send_retries); |
---|
| 570 | + } |
---|
568 | 571 | } |
---|
569 | 572 | |
---|
570 | 573 | static void watch_timeout(struct timer_list *t) |
---|
.. | .. |
---|
579 | 582 | if (ssif_info->watch_timeout) { |
---|
580 | 583 | mod_timer(&ssif_info->watch_timer, |
---|
581 | 584 | jiffies + ssif_info->watch_timeout); |
---|
582 | | - if (SSIF_IDLE(ssif_info)) { |
---|
| 585 | + if (IS_SSIF_IDLE(ssif_info)) { |
---|
583 | 586 | start_flag_fetch(ssif_info, flags); /* Releases lock */ |
---|
584 | 587 | return; |
---|
585 | 588 | } |
---|
.. | .. |
---|
613 | 616 | start_get(ssif_info); |
---|
614 | 617 | } |
---|
615 | 618 | |
---|
616 | | -static int start_resend(struct ssif_info *ssif_info); |
---|
617 | | - |
---|
618 | 619 | static void msg_done_handler(struct ssif_info *ssif_info, int result, |
---|
619 | 620 | unsigned char *data, unsigned int len) |
---|
620 | 621 | { |
---|
621 | 622 | struct ipmi_smi_msg *msg; |
---|
622 | 623 | unsigned long oflags, *flags; |
---|
623 | | - int rv; |
---|
624 | 624 | |
---|
625 | 625 | /* |
---|
626 | 626 | * We are single-threaded here, so no need for a lock until we |
---|
.. | .. |
---|
666 | 666 | ssif_info->multi_len = len; |
---|
667 | 667 | ssif_info->multi_pos = 1; |
---|
668 | 668 | |
---|
669 | | - rv = ssif_i2c_send(ssif_info, msg_done_handler, I2C_SMBUS_READ, |
---|
670 | | - SSIF_IPMI_MULTI_PART_RESPONSE_MIDDLE, |
---|
671 | | - ssif_info->recv, I2C_SMBUS_BLOCK_DATA); |
---|
672 | | - if (rv < 0) { |
---|
673 | | - if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) |
---|
674 | | - dev_dbg(&ssif_info->client->dev, |
---|
675 | | - "Error from i2c_non_blocking_op(1)\n"); |
---|
676 | | - |
---|
677 | | - result = -EIO; |
---|
678 | | - } else |
---|
679 | | - return; |
---|
| 669 | + ssif_i2c_send(ssif_info, msg_done_handler, I2C_SMBUS_READ, |
---|
| 670 | + SSIF_IPMI_MULTI_PART_RESPONSE_MIDDLE, |
---|
| 671 | + ssif_info->recv, I2C_SMBUS_BLOCK_DATA); |
---|
| 672 | + return; |
---|
680 | 673 | } else if (ssif_info->multi_pos) { |
---|
681 | 674 | /* Middle of multi-part read. Start the next transaction. */ |
---|
682 | 675 | int i; |
---|
.. | .. |
---|
738 | 731 | |
---|
739 | 732 | ssif_info->multi_pos++; |
---|
740 | 733 | |
---|
741 | | - rv = ssif_i2c_send(ssif_info, msg_done_handler, |
---|
742 | | - I2C_SMBUS_READ, |
---|
743 | | - SSIF_IPMI_MULTI_PART_RESPONSE_MIDDLE, |
---|
744 | | - ssif_info->recv, |
---|
745 | | - I2C_SMBUS_BLOCK_DATA); |
---|
746 | | - if (rv < 0) { |
---|
747 | | - if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) |
---|
748 | | - dev_dbg(&ssif_info->client->dev, |
---|
749 | | - "Error from ssif_i2c_send\n"); |
---|
750 | | - |
---|
751 | | - result = -EIO; |
---|
752 | | - } else |
---|
753 | | - return; |
---|
| 734 | + ssif_i2c_send(ssif_info, msg_done_handler, |
---|
| 735 | + I2C_SMBUS_READ, |
---|
| 736 | + SSIF_IPMI_MULTI_PART_RESPONSE_MIDDLE, |
---|
| 737 | + ssif_info->recv, |
---|
| 738 | + I2C_SMBUS_BLOCK_DATA); |
---|
| 739 | + return; |
---|
754 | 740 | } |
---|
755 | 741 | } |
---|
756 | 742 | |
---|
.. | .. |
---|
782 | 768 | } |
---|
783 | 769 | |
---|
784 | 770 | switch (ssif_info->ssif_state) { |
---|
785 | | - case SSIF_NORMAL: |
---|
| 771 | + case SSIF_IDLE: |
---|
786 | 772 | ipmi_ssif_unlock_cond(ssif_info, flags); |
---|
787 | 773 | if (!msg) |
---|
788 | 774 | break; |
---|
.. | .. |
---|
800 | 786 | * Error fetching flags, or invalid length, |
---|
801 | 787 | * just give up for now. |
---|
802 | 788 | */ |
---|
803 | | - ssif_info->ssif_state = SSIF_NORMAL; |
---|
| 789 | + ssif_info->ssif_state = SSIF_IDLE; |
---|
804 | 790 | ipmi_ssif_unlock_cond(ssif_info, flags); |
---|
805 | 791 | dev_warn(&ssif_info->client->dev, |
---|
806 | 792 | "Error getting flags: %d %d, %x\n", |
---|
.. | .. |
---|
808 | 794 | } else if (data[0] != (IPMI_NETFN_APP_REQUEST | 1) << 2 |
---|
809 | 795 | || data[1] != IPMI_GET_MSG_FLAGS_CMD) { |
---|
810 | 796 | /* |
---|
811 | | - * Don't abort here, maybe it was a queued |
---|
812 | | - * response to a previous command. |
---|
| 797 | + * Recv error response, give up. |
---|
813 | 798 | */ |
---|
| 799 | + ssif_info->ssif_state = SSIF_IDLE; |
---|
814 | 800 | ipmi_ssif_unlock_cond(ssif_info, flags); |
---|
815 | 801 | dev_warn(&ssif_info->client->dev, |
---|
816 | 802 | "Invalid response getting flags: %x %x\n", |
---|
.. | .. |
---|
835 | 821 | "Invalid response clearing flags: %x %x\n", |
---|
836 | 822 | data[0], data[1]); |
---|
837 | 823 | } |
---|
838 | | - ssif_info->ssif_state = SSIF_NORMAL; |
---|
| 824 | + ssif_info->ssif_state = SSIF_IDLE; |
---|
839 | 825 | ipmi_ssif_unlock_cond(ssif_info, flags); |
---|
840 | 826 | break; |
---|
841 | 827 | |
---|
.. | .. |
---|
913 | 899 | } |
---|
914 | 900 | |
---|
915 | 901 | flags = ipmi_ssif_lock_cond(ssif_info, &oflags); |
---|
916 | | - if (SSIF_IDLE(ssif_info) && !ssif_info->stopping) { |
---|
| 902 | + if (IS_SSIF_IDLE(ssif_info) && !ssif_info->stopping) { |
---|
917 | 903 | if (ssif_info->req_events) |
---|
918 | 904 | start_event_fetch(ssif_info, flags); |
---|
919 | 905 | else if (ssif_info->req_flags) |
---|
.. | .. |
---|
931 | 917 | static void msg_written_handler(struct ssif_info *ssif_info, int result, |
---|
932 | 918 | unsigned char *data, unsigned int len) |
---|
933 | 919 | { |
---|
934 | | - int rv; |
---|
935 | | - |
---|
936 | 920 | /* We are single-threaded here, so no need for a lock. */ |
---|
937 | 921 | if (result < 0) { |
---|
938 | 922 | ssif_info->retries_left--; |
---|
939 | 923 | if (ssif_info->retries_left > 0) { |
---|
940 | | - if (!start_resend(ssif_info)) { |
---|
941 | | - ssif_inc_stat(ssif_info, send_retries); |
---|
942 | | - return; |
---|
943 | | - } |
---|
944 | | - /* request failed, just return the error. */ |
---|
945 | | - ssif_inc_stat(ssif_info, send_errors); |
---|
946 | | - |
---|
947 | | - if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) |
---|
948 | | - dev_dbg(&ssif_info->client->dev, |
---|
949 | | - "%s: Out of retries\n", __func__); |
---|
950 | | - msg_done_handler(ssif_info, -EIO, NULL, 0); |
---|
| 924 | + /* |
---|
| 925 | + * Wait the retry timeout time per the spec, |
---|
| 926 | + * then redo the send. |
---|
| 927 | + */ |
---|
| 928 | + ssif_info->do_resend = true; |
---|
| 929 | + mod_timer(&ssif_info->retry_timer, |
---|
| 930 | + jiffies + SSIF_REQ_RETRY_JIFFIES); |
---|
951 | 931 | return; |
---|
952 | 932 | } |
---|
953 | 933 | |
---|
954 | 934 | ssif_inc_stat(ssif_info, send_errors); |
---|
955 | 935 | |
---|
956 | | - /* |
---|
957 | | - * Got an error on transmit, let the done routine |
---|
958 | | - * handle it. |
---|
959 | | - */ |
---|
960 | 936 | if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) |
---|
961 | 937 | dev_dbg(&ssif_info->client->dev, |
---|
962 | | - "%s: Error %d\n", __func__, result); |
---|
| 938 | + "%s: Out of retries\n", __func__); |
---|
963 | 939 | |
---|
964 | | - msg_done_handler(ssif_info, result, NULL, 0); |
---|
| 940 | + msg_done_handler(ssif_info, -EIO, NULL, 0); |
---|
965 | 941 | return; |
---|
966 | 942 | } |
---|
967 | 943 | |
---|
.. | .. |
---|
995 | 971 | ssif_info->multi_data = NULL; |
---|
996 | 972 | } |
---|
997 | 973 | |
---|
998 | | - rv = ssif_i2c_send(ssif_info, msg_written_handler, |
---|
999 | | - I2C_SMBUS_WRITE, cmd, |
---|
1000 | | - data_to_send, I2C_SMBUS_BLOCK_DATA); |
---|
1001 | | - if (rv < 0) { |
---|
1002 | | - /* request failed, just return the error. */ |
---|
1003 | | - ssif_inc_stat(ssif_info, send_errors); |
---|
1004 | | - |
---|
1005 | | - if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) |
---|
1006 | | - dev_dbg(&ssif_info->client->dev, |
---|
1007 | | - "Error from i2c_non_blocking_op(3)\n"); |
---|
1008 | | - msg_done_handler(ssif_info, -EIO, NULL, 0); |
---|
1009 | | - } |
---|
| 974 | + ssif_i2c_send(ssif_info, msg_written_handler, |
---|
| 975 | + I2C_SMBUS_WRITE, cmd, |
---|
| 976 | + data_to_send, I2C_SMBUS_BLOCK_DATA); |
---|
1010 | 977 | } else { |
---|
1011 | 978 | /* Ready to request the result. */ |
---|
1012 | 979 | unsigned long oflags, *flags; |
---|
.. | .. |
---|
1033 | 1000 | } |
---|
1034 | 1001 | } |
---|
1035 | 1002 | |
---|
1036 | | -static int start_resend(struct ssif_info *ssif_info) |
---|
| 1003 | +static void start_resend(struct ssif_info *ssif_info) |
---|
1037 | 1004 | { |
---|
1038 | | - int rv; |
---|
1039 | 1005 | int command; |
---|
1040 | 1006 | |
---|
1041 | 1007 | ssif_info->got_alert = false; |
---|
.. | .. |
---|
1057 | 1023 | ssif_info->data[0] = ssif_info->data_len; |
---|
1058 | 1024 | } |
---|
1059 | 1025 | |
---|
1060 | | - rv = ssif_i2c_send(ssif_info, msg_written_handler, I2C_SMBUS_WRITE, |
---|
1061 | | - command, ssif_info->data, I2C_SMBUS_BLOCK_DATA); |
---|
1062 | | - if (rv && (ssif_info->ssif_debug & SSIF_DEBUG_MSG)) |
---|
1063 | | - dev_dbg(&ssif_info->client->dev, |
---|
1064 | | - "Error from i2c_non_blocking_op(4)\n"); |
---|
1065 | | - return rv; |
---|
| 1026 | + ssif_i2c_send(ssif_info, msg_written_handler, I2C_SMBUS_WRITE, |
---|
| 1027 | + command, ssif_info->data, I2C_SMBUS_BLOCK_DATA); |
---|
1066 | 1028 | } |
---|
1067 | 1029 | |
---|
1068 | 1030 | static int start_send(struct ssif_info *ssif_info, |
---|
.. | .. |
---|
1077 | 1039 | ssif_info->retries_left = SSIF_SEND_RETRIES; |
---|
1078 | 1040 | memcpy(ssif_info->data + 1, data, len); |
---|
1079 | 1041 | ssif_info->data_len = len; |
---|
1080 | | - return start_resend(ssif_info); |
---|
| 1042 | + start_resend(ssif_info); |
---|
| 1043 | + return 0; |
---|
1081 | 1044 | } |
---|
1082 | 1045 | |
---|
1083 | 1046 | /* Must be called with the message lock held. */ |
---|
.. | .. |
---|
1087 | 1050 | unsigned long oflags; |
---|
1088 | 1051 | |
---|
1089 | 1052 | restart: |
---|
1090 | | - if (!SSIF_IDLE(ssif_info)) { |
---|
| 1053 | + if (!IS_SSIF_IDLE(ssif_info)) { |
---|
1091 | 1054 | ipmi_ssif_unlock_cond(ssif_info, flags); |
---|
1092 | 1055 | return; |
---|
1093 | 1056 | } |
---|
.. | .. |
---|
1310 | 1273 | dev_set_drvdata(&ssif_info->client->dev, NULL); |
---|
1311 | 1274 | |
---|
1312 | 1275 | /* make sure the driver is not looking for flags any more. */ |
---|
1313 | | - while (ssif_info->ssif_state != SSIF_NORMAL) |
---|
| 1276 | + while (ssif_info->ssif_state != SSIF_IDLE) |
---|
1314 | 1277 | schedule_timeout(1); |
---|
1315 | 1278 | |
---|
1316 | 1279 | ssif_info->stopping = true; |
---|
.. | .. |
---|
1377 | 1340 | ret = i2c_smbus_write_block_data(client, SSIF_IPMI_REQUEST, len, msg); |
---|
1378 | 1341 | if (ret) { |
---|
1379 | 1342 | retry_cnt--; |
---|
1380 | | - if (retry_cnt > 0) |
---|
| 1343 | + if (retry_cnt > 0) { |
---|
| 1344 | + msleep(SSIF_REQ_RETRY_MSEC); |
---|
1381 | 1345 | goto retry1; |
---|
| 1346 | + } |
---|
1382 | 1347 | return -ENODEV; |
---|
1383 | 1348 | } |
---|
1384 | 1349 | |
---|
.. | .. |
---|
1449 | 1414 | restart: |
---|
1450 | 1415 | list_for_each_entry(info, &ssif_infos, link) { |
---|
1451 | 1416 | if (info->binfo.addr == addr) { |
---|
1452 | | - if (info->addr_src == SI_SMBIOS) |
---|
| 1417 | + if (info->addr_src == SI_SMBIOS && !info->adapter_name) |
---|
1453 | 1418 | info->adapter_name = kstrdup(adapter_name, |
---|
1454 | 1419 | GFP_KERNEL); |
---|
1455 | 1420 | |
---|
.. | .. |
---|
1519 | 1484 | 32, msg); |
---|
1520 | 1485 | if (ret) { |
---|
1521 | 1486 | retry_cnt--; |
---|
1522 | | - if (retry_cnt > 0) |
---|
| 1487 | + if (retry_cnt > 0) { |
---|
| 1488 | + msleep(SSIF_REQ_RETRY_MSEC); |
---|
1523 | 1489 | goto retry_write; |
---|
| 1490 | + } |
---|
1524 | 1491 | dev_err(&client->dev, "Could not write multi-part start, though the BMC said it could handle it. Just limit sends to one part.\n"); |
---|
1525 | 1492 | return ret; |
---|
1526 | 1493 | } |
---|
.. | .. |
---|
1647 | 1614 | info->addr_src = SI_ACPI; |
---|
1648 | 1615 | info->client = client; |
---|
1649 | 1616 | info->adapter_name = kstrdup(client->adapter->name, GFP_KERNEL); |
---|
| 1617 | + if (!info->adapter_name) { |
---|
| 1618 | + kfree(info); |
---|
| 1619 | + return -ENOMEM; |
---|
| 1620 | + } |
---|
| 1621 | + |
---|
1650 | 1622 | info->binfo.addr = client->addr; |
---|
1651 | 1623 | list_add_tail(&info->link, &ssif_infos); |
---|
1652 | 1624 | return 0; |
---|
.. | .. |
---|
1882 | 1854 | } |
---|
1883 | 1855 | |
---|
1884 | 1856 | spin_lock_init(&ssif_info->lock); |
---|
1885 | | - ssif_info->ssif_state = SSIF_NORMAL; |
---|
| 1857 | + ssif_info->ssif_state = SSIF_IDLE; |
---|
1886 | 1858 | timer_setup(&ssif_info->retry_timer, retry_timeout, 0); |
---|
1887 | 1859 | timer_setup(&ssif_info->watch_timer, watch_timeout, 0); |
---|
1888 | 1860 | |
---|