Commit 07eab624e5cf471450ed7b8c4ba8521e910dc9cf
Committed by
Christoph Hellwig
1 parent
bcece5f557
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
lpfc: Fix locking for postbufq when freeing
Fix locking for postbufq when freeing 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>
Showing 1 changed file with 12 additions and 3 deletions Side-by-side Diff
drivers/scsi/lpfc/lpfc_init.c
... | ... | @@ -836,19 +836,28 @@ |
836 | 836 | struct lpfc_sli *psli = &phba->sli; |
837 | 837 | struct lpfc_sli_ring *pring; |
838 | 838 | struct lpfc_dmabuf *mp, *next_mp; |
839 | + LIST_HEAD(buflist); | |
840 | + int count; | |
839 | 841 | |
840 | 842 | if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) |
841 | 843 | lpfc_sli_hbqbuf_free_all(phba); |
842 | 844 | else { |
843 | 845 | /* Cleanup preposted buffers on the ELS ring */ |
844 | - spin_lock_irq(&phba->hbalock); | |
845 | 846 | pring = &psli->ring[LPFC_ELS_RING]; |
846 | - list_for_each_entry_safe(mp, next_mp, &pring->postbufq, list) { | |
847 | + spin_lock_irq(&phba->hbalock); | |
848 | + list_splice_init(&pring->postbufq, &buflist); | |
849 | + spin_unlock_irq(&phba->hbalock); | |
850 | + | |
851 | + count = 0; | |
852 | + list_for_each_entry_safe(mp, next_mp, &buflist, list) { | |
847 | 853 | list_del(&mp->list); |
848 | - pring->postbufq_cnt--; | |
854 | + count++; | |
849 | 855 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
850 | 856 | kfree(mp); |
851 | 857 | } |
858 | + | |
859 | + spin_lock_irq(&phba->hbalock); | |
860 | + pring->postbufq_cnt -= count; | |
852 | 861 | spin_unlock_irq(&phba->hbalock); |
853 | 862 | } |
854 | 863 | } |