From nobody Sat Sep 26 12:30:56 2026 Received: from fhigh-a5-smtp.messagingengine.com (fhigh-a5-smtp.messagingengine.com [103.168.172.156]) (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 4229D1A6809 for ; Tue, 1 Sep 2026 13:45:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.156 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270344; cv=none; b=kdermGPxvVQL1Agk7a5fX9hLHOb4c/RFY0e6YGelTtvrNzvea85/h1LEZa+lgZnnbDzLPiSHPvIGAVmPCCcfiYaucu8LViKTV1Z/KxpubNWLudrfkh77Q2GEkY/IAhuEnLwETzKOuKtuVpZXZb16BQDDzGLJskwEjAJmT/eeiJ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270344; c=relaxed/simple; bh=R7XKwS1rRQbwNWLlb6FDC7rpfmznSUvP/XShKvGqmUo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X2XNnxsZkgF4BEZ5vDwYmKU9440fENe5eELwrfpbFRDxMHJ9q+DtH8cHEDmsZPL+e7BvIzzVhzeZhLiRbCgFjEBbYG938d8ymUMSBIcZYe96MUa8YXytQpcykRT5ek/6aUHcJu4Jq008n1Qxof0AodumR62TIaSa398+QtosQaE= 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=RnilabOU; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=c+ybRt/y; arc=none smtp.client-ip=103.168.172.156 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="RnilabOU"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="c+ybRt/y" Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfhigh.phl.internal (Postfix) with ESMTP id 6D8FF1400093; Tue, 1 Sep 2026 09:45:40 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Tue, 01 Sep 2026 09:45:40 -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=1788270340; x= 1788356740; bh=9RtNs4qRXiJlS2f2wTR1vyVhwZEuvWmevybH2uZUCLs=; b=R nilabOUIqoBC8Y4OAc+sb47IRn63Tlcz1MT4ErkFMx557HkLcxQ/YVh03hKnwycF Vsc3eUwN5tAzxOee913B4ulLGT+I9U+Ky4pH4hdVQHHzwswlF1LWou0HN3mJ96Xe qnh+tBBBqfCgSwLCCIn2ywMuqX3oKZ85cdc70soWo1sh36//GacyBrqIdg6Lu+AN pSSpgHaluwoVOsh52EAIRTj2kxvinXtEQFsHGYfEgevvmJn8m9zV0rB9AGLQt40e DKKPkIcB8lYEAJ2Tdl6b3IxW6YnV9KfRz90c5oGmwucFgpDKa4KQLwIlZkpT7w/o NPRsHhWqTaEYUtYeC4Zjw== 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=1788270340; x=1788356740; bh=9 RtNs4qRXiJlS2f2wTR1vyVhwZEuvWmevybH2uZUCLs=; b=c+ybRt/yNyMs2RoJs 4wFRTHHl69ehnzD0URiYpCVbZR8QAVeKORMCQLHoJ7VtKYmOrXV0gw580GfWXp0T dKKolQyaLX7HeuYNbMamj3GFvtChMXPdSYkqXcMqi7SWE6nbOxIpYvi7+H8bv+Fk I33PBBX3sPR6L3xpQtFNfahj30f1AoPY3a+lyGpBKL44NFQJV87bPCvseaRr+4Ap JgpxLf4w5KDWmsgaGJQuyIcQ6TvCpT4VLdUTR1H8fpBc93n1yMy9AL4+Qy30mJlh /hBAJcMhau/f1AVmX9CGOIdZ1X1uoQa4sHsBVCzoF9/tjzRqCSpvCNrdpI3xByZI xk8EQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFZwncM1fTlDqQm1y1Qd0WbMqgKiG0A81BHg4cYY3dGXUvtGFI17rS2eqaSTMcTBc w3IzjIjmVlW195FZcDDa3B601JY8rpJ6csJDicaYRdNLVZTvqTWrKZa/klMObsGgDWU/8p /Wr19S7NvuX68LaDTX4w+OnJKTMjpKwxBJGYNHh1AbNse1c9fCMCLHKsRgBaxZv8u1eAH6 mYnyoZaoyrVayB5GOgi+kRthTSA4CwYP93MtH7MmSsT09m4QsIMMuJbtd+noIlvMayqJS4 FyfnBVzwEM7VTPfRUX8JwnBRE4JT8u7X4MwdT7ILu5lMZFPOb3bJn9/6dlgjFc5whtTgEB fZX3m1E89hhLpXWwOhC1PMx9rC9z8RsIcSDwJxd32VN5+PPrKwQFsNJmUBUUjg7IqjlImp BohO4o5rAo7MKy8sizST7dHr0HmOsYqKsga6us3EzylParuVgWkV+njVeAqEwqyjweHisO gV7W0jwc1R/j2Qn4COCT7nIKY9y4fxKpKhXcNgkYGIqkKq15alvK6giymqFxQDW42sEFbK H6NwL545jbwFAvRQeYWLC8PeaFnaiGa5Eu3r81sVwYYbPub1DTfRumU4BuDzJ9ZZlBCHLX pLLMxR3AwXYOMhU0usJ8ADb+tG5loTIJUSKhJ+Vf3yqX1NtOKpzUVDxqStmQ X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 1 Sep 2026 09:45:38 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, mistermidi@gmail.com, sreekuttan2156239@gmail.com Subject: [PATCH 01/13] firewire: core: add KUnit test skeleton for config ROM parser and generator Date: Tue, 1 Sep 2026 22:45:22 +0900 Message-ID: <20260901134534.2386577-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260901134534.2386577-1-o-takashi@sakamocchi.jp> References: <20260901134534.2386577-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" In IEEE 1394, all devices on the bus are required to provide structured data in response to requests to a specific range of their address space. This structured data is called configuration ROM and is defined in IEEE 1212. The core function of this subsystem contains the generator and parser for the configuration ROM. The generator constructs the configuration ROM for the local host node, while the parser interprets the configuration ROM of detected nodes. Both the generator and parser are fundamental to identifying the node capabilities. Add KUnit test skeletons for testing their implementations. Signed-off-by: Takashi Sakamoto --- drivers/firewire/.kunitconfig | 1 + drivers/firewire/Kconfig | 16 ++++++++++++++++ drivers/firewire/config-rom-generator-test.c | 19 +++++++++++++++++++ drivers/firewire/config-rom-parser-test.c | 19 +++++++++++++++++++ drivers/firewire/core-card.c | 4 ++++ drivers/firewire/core-device.c | 4 ++++ 6 files changed, 63 insertions(+) create mode 100644 drivers/firewire/config-rom-generator-test.c create mode 100644 drivers/firewire/config-rom-parser-test.c diff --git a/drivers/firewire/.kunitconfig b/drivers/firewire/.kunitconfig index 7406acb00478..ee9129081cef 100644 --- a/drivers/firewire/.kunitconfig +++ b/drivers/firewire/.kunitconfig @@ -7,3 +7,4 @@ CONFIG_FIREWIRE_KUNIT_PACKET_SERDES_TEST=3Dy CONFIG_FIREWIRE_KUNIT_SELF_ID_SEQUENCE_HELPER_TEST=3Dy CONFIG_FIREWIRE_KUNIT_OHCI_SERDES_TEST=3Dy CONFIG_FIREWIRE_KUNIT_NODE_TREE_TEST=3Dy +CONFIG_FIREWIRE_KUNIT_CONFIG_ROM_PARSER_AND_GENERATOR_TEST=3Dy diff --git a/drivers/firewire/Kconfig b/drivers/firewire/Kconfig index b5abe00accc9..7e1d4b2c440b 100644 --- a/drivers/firewire/Kconfig +++ b/drivers/firewire/Kconfig @@ -96,6 +96,22 @@ config FIREWIRE_KUNIT_NODE_TREE_TEST For more information on KUnit and unit tests in general, refer to the KUnit documentation in Documentation/dev-tools/kunit/. =20 +config FIREWIRE_KUNIT_CONFIG_ROM_PARSER_AND_GENERATOR_TEST + tristate "KUnit tests for config ROM parser and generator" if !KUNIT_ALL_= TESTS + depends on FIREWIRE && KUNIT + default KUNIT_ALL_TESTS + help + This builds the KUnit tests to check parser and generator for + configuration ROM content defined in IEEE 1212. + + KUnit tests run during boot and output the results to the debug + log in TAP format (https://testanything.org/). Only useful for + kernel devs running KUnit test harness and are not for inclusion + into a production build. + + For more information on KUnit and unit tests in general, refer + to the KUnit documentation in Documentation/dev-tools/kunit/. + config FIREWIRE_OHCI tristate "OHCI-1394 controllers" depends on PCI && FIREWIRE diff --git a/drivers/firewire/config-rom-generator-test.c b/drivers/firewir= e/config-rom-generator-test.c new file mode 100644 index 000000000000..9a901eef7b0a --- /dev/null +++ b/drivers/firewire/config-rom-generator-test.c @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// config-rom-generator-test.c - An application of Kunit to test configura= tion ROM generator. +// +// Copyright (c) 2026 Takashi Sakamoto +// +// This file can not be built independently since it is intentionally incl= uded in core-card.c. + +#include + +static struct kunit_case config_rom_generator_test_cases[] =3D { + {} +}; + +static struct kunit_suite config_rom_generator_test_suite =3D { + .name =3D "firewire-config-rom-generator", + .test_cases =3D config_rom_generator_test_cases, +}; +kunit_test_suite(config_rom_generator_test_suite); diff --git a/drivers/firewire/config-rom-parser-test.c b/drivers/firewire/c= onfig-rom-parser-test.c new file mode 100644 index 000000000000..632f24e68692 --- /dev/null +++ b/drivers/firewire/config-rom-parser-test.c @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// config-rom-parser-test.c - An application of Kunit to test configuratio= n ROM parser. +// +// Copyright (c) 2026 Takashi Sakamoto +// +// This file can not be built independently since it is intentionally incl= uded in core-device.c. + +#include + +static struct kunit_case config_rom_parser_test_cases[] =3D { + {} +}; + +static struct kunit_suite config_rom_parser_test_suite =3D { + .name =3D "firewire-config-rom-parser", + .test_cases =3D config_rom_parser_test_cases, +}; +kunit_test_suite(config_rom_parser_test_suite); diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index 94992791f02e..23749434d900 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -851,3 +851,7 @@ int fw_card_read_cycle_time(struct fw_card *card, u32 *= cycle_time) return 0; } EXPORT_SYMBOL_GPL(fw_card_read_cycle_time); + +#ifdef CONFIG_FIREWIRE_KUNIT_CONFIG_ROM_PARSER_AND_GENERATOR_TEST +#include "config-rom-generator-test.c" +#endif diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index cbac66916240..4e79c57263ff 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -1442,3 +1442,7 @@ void fw_node_event(struct fw_card *card, struct fw_no= de *node, int event) #ifdef CONFIG_FIREWIRE_KUNIT_DEVICE_ATTRIBUTE_TEST #include "device-attribute-test.c" #endif + +#ifdef CONFIG_FIREWIRE_KUNIT_CONFIG_ROM_PARSER_AND_GENERATOR_TEST +#include "config-rom-parser-test.c" +#endif --=20 2.53.0 From nobody Sat Sep 26 12:30:56 2026 Received: from fhigh-a5-smtp.messagingengine.com (fhigh-a5-smtp.messagingengine.com [103.168.172.156]) (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 C0E6B2F87B for ; Tue, 1 Sep 2026 13:45:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.156 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270344; cv=none; b=dyFxQa4m12irHGr3Ya0/UENxEwY/coshFvB1oaJiMoB/+CE72S2LYbBb7xdKvwmQM5lYAp12xflGxIWtY3DFZ82baO+kUYacJRd5Z0bZ1QXsp0Xk9Iu+g8viQPwO/m5T0nA5XuVHTysZ3/jWybcVsmejQ1ngLkj7hHUoqUGOMvo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270344; c=relaxed/simple; bh=+vm7s0egTqqb64G9GlvYTBJeev+KKZiGr2/t6huP8IA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tYHkdhrSmESpW+RlE1rTMm+QIfZRpMuBFup1BNonUDAI/bY2fTlObDJHKvOX1g4C0DXgHYFcCFo98ICA9G26VJ/fjKMRsrX9aV0yIfDBmiENFHfsY3R6/aXl3HgxbtoewjykCzG2JdOPNKDzUXAfh9qZClpqZ9nrYPClfcH5OJ0= 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=KUZXdsOx; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=A/XugAq1; arc=none smtp.client-ip=103.168.172.156 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="KUZXdsOx"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="A/XugAq1" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.phl.internal (Postfix) with ESMTP id EF4E81400128; Tue, 1 Sep 2026 09:45:41 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Tue, 01 Sep 2026 09:45:41 -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=1788270341; x= 1788356741; bh=ADdpa4P660nW5EGXtQlYjGkMWvI5Ga+2XkstTrGI+n4=; b=K UZXdsOx0QvsTCUjNaJ5P0Px+sctNr2nF5ThqLhwXExLXlIzVDMkG3jjKjbg8Myxd Yg4UCzV6NPcNPi6woHE2XjnKw9rcv6rQK+fwxQ6jzw1OxJSSME9UwVQIKJojIU1c f9s5ZBJwOMlkr2ppQMl6iql2Ac1dpAP7Vjenk23LBUliBvejQDRVBZ4RYq3ouFU0 w2+R3tA4r2XZErwacYRYUsztCO4Me+u2CUJx3Y7Fnxd0z2cFh8TRKtTjp05NQdFO hGxJk5lYybbAlFaxsouggvMZZbIWignjXtmbux3cO/pHGznVggcQDlLXUAe6Kf0A pv7/v/TidbOhhyIFs7HuA== 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=1788270341; x=1788356741; bh=A Ddpa4P660nW5EGXtQlYjGkMWvI5Ga+2XkstTrGI+n4=; b=A/XugAq1VDBVDhZjk 06cWt57Dx/Gh3U9g3MMyZGqLLtr15lLArwSkX+0s8bCSvFYloCQyYaV6l6SzTSdZ +A+NbEy4xpwD9HAejVM6hSUHZxzKX5kT4S3kd0dXw6TYs6m+SqeLdODFtvWiN9WO 64YL1bzy2ZZIJ9YGgu+7mJYsbiKFch3EdtUQQhDVOt4IFO7z85hmgbdqi0SUEfos okzTCmcG0plIL5krPhzj+jJiFMkVd546Qz6fU4cW0hYdfM+uceHBP3CDsuFbCkGD fxBOWi6ivN3jGhXUpoG5CAXQ2E+vMH7axQg85A2a4J/5sadA4qn5bseEe7oeVn0l 2uwSQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFd20KhNkN+3L5LiLZttK1v9olpqJHdGSiQ5OEvQEzQTpqkbdCa1gFpOy5kosexA+ oBnU+A0NgYLJUUCWl/KhkFcDVq//IFRxbDRLvKAgz0hO+62jToZvj3pbRIh7nMxh1Sd3u+ ADhjawZuZu2sJOODqYOp3Fp/6UcSMCdfX79mH+4KAWY4wuX5gSyngUIstRvqP70LTdaTNw 142uQ5Tf7OiEQiDFOnAzQ1dr0TnVke38lMeEB6PzIbyOA2OtPJCTnajwUbC4LypA1F4hH+ GeU3fV8WaYU/7vXIlwqw0pWxg3eBnyxKOjbhQT+UGTUptGTL3GwY5JX3zfRaqZJbkJZeGV sA6QkViWELpyuYNRS/4sTEhJWiyzoIY0oCj3Zl8RsZV+G0rFT6HgURkz34R2LtB5IVm8Gq zwqoHntBBvScRi1edARmeDg1NnrKraXPFPS810ckwitkUSC7lLPc6FJyuiVp7KZMQyacpv FOSH6u4Ksri+NKHEOgwkW2mXeLb7hkarFcLRYdxCydc3FJiBsuSSiqZgZQ3tdy5FPulMtF clcwB4F9bYb72z2rLNGn8X9gUjE71tZsVd02Fko1Vwb83xxYLKZY5OfkjS/WwOxiv4z6yR ZSpSnIaRkNuKcW6luBjalJXkOqmwyjLcFPdSahADsRxdBoswaoGBEhPl7Zcw X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 1 Sep 2026 09:45:40 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, mistermidi@gmail.com, sreekuttan2156239@gmail.com Subject: [PATCH 02/13] firewire: core: add test to detect irm-is-1394-1995-only quirk in config ROM parser Date: Tue, 1 Sep 2026 22:45:23 +0900 Message-ID: <20260901134534.2386577-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260901134534.2386577-1-o-takashi@sakamocchi.jp> References: <20260901134534.2386577-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" Some Sony DV cameras have a quirk where their IRM functionality does not comply with IEEE 1394a:2000. This quirk was supported by commit 10389536742c ("firewire: core: check for 1394a compliant IRM, fix inaccessibility of Sony camcorder") and refactored by commit 5a43dc9f4ee0 ("firewire: core: detect device quirk when reading configuration ROM"). Add a KUnit test to check detection of the quirk. The configuration ROM content is retrieved from the following discussion: https://github.com/systemd/systemd/issues/25029. Signed-off-by: Takashi Sakamoto --- drivers/firewire/config-rom-parser-test.c | 151 ++++++++++++++++++++++ drivers/firewire/core-transaction.c | 4 + 2 files changed, 155 insertions(+) diff --git a/drivers/firewire/config-rom-parser-test.c b/drivers/firewire/c= onfig-rom-parser-test.c index 632f24e68692..131c7aa3b224 100644 --- a/drivers/firewire/config-rom-parser-test.c +++ b/drivers/firewire/config-rom-parser-test.c @@ -7,13 +7,164 @@ // This file can not be built independently since it is intentionally incl= uded in core-device.c. =20 #include +#include +#include + +static const u32 sony_dcr_trv310k_config_rom[] =3D { + 0x0404e552, + 0x31333934, + 0xe0648100, + 0x00008500, + 0x005eb597, + 0x0007cdd0, + 0x03000085, + 0x8100000d, + 0x17000002, + 0x81000010, + 0x0c0083c0, + 0xd8000002, + 0xd1000003, + 0x0001ce96, + 0xd1000001, + 0x0004bbee, + 0x1200a02d, + 0x13010001, + 0x17000002, + 0x81000006, + 0x00046dc8, + 0x00000000, + 0x00000000, + 0x43616e6f, + 0x6e000000, + 0x000621ee, + 0x00000000, + 0x00000000, + 0x4d563569, + 0x204d4300, + 0x00000000, + 0x00000000, +}; + +static const struct parser_test_case { + const char *name; + const u32 *quadlets; + size_t quadlet_length; + int phy_speed_in_self_id; + int expected_speed; + int expected_quirk; + unsigned int expected_max_rec; + bool expected_cmc; + bool expected_irmc; +} parser_test_cases[] =3D { + { + .name =3D "detect_irm_is_1394_1995_only_quirk", + .quadlets =3D sony_dcr_trv310k_config_rom, + .quadlet_length =3D ARRAY_SIZE(sony_dcr_trv310k_config_rom), + .phy_speed_in_self_id =3D SCODE_100, + .expected_speed =3D SCODE_100, + .expected_quirk =3D FW_DEVICE_QUIRK_IRM_IS_1394_1995_ONLY, + .expected_max_rec =3D 8, + .expected_cmc =3D true, + .expected_irmc =3D true, + }, +}; + +// Define parser_test_gen_params. +KUNIT_ARRAY_PARAM_DESC(parser_test, parser_test_cases, name); + +static int stub_run_regular_transaction(struct fw_card *card, int tcode, i= nt destination_id, + int generation, int speed, unsigned long long offset, + void *payload, size_t length) +{ + struct kunit *test =3D kunit_get_current_test(); + const struct parser_test_case *param =3D test->param_value; + + KUNIT_ASSERT_GE(test, offset, CSR_REGISTER_BASE | CSR_CONFIG_ROM); + KUNIT_ASSERT_LT(test, offset, CSR_REGISTER_BASE | CSR_CONFIG_ROM_END); + KUNIT_ASSERT_NOT_NULL(test, payload); + KUNIT_ASSERT_EQ(test, length, 4); + + unsigned int index =3D (offset - (CSR_REGISTER_BASE | CSR_CONFIG_ROM)) / = sizeof(u32); + u32 *quadlet =3D payload; + + KUNIT_EXPECT_LE(test, speed, param->expected_speed); + KUNIT_EXPECT_LT(test, index, param->quadlet_length); + + *quadlet =3D cpu_to_be32(param->quadlets[index]); + + return RCODE_COMPLETE; +} + +static void test_parser_with_regular_cases(struct kunit *test) +{ + struct fw_device *device =3D test->priv; + const struct parser_test_case *param =3D test->param_value; + + kunit_activate_static_stub(test, fw_run_transaction, stub_run_regular_tra= nsaction); + + device->card->link_speed =3D SCODE_BETA; + device->node->max_speed =3D param->phy_speed_in_self_id; + + KUNIT_EXPECT_EQ(test, read_config_rom(device, 0), RCODE_COMPLETE); + + KUNIT_EXPECT_EQ(test, device->config_rom_length, param->quadlet_length); + KUNIT_EXPECT_MEMEQ(test, device->config_rom, param->quadlets, param->quad= let_length); + + KUNIT_EXPECT_TRUE(test, device->quirks & param->expected_quirk); + KUNIT_EXPECT_EQ(test, device->max_speed, param->expected_speed); + KUNIT_EXPECT_EQ(test, (unsigned int)device->max_rec, param->expected_max_= rec); + KUNIT_EXPECT_EQ(test, (bool)device->cmc, param->expected_cmc); + KUNIT_EXPECT_EQ(test, (bool)device->irmc, param->expected_irmc); + + kunit_deactivate_static_stub(test, fw_run_transaction); +} + +static const struct fw_card_driver dummy_card_driver; + +static int config_rom_parser_test_init(struct kunit *test) +{ + struct fw_device *device; + struct device *dev; + + device =3D kunit_kzalloc(test, sizeof(*device), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, device); + + device->node =3D kunit_kzalloc(test, sizeof(*device->node), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, device->node); + kref_init(&device->node->kref); + + device->card =3D kunit_kzalloc(test, sizeof(*device->card), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, device->card); + + dev =3D kunit_device_register(test, "dummy-device"); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev); + + fw_card_initialize(device->card, &dummy_card_driver, dev); + + test->priv =3D device; + + return 0; +} + +static void config_rom_parser_test_exit(struct kunit *test) +{ + struct fw_device *device =3D test->priv; + + kunit_device_unregister(test, device->card->device); + kunit_kfree(test, device->card); + kunit_kfree(test, device->node); + kunit_kfree(test, device); +} =20 static struct kunit_case config_rom_parser_test_cases[] =3D { + KUNIT_CASE_PARAM(test_parser_with_regular_cases, parser_test_gen_params), {} }; =20 static struct kunit_suite config_rom_parser_test_suite =3D { .name =3D "firewire-config-rom-parser", + .init =3D config_rom_parser_test_init, + .exit =3D config_rom_parser_test_exit, .test_cases =3D config_rom_parser_test_cases, }; kunit_test_suite(config_rom_parser_test_suite); diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-tr= ansaction.c index 22ae387ae03c..995c2001bee0 100644 --- a/drivers/firewire/core-transaction.c +++ b/drivers/firewire/core-transaction.c @@ -24,6 +24,7 @@ #include #include #include +#include =20 #include =20 @@ -481,6 +482,9 @@ int fw_run_transaction(struct fw_card *card, int tcode,= int destination_id, int generation, int speed, unsigned long long offset, void *payload, size_t length) { + KUNIT_STATIC_STUB_REDIRECT(fw_run_transaction, card, tcode, destination_i= d, generation, + speed, offset, payload, length); + struct transaction_callback_data d; struct fw_transaction t; =20 --=20 2.53.0 From nobody Sat Sep 26 12:30:56 2026 Received: from fout-a7-smtp.messagingengine.com (fout-a7-smtp.messagingengine.com [103.168.172.150]) (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 87C0B2F7F0F for ; Tue, 1 Sep 2026 13:45:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.150 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270346; cv=none; b=DeZoPwWD+Zb/geboT1To8GnEoGE2W5pl6x+uG+QgSCObQ7MAvJlTkBQ/WSSvJRyNBCYOS1lo74Q1I33+BZ5hbUF+s/92f/lY5Lrqt4rQQ+yMi4ZTIKaXEGVbKnAWrKza6U80a0onIvLECGyDBgIYZvwcEpVjhgzQCg8F4C5/CAo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270346; c=relaxed/simple; bh=nFCJLO384mac6C9HeCwrGQ2XhIe/AUhAVM4w1x9u1CI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gHyuqKSrAlMEXX1YCWfaHbtk8sQPKh+TOt32CnKGlsHzbhn0bVroSdOp5xRKQ/kNXwVuvdAb5Vvl82KRcUtn2McDvESCt8PnxziFsqx72nUPTJ1bLYSxw1s44bSjsAGyF/7BJuAI4LiFhLeqAoAwKepW2Yor6aI+EzDnrU0oEjA= 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=SrXfQuVq; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=UuPHaYpb; arc=none smtp.client-ip=103.168.172.150 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="SrXfQuVq"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="UuPHaYpb" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.phl.internal (Postfix) with ESMTP id 8DA94EC00BD; Tue, 1 Sep 2026 09:45:43 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Tue, 01 Sep 2026 09:45:43 -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=1788270343; x= 1788356743; bh=Miba7rBHG1INP9PhTrnQwE0ikEZvKK2hUVomzqTr/zw=; b=S rXfQuVq8l0305YIAXJxo43BU0HZIgM7201YEK22VEw7ryLjg9OidpJMwDh6/1bHF OIhLKuTlpVL6nOrDD3mxg8JLlLF7XMhdnWSGjEHOnuNJgYoi1Xi9cnNwiQb8aLdR 8/Hq1YmkIltCfX8vGOKfzjoOw9jh0f0xdtf+ySWiDs+Mvb/yvpQSh69w2mIGhsxL CnjLBJSNAew7fWvd3RENtTK4qMzcGvqzeL+dH9Polnf4i/Whd0TxOVunkr5L6Zkd K42L8bOSH37AJnv3v2MACCjAHDHoUdiaMphpbevagzA4Qm1nGtxMZ6XoAgCg+mOi x44Oa3k16W0BxHs/YH+6w== 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=1788270343; x=1788356743; bh=M iba7rBHG1INP9PhTrnQwE0ikEZvKK2hUVomzqTr/zw=; b=UuPHaYpbCivnlGlAZ Zou7ogz58jeHz+FP4UbzYW+r+v6TupLAGmRDeQltEeAX0jXaylFr05GUjqu/6et6 TLCgetGtFk7iiL7ugkBNrjBdDAuE6sA3UjelgqDBFsiwT2FjMofKCQkDBRMrRfyt tWIVNIxM1dhy6dYHgQaH2mW9mu4qt3Svpg/D+iDpSvDAOpLL4JLMnvPttvjqLrtC PG4Y4v+7kqfYhDmC3plBA6jC91szyztRRd/mGW/2YO1MLa0n/VGGcYhQIDWHottm e+JnA8IdgYsv5Z7kn3A23DTJzY+C/+p2lVSJ1Js9shCYC/UwYD2HP1HN6Y3/Sr+N gmbRA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTERWJ+9AxblpY30+y7wpfkur1Fgy92ADYf3L53ujt/fv+xv29vapTGT7o9DeiD4Ib 7qPIYYxKYoQ/ySkn73mPNzEJ2AhV+J39wbt0OMehXHp9FIyeygqi2nnIr9iN/hoGbTb3Ch lNhtmFF8Z9J5GDUIjEHU8cgScPorWYCARsDErQnCMEU4SqFLQsTLxPyl73/pam9i4iGEas 0ws+D7eOCVyqnMsRzgFnc4n7CBFtRS6kxVxzS8QTsy1twe4WvgnhFJWqU0UPRyURkOW0jv i5R/R/nP1psaLpmS/T8lXvod++rIw8nNGbAZ+bpX08YpXVA0TY/DYmsjiBIvHI54ZVI7a+ l2Q0Oexgr7GAAneErCbSS2afmQ9DF/4AGT0gji32Wml934mpt6w1cHWaWLi7au38hikWTO wITrO1ANI7dPPEjaF+VGbvRLkWayPADoyN3bfGxixiJ4kpERSoSosTZhLTt3Nd9ou8INHf c0heEtu/Bx3eHGqxAe1EH7zI1Luw6VuLa0GTzrxSVGVk0wKALIw3Clan8IC3OfcQs1ps2Y UnUZeGUmxbOGyHpcGrMqUH+TW/UNupfbtt7FX8cBH6RRpeqh1lDViTS883yU1OTYOR8c8+ QzB/rbgHmwStGStAlNKkTdhMymdK9lwVTHTqFOQV2ZT0keOAQPrN0IzfOAfA X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 1 Sep 2026 09:45:42 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, mistermidi@gmail.com, sreekuttan2156239@gmail.com Subject: [PATCH 03/13] firewire: core: add test to detect irm-ignores-bus-manager quirk in config ROM parser Date: Tue, 1 Sep 2026 22:45:24 +0900 Message-ID: <20260901134534.2386577-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260901134534.2386577-1-o-takashi@sakamocchi.jp> References: <20260901134534.2386577-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" Some Canon DV cameras have a quirk where they malfunction as non-root nodes by ignoring the bus manager. This quirk was supported by commit 6044565af458e ("firewire: core: fix unstable I/O with Canon camcorder") and refactored by commit 5a43dc9f4ee0 ("firewire: core: detect device quirk when reading configuration ROM"). Add a KUnit test to verify that the configuration ROM parser detects the quirk correctly. The configuration ROM content is retrieved from the following discussion: https://bugzilla.redhat.com/show_bug.cgi?id=3D633260 Signed-off-by: Takashi Sakamoto --- drivers/firewire/config-rom-parser-test.c | 46 +++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/firewire/config-rom-parser-test.c b/drivers/firewire/c= onfig-rom-parser-test.c index 131c7aa3b224..11c01ef9efd9 100644 --- a/drivers/firewire/config-rom-parser-test.c +++ b/drivers/firewire/config-rom-parser-test.c @@ -45,6 +45,41 @@ static const u32 sony_dcr_trv310k_config_rom[] =3D { 0x00000000, }; =20 +static const u32 canon_mv5i_mc_config_rom[] =3D { + 0x0404e552, + 0x31333934, + 0xe0648100, + 0x00008500, + 0x005eb597, + 0x0007cdd0, + 0x03000085, + 0x8100000d, + 0x17000002, + 0x81000010, + 0x0c0083c0, + 0xd8000002, + 0xd1000003, + 0x0001ce96, + 0xd1000001, + 0x0004bbee, + 0x1200a02d, + 0x13010001, + 0x17000002, + 0x81000006, + 0x00046dc8, + 0x00000000, + 0x00000000, + 0x43616e6f, + 0x6e000000, + 0x000621ee, + 0x00000000, + 0x00000000, + 0x4d563569, + 0x204d4300, + 0x00000000, + 0x00000000, +}; + static const struct parser_test_case { const char *name; const u32 *quadlets; @@ -67,6 +102,17 @@ static const struct parser_test_case { .expected_cmc =3D true, .expected_irmc =3D true, }, + { + .name =3D "detect_irm_ignores_bus_manager_quirk", + .quadlets =3D canon_mv5i_mc_config_rom, + .quadlet_length =3D ARRAY_SIZE(canon_mv5i_mc_config_rom), + .phy_speed_in_self_id =3D SCODE_100, + .expected_speed =3D SCODE_100, + .expected_quirk =3D FW_DEVICE_QUIRK_IRM_IGNORES_BUS_MANAGER, + .expected_max_rec =3D 8, + .expected_cmc =3D true, + .expected_irmc =3D true, + }, }; =20 // Define parser_test_gen_params. --=20 2.53.0 From nobody Sat Sep 26 12:30:56 2026 Received: from fout-a7-smtp.messagingengine.com (fout-a7-smtp.messagingengine.com [103.168.172.150]) (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 D576931714B for ; Tue, 1 Sep 2026 13:45:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.150 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270347; cv=none; b=egoArByAs/gfl8rWEVJSDkDvlNWUjSbPf/L/pXXhfZ2Nza9ig/nmOT4IgF0hcYwmLZqDM+iDi5Vu7CFBekVudGxckGNETQ+lzcZE142eEyfRlTs2nFTbVDKyvpai8zpqQWDrq0hbyMnXl2Sb4Of3wA3SiCmQyRby0OuO4lXWrkM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270347; c=relaxed/simple; bh=5taGjKMAwwK1Jj7zzWQkSt/4Yc7wFSwn21CLkIB+GHs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RQltfTANhzjTWhW97LhqG3pq/gz9mgUNl4sBl164dp4331Ls7bWllWr89dGkIaIhNczcleLaIm4WYCLyPlyzNiLJrqFAYbwpKCb3gLNZAulgdinoB4ZxY8f2Pv+G9k/T4SxmYydHsSOfTR7FKn/tPR9NQXtxskbgP0T5X+3Heqs= 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=OTbYT++w; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=kIb7YQRw; arc=none smtp.client-ip=103.168.172.150 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="OTbYT++w"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="kIb7YQRw" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.phl.internal (Postfix) with ESMTP id 23A1DEC0089; Tue, 1 Sep 2026 09:45:45 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Tue, 01 Sep 2026 09:45:45 -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=1788270345; x= 1788356745; bh=t9GutbLLvX8hxRlobn5XkB9rAHyBFyHjzglK0FhFsfs=; b=O TbYT++wBIbM8to2kn61DPAUVpXUMwoLMSD4/mJ/lhw7REPNleX3BgZXYTdvub85r RzZBN6FgUEs/qfEMe71vwBiwP+RnbAiBFDQ480QIkvB9loS1s2PZDN7lpMFC3ZCP LtjyWUs+sDRuncZ/wHOJvGndUYeSTVxZRxwmGjL3Sbn2q3E+ES6UTjjSiTaIpP8W +L+MCQy8tNRf74riCKnfoO5st0DtrlnSWdzmPdahR/+QU+GaXp/vi79+ClarrYNh Mxa1rgRTARiWrIEt14yTLJ9TjCkwhtiCkM1qteazBWvZmP/k+AMtCrorlGrCb9hy fC1esvmaQxchwa55mfKdA== 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=1788270345; x=1788356745; bh=t 9GutbLLvX8hxRlobn5XkB9rAHyBFyHjzglK0FhFsfs=; b=kIb7YQRwUBk1IipQc tpwnF7R1uFadqzU6/R0U6FYL4AlW3UW64S6yfqU26SV7gQoC/1TT2/71HJucvDMQ 4dg1QPy7wDt/XROq2lfp3jw1IZSPGwkXtUGdACWtA/qql+kCuG0RgX8/D5yAN+Iu 897bt8/Cz+iZw9gQBw17G+1ETFlvrBNEYO8qI/zpUOWH6dCPSdiultt99fJs/9TD EEnW7CerkeCYLQL9JLb7uhlrKM0eYm9SXeykbyYs2aux1Uz+iE0nxkyhM3amfaTd MGUkc8FYB3uuglrM+dFQodbxVD09msHbwfxmtuwqQPncTDtDjN15lP5UhDBpSbgI FZhkQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFXtr6RCy/pKgLWPJSPBvXFm3znTxzXGxpPXDkaTlm4R2+4gVUR3kwIGcuZcfyzFI mpA4qcBzK+fVPECyFm7OelLWJtGrs9mbkwGUlRcdKEEiZnwYGMKFcyR4Lx0nWJEP53tHrp INpVKbiZ0MYz+E8QUhStfmq+hzC5ZUT09/4EEktKhZJR2UFAYiRFcGT4eRnAplGYtcc0m4 kBT9SKdHIAUPI8Vy/KZ2jkA5cHjiwUJ3cAiwR9JLlHkGd1gZLzXEUZwjj+Cs5XElfa9bu9 n3BhyK/tNfiAgYbIxs/G3L1e09P0C/HIg5r6g0F82tt8zxJVAwrnANwBwWnLSoYkVP19U8 2m4h9QFQmu6mp1Pm9xO/yOijnIrKhW6BcQF5Fa2BGgVvqZ/IAUA0UzKa3N+LDk7eIySmnz dq3wXrTyecXBqT/KnvggfaeUm6yxqOoe/bd4mUoYW6nR9CeOdeDm13tbovVXrGfaAI0Ld+ Bx9Lq6J2AbJxqgTtfT9rGq5rxuvfQ0bxyUqtrnQW9Of3DmigtCqT3Yfbr/91vsoUQBjZb2 +FtkYBzee/bDX0d04T+06Jhua3uGLFAcl7hOgLbt/JCGkXtYgx7wiVzFxmnD2zt8+arg+g gj9Tn6VTBnZgABPdNeMcazk1TZJAMS/cuW6iL4foC1NqP2Z61tmuBVg3zaOQ X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 1 Sep 2026 09:45:43 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, mistermidi@gmail.com, sreekuttan2156239@gmail.com Subject: [PATCH 04/13] firewire: core: add test to detect ack-packet-with-invalid-pending-code quirk in config ROM parser Date: Tue, 1 Sep 2026 22:45:25 +0900 Message-ID: <20260901134534.2386577-5-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260901134534.2386577-1-o-takashi@sakamocchi.jp> References: <20260901134534.2386577-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" MOTU Audio Express has a quirk where it transfers an invalid pending code when receiving an asynchronous request. This quirk was originally reported by commit 3a93d082bacf ("ALSA: firewire-motu: add support for MOTU Audio Express") and later supported by commit 15f9610fc96a ("firewire: core: handle device quirk of MOTU Audio Express"). Add a KUnit test to verify that the configuration ROM parser detects the quirk correctly. The configuration ROM content is retrieved from the commit mentioned above. Signed-off-by: Takashi Sakamoto --- drivers/firewire/config-rom-parser-test.c | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/firewire/config-rom-parser-test.c b/drivers/firewire/c= onfig-rom-parser-test.c index 11c01ef9efd9..35ebe8a6b611 100644 --- a/drivers/firewire/config-rom-parser-test.c +++ b/drivers/firewire/config-rom-parser-test.c @@ -80,6 +80,26 @@ static const u32 canon_mv5i_mc_config_rom[] =3D { 0x00000000, }; =20 +static const u32 motu_audioexpress_config_rom[] =3D { + 0x0410a756, + 0x31333934, + 0x20ff7000, + 0x0001f200, + 0x000a8a7b, + 0x0004ef04, + 0x030001f2, + 0x0c0083c0, + 0xd1000002, + 0x8d000005, + 0x00031680, + 0x120001f2, + 0x13000033, + 0x17104800, + 0x00025ef3, + 0x0001f200, + 0x000a8a7b, +}; + static const struct parser_test_case { const char *name; const u32 *quadlets; @@ -113,6 +133,17 @@ static const struct parser_test_case { .expected_cmc =3D true, .expected_irmc =3D true, }, + { + .name =3D "detect_ack_packet_with_invalid_pending_code_quirk", + .quadlets =3D motu_audioexpress_config_rom, + .quadlet_length =3D ARRAY_SIZE(motu_audioexpress_config_rom), + .phy_speed_in_self_id =3D SCODE_400, + .expected_speed =3D SCODE_400, + .expected_quirk =3D FW_DEVICE_QUIRK_ACK_PACKET_WITH_INVALID_PENDING_CODE, + .expected_max_rec =3D 7, + .expected_cmc =3D false, + .expected_irmc =3D false, + }, }; =20 // Define parser_test_gen_params. --=20 2.53.0 From nobody Sat Sep 26 12:30:56 2026 Received: from fout-a7-smtp.messagingengine.com (fout-a7-smtp.messagingengine.com [103.168.172.150]) (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 C9D19341068 for ; Tue, 1 Sep 2026 13:45:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.150 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270349; cv=none; b=rYk607Se450bidlcDD7fh4SFUiIvh/IJsTHOoNR1pzlbtuLWFN6cHCq+kPeF78fIIHQ97vBnV1Rl2cRD6R1YxkQ2DuDAVzqA16aUUrk5raAMW2X1yjFzAZ5GX7GBzTdFWAw+L48osqhDIp65+Bsg6VTFSR2CM4tQXOiAe9/RAbk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270349; c=relaxed/simple; bh=OOAW/ixLauJNluAv9FZeo/+U3HBq9ayoj8/H6UqVx2k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ftSre9PEjAFV1/5hgs2utXX0TZXWdN7VOMERRe+/BI7X03KlMlTpF+sebwwe7u+HYKDzqoUCkJajHMtysunix6JE+z/JuDa88dx5j7ft8cnv4n2Tts8GGSadh7Wupzd+de6tfE+APCP3uUYPoTzcEy9jc7C0aBDm2yjZr7vtc44= 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=IBS2S+m9; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=L+q0b6Sn; arc=none smtp.client-ip=103.168.172.150 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="IBS2S+m9"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="L+q0b6Sn" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id ADCC1EC010F; Tue, 1 Sep 2026 09:45:46 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Tue, 01 Sep 2026 09:45:46 -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=1788270346; x= 1788356746; bh=67EojhveUNyUfQQ6E5h6S7xVOeXprcHiW2XCsMbVllU=; b=I BS2S+m9bs5BRYhN4RfxZmUQEuL4q2qnmJhnHH8WnmcBxL5ysaqjnaFB7t4H0cva5 8YUbYlEB5eSE1hH436EUMd9qzqsumjRfHidqOdrCh+zIM1KI1gQ2uiKpqSjGcNeX azHxXaPp5ZK7O+oRH9IFHs0uevUcX2vJRQoJ3o9WiR67sBB8e0H7W34GKzlPDOlt c0SSm8Qz+e+KKbIzCAi7zFKutWtwoXwYoP+5kV1R+FXJ9FvesGH0ML6gKDULpdL5 VTf6IQodJScXC3O9vd3HJbWdal9fTu44y2b7qxdy1MxiLn0ilzXoQ4poXwgbTcey miuo8bokRl6nmJplwVVFA== 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=1788270346; x=1788356746; bh=6 7EojhveUNyUfQQ6E5h6S7xVOeXprcHiW2XCsMbVllU=; b=L+q0b6Sn7Ok7bK1lH h6LWn+5eIFiWUzL1d1pt9N0WFY5DdVvpzsC6mVv+9zqRsW8xEAAxlfi2oHwIOLrI ZPl5tYP/+/1BysNS/ANvkVPBu8hJT7PHG694O+G06iZ26FqxsYbz72Yz+CWgZ1MV 9Sk0HDeW+ujeSmdZbXkeXTSAIf7JOV1nz5JA5012fVdErL8qMzCHdime2XEryYW8 m+hgc0jATbWP+UR0wT/O8wPD0lbM6cDAmHBmI5iEXbxqhDtvLxMijTdhUrdjfXSN HqZV5Zar3nMYQN1I20xqf56MCT4TdKYT/5WwuuBV7s2YtiOSuMeWfItaW0BJeWUZ esScw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFXtr6RCy/pKgLWPJSPBvXFm3znTxzXGxpPXDkaTlm4R2+4gVUR3kwIGcuZcfyzFI mpA4qcBzK+fVPECyFm7OelLWJtGrs9mbkwGUlRcdKEEiZnwYGMKFcyR4Lx0nWJEP53tHrp INpVKbiZ0MYz+E8QUhStfmq+hzC5ZUT09/4EEktKhZJR2UFAYiRFcGT4eRnAplGYtcc0m4 kBT9SKdHIAUPI8Vy/KZ2jkA5cHjiwUJ3cAiwR9JLlHkGd1gZLzXEUZwjj+Cs5XElfa9bu9 n3BhyK/tNfiAgYbIxs/G3L1e09P0C/HIg5r6g0F82tt8zxJVAwrnANwBwWnLSoYkVP19cY 1DuXyDVjODspya30ffMT85xJFqb1GLUdY8e5s2gnAn1juTvVIXF0sgyf4dK6LDoi5KyWmq mI+0N5l9Wlk7vPygy4Nlz5k6+jZT492hdoswKGML203IhudZUFGtFyE9BGo+oZ/tTOIjMX HWl9yg6JEa7TPNLEoXhSV+jOeBmnq4zp8C6stdYmNCgyTcLPdiVOj/AwWKXGdWmjQ6RsZh GJnCgrMwdZE0Pp0hj0n7agxgWqcHw07n/Oxn2/JCL7GXV+QlZxBexHYPzadnMWkxlI2ITt /V2XW7AHSIeNgUT3BvOFXZO7/ZkUpUlqf4smkyKTAyu0WPfWvEB41oNykvRQ X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 1 Sep 2026 09:45:45 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, mistermidi@gmail.com, sreekuttan2156239@gmail.com Subject: [PATCH 05/13] firewire: core: add test to detect unstable-at-s400 quirk in config ROM parser Date: Tue, 1 Sep 2026 22:45:26 +0900 Message-ID: <20260901134534.2386577-6-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260901134534.2386577-1-o-takashi@sakamocchi.jp> References: <20260901134534.2386577-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" TASCAM FireWire series devices have a quirk where they fail to respond to asynchronous transactions at S400 speed. This quirk was supported by commit d52bb3daad3f ("firewire: core: handle device quirk of TASCAM FW-1884/FW-1804/FW-1082"). Add a KUnit test to verify that the configuration ROM parser detects the quirk correctly. The configuration ROM content is retrieved from the author's collection. Signed-off-by: Takashi Sakamoto --- drivers/firewire/config-rom-parser-test.c | 44 +++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/firewire/config-rom-parser-test.c b/drivers/firewire/c= onfig-rom-parser-test.c index 35ebe8a6b611..d7c58c7fb995 100644 --- a/drivers/firewire/config-rom-parser-test.c +++ b/drivers/firewire/config-rom-parser-test.c @@ -100,6 +100,39 @@ static const u32 motu_audioexpress_config_rom[] =3D { 0x000a8a7b, }; =20 +static const u32 tascam_fw1884_config_rom[] =3D { + 0x040f23c0, + 0x31333934, + 0x20ff7002, + 0x00022eff, + 0xfe800000, + 0x0004bccc, + 0x0300022e, + 0x0c0083c0, + 0x8d000006, + 0xd1000001, + 0x000347f5, + 0x1200022e, + 0x13800000, + 0xd4000004, + 0x000289aa, + 0x00022eff, + 0xfe800000, + 0x0002ae47, + 0x81000002, + 0x82000006, + 0x0004a79e, + 0x00000000, + 0x00000000, + 0x54415343, + 0x414d0000, + 0x00045443, + 0x00000000, + 0x00000000, + 0x46572d31, + 0x38383400, +}; + static const struct parser_test_case { const char *name; const u32 *quadlets; @@ -144,6 +177,17 @@ static const struct parser_test_case { .expected_cmc =3D false, .expected_irmc =3D false, }, + { + .name =3D "detect_unstable_at_s400_quirk", + .quadlets =3D tascam_fw1884_config_rom, + .quadlet_length =3D ARRAY_SIZE(tascam_fw1884_config_rom), + .phy_speed_in_self_id =3D SCODE_400, + .expected_speed =3D SCODE_200, + .expected_quirk =3D FW_DEVICE_QUIRK_UNSTABLE_AT_S400, + .expected_max_rec =3D 7, + .expected_cmc =3D false, + .expected_irmc =3D false, + }, }; =20 // Define parser_test_gen_params. --=20 2.53.0 From nobody Sat Sep 26 12:30:56 2026 Received: from fout-a7-smtp.messagingengine.com (fout-a7-smtp.messagingengine.com [103.168.172.150]) (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 22CAF355803 for ; Tue, 1 Sep 2026 13:45:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.150 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270350; cv=none; b=XC/3+9VosR/fMIQ5VEc4e7+w8+vx2s3VjULtmAoKocBlVhvvAgJSuHuRT66aqFbMZ4tvpTtPpHnKLSwa/zVcXQgr2DcO8igQ4DAGLvqEi2jp0M2CVIsBNM1p42AD9PYOQYVAe1luizI2rnfK56akJLKUpWaiZ+CjSDmPrYbW/ko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270350; c=relaxed/simple; bh=S6hQwRkRGloM8ZnTv56PXXEdBxCDz+4KTVdwKZPnzYc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HNP243D+TZRcEWPWqtjCguoK/EjRjJyLxqgXnFOacaDLDwDbhlkCE/TjwBEF60/B3YrIs+DPgmTMBNYcpSv8ycmq0IRhOpbV8dwk6J7d6u+Le53qgWKrgwu6TcZqylZ9E3JfhCLc0yidXl/e27qm/7inZWZ/yvY3g0ZQU8+a1VA= 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=LFUXcJYn; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=YM7DjI3l; arc=none smtp.client-ip=103.168.172.150 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="LFUXcJYn"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="YM7DjI3l" Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfout.phl.internal (Postfix) with ESMTP id 32861EC00C8; Tue, 1 Sep 2026 09:45:48 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Tue, 01 Sep 2026 09:45:48 -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=1788270348; x= 1788356748; bh=bd8h4FHmaELkBHWvIQd6yHzmcJO30UfhAWwkfBUCuF8=; b=L FUXcJYnYsRMUul/sm2Xa7n6UjSHBqdhbctPkuq+gO1GzadgZbnuq/xLvCHUqJC5+ LgZLVpMFugZ1Grw9yUtugNYjPhrTz9mu5FNGTXGjJA885n+ZmnjZhrxNbeLbLPLX gXZzCkXz55FZ+BTLinCssaOmO8E3XYg7G0cVV8Tk7hrPMzeVsHw5cHLnrC/J4hvP faKLSDZZAeGjrmzRslOFaZdSCDA+uH+fT5JNv3A/b/v+bZsH+A7GwFAPbvp2ArHz u+qPlucCLQ6bvWVf0mGLgZD0LVgGZGWIQ+z2DQHU6BkzllxPvi4uHHO5hlJQmfpC K9wfpVKOqEOuez0mkTN3Q== 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=1788270348; x=1788356748; bh=b d8h4FHmaELkBHWvIQd6yHzmcJO30UfhAWwkfBUCuF8=; b=YM7DjI3l2+siaQH6q uIitsbTHpUBTPvuFOgxelnrM/iGlb3XXwUfjCLbpNNFTvRgSW/NiWp7EHwr2p2aJ 37UbTyGKeD56HO5Cg15YwcJPbY3Wm7ilotzStIJPKga8XDQetAFIXF4L4TyYeVa6 AMDBX0XcfvJ3M+Sn+Nup4W6UHxrIJhN8AhzljouZAQYoGpebraE++K9HftVNTFRl hDDCuf5t15Zz+d7XuOrpCZ/4jDs9ob7K6G0oz76itRugL1cToAiiTW6lDqpSFTVV iB0GW5KkWEQapMqVaZ4hw+7QoBG3xQZqQmv+9aAP3ZESCGDnwKKVc83tz4tQ2Uvs vMRsw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEWdYH4dU+NQdTDhk9Zyzve1QFfC5NIhqKaEiG5+seWXcecosUXsnkY37p1mUpvde w9SlMwb4c3jDtKGytm1bIFR8Z1OxJIfMkthf0E3aR8zR24v/lQsWm7D9MwgP/fPLR+2uYe Dd3oChgzJfe0FMgMpUbT8SHEtTLBDrlTipebB9/xh3gTLWxp7SzwpqquiGnWJQGNbis+Jy NL2xLpELn0ZshX5UJcJoiK2+WXnLRUAHqsmiEa7T6/2Hgnqyv9SFQG/mW3HXRVk4Hli5m3 4WwSeLZzxL1A2RZPMINWZGlDPQkfI+tgq/vbW1bGugNfSvAQ3FK/YfkNHGzM/RogcgX9LB bUmykdxCun1A/AJZuLZcVvxIgD02TrziUlnuQBwwN34C+oS4haBmTyRKYTTW+VuhtJ6sUM 0CiVKv9krJCas/p1SaRZKusKABvO2OGG3eR2cgrigB4NSBAGJsxl+a6Py6hDJyCZSb0QKA FuH5NuZaZiM4BTz51XJPQuqyN8H3dDIkuF4Naz8NioSP84ZvcrOa96yAdAHEEr1x5bjXDH inUTYgrCFPXq9VRWciGDmTKfHfGGGSlDUC+CJHVw8u7RKvo89scC2cqMUogAR769r7Rlme 7C9EUyQGM2xF47reVKhM8JxC9GJC1ekDgHaqQURzuReG/wQqVpe35J1dBiEQ X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 1 Sep 2026 09:45:46 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, mistermidi@gmail.com, sreekuttan2156239@gmail.com Subject: [PATCH 06/13] firewire: core: add test to avoid excessive configuration ROM length Date: Tue, 1 Sep 2026 22:45:27 +0900 Message-ID: <20260901134534.2386577-7-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260901134534.2386577-1-o-takashi@sakamocchi.jp> References: <20260901134534.2386577-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 configuration ROM parser needs to handle malformed ROM contents safely. In particular, malformed directory and leaf offsets and block lengths should not result in accesses beyond the available configuration ROM data. Add a KUnit test with malformed configuration ROM content to verify that the parser sanitizes entries that would cause accesses beyond the available configuration ROM data. Reported-by: Aleksandr Shabelnikov Link: https://lore.kernel.org/lkml/20250901171547.47065-1-mistermidi@gmail.= com/ Signed-off-by: Takashi Sakamoto --- drivers/firewire/config-rom-parser-test.c | 68 ++++++++++++++++++++++- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/drivers/firewire/config-rom-parser-test.c b/drivers/firewire/c= onfig-rom-parser-test.c index d7c58c7fb995..e5c173353057 100644 --- a/drivers/firewire/config-rom-parser-test.c +++ b/drivers/firewire/config-rom-parser-test.c @@ -193,7 +193,7 @@ static const struct parser_test_case { // Define parser_test_gen_params. KUNIT_ARRAY_PARAM_DESC(parser_test, parser_test_cases, name); =20 -static int stub_run_regular_transaction(struct fw_card *card, int tcode, i= nt destination_id, +static int stub_run_transaction_regular(struct fw_card *card, int tcode, i= nt destination_id, int generation, int speed, unsigned long long offset, void *payload, size_t length) { @@ -221,7 +221,7 @@ static void test_parser_with_regular_cases(struct kunit= *test) struct fw_device *device =3D test->priv; const struct parser_test_case *param =3D test->param_value; =20 - kunit_activate_static_stub(test, fw_run_transaction, stub_run_regular_tra= nsaction); + kunit_activate_static_stub(test, fw_run_transaction, stub_run_transaction= _regular); =20 device->card->link_speed =3D SCODE_BETA; device->node->max_speed =3D param->phy_speed_in_self_id; @@ -240,6 +240,69 @@ static void test_parser_with_regular_cases(struct kuni= t *test) kunit_deactivate_static_stub(test, fw_run_transaction); } =20 +static int stub_run_transaction_malformed(struct fw_card *card, int tcode,= int destination_id, + int generation, int speed, unsigned long long offset, + void *payload, size_t length) +{ + static const u32 config_rom_first_part[] =3D { + 0x04000000, + 0x31333934, + 0x00008002, + 0x00000000, + 0x00000000, + 0x00030000, + (CSR_VENDOR << 24) | 0x00123456, // Regular entry. + ((CSR_LEAF | CSR_DESCRIPTOR) << 24) | 0x000000f9, // Beyond the upper li= mit. + ((CSR_DIRECTORY | CSR_UNIT) << 24) | 0x00000001, + 0xffff0000, // Over the upper limit. + }; + struct kunit *test =3D kunit_get_current_test(); + + KUNIT_ASSERT_GE(test, offset, CSR_REGISTER_BASE | CSR_CONFIG_ROM); + KUNIT_ASSERT_LT(test, offset, CSR_REGISTER_BASE | CSR_CONFIG_ROM_END); + KUNIT_ASSERT_NOT_NULL(test, payload); + KUNIT_ASSERT_EQ(test, length, 4); + + unsigned int index =3D (offset - (CSR_REGISTER_BASE | CSR_CONFIG_ROM)) / = sizeof(u32); + u32 *quadlet =3D payload; + + if (index < ARRAY_SIZE(config_rom_first_part)) + *quadlet =3D cpu_to_be32(config_rom_first_part[index]); + else + *quadlet =3D 0; + + return RCODE_COMPLETE; +} + +static void test_parser_with_overflowed_case(struct kunit *test) +{ + static const u32 corrected_config_rom[] =3D { + 0x04000000, + 0x31333934, + 0x00008002, + 0x00000000, + 0x00000000, + 0x00030000, + 0x03123456, + 0x00000000, // Sanitized. + 0xd1000001, + 0x00000000, // Sanitized. + }; + struct fw_device *device =3D test->priv; + + kunit_activate_static_stub(test, fw_run_transaction, stub_run_transaction= _malformed); + + device->card->link_speed =3D SCODE_BETA; + + KUNIT_EXPECT_EQ(test, read_config_rom(device, 0), RCODE_COMPLETE); + + KUNIT_EXPECT_EQ(test, device->config_rom_length, ARRAY_SIZE(corrected_con= fig_rom)); + KUNIT_EXPECT_MEMEQ(test, device->config_rom, corrected_config_rom, + sizeof(corrected_config_rom)); + + kunit_deactivate_static_stub(test, fw_run_transaction); +} + static const struct fw_card_driver dummy_card_driver; =20 static int config_rom_parser_test_init(struct kunit *test) @@ -279,6 +342,7 @@ static void config_rom_parser_test_exit(struct kunit *t= est) =20 static struct kunit_case config_rom_parser_test_cases[] =3D { KUNIT_CASE_PARAM(test_parser_with_regular_cases, parser_test_gen_params), + KUNIT_CASE(test_parser_with_overflowed_case), {} }; =20 --=20 2.53.0 From nobody Sat Sep 26 12:30:56 2026 Received: from fhigh-a5-smtp.messagingengine.com (fhigh-a5-smtp.messagingengine.com [103.168.172.156]) (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 A6D4A37BE6A for ; Tue, 1 Sep 2026 13:45:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.156 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270352; cv=none; b=id4ri87yZ5lyztN7tnVvIyGEjPbt7ucm7K0k5ymv/S3qkKT1c9JbyTPd4aWhlxcqD5EiRRw6B/jVGericV9zR/DPlafNoIZv7ZJatkNw/wEAVDOqJybnmdjPP1npLV/gDz62RK78t2jlyDbpZwxACcs1UpkJy8Cmu46cRBKUts4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270352; c=relaxed/simple; bh=wd3uFJ8NzgQMQ2i57BFHNeacPpDMNKeXlTWdcuMfztQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SGu7eylPUnLLZD4tmBSnEjSAMVLXkAmktONaE9QDhj3Sa0VoLHhXo9T0JG0L6Kaxd9Km4Qv/KA5KW6eemIYB2r7YKL6ccGLoCv0RpUT0fw2pedMBU9Wh9+lNE8rKlNWb1TXoo5zn2TZYPpyBW9SfxhTFjuXTmsD/m/714Qp1JY8= 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=WB+wJtEo; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=l7IEc8eN; arc=none smtp.client-ip=103.168.172.156 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="WB+wJtEo"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="l7IEc8eN" Received: from phl-compute-07.internal (phl-compute-07.internal [10.202.2.47]) by mailfhigh.phl.internal (Postfix) with ESMTP id BEC761400098; Tue, 1 Sep 2026 09:45:49 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-07.internal (MEProxy); Tue, 01 Sep 2026 09:45:49 -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=1788270349; x= 1788356749; bh=Svm4BpzWCz2Fy5rzhCxWWTqjFOb9ftxZSo00fuBLR8E=; b=W B+wJtEogEb7xMf9e00Atkhe7DVnkYr+Em3G0nFDILzl9/7uEUOERcFocoGX1XKyc VL+c8UJ8ol1GK7DSRdZc5u5ZQeEmvec0duQCrdrNeIz9yMitAdCJp84Qjb87sCwr PiPbDiLxT3snb/emmro8qnEgt0baDdsd4lbQzLnOxXmGNBDZIuZ55gm2756plgje sYVS3uO2N66NCozjQKgPplSter0GMqk79hLKCgquhnlZ3RODIgE0QRDXkuf3ykGR b2E1XVAyiRYibDR1Jb0jSjtGnc/7gciCjiPj/tkkykxX/apLIieF8yAUj9Q73xfx cpxVz64mOQhITdcLbxg6w== 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=1788270349; x=1788356749; bh=S vm4BpzWCz2Fy5rzhCxWWTqjFOb9ftxZSo00fuBLR8E=; b=l7IEc8eN+ZQ2kiYK5 YFitrqlw2OKojK5pOAAuaP4OWwf2ZLHtpMZ4UTLTAw8M5qZij+pp62tkzKwU6UtM Y83EnFO35tnbtns0mwtrs1E0KKm4CqyalsVKazvnyDwbzq1yMzlZzYSpbSeY911T pIPDNktvyWcu1uKLHdfePH4HI4Zz9OhyijZmu2Nr0xUk254k5hJJdj3s6oxedc/V S5gBVGgI23ysPhC015r68XDgbE+zLGbCAHtupGjSe3yGeBY2Sjb45hWp25AbwVda J2oD0RDmMxxfd+yTxOZSsUZOmM12YLHT19M7eQgo/3XRCwFrlBeXgDyUi2sTYiM6 WIxVw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFXtr6RCy/pKgLWPJSPBvXFm3znTxzXGxpPXDkaTlm4R2+4gVUR3kwIGcuZcfyzFI mpA4qcBzK+fVPECyFm7OelLWJtGrs9mbkwGUlRcdKEEiZnwYGMKFcyR4Lx0nWJEP53tHrp INpVKbiZ0MYz+E8QUhStfmq+hzC5ZUT09/4EEktKhZJR2UFAYiRFcGT4eRnAplGYtcc0m4 kBT9SKdHIAUPI8Vy/KZ2jkA5cHjiwUJ3cAiwR9JLlHkGd1gZLzXEUZwjj+Cs5XElfa9bu9 n3BhyK/tNfiAgYbIxs/G3L1e09P0C/HIg5r6g0F82tt8zxJVAwrnANwBwWnLSoYkVP19d1 Da13ImrcWTaPDKUFPTbolTb/MptQJZ/Bwop64YqNTl+Nt2WjLzcXbbglGuPI6fZkx8OeIW 7RdtBZ2vxkYHscPazksden0klhEf8/GyKuc6YuuXrWJfzi+cwx1qp9hhfzFUxTy8Zo7low 527VenQ4ylCjBcl5h+8w7Dt2pzv8X00netfEtXPoF8INKGUEYWF3U3YQjGOcYXIq11jWsH 0pJIE5VMmdCw+9ahKJc/Za2IXv/+IXmwxRWfJQfoBivU8xM2cb0LGrqzBpknzeBNuFSh6/ o1TxQ3FdXSIFxoXSLVpkMYOH7hQIyyqEQdl9HCV/XGRNzR7RTs0hm0IXvOSg X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 1 Sep 2026 09:45:48 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, mistermidi@gmail.com, sreekuttan2156239@gmail.com Subject: [PATCH 07/13] firewire: core: add test for root directory generation in config ROM generator Date: Tue, 1 Sep 2026 22:45:28 +0900 Message-ID: <20260901134534.2386577-8-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260901134534.2386577-1-o-takashi@sakamocchi.jp> References: <20260901134534.2386577-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 core function allows both the unit drivers and the userspace applications to extend the system configuration ROM. Without any extensions, the generator produces a root directory accompanied by two descriptor leaves. Add a KUnit test to verify the configuration ROM generated in this case. Signed-off-by: Takashi Sakamoto --- drivers/firewire/config-rom-generator-test.c | 100 +++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/drivers/firewire/config-rom-generator-test.c b/drivers/firewir= e/config-rom-generator-test.c index 9a901eef7b0a..02477300c1df 100644 --- a/drivers/firewire/config-rom-generator-test.c +++ b/drivers/firewire/config-rom-generator-test.c @@ -7,13 +7,113 @@ // This file can not be built independently since it is intentionally incl= uded in core-card.c. =20 #include +#include + +static const u32 config_rom_bare[] =3D { + cpu_to_be32(0x0404921b), // bus info + cpu_to_be32(0x31333934), // | + cpu_to_be32(0xf000b223), // | + cpu_to_be32(0x01234567), // | + cpu_to_be32(0x89abcdef), // v + cpu_to_be32(0x00051b70), // root directory + cpu_to_be32(0x0c0083c0), // | + cpu_to_be32(0x03001f11), // | + cpu_to_be32(0x81000003), // | + cpu_to_be32(0x17023901), // | + cpu_to_be32(0x81000008), // v + cpu_to_be32(0x00064cb7), // text descriptor leaf (from root) + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x4c696e75), // | + cpu_to_be32(0x78204669), // | + cpu_to_be32(0x72657769), // | + cpu_to_be32(0x72650000), // v + cpu_to_be32(0x0003ff1c), // text descriptor leaf (from root) + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x4a756a75), // v Juju is a code name at the development time= of this stack. +}; + +static const struct generator_test_case { + const char *const name; + int config_rom_generation; + const __be32 *const expected; + unsigned int quadlet_length; +} generator_test_cases[] =3D { + { + .name =3D "bare", + .config_rom_generation =3D 0, + .expected =3D config_rom_bare, + .quadlet_length =3D ARRAY_SIZE(config_rom_bare), + }, +}; + +// Define generator_test_gen_params. +KUNIT_ARRAY_PARAM_DESC(generator_test, generator_test_cases, name); + +struct state_data { + struct fw_card card; + __be32 config_rom[(CSR_CONFIG_ROM_END - CSR_CONFIG_ROM) / sizeof(__be32)]; +}; + +static void test_config_rom_generator(struct kunit *test) +{ + const struct generator_test_case *test_case =3D test->param_value; + struct state_data *state =3D test->priv; + struct fw_card *card =3D &state->card; + __be32 *config_rom =3D state->config_rom; + + card->config_rom_generation =3D test_case->config_rom_generation; + card->link_speed =3D SCODE_800; + card->max_receive =3D 11; + card->guid =3D 0x0123456789abcdefULL; + + scoped_guard(mutex, &card_mutex) { + generate_config_rom(card, config_rom); + KUNIT_EXPECT_EQ(test, config_rom_length, test_case->quadlet_length); + } + + KUNIT_EXPECT_MEMEQ(test, config_rom, test_case->expected, + sizeof(*test_case->expected) * test_case->quadlet_length); +} + +static const struct fw_card_driver dummy_card_driver; + +static int config_rom_generator_test_init(struct kunit *test) +{ + struct state_data *state =3D kunit_kzalloc(test, sizeof(*state), GFP_KERN= EL); + + KUNIT_ASSERT_NOT_NULL(test, state); + + struct device *dev =3D kunit_device_register(test, "dummy-device"); + + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev); + + fw_card_initialize(&state->card, &dummy_card_driver, dev); + + test->priv =3D state; + + return 0; +} + +static void config_rom_generator_test_exit(struct kunit *test) +{ + struct state_data *state =3D test->priv; + + kunit_device_unregister(test, state->card.device); + kunit_kfree(test, state); +} + =20 static struct kunit_case config_rom_generator_test_cases[] =3D { + KUNIT_CASE_PARAM(test_config_rom_generator, generator_test_gen_params), {} }; =20 static struct kunit_suite config_rom_generator_test_suite =3D { .name =3D "firewire-config-rom-generator", + .init =3D config_rom_generator_test_init, + .exit =3D config_rom_generator_test_exit, .test_cases =3D config_rom_generator_test_cases, }; kunit_test_suite(config_rom_generator_test_suite); --=20 2.53.0 From nobody Sat Sep 26 12:30:56 2026 Received: from fout-a7-smtp.messagingengine.com (fout-a7-smtp.messagingengine.com [103.168.172.150]) (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 32D403911BD for ; Tue, 1 Sep 2026 13:45:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.150 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270353; cv=none; b=eEVrjyiVSQb/qtWTuYm4dsZQVEN3iYZNe4Yv2WbACu1MJI/7RIA6LkAB6n1PmONNmHOyaRjWDCD9k7em5Ufjmh/dUfQ0KgImxPXDTtnqfQDHSSOFd96Cu7jFqrof0i4HpQpHfGJd30OIQqWzRcRBNd2cuZoFl3y/NMija1y3IOI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270353; c=relaxed/simple; bh=IYCoSwMOmLXMgcXg2bBVNLjbBCAdWNhoshIzeZ+YYRM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NkcGfkh2+t/rrfjLGphJSVoARAccbld/NiWAinQIzhIcb24WnIncG9jcWTEEwRwUe37YYtmv9/mehb2/7Zp+Acpw7fj6iYMsV481h9dNA0hS+uid92Th5WopTrCuto5VFK3UFAvswesJ340MfwtxJkqRoPmvzmjKj1mEe8wxXmE= 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=ZAXTCkZQ; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=TH5PY+5m; arc=none smtp.client-ip=103.168.172.150 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="ZAXTCkZQ"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="TH5PY+5m" Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfout.phl.internal (Postfix) with ESMTP id 3BACDEC00AD; Tue, 1 Sep 2026 09:45:51 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Tue, 01 Sep 2026 09:45:51 -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=1788270351; x= 1788356751; bh=SdbpUaxoCdI4VAT0vfU1WWlRpcDnzoWgrqRzDpLgcTQ=; b=Z AXTCkZQkf25o1FTiSAtlenIC6xsooJBNKmgUb9P+xrSb+w9Wm9hjrmfFRmyg/kCO v25XdUharUFsiu5fm/E5taWobsPnR00ecUnYJPVPgBNV7Fv4WcC4ajuRPWPFdMQd SaauKTqnrgWlDv54+LjJjhiX4/vMeG34pN7AoMTZUkxiX0szEdfEt4QYv2v/kdBA fbTuiFMvu0kuziyHiuVPd2nThzMxNitmtFtKC1mHUt+lEqsw7lBy7anLdxcsWd1K U0sleEwHabbBmm7aoSEq+YO8daNwRQ13h28C9xQaROk1H8sPFX2EPGbO4WSgARV+ Ai3Eggt7soAdR+eE/t/FA== 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=1788270351; x=1788356751; bh=S dbpUaxoCdI4VAT0vfU1WWlRpcDnzoWgrqRzDpLgcTQ=; b=TH5PY+5m7YwJ+/WBr PjkEkgXReyYKVlsDmcCIaS/1WTisSUbqBlPE9ghzKfGByg18eb80e4TyrIkM0WE8 vtJ42skOAPLbNal7ufSwWjcUGIzh2LK7km6tEtSXaIpxsG1+vHRI3QM8o280Fmn4 fIKV6A6Gd65xAG7w0r0RskZGHPDuU1V8zDsmD6e2l3rbsHvKTgD58YaEhj7c4kwk AC4Ns3kKIyV4Gar1FF34KB0fX71TrjhA7KfAGYn2BBfyebfh2IJ/FdLe5llj9IeH LnD76hmglVNpwaurxGmmtcDP4HCefGIeLfDc3PrYDeBj0IlfpRXXFv5F4udIsms6 Gn7Gg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFXtr6RCy/pKgLWPJSPBvXFm3znTxzXGxpPXDkaTlm4R2+4gVUR3kwIGcuZcfyzFI mpA4qcBzK+fVPECyFm7OelLWJtGrs9mbkwGUlRcdKEEiZnwYGMKFcyR4Lx0nWJEP53tHrp INpVKbiZ0MYz+E8QUhStfmq+hzC5ZUT09/4EEktKhZJR2UFAYiRFcGT4eRnAplGYtcc0m4 kBT9SKdHIAUPI8Vy/KZ2jkA5cHjiwUJ3cAiwR9JLlHkGd1gZLzXEUZwjj+Cs5XElfa9bu9 n3BhyK/tNfiAgYbIxs/G3L1e09P0C/HIg5r6g0F82tt8zxJVAwrnANwBwWnLSoYkVP19Je 85qEZBDcFufg01uFJkOrTspc32cvoLBo1efmL4sBGA0i5X3zuxDEHnZYzeDL2IfcuOieuf nQhIJRzC9sqW9v7kOTD7tXEul3am5JcX4uz5eskFtrC1Z+DxthupboQlPRyhEAabCfGTRm PfrzQFJa1jrhuIQ7x8m2EUr9CzWpMYYIOKl+zszhY+vwQ85ocgO9k91vcZAlonRG1xfIZk tLW06oniPYfCLamw78+Xr6z/+iYjWZ0HXRScuRj0usAhNYUNJejnK9+1WPJoYJ4Y9MSmTe XwuERM6h97/zU76jGZVba9T4dsqo5CsNH2JLetgAAJNMsxJ5I6UE08qIGMYg X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 1 Sep 2026 09:45:49 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, mistermidi@gmail.com, sreekuttan2156239@gmail.com Subject: [PATCH 08/13] firewire: core: add test to generate with AV/C unit in config ROM generator Date: Tue, 1 Sep 2026 22:45:29 +0900 Message-ID: <20260901134534.2386577-9-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260901134534.2386577-1-o-takashi@sakamocchi.jp> References: <20260901134534.2386577-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" There is a standard layout of configuration ROM for AV/C devices. Add a KUnit test to verify that the generator produces the expected configuration ROM when an AV/C unit is registered. Signed-off-by: Takashi Sakamoto --- drivers/firewire/config-rom-generator-test.c | 71 ++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/drivers/firewire/config-rom-generator-test.c b/drivers/firewir= e/config-rom-generator-test.c index 02477300c1df..c695811a50bb 100644 --- a/drivers/firewire/config-rom-generator-test.c +++ b/drivers/firewire/config-rom-generator-test.c @@ -34,6 +34,59 @@ static const u32 config_rom_bare[] =3D { cpu_to_be32(0x4a756a75), // v Juju is a code name at the development time= of this stack. }; =20 +// Following to Configuration ROM for AV/C Devices 1.0 (Dec. 2000. 1394 Tr= ading Association, +// Document 1999027). +#define UNIT_SPEC_ID_1394TA 0x0000a02d +#define UNIT_SW_VERSION_AVC 0x00010001 +#define UNIT_SW_VERSION_IIDC_0104 0x00000100 + +static const u32 avc_unit_directory_and_leaf[] =3D { + 0x00040000, // Unit directory consists of below 4 quads. + (CSR_SPECIFIER_ID << 24) | UNIT_SPEC_ID_1394TA, + (CSR_VERSION << 24) | UNIT_SW_VERSION_AVC, + (CSR_MODEL << 24) | 0x00260827, // Today. + ((CSR_LEAF | CSR_DESCRIPTOR) << 24) | 0x00000001, // Point to next quadle= t. + 0x00030000, // Text leaf consists of below 3 quads. + 0x00000000, + 0x00000000, + 0x50756900, // Pui is the name of a cat that the author takes care of. +}; + +static const u32 config_rom_with_avc_unit[] =3D { + cpu_to_be32(0x0404c1e5), // bus info + cpu_to_be32(0x31333934), // | + cpu_to_be32(0xf000b233), // | + cpu_to_be32(0x01234567), // | + cpu_to_be32(0x89abcdef), // v + cpu_to_be32(0x0006a2d2), // root directory + cpu_to_be32(0x0c0083c0), // | + cpu_to_be32(0x03001f11), // | + cpu_to_be32(0x81000004), // | + cpu_to_be32(0x17023901), // | + cpu_to_be32(0x81000009), // | + cpu_to_be32(0xd100000c), // v + cpu_to_be32(0x00064cb7), // text descriptor leaf (from root) + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x4c696e75), // | + cpu_to_be32(0x78204669), // | + cpu_to_be32(0x72657769), // | + cpu_to_be32(0x72650000), // v + cpu_to_be32(0x0003ff1c), // text descriptor leaf (from root) + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x4a756a75), // v + cpu_to_be32(0x0004227b), // unit directory (from root) + cpu_to_be32(0x1200a02d), // | + cpu_to_be32(0x13010001), // | + cpu_to_be32(0x17260827), // | + cpu_to_be32(0x81000001), // v + cpu_to_be32(0x0003f771), // text descriptor leaf (from unit) + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x50756900), // v +}; + static const struct generator_test_case { const char *const name; int config_rom_generation; @@ -46,6 +99,12 @@ static const struct generator_test_case { .expected =3D config_rom_bare, .quadlet_length =3D ARRAY_SIZE(config_rom_bare), }, + { + .name =3D "with_avc_unit", + .config_rom_generation =3D 1, + .expected =3D config_rom_with_avc_unit, + .quadlet_length =3D ARRAY_SIZE(config_rom_with_avc_unit), + }, }; =20 // Define generator_test_gen_params. @@ -58,6 +117,12 @@ struct state_data { =20 static void test_config_rom_generator(struct kunit *test) { + // Use kernel stack since they should be mutable for doubly linked-list. + struct fw_descriptor avc_unit_entry =3D { + .length =3D ARRAY_SIZE(avc_unit_directory_and_leaf), + .key =3D (CSR_DIRECTORY | CSR_UNIT) << 24, + .data =3D avc_unit_directory_and_leaf, + }; const struct generator_test_case *test_case =3D test->param_value; struct state_data *state =3D test->priv; struct fw_card *card =3D &state->card; @@ -68,6 +133,9 @@ static void test_config_rom_generator(struct kunit *test) card->max_receive =3D 11; card->guid =3D 0x0123456789abcdefULL; =20 + if (test_case->expected =3D=3D config_rom_with_avc_unit) + KUNIT_EXPECT_EQ(test, fw_core_add_descriptor(&avc_unit_entry), 0); + scoped_guard(mutex, &card_mutex) { generate_config_rom(card, config_rom); KUNIT_EXPECT_EQ(test, config_rom_length, test_case->quadlet_length); @@ -75,6 +143,9 @@ static void test_config_rom_generator(struct kunit *test) =20 KUNIT_EXPECT_MEMEQ(test, config_rom, test_case->expected, sizeof(*test_case->expected) * test_case->quadlet_length); + + if (test_case->expected =3D=3D config_rom_with_avc_unit) + fw_core_remove_descriptor(&avc_unit_entry); } =20 static const struct fw_card_driver dummy_card_driver; --=20 2.53.0 From nobody Sat Sep 26 12:30:56 2026 Received: from fout-a7-smtp.messagingengine.com (fout-a7-smtp.messagingengine.com [103.168.172.150]) (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 AB22B3AEF50 for ; Tue, 1 Sep 2026 13:45:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.150 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270355; cv=none; b=oTuyVs1BUgzsWHwvp9Pf77qwuk6YGWLez7/bwJuQW0EmbuFH712Zld90TEjZv1zfLukNi7HQ5VmExPPyktbYZeKto6+W6Wr8GRRa5jHi7tye3ZIFN0Z1UD60rpEPoi7FnoEgaWIXBrHdKq7CLnV1GwNxuQ1JOHC0SBvAlm0KoBs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270355; c=relaxed/simple; bh=qgiyO6Oiz37QAwDooQPVcfkUhvSyEtAunUHz1++G1V0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TEpQ+REhGeSBAUXVop8AsIsbCUpJDnPxNvW8AZpVTGCNC6n5IWTJ1C655sqEwPA+aPOuLEHyi65LeW7JFtHY7AHgZUG6dXkx2JFUJi2qfmTKuK2VoQgjqQfHh7Sakj0ybWYN0+D4RRtFpOIZVCL2L7LurySqmhCeBo81ofhHZT4= 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=qF7y3FKn; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=jHkzSKMS; arc=none smtp.client-ip=103.168.172.150 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="qF7y3FKn"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="jHkzSKMS" Received: from phl-compute-08.internal (phl-compute-08.internal [10.202.2.48]) by mailfout.phl.internal (Postfix) with ESMTP id DDC53EC00C1; Tue, 1 Sep 2026 09:45:52 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-08.internal (MEProxy); Tue, 01 Sep 2026 09:45:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1788270352; x= 1788356752; bh=ZtCkhLrhcvMxGOfdSJ5IQf+T2fdhFoHn9DVAVOReVf8=; b=q F7y3FKnr2Si1DXNZvq3oZRrNyJgrKPa8IHwBTov12vunVbZfjU6SD/0BmwEiYnOZ e8W+i+2uPduv5B+8bDlijibTyHfqxKk4r8eK6B7eAdXP/bCb5j7wnExGizlSh22Z T1oXrLFLZbsJYKu0OIdsHEYdqG+JZsCJR2rafeH7Fhph0bQynRtimYg1J7F0aswQ OrxTzmB4FdtyAljSr5lJK/gDosgjtSPX5H+YIEYzdEwRAkFvENjAuAC1O2+R/AxA 8QPNWfq6daFflwZCnmSefvbZgmck8Nhid8tnb/woU1VwDiNuef0aiVqkjK1iBnEI yS6oM3CLGVupjCqHWPp3w== 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=1788270352; x=1788356752; bh=Z tCkhLrhcvMxGOfdSJ5IQf+T2fdhFoHn9DVAVOReVf8=; b=jHkzSKMSxn7me3Am4 wm5i63YKdjFwe1H/RsinJWzHzJdkNWauuwPaeqPsBF5j4FA/ZSHm8zd1ga2mQycD gCamYk2BO0Caj1P94GYg1c+mWE8VJwIik51M96P6GKp+6fMKODwi82yA7EqEnizE QayF6yCpPpYIGr/z2KgUGTPc+P7kdqkCb444q0xtoJMMMZZ5uZtsZ5kfJaVQECXP qSstnqk3Z1/JenFo+kBazZc7Y39HJUVgCeXXazuNy9uQ5szymwOUWt67ZEGeOSkL 0uO04ZTjxYZ3uZl9Cgb1Za0IzZQ/v8M5rRtK5sKhMW2OAjSCjIc+3yb9ZB+UgIn8 y6b0Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFXtr6RCy/pKgLWPJSPBvXFm3znTxzXGxpPXDkaTlm4R2+4gVUR3kwIGcuZcfyzFI mpA4qcBzK+fVPECyFm7OelLWJtGrs9mbkwGUlRcdKEEiZnwYGMKFcyR4Lx0nWJEP53tHrp INpVKbiZ0MYz+E8QUhStfmq+hzC5ZUT09/4EEktKhZJR2UFAYiRFcGT4eRnAplGYtcc0m4 kBT9SKdHIAUPI8Vy/KZ2jkA5cHjiwUJ3cAiwR9JLlHkGd1gZLzXEUZwjj+Cs5XElfa9bu9 n3BhyK/tNfiAgYbIxs/G3L1e09P0C/HIg5r6g0F82tt8zxJVAwrnANwBwWnLSoYkVP19MH Cq6WdTWfQvI0qmnJqZL6LzPZtqbsUvLsA/ydmdg2y+Qoyl0rpoq+tb5R04cdC1gVs2bIjm N4WBEEPtFYTHse8FBQ5jqG3WQLfl1yWRcsPsbuXnIuL7Ep2qEo7Mc9mK+bpYqsI6ADvkeM g/S9COuhgo0fs9b/LEVXCW8n5huJlgu2MI7GBGk/B/svQiDu2n1WK1ZCc+6YBjNREV1jIj d8otFozLfFgFikOsahflRMwcgLxTk5AUY+JlE96PvcxOavMnAFCTnjBDvm6nZGEQAaVeYD 1fDpmRj9ewW1K6GsPIZtHAnuP+u5dsqYI0Po6Q9xSNhji8H9en5gJkKTfk6A X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 1 Sep 2026 09:45:51 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, mistermidi@gmail.com, sreekuttan2156239@gmail.com Subject: [PATCH 09/13] firewire: core: add test to generate with IIDC unit in config ROM generator Date: Tue, 1 Sep 2026 22:45:30 +0900 Message-ID: <20260901134534.2386577-10-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260901134534.2386577-1-o-takashi@sakamocchi.jp> References: <20260901134534.2386577-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" There is a standard layout of configuration ROM for IIDC devices. Add a KUnit test to verify that the generator produces the expected configuration ROM when an IIDC unit is registered. Signed-off-by: Takashi Sakamoto --- drivers/firewire/config-rom-generator-test.c | 92 ++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/drivers/firewire/config-rom-generator-test.c b/drivers/firewir= e/config-rom-generator-test.c index c695811a50bb..6ca5c16b4f0f 100644 --- a/drivers/firewire/config-rom-generator-test.c +++ b/drivers/firewire/config-rom-generator-test.c @@ -87,6 +87,81 @@ static const u32 config_rom_with_avc_unit[] =3D { cpu_to_be32(0x50756900), // v }; =20 +// Following to 1394-based Digital Camera Specification Version 1.04 (Aug.= 1996. 1394 Trading +// Association) +#define IIDC_COMMAND_REGS_BASE 0x00 +#define IIDC_VENDOR_NAME_LEAF 0x01 +#define IIDC_MODEL_NAME_LEAF 0x02 + +static const u32 iidc_unit_directories_and_leafs[] =3D { + 0x00030000, + (CSR_SPECIFIER_ID << 24) | UNIT_SPEC_ID_1394TA, + (CSR_VERSION << 24) | UNIT_SW_VERSION_IIDC_0104, + ((CSR_DIRECTORY | CSR_DEPENDENT_INFO) << 24) | 0x00000001, + 0x00030000, + ((CSR_OFFSET | IIDC_COMMAND_REGS_BASE) << 24) | 0x00012345, + ((CSR_LEAF | IIDC_VENDOR_NAME_LEAF) << 24) | 0x00000002, + ((CSR_LEAF | IIDC_MODEL_NAME_LEAF) << 24) | 0x00000008, + 0x00060000, // Text leaf consists of below 6 quads. + 0x00000000, + 0x00000000, + 0x4c696e75, // Use the same name in root directory. + 0x78204669, + 0x72657769, + 0x72650000, + 0x00040000, // Text leaf consists of below 4 quads. + 0x00000000, + 0x00000000, + 0x43686566, // Chef Cat is a nick name when inventing IEEE 1394 itself. + 0x20436174, +}; + +static const u32 config_rom_with_iidc_unit[] =3D { + cpu_to_be32(0x04046a3e), // bus info + cpu_to_be32(0x31333934), // | + cpu_to_be32(0xf000b243), // | + cpu_to_be32(0x01234567), // | + cpu_to_be32(0x89abcdef), // v + cpu_to_be32(0x0006a2d2), // root directory + cpu_to_be32(0x0c0083c0), // | + cpu_to_be32(0x03001f11), // | + cpu_to_be32(0x81000004), // | + cpu_to_be32(0x17023901), // | + cpu_to_be32(0x81000009), // | + cpu_to_be32(0xd100000c), // v + cpu_to_be32(0x00064cb7), // text descriptor leaf (from root) + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x4c696e75), // | + cpu_to_be32(0x78204669), // | + cpu_to_be32(0x72657769), // | + cpu_to_be32(0x72650000), // v + cpu_to_be32(0x0003ff1c), // text descriptor leaf (from root) + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x4a756a75), // v + cpu_to_be32(0x0003d7fe), // unit directory (from root) + cpu_to_be32(0x1200a02d), // | + cpu_to_be32(0x13000100), // | + cpu_to_be32(0xd4000001), // v + cpu_to_be32(0x0003ea57), // dependent directory (from unit directory) + cpu_to_be32(0x40012345), // | + cpu_to_be32(0x81000002), // | + cpu_to_be32(0x82000008), // v + cpu_to_be32(0x00064cb7), // text descriptor leaf (from dependent director= y) + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x4c696e75), // | + cpu_to_be32(0x78204669), // | + cpu_to_be32(0x72657769), // | + cpu_to_be32(0x72650000), // v + cpu_to_be32(0x0004a3e9), // text descriptor leaf (from dependent director= y) + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x43686566), // | + cpu_to_be32(0x20436174), // v +}; + static const struct generator_test_case { const char *const name; int config_rom_generation; @@ -105,6 +180,12 @@ static const struct generator_test_case { .expected =3D config_rom_with_avc_unit, .quadlet_length =3D ARRAY_SIZE(config_rom_with_avc_unit), }, + { + .name =3D "with_iidc_unit", + .config_rom_generation =3D 2, + .expected =3D config_rom_with_iidc_unit, + .quadlet_length =3D ARRAY_SIZE(config_rom_with_iidc_unit), + }, }; =20 // Define generator_test_gen_params. @@ -123,6 +204,11 @@ static void test_config_rom_generator(struct kunit *te= st) .key =3D (CSR_DIRECTORY | CSR_UNIT) << 24, .data =3D avc_unit_directory_and_leaf, }; + struct fw_descriptor iidc_unit_entry =3D { + .length =3D ARRAY_SIZE(iidc_unit_directories_and_leafs), + .key =3D (CSR_DIRECTORY | CSR_UNIT) << 24, + .data =3D iidc_unit_directories_and_leafs, + }; const struct generator_test_case *test_case =3D test->param_value; struct state_data *state =3D test->priv; struct fw_card *card =3D &state->card; @@ -136,6 +222,9 @@ static void test_config_rom_generator(struct kunit *tes= t) if (test_case->expected =3D=3D config_rom_with_avc_unit) KUNIT_EXPECT_EQ(test, fw_core_add_descriptor(&avc_unit_entry), 0); =20 + if (test_case->expected =3D=3D config_rom_with_iidc_unit) + KUNIT_EXPECT_EQ(test, fw_core_add_descriptor(&iidc_unit_entry), 0); + scoped_guard(mutex, &card_mutex) { generate_config_rom(card, config_rom); KUNIT_EXPECT_EQ(test, config_rom_length, test_case->quadlet_length); @@ -144,6 +233,9 @@ static void test_config_rom_generator(struct kunit *tes= t) KUNIT_EXPECT_MEMEQ(test, config_rom, test_case->expected, sizeof(*test_case->expected) * test_case->quadlet_length); =20 + if (test_case->expected =3D=3D config_rom_with_iidc_unit) + fw_core_remove_descriptor(&iidc_unit_entry); + if (test_case->expected =3D=3D config_rom_with_avc_unit) fw_core_remove_descriptor(&avc_unit_entry); } --=20 2.53.0 From nobody Sat Sep 26 12:30:56 2026 Received: from fout-a7-smtp.messagingengine.com (fout-a7-smtp.messagingengine.com [103.168.172.150]) (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 4D8C73B9DAB for ; Tue, 1 Sep 2026 13:45:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.150 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270357; cv=none; b=KbWIO+NbwBFGOPNK3w5wfqEVa9n9jnmIPjifqabXUA6ho8B93aeiN8kstILx4984mvRqvp+oUw7berd9cM68adge6o4kaioYjbBDlkJYR8AnxitwQGvkuHdpIxraWRtTLpReBd/8S0bq8jDyXVl6szMZrcM6gFSKnbu81Hn4R/E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270357; c=relaxed/simple; bh=DCh9JZBJCtXXPBu0v4ebMln/jxXGau8osWVZJniwXUI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SIkAtlwVFcIQemVnjZdwjqrramJYHbYa4U5CHcZNNDj/PQQvOfuqZVTVPZ8YbrpN+4FNHyYuseQ20+pnAk5EK1oLMzchM6PyPKZy0hVy1yeHFSytFkp5BgFG8apWVnHXmWE6TbrwyqSukqNdLi23WlHVmrIePudgxRtLH7VX8jw= 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=ck4TJfHA; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=idp+8CY2; arc=none smtp.client-ip=103.168.172.150 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="ck4TJfHA"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="idp+8CY2" Received: from phl-compute-07.internal (phl-compute-07.internal [10.202.2.47]) by mailfout.phl.internal (Postfix) with ESMTP id 683DDEC011F; Tue, 1 Sep 2026 09:45:54 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-07.internal (MEProxy); Tue, 01 Sep 2026 09:45:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1788270354; x= 1788356754; bh=h6V02rYyGQ8IATTwuJsoBnvhP7/OR7wgUI3SO299PIY=; b=c k4TJfHAk6JI4gLlJBJvS12dokPY1KDZHgAQR1RUx5bMZFNc7RCcaGV9rcFN9LawR BcXnyPl/ySo7tLKamJSad6GlIKUxauOzdiFIUbkShLU6RQLJ7aLMK12uRVF0ZFm6 7XNa8Jlu8eoJ36uYsOJMWhtFoKBHkCTRNrZlGsonfOfqJS+OpYmKaR/7ZZ8z49bO U+QEIb77/x2CwGThz8sU1JWcW65/dsUGtnpsgiDRrYuQPsZeq6fOUh5qa4AC52Nf OxgQVn5CCAQLvBhYxTOwecDFA6VUvyXnXzA5w8BvrsV/gILhsI+424hFwxy7lkUA Y9wwRs0ZBgD/tNuU6h0Sg== 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=1788270354; x=1788356754; bh=h 6V02rYyGQ8IATTwuJsoBnvhP7/OR7wgUI3SO299PIY=; b=idp+8CY2NXuZ+LU7C FMmkqA3iXW61Na1/N8RLKaG4MS3uGTyKu+G4qn73e5znLkCZnEyU1KehddGyOWln zeIo6vluaWLGwMdL4ufWc0p/HCqW0UhXxIFUwXCVDRysPtqbrxWJl2F+eXsY3KqU q4XSP9NDQXMA2bBqFLd6zddXlEU5881w1hPr09CGRo/Bc6DW55qlXl20Fneos/YK IIFDtace6rwQZdpgfCDRrZWhsYv/H1llREND+TCxxs6Z+9IePK0lf8PwqjTX33LX lVQSjYZM0BqdirZSgEDQhf6fcfR6ENkwQEMYss7kfiqrMGcHXn/DOyFDUOTQKc6l jraMw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFREBd8oipOne+whwDSMInIixSeI1lCerfHK3L4pOWL9djsbhxQ7B5sFcMPFC5ZHA MH3VvkrRHMa+iQQcOqPxGnC2IQB9D4JAe/3AuK6tpWR4HiWaEkwDxUpMyHYHygDA3Xsa7z dC7C0+FP7eobx+zdZ2fLBWL2c9uouHcGbMZUsAXCwMf3uBDxHXV7xmoI0Av4z39bFhb2B8 YcfxD8xc6QTRsePpNGxtpnkCfZc7Htd0IhA8vCGr6kTiSDRJR7oERY3rZMKJZA/+6wVpa6 Z1u1B5dF5XZ+J25H3NG+Ru4gEcIfhwPmzy/W/Pn8uVcz3UV6PD8S5w/Rz98MJxrXVdwZLa M31YyvG8yA+70av8a0cJnnPm6Is7s6esxrSElfalXZtsUCmWd471GgxqDhi7IaZ7R69f0G f27zcqijKzpctY+ggj3f5eueM7s2iodQhW2diWFNVoEFbMVOXLyDmlj+LLVx7euwHEIhaf tJVq2SfVLCL/Iv1ypcSZEWMXmWv96JefkhUUbS8DgFOyvM3QPQtj8OrgONYqUR4CnfkcER 05WX+FsfOi6s/dxrdo/fS2TlO+tO3LM+NJT+Tl6ic+xSBfZ83jJJBgt9FhMqUpTMdtClwJ EXB0uUXPdxda1KMfLD1OlXJqibuU+nJEilBjq1ZUru72VitprYth3pWEXYrg X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 1 Sep 2026 09:45:53 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, mistermidi@gmail.com, sreekuttan2156239@gmail.com Subject: [PATCH 10/13] firewire: core: add test to generate with both AV/C and IIDC units in config ROM generator Date: Tue, 1 Sep 2026 22:45:31 +0900 Message-ID: <20260901134534.2386577-11-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260901134534.2386577-1-o-takashi@sakamocchi.jp> References: <20260901134534.2386577-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" Add a KUnit test to verify that the generator produces the expected configuration ROM when both AV/C and IIDC units are registered. Signed-off-by: Takashi Sakamoto --- drivers/firewire/config-rom-generator-test.c | 74 ++++++++++++++++++-- 1 file changed, 70 insertions(+), 4 deletions(-) diff --git a/drivers/firewire/config-rom-generator-test.c b/drivers/firewir= e/config-rom-generator-test.c index 6ca5c16b4f0f..7d76580c2004 100644 --- a/drivers/firewire/config-rom-generator-test.c +++ b/drivers/firewire/config-rom-generator-test.c @@ -162,6 +162,62 @@ static const u32 config_rom_with_iidc_unit[] =3D { cpu_to_be32(0x20436174), // v }; =20 +static const u32 config_rom_with_avc_and_iidc_units[] =3D { + cpu_to_be32(0x040439c0), // bus info + cpu_to_be32(0x31333934), // | + cpu_to_be32(0xf000b253), // | + cpu_to_be32(0x01234567), // | + cpu_to_be32(0x89abcdef), // v + cpu_to_be32(0x0007073e), // root directory + cpu_to_be32(0x0c0083c0), // | + cpu_to_be32(0x03001f11), // | + cpu_to_be32(0x81000005), // | + cpu_to_be32(0x17023901), // | + cpu_to_be32(0x8100000a), // | + cpu_to_be32(0xd100000d), // | + cpu_to_be32(0xd1000015), // v + cpu_to_be32(0x00064cb7), // text descriptor leaf (from root) + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x4c696e75), // | + cpu_to_be32(0x78204669), // | + cpu_to_be32(0x72657769), // | + cpu_to_be32(0x72650000), // v + cpu_to_be32(0x0003ff1c), // text descriptor leaf (from root) + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x4a756a75), // v + cpu_to_be32(0x0004227b), // unit directory (from root) + cpu_to_be32(0x1200a02d), // | + cpu_to_be32(0x13010001), // | + cpu_to_be32(0x17260827), // | + cpu_to_be32(0x81000001), // v + cpu_to_be32(0x0003f771), // text descriptor leaf (from unit) + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x50756900), // v + cpu_to_be32(0x0003d7fe), // unit directory (from root) + cpu_to_be32(0x1200a02d), // | + cpu_to_be32(0x13000100), // | + cpu_to_be32(0xd4000001), // v + cpu_to_be32(0x0003ea57), // dependent directory (from unit directory) + cpu_to_be32(0x40012345), // | + cpu_to_be32(0x81000002), // | + cpu_to_be32(0x82000008), // v + cpu_to_be32(0x00064cb7), // text descriptor leaf (from dependent director= y) + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x4c696e75), // | + cpu_to_be32(0x78204669), // | + cpu_to_be32(0x72657769), // | + cpu_to_be32(0x72650000), // v + cpu_to_be32(0x0004a3e9), // text descriptor leaf (from dependent director= y) + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x00000000), // | + cpu_to_be32(0x43686566), // | + cpu_to_be32(0x20436174), // v +}; + static const struct generator_test_case { const char *const name; int config_rom_generation; @@ -186,6 +242,12 @@ static const struct generator_test_case { .expected =3D config_rom_with_iidc_unit, .quadlet_length =3D ARRAY_SIZE(config_rom_with_iidc_unit), }, + { + .name =3D "with_avc_and_iidc_unit", + .config_rom_generation =3D 3, + .expected =3D config_rom_with_avc_and_iidc_units, + .quadlet_length =3D ARRAY_SIZE(config_rom_with_avc_and_iidc_units), + }, }; =20 // Define generator_test_gen_params. @@ -219,10 +281,12 @@ static void test_config_rom_generator(struct kunit *t= est) card->max_receive =3D 11; card->guid =3D 0x0123456789abcdefULL; =20 - if (test_case->expected =3D=3D config_rom_with_avc_unit) + if (test_case->expected =3D=3D config_rom_with_avc_unit || + test_case->expected =3D=3D config_rom_with_avc_and_iidc_units) KUNIT_EXPECT_EQ(test, fw_core_add_descriptor(&avc_unit_entry), 0); =20 - if (test_case->expected =3D=3D config_rom_with_iidc_unit) + if (test_case->expected =3D=3D config_rom_with_iidc_unit || + test_case->expected =3D=3D config_rom_with_avc_and_iidc_units) KUNIT_EXPECT_EQ(test, fw_core_add_descriptor(&iidc_unit_entry), 0); =20 scoped_guard(mutex, &card_mutex) { @@ -233,10 +297,12 @@ static void test_config_rom_generator(struct kunit *t= est) KUNIT_EXPECT_MEMEQ(test, config_rom, test_case->expected, sizeof(*test_case->expected) * test_case->quadlet_length); =20 - if (test_case->expected =3D=3D config_rom_with_iidc_unit) + if (test_case->expected =3D=3D config_rom_with_iidc_unit || + test_case->expected =3D=3D config_rom_with_avc_and_iidc_units) fw_core_remove_descriptor(&iidc_unit_entry); =20 - if (test_case->expected =3D=3D config_rom_with_avc_unit) + if (test_case->expected =3D=3D config_rom_with_avc_unit || + test_case->expected =3D=3D config_rom_with_avc_and_iidc_units) fw_core_remove_descriptor(&avc_unit_entry); } =20 --=20 2.53.0 From nobody Sat Sep 26 12:30:56 2026 Received: from fhigh-a5-smtp.messagingengine.com (fhigh-a5-smtp.messagingengine.com [103.168.172.156]) (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 E1FCC415B6B for ; Tue, 1 Sep 2026 13:45:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.156 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270358; cv=none; b=ZSo1iak5tDOENgCy2C1x6djKo8HCVGca2R3FCdXhqMEEh7xHdzKnWsGkTCEtj2+w0GaeK3Up7lRM5XTk1uKOmVS8fsBzIixppz3lv2ty4eziVz2fruu9BCNwos5FopT4euFyom6eBQBbFpSuo+JYVW7z7bSo0BfuWAx6r+fcaO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270358; c=relaxed/simple; bh=CJeBaLICVOmyWZjtAYTQq3uao6YN/erJngwTBInYak0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ajLub9HzlGeUo6HgYoRccuRHO9OggNRBxVux2CqXhE3YjE30gweiLNwufF8BRuIiUc/L7O/iNr9WuIPZXj8LsajizLvz5+WZOJyCejxoGxaVl/mh/+k90A4bmY4r3O0SRSOxbXwa8h5llFVN6JNEmxG7hZyAaVFQ07NR+WxXVtk= 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=SH9wEZvu; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=lDOe2B+U; arc=none smtp.client-ip=103.168.172.156 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="SH9wEZvu"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="lDOe2B+U" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id F3FCF140006D; Tue, 1 Sep 2026 09:45:55 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Tue, 01 Sep 2026 09:45: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=fm3; t=1788270355; x= 1788356755; bh=TIZ29zTt9hWLX5Ra3muzPURNiJ2s9IdGBtnDopyV00E=; b=S H9wEZvuPQJuLouZS1jLhHs2QgtI7imbFbx3k9ENA6VjPmI7b16qgk4EwdoSom7HY C0MndCpQsvCM9EXqMEoxpzSjOSTCRygtYcYz7UNwa09RuglOmuzUhx4NBbo8VIQX Q0+GHcZr7DyVYbAtkZNz7gsE/BEKP8K2cawkjVGV0RnPNq/ZxyR07n9CELbIb5IW u8NF09JBGHYdVWJf+oda5o8d+VHpybj81c+1B4HyGBoT8a2WjUNsZoC+W5smJyJh TKJk2i69t1ec+l82RzgrgWPYHGPl7NIDPRtBGAbdtESAo+uEDHxcda5uxDykVWL0 3olRBNL387PPCazAQsbBw== 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=1788270355; x=1788356755; bh=T IZ29zTt9hWLX5Ra3muzPURNiJ2s9IdGBtnDopyV00E=; b=lDOe2B+UqrI+9rCMe WsJwetRPdyt/Y0jeFf7hit8hwfvIhPqqKoMycIc4LEnKeVzSfizSW5BgnXE7kD90 Zu2cRXl3Lb3t1//km7CmBmX5cVf1t1fhdva6WB3cQROFkLZPA9RZYl85WJbfs1pO gOO0BPx6L4u3Mxf9BDyl6SxE0fnCkuL9vW3n/F6LMmHo8qPy+GlAUapaw2cVVJHS Bcb1FJgxTwkkGqbtmao+Vwe9D0YEGUpcVRCTn7yvk1V1yivzB9Fl35xteMrn2m/f UkuIVIk7dJ3S4TzJCW3C0kdlkWHXDEHt4ZRVGqhElAsSVc4hSEfygn14SrXrThfM +E1pQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFXtr6RCy/pKgLWPJSPBvXFm3znTxzXGxpPXDkaTlm4R2+4gVUR3kwIGcuZcfyzFI mpA4qcBzK+fVPECyFm7OelLWJtGrs9mbkwGUlRcdKEEiZnwYGMKFcyR4Lx0nWJEP53tHrp INpVKbiZ0MYz+E8QUhStfmq+hzC5ZUT09/4EEktKhZJR2UFAYiRFcGT4eRnAplGYtcc0m4 kBT9SKdHIAUPI8Vy/KZ2jkA5cHjiwUJ3cAiwR9JLlHkGd1gZLzXEUZwjj+Cs5XElfa9bu9 n3BhyK/tNfiAgYbIxs/G3L1e09P0C/HIg5r6g0F82tt8zxJVAwrnANwBwWnLSoYkVP19el vzMQRZeMpvvPsQ3h5L+ktaSURVbv7bUFiGiMvJee6XE24iMPmJlsgK4FDFiRpp7owOWdXb 3zzULLYywfvkfAhjbYyfRl/0SYiwxtZ7uLzVBiQfBp44dFQP/+rC5nbWkJd68eJ72TAqpX xDrgqP9F5o1c477Xjjq0R9wTw/jdao2WV5LyYohTUswFIsOuYPQu/nl+plMTBiYC0WXVPX tStu0TbMb/r2knWBQKIWBAmDcWuKXJJhN55fg+CwMBE8XbPlsbhXRWqgbAs0JN/3FOGWJa JPEWuQSvlUkPAFO4xhoB42h3+alqA5h0vAzOKKOt+gFizoisMIy1qcvyodtw X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 1 Sep 2026 09:45:54 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, mistermidi@gmail.com, sreekuttan2156239@gmail.com Subject: [PATCH 11/13] firewire: core: add test for invalid length in config ROM generator Date: Tue, 1 Sep 2026 22:45:32 +0900 Message-ID: <20260901134534.2386577-12-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260901134534.2386577-1-o-takashi@sakamocchi.jp> References: <20260901134534.2386577-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" Although the unit drivers and the userspace applications are allowed to extend the system configuration ROM, they could provide invalid extension data. Add a KUnit test to verify that the generator handles an extension with an invalid length. Signed-off-by: Takashi Sakamoto --- drivers/firewire/config-rom-generator-test.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/firewire/config-rom-generator-test.c b/drivers/firewir= e/config-rom-generator-test.c index 7d76580c2004..260b3d6e9a27 100644 --- a/drivers/firewire/config-rom-generator-test.c +++ b/drivers/firewire/config-rom-generator-test.c @@ -306,6 +306,16 @@ static void test_config_rom_generator(struct kunit *te= st) fw_core_remove_descriptor(&avc_unit_entry); } =20 +static void add_descriptor_with_invalid_length(struct kunit *test) +{ + // Use kernel stack since they should be mutable for doubly linked-list. + struct fw_descriptor entry_with_invalid_length =3D { + .length =3D 257, + }; + + KUNIT_EXPECT_EQ(test, fw_core_add_descriptor(&entry_with_invalid_length),= -EINVAL); +} + static const struct fw_card_driver dummy_card_driver; =20 static int config_rom_generator_test_init(struct kunit *test) @@ -336,6 +346,7 @@ static void config_rom_generator_test_exit(struct kunit= *test) =20 static struct kunit_case config_rom_generator_test_cases[] =3D { KUNIT_CASE_PARAM(test_config_rom_generator, generator_test_gen_params), + KUNIT_CASE(add_descriptor_with_invalid_length), {} }; =20 --=20 2.53.0 From nobody Sat Sep 26 12:30:56 2026 Received: from fout-a7-smtp.messagingengine.com (fout-a7-smtp.messagingengine.com [103.168.172.150]) (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 1ED0B46AA8E for ; Tue, 1 Sep 2026 13:45:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.150 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270360; cv=none; b=icblOSzzx7HN5X6idGr9rPa5nj2IrbymO+JozsRwG9RZhDnXijk714pUSjrxEygx3xgHAQKcD5E6hCdTU319e8Uf7Dr59VLHpK/IRcxcxea3Yn7AvCkJC1JZTtaJZtp3u6kXCgJcJo44VJOYa1myV2zmOQ8CvbI+B+4/Qp94bUM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270360; c=relaxed/simple; bh=WMrLdh3pEugaDEFtPD+jMQ1zhTWROqbby6esXqgw500=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YhwENHkuhhoS+2QpQctAGYQ0YAvnvXtVxHmmdZIVcMlTPXKHLb1QwRDBKg+q2vv4SOUT/CJ/hgFY293FafD99c+2S4DnuiGzrRMxy5J6a5k1vekXHhlclIS8GlzkwaYSvW+QSzc8BxupxlOKa3ZRb+AnG/7OtCfRgezL3yvItGc= 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=fsd5i+lk; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=bCB3f3j0; arc=none smtp.client-ip=103.168.172.150 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="fsd5i+lk"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="bCB3f3j0" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id 6B49FEC00BD; Tue, 1 Sep 2026 09:45:57 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Tue, 01 Sep 2026 09:45:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1788270357; x= 1788356757; bh=vW9ZVLj93rAbqSELauULXZEinKxoH8huQpiry8QRwmA=; b=f sd5i+lkO8HqTsM3ymvkGM/JrYjwy5r8t6ZOHKZ0T0XdhbwAba8vQwnIwsi8l7ylp DIFSQys7iJT3EdbSe2AKa92yG2nXIBQIP6SRad+X9DA/py7mQ1/Yszt8g5zX2onF bu2PQUOh/fReuZIObPuRlff7ftcMmNoKvGrlUupzeY7bU993kCaZGzEBN7HbSrSC 3CoX6oJzyweVZUCErSSSGAQcRa47U2DnTfr4aSEQ1I5INpuyRfiQZ8omKaOaOh/i s/iXfH3R9hdzqEmjKWKeNRNIZJ7yGMOCUS5Kl+zOgdQeR167s+0z8DWbCr807o3t sVZy07YNXz0pev7jJGBcQ== 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=1788270357; x=1788356757; bh=v W9ZVLj93rAbqSELauULXZEinKxoH8huQpiry8QRwmA=; b=bCB3f3j0UAqfToyjS n2S9WQ/0esKKLsVMH4XOp4rZ4j2WdO9vlkxo3wXCEwvHObWtAjqMYc8oilzGZIIc Qhz+2g7NEHomC+Ew7KVw3vbtOz0RfD+LFqdgwt8lQtcfaeh7+SJJEyziSNYIqxGz C3MRFcDD9rUzCb+LxeL2UewUC4+sdvmaSFpkimM0bAeIMCAOYjjArUWSnxzSXfE3 cOIKHt7S1Snkw5uMyUPgs+6VSJYB2Z+Yoie3bsDq1IO32BTMDn1XxaS/SmJdyotl m4Otz2UzS+piNSuS7OTUkpbLdjU/q3yFwsTy1hsTq3hvjf+q3e44tQEpZEJeGdv6 ylQNg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFXtr6RCy/pKgLWPJSPBvXFm3znTxzXGxpPXDkaTlm4R2+4gVUR3kwIGcuZcfyzFI mpA4qcBzK+fVPECyFm7OelLWJtGrs9mbkwGUlRcdKEEiZnwYGMKFcyR4Lx0nWJEP53tHrp INpVKbiZ0MYz+E8QUhStfmq+hzC5ZUT09/4EEktKhZJR2UFAYiRFcGT4eRnAplGYtcc0m4 kBT9SKdHIAUPI8Vy/KZ2jkA5cHjiwUJ3cAiwR9JLlHkGd1gZLzXEUZwjj+Cs5XElfa9bu9 n3BhyK/tNfiAgYbIxs/G3L1e09P0C/HIg5r6g0F82tt8zxJVAwrnANwBwWnLSoYkVP19rx dCDzTuykijYG0sirrhPceyy5uszDiB/34Jmk64TFzPQkBMHct6JyHQ5SppXUebI3FOI/aM flmsZ6UeFpecvJpyN14ZU56tStyqvVkaJ2C0iDdTETJT0fio2JeJlyGNyzTtIUO0BavEiQ kFWUf3I//h0ocxsy89V9xm3Rn4rR86JmsTSq+QIwXBBLJK7iCwMbwRz6ih0mvGRi2f+x4g gWOlvP2i5OSAI/sQE8gp5IBOv/eC77RzqV2hIZGuqysMgm8Yzj9A2stubaGn1nEk96dVQe LDkbzTtxRyXn9bXvp6dd7yCduMyBi+Sq5F44nwXKPx99BoJI4e7XjlRt45Dg X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 1 Sep 2026 09:45:56 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, mistermidi@gmail.com, sreekuttan2156239@gmail.com Subject: [PATCH 12/13] firewire: core: add invalid block test for config ROM generator Date: Tue, 1 Sep 2026 22:45:33 +0900 Message-ID: <20260901134534.2386577-13-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260901134534.2386577-1-o-takashi@sakamocchi.jp> References: <20260901134534.2386577-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" Although the unit drivers and the userspace applications are allowed to extend the system configuration ROM, they could provide invalid extension data. Add a KUnit test to verify that the generator handles an invalid block. Signed-off-by: Takashi Sakamoto --- drivers/firewire/config-rom-generator-test.c | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/firewire/config-rom-generator-test.c b/drivers/firewir= e/config-rom-generator-test.c index 260b3d6e9a27..3114110307b5 100644 --- a/drivers/firewire/config-rom-generator-test.c +++ b/drivers/firewire/config-rom-generator-test.c @@ -316,6 +316,32 @@ static void add_descriptor_with_invalid_length(struct = kunit *test) KUNIT_EXPECT_EQ(test, fw_core_add_descriptor(&entry_with_invalid_length),= -EINVAL); } =20 +static void add_descriptor_with_invalid_data(struct kunit *test) +{ + // Use vendor directory defined in Annex A of Configuration ROM for AV/C = Devices 1.0 (Dec. + // 2000, 1394 Trading Association, TA Document 1999027). + static const u32 invalid_vendor_directory[] =3D { + 0x00020000, + (CSR_MODEL << 24) | 0x00009402, + ((CSR_LEAF | CSR_DESCRIPTOR) << 24) | 0x00000001, + 0xffff0000, // The length should be 6, invalid. + 0x00000000, + 0x00000000, + 0x436f6e63, + 0x6174204e, + 0x6f746174, + 0x696f6e00, + }; + // Use kernel stack since they should be mutable for doubly linked-list. + struct fw_descriptor entry_with_invalid_data =3D { + .length =3D ARRAY_SIZE(invalid_vendor_directory), + .key =3D (CSR_DIRECTORY | CSR_VENDOR) << 24, + .data =3D invalid_vendor_directory, + }; + + KUNIT_EXPECT_EQ(test, fw_core_add_descriptor(&entry_with_invalid_data), -= EINVAL); +} + static const struct fw_card_driver dummy_card_driver; =20 static int config_rom_generator_test_init(struct kunit *test) @@ -347,6 +373,7 @@ static void config_rom_generator_test_exit(struct kunit= *test) static struct kunit_case config_rom_generator_test_cases[] =3D { KUNIT_CASE_PARAM(test_config_rom_generator, generator_test_gen_params), KUNIT_CASE(add_descriptor_with_invalid_length), + KUNIT_CASE(add_descriptor_with_invalid_data), {} }; =20 --=20 2.53.0 From nobody Sat Sep 26 12:30:56 2026 Received: from fhigh-a5-smtp.messagingengine.com (fhigh-a5-smtp.messagingengine.com [103.168.172.156]) (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 EBB5E47CA7D for ; Tue, 1 Sep 2026 13:45:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.156 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270361; cv=none; b=ptj0EJuKeB04VAnZkqWnF27ib80P9HLUekCBS82EmoofW9lSDhFMNPBWzqMwvFDZoyRDZ6QCjifMuSgYCKOrmUMf0ZLd51rIMKbdkCM5mQpoUt4dY6lDkrjxCxJepSYqolkCqaTIS25aSyd+fUDr87/F3yMU9hkasgBf+v3rER4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788270361; c=relaxed/simple; bh=cd884XH1smHerg3iOHSMpm8x/c+cjiRg5u6hlcuupAU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ToZygTFMVZi0Axkb/SMoaJn0ibUGqxYFtoWAAJIekDEuy6Ri1DJN6zZdskcjnexBmrf1UBnfcF4Dx5zRrH3k4T1TmyWgolHK/tXDALuzgI9L9t2ZA+cOX9Cw+cxA5TzPzJbNGN5btOOuIT9bDwicxd3i8xyrw7wQtdFchKbCE70= 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=Y8JGWpMv; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=DMyyF8tb; arc=none smtp.client-ip=103.168.172.156 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="Y8JGWpMv"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="DMyyF8tb" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.phl.internal (Postfix) with ESMTP id F34DD140012D; Tue, 1 Sep 2026 09:45:58 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Tue, 01 Sep 2026 09:45: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=fm3; t=1788270358; x= 1788356758; bh=kBYzCr8NQhvsbNexWcUVTFKpY2eB55ccLL1loHUgTYI=; b=Y 8JGWpMvC175DluIh80kN+BjkV0tjXQsAmgFA/3qYZaYPMQ0W5uZNQWheWuyqoR/Q oF7nVpM/zIlFJdGqzI/pDbqSxy2REDs/Xtf+9niILa1iIYiHwvNUDqcQEJAi4acw uZF1h4rsydOgIc8aYOP3KHOeO7nftrUyAw8WVkfRaVq+oQUwE2+nrC/02JIjjiC0 8jDC0otmHD97LjSObLxc4kAklIJhnwFcq9fCOigQwva/HVRBH6E0ZbUtjhQzLfdx 5kicBn9rtcPSdeyo7JLPjdVvmGDZoqMBcnt3Vfso9p9kwjjzwtZg1G/rC+33ukBX 2TOA3QrRBniZtSX4hCwsw== 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=1788270358; x=1788356758; bh=k BYzCr8NQhvsbNexWcUVTFKpY2eB55ccLL1loHUgTYI=; b=DMyyF8tbTm846MhKz J6hKw7pRPk9e3xwD1ZFNI+fokFZxp1ImD5vMUlVi/ETuKisQSdiZROyegsqKPJuu aiTw0Y71FWLvWAi+0bzq/n+JAJ0RIKJeVqgXF2qWdI+g26rfNncMThgAVsni+uOa zKC2+DX++lGFZfcKGK+h+OCNqSztb4P1PUVt9JzNmkVInCEsCLnZQWb7u10IGAAx MjFVtsbQgjsKraMJVQ8lL2aVezpcj2HxU9AT+7lUtRXZ2DQpdxW8lUZxcbnlhjUy qvxAbD0j/85ioep8PdONdzsUWfcZ1J0dMtBWXXE2BLy2RmI4xXjCHMpabRM2plsH WmTdw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTGiQ9ZlRiJKC7D1d5DbbxIr+g55vUKGneT25tIRMdYB7k9WyFFnZehrURFTVYpo1W 8uZu4NqjR+kuwMmES6P3uwaQkgmKqGxxKSim8VJVBc81V1vfj4BBxc1mm7eaZY6HGk2VH6 6/5LNy1C3nY8ZFLHi56w8j8b+LGZLCEdnNYyr88OqyO2LRFubLgd9d2lIgmNhCYTS5PS+c QPA7kV6z2mnKnfD7tOwxwq5H06WLKaSyFE49R8r1afWyhqm1Iq1caezZ8QFao5RzFljygh 2tEFgZXcir9eShF+WIZQuuaXPJ96e7idd8zffgDbO7adFp3an2PgcZzpUj4Ud0JrKyGBR9 zM0XFXiGljdqaVygIYdppB8OfxQ0Lz9aAGgNziu7uSAo8uitvVHISFmdyyPsvUi7a17UBC pIsSWaf1/Em3MM4ybTkc5krd26jV8B/b1fvv79R7hL6gb5sXv09TJTLq7kd6hA81OHbXQi 3gIBpIv0PrkKcyX99nunGLVb6RQFkkbQL0T1PvVxc+b7KGGJM8/zMwKLuBGfUTtABgoAL5 v3YS0j0yhjmCmzqt09q6oRCartaJEqcSQOV2/Q/tbdXaFF6aaGUfdi/hS7LWYDXRc90e07 tO6mhh3mRL9B5ymzdT8nKxzU36VMF4xpGQwL7ycy61U3QBcUbnDL67LMUG0Q X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 1 Sep 2026 09:45:57 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, mistermidi@gmail.com, sreekuttan2156239@gmail.com Subject: [PATCH 13/13] firewire: core: add test for beyond-boundary case in config ROM generator Date: Tue, 1 Sep 2026 22:45:34 +0900 Message-ID: <20260901134534.2386577-14-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260901134534.2386577-1-o-takashi@sakamocchi.jp> References: <20260901134534.2386577-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" Although unit drivers and userspace applications are allowed to extend the system configuration ROM, they could provide invalid extension data. Add a KUnit test to verify that the generator does not write beyond the boundary of the configuration ROM when handling an extension. Signed-off-by: Takashi Sakamoto --- drivers/firewire/config-rom-generator-test.c | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/firewire/config-rom-generator-test.c b/drivers/firewir= e/config-rom-generator-test.c index 3114110307b5..212dbdcd43ba 100644 --- a/drivers/firewire/config-rom-generator-test.c +++ b/drivers/firewire/config-rom-generator-test.c @@ -342,6 +342,26 @@ static void add_descriptor_with_invalid_data(struct ku= nit *test) KUNIT_EXPECT_EQ(test, fw_core_add_descriptor(&entry_with_invalid_data), -= EINVAL); } =20 +static void add_descriptor_beyond_upper_limit(struct kunit *test) +{ + // Use kernel stack since they should be mutable for doubly linked-list. + struct fw_descriptor entry_beyond_upper_limit =3D { + .length =3D 255, + .key =3D (CSR_DIRECTORY | CSR_UNIT) << 24, + .data =3D NULL, + }; + u32 *data; + + data =3D kunit_kzalloc(test, entry_beyond_upper_limit.length, GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, data); + + data[0] =3D (entry_beyond_upper_limit.length - 1) << 16; + entry_beyond_upper_limit.data =3D data; + KUNIT_EXPECT_EQ(test, fw_core_add_descriptor(&entry_beyond_upper_limit), = -EBUSY); + + kunit_kfree(test, data); +} + static const struct fw_card_driver dummy_card_driver; =20 static int config_rom_generator_test_init(struct kunit *test) @@ -374,6 +394,7 @@ static struct kunit_case config_rom_generator_test_case= s[] =3D { KUNIT_CASE_PARAM(test_config_rom_generator, generator_test_gen_params), KUNIT_CASE(add_descriptor_with_invalid_length), KUNIT_CASE(add_descriptor_with_invalid_data), + KUNIT_CASE(add_descriptor_beyond_upper_limit), {} }; =20 --=20 2.53.0