diff options
author | James Smart <james.smart@emulex.com> | 2014-04-04 13:51:34 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2014-06-02 12:28:35 -0400 |
commit | bcece5f557d533a85b24cf4f4416c821219fb7b7 (patch) | |
tree | 0553bca5bb2cd896de84eb24cb178e0cd93792ef | |
parent | 6acb3481498a0bd3bac02af7aa5003f0a52bf037 (diff) |
lpfc: Fix locking for lpfc_hba_down_post
Fix locking for lpfc_hba_down_post
Signed-off-by: James Smart <james.smart@emulex.com>
Reviewed-By: Dick Kennedy <dick.kennedy@emulex.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r-- | drivers/scsi/lpfc/lpfc_init.c | 79 |
1 files changed, 60 insertions, 19 deletions
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 635eeb3d6987..b2671dd520db 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c | |||
@@ -820,29 +820,28 @@ lpfc_hba_down_prep(struct lpfc_hba *phba) | |||
820 | } | 820 | } |
821 | 821 | ||
822 | /** | 822 | /** |
823 | * lpfc_hba_down_post_s3 - Perform lpfc uninitialization after HBA reset | 823 | * lpfc_hba_free_post_buf - Perform lpfc uninitialization after HBA reset |
824 | * @phba: pointer to lpfc HBA data structure. | 824 | * @phba: pointer to lpfc HBA data structure. |
825 | * | 825 | * |
826 | * This routine will do uninitialization after the HBA is reset when bring | 826 | * This routine will cleanup posted ELS buffers after the HBA is reset |
827 | * down the SLI Layer. | 827 | * when bringing down the SLI Layer. |
828 | * | ||
828 | * | 829 | * |
829 | * Return codes | 830 | * Return codes |
830 | * 0 - success. | 831 | * void. |
831 | * Any other value - error. | ||
832 | **/ | 832 | **/ |
833 | static int | 833 | static void |
834 | lpfc_hba_down_post_s3(struct lpfc_hba *phba) | 834 | lpfc_hba_free_post_buf(struct lpfc_hba *phba) |
835 | { | 835 | { |
836 | struct lpfc_sli *psli = &phba->sli; | 836 | struct lpfc_sli *psli = &phba->sli; |
837 | struct lpfc_sli_ring *pring; | 837 | struct lpfc_sli_ring *pring; |
838 | struct lpfc_dmabuf *mp, *next_mp; | 838 | struct lpfc_dmabuf *mp, *next_mp; |
839 | LIST_HEAD(completions); | ||
840 | int i; | ||
841 | 839 | ||
842 | if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) | 840 | if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) |
843 | lpfc_sli_hbqbuf_free_all(phba); | 841 | lpfc_sli_hbqbuf_free_all(phba); |
844 | else { | 842 | else { |
845 | /* Cleanup preposted buffers on the ELS ring */ | 843 | /* Cleanup preposted buffers on the ELS ring */ |
844 | spin_lock_irq(&phba->hbalock); | ||
846 | pring = &psli->ring[LPFC_ELS_RING]; | 845 | pring = &psli->ring[LPFC_ELS_RING]; |
847 | list_for_each_entry_safe(mp, next_mp, &pring->postbufq, list) { | 846 | list_for_each_entry_safe(mp, next_mp, &pring->postbufq, list) { |
848 | list_del(&mp->list); | 847 | list_del(&mp->list); |
@@ -850,27 +849,70 @@ lpfc_hba_down_post_s3(struct lpfc_hba *phba) | |||
850 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | 849 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
851 | kfree(mp); | 850 | kfree(mp); |
852 | } | 851 | } |
852 | spin_unlock_irq(&phba->hbalock); | ||
853 | } | 853 | } |
854 | } | ||
855 | |||
856 | /** | ||
857 | * lpfc_hba_clean_txcmplq - Perform lpfc uninitialization after HBA reset | ||
858 | * @phba: pointer to lpfc HBA data structure. | ||
859 | * | ||
860 | * This routine will cleanup the txcmplq after the HBA is reset when bringing | ||
861 | * down the SLI Layer. | ||
862 | * | ||
863 | * Return codes | ||
864 | * void | ||
865 | **/ | ||
866 | static void | ||
867 | lpfc_hba_clean_txcmplq(struct lpfc_hba *phba) | ||
868 | { | ||
869 | struct lpfc_sli *psli = &phba->sli; | ||
870 | struct lpfc_sli_ring *pring; | ||
871 | LIST_HEAD(completions); | ||
872 | int i; | ||
873 | |||
874 | |||
854 | 875 | ||
855 | spin_lock_irq(&phba->hbalock); | ||
856 | for (i = 0; i < psli->num_rings; i++) { | 876 | for (i = 0; i < psli->num_rings; i++) { |
857 | pring = &psli->ring[i]; | 877 | pring = &psli->ring[i]; |
858 | 878 | if (phba->sli_rev >= LPFC_SLI_REV4) | |
879 | spin_lock_irq(&pring->ring_lock); | ||
880 | else | ||
881 | spin_lock_irq(&phba->hbalock); | ||
859 | /* At this point in time the HBA is either reset or DOA. Either | 882 | /* At this point in time the HBA is either reset or DOA. Either |
860 | * way, nothing should be on txcmplq as it will NEVER complete. | 883 | * way, nothing should be on txcmplq as it will NEVER complete. |
861 | */ | 884 | */ |
862 | list_splice_init(&pring->txcmplq, &completions); | 885 | list_splice_init(&pring->txcmplq, &completions); |
863 | spin_unlock_irq(&phba->hbalock); | 886 | |
887 | if (phba->sli_rev >= LPFC_SLI_REV4) | ||
888 | spin_unlock_irq(&pring->ring_lock); | ||
889 | else | ||
890 | spin_unlock_irq(&phba->hbalock); | ||
864 | 891 | ||
865 | /* Cancel all the IOCBs from the completions list */ | 892 | /* Cancel all the IOCBs from the completions list */ |
866 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, | 893 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
867 | IOERR_SLI_ABORTED); | 894 | IOERR_SLI_ABORTED); |
868 | |||
869 | lpfc_sli_abort_iocb_ring(phba, pring); | 895 | lpfc_sli_abort_iocb_ring(phba, pring); |
870 | spin_lock_irq(&phba->hbalock); | ||
871 | } | 896 | } |
872 | spin_unlock_irq(&phba->hbalock); | 897 | } |
873 | 898 | ||
899 | /** | ||
900 | * lpfc_hba_down_post_s3 - Perform lpfc uninitialization after HBA reset | ||
901 | int i; | ||
902 | * @phba: pointer to lpfc HBA data structure. | ||
903 | * | ||
904 | * This routine will do uninitialization after the HBA is reset when bring | ||
905 | * down the SLI Layer. | ||
906 | * | ||
907 | * Return codes | ||
908 | * 0 - success. | ||
909 | * Any other value - error. | ||
910 | **/ | ||
911 | static int | ||
912 | lpfc_hba_down_post_s3(struct lpfc_hba *phba) | ||
913 | { | ||
914 | lpfc_hba_free_post_buf(phba); | ||
915 | lpfc_hba_clean_txcmplq(phba); | ||
874 | return 0; | 916 | return 0; |
875 | } | 917 | } |
876 | 918 | ||
@@ -890,13 +932,12 @@ lpfc_hba_down_post_s4(struct lpfc_hba *phba) | |||
890 | { | 932 | { |
891 | struct lpfc_scsi_buf *psb, *psb_next; | 933 | struct lpfc_scsi_buf *psb, *psb_next; |
892 | LIST_HEAD(aborts); | 934 | LIST_HEAD(aborts); |
893 | int ret; | ||
894 | unsigned long iflag = 0; | 935 | unsigned long iflag = 0; |
895 | struct lpfc_sglq *sglq_entry = NULL; | 936 | struct lpfc_sglq *sglq_entry = NULL; |
896 | 937 | ||
897 | ret = lpfc_hba_down_post_s3(phba); | 938 | lpfc_hba_free_post_buf(phba); |
898 | if (ret) | 939 | lpfc_hba_clean_txcmplq(phba); |
899 | return ret; | 940 | |
900 | /* At this point in time the HBA is either reset or DOA. Either | 941 | /* At this point in time the HBA is either reset or DOA. Either |
901 | * way, nothing should be on lpfc_abts_els_sgl_list, it needs to be | 942 | * way, nothing should be on lpfc_abts_els_sgl_list, it needs to be |
902 | * on the lpfc_sgl_list so that it can either be freed if the | 943 | * on the lpfc_sgl_list so that it can either be freed if the |