[PATCH 2/5] firewire: ohci: add helper function to detect local AT request/response packets

From: Takashi Sakamoto

Date: Sun Sep 13 2026 - 06:14:11 EST


The current implementation handles asynchronous packets sent to the local
node specially. To decide whether a packet is destined for the local node,
the local node ID and bus generation need to be checked while holding the
spinlock, since both can change.

Add a helper function annotated to require the spinlock to be held.

Signed-off-by: Takashi Sakamoto <o-takashi@xxxxxxxxxxxxx>
---
drivers/firewire/ohci.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
index c8cb7bdcb4ed..290bac5112b7 100644
--- a/drivers/firewire/ohci.c
+++ b/drivers/firewire/ohci.c
@@ -1574,6 +1574,15 @@ static void handle_local_request(struct at_context *ctx, struct fw_packet *packe
}
}

+static bool destination_is_local(const struct fw_packet *packet, const struct fw_ohci *ohci)
+__must_hold(&ohci->lock)
+{
+ lockdep_assert_held(&ohci->lock);
+
+ return (async_header_get_destination(packet->header) == ohci->node_id &&
+ ohci->generation == packet->generation);
+}
+
static void at_context_transmit(struct at_context *ctx, struct fw_packet *packet)
{
struct fw_ohci *ohci = ctx->context.ohci;
@@ -1582,8 +1591,7 @@ static void at_context_transmit(struct at_context *ctx, struct fw_packet *packet

spin_lock_irqsave(&ohci->lock, flags);

- if (async_header_get_destination(packet->header) == ohci->node_id &&
- ohci->generation == packet->generation) {
+ if (destination_is_local(packet, ohci)) {
spin_unlock_irqrestore(&ohci->lock, flags);

// Timestamping on behalf of the hardware.
--
2.53.0