aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/isci
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2012-02-10 04:18:49 -0500
committerJames Bottomley <JBottomley@Parallels.com>2012-02-29 17:24:13 -0500
commite462116afb1e436d4045167e7fe979405ae33d2b (patch)
tree0ccb050d8c3ce67419a1da7e92dc9c386ad9fd3c /drivers/scsi/isci
parentd7a0ccdd9bd78b5b74d2963ec7ab67c9d896902a (diff)
[SCSI] isci: improve phy event warnings
isci occasionally spews messages like: isci 0000:03:00.0: sci_phy_event_handler: PHY starting substate machine received unexpected event_code b3940000 ...which is not very helpful, since we don't know which controller, which phy, the exact state, or a decode of the event. Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/isci')
-rw-r--r--drivers/scsi/isci/phy.c123
1 files changed, 71 insertions, 52 deletions
diff --git a/drivers/scsi/isci/phy.c b/drivers/scsi/isci/phy.c
index 87064f13f8fa..fab3586840b5 100644
--- a/drivers/scsi/isci/phy.c
+++ b/drivers/scsi/isci/phy.c
@@ -77,12 +77,17 @@ enum sas_linkrate sci_phy_linkrate(struct isci_phy *iphy)
77 return iphy->max_negotiated_speed; 77 return iphy->max_negotiated_speed;
78} 78}
79 79
80static struct device *sciphy_to_dev(struct isci_phy *iphy) 80static struct isci_host *phy_to_host(struct isci_phy *iphy)
81{ 81{
82 struct isci_phy *table = iphy - iphy->phy_index; 82 struct isci_phy *table = iphy - iphy->phy_index;
83 struct isci_host *ihost = container_of(table, typeof(*ihost), phys[0]); 83 struct isci_host *ihost = container_of(table, typeof(*ihost), phys[0]);
84 84
85 return &ihost->pdev->dev; 85 return ihost;
86}
87
88static struct device *sciphy_to_dev(struct isci_phy *iphy)
89{
90 return &phy_to_host(iphy)->pdev->dev;
86} 91}
87 92
88static enum sci_status 93static enum sci_status
@@ -609,6 +614,60 @@ static void sci_phy_complete_link_training(struct isci_phy *iphy,
609 sci_change_state(&iphy->sm, next_state); 614 sci_change_state(&iphy->sm, next_state);
610} 615}
611 616
617static const char *phy_event_name(u32 event_code)
618{
619 switch (scu_get_event_code(event_code)) {
620 case SCU_EVENT_PORT_SELECTOR_DETECTED:
621 return "port selector";
622 case SCU_EVENT_SENT_PORT_SELECTION:
623 return "port selection";
624 case SCU_EVENT_HARD_RESET_TRANSMITTED:
625 return "tx hard reset";
626 case SCU_EVENT_HARD_RESET_RECEIVED:
627 return "rx hard reset";
628 case SCU_EVENT_RECEIVED_IDENTIFY_TIMEOUT:
629 return "identify timeout";
630 case SCU_EVENT_LINK_FAILURE:
631 return "link fail";
632 case SCU_EVENT_SATA_SPINUP_HOLD:
633 return "sata spinup hold";
634 case SCU_EVENT_SAS_15_SSC:
635 case SCU_EVENT_SAS_15:
636 return "sas 1.5";
637 case SCU_EVENT_SAS_30_SSC:
638 case SCU_EVENT_SAS_30:
639 return "sas 3.0";
640 case SCU_EVENT_SAS_60_SSC:
641 case SCU_EVENT_SAS_60:
642 return "sas 6.0";
643 case SCU_EVENT_SATA_15_SSC:
644 case SCU_EVENT_SATA_15:
645 return "sata 1.5";
646 case SCU_EVENT_SATA_30_SSC:
647 case SCU_EVENT_SATA_30:
648 return "sata 3.0";
649 case SCU_EVENT_SATA_60_SSC:
650 case SCU_EVENT_SATA_60:
651 return "sata 6.0";
652 case SCU_EVENT_SAS_PHY_DETECTED:
653 return "sas detect";
654 case SCU_EVENT_SATA_PHY_DETECTED:
655 return "sata detect";
656 default:
657 return "unknown";
658 }
659}
660
661#define phy_event_dbg(iphy, state, code) \
662 dev_dbg(sciphy_to_dev(iphy), "phy-%d:%d: %s event: %s (%x)\n", \
663 phy_to_host(iphy)->id, iphy->phy_index, \
664 phy_state_name(state), phy_event_name(code), code)
665
666#define phy_event_warn(iphy, state, code) \
667 dev_warn(sciphy_to_dev(iphy), "phy-%d:%d: %s event: %s (%x)\n", \
668 phy_to_host(iphy)->id, iphy->phy_index, \
669 phy_state_name(state), phy_event_name(code), code)
670
612enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code) 671enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
613{ 672{
614 enum sci_phy_states state = iphy->sm.current_state_id; 673 enum sci_phy_states state = iphy->sm.current_state_id;
@@ -625,11 +684,7 @@ enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
625 iphy->is_in_link_training = true; 684 iphy->is_in_link_training = true;
626 break; 685 break;
627 default: 686 default:
628 dev_dbg(sciphy_to_dev(iphy), 687 phy_event_dbg(iphy, state, event_code);
629 "%s: PHY starting substate machine received "
630 "unexpected event_code %x\n",
631 __func__,
632 event_code);
633 return SCI_FAILURE; 688 return SCI_FAILURE;
634 } 689 }
635 return SCI_SUCCESS; 690 return SCI_SUCCESS;
@@ -666,11 +721,7 @@ enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
666 sci_change_state(&iphy->sm, SCI_PHY_STARTING); 721 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
667 break; 722 break;
668 default: 723 default:
669 dev_warn(sciphy_to_dev(iphy), 724 phy_event_warn(iphy, state, event_code);
670 "%s: PHY starting substate machine received "
671 "unexpected event_code %x\n",
672 __func__, event_code);
673
674 return SCI_FAILURE; 725 return SCI_FAILURE;
675 break; 726 break;
676 } 727 }
@@ -695,10 +746,7 @@ enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
695 sci_change_state(&iphy->sm, SCI_PHY_STARTING); 746 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
696 break; 747 break;
697 default: 748 default:
698 dev_warn(sciphy_to_dev(iphy), 749 phy_event_warn(iphy, state, event_code);
699 "%s: PHY starting substate machine received "
700 "unexpected event_code %x\n",
701 __func__, event_code);
702 return SCI_FAILURE; 750 return SCI_FAILURE;
703 } 751 }
704 return SCI_SUCCESS; 752 return SCI_SUCCESS;
@@ -709,11 +757,7 @@ enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
709 sci_change_state(&iphy->sm, SCI_PHY_STARTING); 757 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
710 break; 758 break;
711 default: 759 default:
712 dev_warn(sciphy_to_dev(iphy), 760 phy_event_warn(iphy, state, event_code);
713 "%s: PHY starting substate machine received unexpected "
714 "event_code %x\n",
715 __func__,
716 event_code);
717 return SCI_FAILURE; 761 return SCI_FAILURE;
718 } 762 }
719 return SCI_SUCCESS; 763 return SCI_SUCCESS;
@@ -737,11 +781,7 @@ enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
737 break; 781 break;
738 782
739 default: 783 default:
740 dev_warn(sciphy_to_dev(iphy), 784 phy_event_warn(iphy, state, event_code);
741 "%s: PHY starting substate machine received "
742 "unexpected event_code %x\n",
743 __func__, event_code);
744
745 return SCI_FAILURE; 785 return SCI_FAILURE;
746 } 786 }
747 return SCI_SUCCESS; 787 return SCI_SUCCESS;
@@ -769,12 +809,7 @@ enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
769 sci_phy_start_sas_link_training(iphy); 809 sci_phy_start_sas_link_training(iphy);
770 break; 810 break;
771 default: 811 default:
772 dev_warn(sciphy_to_dev(iphy), 812 phy_event_warn(iphy, state, event_code);
773 "%s: PHY starting substate machine received "
774 "unexpected event_code %x\n",
775 __func__,
776 event_code);
777
778 return SCI_FAILURE; 813 return SCI_FAILURE;
779 } 814 }
780 return SCI_SUCCESS; 815 return SCI_SUCCESS;
@@ -811,11 +846,7 @@ enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
811 sci_phy_start_sas_link_training(iphy); 846 sci_phy_start_sas_link_training(iphy);
812 break; 847 break;
813 default: 848 default:
814 dev_warn(sciphy_to_dev(iphy), 849 phy_event_warn(iphy, state, event_code);
815 "%s: PHY starting substate machine received "
816 "unexpected event_code %x\n",
817 __func__, event_code);
818
819 return SCI_FAILURE; 850 return SCI_FAILURE;
820 } 851 }
821 852
@@ -833,12 +864,7 @@ enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
833 break; 864 break;
834 865
835 default: 866 default:
836 dev_warn(sciphy_to_dev(iphy), 867 phy_event_warn(iphy, state, event_code);
837 "%s: PHY starting substate machine received "
838 "unexpected event_code %x\n",
839 __func__,
840 event_code);
841
842 return SCI_FAILURE; 868 return SCI_FAILURE;
843 } 869 }
844 return SCI_SUCCESS; 870 return SCI_SUCCESS;
@@ -856,10 +882,7 @@ enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
856 iphy->bcn_received_while_port_unassigned = true; 882 iphy->bcn_received_while_port_unassigned = true;
857 break; 883 break;
858 default: 884 default:
859 dev_warn(sciphy_to_dev(iphy), 885 phy_event_warn(iphy, state, event_code);
860 "%sP SCIC PHY 0x%p ready state machine received "
861 "unexpected event_code %x\n",
862 __func__, iphy, event_code);
863 return SCI_FAILURE_INVALID_STATE; 886 return SCI_FAILURE_INVALID_STATE;
864 } 887 }
865 return SCI_SUCCESS; 888 return SCI_SUCCESS;
@@ -870,11 +893,7 @@ enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
870 sci_change_state(&iphy->sm, SCI_PHY_STARTING); 893 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
871 break; 894 break;
872 default: 895 default:
873 dev_warn(sciphy_to_dev(iphy), 896 phy_event_warn(iphy, state, event_code);
874 "%s: SCIC PHY 0x%p resetting state machine received "
875 "unexpected event_code %x\n",
876 __func__, iphy, event_code);
877
878 return SCI_FAILURE_INVALID_STATE; 897 return SCI_FAILURE_INVALID_STATE;
879 break; 898 break;
880 } 899 }