Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: lpfc: Use a dedicated lock for ras_fwlog state

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>

authored by

Justin Tee and committed by
Martin K. Petersen
f733a76e ded20192

+32 -28
+1
drivers/scsi/lpfc/lpfc.h
··· 1437 1437 struct timer_list inactive_vmid_poll; 1438 1438 1439 1439 /* RAS Support */ 1440 + spinlock_t ras_fwlog_lock; /* do not take while holding another lock */ 1440 1441 struct lpfc_ras_fwlog ras_fwlog; 1441 1442 1442 1443 uint32_t iocb_cnt;
+2 -2
drivers/scsi/lpfc/lpfc_attr.c
··· 5865 5865 if (phba->cfg_ras_fwlog_func != PCI_FUNC(phba->pcidev->devfn)) 5866 5866 return -EINVAL; 5867 5867 5868 - spin_lock_irq(&phba->hbalock); 5868 + spin_lock_irq(&phba->ras_fwlog_lock); 5869 5869 state = phba->ras_fwlog.state; 5870 - spin_unlock_irq(&phba->hbalock); 5870 + spin_unlock_irq(&phba->ras_fwlog_lock); 5871 5871 5872 5872 if (state == REG_INPROGRESS) { 5873 5873 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, "6147 RAS Logging "
+10 -10
drivers/scsi/lpfc/lpfc_bsg.c
··· 5070 5070 bsg_reply->reply_data.vendor_reply.vendor_rsp; 5071 5071 5072 5072 /* Current logging state */ 5073 - spin_lock_irq(&phba->hbalock); 5073 + spin_lock_irq(&phba->ras_fwlog_lock); 5074 5074 if (ras_fwlog->state == ACTIVE) 5075 5075 ras_reply->state = LPFC_RASLOG_STATE_RUNNING; 5076 5076 else 5077 5077 ras_reply->state = LPFC_RASLOG_STATE_STOPPED; 5078 - spin_unlock_irq(&phba->hbalock); 5078 + spin_unlock_irq(&phba->ras_fwlog_lock); 5079 5079 5080 5080 ras_reply->log_level = phba->ras_fwlog.fw_loglevel; 5081 5081 ras_reply->log_buff_sz = phba->cfg_ras_fwlog_buffsize; ··· 5132 5132 5133 5133 if (action == LPFC_RASACTION_STOP_LOGGING) { 5134 5134 /* Check if already disabled */ 5135 - spin_lock_irq(&phba->hbalock); 5135 + spin_lock_irq(&phba->ras_fwlog_lock); 5136 5136 if (ras_fwlog->state != ACTIVE) { 5137 - spin_unlock_irq(&phba->hbalock); 5137 + spin_unlock_irq(&phba->ras_fwlog_lock); 5138 5138 rc = -ESRCH; 5139 5139 goto ras_job_error; 5140 5140 } 5141 - spin_unlock_irq(&phba->hbalock); 5141 + spin_unlock_irq(&phba->ras_fwlog_lock); 5142 5142 5143 5143 /* Disable logging */ 5144 5144 lpfc_ras_stop_fwlog(phba); ··· 5149 5149 * FW-logging with new log-level. Return status 5150 5150 * "Logging already Running" to caller. 5151 5151 **/ 5152 - spin_lock_irq(&phba->hbalock); 5152 + spin_lock_irq(&phba->ras_fwlog_lock); 5153 5153 if (ras_fwlog->state != INACTIVE) 5154 5154 action_status = -EINPROGRESS; 5155 - spin_unlock_irq(&phba->hbalock); 5155 + spin_unlock_irq(&phba->ras_fwlog_lock); 5156 5156 5157 5157 /* Enable logging */ 5158 5158 rc = lpfc_sli4_ras_fwlog_init(phba, log_level, ··· 5268 5268 goto ras_job_error; 5269 5269 5270 5270 /* Logging to be stopped before reading */ 5271 - spin_lock_irq(&phba->hbalock); 5271 + spin_lock_irq(&phba->ras_fwlog_lock); 5272 5272 if (ras_fwlog->state == ACTIVE) { 5273 - spin_unlock_irq(&phba->hbalock); 5273 + spin_unlock_irq(&phba->ras_fwlog_lock); 5274 5274 rc = -EINPROGRESS; 5275 5275 goto ras_job_error; 5276 5276 } 5277 - spin_unlock_irq(&phba->hbalock); 5277 + spin_unlock_irq(&phba->ras_fwlog_lock); 5278 5278 5279 5279 if (job->request_len < 5280 5280 sizeof(struct fc_bsg_request) +
+6 -6
drivers/scsi/lpfc/lpfc_debugfs.c
··· 2194 2194 2195 2195 memset(buffer, 0, size); 2196 2196 2197 - spin_lock_irq(&phba->hbalock); 2197 + spin_lock_irq(&phba->ras_fwlog_lock); 2198 2198 if (phba->ras_fwlog.state != ACTIVE) { 2199 - spin_unlock_irq(&phba->hbalock); 2199 + spin_unlock_irq(&phba->ras_fwlog_lock); 2200 2200 return -EINVAL; 2201 2201 } 2202 - spin_unlock_irq(&phba->hbalock); 2202 + spin_unlock_irq(&phba->ras_fwlog_lock); 2203 2203 2204 2204 list_for_each_entry_safe(dmabuf, next, 2205 2205 &phba->ras_fwlog.fwlog_buff_list, list) { ··· 2250 2250 int size; 2251 2251 int rc = -ENOMEM; 2252 2252 2253 - spin_lock_irq(&phba->hbalock); 2253 + spin_lock_irq(&phba->ras_fwlog_lock); 2254 2254 if (phba->ras_fwlog.state != ACTIVE) { 2255 - spin_unlock_irq(&phba->hbalock); 2255 + spin_unlock_irq(&phba->ras_fwlog_lock); 2256 2256 rc = -EINVAL; 2257 2257 goto out; 2258 2258 } 2259 - spin_unlock_irq(&phba->hbalock); 2259 + spin_unlock_irq(&phba->ras_fwlog_lock); 2260 2260 2261 2261 if (check_mul_overflow(LPFC_RAS_MIN_BUFF_POST_SIZE, 2262 2262 phba->cfg_ras_fwlog_buffsize, &size))
+3
drivers/scsi/lpfc/lpfc_init.c
··· 7705 7705 "NVME" : " "), 7706 7706 (phba->nvmet_support ? "NVMET" : " ")); 7707 7707 7708 + /* ras_fwlog state */ 7709 + spin_lock_init(&phba->ras_fwlog_lock); 7710 + 7708 7711 /* Initialize the IO buffer list used by driver for SLI3 SCSI */ 7709 7712 spin_lock_init(&phba->scsi_buf_list_get_lock); 7710 7713 INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_get);
+10 -10
drivers/scsi/lpfc/lpfc_sli.c
··· 6849 6849 { 6850 6850 struct lpfc_ras_fwlog *ras_fwlog = &phba->ras_fwlog; 6851 6851 6852 - spin_lock_irq(&phba->hbalock); 6852 + spin_lock_irq(&phba->ras_fwlog_lock); 6853 6853 ras_fwlog->state = INACTIVE; 6854 - spin_unlock_irq(&phba->hbalock); 6854 + spin_unlock_irq(&phba->ras_fwlog_lock); 6855 6855 6856 6856 /* Disable FW logging to host memory */ 6857 6857 writel(LPFC_CTL_PDEV_CTL_DDL_RAS, ··· 6894 6894 ras_fwlog->lwpd.virt = NULL; 6895 6895 } 6896 6896 6897 - spin_lock_irq(&phba->hbalock); 6897 + spin_lock_irq(&phba->ras_fwlog_lock); 6898 6898 ras_fwlog->state = INACTIVE; 6899 - spin_unlock_irq(&phba->hbalock); 6899 + spin_unlock_irq(&phba->ras_fwlog_lock); 6900 6900 } 6901 6901 6902 6902 /** ··· 6998 6998 goto disable_ras; 6999 6999 } 7000 7000 7001 - spin_lock_irq(&phba->hbalock); 7001 + spin_lock_irq(&phba->ras_fwlog_lock); 7002 7002 ras_fwlog->state = ACTIVE; 7003 - spin_unlock_irq(&phba->hbalock); 7003 + spin_unlock_irq(&phba->ras_fwlog_lock); 7004 7004 mempool_free(pmb, phba->mbox_mem_pool); 7005 7005 7006 7006 return; ··· 7032 7032 uint32_t len = 0, fwlog_buffsize, fwlog_entry_count; 7033 7033 int rc = 0; 7034 7034 7035 - spin_lock_irq(&phba->hbalock); 7035 + spin_lock_irq(&phba->ras_fwlog_lock); 7036 7036 ras_fwlog->state = INACTIVE; 7037 - spin_unlock_irq(&phba->hbalock); 7037 + spin_unlock_irq(&phba->ras_fwlog_lock); 7038 7038 7039 7039 fwlog_buffsize = (LPFC_RAS_MIN_BUFF_POST_SIZE * 7040 7040 phba->cfg_ras_fwlog_buffsize); ··· 7095 7095 mbx_fwlog->u.request.lwpd.addr_lo = putPaddrLow(ras_fwlog->lwpd.phys); 7096 7096 mbx_fwlog->u.request.lwpd.addr_hi = putPaddrHigh(ras_fwlog->lwpd.phys); 7097 7097 7098 - spin_lock_irq(&phba->hbalock); 7098 + spin_lock_irq(&phba->ras_fwlog_lock); 7099 7099 ras_fwlog->state = REG_INPROGRESS; 7100 - spin_unlock_irq(&phba->hbalock); 7100 + spin_unlock_irq(&phba->ras_fwlog_lock); 7101 7101 mbox->vport = phba->pport; 7102 7102 mbox->mbox_cmpl = lpfc_sli4_ras_mbox_cmpl; 7103 7103