]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
net: spacemit: Make stats_lock softirq-safe
authorVivian Wang <wangruikang@iscas.ac.cn>
Fri, 19 Sep 2025 12:04:33 +0000 (20:04 +0800)
committerJakub Kicinski <kuba@kernel.org>
Mon, 22 Sep 2025 18:50:40 +0000 (11:50 -0700)
commit35626012877b80436e0627feb16520db4f0ba53e
tree0483c1c4153121cce8305ee5299cbb54d240a9ee
parent4b1eb8337e6bc1a8831e4ba8feff5927a8fb9a34
net: spacemit: Make stats_lock softirq-safe

While most of the statistics functions (emac_get_stats64() and such) are
called with softirqs enabled, emac_stats_timer() is, as its name
suggests, also called from a timer, i.e. called in softirq context.

All of these take stats_lock. Therefore, make stats_lock softirq-safe by
changing spin_lock() into spin_lock_bh() for the functions that get
statistics.

Also, instead of directly calling emac_stats_timer() in emac_up() and
emac_resume(), set the timer to trigger instead, so that
emac_stats_timer() is only called from the timer. It will keep using
spin_lock().

This fixes a lockdep warning, and potential deadlock when stats_timer is
triggered in the middle of getting statistics.

Fixes: bfec6d7f2001 ("net: spacemit: Add K1 Ethernet MAC")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Closes: https://lore.kernel.org/all/a52c0cf5-0444-41aa-b061-a0a1d72b02fe@samsung.com/
Signed-off-by: Vivian Wang <wangruikang@iscas.ac.cn>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Link: https://patch.msgid.link/20250919-k1-ethernet-fix-lock-v1-1-c8b700aa4954@iscas.ac.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/spacemit/k1_emac.c