scsi: lpfc: Use a dedicated lock for ras_fwlog state
authorJustin Tee <justin.tee@broadcom.com>
Tue, 5 Mar 2024 20:04:58 +0000 (12:04 -0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Sun, 10 Mar 2024 22:56:43 +0000 (18:56 -0400)
To reduce usage of and contention for hbalock, a separate dedicated lock is
used to protect ras_fwlog state.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20240305200503.57317-8-justintee8345@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/lpfc/lpfc.h
drivers/scsi/lpfc/lpfc_attr.c
drivers/scsi/lpfc/lpfc_bsg.c
drivers/scsi/lpfc/lpfc_debugfs.c
drivers/scsi/lpfc/lpfc_init.c
drivers/scsi/lpfc/lpfc_sli.c

index 18cbfd371cccddf67af8ad95c478ec1708ab4590..98ca7df003efb377427ceed6ac431b0c1e6a97d5 100644 (file)
@@ -1437,6 +1437,7 @@ struct lpfc_hba {
        struct timer_list inactive_vmid_poll;
 
        /* RAS Support */
+       spinlock_t ras_fwlog_lock; /* do not take while holding another lock */
        struct lpfc_ras_fwlog ras_fwlog;
 
        uint32_t iocb_cnt;
index 365c7e96070bb7aec4cad7fa09f17eb0aa8b6345..3c534b3cfe9186857b6109f668c161af704eda6d 100644 (file)
@@ -5865,9 +5865,9 @@ lpfc_ras_fwlog_buffsize_set(struct lpfc_hba  *phba, uint val)
        if (phba->cfg_ras_fwlog_func != PCI_FUNC(phba->pcidev->devfn))
                return -EINVAL;
 
-       spin_lock_irq(&phba->hbalock);
+       spin_lock_irq(&phba->ras_fwlog_lock);
        state = phba->ras_fwlog.state;
-       spin_unlock_irq(&phba->hbalock);
+       spin_unlock_irq(&phba->ras_fwlog_lock);
 
        if (state == REG_INPROGRESS) {
                lpfc_printf_log(phba, KERN_ERR, LOG_SLI, "6147 RAS Logging "
index d80e6e81053b0a9d61aec5574d2d5d3a2d241e64..fee485e47041280f2aa6d5f95f25201a31edb4c9 100644 (file)
@@ -5070,12 +5070,12 @@ lpfc_bsg_get_ras_config(struct bsg_job *job)
                bsg_reply->reply_data.vendor_reply.vendor_rsp;
 
        /* Current logging state */
-       spin_lock_irq(&phba->hbalock);
+       spin_lock_irq(&phba->ras_fwlog_lock);
        if (ras_fwlog->state == ACTIVE)
                ras_reply->state = LPFC_RASLOG_STATE_RUNNING;
        else
                ras_reply->state = LPFC_RASLOG_STATE_STOPPED;
-       spin_unlock_irq(&phba->hbalock);
+       spin_unlock_irq(&phba->ras_fwlog_lock);
 
        ras_reply->log_level = phba->ras_fwlog.fw_loglevel;
        ras_reply->log_buff_sz = phba->cfg_ras_fwlog_buffsize;
@@ -5132,13 +5132,13 @@ lpfc_bsg_set_ras_config(struct bsg_job *job)
 
        if (action == LPFC_RASACTION_STOP_LOGGING) {
                /* Check if already disabled */
-               spin_lock_irq(&phba->hbalock);
+               spin_lock_irq(&phba->ras_fwlog_lock);
                if (ras_fwlog->state != ACTIVE) {
-                       spin_unlock_irq(&phba->hbalock);
+                       spin_unlock_irq(&phba->ras_fwlog_lock);
                        rc = -ESRCH;
                        goto ras_job_error;
                }
-               spin_unlock_irq(&phba->hbalock);
+               spin_unlock_irq(&phba->ras_fwlog_lock);
 
                /* Disable logging */
                lpfc_ras_stop_fwlog(phba);
@@ -5149,10 +5149,10 @@ lpfc_bsg_set_ras_config(struct bsg_job *job)
                 * FW-logging with new log-level. Return status
                 * "Logging already Running" to caller.
                 **/
-               spin_lock_irq(&phba->hbalock);
+               spin_lock_irq(&phba->ras_fwlog_lock);
                if (ras_fwlog->state != INACTIVE)
                        action_status = -EINPROGRESS;
-               spin_unlock_irq(&phba->hbalock);
+               spin_unlock_irq(&phba->ras_fwlog_lock);
 
                /* Enable logging */
                rc = lpfc_sli4_ras_fwlog_init(phba, log_level,
@@ -5268,13 +5268,13 @@ lpfc_bsg_get_ras_fwlog(struct bsg_job *job)
                goto ras_job_error;
 
        /* Logging to be stopped before reading */
-       spin_lock_irq(&phba->hbalock);
+       spin_lock_irq(&phba->ras_fwlog_lock);
        if (ras_fwlog->state == ACTIVE) {
-               spin_unlock_irq(&phba->hbalock);
+               spin_unlock_irq(&phba->ras_fwlog_lock);
                rc = -EINPROGRESS;
                goto ras_job_error;
        }
-       spin_unlock_irq(&phba->hbalock);
+       spin_unlock_irq(&phba->ras_fwlog_lock);
 
        if (job->request_len <
            sizeof(struct fc_bsg_request) +
index ab5af10c8a16ca597e1fbde60a3c4562981ea03c..a2d2b02b34187f92a28957b5d1c466e9e31d1a37 100644 (file)
@@ -2194,12 +2194,12 @@ static int lpfc_debugfs_ras_log_data(struct lpfc_hba *phba,
 
        memset(buffer, 0, size);
 
-       spin_lock_irq(&phba->hbalock);
+       spin_lock_irq(&phba->ras_fwlog_lock);
        if (phba->ras_fwlog.state != ACTIVE) {
-               spin_unlock_irq(&phba->hbalock);
+               spin_unlock_irq(&phba->ras_fwlog_lock);
                return -EINVAL;
        }
-       spin_unlock_irq(&phba->hbalock);
+       spin_unlock_irq(&phba->ras_fwlog_lock);
 
        list_for_each_entry_safe(dmabuf, next,
                                 &phba->ras_fwlog.fwlog_buff_list, list) {
@@ -2250,13 +2250,13 @@ lpfc_debugfs_ras_log_open(struct inode *inode, struct file *file)
        int size;
        int rc = -ENOMEM;
 
-       spin_lock_irq(&phba->hbalock);
+       spin_lock_irq(&phba->ras_fwlog_lock);
        if (phba->ras_fwlog.state != ACTIVE) {
-               spin_unlock_irq(&phba->hbalock);
+               spin_unlock_irq(&phba->ras_fwlog_lock);
                rc = -EINVAL;
                goto out;
        }
-       spin_unlock_irq(&phba->hbalock);
+       spin_unlock_irq(&phba->ras_fwlog_lock);
 
        if (check_mul_overflow(LPFC_RAS_MIN_BUFF_POST_SIZE,
                               phba->cfg_ras_fwlog_buffsize, &size))
index 3363b0db65aeda9b44cdd9e7f147055f7a11eff6..c4c305472285a30183057fe4782902f1b1b9b102 100644 (file)
@@ -7705,6 +7705,9 @@ lpfc_setup_driver_resource_phase1(struct lpfc_hba *phba)
                                "NVME" : " "),
                        (phba->nvmet_support ? "NVMET" : " "));
 
+       /* ras_fwlog state */
+       spin_lock_init(&phba->ras_fwlog_lock);
+
        /* Initialize the IO buffer list used by driver for SLI3 SCSI */
        spin_lock_init(&phba->scsi_buf_list_get_lock);
        INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_get);
index 030d7084e412f694ba88e373b58817a43eb0da83..7f87046e64b727711abc6890be91a5fa36b9ee2d 100644 (file)
@@ -6849,9 +6849,9 @@ lpfc_ras_stop_fwlog(struct lpfc_hba *phba)
 {
        struct lpfc_ras_fwlog *ras_fwlog = &phba->ras_fwlog;
 
-       spin_lock_irq(&phba->hbalock);
+       spin_lock_irq(&phba->ras_fwlog_lock);
        ras_fwlog->state = INACTIVE;
-       spin_unlock_irq(&phba->hbalock);
+       spin_unlock_irq(&phba->ras_fwlog_lock);
 
        /* Disable FW logging to host memory */
        writel(LPFC_CTL_PDEV_CTL_DDL_RAS,
@@ -6894,9 +6894,9 @@ lpfc_sli4_ras_dma_free(struct lpfc_hba *phba)
                ras_fwlog->lwpd.virt = NULL;
        }
 
-       spin_lock_irq(&phba->hbalock);
+       spin_lock_irq(&phba->ras_fwlog_lock);
        ras_fwlog->state = INACTIVE;
-       spin_unlock_irq(&phba->hbalock);
+       spin_unlock_irq(&phba->ras_fwlog_lock);
 }
 
 /**
@@ -6998,9 +6998,9 @@ lpfc_sli4_ras_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
                goto disable_ras;
        }
 
-       spin_lock_irq(&phba->hbalock);
+       spin_lock_irq(&phba->ras_fwlog_lock);
        ras_fwlog->state = ACTIVE;
-       spin_unlock_irq(&phba->hbalock);
+       spin_unlock_irq(&phba->ras_fwlog_lock);
        mempool_free(pmb, phba->mbox_mem_pool);
 
        return;
@@ -7032,9 +7032,9 @@ lpfc_sli4_ras_fwlog_init(struct lpfc_hba *phba,
        uint32_t len = 0, fwlog_buffsize, fwlog_entry_count;
        int rc = 0;
 
-       spin_lock_irq(&phba->hbalock);
+       spin_lock_irq(&phba->ras_fwlog_lock);
        ras_fwlog->state = INACTIVE;
-       spin_unlock_irq(&phba->hbalock);
+       spin_unlock_irq(&phba->ras_fwlog_lock);
 
        fwlog_buffsize = (LPFC_RAS_MIN_BUFF_POST_SIZE *
                          phba->cfg_ras_fwlog_buffsize);
@@ -7095,9 +7095,9 @@ lpfc_sli4_ras_fwlog_init(struct lpfc_hba *phba,
        mbx_fwlog->u.request.lwpd.addr_lo = putPaddrLow(ras_fwlog->lwpd.phys);
        mbx_fwlog->u.request.lwpd.addr_hi = putPaddrHigh(ras_fwlog->lwpd.phys);
 
-       spin_lock_irq(&phba->hbalock);
+       spin_lock_irq(&phba->ras_fwlog_lock);
        ras_fwlog->state = REG_INPROGRESS;
-       spin_unlock_irq(&phba->hbalock);
+       spin_unlock_irq(&phba->ras_fwlog_lock);
        mbox->vport = phba->pport;
        mbox->mbox_cmpl = lpfc_sli4_ras_mbox_cmpl;