Skip to content

Commit a131f20

Browse files
easwarhmartinkpetersen
authored andcommitted
scsi: lpfc: Convert timeouts to secs_to_jiffies()
Commit b35108a ("jiffies: Define secs_to_jiffies()") introduced secs_to_jiffies(). As the value here is a multiple of 1000, use secs_to_jiffies() instead of msecs_to_jiffies() to avoid the multiplication This is converted using scripts/coccinelle/misc/secs_to_jiffies.cocci with the following Coccinelle rules: @Depends on patch@ expression E; @@ -msecs_to_jiffies(E * 1000) +secs_to_jiffies(E) -msecs_to_jiffies(E * MSEC_PER_SEC) +secs_to_jiffies(E) While here, convert some timeouts that are denominated in seconds manually. [mkp: Fix compilation error] Signed-off-by: Easwar Hariharan <[email protected]> Link: https://lore.kernel.org/r/20250225-converge-secs-to-jiffies-part-two-v3-2-a43967e36c88@linux.microsoft.com Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 7a9c047 commit a131f20

File tree

7 files changed

+34
-47
lines changed

7 files changed

+34
-47
lines changed

drivers/scsi/lpfc/lpfc.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ struct lpfc_sli2_slim;
7474
* queue depths when there are driver resource error or Firmware
7575
* resource error.
7676
*/
77-
/* 1 Second */
78-
#define QUEUE_RAMP_DOWN_INTERVAL (msecs_to_jiffies(1000 * 1))
77+
#define QUEUE_RAMP_DOWN_INTERVAL (secs_to_jiffies(1))
7978

8079
/* Number of exchanges reserved for discovery to complete */
8180
#define LPFC_DISC_IOCB_BUFF_COUNT 20

drivers/scsi/lpfc/lpfc_els.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8045,8 +8045,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
80458045
if (test_bit(FC_DISC_TMO, &vport->fc_flag)) {
80468046
tmo = ((phba->fc_ratov * 3) + 3);
80478047
mod_timer(&vport->fc_disctmo,
8048-
jiffies +
8049-
msecs_to_jiffies(1000 * tmo));
8048+
jiffies + secs_to_jiffies(tmo));
80508049
}
80518050
return 0;
80528051
}
@@ -8081,7 +8080,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
80818080
if (test_bit(FC_DISC_TMO, &vport->fc_flag)) {
80828081
tmo = ((phba->fc_ratov * 3) + 3);
80838082
mod_timer(&vport->fc_disctmo,
8084-
jiffies + msecs_to_jiffies(1000 * tmo));
8083+
jiffies + secs_to_jiffies(tmo));
80858084
}
80868085
if ((rscn_cnt < FC_MAX_HOLD_RSCN) &&
80878086
!test_bit(FC_RSCN_DISCOVERY, &vport->fc_flag)) {
@@ -9511,7 +9510,7 @@ lpfc_els_timeout_handler(struct lpfc_vport *vport)
95119510
if (!list_empty(&pring->txcmplq))
95129511
if (!test_bit(FC_UNLOADING, &phba->pport->load_flag))
95139512
mod_timer(&vport->els_tmofunc,
9514-
jiffies + msecs_to_jiffies(1000 * timeout));
9513+
jiffies + secs_to_jiffies(timeout));
95159514
}
95169515

95179516
/**
@@ -10897,7 +10896,7 @@ lpfc_do_scr_ns_plogi(struct lpfc_hba *phba, struct lpfc_vport *vport)
1089710896
"3334 Delay fc port discovery for %d secs\n",
1089810897
phba->fc_ratov);
1089910898
mod_timer(&vport->delayed_disc_tmo,
10900-
jiffies + msecs_to_jiffies(1000 * phba->fc_ratov));
10899+
jiffies + secs_to_jiffies(phba->fc_ratov));
1090110900
return;
1090210901
}
1090310902

@@ -11154,7 +11153,7 @@ lpfc_retry_pport_discovery(struct lpfc_hba *phba)
1115411153
if (!ndlp)
1115511154
return;
1115611155

11157-
mod_timer(&ndlp->nlp_delayfunc, jiffies + msecs_to_jiffies(1000));
11156+
mod_timer(&ndlp->nlp_delayfunc, jiffies + secs_to_jiffies(1));
1115811157
set_bit(NLP_DELAY_TMO, &ndlp->nlp_flag);
1115911158
ndlp->nlp_last_elscmd = ELS_CMD_FLOGI;
1116011159
phba->pport->port_state = LPFC_FLOGI;

drivers/scsi/lpfc/lpfc_hbadisc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4979,7 +4979,7 @@ lpfc_set_disctmo(struct lpfc_vport *vport)
49794979
tmo, vport->port_state, vport->fc_flag);
49804980
}
49814981

4982-
mod_timer(&vport->fc_disctmo, jiffies + msecs_to_jiffies(1000 * tmo));
4982+
mod_timer(&vport->fc_disctmo, jiffies + secs_to_jiffies(tmo));
49834983
set_bit(FC_DISC_TMO, &vport->fc_flag);
49844984

49854985
/* Start Discovery Timer state <hba_state> */

drivers/scsi/lpfc/lpfc_init.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ lpfc_config_port_post(struct lpfc_hba *phba)
595595
/* Set up ring-0 (ELS) timer */
596596
timeout = phba->fc_ratov * 2;
597597
mod_timer(&vport->els_tmofunc,
598-
jiffies + msecs_to_jiffies(1000 * timeout));
598+
jiffies + secs_to_jiffies(timeout));
599599
/* Set up heart beat (HB) timer */
600600
mod_timer(&phba->hb_tmofunc,
601601
jiffies + secs_to_jiffies(LPFC_HB_MBOX_INTERVAL));
@@ -604,7 +604,7 @@ lpfc_config_port_post(struct lpfc_hba *phba)
604604
phba->last_completion_time = jiffies;
605605
/* Set up error attention (ERATT) polling timer */
606606
mod_timer(&phba->eratt_poll,
607-
jiffies + msecs_to_jiffies(1000 * phba->eratt_poll_interval));
607+
jiffies + secs_to_jiffies(phba->eratt_poll_interval));
608608

609609
if (test_bit(LINK_DISABLED, &phba->hba_flag)) {
610610
lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
@@ -3361,8 +3361,8 @@ lpfc_block_mgmt_io(struct lpfc_hba *phba, int mbx_action)
33613361
/* Determine how long we might wait for the active mailbox
33623362
* command to be gracefully completed by firmware.
33633363
*/
3364-
timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba,
3365-
phba->sli.mbox_active) * 1000) + jiffies;
3364+
timeout = secs_to_jiffies(lpfc_mbox_tmo_val(phba,
3365+
phba->sli.mbox_active)) + jiffies;
33663366
}
33673367
spin_unlock_irqrestore(&phba->hbalock, iflag);
33683368

@@ -6909,7 +6909,7 @@ lpfc_sli4_async_fip_evt(struct lpfc_hba *phba,
69096909
* re-instantiate the Vlink using FDISC.
69106910
*/
69116911
mod_timer(&ndlp->nlp_delayfunc,
6912-
jiffies + msecs_to_jiffies(1000));
6912+
jiffies + secs_to_jiffies(1));
69136913
set_bit(NLP_DELAY_TMO, &ndlp->nlp_flag);
69146914
ndlp->nlp_last_elscmd = ELS_CMD_FDISC;
69156915
vport->port_state = LPFC_FDISC;

drivers/scsi/lpfc/lpfc_scsi.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5645,9 +5645,8 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
56455645
* cmd_flag is set to LPFC_DRIVER_ABORTED before we wait
56465646
* for abort to complete.
56475647
*/
5648-
wait_event_timeout(waitq,
5649-
(lpfc_cmd->pCmd != cmnd),
5650-
msecs_to_jiffies(2*vport->cfg_devloss_tmo*1000));
5648+
wait_event_timeout(waitq, (lpfc_cmd->pCmd != cmnd),
5649+
secs_to_jiffies(2*vport->cfg_devloss_tmo));
56515650

56525651
spin_lock(&lpfc_cmd->buf_lock);
56535652

@@ -5911,7 +5910,7 @@ lpfc_chk_tgt_mapped(struct lpfc_vport *vport, struct fc_rport *rport)
59115910
* If target is not in a MAPPED state, delay until
59125911
* target is rediscovered or devloss timeout expires.
59135912
*/
5914-
later = msecs_to_jiffies(2 * vport->cfg_devloss_tmo * 1000) + jiffies;
5913+
later = secs_to_jiffies(2 * vport->cfg_devloss_tmo) + jiffies;
59155914
while (time_after(later, jiffies)) {
59165915
if (!pnode)
59175916
return FAILED;
@@ -5957,7 +5956,7 @@ lpfc_reset_flush_io_context(struct lpfc_vport *vport, uint16_t tgt_id,
59575956
lpfc_sli_abort_taskmgmt(vport,
59585957
&phba->sli.sli3_ring[LPFC_FCP_RING],
59595958
tgt_id, lun_id, context);
5960-
later = msecs_to_jiffies(2 * vport->cfg_devloss_tmo * 1000) + jiffies;
5959+
later = secs_to_jiffies(2 * vport->cfg_devloss_tmo) + jiffies;
59615960
while (time_after(later, jiffies) && cnt) {
59625961
schedule_timeout_uninterruptible(msecs_to_jiffies(20));
59635962
cnt = lpfc_sli_sum_iocb(vport, tgt_id, lun_id, context);
@@ -6137,8 +6136,7 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd)
61376136
wait_event_timeout(waitq,
61386137
!test_bit(NLP_WAIT_FOR_LOGO,
61396138
&pnode->save_flags),
6140-
msecs_to_jiffies(dev_loss_tmo *
6141-
1000));
6139+
secs_to_jiffies(dev_loss_tmo));
61426140

61436141
if (test_and_clear_bit(NLP_WAIT_FOR_LOGO,
61446142
&pnode->save_flags))

drivers/scsi/lpfc/lpfc_sli.c

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ lpfc_handle_rrq_active(struct lpfc_hba *phba)
10251025
LIST_HEAD(send_rrq);
10261026

10271027
clear_bit(HBA_RRQ_ACTIVE, &phba->hba_flag);
1028-
next_time = jiffies + msecs_to_jiffies(1000 * (phba->fc_ratov + 1));
1028+
next_time = jiffies + secs_to_jiffies(phba->fc_ratov + 1);
10291029
spin_lock_irqsave(&phba->rrq_list_lock, iflags);
10301030
list_for_each_entry_safe(rrq, nextrrq,
10311031
&phba->active_rrq_list, list) {
@@ -1208,8 +1208,7 @@ lpfc_set_rrq_active(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
12081208
else
12091209
rrq->send_rrq = 0;
12101210
rrq->xritag = xritag;
1211-
rrq->rrq_stop_time = jiffies +
1212-
msecs_to_jiffies(1000 * (phba->fc_ratov + 1));
1211+
rrq->rrq_stop_time = jiffies + secs_to_jiffies(phba->fc_ratov + 1);
12131212
rrq->nlp_DID = ndlp->nlp_DID;
12141213
rrq->vport = ndlp->vport;
12151214
rrq->rxid = rxid;
@@ -1736,8 +1735,7 @@ lpfc_sli_ringtxcmpl_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
17361735
BUG_ON(!piocb->vport);
17371736
if (!test_bit(FC_UNLOADING, &piocb->vport->load_flag))
17381737
mod_timer(&piocb->vport->els_tmofunc,
1739-
jiffies +
1740-
msecs_to_jiffies(1000 * (phba->fc_ratov << 1)));
1738+
jiffies + secs_to_jiffies(phba->fc_ratov << 1));
17411739
}
17421740

17431741
return 0;
@@ -3956,8 +3954,7 @@ void lpfc_poll_eratt(struct timer_list *t)
39563954
else
39573955
/* Restart the timer for next eratt poll */
39583956
mod_timer(&phba->eratt_poll,
3959-
jiffies +
3960-
msecs_to_jiffies(1000 * phba->eratt_poll_interval));
3957+
jiffies + secs_to_jiffies(phba->eratt_poll_interval));
39613958
return;
39623959
}
39633960

@@ -9008,7 +9005,7 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
90089005

90099006
/* Start the ELS watchdog timer */
90109007
mod_timer(&vport->els_tmofunc,
9011-
jiffies + msecs_to_jiffies(1000 * (phba->fc_ratov * 2)));
9008+
jiffies + secs_to_jiffies(phba->fc_ratov * 2));
90129009

90139010
/* Start heart beat timer */
90149011
mod_timer(&phba->hb_tmofunc,
@@ -9027,7 +9024,7 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
90279024

90289025
/* Start error attention (ERATT) polling timer */
90299026
mod_timer(&phba->eratt_poll,
9030-
jiffies + msecs_to_jiffies(1000 * phba->eratt_poll_interval));
9027+
jiffies + secs_to_jiffies(phba->eratt_poll_interval));
90319028

90329029
/*
90339030
* The port is ready, set the host's link state to LINK_DOWN
@@ -9504,8 +9501,7 @@ lpfc_sli_issue_mbox_s3(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox,
95049501
goto out_not_finished;
95059502
}
95069503
/* timeout active mbox command */
9507-
timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba, pmbox) *
9508-
1000);
9504+
timeout = secs_to_jiffies(lpfc_mbox_tmo_val(phba, pmbox));
95099505
mod_timer(&psli->mbox_tmo, jiffies + timeout);
95109506
}
95119507

@@ -9629,8 +9625,7 @@ lpfc_sli_issue_mbox_s3(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox,
96299625
drvr_flag);
96309626
goto out_not_finished;
96319627
}
9632-
timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba, pmbox) *
9633-
1000) + jiffies;
9628+
timeout = secs_to_jiffies(lpfc_mbox_tmo_val(phba, pmbox)) + jiffies;
96349629
i = 0;
96359630
/* Wait for command to complete */
96369631
while (((word0 & OWN_CHIP) == OWN_CHIP) ||
@@ -9756,9 +9751,8 @@ lpfc_sli4_async_mbox_block(struct lpfc_hba *phba)
97569751
* command to be gracefully completed by firmware.
97579752
*/
97589753
if (phba->sli.mbox_active)
9759-
timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba,
9760-
phba->sli.mbox_active) *
9761-
1000) + jiffies;
9754+
timeout = secs_to_jiffies(lpfc_mbox_tmo_val(phba,
9755+
phba->sli.mbox_active)) + jiffies;
97629756
spin_unlock_irq(&phba->hbalock);
97639757

97649758
/* Make sure the mailbox is really active */
@@ -9881,8 +9875,7 @@ lpfc_sli4_wait_bmbx_ready(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
98819875
}
98829876
}
98839877

9884-
timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba, mboxq)
9885-
* 1000) + jiffies;
9878+
timeout = secs_to_jiffies(lpfc_mbox_tmo_val(phba, mboxq)) + jiffies;
98869879

98879880
do {
98889881
bmbx_reg.word0 = readl(phba->sli4_hba.BMBXregaddr);
@@ -10230,7 +10223,7 @@ lpfc_sli4_post_async_mbox(struct lpfc_hba *phba)
1023010223

1023110224
/* Start timer for the mbox_tmo and log some mailbox post messages */
1023210225
mod_timer(&psli->mbox_tmo, (jiffies +
10233-
msecs_to_jiffies(1000 * lpfc_mbox_tmo_val(phba, mboxq))));
10226+
secs_to_jiffies(lpfc_mbox_tmo_val(phba, mboxq))));
1023410227

1023510228
lpfc_printf_log(phba, KERN_INFO, LOG_MBOX | LOG_SLI,
1023610229
"(%d):0355 Mailbox cmd x%x (x%x/x%x) issue Data: "
@@ -13159,7 +13152,7 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba *phba,
1315913152
retval = lpfc_sli_issue_iocb(phba, ring_number, piocb,
1316013153
SLI_IOCB_RET_IOCB);
1316113154
if (retval == IOCB_SUCCESS) {
13162-
timeout_req = msecs_to_jiffies(timeout * 1000);
13155+
timeout_req = secs_to_jiffies(timeout);
1316313156
timeleft = wait_event_timeout(done_q,
1316413157
lpfc_chk_iocb_flg(phba, piocb, LPFC_IO_WAKE),
1316513158
timeout_req);
@@ -13275,8 +13268,7 @@ lpfc_sli_issue_mbox_wait(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq,
1327513268
/* now issue the command */
1327613269
retval = lpfc_sli_issue_mbox(phba, pmboxq, MBX_NOWAIT);
1327713270
if (retval == MBX_BUSY || retval == MBX_SUCCESS) {
13278-
wait_for_completion_timeout(&mbox_done,
13279-
msecs_to_jiffies(timeout * 1000));
13271+
wait_for_completion_timeout(&mbox_done, secs_to_jiffies(timeout));
1328013272

1328113273
spin_lock_irqsave(&phba->hbalock, flag);
1328213274
pmboxq->ctx_u.mbox_wait = NULL;
@@ -13336,9 +13328,8 @@ lpfc_sli_mbox_sys_shutdown(struct lpfc_hba *phba, int mbx_action)
1333613328
* command to be gracefully completed by firmware.
1333713329
*/
1333813330
if (phba->sli.mbox_active)
13339-
timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba,
13340-
phba->sli.mbox_active) *
13341-
1000) + jiffies;
13331+
timeout = secs_to_jiffies(lpfc_mbox_tmo_val(phba,
13332+
phba->sli.mbox_active)) + jiffies;
1334213333
spin_unlock_irq(&phba->hbalock);
1334313334

1334413335
/* Enable softirqs again, done with phba->hbalock */

drivers/scsi/lpfc/lpfc_vport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ static void lpfc_discovery_wait(struct lpfc_vport *vport)
246246
* fabric RA_TOV value and dev_loss tmo. The driver's
247247
* devloss_tmo is 10 giving this loop a 3x multiplier minimally.
248248
*/
249-
wait_time_max = msecs_to_jiffies(((phba->fc_ratov * 3) + 3) * 1000);
249+
wait_time_max = secs_to_jiffies((phba->fc_ratov * 3) + 3);
250250
wait_time_max += jiffies;
251251
start_time = jiffies;
252252
while (time_before(jiffies, wait_time_max)) {

0 commit comments

Comments
 (0)