firewire: core: use reference counting to invoke address handlers safely
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sun, 3 Aug 2025 12:20:12 +0000 (21:20 +0900)
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>
Mon, 11 Aug 2025 13:22:33 +0000 (22:22 +0900)
commit7c527c15cdda2e0a26a05ac15a44d3e14738fc55
tree187e51060ad1114eb7e33346550073b5d945098c
parent8f5ae30d69d7543eee0d70083daf4de8fe15d585
firewire: core: use reference counting to invoke address handlers safely

The lifetime of address handler has been managed by linked list and RCU.
This approach was introduced in commit 35202f7d8420 ("firewire: remove
global lock around address handlers, convert to RCU"). The invocations of
address handler are performed within RCU read-side critical sections.

In commit 57e6d9f85fff ("firewire: ohci: use workqueue to handle events
of AR request/response contexts"), the invocations are in a workqueue
context. The approach still imposes limitation that sleeping is not
allowed within RCU read-side critical sections. However, since sleeping
is not permitted within RCU read-side critical sections, this approach
still has a limitation.

This commit adds reference counting to decouple handler invocation from
handler discovery. The linked list and RCU is used to discover the
handlers, while the reference counting is used to invoke them safely.

Link: https://lore.kernel.org/r/20250803122015.236493-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
drivers/firewire/core-transaction.c
include/linux/firewire.h