From c2b3fb63263ed5f15d3855e2ca0405d412f836f0 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Sun, 11 Oct 2026 15:31:45 +0900 Subject: [PATCH] firewire: core: use context analysis annotations and lockdep checks for topology map lock The spinlock protects the topology map from concurrent access. Add context analysis annotations and lockdep checks for this lock. Link: https://lore.kernel.org/r/20261011063146.497455-6-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-topology.c | 3 +++ drivers/firewire/core-transaction.c | 3 +++ include/linux/firewire.h | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/firewire/core-topology.c b/drivers/firewire/core-topology.c index ee6b54f89859..512b7e4473af 100644 --- a/drivers/firewire/core-topology.c +++ b/drivers/firewire/core-topology.c @@ -474,9 +474,12 @@ static void update_topology_map(__be32 *buffer, size_t buffer_size, int root_nod void fw_core_handle_bus_reset(struct fw_card *card, int node_id, int generation, int self_id_count, u32 *self_ids, bool bm_abdicate) +__must_not_hold(&card->topology_map.lock) { struct fw_node *local_node; + lockdep_assert_not_held(&card->topology_map.lock); + trace_bus_reset_handle(card->index, generation, node_id, bm_abdicate, self_ids, self_id_count); scoped_guard(spinlock, &card->lock) { diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c index 4d60f4998c6e..ee1679347b36 100644 --- a/drivers/firewire/core-transaction.c +++ b/drivers/firewire/core-transaction.c @@ -1290,9 +1290,12 @@ static void handle_topology_map(struct fw_card *card, struct fw_request *request int tcode, int destination, int source, int generation, unsigned long long offset, void *payload, size_t length, void *callback_data) +__must_not_hold(&card->topology_map.lock) { int start; + lockdep_assert_not_held(&card->topology_map.lock); + if (!tcode_is_read_request(tcode)) { fw_send_response(card, request, RCODE_TYPE_ERROR); return; diff --git a/include/linux/firewire.h b/include/linux/firewire.h index a3660ad1a1d4..b55c2fdd739d 100644 --- a/include/linux/firewire.h +++ b/include/linux/firewire.h @@ -139,7 +139,7 @@ struct fw_card { u32 broadcast_channel; struct { - __be32 buffer[(CSR_TOPOLOGY_MAP_END - CSR_TOPOLOGY_MAP) / 4]; + __be32 buffer[(CSR_TOPOLOGY_MAP_END - CSR_TOPOLOGY_MAP) / 4] __guarded_by(&lock); spinlock_t lock; } topology_map;