aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Smart <jsmart2021@gmail.com>2019-05-06 20:26:47 -0400
committerMartin K. Petersen <martin.petersen@oracle.com>2019-05-13 20:32:49 -0400
commite2a8be5696e706a2fce6edd11e5c74ce14cffec0 (patch)
tree3aa0d3314544e367b2fc452ff8f48e23f70a4d33
parentd0adee5d12752256ff0c87ad7f002f21fe49d618 (diff)
scsi: lpfc: resolve lockdep warnings
There were a number of erroneous comments and incorrect older lockdep checks that were causing a number of warnings. Resolve the following: - Inconsistent lock state warnings in lpfc_nvme_info_show(). - Fixed comments and code on sequences where ring lock is now held instead of hbalock. - Reworked calling sequences around lpfc_sli_iocbq_lookup(). Rather than locking prior to the routine and have routine guess on what lock, take the lock within the routine. The lockdep check becomes unnecessary. - Fixed comments and removed erroneous hbalock checks. Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com> Signed-off-by: James Smart <jsmart2021@gmail.com> CC: Bart Van Assche <bvanassche@acm.org> Tested-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c5
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c84
2 files changed, 56 insertions, 33 deletions
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index e9adb3f1961d..31b963ae7289 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -176,6 +176,7 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr,
176 int i; 176 int i;
177 int len = 0; 177 int len = 0;
178 char tmp[LPFC_MAX_NVME_INFO_TMP_LEN] = {0}; 178 char tmp[LPFC_MAX_NVME_INFO_TMP_LEN] = {0};
179 unsigned long iflags = 0;
179 180
180 if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) { 181 if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) {
181 len = scnprintf(buf, PAGE_SIZE, "NVME Disabled\n"); 182 len = scnprintf(buf, PAGE_SIZE, "NVME Disabled\n");
@@ -374,11 +375,11 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr,
374 375
375 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { 376 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
376 nrport = NULL; 377 nrport = NULL;
377 spin_lock(&vport->phba->hbalock); 378 spin_lock_irqsave(&vport->phba->hbalock, iflags);
378 rport = lpfc_ndlp_get_nrport(ndlp); 379 rport = lpfc_ndlp_get_nrport(ndlp);
379 if (rport) 380 if (rport)
380 nrport = rport->remoteport; 381 nrport = rport->remoteport;
381 spin_unlock(&vport->phba->hbalock); 382 spin_unlock_irqrestore(&vport->phba->hbalock, iflags);
382 if (!nrport) 383 if (!nrport)
383 continue; 384 continue;
384 385
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 2acda188b0dc..d1512e4f9791 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -991,15 +991,14 @@ lpfc_cleanup_vports_rrqs(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
991 * @ndlp: Targets nodelist pointer for this exchange. 991 * @ndlp: Targets nodelist pointer for this exchange.
992 * @xritag the xri in the bitmap to test. 992 * @xritag the xri in the bitmap to test.
993 * 993 *
994 * This function is called with hbalock held. This function 994 * This function returns:
995 * returns 0 = rrq not active for this xri 995 * 0 = rrq not active for this xri
996 * 1 = rrq is valid for this xri. 996 * 1 = rrq is valid for this xri.
997 **/ 997 **/
998int 998int
999lpfc_test_rrq_active(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, 999lpfc_test_rrq_active(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
1000 uint16_t xritag) 1000 uint16_t xritag)
1001{ 1001{
1002 lockdep_assert_held(&phba->hbalock);
1003 if (!ndlp) 1002 if (!ndlp)
1004 return 0; 1003 return 0;
1005 if (!ndlp->active_rrqs_xri_bitmap) 1004 if (!ndlp->active_rrqs_xri_bitmap)
@@ -1102,10 +1101,11 @@ out:
1102 * @phba: Pointer to HBA context object. 1101 * @phba: Pointer to HBA context object.
1103 * @piocb: Pointer to the iocbq. 1102 * @piocb: Pointer to the iocbq.
1104 * 1103 *
1105 * This function is called with the ring lock held. This function 1104 * The driver calls this function with either the nvme ls ring lock
1106 * gets a new driver sglq object from the sglq list. If the 1105 * or the fc els ring lock held depending on the iocb usage. This function
1107 * list is not empty then it is successful, it returns pointer to the newly 1106 * gets a new driver sglq object from the sglq list. If the list is not empty
1108 * allocated sglq object else it returns NULL. 1107 * then it is successful, it returns pointer to the newly allocated sglq
1108 * object else it returns NULL.
1109 **/ 1109 **/
1110static struct lpfc_sglq * 1110static struct lpfc_sglq *
1111__lpfc_sli_get_els_sglq(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq) 1111__lpfc_sli_get_els_sglq(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq)
@@ -1115,9 +1115,15 @@ __lpfc_sli_get_els_sglq(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq)
1115 struct lpfc_sglq *start_sglq = NULL; 1115 struct lpfc_sglq *start_sglq = NULL;
1116 struct lpfc_io_buf *lpfc_cmd; 1116 struct lpfc_io_buf *lpfc_cmd;
1117 struct lpfc_nodelist *ndlp; 1117 struct lpfc_nodelist *ndlp;
1118 struct lpfc_sli_ring *pring = NULL;
1118 int found = 0; 1119 int found = 0;
1119 1120
1120 lockdep_assert_held(&phba->hbalock); 1121 if (piocbq->iocb_flag & LPFC_IO_NVME_LS)
1122 pring = phba->sli4_hba.nvmels_wq->pring;
1123 else
1124 pring = lpfc_phba_elsring(phba);
1125
1126 lockdep_assert_held(&pring->ring_lock);
1121 1127
1122 if (piocbq->iocb_flag & LPFC_IO_FCP) { 1128 if (piocbq->iocb_flag & LPFC_IO_FCP) {
1123 lpfc_cmd = (struct lpfc_io_buf *) piocbq->context1; 1129 lpfc_cmd = (struct lpfc_io_buf *) piocbq->context1;
@@ -1560,7 +1566,8 @@ lpfc_sli_ring_map(struct lpfc_hba *phba)
1560 * @pring: Pointer to driver SLI ring object. 1566 * @pring: Pointer to driver SLI ring object.
1561 * @piocb: Pointer to the driver iocb object. 1567 * @piocb: Pointer to the driver iocb object.
1562 * 1568 *
1563 * This function is called with hbalock held. The function adds the 1569 * The driver calls this function with the hbalock held for SLI3 ports or
1570 * the ring lock held for SLI4 ports. The function adds the
1564 * new iocb to txcmplq of the given ring. This function always returns 1571 * new iocb to txcmplq of the given ring. This function always returns
1565 * 0. If this function is called for ELS ring, this function checks if 1572 * 0. If this function is called for ELS ring, this function checks if
1566 * there is a vport associated with the ELS command. This function also 1573 * there is a vport associated with the ELS command. This function also
@@ -1570,7 +1577,10 @@ static int
1570lpfc_sli_ringtxcmpl_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, 1577lpfc_sli_ringtxcmpl_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
1571 struct lpfc_iocbq *piocb) 1578 struct lpfc_iocbq *piocb)
1572{ 1579{
1573 lockdep_assert_held(&phba->hbalock); 1580 if (phba->sli_rev == LPFC_SLI_REV4)
1581 lockdep_assert_held(&pring->ring_lock);
1582 else
1583 lockdep_assert_held(&phba->hbalock);
1574 1584
1575 BUG_ON(!piocb); 1585 BUG_ON(!piocb);
1576 1586
@@ -2967,8 +2977,8 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
2967 * 2977 *
2968 * This function looks up the iocb_lookup table to get the command iocb 2978 * This function looks up the iocb_lookup table to get the command iocb
2969 * corresponding to the given response iocb using the iotag of the 2979 * corresponding to the given response iocb using the iotag of the
2970 * response iocb. This function is called with the hbalock held 2980 * response iocb. The driver calls this function with the hbalock held
2971 * for sli3 devices or the ring_lock for sli4 devices. 2981 * for SLI3 ports or the ring lock held for SLI4 ports.
2972 * This function returns the command iocb object if it finds the command 2982 * This function returns the command iocb object if it finds the command
2973 * iocb else returns NULL. 2983 * iocb else returns NULL.
2974 **/ 2984 **/
@@ -2979,8 +2989,15 @@ lpfc_sli_iocbq_lookup(struct lpfc_hba *phba,
2979{ 2989{
2980 struct lpfc_iocbq *cmd_iocb = NULL; 2990 struct lpfc_iocbq *cmd_iocb = NULL;
2981 uint16_t iotag; 2991 uint16_t iotag;
2982 lockdep_assert_held(&phba->hbalock); 2992 spinlock_t *temp_lock = NULL;
2993 unsigned long iflag = 0;
2983 2994
2995 if (phba->sli_rev == LPFC_SLI_REV4)
2996 temp_lock = &pring->ring_lock;
2997 else
2998 temp_lock = &phba->hbalock;
2999
3000 spin_lock_irqsave(temp_lock, iflag);
2984 iotag = prspiocb->iocb.ulpIoTag; 3001 iotag = prspiocb->iocb.ulpIoTag;
2985 3002
2986 if (iotag != 0 && iotag <= phba->sli.last_iotag) { 3003 if (iotag != 0 && iotag <= phba->sli.last_iotag) {
@@ -2990,10 +3007,12 @@ lpfc_sli_iocbq_lookup(struct lpfc_hba *phba,
2990 list_del_init(&cmd_iocb->list); 3007 list_del_init(&cmd_iocb->list);
2991 cmd_iocb->iocb_flag &= ~LPFC_IO_ON_TXCMPLQ; 3008 cmd_iocb->iocb_flag &= ~LPFC_IO_ON_TXCMPLQ;
2992 pring->txcmplq_cnt--; 3009 pring->txcmplq_cnt--;
3010 spin_unlock_irqrestore(temp_lock, iflag);
2993 return cmd_iocb; 3011 return cmd_iocb;
2994 } 3012 }
2995 } 3013 }
2996 3014
3015 spin_unlock_irqrestore(temp_lock, iflag);
2997 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 3016 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
2998 "0317 iotag x%x is out of " 3017 "0317 iotag x%x is out of "
2999 "range: max iotag x%x wd0 x%x\n", 3018 "range: max iotag x%x wd0 x%x\n",
@@ -3009,8 +3028,8 @@ lpfc_sli_iocbq_lookup(struct lpfc_hba *phba,
3009 * @iotag: IOCB tag. 3028 * @iotag: IOCB tag.
3010 * 3029 *
3011 * This function looks up the iocb_lookup table to get the command iocb 3030 * This function looks up the iocb_lookup table to get the command iocb
3012 * corresponding to the given iotag. This function is called with the 3031 * corresponding to the given iotag. The driver calls this function with
3013 * hbalock held. 3032 * the ring lock held because this function is an SLI4 port only helper.
3014 * This function returns the command iocb object if it finds the command 3033 * This function returns the command iocb object if it finds the command
3015 * iocb else returns NULL. 3034 * iocb else returns NULL.
3016 **/ 3035 **/
@@ -3019,8 +3038,15 @@ lpfc_sli_iocbq_lookup_by_tag(struct lpfc_hba *phba,
3019 struct lpfc_sli_ring *pring, uint16_t iotag) 3038 struct lpfc_sli_ring *pring, uint16_t iotag)
3020{ 3039{
3021 struct lpfc_iocbq *cmd_iocb = NULL; 3040 struct lpfc_iocbq *cmd_iocb = NULL;
3041 spinlock_t *temp_lock = NULL;
3042 unsigned long iflag = 0;
3022 3043
3023 lockdep_assert_held(&phba->hbalock); 3044 if (phba->sli_rev == LPFC_SLI_REV4)
3045 temp_lock = &pring->ring_lock;
3046 else
3047 temp_lock = &phba->hbalock;
3048
3049 spin_lock_irqsave(temp_lock, iflag);
3024 if (iotag != 0 && iotag <= phba->sli.last_iotag) { 3050 if (iotag != 0 && iotag <= phba->sli.last_iotag) {
3025 cmd_iocb = phba->sli.iocbq_lookup[iotag]; 3051 cmd_iocb = phba->sli.iocbq_lookup[iotag];
3026 if (cmd_iocb->iocb_flag & LPFC_IO_ON_TXCMPLQ) { 3052 if (cmd_iocb->iocb_flag & LPFC_IO_ON_TXCMPLQ) {
@@ -3028,10 +3054,12 @@ lpfc_sli_iocbq_lookup_by_tag(struct lpfc_hba *phba,
3028 list_del_init(&cmd_iocb->list); 3054 list_del_init(&cmd_iocb->list);
3029 cmd_iocb->iocb_flag &= ~LPFC_IO_ON_TXCMPLQ; 3055 cmd_iocb->iocb_flag &= ~LPFC_IO_ON_TXCMPLQ;
3030 pring->txcmplq_cnt--; 3056 pring->txcmplq_cnt--;
3057 spin_unlock_irqrestore(temp_lock, iflag);
3031 return cmd_iocb; 3058 return cmd_iocb;
3032 } 3059 }
3033 } 3060 }
3034 3061
3062 spin_unlock_irqrestore(temp_lock, iflag);
3035 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 3063 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
3036 "0372 iotag x%x lookup error: max iotag (x%x) " 3064 "0372 iotag x%x lookup error: max iotag (x%x) "
3037 "iocb_flag x%x\n", 3065 "iocb_flag x%x\n",
@@ -3065,17 +3093,7 @@ lpfc_sli_process_sol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
3065 int rc = 1; 3093 int rc = 1;
3066 unsigned long iflag; 3094 unsigned long iflag;
3067 3095
3068 /* Based on the iotag field, get the cmd IOCB from the txcmplq */
3069 if (phba->sli_rev == LPFC_SLI_REV4)
3070 spin_lock_irqsave(&pring->ring_lock, iflag);
3071 else
3072 spin_lock_irqsave(&phba->hbalock, iflag);
3073 cmdiocbp = lpfc_sli_iocbq_lookup(phba, pring, saveq); 3096 cmdiocbp = lpfc_sli_iocbq_lookup(phba, pring, saveq);
3074 if (phba->sli_rev == LPFC_SLI_REV4)
3075 spin_unlock_irqrestore(&pring->ring_lock, iflag);
3076 else
3077 spin_unlock_irqrestore(&phba->hbalock, iflag);
3078
3079 if (cmdiocbp) { 3097 if (cmdiocbp) {
3080 if (cmdiocbp->iocb_cmpl) { 3098 if (cmdiocbp->iocb_cmpl) {
3081 /* 3099 /*
@@ -3406,8 +3424,10 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba *phba,
3406 break; 3424 break;
3407 } 3425 }
3408 3426
3427 spin_unlock_irqrestore(&phba->hbalock, iflag);
3409 cmdiocbq = lpfc_sli_iocbq_lookup(phba, pring, 3428 cmdiocbq = lpfc_sli_iocbq_lookup(phba, pring,
3410 &rspiocbq); 3429 &rspiocbq);
3430 spin_lock_irqsave(&phba->hbalock, iflag);
3411 if (unlikely(!cmdiocbq)) 3431 if (unlikely(!cmdiocbq))
3412 break; 3432 break;
3413 if (cmdiocbq->iocb_flag & LPFC_DRIVER_ABORTED) 3433 if (cmdiocbq->iocb_flag & LPFC_DRIVER_ABORTED)
@@ -3601,9 +3621,12 @@ lpfc_sli_sp_handle_rspiocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
3601 3621
3602 case LPFC_ABORT_IOCB: 3622 case LPFC_ABORT_IOCB:
3603 cmdiocbp = NULL; 3623 cmdiocbp = NULL;
3604 if (irsp->ulpCommand != CMD_XRI_ABORTED_CX) 3624 if (irsp->ulpCommand != CMD_XRI_ABORTED_CX) {
3625 spin_unlock_irqrestore(&phba->hbalock, iflag);
3605 cmdiocbp = lpfc_sli_iocbq_lookup(phba, pring, 3626 cmdiocbp = lpfc_sli_iocbq_lookup(phba, pring,
3606 saveq); 3627 saveq);
3628 spin_lock_irqsave(&phba->hbalock, iflag);
3629 }
3607 if (cmdiocbp) { 3630 if (cmdiocbp) {
3608 /* Call the specified completion routine */ 3631 /* Call the specified completion routine */
3609 if (cmdiocbp->iocb_cmpl) { 3632 if (cmdiocbp->iocb_cmpl) {
@@ -12976,13 +12999,11 @@ lpfc_sli4_els_wcqe_to_rspiocbq(struct lpfc_hba *phba,
12976 return NULL; 12999 return NULL;
12977 13000
12978 wcqe = &irspiocbq->cq_event.cqe.wcqe_cmpl; 13001 wcqe = &irspiocbq->cq_event.cqe.wcqe_cmpl;
12979 spin_lock_irqsave(&pring->ring_lock, iflags);
12980 pring->stats.iocb_event++; 13002 pring->stats.iocb_event++;
12981 /* Look up the ELS command IOCB and create pseudo response IOCB */ 13003 /* Look up the ELS command IOCB and create pseudo response IOCB */
12982 cmdiocbq = lpfc_sli_iocbq_lookup_by_tag(phba, pring, 13004 cmdiocbq = lpfc_sli_iocbq_lookup_by_tag(phba, pring,
12983 bf_get(lpfc_wcqe_c_request_tag, wcqe)); 13005 bf_get(lpfc_wcqe_c_request_tag, wcqe));
12984 if (unlikely(!cmdiocbq)) { 13006 if (unlikely(!cmdiocbq)) {
12985 spin_unlock_irqrestore(&pring->ring_lock, iflags);
12986 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI, 13007 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI,
12987 "0386 ELS complete with no corresponding " 13008 "0386 ELS complete with no corresponding "
12988 "cmdiocb: 0x%x 0x%x 0x%x 0x%x\n", 13009 "cmdiocb: 0x%x 0x%x 0x%x 0x%x\n",
@@ -12992,6 +13013,7 @@ lpfc_sli4_els_wcqe_to_rspiocbq(struct lpfc_hba *phba,
12992 return NULL; 13013 return NULL;
12993 } 13014 }
12994 13015
13016 spin_lock_irqsave(&pring->ring_lock, iflags);
12995 /* Put the iocb back on the txcmplq */ 13017 /* Put the iocb back on the txcmplq */
12996 lpfc_sli_ringtxcmpl_put(phba, pring, cmdiocbq); 13018 lpfc_sli_ringtxcmpl_put(phba, pring, cmdiocbq);
12997 spin_unlock_irqrestore(&pring->ring_lock, iflags); 13019 spin_unlock_irqrestore(&pring->ring_lock, iflags);
@@ -13762,9 +13784,9 @@ lpfc_sli4_fp_handle_fcp_wcqe(struct lpfc_hba *phba, struct lpfc_queue *cq,
13762 /* Look up the FCP command IOCB and create pseudo response IOCB */ 13784 /* Look up the FCP command IOCB and create pseudo response IOCB */
13763 spin_lock_irqsave(&pring->ring_lock, iflags); 13785 spin_lock_irqsave(&pring->ring_lock, iflags);
13764 pring->stats.iocb_event++; 13786 pring->stats.iocb_event++;
13787 spin_unlock_irqrestore(&pring->ring_lock, iflags);
13765 cmdiocbq = lpfc_sli_iocbq_lookup_by_tag(phba, pring, 13788 cmdiocbq = lpfc_sli_iocbq_lookup_by_tag(phba, pring,
13766 bf_get(lpfc_wcqe_c_request_tag, wcqe)); 13789 bf_get(lpfc_wcqe_c_request_tag, wcqe));
13767 spin_unlock_irqrestore(&pring->ring_lock, iflags);
13768 if (unlikely(!cmdiocbq)) { 13790 if (unlikely(!cmdiocbq)) {
13769 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI, 13791 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI,
13770 "0374 FCP complete with no corresponding " 13792 "0374 FCP complete with no corresponding "