firewire: core: use spin lock specific to topology map

At present, the operation for read transaction to topology map register is
not protected by any kind of lock primitives. This causes a potential
problem to result in the mixed content of topology map.

This commit adds and uses spin lock specific to topology map.

Link: https://lore.kernel.org/r/20250915234747.915922-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
This commit is contained in:
Takashi Sakamoto
2025-09-16 08:47:44 +09:00
parent 07c446e35b
commit 7d138cb269
3 changed files with 24 additions and 10 deletions

View File

@@ -1196,7 +1196,11 @@ static void handle_topology_map(struct fw_card *card, struct fw_request *request
}
start = (offset - topology_map_region.start) / 4;
memcpy(payload, &card->topology_map[start], length);
// NOTE: This can be without irqsave when we can guarantee that fw_send_request() for local
// destination never runs in any type of IRQ context.
scoped_guard(spinlock_irqsave, &card->topology_map.lock)
memcpy(payload, &card->topology_map.buffer[start], length);
fw_send_response(card, request, RCODE_COMPLETE);
}