Skip to content

Commit f733a76

Browse files
Justin Teemartinkpetersen
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent ded2019 commit f733a76

File tree

6 files changed

+32
-28
lines changed

6 files changed

+32
-28
lines changed

drivers/scsi/lpfc/lpfc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,6 +1437,7 @@ struct lpfc_hba {
14371437
struct timer_list inactive_vmid_poll;
14381438

14391439
/* RAS Support */
1440+
spinlock_t ras_fwlog_lock; /* do not take while holding another lock */
14401441
struct lpfc_ras_fwlog ras_fwlog;
14411442

14421443
uint32_t iocb_cnt;

drivers/scsi/lpfc/lpfc_attr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5865,9 +5865,9 @@ lpfc_ras_fwlog_buffsize_set(struct lpfc_hba *phba, uint val)
58655865
if (phba->cfg_ras_fwlog_func != PCI_FUNC(phba->pcidev->devfn))
58665866
return -EINVAL;
58675867

5868-
spin_lock_irq(&phba->hbalock);
5868+
spin_lock_irq(&phba->ras_fwlog_lock);
58695869
state = phba->ras_fwlog.state;
5870-
spin_unlock_irq(&phba->hbalock);
5870+
spin_unlock_irq(&phba->ras_fwlog_lock);
58715871

58725872
if (state == REG_INPROGRESS) {
58735873
lpfc_printf_log(phba, KERN_ERR, LOG_SLI, "6147 RAS Logging "

drivers/scsi/lpfc/lpfc_bsg.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5070,12 +5070,12 @@ lpfc_bsg_get_ras_config(struct bsg_job *job)
50705070
bsg_reply->reply_data.vendor_reply.vendor_rsp;
50715071

50725072
/* Current logging state */
5073-
spin_lock_irq(&phba->hbalock);
5073+
spin_lock_irq(&phba->ras_fwlog_lock);
50745074
if (ras_fwlog->state == ACTIVE)
50755075
ras_reply->state = LPFC_RASLOG_STATE_RUNNING;
50765076
else
50775077
ras_reply->state = LPFC_RASLOG_STATE_STOPPED;
5078-
spin_unlock_irq(&phba->hbalock);
5078+
spin_unlock_irq(&phba->ras_fwlog_lock);
50795079

50805080
ras_reply->log_level = phba->ras_fwlog.fw_loglevel;
50815081
ras_reply->log_buff_sz = phba->cfg_ras_fwlog_buffsize;
@@ -5132,13 +5132,13 @@ lpfc_bsg_set_ras_config(struct bsg_job *job)
51325132

51335133
if (action == LPFC_RASACTION_STOP_LOGGING) {
51345134
/* Check if already disabled */
5135-
spin_lock_irq(&phba->hbalock);
5135+
spin_lock_irq(&phba->ras_fwlog_lock);
51365136
if (ras_fwlog->state != ACTIVE) {
5137-
spin_unlock_irq(&phba->hbalock);
5137+
spin_unlock_irq(&phba->ras_fwlog_lock);
51385138
rc = -ESRCH;
51395139
goto ras_job_error;
51405140
}
5141-
spin_unlock_irq(&phba->hbalock);
5141+
spin_unlock_irq(&phba->ras_fwlog_lock);
51425142

51435143
/* Disable logging */
51445144
lpfc_ras_stop_fwlog(phba);
@@ -5149,10 +5149,10 @@ lpfc_bsg_set_ras_config(struct bsg_job *job)
51495149
* FW-logging with new log-level. Return status
51505150
* "Logging already Running" to caller.
51515151
**/
5152-
spin_lock_irq(&phba->hbalock);
5152+
spin_lock_irq(&phba->ras_fwlog_lock);
51535153
if (ras_fwlog->state != INACTIVE)
51545154
action_status = -EINPROGRESS;
5155-
spin_unlock_irq(&phba->hbalock);
5155+
spin_unlock_irq(&phba->ras_fwlog_lock);
51565156

51575157
/* Enable logging */
51585158
rc = lpfc_sli4_ras_fwlog_init(phba, log_level,
@@ -5268,13 +5268,13 @@ lpfc_bsg_get_ras_fwlog(struct bsg_job *job)
52685268
goto ras_job_error;
52695269

52705270
/* Logging to be stopped before reading */
5271-
spin_lock_irq(&phba->hbalock);
5271+
spin_lock_irq(&phba->ras_fwlog_lock);
52725272
if (ras_fwlog->state == ACTIVE) {
5273-
spin_unlock_irq(&phba->hbalock);
5273+
spin_unlock_irq(&phba->ras_fwlog_lock);
52745274
rc = -EINPROGRESS;
52755275
goto ras_job_error;
52765276
}
5277-
spin_unlock_irq(&phba->hbalock);
5277+
spin_unlock_irq(&phba->ras_fwlog_lock);
52785278

52795279
if (job->request_len <
52805280
sizeof(struct fc_bsg_request) +

drivers/scsi/lpfc/lpfc_debugfs.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,12 +2194,12 @@ static int lpfc_debugfs_ras_log_data(struct lpfc_hba *phba,
21942194

21952195
memset(buffer, 0, size);
21962196

2197-
spin_lock_irq(&phba->hbalock);
2197+
spin_lock_irq(&phba->ras_fwlog_lock);
21982198
if (phba->ras_fwlog.state != ACTIVE) {
2199-
spin_unlock_irq(&phba->hbalock);
2199+
spin_unlock_irq(&phba->ras_fwlog_lock);
22002200
return -EINVAL;
22012201
}
2202-
spin_unlock_irq(&phba->hbalock);
2202+
spin_unlock_irq(&phba->ras_fwlog_lock);
22032203

22042204
list_for_each_entry_safe(dmabuf, next,
22052205
&phba->ras_fwlog.fwlog_buff_list, list) {
@@ -2250,13 +2250,13 @@ lpfc_debugfs_ras_log_open(struct inode *inode, struct file *file)
22502250
int size;
22512251
int rc = -ENOMEM;
22522252

2253-
spin_lock_irq(&phba->hbalock);
2253+
spin_lock_irq(&phba->ras_fwlog_lock);
22542254
if (phba->ras_fwlog.state != ACTIVE) {
2255-
spin_unlock_irq(&phba->hbalock);
2255+
spin_unlock_irq(&phba->ras_fwlog_lock);
22562256
rc = -EINVAL;
22572257
goto out;
22582258
}
2259-
spin_unlock_irq(&phba->hbalock);
2259+
spin_unlock_irq(&phba->ras_fwlog_lock);
22602260

22612261
if (check_mul_overflow(LPFC_RAS_MIN_BUFF_POST_SIZE,
22622262
phba->cfg_ras_fwlog_buffsize, &size))

drivers/scsi/lpfc/lpfc_init.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7705,6 +7705,9 @@ lpfc_setup_driver_resource_phase1(struct lpfc_hba *phba)
77057705
"NVME" : " "),
77067706
(phba->nvmet_support ? "NVMET" : " "));
77077707

7708+
/* ras_fwlog state */
7709+
spin_lock_init(&phba->ras_fwlog_lock);
7710+
77087711
/* Initialize the IO buffer list used by driver for SLI3 SCSI */
77097712
spin_lock_init(&phba->scsi_buf_list_get_lock);
77107713
INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_get);

drivers/scsi/lpfc/lpfc_sli.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6849,9 +6849,9 @@ lpfc_ras_stop_fwlog(struct lpfc_hba *phba)
68496849
{
68506850
struct lpfc_ras_fwlog *ras_fwlog = &phba->ras_fwlog;
68516851

6852-
spin_lock_irq(&phba->hbalock);
6852+
spin_lock_irq(&phba->ras_fwlog_lock);
68536853
ras_fwlog->state = INACTIVE;
6854-
spin_unlock_irq(&phba->hbalock);
6854+
spin_unlock_irq(&phba->ras_fwlog_lock);
68556855

68566856
/* Disable FW logging to host memory */
68576857
writel(LPFC_CTL_PDEV_CTL_DDL_RAS,
@@ -6894,9 +6894,9 @@ lpfc_sli4_ras_dma_free(struct lpfc_hba *phba)
68946894
ras_fwlog->lwpd.virt = NULL;
68956895
}
68966896

6897-
spin_lock_irq(&phba->hbalock);
6897+
spin_lock_irq(&phba->ras_fwlog_lock);
68986898
ras_fwlog->state = INACTIVE;
6899-
spin_unlock_irq(&phba->hbalock);
6899+
spin_unlock_irq(&phba->ras_fwlog_lock);
69006900
}
69016901

69026902
/**
@@ -6998,9 +6998,9 @@ lpfc_sli4_ras_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
69986998
goto disable_ras;
69996999
}
70007000

7001-
spin_lock_irq(&phba->hbalock);
7001+
spin_lock_irq(&phba->ras_fwlog_lock);
70027002
ras_fwlog->state = ACTIVE;
7003-
spin_unlock_irq(&phba->hbalock);
7003+
spin_unlock_irq(&phba->ras_fwlog_lock);
70047004
mempool_free(pmb, phba->mbox_mem_pool);
70057005

70067006
return;
@@ -7032,9 +7032,9 @@ lpfc_sli4_ras_fwlog_init(struct lpfc_hba *phba,
70327032
uint32_t len = 0, fwlog_buffsize, fwlog_entry_count;
70337033
int rc = 0;
70347034

7035-
spin_lock_irq(&phba->hbalock);
7035+
spin_lock_irq(&phba->ras_fwlog_lock);
70367036
ras_fwlog->state = INACTIVE;
7037-
spin_unlock_irq(&phba->hbalock);
7037+
spin_unlock_irq(&phba->ras_fwlog_lock);
70387038

70397039
fwlog_buffsize = (LPFC_RAS_MIN_BUFF_POST_SIZE *
70407040
phba->cfg_ras_fwlog_buffsize);
@@ -7095,9 +7095,9 @@ lpfc_sli4_ras_fwlog_init(struct lpfc_hba *phba,
70957095
mbx_fwlog->u.request.lwpd.addr_lo = putPaddrLow(ras_fwlog->lwpd.phys);
70967096
mbx_fwlog->u.request.lwpd.addr_hi = putPaddrHigh(ras_fwlog->lwpd.phys);
70977097

7098-
spin_lock_irq(&phba->hbalock);
7098+
spin_lock_irq(&phba->ras_fwlog_lock);
70997099
ras_fwlog->state = REG_INPROGRESS;
7100-
spin_unlock_irq(&phba->hbalock);
7100+
spin_unlock_irq(&phba->ras_fwlog_lock);
71017101
mbox->vport = phba->pport;
71027102
mbox->mbox_cmpl = lpfc_sli4_ras_mbox_cmpl;
71037103

0 commit comments

Comments
 (0)