linux/drivers/net
Kevin Hao aba3ea9829 net: macb: Move devm_{free,request}_irq() out of spin lock area
[ Upstream commit 317e49358e ]

The devm_free_irq() and devm_request_irq() functions should not be
executed in an atomic context.

During device suspend, all userspace processes and most kernel threads
are frozen. Additionally, we flush all tx/rx status, disable all macb
interrupts, and halt rx operations. Therefore, it is safe to split the
region protected by bp->lock into two independent sections, allowing
devm_free_irq() and devm_request_irq() to run in a non-atomic context.
This modification resolves the following lockdep warning:
  BUG: sleeping function called from invalid context at kernel/locking/mutex.c:591
  in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 501, name: rtcwake
  preempt_count: 1, expected: 0
  RCU nest depth: 1, expected: 0
  7 locks held by rtcwake/501:
   #0: ffff0008038c3408 (sb_writers#5){.+.+}-{0:0}, at: vfs_write+0xf8/0x368
   #1: ffff0008049a5e88 (&of->mutex#2){+.+.}-{4:4}, at: kernfs_fop_write_iter+0xbc/0x1c8
   #2: ffff00080098d588 (kn->active#70){.+.+}-{0:0}, at: kernfs_fop_write_iter+0xcc/0x1c8
   #3: ffff800081c84888 (system_transition_mutex){+.+.}-{4:4}, at: pm_suspend+0x1ec/0x290
   #4: ffff0008009ba0f8 (&dev->mutex){....}-{4:4}, at: device_suspend+0x118/0x4f0
   #5: ffff800081d00458 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire+0x4/0x48
   #6: ffff0008031fb9e0 (&bp->lock){-.-.}-{3:3}, at: macb_suspend+0x144/0x558
  irq event stamp: 8682
  hardirqs last  enabled at (8681): [<ffff8000813c7d7c>] _raw_spin_unlock_irqrestore+0x44/0x88
  hardirqs last disabled at (8682): [<ffff8000813c7b58>] _raw_spin_lock_irqsave+0x38/0x98
  softirqs last  enabled at (7322): [<ffff8000800f1b4c>] handle_softirqs+0x52c/0x588
  softirqs last disabled at (7317): [<ffff800080010310>] __do_softirq+0x20/0x2c
  CPU: 1 UID: 0 PID: 501 Comm: rtcwake Not tainted 7.0.0-rc3-next-20260310-yocto-standard+ #125 PREEMPT
  Hardware name: ZynqMP ZCU102 Rev1.1 (DT)
  Call trace:
   show_stack+0x24/0x38 (C)
   __dump_stack+0x28/0x38
   dump_stack_lvl+0x64/0x88
   dump_stack+0x18/0x24
   __might_resched+0x200/0x218
   __might_sleep+0x38/0x98
   __mutex_lock_common+0x7c/0x1378
   mutex_lock_nested+0x38/0x50
   free_irq+0x68/0x2b0
   devm_irq_release+0x24/0x38
   devres_release+0x40/0x80
   devm_free_irq+0x48/0x88
   macb_suspend+0x298/0x558
   device_suspend+0x218/0x4f0
   dpm_suspend+0x244/0x3a0
   dpm_suspend_start+0x50/0x78
   suspend_devices_and_enter+0xec/0x560
   pm_suspend+0x194/0x290
   state_store+0x110/0x158
   kobj_attr_store+0x1c/0x30
   sysfs_kf_write+0xa8/0xd0
   kernfs_fop_write_iter+0x11c/0x1c8
   vfs_write+0x248/0x368
   ksys_write+0x7c/0xf8
   __arm64_sys_write+0x28/0x40
   invoke_syscall+0x4c/0xe8
   el0_svc_common+0x98/0xf0
   do_el0_svc+0x28/0x40
   el0_svc+0x54/0x1e0
   el0t_64_sync_handler+0x84/0x130
   el0t_64_sync+0x198/0x1a0

Fixes: 558e35ccfe ("net: macb: WoL support for GEM type of Ethernet controller")
Cc: stable@vger.kernel.org
Reviewed-by: Théo Lebrun <theo.lebrun@bootlin.com>
Signed-off-by: Kevin Hao <haokexin@gmail.com>
Link: https://patch.msgid.link/20260318-macb-irq-v2-1-f1179768ab24@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[ adapted WoL register writes to use MACB_BIT(MAG) instead of tmp variable ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-04-18 10:33:38 +02:00
..
appletalk make legacy ISA probe optional 2021-08-03 13:05:26 +01:00
arcnet net: arcnet: com20020-pci: fix support for 2.5Mbit cards 2026-04-18 10:33:08 +02:00
bonding net: bonding: fix NULL deref in bond_debug_rlb_hash_show 2026-04-18 10:33:21 +02:00
caif serial: caif: hold tty->link reference in ldisc_open and ser_release 2026-04-18 10:33:12 +02:00
can can: gs_usb: gs_usb_receive_bulk_callback(): fix error message 2026-04-18 10:33:34 +02:00
dsa net: dsa: bcm_sf2: fix missing clk_disable_unprepare() in error paths 2026-04-18 10:33:22 +02:00
ethernet net: macb: Move devm_{free,request}_irq() out of spin lock area 2026-04-18 10:33:38 +02:00
fddi net: defxx: Fix missing err handling in dfx_init() 2022-12-31 13:14:18 +01:00
fjes fjes: Add missing iounmap in fjes_hw_init() 2026-01-19 13:10:03 +01:00
hamradio hamradio: baycom_epp: Fix return type of baycom_send_packet() 2022-12-31 13:14:41 +01:00
hippi drivers: net: hippi: Fix deadlock in rr_close() 2022-05-09 09:14:40 +02:00
hyperv hv_netvsc: Fix panic during namespace deletion with VF 2025-08-28 16:24:31 +02:00
ieee802154 ieee802154: ca8210: Use proper setters and getters for bitwise types 2025-06-04 14:37:58 +02:00
ipa net: ipa: compute DMA pool size properly 2023-04-05 11:24:57 +02:00
ipvlan ipvlan: Make the addrs_lock be per port 2026-02-06 16:41:53 +01:00
mctp mctp: Add initial driver infrastructure 2021-07-29 15:06:50 +01:00
mdio net: mdio: aspeed: add dummy read to avoid read-after-write issue 2026-01-19 13:09:56 +01:00
netdevsim netdevsim: print human readable IP address 2025-03-13 12:50:46 +01:00
pcs net: pcs: xpcs: Return EINVAL in the internal methods 2024-04-13 13:01:43 +02:00
phy net: phy: register phy led_triggers during probe to avoid AB-BA deadlock 2026-04-18 10:33:19 +02:00
plip net: plip: fix break; causing plip to never transmit 2024-11-01 01:52:36 +01:00
ppp ppp: fix memory leak in pad_compress_skb 2025-09-09 18:50:20 +02:00
slip slip: make slhc_remember() more robust against malicious packets 2024-10-17 15:11:58 +02:00
team team: Move team device type change at the end of team_port_add 2026-02-06 16:42:06 +01:00
usb net: usb: r8152: add TRENDnet TUC-ET2G 2026-04-18 10:33:23 +02:00
vmxnet3 vmxnet3: update MTU after device quiesce 2025-09-09 18:50:23 +02:00
vxlan vxlan: validate ND option lengths in vxlan_na_create 2026-04-18 10:33:34 +02:00
wan net: wan/fsl_ucc_hdlc: Fix dma_free_coherent() in uhdlc_memclean() 2026-03-04 07:20:35 -05:00
wireguard Revert "wireguard: device: enable threaded NAPI" 2026-02-19 16:21:44 +01:00
wireless wifi: brcmsmac: Fix dma_free_coherent() size 2026-04-18 10:33:36 +02:00
wwan net: wwan: mhi_wwan_mbim: Silence sequence number glitch errors 2025-04-10 14:31:51 +02:00
xen-netback xen-netback: reject zero-queue configuration from guest 2026-03-04 07:19:50 -05:00
bareudp.c bareudp: Pull inner IP header on xmit. 2024-10-17 15:10:47 +02:00
dummy.c net: bonding, dummy, ifb, team: advertise NETIF_F_GSO_SOFTWARE 2020-11-03 16:53:55 -08:00
eql.c eql: use ndo_siocdevprivate 2021-07-27 20:11:43 +01:00
geneve.c geneve: Suppress list corruption splat in geneve_destroy_tunnels(). 2025-03-13 12:50:52 +01:00
gtp.c gtp: Suppress list corruption splat in gtp_net_exit_batch_rtnl(). 2025-03-13 12:50:52 +01:00
ifb.c ifb: fix building without CONFIG_NET_CLS_ACT 2021-11-18 19:16:04 +01:00
Kconfig lib/crypto: blake2s: include as built-in 2022-05-30 09:28:59 +02:00
LICENSE.SRC Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
loopback.c net: loopback: Avoid sending IP packets without an Ethernet header 2025-03-13 12:50:56 +01:00
macsec.c macsec: MACsec SCI assignment for ES = 0 2025-06-27 11:05:20 +01:00
macvlan.c macvlan: observe an RCU grace period in macvlan_common_newlink() error path 2026-03-04 07:19:52 -05:00
macvtap.c macvtap: advertise link netns via netlink 2022-04-13 20:59:07 +02:00
Makefile net: Always descend into dsa/ folder with CONFIG_NET_DSA enabled 2024-06-16 13:39:46 +02:00
mdio.c net: mdio: Correct function name mdio45_links_ok() in comment 2021-03-29 13:42:44 -07:00
mhi_net.c net: mhi: Fix memory leak in mhi_net_dellink() 2022-11-26 09:24:40 +01:00
mii.c net: mii: make mii_ethtool_gset() return void 2021-08-19 13:06:53 +01:00
net_failover.c net/net_failover: fix txq exceeding warning 2023-04-05 11:24:55 +02:00
netconsole.c net: netconsole: Disable target before netpoll cleanup 2024-08-19 05:45:11 +02:00
nlmon.c net: don't include ethtool.h from netdevice.h 2020-11-23 17:27:04 -08:00
ntb_netdev.c ntb_netdev: Use dev_kfree_skb_any() in interrupt context 2022-12-31 13:14:20 +01:00
rionet.c rionet: Fix use correct return type for ndo_start_xmit() 2020-04-30 12:15:13 -07:00
sb1000.c sb1000: use ndo_siocdevprivate 2021-07-27 20:11:44 +01:00
Space.c wan: remove sbni/granch driver 2021-08-03 13:05:26 +01:00
sungem_phy.c net: sungem_phy: Add of_node_put() for reference returned by of_get_parent() 2022-08-03 12:03:48 +02:00
tap.c tap: add missing verification for short frame 2024-07-27 10:46:18 +02:00
thunderbolt.c net: thunderbolt: Fix the parameter passing of tb_xdomain_enable_paths()/tb_xdomain_disable_paths() 2025-08-28 16:24:21 +02:00
tun.c tun: revert fix group permission check 2025-03-13 12:50:23 +01:00
veth.c net: veth: do not manipulate GRO when using XDP 2024-03-26 18:21:35 -04:00
virtio_net.c virtio_net: Fix UAF on dst_ops when IFF_XMIT_DST_RELEASE is cleared and napi_tx is false 2026-04-18 10:33:27 +02:00
vrf.c vrf: Drop existing dst reference in vrf_ip6_input_dst 2025-08-28 16:24:09 +02:00
vsockmon.c net: don't include ethtool.h from netdevice.h 2020-11-23 17:27:04 -08:00
xen-netfront.c xen/netfront: Fix TX response spurious interrupts 2025-08-28 16:24:19 +02:00