From nobody Sun Jun 14 07:49:10 2026 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 734E13BF675 for ; Fri, 1 May 2026 13:58:29 +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=1777643911; cv=none; b=Q1Ctyzg3ffZCXHrEiTPYV/KOwUA3FGYrUh9SimeB0t1YubqD16hCFRpWf0jzOBdIXqR/Qu1Y/RZ/KibWyYa7EReSDq4j2WB5ggjHeeUxtvCvu/9PCE56FC5z6rQZ0+JRCiMa+EzPe3Vi6lGW7enRalFnQMKB0WyUjS3J2vhSwss= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777643911; c=relaxed/simple; bh=Nsqs/J/RbeyF9uGUPfjRRpBgzCicJThbgW2Fw58zcdQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nRwHajufWPz5E28YYB2XXd9AwOGGxz4KyyMaZpl3FzHqt88fkBPthU8vHv1Y12jl/kfcRwIb3N2L21oYOwyRl7yaRgYQMWhc+VMHxQFA/0brwv/kaXvgxPDX+tYwA+8iIl50wZJVsI97ZGdZlsyHUcSc9to2egBaUpvKDY1HoOE= 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=Zs7K6Trg; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=cCykyI5N; 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="Zs7K6Trg"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="cCykyI5N" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id C69A77A00CB; Fri, 1 May 2026 09:58:28 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Fri, 01 May 2026 09:58:28 -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=fm3; t=1777643908; x= 1777730308; bh=yP4/WkwoDV7wTaYoVfglgXjwLcswPBb2/EQ8z+42nuc=; b=Z s7K6Trgq87LhrLN6Frsp/XD30qCALJQSzeAgUUXYJkHHzNVbAf66mw80aqNbyYiF CqvfVfJm7M95QeldnVpQ8GJVDqvhYnYpD8tzjIlkKBuIIypt0FIpynIKjIa7U/U5 VA4+XeT9CP3voQCQgMtWP4a7u2C/MJVJNbEtcDJ2ABJQtiAMOs7+ITirYrvZJg4a CSfuzoFDzqJdeqUd4raxbH0TwvUe4eSaYlIsERMJjL9RT5AFlwtrC57NUNzF15yz nCTz3iUlWIX561nrYmIFqfoLKHim8jM6205ydoFLEVQBbgx0Yw/Vyju96+Rtafdg nULyK2/zskT0teJpZprhQ== 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=fm3; t=1777643908; x=1777730308; bh=y P4/WkwoDV7wTaYoVfglgXjwLcswPBb2/EQ8z+42nuc=; b=cCykyI5NFx5cUtfRi ak/gzFrWh8EY70lbg/QTkPzNI1ec3kblZkzGcQ/r64h0Fy4C6fvUP54zqZkikCSn SgKBiUcXFk8fRAEnt/hsxsthF6Znb/iaqminaRP8l1wq4EhxKqPY94FOU4W50Q1q ncKIPPW3OGpa5DflReig0hBFMrBuEkGXVNmowcVMVCMIVLlHVbEftSOiRBsc8jNh TB7iJ3lCAM+FxTO/Am7Jt9sqcaV0IjVt4xoznScwd7AhTtuPL3HH53USQllaimKh Fuic6u56/93d3p1krjDGplpmGUlIdbjIfGjADaorpvZTf6IDBg3/MQm913Rbb27K 0rS0g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdeltdefkecutefuodetggdotefrod 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; Fri, 1 May 2026 09:58:27 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 1/4] firewire: core: reduce critical section duration in pre-processing of isoc resource management in cdev Date: Fri, 1 May 2026 22:58:20 +0900 Message-ID: <20260501135823.241940-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260501135823.241940-1-o-takashi@sakamocchi.jp> References: <20260501135823.241940-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" It is preferable for the critical section to be as small as possible. Current implementation of iso_resource_auto_work() function uses a spinlock to control concurrent access to members of fw_card, fw_device, iso_resource_auto structures, however the locking duration could be reduced. This commit refactors to shorten that duration. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-cdev.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index bcfb20b770df..887783e4bd52 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -1329,32 +1329,36 @@ static void iso_resource_auto_work(struct work_stru= ct *work) struct iso_resource_auto *r =3D from_work(r, work, work.work); struct client *client =3D r->client; unsigned long index =3D r->resource.handle; - int generation, channel, bandwidth, todo; + int current_generation, resource_generation, channel, bandwidth, todo; + u64 reset_jiffies; bool skip, free, success; =20 scoped_guard(spinlock_irq, &client->lock) { - generation =3D client->device->generation; + reset_jiffies =3D client->device->card->reset_jiffies; + current_generation =3D client->device->generation; + resource_generation =3D r->params.generation; + r->params.generation =3D current_generation; todo =3D r->todo; - // Allow 1000ms grace period for other reallocations. - if (todo =3D=3D ISO_RES_AUTO_ALLOC && - time_is_after_jiffies64(client->device->card->reset_jiffies + secs_t= o_jiffies(1))) { - schedule_iso_resource_auto(r, msecs_to_jiffies(333)); - skip =3D true; - } else { - // We could be called twice within the same generation. - skip =3D todo =3D=3D ISO_RES_AUTO_REALLOC && - r->params.generation =3D=3D generation; - } - free =3D todo =3D=3D ISO_RES_AUTO_DEALLOC; - r->params.generation =3D generation; } =20 + // Allow 1000ms grace period for other reallocations. + if (todo =3D=3D ISO_RES_AUTO_ALLOC && + time_is_after_jiffies64(reset_jiffies + secs_to_jiffies(1))) { + schedule_iso_resource_auto(r, msecs_to_jiffies(333)); + skip =3D true; + } else { + // We could be called twice within the same generation. + skip =3D todo =3D=3D ISO_RES_AUTO_REALLOC && + resource_generation =3D=3D current_generation; + } + free =3D todo =3D=3D ISO_RES_AUTO_DEALLOC; + if (skip) goto out; =20 bandwidth =3D r->params.bandwidth; =20 - fw_iso_resource_manage(client->device->card, generation, + fw_iso_resource_manage(client->device->card, current_generation, r->params.channels, &channel, &bandwidth, todo =3D=3D ISO_RES_AUTO_ALLOC || todo =3D=3D ISO_RES_AUTO_REALLOC); --=20 2.53.0 From nobody Sun Jun 14 07:49:10 2026 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 B97FA3BF699 for ; Fri, 1 May 2026 13:58:30 +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=1777643912; cv=none; b=CiIfRmzkRNcSD4AuMedPiwJdXWx4ePiImPZ/Qk3YbU8lJiAnJNTWo0hAwxzLNs1DXy/yNIvDvAQKJ0Sk6EZyKG4ZDKkG0iEALUo/SRIXQ0ghEK8JPSwTybDZNuGpELaOpGVUP0RIMZ7rOxd5v6DmqbNgwTRuSCFTbodpLd3Wh20= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777643912; c=relaxed/simple; bh=gDwByUWoeT8At4wf5Ac2qVBBdT3uJwJQyhECPhuo/PI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L3Nbdrp+v1OhzteC4j8CK/RhU1+ji32DH0lNTC+9gcGWHlKCWflatG3Vxec+a8FcUTNv9YL2SWiWrFmfEAS0i9Li4FZcxM3w5xyh2ZzwQdgKKefJ2JliD3KPtUPDe1JTdGfmAZWhkdIbmUAOJpYLIqhY7jCrGALOVNrWqOOh7vk= 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=oc8snJo2; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=qsF0UCr4; 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="oc8snJo2"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="qsF0UCr4" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.stl.internal (Postfix) with ESMTP id 310D41D00107; Fri, 1 May 2026 09:58:30 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Fri, 01 May 2026 09:58:30 -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=fm3; t=1777643910; x= 1777730310; bh=2k34AQgQBKDdUYmfnYGoLCcisq3/RTFNeaJ6w1tFMlo=; b=o c8snJo2QbzcXb3DDrIM8iirhmgNJ/uSDOiKNxAcjvES1ku5vorjgKOqz9Y9f7NTO Kn68qbwCYu7iTNGzPkByw0fR9qU7WDvQVeWjTSeb4ZNPayOovFwM6erab9zYJQKA WXZyCXIOWqUgI4sz1w1Qp4jgz+M0TULPIFSJj+2k8Bjxv23IwIJB6zNyjxbnWGO8 vZ2tKera6FWGb9EiGWUjKmWuj6TzLwh6ajGWHL0bwWv3FI/RnaC+5JHyx+Cyw3Xc b0Ly3QJbpJCYIwROI88w1Md7l0aWJbv9cTKfQjyKwrR5fOXQPN1kdJZjZRamTlFJ JfRmGPmRdXr2IoVdRBKDQ== 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=fm3; t=1777643910; x=1777730310; bh=2 k34AQgQBKDdUYmfnYGoLCcisq3/RTFNeaJ6w1tFMlo=; b=qsF0UCr4x6DIdKfcl ymL/iH4/gIEiwD/Jz5J2qOCwxh25DJhneVHSRFU397pjLy3xN694C2bMcsIU0zwC Fc5eJ6PBekhrkI/ACqxGDEj52XmbGaC+WMnExs3SMT95xN7CCNRBK+1nhN3DllYL ADccJxDA/tXv5qpQa/RNxSu5Ozhx6AO037BH8qppeXsRqgJ0y6DSsOZ2WajkSJL4 f2zmE7g8EQJYvsoSnE03D+2g2B7FLwUj08SQIm7CMrzoqLmGkuNxZ5Yk98YbQMpo ITZxA+r7y6+tKAz8NGsobheEGHvS0lPRSkBj14+1JgIQgVn8zbfxP7QNAbhN9T5z S2FQw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdeltdefkecutefuodetggdotefrod 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; Fri, 1 May 2026 09:58:29 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 2/4] firewire: core: use switch statement for post-processing of isoc resource management in cdev Date: Fri, 1 May 2026 22:58:21 +0900 Message-ID: <20260501135823.241940-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260501135823.241940-1-o-takashi@sakamocchi.jp> References: <20260501135823.241940-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 iso_resource_auto structure object has three states. The current implementation of state evaluation before managing the actual isochronous resources can be improved. This commit refactors the evaluation logic using a switch statement. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-cdev.c | 37 +++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index 887783e4bd52..0d57b61ade12 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -1331,7 +1331,7 @@ static void iso_resource_auto_work(struct work_struct= *work) unsigned long index =3D r->resource.handle; int current_generation, resource_generation, channel, bandwidth, todo; u64 reset_jiffies; - bool skip, free, success; + bool free =3D false, success; =20 scoped_guard(spinlock_irq, &client->lock) { reset_jiffies =3D client->device->card->reset_jiffies; @@ -1341,27 +1341,29 @@ static void iso_resource_auto_work(struct work_stru= ct *work) todo =3D r->todo; } =20 - // Allow 1000ms grace period for other reallocations. - if (todo =3D=3D ISO_RES_AUTO_ALLOC && - time_is_after_jiffies64(reset_jiffies + secs_to_jiffies(1))) { - schedule_iso_resource_auto(r, msecs_to_jiffies(333)); - skip =3D true; - } else { + switch (todo) { + case ISO_RES_AUTO_ALLOC: + // Allow 1000ms grace period for other reallocations. + if (time_is_after_jiffies64(reset_jiffies + secs_to_jiffies(1))) { + schedule_iso_resource_auto(r, msecs_to_jiffies(333)); + goto out; + } + break; + case ISO_RES_AUTO_REALLOC: // We could be called twice within the same generation. - skip =3D todo =3D=3D ISO_RES_AUTO_REALLOC && - resource_generation =3D=3D current_generation; + if (resource_generation =3D=3D current_generation) + goto out; + break; + case ISO_RES_AUTO_DEALLOC: + default: + break; } - free =3D todo =3D=3D ISO_RES_AUTO_DEALLOC; - - if (skip) - goto out; =20 bandwidth =3D r->params.bandwidth; =20 - fw_iso_resource_manage(client->device->card, current_generation, - r->params.channels, &channel, &bandwidth, - todo =3D=3D ISO_RES_AUTO_ALLOC || - todo =3D=3D ISO_RES_AUTO_REALLOC); + fw_iso_resource_manage(client->device->card, current_generation, r->param= s.channels, + &channel, &bandwidth, todo !=3D ISO_RES_AUTO_DEALLOC); + /* * Is this generation outdated already? As long as this resource sticks * in the xarray, it will be scheduled again for a newer generation or at @@ -1398,6 +1400,7 @@ static void iso_resource_auto_work(struct work_struct= *work) e =3D r->e_alloc; r->e_alloc =3D NULL; } else { + free =3D true; e =3D r->e_dealloc; r->e_dealloc =3D NULL; } --=20 2.53.0 From nobody Sun Jun 14 07:49:10 2026 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 1ED5A3BFE3F for ; Fri, 1 May 2026 13:58:32 +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=1777643914; cv=none; b=AtNeJbZlrpKIv8qhiZ5HWtPZxuExPsPZH9GxGDavhhrLW73NGjHFABzS/xp1mjSG83qCcClXM0+Kmxl/lh0x/XiIgu9K5Re0CfN9zp5FRyjVSHzOOG4+YHdXkcIKlVd8a7WoEExUp+0xs3AOVT0fmQaA7uhDWMF1UXACaIpyo5o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777643914; c=relaxed/simple; bh=IqHTAKspRD1IVfrtk3uBBrtmy/ZW/wRQpjSc9/Zy6NY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b9XSrrW/g8uNjp/tmbDc6MwicY9BsV6f075LgRBdRtPTUQ+15+LRShTHBLs4M09m/NMdmIyVYpXa8HSROhmsUsjByjmm0ekH1kxik2oqQFwkWAF0mCvPge/sz//TSXnaaujUaISFBhG9tGzB19yDxogbLT6o1K6bZV9xUMO+6uU= 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=rXNfs74f; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Gz8Z+5GQ; 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="rXNfs74f"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Gz8Z+5GQ" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id 894577A0087; Fri, 1 May 2026 09:58:31 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Fri, 01 May 2026 09:58:31 -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=fm3; t=1777643911; x= 1777730311; bh=uojPCuE4kirNqPd4RC4rH9WIYRHt2M7diKe8bhLfrsg=; b=r XNfs74f8V64ZdDLTnRLFAVXWoYSFgykxACjIU1Dul4gFg+ZWQDzpE0AE/BuhA/mz rNEr0STbMPbOQPutn/hfgzAmPX9Wa+c6OxGCSZkcwVQF5JKZH+uRkjlZlxrJOnkC nJE8vi5zoXGrCpqxYS6YItwtTJbc1dzqYQjO1LVypEacuXAjA2ttVv4yjN3hdxSC tTJXaVRpK3Xt5CRprs4y8hJYx1wBBKCOd2OyS1IFmWYoV6IvebIgt04Z5NoMsHUX 2UTKNWg6MBErG+oiF4t5pIrqR5CP4R2Xazqk7AHSdbD+WMFKJ+DtTlQugt1CKMCT rA9LM7L2VXhVBzLQVykcw== 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=fm3; t=1777643911; x=1777730311; bh=u ojPCuE4kirNqPd4RC4rH9WIYRHt2M7diKe8bhLfrsg=; b=Gz8Z+5GQDVPrYJzd9 gsosfhIRpx2l9Z22MriTPv7uw50qqmqDBLSlYbnk+V0kGU/2G4YVlzeMb5kMbRyp 4zabR/kh4dF1qrF3h05AKXE/aS5WDSF0cCl4TRy9QmkWY26bwbmUbTx49/MqqFnL M6ZXjlnooGdcFJrPEO/10aNZi11IuSACnJB29WnwlUcQMwHbXqVRLb2A/lKKOxMt TdSff4YrSu9ZFvQJ3pnC4A3j41xXbcQSDD+v8GTQcMlq10+IraDaFxRhAA/dCapW e8qHhM1xxadzA9CEzfLhpC7D4ddS5KVIE7o8F9IXoLP2t3hgyGe4bbIaS9d+gP2h cY2Hw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdeltdefkecutefuodetggdotefrod 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; Fri, 1 May 2026 09:58:30 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 3/4] firewire: core: refactor notification type determination after isoc resource management in cdev Date: Fri, 1 May 2026 22:58:22 +0900 Message-ID: <20260501135823.241940-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260501135823.241940-1-o-takashi@sakamocchi.jp> References: <20260501135823.241940-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" After managing the actual isochronous resources, there is post-processing logic to determine what type of event should be notified. However, there is room for improvement. This commit refactors the logic. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-cdev.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index 0d57b61ade12..4ce8754da93f 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -1390,20 +1390,27 @@ static void iso_resource_auto_work(struct work_stru= ct *work) } } =20 - if (todo =3D=3D ISO_RES_AUTO_ALLOC && channel >=3D 0) - r->params.channels =3D 1ULL << channel; - - if (todo =3D=3D ISO_RES_AUTO_REALLOC && success) - goto out; - - if (todo =3D=3D ISO_RES_AUTO_ALLOC) { - e =3D r->e_alloc; - r->e_alloc =3D NULL; - } else { + if (todo =3D=3D ISO_RES_AUTO_DEALLOC) { free =3D true; e =3D r->e_dealloc; r->e_dealloc =3D NULL; + } else { + if (todo =3D=3D ISO_RES_AUTO_REALLOC) { + if (success) + goto out; + + // Notify the userspace client of the failure through a deallocation ev= ent. + e =3D r->e_dealloc; + r->e_dealloc =3D NULL; + } else { + if (channel >=3D 0) + r->params.channels =3D 1ULL << channel; + + e =3D r->e_alloc; + r->e_alloc =3D NULL; + } } + e->iso_resource.handle =3D r->resource.handle; e->iso_resource.channel =3D channel; e->iso_resource.bandwidth =3D bandwidth; --=20 2.53.0 From nobody Sun Jun 14 07:49:10 2026 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 92F233BFE4C for ; Fri, 1 May 2026 13:58:33 +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=1777643916; cv=none; b=AJCzVN/yg1UG0ErjEyUPxJ0OEEe559GYj5cCIYe90bdcvS9sFNyGW3HvGp8xoxbQtzFa4yy0IZSwWlis5Gifh61jhUd+SgT57wy//ZWTWtKLu5vmfyEa1IJVJySyYKpiu1rR1WpYmL7nntRBryOoCPTekPVhVRoi42TpfSEO8kA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777643916; c=relaxed/simple; bh=LS1L9/uG/ACFkxiIkEZ1R8YciJcWkXGgUnhZQMOytuY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n3mXYeBABqyzhq5n2HAfSEFNWb4SIKN96RwWl0Zc+jSsyEhoQHjvkjUsszVQzJ+8m1Jbwm0L/ujJtxgucwbPSwNDSqYkTOGg1GJbS9MZqSEO2sihhOdH3/FmwEr4eZgDhpjaQlMM7KVJqPyU1GeZEjfveDruQE/+Zx1tGFb+HxY= 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=pUdr3Zxy; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=cq10QSMm; 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="pUdr3Zxy"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="cq10QSMm" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id D39807A00D7; Fri, 1 May 2026 09:58:32 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Fri, 01 May 2026 09:58:32 -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=fm3; t=1777643912; x= 1777730312; bh=Th5S91UAIDprKOAcqeblHzt8y0T+mD9ozKWgcZSujhQ=; b=p Udr3Zxye4WZecCeMiKjY2fjZx+BktHkNJWBgwi7cih0ZLHh4iKdbi84O5CJs78qd O5mpOAGtW2VKtSVNrXEyVljl0vt6QVfuyYAzXqExyaY/hdrOJ4JVdsxSrmzLubNs sY+7G4lhADVJL1K88DX7XvEPX16K8a2AbJiaPBf+obzkSV6/3iFNmFGFnZbQXIsH EuvE+RyvtNmvlSaw9muTbDUfdqG2x7/2ryhAPAbrdXSg3GUjuJZQ5tGMZ/VuxEr7 78EPSH7Sv+KQ/qNitoH1sjK7otN5rwHzNq6lJTY8tVfXCcdCpXtcbP8yndtlTV0J CNVc1xfKZ/0O8vdo6rjaw== 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=fm3; t=1777643912; x=1777730312; bh=T h5S91UAIDprKOAcqeblHzt8y0T+mD9ozKWgcZSujhQ=; b=cq10QSMmpR1IfG1rD pv9YFBvAWdoOEdkjpj7C0oJkJ3rvaOvQuJdIhMJ7tOao0M0y9Zn8JOTytpHeq2Uq Hgcf7cz4nUUTYKGJFlqL0NSuM9L164JbmiLrKQ+y/DwRoWf7/2YjX7z+1As3ONoj B3H6x64U7gWn0L1Z6S+oZ6rl/o+N7JQjMrti2ExBV/lzollBFf0clCS6b+cpsyeV /0pM3TnAqLgIOLDFDgxSQZf7yy9PUJ6zOoUAwTfldJl1AaFlMfF9v29rCP+z9Jjg 2Jx+qQS5iqceXY2pjpz4emJ/MjR7JrnBbqB7GRCRbQ6FpsAeubIkO+UN0FYzifUJ e6d/Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdeltdefkecutefuodetggdotefrod 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; Fri, 1 May 2026 09:58:31 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 4/4] firewire: core: move allocation/reallocation paths into specific branch after isoc resource management in cdev Date: Fri, 1 May 2026 22:58:23 +0900 Message-ID: <20260501135823.241940-5-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260501135823.241940-1-o-takashi@sakamocchi.jp> References: <20260501135823.241940-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" After managing the actual isochronous resources, there is post-processing logic to determine what type of event should be notified. However, there is room for improvement. This commit refactors the logic. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-cdev.c | 53 ++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index 4ce8754da93f..c166e7617d2a 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -1331,7 +1331,7 @@ static void iso_resource_auto_work(struct work_struct= *work) unsigned long index =3D r->resource.handle; int current_generation, resource_generation, channel, bandwidth, todo; u64 reset_jiffies; - bool free =3D false, success; + bool free; =20 scoped_guard(spinlock_irq, &client->lock) { reset_jiffies =3D client->device->card->reset_jiffies; @@ -1364,37 +1364,31 @@ static void iso_resource_auto_work(struct work_stru= ct *work) fw_iso_resource_manage(client->device->card, current_generation, r->param= s.channels, &channel, &bandwidth, todo !=3D ISO_RES_AUTO_DEALLOC); =20 - /* - * Is this generation outdated already? As long as this resource sticks - * in the xarray, it will be scheduled again for a newer generation or at - * shutdown. - */ - if (channel =3D=3D -EAGAIN && - (todo =3D=3D ISO_RES_AUTO_ALLOC || todo =3D=3D ISO_RES_AUTO_REALLOC)) - goto out; - - success =3D channel >=3D 0 || bandwidth > 0; - - scoped_guard(spinlock_irq, &client->lock) { - // Transit from allocation to reallocation, except if the client - // requested deallocation in the meantime. - if (r->todo =3D=3D ISO_RES_AUTO_ALLOC) - r->todo =3D ISO_RES_AUTO_REALLOC; - // Allocation or reallocation failure? Pull this resource out of the - // xarray and prepare for deletion, unless the client is shutting down. - if (r->todo =3D=3D ISO_RES_AUTO_REALLOC && !success && - !client->in_shutdown && - xa_erase(&client->resource_xa, index)) { - client_put(client); - free =3D true; - } - } - if (todo =3D=3D ISO_RES_AUTO_DEALLOC) { free =3D true; e =3D r->e_dealloc; r->e_dealloc =3D NULL; } else { + free =3D false; + + // Is this generation outdated already? As long as this resource sticks= in the + // xarray, it will be scheduled again for a newer generation or at shutd= own. + if (channel =3D=3D -EAGAIN) + goto out; + + bool success =3D channel >=3D 0 || bandwidth > 0; + + if (!success) { + // Allocation or reallocation failure? Pull this resource out of the + // xarray and prepare for deletion, unless the client is shutting down. + scoped_guard(spinlock_irq, &client->lock) { + if (!client->in_shutdown && xa_erase(&client->resource_xa, index)) { + client_put(client); + free =3D true; + } + } + } + if (todo =3D=3D ISO_RES_AUTO_REALLOC) { if (success) goto out; @@ -1403,6 +1397,11 @@ static void iso_resource_auto_work(struct work_struc= t *work) e =3D r->e_dealloc; r->e_dealloc =3D NULL; } else { + // Transit from allocation to reallocation, except if the client reques= ted + // deallocation in the meantime. + scoped_guard(spinlock_irq, &client->lock) + r->todo =3D ISO_RES_AUTO_REALLOC; + if (channel >=3D 0) r->params.channels =3D 1ULL << channel; =20 --=20 2.53.0