* [PATCH v2 net] net: stmmac: Use readl_poll_timeout_atomic() in atomic state
@ 2022-04-19 8:42 Kevin Hao
2022-04-20 10:20 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Kevin Hao @ 2022-04-19 8:42 UTC (permalink / raw)
To: netdev
Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
David S. Miller, Jakub Kicinski, Paolo Abeni, Maxime Coquelin,
Dejin Zheng, linux-stm32, linux-arm-kernel
The init_systime() may be invoked in atomic state. We have observed the
following call trace when running "phc_ctl /dev/ptp0 set" on a Intel
Agilex board.
BUG: sleeping function called from invalid context at drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c:74
in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 381, name: phc_ctl
preempt_count: 1, expected: 0
RCU nest depth: 0, expected: 0
Preemption disabled at:
[<ffff80000892ef78>] stmmac_set_time+0x34/0x8c
CPU: 2 PID: 381 Comm: phc_ctl Not tainted 5.18.0-rc2-next-20220414-yocto-standard+ #567
Hardware name: SoCFPGA Agilex SoCDK (DT)
Call trace:
dump_backtrace.part.0+0xc4/0xd0
show_stack+0x24/0x40
dump_stack_lvl+0x7c/0xa0
dump_stack+0x18/0x34
__might_resched+0x154/0x1c0
__might_sleep+0x58/0x90
init_systime+0x78/0x120
stmmac_set_time+0x64/0x8c
ptp_clock_settime+0x60/0x9c
pc_clock_settime+0x6c/0xc0
__arm64_sys_clock_settime+0x88/0xf0
invoke_syscall+0x5c/0x130
el0_svc_common.constprop.0+0x4c/0x100
do_el0_svc+0x7c/0xa0
el0_svc+0x58/0xcc
el0t_64_sync_handler+0xa4/0x130
el0t_64_sync+0x18c/0x190
So we should use readl_poll_timeout_atomic() here instead of
readl_poll_timeout().
Also adjust the delay time to 10us to fix a "__bad_udelay" build error
reported by "kernel test robot <lkp@intel.com>". I have tested this on
Intel Agilex and NXP S32G boards, there is no delay needed at all.
So the 10us delay should be long enough for most cases.
Fixes: ff8ed737860e ("net: stmmac: use readl_poll_timeout() function in init_systime()")
Signed-off-by: Kevin Hao <haokexin@gmail.com>
---
v2: Fix the "__bad_udelay" build error.
drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
index 22fea0f67245..92d32940aff0 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
@@ -71,9 +71,9 @@ static int init_systime(void __iomem *ioaddr, u32 sec, u32 nsec)
writel(value, ioaddr + PTP_TCR);
/* wait for present system time initialize to complete */
- return readl_poll_timeout(ioaddr + PTP_TCR, value,
+ return readl_poll_timeout_atomic(ioaddr + PTP_TCR, value,
!(value & PTP_TCR_TSINIT),
- 10000, 100000);
+ 10, 100000);
}
static int config_addend(void __iomem *ioaddr, u32 addend)
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 net] net: stmmac: Use readl_poll_timeout_atomic() in atomic state
2022-04-19 8:42 [PATCH v2 net] net: stmmac: Use readl_poll_timeout_atomic() in atomic state Kevin Hao
@ 2022-04-20 10:20 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-04-20 10:20 UTC (permalink / raw)
To: Kevin Hao
Cc: netdev, peppe.cavallaro, alexandre.torgue, joabreu, davem, kuba,
pabeni, mcoquelin.stm32, zhengdejin5, linux-stm32,
linux-arm-kernel
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:
On Tue, 19 Apr 2022 16:42:26 +0800 you wrote:
> The init_systime() may be invoked in atomic state. We have observed the
> following call trace when running "phc_ctl /dev/ptp0 set" on a Intel
> Agilex board.
> BUG: sleeping function called from invalid context at drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c:74
> in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 381, name: phc_ctl
> preempt_count: 1, expected: 0
> RCU nest depth: 0, expected: 0
> Preemption disabled at:
> [<ffff80000892ef78>] stmmac_set_time+0x34/0x8c
> CPU: 2 PID: 381 Comm: phc_ctl Not tainted 5.18.0-rc2-next-20220414-yocto-standard+ #567
> Hardware name: SoCFPGA Agilex SoCDK (DT)
> Call trace:
> dump_backtrace.part.0+0xc4/0xd0
> show_stack+0x24/0x40
> dump_stack_lvl+0x7c/0xa0
> dump_stack+0x18/0x34
> __might_resched+0x154/0x1c0
> __might_sleep+0x58/0x90
> init_systime+0x78/0x120
> stmmac_set_time+0x64/0x8c
> ptp_clock_settime+0x60/0x9c
> pc_clock_settime+0x6c/0xc0
> __arm64_sys_clock_settime+0x88/0xf0
> invoke_syscall+0x5c/0x130
> el0_svc_common.constprop.0+0x4c/0x100
> do_el0_svc+0x7c/0xa0
> el0_svc+0x58/0xcc
> el0t_64_sync_handler+0xa4/0x130
> el0t_64_sync+0x18c/0x190
>
> [...]
Here is the summary with links:
- [v2,net] net: stmmac: Use readl_poll_timeout_atomic() in atomic state
https://git.kernel.org/netdev/net/c/234901de2bc6
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-20 10:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-19 8:42 [PATCH v2 net] net: stmmac: Use readl_poll_timeout_atomic() in atomic state Kevin Hao
2022-04-20 10:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).