From nobody Thu Oct 2 14:27:54 2025 Received: from fout-b5-smtp.messagingengine.com (fout-b5-smtp.messagingengine.com [202.12.124.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 007A521A420 for ; Mon, 15 Sep 2025 23:47:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.148 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757980076; cv=none; b=MDVh5zDrrUCini83trE90CaMzUl6NqrkjUTcXjzWTcErm9DoexYeaUbf9uVM3xGtrzgjgSDOCLjJPZ/N2DOCjtU5PSkKwHFumgo42iMD3CbzAkFjKaQKtmB2ht47VbYOC2v1KxsTEBOdEPQiKm2bS2XlHV+huCTutUNmPx9hLAk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757980076; c=relaxed/simple; bh=YMLVPxZRJjHSwpacs4Y/4zxs9XOK0x8s3Jy3zIPcHAw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mJ4GGnADHBuHmb29Kic2MbFvqgqponP8L3fsxGRxBvFqKkWdC5SXDx/LoAqEV38wz56qCA6zd6b6Oo2+vQYd4qBIwv8h/9HP66jRyh+P61+c54DyceoiuaGF797mtO/11QQruGerxShyN/Q5tljK4DqX/P6ujJxzqDViN0Aelxs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp; spf=pass smtp.mailfrom=sakamocchi.jp; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b=Y13EsDhw; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=k2/z/z+P; arc=none smtp.client-ip=202.12.124.148 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="Y13EsDhw"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="k2/z/z+P" Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailfout.stl.internal (Postfix) with ESMTP id DF3FD1D001C2; Mon, 15 Sep 2025 19:47:52 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Mon, 15 Sep 2025 19:47:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1757980072; x= 1758066472; bh=TVLAZiE8S6oLCOMyBp6Z+AOI4tSEx9bMWEKSAF910Rk=; b=Y 13EsDhwWYzR3WvMUFORzFdbSUpAFPTq38GWvryOV0e3ULJuPshh8fZnUzUnZaA95 CQDGz+A9YmsoELOLhLNi5W0QYzSx03lK4ijM+C6BerTbLfFDgnSwoGGcRjw0pv5o wA6iDgFsZd1lAxoIAn7Pauc04iGoXM2PNi5jnm4+liI7LF6W86qGpVE9iaIJrnh7 euyY05AO83R0Wk2F5pmHCFRjK6SQpvxonUd+w9oUGVBIVoBItGR8kzof4PRPOShR touc8bt48VVY7pu22qyKLMB2L8IExB/NNroIDUJEEqzuzEVCkYwRAwWzPlH6KTJM Nm6BWPL78l9CNTdPGITOQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1757980072; x=1758066472; bh=T VLAZiE8S6oLCOMyBp6Z+AOI4tSEx9bMWEKSAF910Rk=; b=k2/z/z+PhPie740iq U1dk0p9DF/ztMps4i5q24wuTqDhLBzOTZ4CFimP79zbvsltJJxCnWEBzNTYIs69s VamGpUqHmL0zDiTNF0xEqVnzuslT7wKsT33V5JOtvxtqK9XscSC3U6e6z/yMUvdr ZOsBQBYOTotRFPfLaSuAlCsQwCRiDsQtsQKYXRdYRtOtjFdlwsMv32tgOREDjQCB x6MYbp4GlQE5Q+eikt6tXqEgZ74JYFglhskGKVcGOhNCT2z3UpudoDk+tDL4kp/o xWQ7icPaeJNuvnRFcLht3tA/Bzs23J3KO166KBov0u0GY7/7dgh7IS4WiTKrpFR5 uzHYA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdefledtgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghr rdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 15 Sep 2025 19:47:51 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 1/6] firewire: core: use scoped_guard() to manage critical section to update topology Date: Tue, 16 Sep 2025 08:47:42 +0900 Message-ID: <20250915234747.915922-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250915234747.915922-1-o-takashi@sakamocchi.jp> References: <20250915234747.915922-1-o-takashi@sakamocchi.jp> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" At present, guard() macro is used for the critical section to update topology. It is inconvenient to add the other critical sections into the function. This commit uses scoped_guard() macro instead. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-topology.c | 74 +++++++++++++++----------------- 1 file changed, 34 insertions(+), 40 deletions(-) diff --git a/drivers/firewire/core-topology.c b/drivers/firewire/core-topol= ogy.c index 5f8fb1201d80..17aaf14cab0b 100644 --- a/drivers/firewire/core-topology.c +++ b/drivers/firewire/core-topology.c @@ -458,46 +458,40 @@ void fw_core_handle_bus_reset(struct fw_card *card, i= nt node_id, int generation, =20 trace_bus_reset_handle(card->index, generation, node_id, bm_abdicate, sel= f_ids, self_id_count); =20 - guard(spinlock_irqsave)(&card->lock); - - /* - * If the selfID buffer is not the immediate successor of the - * previously processed one, we cannot reliably compare the - * old and new topologies. - */ - if (!is_next_generation(generation, card->generation) && - card->local_node !=3D NULL) { - fw_destroy_nodes(card); - card->bm_retries =3D 0; - } - - card->broadcast_channel_allocated =3D card->broadcast_channel_auto_alloca= ted; - card->node_id =3D node_id; - /* - * Update node_id before generation to prevent anybody from using - * a stale node_id together with a current generation. - */ - smp_wmb(); - card->generation =3D generation; - card->reset_jiffies =3D get_jiffies_64(); - card->bm_node_id =3D 0xffff; - card->bm_abdicate =3D bm_abdicate; - fw_schedule_bm_work(card, 0); - - local_node =3D build_tree(card, self_ids, self_id_count, generation); - - update_topology_map(card, self_ids, self_id_count); - - card->color++; - - if (local_node =3D=3D NULL) { - fw_err(card, "topology build failed\n"); - /* FIXME: We need to issue a bus reset in this case. */ - } else if (card->local_node =3D=3D NULL) { - card->local_node =3D local_node; - for_each_fw_node(card, local_node, report_found_node); - } else { - update_tree(card, local_node); + scoped_guard(spinlock, &card->lock) { + // If the selfID buffer is not the immediate successor of the + // previously processed one, we cannot reliably compare the + // old and new topologies. + if (!is_next_generation(generation, card->generation) && card->local_nod= e !=3D NULL) { + fw_destroy_nodes(card); + card->bm_retries =3D 0; + } + card->broadcast_channel_allocated =3D card->broadcast_channel_auto_alloc= ated; + card->node_id =3D node_id; + // Update node_id before generation to prevent anybody from using + // a stale node_id together with a current generation. + smp_wmb(); + card->generation =3D generation; + card->reset_jiffies =3D get_jiffies_64(); + card->bm_node_id =3D 0xffff; + card->bm_abdicate =3D bm_abdicate; + fw_schedule_bm_work(card, 0); + + local_node =3D build_tree(card, self_ids, self_id_count, generation); + + update_topology_map(card, self_ids, self_id_count); + + card->color++; + + if (local_node =3D=3D NULL) { + fw_err(card, "topology build failed\n"); + // FIXME: We need to issue a bus reset in this case. + } else if (card->local_node =3D=3D NULL) { + card->local_node =3D local_node; + for_each_fw_node(card, local_node, report_found_node); + } else { + update_tree(card, local_node); + } } } EXPORT_SYMBOL(fw_core_handle_bus_reset); --=20 2.48.1 From nobody Thu Oct 2 14:27:54 2025 Received: from fhigh-b6-smtp.messagingengine.com (fhigh-b6-smtp.messagingengine.com [202.12.124.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E62B2D7DC3 for ; Mon, 15 Sep 2025 23:47:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757980077; cv=none; b=ms/afqLDm54aGIoiwfh1QV28uNgDfkgN3n9muer5e1UGmisC4l+kN5szT98zCUKTFnbZB2FMk6pSDARs9ItiQfJPG9WIG5XpLre4CJt2g6EBtDTwIgL6X8pJjXDGKNRZTh+r5ClvfJ4BUWuGsr9r+rffMgo3lZn/Ey36LjN6sys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757980077; c=relaxed/simple; bh=37KFyZI8OaTZbPQtlWzGXpFRUlsa5GSETNO5iQbFa/g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UwG2Pfh+eHWtFUJFcrASb4lbKnXwmnLIo2h+bZYtBj9E9JXvYIXdiIRZ36gQrTr/TkETTM8pNyAWUx94Nn2kX3U77kYD2DGmR9n8SUAm1SgQphrY8BOYRblkgAiwHKwet9ub4K3yjkyMjdU+wIP5cOcs8xQ2MHUZmSwKeqhx8NM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp; spf=pass smtp.mailfrom=sakamocchi.jp; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b=TldeXMoA; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Cq7aHsoG; arc=none smtp.client-ip=202.12.124.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="TldeXMoA"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Cq7aHsoG" Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfhigh.stl.internal (Postfix) with ESMTP id 7F9177A01CE; Mon, 15 Sep 2025 19:47:54 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Mon, 15 Sep 2025 19:47:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1757980074; x= 1758066474; bh=5jZos+QL9az8uCHYNxTxueQYyMEWprpgi39yg43KbGM=; b=T ldeXMoAets+eOFo0jj4Nz6vG1IHhC5P6pPXwTXvS3+NV2r2RRM/IBWNW2KH4AGcw RhqAbthmZy5lecLjd3Fj6Xh/dVvKQKb1KTQ0OgT/9iDm8f/oZgLThkoSBd2k7dms P57+2l2mggAC+I2U9VguwsdRn/8FgCqgSa4dFjZqNoCFx8ptCwx4gXMApy76FNpw 2u/ACr1fs60xnr66scsMdFsdJ+e+heaXiu9aa9bxOkgg/qiQde/hbvTtbwk/9lXI Z+jqzr9oSSMgOJ1mGeet03jZHMbks7ANPhuvHfGeobZB+kpgWNrkj8DolKVUbiGJ 7+sRtMRgZP5/UosIr2I3g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1757980074; x=1758066474; bh=5 jZos+QL9az8uCHYNxTxueQYyMEWprpgi39yg43KbGM=; b=Cq7aHsoGSfq8ft9mF 7WWoy9RPr5eLHRvl8OZZ0Pjs3Htu5MUJ4Hco6N8rMWCl8anpe3DO4z2hc1y4w/Xk JviX5dMaHowA6DBaKpaTvMV0JXnL5CbOncRpMPNFZp/Gu2yhpOMhasEX7AwD6QAe 8Yjv2L2OPbUpbOkSlcbf94etZq5rAl3kX1YBlE1atQeqyeU/Gvqo752J32vCPFTO j7+M7FrtauoduTrj84qKYWjUj8v8LHeqyhnVoDNJnxs0hmN7Om5EJ24oCff8rwTq pOTiOubGBEt+8GUz3QF6FIns6c7DBYYTztjlQxL6iH/umYOeAKCUFM65KscgnHod aQAqg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdefledthecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghr rdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 15 Sep 2025 19:47:53 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 2/6] firewire: core: maintain phy packet receivers locally in cdev layer Date: Tue, 16 Sep 2025 08:47:43 +0900 Message-ID: <20250915234747.915922-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250915234747.915922-1-o-takashi@sakamocchi.jp> References: <20250915234747.915922-1-o-takashi@sakamocchi.jp> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The list of receivers for phy packet is used only by cdev layer, while it is maintained as a member of fw_card structure. This commit maintains the list locally in cdev layer. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 1 - drivers/firewire/core-cdev.c | 27 ++++++++++++++++++++------- include/linux/firewire.h | 2 -- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index b5e01a711145..616abb836ef3 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -556,7 +556,6 @@ void fw_card_initialize(struct fw_card *card, kref_init(&card->kref); init_completion(&card->done); INIT_LIST_HEAD(&card->transaction_list); - INIT_LIST_HEAD(&card->phy_receiver_list); spin_lock_init(&card->lock); =20 card->local_node =3D NULL; diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index 1be8f5eb3e17..112b33099610 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -47,6 +47,9 @@ #define FW_CDEV_VERSION_AUTO_FLUSH_ISO_OVERFLOW 5 #define FW_CDEV_VERSION_EVENT_ASYNC_TSTAMP 6 =20 +static DEFINE_SPINLOCK(phy_receiver_list_lock); +static LIST_HEAD(phy_receiver_list); + struct client { u32 version; struct fw_device *device; @@ -1669,15 +1672,16 @@ static int ioctl_send_phy_packet(struct client *cli= ent, union ioctl_arg *arg) static int ioctl_receive_phy_packets(struct client *client, union ioctl_ar= g *arg) { struct fw_cdev_receive_phy_packets *a =3D &arg->receive_phy_packets; - struct fw_card *card =3D client->device->card; =20 /* Access policy: Allow this ioctl only on local nodes' device files. */ if (!client->device->is_local) return -ENOSYS; =20 - guard(spinlock_irq)(&card->lock); + // NOTE: This can be without irq when we can guarantee that __fw_send_req= uest() for local + // destination never runs in any type of IRQ context. + scoped_guard(spinlock_irq, &phy_receiver_list_lock) + list_move_tail(&client->phy_receiver_link, &phy_receiver_list); =20 - list_move_tail(&client->phy_receiver_link, &card->phy_receiver_list); client->phy_receiver_closure =3D a->closure; =20 return 0; @@ -1687,10 +1691,17 @@ void fw_cdev_handle_phy_packet(struct fw_card *card= , struct fw_packet *p) { struct client *client; =20 - guard(spinlock_irqsave)(&card->lock); + // 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. + guard(spinlock_irqsave)(&phy_receiver_list_lock); + + list_for_each_entry(client, &phy_receiver_list, phy_receiver_link) { + struct inbound_phy_packet_event *e; + + if (client->device->card !=3D card) + continue; =20 - list_for_each_entry(client, &card->phy_receiver_list, phy_receiver_link) { - struct inbound_phy_packet_event *e =3D kmalloc(sizeof(*e) + 8, GFP_ATOMI= C); + e =3D kmalloc(sizeof(*e) + 8, GFP_ATOMIC); if (e =3D=3D NULL) break; =20 @@ -1857,7 +1868,9 @@ static int fw_device_op_release(struct inode *inode, = struct file *file) struct client_resource *resource; unsigned long index; =20 - scoped_guard(spinlock_irq, &client->device->card->lock) + // NOTE: This can be without irq when we can guarantee that __fw_send_req= uest() for local + // destination never runs in any type of IRQ context. + scoped_guard(spinlock_irq, &phy_receiver_list_lock) list_del(&client->phy_receiver_link); =20 scoped_guard(mutex, &client->device->client_list_mutex) diff --git a/include/linux/firewire.h b/include/linux/firewire.h index d38c6e538e5c..f3260aacf730 100644 --- a/include/linux/firewire.h +++ b/include/linux/firewire.h @@ -115,8 +115,6 @@ struct fw_card { int index; struct list_head link; =20 - struct list_head phy_receiver_list; - struct delayed_work br_work; /* bus reset job */ bool br_short; =20 --=20 2.48.1 From nobody Thu Oct 2 14:27:54 2025 Received: from fout-b5-smtp.messagingengine.com (fout-b5-smtp.messagingengine.com [202.12.124.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F34822DCF62 for ; Mon, 15 Sep 2025 23:47:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.148 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757980079; cv=none; b=XDTtqBbX2K0o9s3LEH6HG9pKwBLFPqgHB5NJyZA6dHW3H+cpbMBNxMrtnhy1qR+fIRW4YH7hFW8UEELgVAMJubIcTmK3LFXPaL0cvDzMoq0F2PM5ljTjjcw5j9JUfE0FgAlG6Wyjkjnv+2B0+Z4fMvys5gCx5ONstJFfhIHxsM0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757980079; c=relaxed/simple; bh=K0UcjUZYEl+Kv8ubuBGOj04ZWNBPfcbzKPW+heC6t40=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=opAAwky6xk9mWqI7LxjzLjEp+pEqQrO2YuaD/5R5gSy9KdyCnA2GrAPvkhNDL0oZjxcBrDupBU36wgm6dahmkBeHoqqz+wWiYrM7wLm2EHXqHHFtexBpU8N7Asd+w2DldV2FEgI1GrozxugaTW5PHOmaz8/J1Tv5/VQBCn4S9qo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp; spf=pass smtp.mailfrom=sakamocchi.jp; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b=RlJMaXh8; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=JIRyxcBF; arc=none smtp.client-ip=202.12.124.148 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="RlJMaXh8"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="JIRyxcBF" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.stl.internal (Postfix) with ESMTP id 1BC8F1D001C9; Mon, 15 Sep 2025 19:47:56 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Mon, 15 Sep 2025 19:47:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1757980075; x= 1758066475; bh=Dol20McAHmsGe7jZI4Cf8OSI5NXIOjVDQY+keMjSiAg=; b=R lJMaXh86BW7g0l/TLxN/QBxVVUrOHTFGOfLoS0qWY8sEeizOatGqeyYtwOPEWaFc ecCQ5AnIKpi/e5d58mEg2bUlVh8CICRnQapCKkmkKGi/6tmunjwYiFh7RfjgMMlR hr6uyr+f76Dzj+HcTANFbUBUxHXXtuRCpVF0+/kuMI5ueGG7vNtGO0SJ9Vpan8TT 7ksxPzx/D1KjRcGLQu6PvsM61QuaOMQWEZPWox3hHeEPjWktfu8LibsRig0NxsZ+ MUt6gECzf0+Mq0EFCVxfFbKY5CAimvXeqBhmA1g2hj0G1HLAcM53BgdWqfdH/NTp M1cZV7OLWkuL6F7598nsA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1757980075; x=1758066475; bh=D ol20McAHmsGe7jZI4Cf8OSI5NXIOjVDQY+keMjSiAg=; b=JIRyxcBFkpKooUjeH wYAS52CJbcSVp8H0INJzI6vYSvNzXDgkjtSfDqxll7IOSirdVpuMwhsByMHroD4p OyACMyXUNeGMovbyTs0kTQVxbZX058L22WXbpKyqOdHgAeF3SFoVHvxsUmYh6iYy dX0Nc5JlMnc1RWjzCj3tM+0TzVu6O48VcZ/sFmlJ7VTOvcMMy3mQvOfaQJazTR7X P92ILkB5p0a4xri8xVOkZl4o5rBUmAQAadCU0cyhMz4LQaSSOVxiT53deQ+R9odL 1fpxpi+L1uCyKP4e+xHd/GJT6Zh4jYB2/Yo4+N2ljuO84TUuerYjg5qqZE15NZ0F LnCKQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdefledthecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghr rdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 15 Sep 2025 19:47:54 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 3/6] firewire: core: use spin lock specific to topology map Date: Tue, 16 Sep 2025 08:47:44 +0900 Message-ID: <20250915234747.915922-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250915234747.915922-1-o-takashi@sakamocchi.jp> References: <20250915234747.915922-1-o-takashi@sakamocchi.jp> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-topology.c | 22 ++++++++++++++-------- drivers/firewire/core-transaction.c | 6 +++++- include/linux/firewire.h | 6 +++++- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/drivers/firewire/core-topology.c b/drivers/firewire/core-topol= ogy.c index 17aaf14cab0b..c62cf93f3f65 100644 --- a/drivers/firewire/core-topology.c +++ b/drivers/firewire/core-topology.c @@ -435,20 +435,22 @@ static void update_tree(struct fw_card *card, struct = fw_node *root) } } =20 -static void update_topology_map(struct fw_card *card, - u32 *self_ids, int self_id_count) +static void update_topology_map(__be32 *buffer, size_t buffer_size, int ro= ot_node_id, + const u32 *self_ids, int self_id_count) { - int node_count =3D (card->root_node->node_id & 0x3f) + 1; - __be32 *map =3D card->topology_map; + __be32 *map =3D buffer; + int node_count =3D (root_node_id & 0x3f) + 1; + + memset(map, 0, buffer_size); =20 *map++ =3D cpu_to_be32((self_id_count + 2) << 16); - *map++ =3D cpu_to_be32(be32_to_cpu(card->topology_map[1]) + 1); + *map++ =3D cpu_to_be32(be32_to_cpu(buffer[1]) + 1); *map++ =3D cpu_to_be32((node_count << 16) | self_id_count); =20 while (self_id_count--) *map++ =3D cpu_to_be32p(self_ids++); =20 - fw_compute_block_crc(card->topology_map); + fw_compute_block_crc(buffer); } =20 void fw_core_handle_bus_reset(struct fw_card *card, int node_id, int gener= ation, @@ -479,8 +481,6 @@ void fw_core_handle_bus_reset(struct fw_card *card, int= node_id, int generation, =20 local_node =3D build_tree(card, self_ids, self_id_count, generation); =20 - update_topology_map(card, self_ids, self_id_count); - card->color++; =20 if (local_node =3D=3D NULL) { @@ -493,5 +493,11 @@ void fw_core_handle_bus_reset(struct fw_card *card, in= t node_id, int generation, update_tree(card, local_node); } } + + // Just used by transaction layer. + scoped_guard(spinlock, &card->topology_map.lock) { + update_topology_map(card->topology_map.buffer, sizeof(card->topology_map= .buffer), + card->root_node->node_id, self_ids, self_id_count); + } } EXPORT_SYMBOL(fw_core_handle_bus_reset); diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-tr= ansaction.c index 623e1d9bd107..8edffafd21c1 100644 --- a/drivers/firewire/core-transaction.c +++ b/drivers/firewire/core-transaction.c @@ -1196,7 +1196,11 @@ static void handle_topology_map(struct fw_card *card= , struct fw_request *request } =20 start =3D (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_r= equest() 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); =20 fw_send_response(card, request, RCODE_COMPLETE); } diff --git a/include/linux/firewire.h b/include/linux/firewire.h index f3260aacf730..aeb71c39e57e 100644 --- a/include/linux/firewire.h +++ b/include/linux/firewire.h @@ -129,7 +129,11 @@ struct fw_card { =20 bool broadcast_channel_allocated; u32 broadcast_channel; - __be32 topology_map[(CSR_TOPOLOGY_MAP_END - CSR_TOPOLOGY_MAP) / 4]; + + struct { + __be32 buffer[(CSR_TOPOLOGY_MAP_END - CSR_TOPOLOGY_MAP) / 4]; + spinlock_t lock; + } topology_map; =20 __be32 maint_utility_register; =20 --=20 2.48.1 From nobody Thu Oct 2 14:27:54 2025 Received: from fout-b5-smtp.messagingengine.com (fout-b5-smtp.messagingengine.com [202.12.124.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE0B12DF149 for ; Mon, 15 Sep 2025 23:47:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.148 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757980080; cv=none; b=mSbcHMwWFQHBzG7sAS0QyagfpKel7gumUrdIHl0mdoXv1Uvmc6USA00JoLCrjf/L2Puupk5kh0hohjd35GKl18jBcJyVmIRg+swfZkgRjrUqzph/VyLVwFZ5qRgu+qFK362VB0rJe9gAAH2bxpBRL5/n/RvBtyXfQDVAfT10PAg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757980080; c=relaxed/simple; bh=0j3gWXdeyB+uXOybDwzFHQT6HxRLv5uMoPrCHdBqsoQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lajglRsCOYyuYWqGK7D1gg1kgbSNJK/FdaG//pAXJCUzkCAsMAARes+TSVVYNA3ycMmGeaRugDkUgyk+MoQrPouNvDbNW/Wjbz0Wd5gNMnjS3qf1dQE+c6MtRSMQS02Iz6VbZj6NR2D97gWgBA9G2Xfh6pSx1IfBpVGvbDEInLA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp; spf=pass smtp.mailfrom=sakamocchi.jp; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b=pywV4gCN; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=bmS/Bh7b; arc=none smtp.client-ip=202.12.124.148 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="pywV4gCN"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="bmS/Bh7b" Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfout.stl.internal (Postfix) with ESMTP id A37921D001B7; Mon, 15 Sep 2025 19:47:57 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Mon, 15 Sep 2025 19:47:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1757980077; x= 1758066477; bh=ftRdwZYdPo5igfENPCqfeghdCxDccZ9UOFd6fov0EIE=; b=p ywV4gCNyrk68zkwyUIwCL9BMtcUTqujSgeDdoA490/iHRipJirD0CmsCEXJd81l3 q/vxmmfgZW8pS51F7tmTNSosSqa1oseA1WSVrk4ajA5vv1QBD5Up8FCJzBvrdhvX 9Ar56LWOUbg8h/LD79k93Mbnai2y8P9DMW8ffIZJHiybLGwfPQWOX4AKNUQfDkwg 7UCw64Rxg82BbJ8/X4A+YW40GRNi1zvaySWhJFuVeYR3caZeYAWhTofQ0O7sxb80 VxiydZ5gSmEtRD9gi2Vqc1N87HEX61JQwtWvxaRj+ZE9IJHy8a2kYxkjgT4dhkuv MJ0dj4rFbB31WgbouazGA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1757980077; x=1758066477; bh=f tRdwZYdPo5igfENPCqfeghdCxDccZ9UOFd6fov0EIE=; b=bmS/Bh7bGeAdCpfuC ej14kHpghapfjS96YTApc6IDLCLkHOqEDvpXvm3+L2L5VInZ1pECYLcDlTm7vS7H CeaCRbK4ZbASgCSioO17eOUEWLYBRSXJDhndMdnktAtKLdeWGnPZfnzIELbj9jWD /BkGKtOcikKfwZ6/6VGU3RAz9hfl7z+nnVOMI7JODtC4oo5hL6TNZiI0TRusQ+ov wxA9VN5Xm6e85LOEemWBaFCpYp8gxd/OEpYEXgWQ3Nc3QRvgIHZM2xrNLsp3NQA0 PLfoN/XkHb1lUjm69DZZHknxgDmQCQ0+c5m/kR7UaQO6uaNPF3+mQYq/UPh/OQOf YeZnw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdefledthecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghr rdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 15 Sep 2025 19:47:56 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 4/6] firewire: core: use spin lock specific to transaction Date: Tue, 16 Sep 2025 08:47:45 +0900 Message-ID: <20250915234747.915922-5-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250915234747.915922-1-o-takashi@sakamocchi.jp> References: <20250915234747.915922-1-o-takashi@sakamocchi.jp> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The list of instance for asynchronous transaction to wait for response subaction is maintained as a member of fw_card structure. The card-wide spinlock is used at present for any operation over the list, however it is not necessarily suited for the purpose. This commit adds and uses the spin lock specific to maintain the list. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 12 ++++-- drivers/firewire/core-transaction.c | 59 ++++++++++++++++++----------- include/linux/firewire.h | 10 +++-- 3 files changed, 51 insertions(+), 30 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index 616abb836ef3..39f95007305f 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -544,8 +544,12 @@ void fw_card_initialize(struct fw_card *card, card->index =3D atomic_inc_return(&index); card->driver =3D driver; card->device =3D device; - card->current_tlabel =3D 0; - card->tlabel_mask =3D 0; + + card->transactions.current_tlabel =3D 0; + card->transactions.tlabel_mask =3D 0; + INIT_LIST_HEAD(&card->transactions.list); + spin_lock_init(&card->transactions.lock); + card->split_timeout_hi =3D DEFAULT_SPLIT_TIMEOUT / 8000; card->split_timeout_lo =3D (DEFAULT_SPLIT_TIMEOUT % 8000) << 19; card->split_timeout_cycles =3D DEFAULT_SPLIT_TIMEOUT; @@ -555,7 +559,7 @@ void fw_card_initialize(struct fw_card *card, =20 kref_init(&card->kref); init_completion(&card->done); - INIT_LIST_HEAD(&card->transaction_list); + spin_lock_init(&card->lock); =20 card->local_node =3D NULL; @@ -772,7 +776,7 @@ void fw_core_remove_card(struct fw_card *card) destroy_workqueue(card->isoc_wq); destroy_workqueue(card->async_wq); =20 - WARN_ON(!list_empty(&card->transaction_list)); + WARN_ON(!list_empty(&card->transactions.list)); } EXPORT_SYMBOL(fw_core_remove_card); =20 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-tr= ansaction.c index 8edffafd21c1..5366d8a781ac 100644 --- a/drivers/firewire/core-transaction.c +++ b/drivers/firewire/core-transaction.c @@ -49,12 +49,14 @@ static int close_transaction(struct fw_transaction *tra= nsaction, struct fw_card { struct fw_transaction *t =3D NULL, *iter; =20 - scoped_guard(spinlock_irqsave, &card->lock) { - list_for_each_entry(iter, &card->transaction_list, link) { + // 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->transactions.lock) { + list_for_each_entry(iter, &card->transactions.list, link) { if (iter =3D=3D transaction) { if (try_cancel_split_timeout(iter)) { list_del_init(&iter->link); - card->tlabel_mask &=3D ~(1ULL << iter->tlabel); + card->transactions.tlabel_mask &=3D ~(1ULL << iter->tlabel); t =3D iter; } break; @@ -117,11 +119,11 @@ static void split_transaction_timeout_callback(struct= timer_list *timer) struct fw_transaction *t =3D timer_container_of(t, timer, split_timeout_t= imer); struct fw_card *card =3D t->card; =20 - scoped_guard(spinlock_irqsave, &card->lock) { + scoped_guard(spinlock_irqsave, &card->transactions.lock) { if (list_empty(&t->link)) return; list_del(&t->link); - card->tlabel_mask &=3D ~(1ULL << t->tlabel); + card->transactions.tlabel_mask &=3D ~(1ULL << t->tlabel); } =20 if (!t->with_tstamp) { @@ -259,18 +261,21 @@ static void fw_fill_request(struct fw_packet *packet,= int tcode, int tlabel, } =20 static int allocate_tlabel(struct fw_card *card) +__must_hold(&card->transactions_lock) { int tlabel; =20 - tlabel =3D card->current_tlabel; - while (card->tlabel_mask & (1ULL << tlabel)) { + lockdep_assert_held(&card->transactions.lock); + + tlabel =3D card->transactions.current_tlabel; + while (card->transactions.tlabel_mask & (1ULL << tlabel)) { tlabel =3D (tlabel + 1) & 0x3f; - if (tlabel =3D=3D card->current_tlabel) + if (tlabel =3D=3D card->transactions.current_tlabel) return -EBUSY; } =20 - card->current_tlabel =3D (tlabel + 1) & 0x3f; - card->tlabel_mask |=3D 1ULL << tlabel; + card->transactions.current_tlabel =3D (tlabel + 1) & 0x3f; + card->transactions.tlabel_mask |=3D 1ULL << tlabel; =20 return tlabel; } @@ -331,7 +336,6 @@ void __fw_send_request(struct fw_card *card, struct fw_= transaction *t, int tcode void *payload, size_t length, union fw_transaction_callback callback, bool with_tstamp, void *callback_data) { - unsigned long flags; int tlabel; =20 /* @@ -339,11 +343,11 @@ void __fw_send_request(struct fw_card *card, struct f= w_transaction *t, int tcode * the list while holding the card spinlock. */ =20 - spin_lock_irqsave(&card->lock, flags); - - tlabel =3D allocate_tlabel(card); + // 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->transactions.lock) + tlabel =3D allocate_tlabel(card); if (tlabel < 0) { - spin_unlock_irqrestore(&card->lock, flags); if (!with_tstamp) { callback.without_tstamp(card, RCODE_SEND_ERROR, NULL, 0, callback_data); } else { @@ -368,15 +372,22 @@ void __fw_send_request(struct fw_card *card, struct f= w_transaction *t, int tcode t->callback =3D callback; t->with_tstamp =3D with_tstamp; t->callback_data =3D callback_data; - - fw_fill_request(&t->packet, tcode, t->tlabel, destination_id, card->node_= id, generation, - speed, offset, payload, length); t->packet.callback =3D transmit_complete_callback; =20 - list_add_tail(&t->link, &card->transaction_list); + // 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->lock) { + // The node_id field of fw_card can be updated when handling SelfIDCompl= ete. + fw_fill_request(&t->packet, tcode, t->tlabel, destination_id, card->node= _id, + generation, speed, offset, payload, length); + } =20 - spin_unlock_irqrestore(&card->lock, flags); + // 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->transactions.lock) + list_add_tail(&t->link, &card->transactions.list); =20 + // Safe with no lock, since the index field of fw_card is immutable once = assigned. trace_async_request_outbound_initiate((uintptr_t)t, card->index, generati= on, speed, t->packet.header, payload, tcode_is_read_request(tcode) ? 0 : length / 4); @@ -1111,12 +1122,14 @@ void fw_core_handle_response(struct fw_card *card, = struct fw_packet *p) break; } =20 - scoped_guard(spinlock_irqsave, &card->lock) { - list_for_each_entry(iter, &card->transaction_list, link) { + // 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->transactions.lock) { + list_for_each_entry(iter, &card->transactions.list, link) { if (iter->node_id =3D=3D source && iter->tlabel =3D=3D tlabel) { if (try_cancel_split_timeout(iter)) { list_del_init(&iter->link); - card->tlabel_mask &=3D ~(1ULL << iter->tlabel); + card->transactions.tlabel_mask &=3D ~(1ULL << iter->tlabel); t =3D iter; } break; diff --git a/include/linux/firewire.h b/include/linux/firewire.h index aeb71c39e57e..8d6801cf2fca 100644 --- a/include/linux/firewire.h +++ b/include/linux/firewire.h @@ -88,11 +88,15 @@ struct fw_card { =20 int node_id; int generation; - int current_tlabel; - u64 tlabel_mask; - struct list_head transaction_list; u64 reset_jiffies; =20 + struct { + int current_tlabel; + u64 tlabel_mask; + struct list_head list; + spinlock_t lock; + } transactions; + u32 split_timeout_hi; u32 split_timeout_lo; unsigned int split_timeout_cycles; --=20 2.48.1 From nobody Thu Oct 2 14:27:54 2025 Received: from fhigh-b6-smtp.messagingengine.com (fhigh-b6-smtp.messagingengine.com [202.12.124.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17A012DF6F8 for ; Mon, 15 Sep 2025 23:47:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757980082; cv=none; b=vBsXjCRxiRl+3/2B827G1mNyi/b6yzP9IEbVxdUKxNIANdoodGsOXUJy3EfvsjmJomWoc0skNCxBYksSg9FHwykMb1vJtDKy7lkrzXfh809Io/2ynI+4npWECjhRfEKNy9N7csmXX/BNPjMaEci8ZVtNx8Mn0/AatZ98pfdZl+8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757980082; c=relaxed/simple; bh=sAqn9T1+386/jetiB7S/ZTyAagDI23m4kwWRc17HvWk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RLtgr9pAxJ7ZtWKethJE0H9+R2RCju1jmNOR9cG3q4Vc09fcOgcdn8sQpgcEO+SICUjetunICyeYtMgQnG05CLLVQ8YiPRX5qNroi6wx0GPqNj3l2f4UeYDlzrmE/fGKo7lAsvLSoxw78crDwmZNEHBgtU2fZJ0i5Oe1I3HO6cE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp; spf=pass smtp.mailfrom=sakamocchi.jp; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b=q1gm3f1G; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=IC5tJNGA; arc=none smtp.client-ip=202.12.124.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="q1gm3f1G"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="IC5tJNGA" Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfhigh.stl.internal (Postfix) with ESMTP id 375CF7A019F; Mon, 15 Sep 2025 19:47:59 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Mon, 15 Sep 2025 19:47:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1757980079; x= 1758066479; bh=0q1rmHtcD/GAxDwFEVUDokzNyCrgp7cj3dsW3YNiFTU=; b=q 1gm3f1G41PBtL5ilaq4WMZOeBVMJSDi1ySWPVKY+9YR7QXUJTLajInCR69qtf79i e/Rjwudw/5qbRalJQLh9coddHchvHWnSiIaZXjPj06uTsKNUxOc+6pXfgD+GsODA pZYxdoOdLyijP4B9w0cDf0jpan0bvxEiCFx1HzZ33VXJBTqwt5kEY1djYZ/F8maJ JXhVt6TQT/JIlSpoXm/7eyOwCxhRXkpmRhBPiP1eO5/jplHr43sit9wJaIjkV3oa iT8t78PtruK7Jq0iJrK1lb7Lo5odMPGwFe5ILc32ows5cOgJWXhFNejNPUnmTXN9 pOvZgbjj4AXRW9hH5twZw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1757980079; x=1758066479; bh=0 q1rmHtcD/GAxDwFEVUDokzNyCrgp7cj3dsW3YNiFTU=; b=IC5tJNGAqs5eHf7dS eAvz2ajvwaIvKp0ALGLl6+YWTQFla0X0iMkdqHTzYZQ5YqFk6IEo1M4P97C7DOWL CsPnCjPv6JitPCA7eUbQCaqQ1dvWzgLRRMQJDmAvO56ngx0P+NKT8uu2nCmhlzbY bsLDznZu/EWUdZNaRjlkMHj38l5FZf9VPC0nJ9scikhK+ppZ9Yc9LD/9Ry5P7H0a EzIIrju/U8ZdY1pWQm+Xl+CQBuTvoY/9M9WzAUDSwoQXdlq67OlZ7RDlwdyxaHbd Ng2h9w+BAtnv8SjAiRzY8v6h2NoWMwQDlU3aUksq/6ftszCWpDPn2K+mOEpybULI 9T8/w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdefledthecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghr rdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 15 Sep 2025 19:47:57 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 5/6] firewire: core: use spin lock specific to timer for split transaction Date: Tue, 16 Sep 2025 08:47:46 +0900 Message-ID: <20250915234747.915922-6-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250915234747.915922-1-o-takashi@sakamocchi.jp> References: <20250915234747.915922-1-o-takashi@sakamocchi.jp> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" At present the parameters to compute timeout time for split transaction is protected by card-wide spin lock, while it is not necessarily convenient in a point to narrower critical section. This commit adds and uses another spin lock specific for the purpose. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 10 +++-- drivers/firewire/core-transaction.c | 63 +++++++++++++++++++---------- include/linux/firewire.h | 15 ++++--- 3 files changed, 57 insertions(+), 31 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index 39f95007305f..96495392a1f6 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -550,10 +550,12 @@ void fw_card_initialize(struct fw_card *card, INIT_LIST_HEAD(&card->transactions.list); spin_lock_init(&card->transactions.lock); =20 - card->split_timeout_hi =3D DEFAULT_SPLIT_TIMEOUT / 8000; - card->split_timeout_lo =3D (DEFAULT_SPLIT_TIMEOUT % 8000) << 19; - card->split_timeout_cycles =3D DEFAULT_SPLIT_TIMEOUT; - card->split_timeout_jiffies =3D isoc_cycles_to_jiffies(DEFAULT_SPLIT_TIME= OUT); + card->split_timeout.hi =3D DEFAULT_SPLIT_TIMEOUT / 8000; + card->split_timeout.lo =3D (DEFAULT_SPLIT_TIMEOUT % 8000) << 19; + card->split_timeout.cycles =3D DEFAULT_SPLIT_TIMEOUT; + card->split_timeout.jiffies =3D isoc_cycles_to_jiffies(DEFAULT_SPLIT_TIME= OUT); + spin_lock_init(&card->split_timeout.lock); + card->color =3D 0; card->broadcast_channel =3D BROADCAST_CHANNEL_INITIAL; =20 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-tr= ansaction.c index 5366d8a781ac..dd3656a0c1ff 100644 --- a/drivers/firewire/core-transaction.c +++ b/drivers/firewire/core-transaction.c @@ -137,14 +137,18 @@ static void split_transaction_timeout_callback(struct= timer_list *timer) static void start_split_transaction_timeout(struct fw_transaction *t, struct fw_card *card) { - guard(spinlock_irqsave)(&card->lock); + unsigned long delta; =20 if (list_empty(&t->link) || WARN_ON(t->is_split_transaction)) return; =20 t->is_split_transaction =3D true; - mod_timer(&t->split_timeout_timer, - jiffies + card->split_timeout_jiffies); + + // 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->split_timeout.lock) + delta =3D card->split_timeout.jiffies; + mod_timer(&t->split_timeout_timer, jiffies + delta); } =20 static u32 compute_split_timeout_timestamp(struct fw_card *card, u32 reque= st_timestamp); @@ -164,8 +168,12 @@ static void transmit_complete_callback(struct fw_packe= t *packet, break; case ACK_PENDING: { - t->split_timeout_cycle =3D - compute_split_timeout_timestamp(card, packet->timestamp) & 0xffff; + // NOTE: This can be without irqsave when we can guarantee that __fw_sen= d_request() for + // local destination never runs in any type of IRQ context. + scoped_guard(spinlock_irqsave, &card->split_timeout.lock) { + t->split_timeout_cycle =3D + compute_split_timeout_timestamp(card, packet->timestamp) & 0xffff; + } start_split_transaction_timeout(t, card); break; } @@ -790,11 +798,14 @@ EXPORT_SYMBOL(fw_fill_response); =20 static u32 compute_split_timeout_timestamp(struct fw_card *card, u32 request_timestamp) +__must_hold(&card->split_timeout.lock) { unsigned int cycles; u32 timestamp; =20 - cycles =3D card->split_timeout_cycles; + lockdep_assert_held(&card->split_timeout.lock); + + cycles =3D card->split_timeout.cycles; cycles +=3D request_timestamp & 0x1fff; =20 timestamp =3D request_timestamp & ~0x1fff; @@ -845,9 +856,12 @@ static struct fw_request *allocate_request(struct fw_c= ard *card, return NULL; kref_init(&request->kref); =20 + // 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->split_timeout.lock) + request->response.timestamp =3D compute_split_timeout_timestamp(card, p-= >timestamp); + request->response.speed =3D p->speed; - request->response.timestamp =3D - compute_split_timeout_timestamp(card, p->timestamp); request->response.generation =3D p->generation; request->response.ack =3D 0; request->response.callback =3D free_response_callback; @@ -1228,16 +1242,17 @@ static const struct fw_address_region registers_reg= ion =3D .end =3D CSR_REGISTER_BASE | CSR_CONFIG_ROM, }; =20 static void update_split_timeout(struct fw_card *card) +__must_hold(&card->split_timeout.lock) { unsigned int cycles; =20 - cycles =3D card->split_timeout_hi * 8000 + (card->split_timeout_lo >> 19); + cycles =3D card->split_timeout.hi * 8000 + (card->split_timeout.lo >> 19); =20 /* minimum per IEEE 1394, maximum which doesn't overflow OHCI */ cycles =3D clamp(cycles, 800u, 3u * 8000u); =20 - card->split_timeout_cycles =3D cycles; - card->split_timeout_jiffies =3D isoc_cycles_to_jiffies(cycles); + card->split_timeout.cycles =3D cycles; + card->split_timeout.jiffies =3D isoc_cycles_to_jiffies(cycles); } =20 static void handle_registers(struct fw_card *card, struct fw_request *requ= est, @@ -1287,12 +1302,15 @@ static void handle_registers(struct fw_card *card, = struct fw_request *request, =20 case CSR_SPLIT_TIMEOUT_HI: if (tcode =3D=3D TCODE_READ_QUADLET_REQUEST) { - *data =3D cpu_to_be32(card->split_timeout_hi); + *data =3D cpu_to_be32(card->split_timeout.hi); } else if (tcode =3D=3D TCODE_WRITE_QUADLET_REQUEST) { - guard(spinlock_irqsave)(&card->lock); - - card->split_timeout_hi =3D be32_to_cpu(*data) & 7; - update_split_timeout(card); + // 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->split_timeout.lock) { + card->split_timeout.hi =3D be32_to_cpu(*data) & 7; + update_split_timeout(card); + } } else { rcode =3D RCODE_TYPE_ERROR; } @@ -1300,12 +1318,15 @@ static void handle_registers(struct fw_card *card, = struct fw_request *request, =20 case CSR_SPLIT_TIMEOUT_LO: if (tcode =3D=3D TCODE_READ_QUADLET_REQUEST) { - *data =3D cpu_to_be32(card->split_timeout_lo); + *data =3D cpu_to_be32(card->split_timeout.lo); } else if (tcode =3D=3D TCODE_WRITE_QUADLET_REQUEST) { - guard(spinlock_irqsave)(&card->lock); - - card->split_timeout_lo =3D be32_to_cpu(*data) & 0xfff80000; - update_split_timeout(card); + // 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->split_timeout.lock) { + card->split_timeout.lo =3D be32_to_cpu(*data) & 0xfff80000; + update_split_timeout(card); + } } else { rcode =3D RCODE_TYPE_ERROR; } diff --git a/include/linux/firewire.h b/include/linux/firewire.h index 8d6801cf2fca..6d208769d456 100644 --- a/include/linux/firewire.h +++ b/include/linux/firewire.h @@ -97,18 +97,21 @@ struct fw_card { spinlock_t lock; } transactions; =20 - u32 split_timeout_hi; - u32 split_timeout_lo; - unsigned int split_timeout_cycles; - unsigned int split_timeout_jiffies; + struct { + u32 hi; + u32 lo; + unsigned int cycles; + unsigned int jiffies; + spinlock_t lock; + } split_timeout; =20 unsigned long long guid; unsigned max_receive; int link_speed; int config_rom_generation; =20 - spinlock_t lock; /* Take this lock when handling the lists in - * this struct. */ + spinlock_t lock; + struct fw_node *local_node; struct fw_node *root_node; struct fw_node *irm_node; --=20 2.48.1 From nobody Thu Oct 2 14:27:54 2025 Received: from fout-b5-smtp.messagingengine.com (fout-b5-smtp.messagingengine.com [202.12.124.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2FA32D7DC3 for ; Mon, 15 Sep 2025 23:48:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.148 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757980084; cv=none; b=N0dfgoRPPUPguSG4+zpWTwmFRU0qzaqeCz1trehvLKOQb6sSRfY1TcDB4BEYqj8DtvJbeaYCHLSk1xmjGXI/0wF0u8SdRXMq70ZqK0H3Nekokf3Tvtta7Eux5r8DLsnNm1+vms2Kh6awsFRuPm42PsHwum8y7tFAS4d+AhSQtug= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757980084; c=relaxed/simple; bh=poh/xEaqp/7aH7FXA6r+ZHKUolObNr3GkBGAeyRaZ/c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TeGlGwjppLoHqY/JTUJAx1GzcBJhYotiO2Do5xiE7jr22Q27HytyV9d0eWvbBBz7KFwcA9DMLcsQ9/WJZb1pd+QLJpC7NNFV9bU8VUcoug3bdgLxh0GYvIMV/HHL9EduWMNPssviQiMsrKZd98c/8K31Uw70kU2OseFisDBdamo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp; spf=pass smtp.mailfrom=sakamocchi.jp; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b=m9dVGK8e; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=OEQlB0SB; arc=none smtp.client-ip=202.12.124.148 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="m9dVGK8e"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="OEQlB0SB" Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfout.stl.internal (Postfix) with ESMTP id C2DD51D001B8; Mon, 15 Sep 2025 19:48:00 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Mon, 15 Sep 2025 19:48:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1757980080; x= 1758066480; bh=T6wMwxzSvaxXpw+n82w5s56jqEc3YNWXuoN96hl1MF0=; b=m 9dVGK8ekC3Nujd+QOrvppfpz/FZdaGPnQot4/Bmr9Qt+Qs/hDBSRkaiL/PEY2PxU kKKlf2cO+9TsIEFJD6UBJDNnmpVOnszmOnRtErelhZeXOoCTfq55v2a5hukoVEg1 oCKdUtTECB68Gs7HoYzdl69q1e4STKraTphlRuRijEAwx0UaIzAHC4bzUuqhn1t5 vq/USK50ATUuQLnTdXo8fG0xdxaC2hHq5jnqG1UCmUb7wFQ8S6TH8QLRToob2En1 adL/xDQn7qw0dW+l1c+qBesXTQ+j/d2j6YPNnEA9qEorwKeS3Ix8Mp11jmlOM1Hx kxM+d/MQ3KbWFPoY72VXw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1757980080; x=1758066480; bh=T 6wMwxzSvaxXpw+n82w5s56jqEc3YNWXuoN96hl1MF0=; b=OEQlB0SBkyRuYWt3Z cq9FX6PeP2nNlOVDwlACCVi+3dYEDF2upVDzreB6xc1mnbr/4uEQCtwQ/Danlr6s Frc+PV6Sugf+86txMxnsvb2dtseH2iroSyUpwV7BHNZOTe2zltmU51ufu2KwX77z IDjmgkGVyMqWfzLkzlGHqTxta3Sp0n0PouL4pVlzvUm++MVUZv0RifpoKv1B+84M PW5eKSYmqk35/ghipAL0cZMQ/tW/0T2vaboNopQ1jHbXYqFiaQv9qVVh1gV+jh+l MqcDoo+0oV6o0W3geWEagPHGw5BXf+1cVOycjaX/FV3NxDzlGv/7f5DYsiQvxzOT 8jTog== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdefledthecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghr rdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 15 Sep 2025 19:47:59 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 6/6] firewire: core: annotate fw_destroy_nodes with must-hold-lock Date: Tue, 16 Sep 2025 08:47:47 +0900 Message-ID: <20250915234747.915922-7-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250915234747.915922-1-o-takashi@sakamocchi.jp> References: <20250915234747.915922-1-o-takashi@sakamocchi.jp> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The function, fw_destroy_nodes(), is used widely within firewire-core module. It has a prerequisite condition that struct fw_card.lock must be hold in advance. This commit adds annotation for it. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-topology.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/firewire/core-topology.c b/drivers/firewire/core-topol= ogy.c index c62cf93f3f65..8fa0772ee723 100644 --- a/drivers/firewire/core-topology.c +++ b/drivers/firewire/core-topology.c @@ -325,9 +325,11 @@ static void report_found_node(struct fw_card *card, card->bm_retries =3D 0; } =20 -/* Must be called with card->lock held */ void fw_destroy_nodes(struct fw_card *card) +__must_hold(&card->lock) { + lockdep_assert_held(&card->lock); + card->color++; if (card->local_node !=3D NULL) for_each_fw_node(card, card->local_node, report_lost_node); --=20 2.48.1