From nobody Thu Oct 2 07:49:13 2025 Received: from fout-b1-smtp.messagingengine.com (fout-b1-smtp.messagingengine.com [202.12.124.144]) (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 7CE0D20C488 for ; Thu, 18 Sep 2025 23:54:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758239696; cv=none; b=uds7NSGyG4dahnkz5AXYVYsYV0mB9SWGc1ghQSRn44q+hlzwwka7km8MgL7Cgw2SGhHQsfTgc1KTT4xZzLSRKzIc6AuOq/9ioNYXNS5/nvVoNAfPCfINCx/E/VI9N4BlDKc2FwdUmHwEY0py7fk5sU5OWRCFuWN5XWs8AfcLM0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758239696; c=relaxed/simple; bh=SaMhrXY4ROVt7GFlmLm/qxTHJtT+uMbdM59hXVeaRIA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OXD2s591301vWry6NfDSAXW+z8VY7dvUSN6Ck0cFXS7I2ZoW2stSTJ5QPXwEqHkAt8Zg5kJ/rBvM4cFkkjyPjCd5BXRna5ebWLrsonM8KBDXAJ//rzqS/hp/V9PsHp0OXmwonXKj/KKStBG+6Nhkph6SmJKRps8HUtnbd5R7Www= 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=c38uZGiB; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=B37X+xSf; arc=none smtp.client-ip=202.12.124.144 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="c38uZGiB"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="B37X+xSf" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.stl.internal (Postfix) with ESMTP id 8B8EA1D0028E; Thu, 18 Sep 2025 19:54:53 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Thu, 18 Sep 2025 19:54:53 -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=1758239693; x= 1758326093; bh=ejd4z6Y74LQMHrIhXYwar2zF5r9qzO6yTwePlxELzOg=; b=c 38uZGiBuk9pBkBw+iaAnut3EnYTKzdvVVb3R/OcQOckbqcphKU/xGyk9a8pnKkkI S/OgPJpfN2Lrf2AO0jH80hati/Fv9ZnX79uWirpeHM/UO1OA/jdKpxv4jtXEgTDO tdNyO9qXjSh42XTBrE5kLK+lPf3mSf8VoJZC08AgjdS9YjSgQ5KdFLwT5kNknFhg GWlVQhxLbvCBuAt4iLYoaiDTSWSXFfzqXBB9s2szSEcw7IOWLV5U8QgzRKI5KT2t kBxcTc7gFK0Kq3yq1ZO8RouXj4ghpuFViG13MG9ITqDIV2k9BTToRYmQL/fKqP8q RwLCYnV4VEEUtOr0r54jQ== 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=1758239693; x=1758326093; bh=e jd4z6Y74LQMHrIhXYwar2zF5r9qzO6yTwePlxELzOg=; b=B37X+xSf/fCZHX8Yu ZKNFow/EfEiZgXng1bJaRC8zg8enbQkoJtjbdg3GOpZ2IPshgiQ967QhqWvf+zXA TkAPoqqVb7jDBLLn1MsZcdzaTuljNefjsrj3CrKHLPB1Pgd7JJBwNy+OgLql79UL Hd1diPewM4sOTOJN7yi/U8DINeoAsv0ORQUd0CRNYZa5RG3OrXSf3gTgwM6BY7k3 MwM3Bfw4Nwm5hEHXucLtoHGv4nrSuQMoNsgUAZKltdvydEYkELmn0ldzyNT0qa3I 3YENndllSCHZ9EXYmQ/emHdMuGtfT9GBwhYBrNC91bg6/D8vtksa/z2uJjg6Rzdv OMo6g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdegjeejtdcutefuodetggdotefrod 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; Thu, 18 Sep 2025 19:54:52 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2 1/6] firewire: core: remove useless generation check Date: Fri, 19 Sep 2025 08:54:43 +0900 Message-ID: <20250918235448.129705-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250918230857.127400-1-o-takashi@sakamocchi.jp> References: <20250918230857.127400-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" Two functions, fw_core_handle_bus_reset() and bm_work(), are serialized by a commit 3d91fd440cc7 ("firewire: core: disable bus management work temporarily during updating topology"). Therefore the generation member of fw_card is immutable in bm_work(). This commit removes useless generation check in bm_work(). Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index 4fcd5ce4b2ce..ef00125fb01a 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -362,14 +362,12 @@ static void bm_work(struct work_struct *work) if (rcode =3D=3D RCODE_COMPLETE) { int bm_id =3D be32_to_cpu(data[0]); =20 - if (generation =3D=3D card->generation) { - // Used by cdev layer for "struct fw_cdev_event_bus_reset". - scoped_guard(spinlock, &card->lock) { - if (bm_id !=3D BUS_MANAGER_ID_NOT_REGISTERED) - card->bm_node_id =3D 0xffc0 & bm_id; - else - card->bm_node_id =3D local_id; - } + // Used by cdev layer for "struct fw_cdev_event_bus_reset". + scoped_guard(spinlock, &card->lock) { + if (bm_id !=3D BUS_MANAGER_ID_NOT_REGISTERED) + card->bm_node_id =3D 0xffc0 & bm_id; + else + card->bm_node_id =3D local_id; } =20 if (bm_id !=3D BUS_MANAGER_ID_NOT_REGISTERED) { --=20 2.48.1 From nobody Thu Oct 2 07:49:13 2025 Received: from fhigh-b1-smtp.messagingengine.com (fhigh-b1-smtp.messagingengine.com [202.12.124.152]) (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 895F628488F for ; Thu, 18 Sep 2025 23:09:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.152 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758236947; cv=none; b=YD6e8hKKYYF1rMf/FUWA7UAESvm73rNggspGtUkI8gL5XwIcUSXRB1XWyF/pOr2rBsv8PRR11tWrf/pozN0R7Kmj/HqBRQg6XydAbkbqEGV0uWEwyEMuw4quEbhqootTtUEbgepl0GG9uP7OUGyI8OtWlgYU1UYui9EpeKGNlDU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758236947; c=relaxed/simple; bh=SaMhrXY4ROVt7GFlmLm/qxTHJtT+uMbdM59hXVeaRIA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=esdEuWBHwS8xDZk/JpMQ1LC8fuWDrAkBNCkOOBFNmkEY1clL40/OKLKnvTxkmdTVxjHuBB4ByagGIwVVaV0kf2m6zcVsUiFiZHgchAw4XBvKpE+j28XKcac8Z77eHCcMF33hMjfxR0rJCBlZYF258nxeDVr+f9OSeyLvTn7dFFw= 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=DSKoN2Xm; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=CrIA6jhC; arc=none smtp.client-ip=202.12.124.152 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="DSKoN2Xm"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="CrIA6jhC" Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfhigh.stl.internal (Postfix) with ESMTP id 911667A02F8; Thu, 18 Sep 2025 19:09:04 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Thu, 18 Sep 2025 19:09:04 -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=1758236944; x= 1758323344; bh=ejd4z6Y74LQMHrIhXYwar2zF5r9qzO6yTwePlxELzOg=; b=D SKoN2XmwFgtTRw/nPdlG+86H3qTbMSbZq6VyTy9VRjFpCCMK5CkQE7SFCYybtaJP RrSvdC7uxk0pcApCdaqTiX6OnlG9XppAhHBByJAfGTenws8T0vMr85pdrjL4TeT+ j4/OBP23gDmjslAbePQSwDUfXwSQLsEmn+uZvO8/jU1ivllERKwAiOFoUECwtMeB vzaneqPpw8sFQQRP32+p7Qr8z0uO1ED+UVC0xlbYiyDXR51aYVAAmWWk0FBissLr Op9lGsM8QIF1e/3VySlKafL+qfznWetj3UFxA104ZIaKvB3dblyWZiG8edBF+ULA Hr9faY52EwYM3aSb3rZiw== 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=1758236944; x=1758323344; bh=e jd4z6Y74LQMHrIhXYwar2zF5r9qzO6yTwePlxELzOg=; b=CrIA6jhCsY/BxMck5 ZPXroNW9UiQjAAPmfem7Sb6nUt5Kck+biSMOV62cggUrn/YNF9qom3jjeyTXGTIN hNad82VeJ/W2VZ/WxsXMYz/VlDeKow4kXU8EFp2Nz4SuxhT8WtcAeEtElFxu5gG9 X/YLgm+Klxw/FI5zZLq3SfcY5w7k5JVTyjaai4Eg8tBbZF3atlfPi8V6xzenhpbs xSRhrDY3ZmjW8OI79YMpx+SZQAEo31BeG0GYd+L4+48792Qziv49AVo+a5yR9DT9 OnmkPttLufBr542gac5hYPGoxIuAIwpjg2k2OR+6EIkqw41QZwYRZt4vB8684DiW 0vD+Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdegjeeiudcutefuodetggdotefrod 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; Thu, 18 Sep 2025 19:09:03 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 1/6] firewire: core: remove useless generation check Date: Fri, 19 Sep 2025 08:08:52 +0900 Message-ID: <20250918230857.127400-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250918230857.127400-1-o-takashi@sakamocchi.jp> References: <20250918230857.127400-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" Two functions, fw_core_handle_bus_reset() and bm_work(), are serialized by a commit 3d91fd440cc7 ("firewire: core: disable bus management work temporarily during updating topology"). Therefore the generation member of fw_card is immutable in bm_work(). This commit removes useless generation check in bm_work(). Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index 4fcd5ce4b2ce..ef00125fb01a 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -362,14 +362,12 @@ static void bm_work(struct work_struct *work) if (rcode =3D=3D RCODE_COMPLETE) { int bm_id =3D be32_to_cpu(data[0]); =20 - if (generation =3D=3D card->generation) { - // Used by cdev layer for "struct fw_cdev_event_bus_reset". - scoped_guard(spinlock, &card->lock) { - if (bm_id !=3D BUS_MANAGER_ID_NOT_REGISTERED) - card->bm_node_id =3D 0xffc0 & bm_id; - else - card->bm_node_id =3D local_id; - } + // Used by cdev layer for "struct fw_cdev_event_bus_reset". + scoped_guard(spinlock, &card->lock) { + if (bm_id !=3D BUS_MANAGER_ID_NOT_REGISTERED) + card->bm_node_id =3D 0xffc0 & bm_id; + else + card->bm_node_id =3D local_id; } =20 if (bm_id !=3D BUS_MANAGER_ID_NOT_REGISTERED) { --=20 2.48.1 From nobody Thu Oct 2 07:49:13 2025 Received: from fhigh-b2-smtp.messagingengine.com (fhigh-b2-smtp.messagingengine.com [202.12.124.153]) (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 29E4127D782 for ; Thu, 18 Sep 2025 23:54:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758239698; cv=none; b=FLK4OWfS0Gby8qoe4KDsVAh703LWqmbqnf6gwiJvH9jucl4w99lACK+i12+Alj/F0ig/Waq1ogPZcph6x/jB4TwSLWmtrDaUnm8omrvC6RcZftj6LW7QvAJznyavtO0crMzzvG8g+YYGl0HLg9aduO6R5jwIw1AHInWHa+x0pMc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758239698; c=relaxed/simple; bh=UMMxmPgQwssZS4e1o+79eVN0EoB4UA7jX6vcpvX8PL0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U7tBFKgaBVdp+/8Tywg0TmsgoMbwwO4wpfXhdG/IHrVRssakLxlGvzEW33KbbqX0SrVho6Y6N1GbQShzqTr+Zm/dSiAZXvUGuL9/LvBjGx64aebRszRlQrO0ySRDVJ28BNhJ1YeGDFJuO+76aDsyl+qrGz2VLZ6y4sbwLbLQeKo= 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=mtIq3rrA; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=RDVoz+Vj; arc=none smtp.client-ip=202.12.124.153 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="mtIq3rrA"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="RDVoz+Vj" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.stl.internal (Postfix) with ESMTP id 37A357A02DF; Thu, 18 Sep 2025 19:54:55 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Thu, 18 Sep 2025 19:54:55 -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=1758239695; x= 1758326095; bh=1bhCuPFgP4C1oxsw4LyiUdUqGNWaw/azPwPIYtQV6D8=; b=m tIq3rrAQrUx7B9fdBE/FbgrXer2ML5Hsti69lgaME/GvkWdbJl5hXsCs7f1gCMmB bEJ7uDwka/r/QcMNWwfgOoXDMCdfIcm1O+6Qyp0adxqy/2+ush1fbeVtd9RO9MDh 2NpgJwVfD7+ZsLAT872tuXhXnevw8p9cdjZwqD9FzwasHdhAo9XGawtmT7JMKIDZ x9/23Dw5CPMyPfRd8vahYRUyUeEtGIgHFNSyZzyTS6zSLbU5nru9PG+/A2ws/Q2c 8zqpEGkXVgJ8yXfoq4N5BCGPY4zGbrTxsSYHiBzABRechUAamYvwVVSVPiRhNPsK qq4iAJt65OerqAj1OalFA== 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=1758239695; x=1758326095; bh=1 bhCuPFgP4C1oxsw4LyiUdUqGNWaw/azPwPIYtQV6D8=; b=RDVoz+VjfUVYE4QBV A8l3t3HvMC1GT7+r9u91DXdN5r2MZqHE2y1lJLg3DfKENkpE4CbWSnOU5Dc5OLuM LF7NPJaGUqNFLYONBN4dYS6SQQQZ1zVptLJ5EjXZDqmPC/Fh4iPueh6Xe+elR4h1 hDIsf8eLu4J9DkLQwReSY96DTm+AVV8yTc5OwPhREajmoIMLDl0KPACiFzxqHLwF B41V0afJfwx30Cx85aQDIqMj4qZlqRexUqGSl5gl5p/g8sZ4VTJEETZBzxa9PC+j PrSVWUXTRWKqr5U/kd0V3rQSNqpW78YVu1pFtQ49s2wg40idKakKIarPWpKOuca6 2Vx7g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdegjeejtdcutefuodetggdotefrod 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; Thu, 18 Sep 2025 19:54:53 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2 2/6] firewire: core: use switch statement to evaluate transaction result to CSR_BUS_MANAGER_ID Date: Fri, 19 Sep 2025 08:54:44 +0900 Message-ID: <20250918235448.129705-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250918230857.127400-1-o-takashi@sakamocchi.jp> References: <20250918230857.127400-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 result of the lock transaction to swap bus manager on isochronous resource manager looks like an ad-hoc style. It is hard to read. This commit uses switch statement to evaluate the result. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 50 +++++++++++++++++------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index ef00125fb01a..e9bf8d93f5b7 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -355,11 +355,18 @@ static void bm_work(struct work_struct *work) CSR_REGISTER_BASE + CSR_BUS_MANAGER_ID, data, sizeof(data)); =20 - // Another bus reset, BM work has been rescheduled. - if (rcode =3D=3D RCODE_GENERATION) + switch (rcode) { + case RCODE_GENERATION: + // Another bus reset, BM work has been rescheduled. return; - - if (rcode =3D=3D RCODE_COMPLETE) { + case RCODE_SEND_ERROR: + // We have been unable to send the lock request due to + // some local problem. Let's try again later and hope + // that the problem has gone away by then. + fw_schedule_bm_work(card, msecs_to_jiffies(125)); + return; + case RCODE_COMPLETE: + { int bm_id =3D be32_to_cpu(data[0]); =20 // Used by cdev layer for "struct fw_cdev_event_bus_reset". @@ -376,29 +383,20 @@ static void bm_work(struct work_struct *work) allocate_broadcast_channel(card, generation); return; } + break; } - - if (rcode =3D=3D RCODE_SEND_ERROR) { - /* - * We have been unable to send the lock request due to - * some local problem. Let's try again later and hope - * that the problem has gone away by then. - */ - fw_schedule_bm_work(card, msecs_to_jiffies(125)); - return; - } - - if (rcode !=3D RCODE_COMPLETE && !keep_this_irm) { - /* - * The lock request failed, maybe the IRM - * isn't really IRM capable after all. Let's - * do a bus reset and pick the local node as - * root, and thus, IRM. - */ - new_root_id =3D local_id; - fw_notice(card, "BM lock failed (%s), making local node (%02x) root\n", - fw_rcode_string(rcode), new_root_id); - goto pick_me; + default: + if (!keep_this_irm) { + // The lock request failed, maybe the IRM + // isn't really IRM capable after all. Let's + // do a bus reset and pick the local node as + // root, and thus, IRM. + new_root_id =3D local_id; + fw_notice(card, "BM lock failed (%s), making local node (%02x) root\n", + fw_rcode_string(rcode), new_root_id); + goto pick_me; + } + break; } } else if (card->bm_generation !=3D generation) { /* --=20 2.48.1 From nobody Thu Oct 2 07:49:13 2025 Received: from fout-b1-smtp.messagingengine.com (fout-b1-smtp.messagingengine.com [202.12.124.144]) (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 17BF9285404 for ; Thu, 18 Sep 2025 23:09:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758236949; cv=none; b=L8CyUlvmmys1a+4VzT9bQsRsVWhFf29p+i0Mp2+A/5ia+nQL7Rvi9ueU3AEw8mYEHU+ZRcC87ovIo3xe91c5/vnEr/bA99oAWie4+BWdZU0vSyZFVPG5I13uH5iWqB5gmP9ph+VSYFBAlCwsSwAJp6M0TRApFTbK5NGetxOvebw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758236949; c=relaxed/simple; bh=UMMxmPgQwssZS4e1o+79eVN0EoB4UA7jX6vcpvX8PL0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sItLgrCu3CtiL2QIi2261TqIo8ZCfawZaR1an+bkL4a5SQnGgmV07YRdUF2ht1q7JtLDNyVjEqaQSdUcxp/teIPwC0OjalJMjTF3N/QwsMqLRV/nBYJtnB72gh1qPM3vMGALHxmDpr2ILEIq2Ow8Ti+SvlmmwNez0DxJIyaa/tQ= 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=fasvvCTm; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=mHRS8UTF; arc=none smtp.client-ip=202.12.124.144 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="fasvvCTm"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="mHRS8UTF" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.stl.internal (Postfix) with ESMTP id 1FDA41D002D6; Thu, 18 Sep 2025 19:09:06 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Thu, 18 Sep 2025 19:09:06 -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=1758236945; x= 1758323345; bh=1bhCuPFgP4C1oxsw4LyiUdUqGNWaw/azPwPIYtQV6D8=; b=f asvvCTm+9KHFmKMnoYAzin9td+QeKi2F4e8OGE8+B0xtLVsu0ESa4WRWoat9p+t/ OM+/4wWiYzqRMz2LmkmyPkRwqFSovtyyb19ox7TkWwHI9z656u3zjo+2bRPDjyhM 5MOXxk6nSsljh7WsI3UEOsXu5Wj8tbh5l4B6Oy4+DmiT5aTTKvuVdhunzZd0HdZK jMsG0kaqcI02v+oagi9VcUvYpz/W6BFhmaCLMi+5STOxnpZ/lNiS/bZVTkY6PmJT SbbQYqwmzhZ9jOjh0tfvVK78T2ejs8zP3qRQ/xZb5KDJhvDj0z8doqzp8LGBXfpz N4Rrez1QpTOa/7Nsde51Q== 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=1758236945; x=1758323345; bh=1 bhCuPFgP4C1oxsw4LyiUdUqGNWaw/azPwPIYtQV6D8=; b=mHRS8UTFbfP8EnZAo 9zuaaWrwB+iv9gYShO98xqAHyuhAOcCQ4a+2y2UGZpPdJpeU+8Kqe+0H4JBXqI0L 7OK6/LTrx9vmxrm++JcJmaJ60QdoiLoKAoWDGPYWn3TRZhSqiA1nlctvTZ2KGRod S8bkMfc2+kWhBM6efPK3yd2rDAkBxP4zjd2uFlmIQBuEQNRxK4Kyvu229HFDHtmT WS8dbWw9FdcWNxNkFuswSgrkN5WPmRSVo5+rFuXPtLPGr5SANaT/RoAtw8ONgI/Z 2v7tpwUUmGp4dITYi7S7nASd+6BOqN5L88be7pJGkLryZXQ+YkxRa8LkUsZiIwVN xCVMg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdegjeeiudcutefuodetggdotefrod 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; Thu, 18 Sep 2025 19:09:04 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 2/6] firewire: core: use switch statement to evaluate transaction result to CSR_BUS_MANAGER_ID Date: Fri, 19 Sep 2025 08:08:53 +0900 Message-ID: <20250918230857.127400-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250918230857.127400-1-o-takashi@sakamocchi.jp> References: <20250918230857.127400-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 result of the lock transaction to swap bus manager on isochronous resource manager looks like an ad-hoc style. It is hard to read. This commit uses switch statement to evaluate the result. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 50 +++++++++++++++++------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index ef00125fb01a..e9bf8d93f5b7 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -355,11 +355,18 @@ static void bm_work(struct work_struct *work) CSR_REGISTER_BASE + CSR_BUS_MANAGER_ID, data, sizeof(data)); =20 - // Another bus reset, BM work has been rescheduled. - if (rcode =3D=3D RCODE_GENERATION) + switch (rcode) { + case RCODE_GENERATION: + // Another bus reset, BM work has been rescheduled. return; - - if (rcode =3D=3D RCODE_COMPLETE) { + case RCODE_SEND_ERROR: + // We have been unable to send the lock request due to + // some local problem. Let's try again later and hope + // that the problem has gone away by then. + fw_schedule_bm_work(card, msecs_to_jiffies(125)); + return; + case RCODE_COMPLETE: + { int bm_id =3D be32_to_cpu(data[0]); =20 // Used by cdev layer for "struct fw_cdev_event_bus_reset". @@ -376,29 +383,20 @@ static void bm_work(struct work_struct *work) allocate_broadcast_channel(card, generation); return; } + break; } - - if (rcode =3D=3D RCODE_SEND_ERROR) { - /* - * We have been unable to send the lock request due to - * some local problem. Let's try again later and hope - * that the problem has gone away by then. - */ - fw_schedule_bm_work(card, msecs_to_jiffies(125)); - return; - } - - if (rcode !=3D RCODE_COMPLETE && !keep_this_irm) { - /* - * The lock request failed, maybe the IRM - * isn't really IRM capable after all. Let's - * do a bus reset and pick the local node as - * root, and thus, IRM. - */ - new_root_id =3D local_id; - fw_notice(card, "BM lock failed (%s), making local node (%02x) root\n", - fw_rcode_string(rcode), new_root_id); - goto pick_me; + default: + if (!keep_this_irm) { + // The lock request failed, maybe the IRM + // isn't really IRM capable after all. Let's + // do a bus reset and pick the local node as + // root, and thus, IRM. + new_root_id =3D local_id; + fw_notice(card, "BM lock failed (%s), making local node (%02x) root\n", + fw_rcode_string(rcode), new_root_id); + goto pick_me; + } + break; } } else if (card->bm_generation !=3D generation) { /* --=20 2.48.1 From nobody Thu Oct 2 07:49:13 2025 Received: from fhigh-b2-smtp.messagingengine.com (fhigh-b2-smtp.messagingengine.com [202.12.124.153]) (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 B9EF82D0C63 for ; Thu, 18 Sep 2025 23:54:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758239699; cv=none; b=UyyfK0F9uoUIUJHNodu9Iqdhx+s6J2v6CeDHaS1kOkuIQKFWQ5QvU71O67SJIBhK32YE/1NwLirgaoMxwwrAYvCcRN/ol18/4Lqvb1rkFn66CrkVnjoqb/Yy00o8q6qDi/RxKBVc8JZohZdHDXodrkBuCOy5+C+bV5UpxOBiu58= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758239699; c=relaxed/simple; bh=/PhBDFPm5QIB03v215EWrLH/3rZfVE+oUVn1KB+R0sg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l4+v5V9qXWNySK3wKbMpFK8i8aTQwikjtQfXOtArkMJD0wJwEozGBwEadDGoyGM4oWV0Y4aPW7dvGBirLgfkoj4G4sC3kKbr36qoGJtONEmTP6uvOc4748yl6BtNCRFG9RwY3C5xM5D6Ddr/qAf2XdOI7MslWpDJ575ZO+3nML0= 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=RcRmmUk1; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=g0wzDAh3; arc=none smtp.client-ip=202.12.124.153 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="RcRmmUk1"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="g0wzDAh3" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.stl.internal (Postfix) with ESMTP id C6B067A02F7; Thu, 18 Sep 2025 19:54:56 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Thu, 18 Sep 2025 19:54: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=1758239696; x= 1758326096; bh=01wtiLF2Oli5HjGiFiR6KWpbzIl+tdOyk62gIR53vS4=; b=R cRmmUk1NuF7IrfD5v6j8/246XNoCqqwL41T+QLulC9i1aUGqWEu4ccNXYDX/GGCK w/DBMRbIUEGxukdsG1ToVzj9waVwjbL9ckvFNVmAdKW/Vp5R9X12xiXJNruuDc5Y QvymhNIZxojaGAtiQAcnAAogxWh5tx+54i3fZUV8KoYL2JclqSFbNncqsuJs4C70 pl67l3UT24KyI7cWjkKKdRgOPMAysNtINBTko50bAyJLz8UGTvewfrIpGa8db/rZ wz4/3dvzRGNPwq06oiO2FWWcCMuoIgvXAZtfjLjjZ4yElrcW2xz4yCpriG9TxFMG 9JacFbZxrQ3qDeRdHMX9w== 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=1758239696; x=1758326096; bh=0 1wtiLF2Oli5HjGiFiR6KWpbzIl+tdOyk62gIR53vS4=; b=g0wzDAh3A9VkA8f+N 85gIllPmXsLACl/xceihPqAAKxeieqpFTFfXLZ1qArQrxrRtyA0tzqvBglRxfeb9 40R313Yq+OBe41J5MQOO213+nCBu96jpNbcS4uYX2LFfl1lXnHPuXRjGfdw1f9KN FV8KbOogAMmazSvfhfraWWd6TGnKCcTGWOHHnVLBW5lZx96dc6guGTEmuflQkx3b hYAqcpYhr46t1Khpk7csA8attkPUJR1V8q3aFN4e5qfDCsp2TGvEKc/ahBSXaaAf 8dPYX63WLQ20gIRbmXLnw7ANvow9VJ0mlf9z9V5VXBgvTt69KwbCgOlp9JHKS2od WYeSw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdegjeejtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghr rdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 18 Sep 2025 19:54:55 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2 3/6] firewire: core: code refactoring for the case of generation mismatch Date: Fri, 19 Sep 2025 08:54:45 +0900 Message-ID: <20250918235448.129705-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250918230857.127400-1-o-takashi@sakamocchi.jp> References: <20250918230857.127400-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" Current implementation stores the bus generation at which the bus manager contending procedure finishes. The condition for the procedure is the mismatch of the stored generation against current bus generation. This commit refactors the code for the contending procedure. Two existing branches are put into a new branch to detect the generation mismatch, thus the most of change is indentation. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 188 +++++++++++++++++------------------ 1 file changed, 93 insertions(+), 95 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index e9bf8d93f5b7..02058af705cc 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -290,7 +290,7 @@ static void bm_work(struct work_struct *work) struct fw_card *card __free(card_unref) =3D from_work(card, work, bm_work= .work); struct fw_node *root_node __free(node_unref) =3D NULL; int root_id, new_root_id, irm_id, local_id; - int expected_gap_count, generation, grace; + int expected_gap_count, generation; bool do_reset =3D false; =20 if (card->local_node =3D=3D NULL) @@ -304,107 +304,107 @@ static void bm_work(struct work_struct *work) irm_id =3D card->irm_node->node_id; local_id =3D card->local_node->node_id; =20 - grace =3D time_is_before_jiffies64(card->reset_jiffies + msecs_to_jiffies= (125)); - - if ((is_next_generation(generation, card->bm_generation) && - !card->bm_abdicate) || - (card->bm_generation !=3D generation && grace)) { - /* - * This first step is to figure out who is IRM and - * then try to become bus manager. If the IRM is not - * well defined (e.g. does not have an active link - * layer or does not responds to our lock request, we - * will have to do a little vigilante bus management. - * In that case, we do a goto into the gap count logic - * so that when we do the reset, we still optimize the - * gap count. That could well save a reset in the - * next generation. - */ - __be32 data[2] =3D { - cpu_to_be32(BUS_MANAGER_ID_NOT_REGISTERED), - cpu_to_be32(local_id), - }; - struct fw_device *irm_device =3D fw_node_get_device(card->irm_node); - bool irm_is_1394_1995_only =3D false; - bool keep_this_irm =3D false; - int rcode; - - if (!card->irm_node->link_on) { - new_root_id =3D local_id; - fw_notice(card, "%s, making local node (%02x) root\n", - "IRM has link off", new_root_id); - goto pick_me; - } - - if (irm_device && irm_device->config_rom) { - irm_is_1394_1995_only =3D (irm_device->config_rom[2] & 0x000000f0) =3D= =3D 0; - - // Canon MV5i works unreliably if it is not root node. - keep_this_irm =3D irm_device->config_rom[3] >> 8 =3D=3D CANON_OUI; - } + if (card->bm_generation !=3D generation) { + bool grace =3D time_is_before_jiffies64(card->reset_jiffies + msecs_to_j= iffies(125)); + + if (grace || + (is_next_generation(generation, card->bm_generation) && !card->bm_ab= dicate)) { + // This first step is to figure out who is IRM and + // then try to become bus manager. If the IRM is not + // well defined (e.g. does not have an active link + // layer or does not responds to our lock request, we + // will have to do a little vigilante bus management. + // In that case, we do a goto into the gap count logic + // so that when we do the reset, we still optimize the + // gap count. That could well save a reset in the + // next generation. + __be32 data[2] =3D { + cpu_to_be32(BUS_MANAGER_ID_NOT_REGISTERED), + cpu_to_be32(local_id), + }; + struct fw_device *irm_device =3D fw_node_get_device(card->irm_node); + bool irm_is_1394_1995_only =3D false; + bool keep_this_irm =3D false; + int rcode; + + if (!card->irm_node->link_on) { + new_root_id =3D local_id; + fw_notice(card, "%s, making local node (%02x) root\n", + "IRM has link off", new_root_id); + goto pick_me; + } =20 - if (irm_is_1394_1995_only && !keep_this_irm) { - new_root_id =3D local_id; - fw_notice(card, "%s, making local node (%02x) root\n", - "IRM is not 1394a compliant", new_root_id); - goto pick_me; - } + if (irm_device && irm_device->config_rom) { + irm_is_1394_1995_only =3D (irm_device->config_rom[2] & 0x000000f0) =3D= =3D 0; =20 - rcode =3D fw_run_transaction(card, TCODE_LOCK_COMPARE_SWAP, - irm_id, generation, SCODE_100, - CSR_REGISTER_BASE + CSR_BUS_MANAGER_ID, - data, sizeof(data)); + // Canon MV5i works unreliably if it is not root node. + keep_this_irm =3D irm_device->config_rom[3] >> 8 =3D=3D CANON_OUI; + } =20 - switch (rcode) { - case RCODE_GENERATION: - // Another bus reset, BM work has been rescheduled. - return; - case RCODE_SEND_ERROR: - // We have been unable to send the lock request due to - // some local problem. Let's try again later and hope - // that the problem has gone away by then. - fw_schedule_bm_work(card, msecs_to_jiffies(125)); - return; - case RCODE_COMPLETE: - { - int bm_id =3D be32_to_cpu(data[0]); - - // Used by cdev layer for "struct fw_cdev_event_bus_reset". - scoped_guard(spinlock, &card->lock) { - if (bm_id !=3D BUS_MANAGER_ID_NOT_REGISTERED) - card->bm_node_id =3D 0xffc0 & bm_id; - else - card->bm_node_id =3D local_id; + if (irm_is_1394_1995_only && !keep_this_irm) { + new_root_id =3D local_id; + fw_notice(card, "%s, making local node (%02x) root\n", + "IRM is not 1394a compliant", new_root_id); + goto pick_me; } =20 - if (bm_id !=3D BUS_MANAGER_ID_NOT_REGISTERED) { - // Somebody else is BM. Only act as IRM. - if (local_id =3D=3D irm_id) - allocate_broadcast_channel(card, generation); + rcode =3D fw_run_transaction(card, TCODE_LOCK_COMPARE_SWAP, + irm_id, generation, SCODE_100, + CSR_REGISTER_BASE + CSR_BUS_MANAGER_ID, + data, sizeof(data)); + + switch (rcode) { + case RCODE_GENERATION: + // Another bus reset, BM work has been rescheduled. return; + case RCODE_SEND_ERROR: + // We have been unable to send the lock request due to + // some local problem. Let's try again later and hope + // that the problem has gone away by then. + fw_schedule_bm_work(card, msecs_to_jiffies(125)); + return; + case RCODE_COMPLETE: + { + int bm_id =3D be32_to_cpu(data[0]); + + // Used by cdev layer for "struct fw_cdev_event_bus_reset". + scoped_guard(spinlock, &card->lock) { + if (bm_id !=3D BUS_MANAGER_ID_NOT_REGISTERED) + card->bm_node_id =3D 0xffc0 & bm_id; + else + card->bm_node_id =3D local_id; + } + + if (bm_id !=3D BUS_MANAGER_ID_NOT_REGISTERED) { + // Somebody else is BM. Only act as IRM. + if (local_id =3D=3D irm_id) + allocate_broadcast_channel(card, generation); + return; + } + break; } - break; - } - default: - if (!keep_this_irm) { - // The lock request failed, maybe the IRM - // isn't really IRM capable after all. Let's - // do a bus reset and pick the local node as - // root, and thus, IRM. - new_root_id =3D local_id; - fw_notice(card, "BM lock failed (%s), making local node (%02x) root\n", - fw_rcode_string(rcode), new_root_id); - goto pick_me; + default: + if (!keep_this_irm) { + // The lock request failed, maybe the IRM + // isn't really IRM capable after all. Let's + // do a bus reset and pick the local node as + // root, and thus, IRM. + new_root_id =3D local_id; + fw_notice(card, "BM lock failed (%s), making local node (%02x) root\n= ", + fw_rcode_string(rcode), new_root_id); + goto pick_me; + } + break; } - break; + + // A node contends for bus manager in this generation. + card->bm_generation =3D generation; + } else { + // We weren't BM in the last generation, and the last + // bus reset is less than 125ms ago. Reschedule this job. + fw_schedule_bm_work(card, msecs_to_jiffies(125)); + return; } - } else if (card->bm_generation !=3D generation) { - /* - * We weren't BM in the last generation, and the last - * bus reset is less than 125ms ago. Reschedule this job. - */ - fw_schedule_bm_work(card, msecs_to_jiffies(125)); - return; } =20 /* @@ -412,8 +412,6 @@ static void bm_work(struct work_struct *work) * make sure we have an active cycle master and do gap count * optimization. */ - card->bm_generation =3D generation; - if (card->gap_count =3D=3D GAP_COUNT_MISMATCHED) { /* * If self IDs have inconsistent gap counts, do a --=20 2.48.1 From nobody Thu Oct 2 07:49:13 2025 Received: from fout-b1-smtp.messagingengine.com (fout-b1-smtp.messagingengine.com [202.12.124.144]) (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 CA7C32EB868 for ; Thu, 18 Sep 2025 23:09:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758236951; cv=none; b=UAQ/+DD6mc3HtS1e0r1cN0x6vKAgqNqNmdqMMfdjILbHrZd+A1hTD4cScdkQW0zndb8tzeTr+I5N6onXVBbZLXcFmNjCmWUryIr2wck8FtuC14q2EZkpKRGELavOKxOdSnBr9aogKoA+/iAje9HjE3kpsonE9mF2dDnlhiHMUqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758236951; c=relaxed/simple; bh=/PhBDFPm5QIB03v215EWrLH/3rZfVE+oUVn1KB+R0sg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XnazEBNB/E3zKATxRa+qb07wVowBYtc35+BlP0X0bdq+JrQxTZMwKc9IvGm885uxWyP5OEp442s0rAKrhjByhYdK+jfYdUYzb9zZdhPJm/vBvU880J+mNmmH2xWFq8blIuK5nDrOoqexdbo0BBGsI5jFLdWpkBGpitiR2RMYXck= 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=Bwo9qiLZ; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=A2G+or9t; arc=none smtp.client-ip=202.12.124.144 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="Bwo9qiLZ"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="A2G+or9t" Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailfout.stl.internal (Postfix) with ESMTP id BB68D1D002E9; Thu, 18 Sep 2025 19:09:07 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Thu, 18 Sep 2025 19:09:07 -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=1758236947; x= 1758323347; bh=01wtiLF2Oli5HjGiFiR6KWpbzIl+tdOyk62gIR53vS4=; b=B wo9qiLZZxzkylcwlDeAwXThVQ5LG63aWr7wUZ0jxrduKmkEb6ngf4vDrEcsMAPEP 7S1jL4e6Hn4iYhPnT5CVQ0UTeiDRd+hHrfiP/LSwFAu2bj3PG+jISch0mTkpQ+N9 IluVw5PFJsj0ATIoWxV8Nw13F6w/kPzhNaLk5ZUyBhtvb6Ie3KJXoOQMihHG/jFu 4MlCRb6ExbyLK5FL71BVdC5id/rTMfyDu/G1xOlIUwjv7C8rgtFI+aw5BHa4th8U cBafgbatA9xNqJq+XMXgnYL9+O5jgx9VnW4lKRhKI1RDDVPNiP5pdBen/9Ns5hsJ giKfqfFZwtAagQZRQrblQ== 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=1758236947; x=1758323347; bh=0 1wtiLF2Oli5HjGiFiR6KWpbzIl+tdOyk62gIR53vS4=; b=A2G+or9tX+Xmw+aDg VtA9OceD5DHW/IQMqENax8fFsVdFNlr584nBJjwVLkEftNfQYYJ+PS2Q84DRNsr5 1Iox9RHVJas5fq1mHj6wGxq39hryAvOAd+X7xOQxPzUclNmYaW5kGcRccv9HvFrD i5C8yGaFqvGXz48AarEJXFyk7DGoyqWvzErP7CPzJqeVGqQNQ2vPtwawUXXPhvs4 o3N5OFawsx5mWSZ7UymXK4+tqtIiwM3Pcpdm6A+7OHy9va0Jw58etUMsZdSb/ADI g//Wp6x0zvG5MA4JtGdea9sisXRx2+ywO+ZnrRnwRJK+I4ik3M89LpuJfPfLPYTU Kj+7w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdegjeeiudcutefuodetggdotefrod 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; Thu, 18 Sep 2025 19:09:06 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 3/6] firewire: core: code refactoring for the case of generation mismatch Date: Fri, 19 Sep 2025 08:08:54 +0900 Message-ID: <20250918230857.127400-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250918230857.127400-1-o-takashi@sakamocchi.jp> References: <20250918230857.127400-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" Current implementation stores the bus generation at which the bus manager contending procedure finishes. The condition for the procedure is the mismatch of the stored generation against current bus generation. This commit refactors the code for the contending procedure. Two existing branches are put into a new branch to detect the generation mismatch, thus the most of change is indentation. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 188 +++++++++++++++++------------------ 1 file changed, 93 insertions(+), 95 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index e9bf8d93f5b7..02058af705cc 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -290,7 +290,7 @@ static void bm_work(struct work_struct *work) struct fw_card *card __free(card_unref) =3D from_work(card, work, bm_work= .work); struct fw_node *root_node __free(node_unref) =3D NULL; int root_id, new_root_id, irm_id, local_id; - int expected_gap_count, generation, grace; + int expected_gap_count, generation; bool do_reset =3D false; =20 if (card->local_node =3D=3D NULL) @@ -304,107 +304,107 @@ static void bm_work(struct work_struct *work) irm_id =3D card->irm_node->node_id; local_id =3D card->local_node->node_id; =20 - grace =3D time_is_before_jiffies64(card->reset_jiffies + msecs_to_jiffies= (125)); - - if ((is_next_generation(generation, card->bm_generation) && - !card->bm_abdicate) || - (card->bm_generation !=3D generation && grace)) { - /* - * This first step is to figure out who is IRM and - * then try to become bus manager. If the IRM is not - * well defined (e.g. does not have an active link - * layer or does not responds to our lock request, we - * will have to do a little vigilante bus management. - * In that case, we do a goto into the gap count logic - * so that when we do the reset, we still optimize the - * gap count. That could well save a reset in the - * next generation. - */ - __be32 data[2] =3D { - cpu_to_be32(BUS_MANAGER_ID_NOT_REGISTERED), - cpu_to_be32(local_id), - }; - struct fw_device *irm_device =3D fw_node_get_device(card->irm_node); - bool irm_is_1394_1995_only =3D false; - bool keep_this_irm =3D false; - int rcode; - - if (!card->irm_node->link_on) { - new_root_id =3D local_id; - fw_notice(card, "%s, making local node (%02x) root\n", - "IRM has link off", new_root_id); - goto pick_me; - } - - if (irm_device && irm_device->config_rom) { - irm_is_1394_1995_only =3D (irm_device->config_rom[2] & 0x000000f0) =3D= =3D 0; - - // Canon MV5i works unreliably if it is not root node. - keep_this_irm =3D irm_device->config_rom[3] >> 8 =3D=3D CANON_OUI; - } + if (card->bm_generation !=3D generation) { + bool grace =3D time_is_before_jiffies64(card->reset_jiffies + msecs_to_j= iffies(125)); + + if (grace || + (is_next_generation(generation, card->bm_generation) && !card->bm_ab= dicate)) { + // This first step is to figure out who is IRM and + // then try to become bus manager. If the IRM is not + // well defined (e.g. does not have an active link + // layer or does not responds to our lock request, we + // will have to do a little vigilante bus management. + // In that case, we do a goto into the gap count logic + // so that when we do the reset, we still optimize the + // gap count. That could well save a reset in the + // next generation. + __be32 data[2] =3D { + cpu_to_be32(BUS_MANAGER_ID_NOT_REGISTERED), + cpu_to_be32(local_id), + }; + struct fw_device *irm_device =3D fw_node_get_device(card->irm_node); + bool irm_is_1394_1995_only =3D false; + bool keep_this_irm =3D false; + int rcode; + + if (!card->irm_node->link_on) { + new_root_id =3D local_id; + fw_notice(card, "%s, making local node (%02x) root\n", + "IRM has link off", new_root_id); + goto pick_me; + } =20 - if (irm_is_1394_1995_only && !keep_this_irm) { - new_root_id =3D local_id; - fw_notice(card, "%s, making local node (%02x) root\n", - "IRM is not 1394a compliant", new_root_id); - goto pick_me; - } + if (irm_device && irm_device->config_rom) { + irm_is_1394_1995_only =3D (irm_device->config_rom[2] & 0x000000f0) =3D= =3D 0; =20 - rcode =3D fw_run_transaction(card, TCODE_LOCK_COMPARE_SWAP, - irm_id, generation, SCODE_100, - CSR_REGISTER_BASE + CSR_BUS_MANAGER_ID, - data, sizeof(data)); + // Canon MV5i works unreliably if it is not root node. + keep_this_irm =3D irm_device->config_rom[3] >> 8 =3D=3D CANON_OUI; + } =20 - switch (rcode) { - case RCODE_GENERATION: - // Another bus reset, BM work has been rescheduled. - return; - case RCODE_SEND_ERROR: - // We have been unable to send the lock request due to - // some local problem. Let's try again later and hope - // that the problem has gone away by then. - fw_schedule_bm_work(card, msecs_to_jiffies(125)); - return; - case RCODE_COMPLETE: - { - int bm_id =3D be32_to_cpu(data[0]); - - // Used by cdev layer for "struct fw_cdev_event_bus_reset". - scoped_guard(spinlock, &card->lock) { - if (bm_id !=3D BUS_MANAGER_ID_NOT_REGISTERED) - card->bm_node_id =3D 0xffc0 & bm_id; - else - card->bm_node_id =3D local_id; + if (irm_is_1394_1995_only && !keep_this_irm) { + new_root_id =3D local_id; + fw_notice(card, "%s, making local node (%02x) root\n", + "IRM is not 1394a compliant", new_root_id); + goto pick_me; } =20 - if (bm_id !=3D BUS_MANAGER_ID_NOT_REGISTERED) { - // Somebody else is BM. Only act as IRM. - if (local_id =3D=3D irm_id) - allocate_broadcast_channel(card, generation); + rcode =3D fw_run_transaction(card, TCODE_LOCK_COMPARE_SWAP, + irm_id, generation, SCODE_100, + CSR_REGISTER_BASE + CSR_BUS_MANAGER_ID, + data, sizeof(data)); + + switch (rcode) { + case RCODE_GENERATION: + // Another bus reset, BM work has been rescheduled. return; + case RCODE_SEND_ERROR: + // We have been unable to send the lock request due to + // some local problem. Let's try again later and hope + // that the problem has gone away by then. + fw_schedule_bm_work(card, msecs_to_jiffies(125)); + return; + case RCODE_COMPLETE: + { + int bm_id =3D be32_to_cpu(data[0]); + + // Used by cdev layer for "struct fw_cdev_event_bus_reset". + scoped_guard(spinlock, &card->lock) { + if (bm_id !=3D BUS_MANAGER_ID_NOT_REGISTERED) + card->bm_node_id =3D 0xffc0 & bm_id; + else + card->bm_node_id =3D local_id; + } + + if (bm_id !=3D BUS_MANAGER_ID_NOT_REGISTERED) { + // Somebody else is BM. Only act as IRM. + if (local_id =3D=3D irm_id) + allocate_broadcast_channel(card, generation); + return; + } + break; } - break; - } - default: - if (!keep_this_irm) { - // The lock request failed, maybe the IRM - // isn't really IRM capable after all. Let's - // do a bus reset and pick the local node as - // root, and thus, IRM. - new_root_id =3D local_id; - fw_notice(card, "BM lock failed (%s), making local node (%02x) root\n", - fw_rcode_string(rcode), new_root_id); - goto pick_me; + default: + if (!keep_this_irm) { + // The lock request failed, maybe the IRM + // isn't really IRM capable after all. Let's + // do a bus reset and pick the local node as + // root, and thus, IRM. + new_root_id =3D local_id; + fw_notice(card, "BM lock failed (%s), making local node (%02x) root\n= ", + fw_rcode_string(rcode), new_root_id); + goto pick_me; + } + break; } - break; + + // A node contends for bus manager in this generation. + card->bm_generation =3D generation; + } else { + // We weren't BM in the last generation, and the last + // bus reset is less than 125ms ago. Reschedule this job. + fw_schedule_bm_work(card, msecs_to_jiffies(125)); + return; } - } else if (card->bm_generation !=3D generation) { - /* - * We weren't BM in the last generation, and the last - * bus reset is less than 125ms ago. Reschedule this job. - */ - fw_schedule_bm_work(card, msecs_to_jiffies(125)); - return; } =20 /* @@ -412,8 +412,6 @@ static void bm_work(struct work_struct *work) * make sure we have an active cycle master and do gap count * optimization. */ - card->bm_generation =3D generation; - if (card->gap_count =3D=3D GAP_COUNT_MISMATCHED) { /* * If self IDs have inconsistent gap counts, do a --=20 2.48.1 From nobody Thu Oct 2 07:49:13 2025 Received: from fout-b1-smtp.messagingengine.com (fout-b1-smtp.messagingengine.com [202.12.124.144]) (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 4934F2E03E0 for ; Thu, 18 Sep 2025 23:54:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758239701; cv=none; b=Ayh+OCEFfIIS2ZemcNo2eZWpvElR6zc4Eqkt3u3N64GbuJpD5B0/wizIRhiXOdKlULejf4RmKXvgwTnEP65j54ljMu81MNNbbhPX2tIxffKQ9GLgpOA4AA3W1Vg3BmUdn1Q8MIVlCumnbG2V62cAynz/Rgjzbwdv9X7diSRK63g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758239701; c=relaxed/simple; bh=6XCGEF+O0EumKVvH9K6BwI5JWDaMiPYG0qrGzbn+mCM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pwd/nyhsjC+aCdlZVSuRzfIS6tZa/82RRQiw+t6kzGecPOpQwYVHV6d1MXZb6+exwspn5FEGzkHXm7+6CUEavBadm/shwCpM7KMtfnh+QKWqVqKmKNTjqVsEMCpCnuzP9BY1lHiVyTFmiG5MsLg2HsxfxaN0g+eabdHW18Ozkkk= 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=D/i2xbP1; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=HYSwgwn2; arc=none smtp.client-ip=202.12.124.144 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="D/i2xbP1"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="HYSwgwn2" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id 61A721D002E6; Thu, 18 Sep 2025 19:54:58 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Thu, 18 Sep 2025 19:54:58 -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=1758239698; x= 1758326098; bh=sAuUoMVEHwZXFy2qdrfe1k/tghXZlxjrtGmNtSZya9k=; b=D /i2xbP11AnVoZyNAK4EU3b2t2HLfYoyRMFFQmc/13MmAeESzhY+oWqxpKgLNH3IH qgP/aQhAXbip3h5Macx5RppNEQuzacmAvnlFKyPUJR+t7UD2np4sZe1E8MjMvRfF GrRHC26TbriCu4NyVUVgZmohZ3zJ5ZTliCAPj6/oxI/IGaxzHcH+RT0B7erW2Dqb 5aFhsSNyaxmbv/0EenP9EY+7oz+yjXYspPpyvT/uprBZKzYMNzqXmuSeAj1fHJde hncbhCA+0rSzU+5soh9/fEWPr8mzgQwPKLQ4Z1/0VFNEgDIBxYv+WDO9KtzL6vMG NVG9BvwJqIVUSQgXmHrBw== 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=1758239698; x=1758326098; bh=s AuUoMVEHwZXFy2qdrfe1k/tghXZlxjrtGmNtSZya9k=; b=HYSwgwn2aMRFhTvHf G3FFZeds2pR4OFzTSQOecBCOrYZwlsT/xdiU/8qyWAFM0ZXuW6q+7rwMwVQ0H1/C AxbyKY3If8OnfVIF0yup5DSZDWylxgdQKWyKQwrXA5LEp/AhiP7QlXskIOXtIQST yZMOBEBy3mDg0r8ZPsWyHiZx4hdjRy6wBZ32j7jheLfgJX6CtuBseg3bCFNMzNYF TFCSzMFCj7nl3MlzDVm5YaAeUKzkNcmoHQBAp02om+GHf/Fj98jqChO+YeaLKI/A EruCCnSlnE/V55Rox9Aj1vVUFrqXqCgRBEFCt877bQ+zuh3ngxz2NhnZxlyHy6Bg 2ArvQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdegjeejtdcutefuodetggdotefrod 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; Thu, 18 Sep 2025 19:54:57 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2 4/6] firewire: core: code refactoring to split contention procedure for bus manager Date: Fri, 19 Sep 2025 08:54:46 +0900 Message-ID: <20250918235448.129705-5-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250918230857.127400-1-o-takashi@sakamocchi.jp> References: <20250918230857.127400-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 precedure to contend for bus manager has much code. It is better to split it into a helper function. This commit refactors in the point. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 223 ++++++++++++++++++++--------------- 1 file changed, 127 insertions(+), 96 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index 02058af705cc..6268b595d4fa 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -279,6 +279,102 @@ void fw_schedule_bm_work(struct fw_card *card, unsign= ed long delay) fw_card_put(card); } =20 +enum bm_contention_outcome { + // The bus management contention window is not expired. + BM_CONTENTION_OUTCOME_WITHIN_WINDOW =3D 0, + // The IRM node has link off. + BM_CONTENTION_OUTCOME_IRM_HAS_LINK_OFF, + // The IRM node complies IEEE 1394:1994 only. + BM_CONTENTION_OUTCOME_IRM_COMPLIES_1394_1995_ONLY, + // Another bus reset, BM work has been rescheduled. + BM_CONTENTION_OUTCOME_AT_NEW_GENERATION, + // We have been unable to send the lock request to IRM node due to some l= ocal problem. + BM_CONTENTION_OUTCOME_LOCAL_PROBLEM_AT_TRANSACTION, + // The lock request failed, maybe the IRM isn't really IRM capable after = all. + BM_CONTENTION_OUTCOME_IRM_IS_NOT_CAPABLE_FOR_IRM, + // Somebody else is BM. + BM_CONTENTION_OUTCOME_IRM_HOLDS_ANOTHER_NODE_AS_BM, + // The local node succeeds after contending for bus manager. + BM_CONTENTION_OUTCOME_IRM_HOLDS_LOCAL_NODE_AS_BM, +}; + +static enum bm_contention_outcome contend_for_bm(struct fw_card *card) +{ + int generation =3D card->generation; + int local_id =3D card->local_node->node_id; + __be32 data[2] =3D { + cpu_to_be32(BUS_MANAGER_ID_NOT_REGISTERED), + cpu_to_be32(local_id), + }; + bool grace =3D time_is_before_jiffies64(card->reset_jiffies + msecs_to_ji= ffies(125)); + bool irm_is_1394_1995_only =3D false; + bool keep_this_irm =3D false; + struct fw_node *irm_node; + struct fw_device *irm_device; + int rcode; + + if (!grace) { + if (!is_next_generation(generation, card->bm_generation) || card->bm_abd= icate) + return BM_CONTENTION_OUTCOME_WITHIN_WINDOW; + } + + irm_node =3D card->irm_node; + if (!irm_node->link_on) { + fw_notice(card, "IRM has link off, making local node (%02x) root\n", loc= al_id); + return BM_CONTENTION_OUTCOME_IRM_HAS_LINK_OFF; + } + + irm_device =3D fw_node_get_device(irm_node); + if (irm_device && irm_device->config_rom) { + irm_is_1394_1995_only =3D (irm_device->config_rom[2] & 0x000000f0) =3D= =3D 0; + + // Canon MV5i works unreliably if it is not root node. + keep_this_irm =3D irm_device->config_rom[3] >> 8 =3D=3D CANON_OUI; + } + + if (irm_is_1394_1995_only && !keep_this_irm) { + fw_notice(card, "IRM is not 1394a compliant, making local node (%02x) ro= ot\n", + local_id); + return BM_CONTENTION_OUTCOME_IRM_COMPLIES_1394_1995_ONLY; + } + + rcode =3D fw_run_transaction(card, TCODE_LOCK_COMPARE_SWAP, irm_node->nod= e_id, generation, + SCODE_100, CSR_REGISTER_BASE + CSR_BUS_MANAGER_ID, data, + sizeof(data)); + + switch (rcode) { + case RCODE_GENERATION: + return BM_CONTENTION_OUTCOME_AT_NEW_GENERATION; + case RCODE_SEND_ERROR: + return BM_CONTENTION_OUTCOME_LOCAL_PROBLEM_AT_TRANSACTION; + case RCODE_COMPLETE: + { + int bm_id =3D be32_to_cpu(data[0]); + + // Used by cdev layer for "struct fw_cdev_event_bus_reset". + scoped_guard(spinlock, &card->lock) { + if (bm_id !=3D BUS_MANAGER_ID_NOT_REGISTERED) + card->bm_node_id =3D 0xffc0 & bm_id; + else + card->bm_node_id =3D local_id; + } + + if (bm_id !=3D BUS_MANAGER_ID_NOT_REGISTERED) + return BM_CONTENTION_OUTCOME_IRM_HOLDS_ANOTHER_NODE_AS_BM; + else + return BM_CONTENTION_OUTCOME_IRM_HOLDS_LOCAL_NODE_AS_BM; + } + default: + if (!keep_this_irm) { + fw_notice(card, "BM lock failed (%s), making local node (%02x) root\n", + fw_rcode_string(rcode), local_id); + return BM_CONTENTION_OUTCOME_IRM_COMPLIES_1394_1995_ONLY; + } else { + return BM_CONTENTION_OUTCOME_IRM_IS_NOT_CAPABLE_FOR_IRM; + } + } +} + DEFINE_FREE(node_unref, struct fw_node *, if (_T) fw_node_put(_T)) DEFINE_FREE(card_unref, struct fw_card *, if (_T) fw_card_put(_T)) =20 @@ -305,105 +401,40 @@ static void bm_work(struct work_struct *work) local_id =3D card->local_node->node_id; =20 if (card->bm_generation !=3D generation) { - bool grace =3D time_is_before_jiffies64(card->reset_jiffies + msecs_to_j= iffies(125)); - - if (grace || - (is_next_generation(generation, card->bm_generation) && !card->bm_ab= dicate)) { - // This first step is to figure out who is IRM and - // then try to become bus manager. If the IRM is not - // well defined (e.g. does not have an active link - // layer or does not responds to our lock request, we - // will have to do a little vigilante bus management. - // In that case, we do a goto into the gap count logic - // so that when we do the reset, we still optimize the - // gap count. That could well save a reset in the - // next generation. - __be32 data[2] =3D { - cpu_to_be32(BUS_MANAGER_ID_NOT_REGISTERED), - cpu_to_be32(local_id), - }; - struct fw_device *irm_device =3D fw_node_get_device(card->irm_node); - bool irm_is_1394_1995_only =3D false; - bool keep_this_irm =3D false; - int rcode; - - if (!card->irm_node->link_on) { - new_root_id =3D local_id; - fw_notice(card, "%s, making local node (%02x) root\n", - "IRM has link off", new_root_id); - goto pick_me; - } + enum bm_contention_outcome result =3D contend_for_bm(card); =20 - if (irm_device && irm_device->config_rom) { - irm_is_1394_1995_only =3D (irm_device->config_rom[2] & 0x000000f0) =3D= =3D 0; - - // Canon MV5i works unreliably if it is not root node. - keep_this_irm =3D irm_device->config_rom[3] >> 8 =3D=3D CANON_OUI; - } - - if (irm_is_1394_1995_only && !keep_this_irm) { - new_root_id =3D local_id; - fw_notice(card, "%s, making local node (%02x) root\n", - "IRM is not 1394a compliant", new_root_id); - goto pick_me; - } - - rcode =3D fw_run_transaction(card, TCODE_LOCK_COMPARE_SWAP, - irm_id, generation, SCODE_100, - CSR_REGISTER_BASE + CSR_BUS_MANAGER_ID, - data, sizeof(data)); - - switch (rcode) { - case RCODE_GENERATION: - // Another bus reset, BM work has been rescheduled. - return; - case RCODE_SEND_ERROR: - // We have been unable to send the lock request due to - // some local problem. Let's try again later and hope - // that the problem has gone away by then. - fw_schedule_bm_work(card, msecs_to_jiffies(125)); - return; - case RCODE_COMPLETE: - { - int bm_id =3D be32_to_cpu(data[0]); - - // Used by cdev layer for "struct fw_cdev_event_bus_reset". - scoped_guard(spinlock, &card->lock) { - if (bm_id !=3D BUS_MANAGER_ID_NOT_REGISTERED) - card->bm_node_id =3D 0xffc0 & bm_id; - else - card->bm_node_id =3D local_id; - } - - if (bm_id !=3D BUS_MANAGER_ID_NOT_REGISTERED) { - // Somebody else is BM. Only act as IRM. - if (local_id =3D=3D irm_id) - allocate_broadcast_channel(card, generation); - return; - } - break; - } - default: - if (!keep_this_irm) { - // The lock request failed, maybe the IRM - // isn't really IRM capable after all. Let's - // do a bus reset and pick the local node as - // root, and thus, IRM. - new_root_id =3D local_id; - fw_notice(card, "BM lock failed (%s), making local node (%02x) root\n= ", - fw_rcode_string(rcode), new_root_id); - goto pick_me; - } - break; - } - - // A node contends for bus manager in this generation. - card->bm_generation =3D generation; - } else { - // We weren't BM in the last generation, and the last - // bus reset is less than 125ms ago. Reschedule this job. + switch (result) { + case BM_CONTENTION_OUTCOME_WITHIN_WINDOW: fw_schedule_bm_work(card, msecs_to_jiffies(125)); return; + case BM_CONTENTION_OUTCOME_IRM_HAS_LINK_OFF: + new_root_id =3D local_id; + goto pick_me; + case BM_CONTENTION_OUTCOME_IRM_COMPLIES_1394_1995_ONLY: + new_root_id =3D local_id; + goto pick_me; + case BM_CONTENTION_OUTCOME_AT_NEW_GENERATION: + // BM work has been rescheduled. + return; + case BM_CONTENTION_OUTCOME_LOCAL_PROBLEM_AT_TRANSACTION: + // Let's try again later and hope that the local problem has gone away = by + // then. + fw_schedule_bm_work(card, msecs_to_jiffies(125)); + return; + case BM_CONTENTION_OUTCOME_IRM_IS_NOT_CAPABLE_FOR_IRM: + // Let's do a bus reset and pick the local node as root, and thus, IRM. + new_root_id =3D local_id; + goto pick_me; + case BM_CONTENTION_OUTCOME_IRM_HOLDS_ANOTHER_NODE_AS_BM: + if (local_id =3D=3D irm_id) { + // Only acts as IRM. + allocate_broadcast_channel(card, generation); + } + fallthrough; + case BM_CONTENTION_OUTCOME_IRM_HOLDS_LOCAL_NODE_AS_BM: + default: + card->bm_generation =3D generation; + break; } } =20 --=20 2.48.1 From nobody Thu Oct 2 07:49:13 2025 Received: from fhigh-b1-smtp.messagingengine.com (fhigh-b1-smtp.messagingengine.com [202.12.124.152]) (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 3050F2FD7B9 for ; Thu, 18 Sep 2025 23:09:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.152 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758236952; cv=none; b=rPCI/a9kpjvS608aOHoCR8XL+K87IcNdOmHHtQ+ADr5w+QM75omE6XToHataZHHUt5TwC3lbUBbLXTPEVkRwNMLO2UMCy5sBhB9tyTJ2E0k2X0qqxyUf6nC3dQRDkH+G1fa/ZC2xdTQB0Re7L2I1AXqFkWQBDBaTV46WuolROK4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758236952; c=relaxed/simple; bh=6XCGEF+O0EumKVvH9K6BwI5JWDaMiPYG0qrGzbn+mCM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UljjbFT8IXa6wrkCPIK7W9bmAFoCviVlGhQOQ28HeWIkvqswqW6fNDU/VCL+M0IIgkEIxOe7OxXRe5XAzkJ1LB0Xa9zLn5YyttWUkb9ufF92VQbjdeNx4/kIXimyZsF3pRXyDwMDW6vbJlbNcPY63AiODrxcuHeq6p9oMXmVdVA= 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=onWBy4Hg; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=hVOBl9bX; arc=none smtp.client-ip=202.12.124.152 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="onWBy4Hg"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="hVOBl9bX" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id 593827A02F7; Thu, 18 Sep 2025 19:09:09 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Thu, 18 Sep 2025 19:09:09 -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=1758236949; x= 1758323349; bh=sAuUoMVEHwZXFy2qdrfe1k/tghXZlxjrtGmNtSZya9k=; b=o nWBy4HgUJh5OHpEc3s8Du1fCbig3Z/mOg5OECbd6Kt5RLbqD+WpqMFE15o1rZY4v o520EPVcBYF1OKD+s9DGP1SKHSox/slaqVENwgMx6sH7p9JnZXwYENsMl449vav7 QeO1TMf9jzfZU6oioFybZG5cnKxOsjiTPeaFO+Un/fi2wUO1aYXEu8tdBlUtunTW 3qapilwTFdmoei1+kTmkV1AHxkacByAqpGBiJuKsKZ8y/LkSn68CUpdRZNKx/maq L16FlB2QN2twrCCiKkkMDsMziDnc8yo33zhrlGMU2MjSenVkxafkE2pcuHkTHcmy nTglVswYv7D6gZKIHHYGg== 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=1758236949; x=1758323349; bh=s AuUoMVEHwZXFy2qdrfe1k/tghXZlxjrtGmNtSZya9k=; b=hVOBl9bXEBZvBi0XY WZC4mSPpS/jb5YrVj5wvYd+j+epHN9bjRm71w9HXQU8+N6iJ6fEOxhVFQdSx/F4+ oZG1FiD0j6mqZa8ftettYv4ENLAsjYzqFRvvo/fllVgRvi/T37k32ylje1Hw3D0l deFKLw+u5EgbXI2/U/YXzEk8qFHtPorUuYPJVkKSepn9ngPLZGvn3F7qz9m2K4Q8 g/W9cBvVLysNW+f/gJYwPOE0BSjo6fwwr/ZQEKeOEgF1848stWA9b0/9/vjGU4d2 qnM5hKqdNKaOHGO+KcbgmT0MWLFq/JiVPHW+HQogzChAVo/dmU5T79p4lKSb2fkZ Oflnw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdegjeeiudcutefuodetggdotefrod 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; Thu, 18 Sep 2025 19:09:08 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 4/6] firewire: core: code refactoring to split contention procedure for bus manager Date: Fri, 19 Sep 2025 08:08:55 +0900 Message-ID: <20250918230857.127400-5-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250918230857.127400-1-o-takashi@sakamocchi.jp> References: <20250918230857.127400-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 precedure to contend for bus manager has much code. It is better to split it into a helper function. This commit refactors in the point. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 223 ++++++++++++++++++++--------------- 1 file changed, 127 insertions(+), 96 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index 02058af705cc..6268b595d4fa 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -279,6 +279,102 @@ void fw_schedule_bm_work(struct fw_card *card, unsign= ed long delay) fw_card_put(card); } =20 +enum bm_contention_outcome { + // The bus management contention window is not expired. + BM_CONTENTION_OUTCOME_WITHIN_WINDOW =3D 0, + // The IRM node has link off. + BM_CONTENTION_OUTCOME_IRM_HAS_LINK_OFF, + // The IRM node complies IEEE 1394:1994 only. + BM_CONTENTION_OUTCOME_IRM_COMPLIES_1394_1995_ONLY, + // Another bus reset, BM work has been rescheduled. + BM_CONTENTION_OUTCOME_AT_NEW_GENERATION, + // We have been unable to send the lock request to IRM node due to some l= ocal problem. + BM_CONTENTION_OUTCOME_LOCAL_PROBLEM_AT_TRANSACTION, + // The lock request failed, maybe the IRM isn't really IRM capable after = all. + BM_CONTENTION_OUTCOME_IRM_IS_NOT_CAPABLE_FOR_IRM, + // Somebody else is BM. + BM_CONTENTION_OUTCOME_IRM_HOLDS_ANOTHER_NODE_AS_BM, + // The local node succeeds after contending for bus manager. + BM_CONTENTION_OUTCOME_IRM_HOLDS_LOCAL_NODE_AS_BM, +}; + +static enum bm_contention_outcome contend_for_bm(struct fw_card *card) +{ + int generation =3D card->generation; + int local_id =3D card->local_node->node_id; + __be32 data[2] =3D { + cpu_to_be32(BUS_MANAGER_ID_NOT_REGISTERED), + cpu_to_be32(local_id), + }; + bool grace =3D time_is_before_jiffies64(card->reset_jiffies + msecs_to_ji= ffies(125)); + bool irm_is_1394_1995_only =3D false; + bool keep_this_irm =3D false; + struct fw_node *irm_node; + struct fw_device *irm_device; + int rcode; + + if (!grace) { + if (!is_next_generation(generation, card->bm_generation) || card->bm_abd= icate) + return BM_CONTENTION_OUTCOME_WITHIN_WINDOW; + } + + irm_node =3D card->irm_node; + if (!irm_node->link_on) { + fw_notice(card, "IRM has link off, making local node (%02x) root\n", loc= al_id); + return BM_CONTENTION_OUTCOME_IRM_HAS_LINK_OFF; + } + + irm_device =3D fw_node_get_device(irm_node); + if (irm_device && irm_device->config_rom) { + irm_is_1394_1995_only =3D (irm_device->config_rom[2] & 0x000000f0) =3D= =3D 0; + + // Canon MV5i works unreliably if it is not root node. + keep_this_irm =3D irm_device->config_rom[3] >> 8 =3D=3D CANON_OUI; + } + + if (irm_is_1394_1995_only && !keep_this_irm) { + fw_notice(card, "IRM is not 1394a compliant, making local node (%02x) ro= ot\n", + local_id); + return BM_CONTENTION_OUTCOME_IRM_COMPLIES_1394_1995_ONLY; + } + + rcode =3D fw_run_transaction(card, TCODE_LOCK_COMPARE_SWAP, irm_node->nod= e_id, generation, + SCODE_100, CSR_REGISTER_BASE + CSR_BUS_MANAGER_ID, data, + sizeof(data)); + + switch (rcode) { + case RCODE_GENERATION: + return BM_CONTENTION_OUTCOME_AT_NEW_GENERATION; + case RCODE_SEND_ERROR: + return BM_CONTENTION_OUTCOME_LOCAL_PROBLEM_AT_TRANSACTION; + case RCODE_COMPLETE: + { + int bm_id =3D be32_to_cpu(data[0]); + + // Used by cdev layer for "struct fw_cdev_event_bus_reset". + scoped_guard(spinlock, &card->lock) { + if (bm_id !=3D BUS_MANAGER_ID_NOT_REGISTERED) + card->bm_node_id =3D 0xffc0 & bm_id; + else + card->bm_node_id =3D local_id; + } + + if (bm_id !=3D BUS_MANAGER_ID_NOT_REGISTERED) + return BM_CONTENTION_OUTCOME_IRM_HOLDS_ANOTHER_NODE_AS_BM; + else + return BM_CONTENTION_OUTCOME_IRM_HOLDS_LOCAL_NODE_AS_BM; + } + default: + if (!keep_this_irm) { + fw_notice(card, "BM lock failed (%s), making local node (%02x) root\n", + fw_rcode_string(rcode), local_id); + return BM_CONTENTION_OUTCOME_IRM_COMPLIES_1394_1995_ONLY; + } else { + return BM_CONTENTION_OUTCOME_IRM_IS_NOT_CAPABLE_FOR_IRM; + } + } +} + DEFINE_FREE(node_unref, struct fw_node *, if (_T) fw_node_put(_T)) DEFINE_FREE(card_unref, struct fw_card *, if (_T) fw_card_put(_T)) =20 @@ -305,105 +401,40 @@ static void bm_work(struct work_struct *work) local_id =3D card->local_node->node_id; =20 if (card->bm_generation !=3D generation) { - bool grace =3D time_is_before_jiffies64(card->reset_jiffies + msecs_to_j= iffies(125)); - - if (grace || - (is_next_generation(generation, card->bm_generation) && !card->bm_ab= dicate)) { - // This first step is to figure out who is IRM and - // then try to become bus manager. If the IRM is not - // well defined (e.g. does not have an active link - // layer or does not responds to our lock request, we - // will have to do a little vigilante bus management. - // In that case, we do a goto into the gap count logic - // so that when we do the reset, we still optimize the - // gap count. That could well save a reset in the - // next generation. - __be32 data[2] =3D { - cpu_to_be32(BUS_MANAGER_ID_NOT_REGISTERED), - cpu_to_be32(local_id), - }; - struct fw_device *irm_device =3D fw_node_get_device(card->irm_node); - bool irm_is_1394_1995_only =3D false; - bool keep_this_irm =3D false; - int rcode; - - if (!card->irm_node->link_on) { - new_root_id =3D local_id; - fw_notice(card, "%s, making local node (%02x) root\n", - "IRM has link off", new_root_id); - goto pick_me; - } + enum bm_contention_outcome result =3D contend_for_bm(card); =20 - if (irm_device && irm_device->config_rom) { - irm_is_1394_1995_only =3D (irm_device->config_rom[2] & 0x000000f0) =3D= =3D 0; - - // Canon MV5i works unreliably if it is not root node. - keep_this_irm =3D irm_device->config_rom[3] >> 8 =3D=3D CANON_OUI; - } - - if (irm_is_1394_1995_only && !keep_this_irm) { - new_root_id =3D local_id; - fw_notice(card, "%s, making local node (%02x) root\n", - "IRM is not 1394a compliant", new_root_id); - goto pick_me; - } - - rcode =3D fw_run_transaction(card, TCODE_LOCK_COMPARE_SWAP, - irm_id, generation, SCODE_100, - CSR_REGISTER_BASE + CSR_BUS_MANAGER_ID, - data, sizeof(data)); - - switch (rcode) { - case RCODE_GENERATION: - // Another bus reset, BM work has been rescheduled. - return; - case RCODE_SEND_ERROR: - // We have been unable to send the lock request due to - // some local problem. Let's try again later and hope - // that the problem has gone away by then. - fw_schedule_bm_work(card, msecs_to_jiffies(125)); - return; - case RCODE_COMPLETE: - { - int bm_id =3D be32_to_cpu(data[0]); - - // Used by cdev layer for "struct fw_cdev_event_bus_reset". - scoped_guard(spinlock, &card->lock) { - if (bm_id !=3D BUS_MANAGER_ID_NOT_REGISTERED) - card->bm_node_id =3D 0xffc0 & bm_id; - else - card->bm_node_id =3D local_id; - } - - if (bm_id !=3D BUS_MANAGER_ID_NOT_REGISTERED) { - // Somebody else is BM. Only act as IRM. - if (local_id =3D=3D irm_id) - allocate_broadcast_channel(card, generation); - return; - } - break; - } - default: - if (!keep_this_irm) { - // The lock request failed, maybe the IRM - // isn't really IRM capable after all. Let's - // do a bus reset and pick the local node as - // root, and thus, IRM. - new_root_id =3D local_id; - fw_notice(card, "BM lock failed (%s), making local node (%02x) root\n= ", - fw_rcode_string(rcode), new_root_id); - goto pick_me; - } - break; - } - - // A node contends for bus manager in this generation. - card->bm_generation =3D generation; - } else { - // We weren't BM in the last generation, and the last - // bus reset is less than 125ms ago. Reschedule this job. + switch (result) { + case BM_CONTENTION_OUTCOME_WITHIN_WINDOW: fw_schedule_bm_work(card, msecs_to_jiffies(125)); return; + case BM_CONTENTION_OUTCOME_IRM_HAS_LINK_OFF: + new_root_id =3D local_id; + goto pick_me; + case BM_CONTENTION_OUTCOME_IRM_COMPLIES_1394_1995_ONLY: + new_root_id =3D local_id; + goto pick_me; + case BM_CONTENTION_OUTCOME_AT_NEW_GENERATION: + // BM work has been rescheduled. + return; + case BM_CONTENTION_OUTCOME_LOCAL_PROBLEM_AT_TRANSACTION: + // Let's try again later and hope that the local problem has gone away = by + // then. + fw_schedule_bm_work(card, msecs_to_jiffies(125)); + return; + case BM_CONTENTION_OUTCOME_IRM_IS_NOT_CAPABLE_FOR_IRM: + // Let's do a bus reset and pick the local node as root, and thus, IRM. + new_root_id =3D local_id; + goto pick_me; + case BM_CONTENTION_OUTCOME_IRM_HOLDS_ANOTHER_NODE_AS_BM: + if (local_id =3D=3D irm_id) { + // Only acts as IRM. + allocate_broadcast_channel(card, generation); + } + fallthrough; + case BM_CONTENTION_OUTCOME_IRM_HOLDS_LOCAL_NODE_AS_BM: + default: + card->bm_generation =3D generation; + break; } } =20 --=20 2.48.1 From nobody Thu Oct 2 07:49:13 2025 Received: from fout-b1-smtp.messagingengine.com (fout-b1-smtp.messagingengine.com [202.12.124.144]) (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 C63032F2607 for ; Thu, 18 Sep 2025 23:55:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758239702; cv=none; b=h0Sa2GhoH+u+QxtzGp4yilEnPHSEkW+rvRuM3iEfKzpeU1DehYbKE4TaD1ioOCfOZH1LLkuB+kT3wZkAND955Kb+tMssGIvZOViVcu+si80I14VIi4J7s21xBIWZXVx+oBJw1b87r/4GKBWQ/cUuMoDmXRoGwDaKbrbrV352awE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758239702; c=relaxed/simple; bh=AG53UB01dVOFG9V/HAVXW8WT5VX9S3k64bpboHkrOP8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ov8UVnmlAZEofoZs2KGdABY1hJqwcIRojNusnYiQ8Be0S2zpaMOipQC4JMp1+B2uujCVH6y9HS4LJLIhNcvZ0emggV8F1UxCoBZqyOLNjA7doqJbLkNRYJPSPRoqfyb2fj9UQnavJK2WUxjFnZ+d01CvY0C+9dj+AC4uBBvu7xo= 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=WCoWV3fS; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=oCSmXMRa; arc=none smtp.client-ip=202.12.124.144 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="WCoWV3fS"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="oCSmXMRa" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.stl.internal (Postfix) with ESMTP id F36F11D002E3; Thu, 18 Sep 2025 19:54:59 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Thu, 18 Sep 2025 19:55: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=1758239699; x= 1758326099; bh=KwzQEGG89WT38SZTNrp7a2zR3gJWlAZ5vWCncLkwR5U=; b=W CoWV3fShymqkFuvj1wCyOSoVGox9RzVhXbOhcIOz6ffqsbhMs14NPqbOp5Qb5JRp fjOR2ULjmTSftspNwKsQOOAwBmpG32cxg0oEamLzN+YKMtQUjP6q0yGvjc5UTV2s FqGQXJO8cm67eTe2u5WAOzeUs4hZ/p525AHhMDOlnXJyBtp00xxmNwJgIQtIPQAT FKhg0u1fbSDiz4sV6TvaBALZyIE9DPGzciKpZu0peBiuGkUC5IAakb+nnIaRocIV dyWH13rRikUucY8rNmcICyue078A5XVcnT0AkSdxQefQFqA2jq9UnDvLzx09FOzh RMCbw43lgwVGjE5gHCndQ== 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=1758239699; x=1758326099; bh=K wzQEGG89WT38SZTNrp7a2zR3gJWlAZ5vWCncLkwR5U=; b=oCSmXMRadCOYmXESJ fi50+2H1zwYXT+G2kzm/8GkZs9dsLvlRiCArG1LwtMiDjlw/UXg/dBGQpc7w5v60 Bu3lo55zKMgfB8kwkRNlYMm9kyRHUBs2UnmZ38vTjt49yTe/MuOPRBM2rcTn3O8L gH1IbadPOOdhgJ5JvDYGBJP//HtXC6nqgCkRBsY073PEpflZXxkNq68dxIaZdeTm +/o7gxWH70EGBcbCOU+X8s8r9tpQbZg5OJt+ldr7ec4PWJNj6d5dytmtbJk/XgcQ NN93ucfm03/Zwtw4Jlp00S7D/dNH8WTYcjJIPF9ZDOOBuw/9utXdpaP6BTvGf5CA wv9nQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdegjeejtdcutefuodetggdotefrod 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; Thu, 18 Sep 2025 19:54:58 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2 5/6] firewire: core; eliminate pick_me goto label Date: Fri, 19 Sep 2025 08:54:47 +0900 Message-ID: <20250918235448.129705-6-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250918230857.127400-1-o-takashi@sakamocchi.jp> References: <20250918230857.127400-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" This commit uses condition statements instead of pick_me goto label. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 101 ++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 50 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index 6268b595d4fa..58d1f58a4a0f 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -388,6 +388,7 @@ static void bm_work(struct work_struct *work) int root_id, new_root_id, irm_id, local_id; int expected_gap_count, generation; bool do_reset =3D false; + bool stand_for_root =3D false; =20 if (card->local_node =3D=3D NULL) return; @@ -408,11 +409,11 @@ static void bm_work(struct work_struct *work) fw_schedule_bm_work(card, msecs_to_jiffies(125)); return; case BM_CONTENTION_OUTCOME_IRM_HAS_LINK_OFF: - new_root_id =3D local_id; - goto pick_me; + stand_for_root =3D true; + break; case BM_CONTENTION_OUTCOME_IRM_COMPLIES_1394_1995_ONLY: - new_root_id =3D local_id; - goto pick_me; + stand_for_root =3D true; + break; case BM_CONTENTION_OUTCOME_AT_NEW_GENERATION: // BM work has been rescheduled. return; @@ -423,8 +424,8 @@ static void bm_work(struct work_struct *work) return; case BM_CONTENTION_OUTCOME_IRM_IS_NOT_CAPABLE_FOR_IRM: // Let's do a bus reset and pick the local node as root, and thus, IRM. - new_root_id =3D local_id; - goto pick_me; + stand_for_root =3D true; + break; case BM_CONTENTION_OUTCOME_IRM_HOLDS_ANOTHER_NODE_AS_BM: if (local_id =3D=3D irm_id) { // Only acts as IRM. @@ -438,56 +439,56 @@ static void bm_work(struct work_struct *work) } } =20 - /* - * We're bus manager for this generation, so next step is to - * make sure we have an active cycle master and do gap count - * optimization. - */ - if (card->gap_count =3D=3D GAP_COUNT_MISMATCHED) { - /* - * If self IDs have inconsistent gap counts, do a - * bus reset ASAP. The config rom read might never - * complete, so don't wait for it. However, still - * send a PHY configuration packet prior to the - * bus reset. The PHY configuration packet might - * fail, but 1394-2008 8.4.5.2 explicitly permits - * it in this case, so it should be safe to try. - */ - new_root_id =3D local_id; - /* - * We must always send a bus reset if the gap count - * is inconsistent, so bypass the 5-reset limit. - */ - card->bm_retries =3D 0; - } else { - // Now investigate root node. - struct fw_device *root_device =3D fw_node_get_device(root_node); - - if (root_device =3D=3D NULL) { - // Either link_on is false, or we failed to read the - // config rom. In either case, pick another root. - new_root_id =3D local_id; + // We're bus manager for this generation, so next step is to make sure we= have an active + // cycle master and do gap count optimization. + if (!stand_for_root) { + if (card->gap_count =3D=3D GAP_COUNT_MISMATCHED) { + // If self IDs have inconsistent gap counts, do a + // bus reset ASAP. The config rom read might never + // complete, so don't wait for it. However, still + // send a PHY configuration packet prior to the + // bus reset. The PHY configuration packet might + // fail, but 1394-2008 8.4.5.2 explicitly permits + // it in this case, so it should be safe to try. + stand_for_root =3D true; + + // We must always send a bus reset if the gap count + // is inconsistent, so bypass the 5-reset limit. + card->bm_retries =3D 0; } else { - bool root_device_is_running =3D - atomic_read(&root_device->state) =3D=3D FW_DEVICE_RUNNING; + // Now investigate root node. + struct fw_device *root_device =3D fw_node_get_device(root_node); =20 - if (!root_device_is_running) { - // If we haven't probed this device yet, bail out now - // and let's try again once that's done. - return; - } else if (root_device->cmc) { - // We will send out a force root packet for this - // node as part of the gap count optimization. - new_root_id =3D root_id; + if (root_device =3D=3D NULL) { + // Either link_on is false, or we failed to read the + // config rom. In either case, pick another root. + stand_for_root =3D true; } else { - // Current root has an active link layer and we - // successfully read the config rom, but it's not - // cycle master capable. - new_root_id =3D local_id; + bool root_device_is_running =3D + atomic_read(&root_device->state) =3D=3D FW_DEVICE_RUNNING; + + if (!root_device_is_running) { + // If we haven't probed this device yet, bail out now + // and let's try again once that's done. + return; + } else if (!root_device->cmc) { + // Current root has an active link layer and we + // successfully read the config rom, but it's not + // cycle master capable. + stand_for_root =3D true; + } } } } - pick_me: + + if (stand_for_root) { + new_root_id =3D local_id; + } else { + // We will send out a force root packet for this node as part of the gap= count + // optimization on behalf of the node. + new_root_id =3D root_id; + } + /* * Pick a gap count from 1394a table E-1. The table doesn't cover * the typically much larger 1394b beta repeater delays though. --=20 2.48.1 From nobody Thu Oct 2 07:49:13 2025 Received: from fhigh-b1-smtp.messagingengine.com (fhigh-b1-smtp.messagingengine.com [202.12.124.152]) (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 C499A301712 for ; Thu, 18 Sep 2025 23:09:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.152 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758236953; cv=none; b=EcHoIrUkb9oBgaiofVzH4dJJNSh036LbgFr5Vmxz9p/oknYg6F/PbEP9MecOD7Rz0gYxeBW0BrQRa7mP3FkI3O0jB6GqKjqVisAwBiUyKqMJF/Tkwhu4ouZYwSw/973TYxeIxc1kI5BmJbbX3JMvn80mtI4/DMmsBwTeHuGMKPw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758236953; c=relaxed/simple; bh=wXuzmBeHQCbrEXrGHzKM5GsfOsCiIEOjthhJzG1Jgt0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ppbHoE+Lk1QUr/DaeWZAaI594eyZHuAQEoUyJDhmOpi180nzDqUC+pVFWr0RIS1PPKpr89D/E1uf36qJww4ZlzkUil0LApIcthumFrAODk+kulRW7Ktht4nSIkLXJQQhrdzQOZoYfmiSrIXBYgRfgOISiQKZnQC/UVHgZDEhvCo= 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=TY/JoQQG; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=cgMW4giY; arc=none smtp.client-ip=202.12.124.152 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="TY/JoQQG"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="cgMW4giY" Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfhigh.stl.internal (Postfix) with ESMTP id E5A707A02B2; Thu, 18 Sep 2025 19:09:10 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Thu, 18 Sep 2025 19:09:10 -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=1758236950; x= 1758323350; bh=VYxaUYksUwdGiqYdR3vXLvnRMCgLcjZN4Q57x7wxBzY=; b=T Y/JoQQGcFnCYNJoDErIzH3XZbTaX2nw2A5b/at251+xv6LLYgxBKlTxIpmY1xULG j8j36eZsOGBG5DCtNTTZhWxNYfv2EzWmLx6bm8V7IwwH+KcRrPMSLuVf0hTxzVdb Rm91+WM8IvoQXJE2bu6emraaNfgly2cO1lpRPCMV+gkfY/eCuQ4bGjct9P5YQofc bx+989fldwacmRBMXRnmw44hkRH4fAwr93mSkvLKrGHsujJ1+RNriBysX3RgIkv4 h2wt1Hq2BqjKBnW8Ouix+6bEXp1xQiaOI0zeAjbse/iRWzcy60tArq5RdtKs6l4F xTPgiK6TcUpG4M+pIVLfg== 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=1758236950; x=1758323350; bh=V YxaUYksUwdGiqYdR3vXLvnRMCgLcjZN4Q57x7wxBzY=; b=cgMW4giYZEStddj63 sq2m3l0Xx2rZOEKqzF5poXuFk8EaEUDRCXFh6v/Uyn50ia4FTKlpjs/qqr/WxgU7 3TnSOrHDyouQDDjEivKwt8PGjM8dn7aAxvpxutWHIui/fj/Z0SQddXKf59WqiO7x HIBXNYOb0Ukj3L7rUHXkxw1JhLKtZLzNtMjCN+AIoRDvZ1tU4U/NDHTJavqqmuWQ pEyAVqhp7Id1ziWCB5hzOrW5nhNJ1BjXkEdMvCtHVvh1+6mFvbj4NCaMtjN/qsj+ EQyWJVRPNMm98xCVyxUdE8Z6InOfF6t+HpfTWFPpiYTZMXNAhdD3ALs6Tsqe9U54 0TNRA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdegjeeiudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghr rdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 18 Sep 2025 19:09:09 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 5/6] firewire: core; eliminate pick_me goto label Date: Fri, 19 Sep 2025 08:08:56 +0900 Message-ID: <20250918230857.127400-6-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250918230857.127400-1-o-takashi@sakamocchi.jp> References: <20250918230857.127400-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" This commit uses condition statements instead of pick_me goto label. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 102 ++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 50 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index 6268b595d4fa..b766ce5fdea4 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -388,6 +388,7 @@ static void bm_work(struct work_struct *work) int root_id, new_root_id, irm_id, local_id; int expected_gap_count, generation; bool do_reset =3D false; + bool stand_for_root; =20 if (card->local_node =3D=3D NULL) return; @@ -408,11 +409,11 @@ static void bm_work(struct work_struct *work) fw_schedule_bm_work(card, msecs_to_jiffies(125)); return; case BM_CONTENTION_OUTCOME_IRM_HAS_LINK_OFF: - new_root_id =3D local_id; - goto pick_me; + stand_for_root =3D true; + break; case BM_CONTENTION_OUTCOME_IRM_COMPLIES_1394_1995_ONLY: - new_root_id =3D local_id; - goto pick_me; + stand_for_root =3D true; + break; case BM_CONTENTION_OUTCOME_AT_NEW_GENERATION: // BM work has been rescheduled. return; @@ -423,8 +424,8 @@ static void bm_work(struct work_struct *work) return; case BM_CONTENTION_OUTCOME_IRM_IS_NOT_CAPABLE_FOR_IRM: // Let's do a bus reset and pick the local node as root, and thus, IRM. - new_root_id =3D local_id; - goto pick_me; + stand_for_root =3D true; + break; case BM_CONTENTION_OUTCOME_IRM_HOLDS_ANOTHER_NODE_AS_BM: if (local_id =3D=3D irm_id) { // Only acts as IRM. @@ -434,60 +435,61 @@ static void bm_work(struct work_struct *work) case BM_CONTENTION_OUTCOME_IRM_HOLDS_LOCAL_NODE_AS_BM: default: card->bm_generation =3D generation; + stand_for_root =3D false; break; } } =20 - /* - * We're bus manager for this generation, so next step is to - * make sure we have an active cycle master and do gap count - * optimization. - */ - if (card->gap_count =3D=3D GAP_COUNT_MISMATCHED) { - /* - * If self IDs have inconsistent gap counts, do a - * bus reset ASAP. The config rom read might never - * complete, so don't wait for it. However, still - * send a PHY configuration packet prior to the - * bus reset. The PHY configuration packet might - * fail, but 1394-2008 8.4.5.2 explicitly permits - * it in this case, so it should be safe to try. - */ - new_root_id =3D local_id; - /* - * We must always send a bus reset if the gap count - * is inconsistent, so bypass the 5-reset limit. - */ - card->bm_retries =3D 0; - } else { - // Now investigate root node. - struct fw_device *root_device =3D fw_node_get_device(root_node); - - if (root_device =3D=3D NULL) { - // Either link_on is false, or we failed to read the - // config rom. In either case, pick another root. - new_root_id =3D local_id; + // We're bus manager for this generation, so next step is to make sure we= have an active + // cycle master and do gap count optimization. + if (!stand_for_root) { + if (card->gap_count =3D=3D GAP_COUNT_MISMATCHED) { + // If self IDs have inconsistent gap counts, do a + // bus reset ASAP. The config rom read might never + // complete, so don't wait for it. However, still + // send a PHY configuration packet prior to the + // bus reset. The PHY configuration packet might + // fail, but 1394-2008 8.4.5.2 explicitly permits + // it in this case, so it should be safe to try. + stand_for_root =3D true; + + // We must always send a bus reset if the gap count + // is inconsistent, so bypass the 5-reset limit. + card->bm_retries =3D 0; } else { - bool root_device_is_running =3D - atomic_read(&root_device->state) =3D=3D FW_DEVICE_RUNNING; + // Now investigate root node. + struct fw_device *root_device =3D fw_node_get_device(root_node); =20 - if (!root_device_is_running) { - // If we haven't probed this device yet, bail out now - // and let's try again once that's done. - return; - } else if (root_device->cmc) { - // We will send out a force root packet for this - // node as part of the gap count optimization. - new_root_id =3D root_id; + if (root_device =3D=3D NULL) { + // Either link_on is false, or we failed to read the + // config rom. In either case, pick another root. + stand_for_root =3D true; } else { - // Current root has an active link layer and we - // successfully read the config rom, but it's not - // cycle master capable. - new_root_id =3D local_id; + bool root_device_is_running =3D + atomic_read(&root_device->state) =3D=3D FW_DEVICE_RUNNING; + + if (!root_device_is_running) { + // If we haven't probed this device yet, bail out now + // and let's try again once that's done. + return; + } else if (!root_device->cmc) { + // Current root has an active link layer and we + // successfully read the config rom, but it's not + // cycle master capable. + stand_for_root =3D true; + } } } } - pick_me: + + if (stand_for_root) { + new_root_id =3D local_id; + } else { + // We will send out a force root packet for this node as part of the gap= count + // optimization on behalf of the node. + new_root_id =3D root_id; + } + /* * Pick a gap count from 1394a table E-1. The table doesn't cover * the typically much larger 1394b beta repeater delays though. --=20 2.48.1 From nobody Thu Oct 2 07:49:13 2025 Received: from fhigh-b2-smtp.messagingengine.com (fhigh-b2-smtp.messagingengine.com [202.12.124.153]) (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 7ABB52F5A19 for ; Thu, 18 Sep 2025 23:55:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758239704; cv=none; b=SmfAeBYy+LOwix6tBVGSOn6wus5QpBpzbVtVLi6KRi6R7XGlaCbYQXXHTS5qyNK/McW2ghvmiBWN2wamTRSwDPLTVYo3zkZhrkrqig6VRBq99qPVUqmABoJkIc+WnWfCfGhRkPEErrvYJ8wvDeLLznY3AOgd6gYgs35P8c5OYFA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758239704; c=relaxed/simple; bh=uECkJXUPwFb7rYrOSXuFNLXpq3z/zzqrZrzZMpFEJs8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pHnErlq+J84CETifUPpfJEZokb4rvNO93kkGrHHRluCGyy/CCiQamC1r1ojyjZzw1/Gh1RT7i3qLUWdBHoXdjTkk8t36X2a8gZ13Wwyegb+FjsTGzntfQOpQABFIBZKYrybxqefesU/sdD0XggXCL5cQZzH8p8ANJB7g2nH9jWg= 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=kB3PAg9q; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=PmSWAcG2; arc=none smtp.client-ip=202.12.124.153 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="kB3PAg9q"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="PmSWAcG2" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id 96D997A02DF; Thu, 18 Sep 2025 19:55:01 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Thu, 18 Sep 2025 19:55:01 -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=1758239701; x= 1758326101; bh=xzYwZqfvPW6KOoTt5TjmQYlp4Q4mwY00/jLyNK2kg1E=; b=k B3PAg9qsv6oNBrBk+UkeJv18rGi1MwzulVq9eQVeGb/yjm72NDVV/kn86qs09Sbt tP5LY8iEVEBCa8hdsrTVk7phpuhh4g2zt6suBkJvWAfzNQ9WvGH/wrXiwSHm+Qpw TbV5x8y8c44E0y7+UDqXYnUp0pR8ubqrikEJYPI7fHYCLOhXk4zv0HYvGagZ2zT4 GYK+JT1ksZrkPmZDNibObQr19/GkNoN3fcaFCLdHXD4vAiUlkrhL4eKY533/o2Qo tLyNb5MJ5dvdyeKhrKNagb8AmzizJe73aQJBt+i/GbAxzkk8GRPfuiolLss/ij+S EURCvhlPX6RbHbv/ILHRw== 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=1758239701; x=1758326101; bh=x zYwZqfvPW6KOoTt5TjmQYlp4Q4mwY00/jLyNK2kg1E=; b=PmSWAcG2BqkDxrtKL oIUplyKeBbFVNH+Y3CFCW3GBLERXYu8hK4Lg+fkaR3mzM6VJdH7Dat/8s20CDx3V fHN2p2IDsRvsQnIGDtR26ujjxa3cV9B0FOoyTd5tkONf/ZpaqRR7KB+jzVi/iFZe bKcBL06/Zsn79uF5cjHv6Z4hSGO5iSsxYIqlyhU8brgWes/fCM1gD9pkIH/YtkHG hq64ClGoLxh/akk0Ur2HnrKi8iK9DqWxYcZz1Mf44XiZ84T8WJMIBavh9FwyI6xC tn54H1cUTa6xwJrQk1QJXq7HSMl/1gp65+PcVqXmpKstyZmk3sZliQmU1vK4g0jw R7YBQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdegjeejtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghr rdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 18 Sep 2025 19:55:00 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2 6/6] firewire: core: minor code refactoring to delete useless local variable Date: Fri, 19 Sep 2025 08:54:48 +0900 Message-ID: <20250918235448.129705-7-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250918230857.127400-1-o-takashi@sakamocchi.jp> References: <20250918230857.127400-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 do_reset local variable has less merit. Let's remove it. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index 58d1f58a4a0f..4a5459696093 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -387,7 +387,6 @@ static void bm_work(struct work_struct *work) struct fw_node *root_node __free(node_unref) =3D NULL; int root_id, new_root_id, irm_id, local_id; int expected_gap_count, generation; - bool do_reset =3D false; bool stand_for_root =3D false; =20 if (card->local_node =3D=3D NULL) @@ -499,16 +498,10 @@ static void bm_work(struct work_struct *work) else expected_gap_count =3D 63; =20 - /* - * Finally, figure out if we should do a reset or not. If we have - * done less than 5 resets with the same physical topology and we - * have either a new root or a new gap count setting, let's do it. - */ - - if (card->bm_retries++ < 5 && (card->gap_count !=3D expected_gap_count ||= new_root_id !=3D root_id)) - do_reset =3D true; - - if (do_reset) { + // Finally, figure out if we should do a reset or not. If we have done le= ss than 5 resets + // with the same physical topology and we have either a new root or a new= gap count + // setting, let's do it. + if (card->bm_retries++ < 5 && (card->gap_count !=3D expected_gap_count ||= new_root_id !=3D root_id)) { int card_gap_count =3D card->gap_count; =20 fw_notice(card, "phy config: new root=3D%x, gap_count=3D%d\n", --=20 2.48.1 From nobody Thu Oct 2 07:49:13 2025 Received: from fout-b1-smtp.messagingengine.com (fout-b1-smtp.messagingengine.com [202.12.124.144]) (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 75D8D30DD14 for ; Thu, 18 Sep 2025 23:09:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758236955; cv=none; b=b32q0gaE40b3MBTkB6TWnA2P04e+af3FdcTLRm+D4MLyPXxXXLUnt1krMAeIzFkQu9NDT1eimIHUjIYEV2HYYTimh6o4R9j1oo6/+5W3WwgfvuqxSdVd+tzbusyVE4Zs7zSbH8xnZHXjg2+3cHgTEySmrDgfwrDsdA8D2aN5blU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758236955; c=relaxed/simple; bh=St2b7cHSZC3ZZZPxW7dlg77nj7MUjvqV85jPkIhwpBM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L+T8mLKoOdUjzfhlVCnPX7pfVBPNUo+h5nVPRX11UzYowM/JG2F6A1V+KvsYkN4+3T5h2V/ToBxJ1qkrL0vT58Cbzo0Qd2+qte06RUYTrUCF8bNUhMSvpfAMcA7oQRE4G0OIv1/s1dorHMZCK9UoWKccKiMrRtiKxx1aKD/jgXc= 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=YV1y0l/d; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=K9s7FSdW; arc=none smtp.client-ip=202.12.124.144 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="YV1y0l/d"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="K9s7FSdW" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.stl.internal (Postfix) with ESMTP id 8375C1D002D6; Thu, 18 Sep 2025 19:09:12 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Thu, 18 Sep 2025 19:09:12 -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=1758236952; x= 1758323352; bh=RAKnE91e6mZe7mbb83yvaKy3djJ4JJZGxtMDS0v5CI4=; b=Y V1y0l/d4Qq2dM4gc2qpDojKYx3mUPlF0AUD3lWESgWHzNd0idz06ykcnNodldlXn KdWZTX2Rw+Sb4GKR4Rhl33pfuZtHzDV0C4wvBp9RHEBpICKEEoOc28sf6JvyNJ53 xtov5nZYpIFm4HshpJ65QyiL/jiVwZ3vH2baZDAFSdupr+0BpNYaPlBf1jrnV3e+ Eo5+vBsnZ0iXqt2gbo/4rfsvwwwhhIcuapKhqz5G16uaS6GisOnvUNhpLypi2vrx NquPgo0FAuWk/xYDQr8WkueIZZUeNtLnEZhPMEJGIVQgUUCBIVLZh9uVxL5S7g4V sCUf3DKRQpyddkInnkjsQ== 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=1758236952; x=1758323352; bh=R AKnE91e6mZe7mbb83yvaKy3djJ4JJZGxtMDS0v5CI4=; b=K9s7FSdWM2VwwlV7H a5VDrxwp0ObA5Q0V1cqnxLbqQz7oo6lSiEzQc6Z86gc/8gP0n/tnrbfV7QdQAac0 o6G10/VntjxSHaSddANqcqsW1ZHPZvW7bSHRISYdG6LXqcfDFppO6SWZbqTI6UQ8 USTQ63icdYvg7oQCKX2wlP8I3AeBgDuxJE2CV8oVdBWNabA1trdAb+03NrAtEDtF 0pYNtZjRFuqvpUE+DroHCZE+2b1kyYPqUThbBduaszNZME8i0sJiRYIJpyU88O+T gUkdyhTCoFZ9t4esGDSGNadvJQURT+zaB3tJW/ZG5DtwNYanQCZaIpCOD0MWbMMu VpN7A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdegjeeiudcutefuodetggdotefrod 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; Thu, 18 Sep 2025 19:09:11 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 6/6] firewire: core: minor code refactoring to delete useless local variable Date: Fri, 19 Sep 2025 08:08:57 +0900 Message-ID: <20250918230857.127400-7-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250918230857.127400-1-o-takashi@sakamocchi.jp> References: <20250918230857.127400-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 do_reset local variable has less merit. Let's remove it. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index b766ce5fdea4..527a99ef7c90 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -387,7 +387,6 @@ static void bm_work(struct work_struct *work) struct fw_node *root_node __free(node_unref) =3D NULL; int root_id, new_root_id, irm_id, local_id; int expected_gap_count, generation; - bool do_reset =3D false; bool stand_for_root; =20 if (card->local_node =3D=3D NULL) @@ -500,16 +499,10 @@ static void bm_work(struct work_struct *work) else expected_gap_count =3D 63; =20 - /* - * Finally, figure out if we should do a reset or not. If we have - * done less than 5 resets with the same physical topology and we - * have either a new root or a new gap count setting, let's do it. - */ - - if (card->bm_retries++ < 5 && (card->gap_count !=3D expected_gap_count ||= new_root_id !=3D root_id)) - do_reset =3D true; - - if (do_reset) { + // Finally, figure out if we should do a reset or not. If we have done le= ss than 5 resets + // with the same physical topology and we have either a new root or a new= gap count + // setting, let's do it. + if (card->bm_retries++ < 5 && (card->gap_count !=3D expected_gap_count ||= new_root_id !=3D root_id)) { int card_gap_count =3D card->gap_count; =20 fw_notice(card, "phy config: new root=3D%x, gap_count=3D%d\n", --=20 2.48.1