ixgbe: do not busy wait in ixgbe_devlink_reload_empr_finish()
Subsystems (3)
PATCH v2 1/2 ixgbe: do not busy wait in ixgbe_devlink_reload_empr_finish()
From: Linkui Xiao <[email protected]>
ixgbe_devlink_reload_empr_finish() is the .reload_up devlink operation, so it always runs in process context with the devlink instance lock held. Its polling loop delays with mdelay(500), i.e. it spins the CPU for half a second per iteration and, because the loop bound is 20 iterations, for up to ten seconds. That keeps a CPU fully occupied while the firmware performs the EMP reset, and on CONFIG_PREEMPT_NONE it also makes the loop non-preemptible for that whole window. The loop does not need to be atomic and holds no spinlock.
Use msleep() instead.
---
v1:https://lore.kernel.org/all/[email protected]/
v2:
- Reworded the commit message: mdelay() does not mask interrupts or disable preemption, and the ~10 s window is below the soft lockup / RCU stall thresholds. State the actual rationale instead.
- Split the macro rename into a separate patch.
- The mdelay() -> msleep() change itself is unchanged, so the Reviewed-by tag is kept.
drivers/net/ethernet/intel/ixgbe/devlink/devlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbe/devlink/devlink.c +1 -1
@@ -460,7 +460,7 @@ static int ixgbe_devlink_reload_empr_finish(struct devlink *devlink,* may be not cleared yet, so begin the loop with the delay * in order to not check the not updated register. */ -mdelay (500 ); +msleep (500 ); fwsm =IXGBE_READ_REG (hw,IXGBE_FWSM (hw));
Signature · 1 line
2.25.1
PATCH v2 2/2 ixgbe: rename the EMP reset timeout constant
From: Linkui Xiao <[email protected]>
IXGBE_DEVLINK_RELOAD_TIMEOUT_SEC is misleading: the value counts 0.5 s poll iterations, not seconds, as the comment right above it already explains. Rename it to IXGBE_DEVLINK_RELOAD_MAX_ITER, which says what the value actually is.
--- drivers/net/ethernet/intel/ixgbe/devlink/devlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ixgbe/devlink/devlink.c +2 -2
@@ -430,7 +430,7 @@ static int ixgbe_devlink_reload_empr_start(struct devlink *devlink, }/*Wait for 10 sec with 0.5 sec tic. EMPR takes no less than half of a sec */ -#define IXGBE_DEVLINK_RELOAD_TIMEOUT_SEC 20 +#define IXGBE_DEVLINK_RELOAD_MAX_ITER 20/** * ixgbe_devlink_reload_empr_finish - finishes EMP reset
@@ -464,7 +464,7 @@ static int ixgbe_devlink_reload_empr_finish(struct devlink *devlink, fwsm =IXGBE_READ_REG (hw,IXGBE_FWSM (hw)); -if (i++ >=IXGBE_DEVLINK_RELOAD_TIMEOUT_SEC ) +if (i++ >=IXGBE_DEVLINK_RELOAD_MAX_ITER )return -ETIME ; }while (!(fwsm &IXGBE_FWSM_FW_VAL_BIT ));
Signature · 1 line
2.25.1
Re: [Intel-wired-lan] [PATCH net v2 2/2] ixgbe: rename the EMP reset timeout constant
Dear Linkui,
Thank you for your patch.
Am 17.09.26 um 08:54 schrieb Linkui Xiao:
Quoted 27 lines
From: Linkui Xiao <[email protected]>
IXGBE_DEVLINK_RELOAD_TIMEOUT_SECis misleading: the value counts 0.5 s poll iterations, not seconds, as the comment right above it already explains. Rename it toIXGBE_DEVLINK_RELOAD_MAX_ITER, which says what the value actually is.Reviewed-by Przemek Kitszel <[email protected]>Signed-off-by Linkui Xiao <[email protected]>--- drivers/net/ethernet/intel/ixgbe/devlink/devlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/ethernet/intel/ixgbe/devlink/devlink.c +1
-1@@ -430,7 +430,7 @@ static int ixgbe_devlink_reload_empr_start(struct devlink *devlink, }/*Wait for 10 sec with 0.5 sec tic. EMPR takes no less than half of a sec */ -#define IXGBE_DEVLINK_RELOAD_TIMEOUT_SEC 20 +#define IXGBE_DEVLINK_RELOAD_MAX_ITER 20/** * ixgbe_devlink_reload_empr_finish - finishes EMP reset
drivers/net/ethernet/intel/ixgbe/devlink/devlink.c static int ixgbe_devlink_reload_empr_finish(struct devlink *devlink, · line 470
Quoted 8 lines
drivers/net/ethernet/intel/ixgbe/devlink/devlink.c +1
-1@@ -464,7 +464,7 @@ static int ixgbe_devlink_reload_empr_finish(struct devlink *devlink, fwsm =IXGBE_READ_REG (hw,IXGBE_FWSM (hw)); -if (i++ >=IXGBE_DEVLINK_RELOAD_TIMEOUT_SEC ) +if (i++ >=IXGBE_DEVLINK_RELOAD_MAX_ITER )return -ETIME ; }while (!(fwsm &IXGBE_FWSM_FW_VAL_BIT ));
Kind regards,
Paul
RE: [Intel-wired-lan] [PATCH net v2 2/2] ixgbe: rename the EMP reset timeout constant
In reply to Linkui XiaoQuoted 55 lines
-----Original Message-----
From: Linkui Xiao <[email protected]>
Sent: Thursday, September 17, 2026 8:55 AM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Jagielski, Jedrzej <[email protected]>; [email protected]; Loktionov, Aleksandr <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; Linkui Xiao <[email protected]>
Subject: [Intel-wired-lan] [PATCH net v2 2/2] ixgbe: rename the EMP reset timeout constantFrom: Linkui Xiao <[email protected]>
IXGBE_DEVLINK_RELOAD_TIMEOUT_SECis misleading: the value counts 0.5 s poll iterations, not seconds, as the comment right above it already explains. Rename it toIXGBE_DEVLINK_RELOAD_MAX_ITER, which says what the value actually is.Reviewed-by Przemek Kitszel <[email protected]>Signed-off-by Linkui Xiao <[email protected]>--- drivers/net/ethernet/intel/ixgbe/devlink/devlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/ethernet/intel/ixgbe/devlink/devlink.c +0
-0@@ -430,7 +430,7 @@ static int ixgbe_devlink_reload_empr_start(struct devlink *devlink, }/*Wait for 10 sec with 0.5 sec tic. EMPR takes no less than half of a sec */
drivers/net/ethernet/intel/ixgbe/devlink/devlink.c +2
-1-#define IXGBE_DEVLINK_RELOAD_TIMEOUT_SEC 20 +#define IXGBE_DEVLINK_RELOAD_MAX_ITER 20/** * ixgbe_devlink_reload_empr_finish - finishes EMP reset @@ -464,7 +464,7 @@ static int ixgbe_devlink_reload_empr_finish(struct devlink *devlink,
drivers/net/ethernet/intel/ixgbe/devlink/devlink.c +1
-2fwsm =IXGBE_READ_REG (hw,IXGBE_FWSM (hw)); -if (i++ >=IXGBE_DEVLINK_RELOAD_TIMEOUT_SEC ) +if (i++ >=IXGBE_DEVLINK_RELOAD_MAX_ITER )return -ETIME ; }while (!(fwsm &IXGBE_FWSM_FW_VAL_BIT )); --
Quoted 1 line
2.25.1
Dear Linkui,
Thank you for your patch.
Am 17.09.26 um 08:54 schrieb Linkui Xiao:
Quoted 11 lines
From: Linkui Xiao <[email protected]>
ixgbe_devlink_reload_empr_finish()is the .reload_up devlink operation, so it always runs in process context with the devlink instance lock held. Its polling loop delays with mdelay(500), i.e. it spins the CPU for half a second per iteration and, because the loop bound is 20 iterations, for up to ten seconds. That keeps a CPU fully occupied while the firmware performs the EMP reset, and onCONFIG_PREEMPT_NONEit also makes the loop non-preemptible for that whole window. The loop does not need to be atomic and holds no spinlock.
Quoted 1 line
Use
msleep()instead.
Should you resend, please document the commands how to test this, for example, how to trigger .reload.
Quoted 22 lines
Fixes c9e563cae19e ("ixgbe: add support for devlink reload")Reviewed-by Przemek Kitszel <[email protected]>Signed-off-by Linkui Xiao <[email protected]>---
v1:https://lore.kernel.org/all/[email protected]/v2:
- Reworded the commit message:mdelay()does not mask interrupts or disable preemption, and the ~10 s window is below the soft lockup / RCU stall thresholds. State the actual rationale instead.
- Split the macro rename into a separate patch.
- Themdelay()->msleep()change itself is unchanged, so the Reviewed-by tag is kept.drivers/net/ethernet/intel/ixgbe/devlink/devlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/intel/ixgbe/devlink/devlink.c +0
-0
drivers/net/ethernet/intel/ixgbe/devlink/devlink.c static int ixgbe_devlink_reload_empr_finish(struct devlink *devlink, · line 465
Quoted 7 lines
drivers/net/ethernet/intel/ixgbe/devlink/devlink.c +1
-1@@ -460,7 +460,7 @@ static int ixgbe_devlink_reload_empr_finish(struct devlink *devlink,* may be not cleared yet, so begin the loop with the delay * in order to not check the not updated register. */ -mdelay (500 ); +msleep (500 ); fwsm =IXGBE_READ_REG (hw,IXGBE_FWSM (hw));
Kind regards,
Paul
Quoted 17 lines · Paul Menzel
Dear Linkui,
Thank you for your patch.
Am 17.09.26 um 08:54 schrieb Linkui Xiao:
Quoted 11 lines
From: Linkui Xiao <[email protected]>
ixgbe_devlink_reload_empr_finish()is the .reload_up devlink operation, so it always runs in process context with the devlink instance lock held. Its polling loop delays with mdelay(500), i.e. it spins the CPU for half a second per iteration and, because the loop bound is 20 iterations, for up to ten seconds. That keeps a CPU fully occupied while the firmware performs the EMP reset, and onCONFIG_PREEMPT_NONEit also makes the loop non-preemptible for that whole window. The loop does not need to be atomic and holds no spinlock.
Quoted 3 lines
Quoted 1 line
Use
msleep()instead.Should you resend, please document the commands how to test this, for example, how to trigger .reload.
Hi Paul,
Thanks for the review and the Reviewed-by.
I don't have an E610 adapter available to actually exercise the devlink reload path, so I can't provide a tested-by or a verified test log. The change is a mechanical mdelay() -> msleep() conversion in a sleepable process-context loop; the rationale stands on its own, but I understand if you'd prefer to wait for someone with the hardware to run it.
If you'd still like the test commands documented for reference, I can add them to the changelog, but I want to be clear that I have not run them myself.
Thanks,
Linkui
Quoted 38 lines
Quoted 23 lines
Fixes c9e563cae19e ("ixgbe: add support for devlink reload")Reviewed-by Przemek Kitszel <[email protected]>Signed-off-by Linkui Xiao <[email protected]>---
v1:https://lore.kernel.org/all/[email protected]/v2:
- Reworded the commit message:mdelay()does not mask interrupts or disable preemption, and the ~10 s window is below the soft lockup / RCU stall thresholds. State the actual rationale instead.
- Split the macro rename into a separate patch.
- Themdelay()->msleep()change itself is unchanged, so the Reviewed-by tag is kept.
drivers/net/ethernet/intel/ixgbe/devlink/devlink.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/intel/ixgbe/devlink/devlink.c +0
-0drivers/net/ethernet/intel/ixgbe/devlink/devlink.c static int ixgbe_devlink_reload_empr_finish(struct · line 465
Quoted 7 lines
drivers/net/ethernet/intel/ixgbe/devlink/devlink.c +1
-1@@ -460,7 +460,7 @@ static int ixgbe_devlink_reload_empr_finish(structdevlink *devlink, * may be not cleared yet, so begin the loop with the delay * in order to not check the not updated register. */ - mdelay(500); + msleep(500); fwsm = IXGBE_READ_REG(hw, IXGBE_FWSM(hw));Reviewed-by Paul Menzel <[email protected]>Kind regards,
Paul