[PATCH v3 5/6] firewire: core: use context analysis annotations and lockdep checks for topology map lock

From: Takashi Sakamoto

Date: Sun Oct 11 2026 - 02:32:34 EST


The spinlock protects the topology map from concurrent access.

Add context analysis annotations and lockdep checks for this lock.

Signed-off-by: Takashi Sakamoto <o-takashi@xxxxxxxxxxxxx>
---
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 bd6d28f9bc50..ec04bd82831c 100644
--- a/drivers/firewire/core-transaction.c
+++ b/drivers/firewire/core-transaction.c
@@ -1288,9 +1288,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;

--
2.53.0