From nobody Fri Dec 19 02:19:07 2025 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (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 22FAE63DA for ; Sun, 17 Dec 2023 10:30:19 +0000 (UTC) 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="svQuyeIP"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="GcoZR86Y" Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id E569F5C00C7; Sun, 17 Dec 2023 05:30:18 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 17 Dec 2023 05:30:18 -0500 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=fm2; t=1702809018; x= 1702895418; bh=1pTTxU/VbzAm0lsOewvACvD5yOw657Fm5X2fzaBqO2I=; b=s vQuyeIPK92jI1h59xHID4x1M1mY9Jc9uN0hTwfyXRUs9hkZgsDQVl7oA/tkOjAKA sxrTf4XLGx685gMpiAhLuzex0rCYuZX7VLq5hSnZzEfVmS08XfqjYQHS/hLg2Vm7 zISRUal77Dkt8EWpYbv7vdXTcOiqfalyXJytI+Wc79QcE1LK9gJUa+3NJg6DzXPG IDiuZ8MX3h2O+gCGr2nKou3fkfgwmiwJyLEWvxSWO7PIXBeUZMmXs7LoX94OCRN+ GIqp+tHB8l4Rq1FLwEL7yEtruY3K+S3a2fNlop2qQ0HLtjK0mACpszPPrU7MlG4e jBf/Y+mpKmzf/qaAQOatg== 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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1702809018; x= 1702895418; bh=1pTTxU/VbzAm0lsOewvACvD5yOw657Fm5X2fzaBqO2I=; b=G coZR86YNxYWIDNJxbKMR78//htusgLWPBhH6Iyg+Mgmiewk/fie4rsvi6EzOalW1 e+agUOJdeRXHoLQI9oclEVAzDmsxcc9g77+WbdQfj2vK6PcINGXVNFpeEarGRJmT 9TZID/PR++LQXVDbWlQqoYq2M/xp06aKbRmyrKvqDX5zJ0eXvAOtLI26FSyNj4M1 4qln2tEtaou5MCTD7tcVvzpBUZem0icJvXX4pyxT7rv3pCC3U6jMtFfwWJi4Rd1m Nnoeln/N1M5oPf8JWmh4AL535/mLXExobh7sFXoEqS2pkbQYs41qgycjoGhfEcBa WF0htMEfEZNzAHGMyaEdg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddtiedgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 17 Dec 2023 05:30:17 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [RFC PATCH 1/8] firewire: core: adds constant qualifier for local helper functions Date: Sun, 17 Dec 2023 19:30:04 +0900 Message-Id: <20231217103012.41273-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231217103012.41273-1-o-takashi@sakamocchi.jp> References: <20231217103012.41273-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 local functions just handles given argument as mutable, thus it is preferable to add constant qualifier to them. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-device.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index aa597cda0d88..16c32cb38f0f 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -171,7 +171,7 @@ static const struct ieee1394_device_id *unit_match(stru= ct device *dev, return NULL; } =20 -static bool is_fw_unit(struct device *dev); +static bool is_fw_unit(const struct device *dev); =20 static int fw_unit_match(struct device *dev, struct device_driver *drv) { @@ -679,7 +679,7 @@ static struct device_type fw_unit_type =3D { .release =3D fw_unit_release, }; =20 -static bool is_fw_unit(struct device *dev) +static bool is_fw_unit(const struct device *dev) { return dev->type =3D=3D &fw_unit_type; } @@ -838,7 +838,7 @@ static struct device_type fw_device_type =3D { .release =3D fw_device_release, }; =20 -static bool is_fw_device(struct device *dev) +static bool is_fw_device(const struct device *dev) { return dev->type =3D=3D &fw_device_type; } --=20 2.39.2 From nobody Fri Dec 19 02:19:07 2025 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (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 AF2E2613C for ; Sun, 17 Dec 2023 10:30:21 +0000 (UTC) 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="udElJpNm"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="0iS9cBa2" Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailout.nyi.internal (Postfix) with ESMTP id 83F015C0113; Sun, 17 Dec 2023 05:30:20 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Sun, 17 Dec 2023 05:30:20 -0500 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=fm2; t=1702809020; x= 1702895420; bh=/6Ta9woOfTDpfu4hjdamNnLTts8ODMKhVhLZw/OsZHE=; b=u dElJpNmM8IX4CREWPjR1PnG8MwDSKDRHAVTZrKhneacCnqx+wKR/qZqdl+JoBY5C nJA8uoI+3jxPH+rJht0btFRsEz5/DutSaYyXc/G739V3sQtqOa0s/a/wvDfclrGr L4uzK3Zefs9hZysyXzwfDMloUVQgxakrFq6NkPWLThL0m3hjfdWDm5pQmwzRoZFL TrtcYg7rqP09g7UiQdQ41oxkzu2KSVb9cUg+Oh/FTNZtbaPcb+CtgRxoLC6XjgAr QsNuYq8UgAvS/a7tIoBqUcesbo+v2Ns/aVtQ+b9YmoYr5abr5O9g1Vv56uoswlPl 158mjO6lsRK8VSDjUz/cA== 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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1702809020; x= 1702895420; bh=/6Ta9woOfTDpfu4hjdamNnLTts8ODMKhVhLZw/OsZHE=; b=0 iS9cBa2rjrrEO2hdjyh2xoBiMgmTZSLtPXEhg4/HDC5Fq3vXbQm5PIJlHS+XL5B1 x//TzfsE+P17ep6LzDmddcNm50cIwZsqWqzlXJRrd1oF1GbYLfFSU9m47YlpGsVN grQMOcp9umLrx9K2RDcN+W587+WpcT1ItRYbYNuSMVwQNW9gfJTQvhE+spMAMfW/ wDQBpLL3euQFDxc4OJS+qgs8YcCLymq0bSW6AgIqf2wtVyofSkWYiNQnmuPRCxOu DVUhSj91sYTb9zRXuWDjNVgcFVaxNhsapciEIpgqQE6YxbzyNDdIoYAtbg6UhN6g y3ko9UNv4buPzrKMj0F7w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddtiedgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 17 Dec 2023 05:30:19 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [RFC PATCH 2/8] firewire: core: replace magic number with macro Date: Sun, 17 Dec 2023 19:30:05 +0900 Message-Id: <20231217103012.41273-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231217103012.41273-1-o-takashi@sakamocchi.jp> References: <20231217103012.41273-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 specification, the size of bus information block of configuration ROM is fixed to 5, thus the offset of root directory is 5. Current implementation to handle device structures has the hard-coded offset. This commit replaces the offset with macro. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-device.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index 16c32cb38f0f..137001f8a695 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -31,6 +31,8 @@ =20 #include "core.h" =20 +#define ROOT_DIR_OFFSET 5 + void fw_csr_iterator_init(struct fw_csr_iterator *ci, const u32 *p) { ci->p =3D p + 1; @@ -135,7 +137,7 @@ static void get_ids(const u32 *directory, int *id) =20 static void get_modalias_ids(const struct fw_unit *unit, int *id) { - get_ids(&fw_parent_device(unit)->config_rom[5], id); + get_ids(&fw_parent_device(unit)->config_rom[ROOT_DIR_OFFSET], id); get_ids(unit->directory, id); } =20 @@ -259,7 +261,7 @@ static ssize_t show_immediate(struct device *dev, if (is_fw_unit(dev)) dir =3D fw_unit(dev)->directory; else - dir =3D fw_device(dev)->config_rom + 5; + dir =3D fw_device(dev)->config_rom + ROOT_DIR_OFFSET; =20 fw_csr_iterator_init(&ci, dir); while (fw_csr_iterator_next(&ci, &key, &value)) @@ -292,7 +294,7 @@ static ssize_t show_text_leaf(struct device *dev, if (is_fw_unit(dev)) dir =3D fw_unit(dev)->directory; else - dir =3D fw_device(dev)->config_rom + 5; + dir =3D fw_device(dev)->config_rom + ROOT_DIR_OFFSET; =20 if (buf) { bufsize =3D PAGE_SIZE - 1; @@ -446,7 +448,7 @@ static ssize_t units_show(struct device *dev, int key, value, i =3D 0; =20 down_read(&fw_device_rwsem); - fw_csr_iterator_init(&ci, &device->config_rom[5]); + fw_csr_iterator_init(&ci, &device->config_rom[ROOT_DIR_OFFSET]); while (fw_csr_iterator_next(&ci, &key, &value)) { if (key !=3D (CSR_UNIT | CSR_DIRECTORY)) continue; @@ -691,7 +693,7 @@ static void create_units(struct fw_device *device) int key, value, i; =20 i =3D 0; - fw_csr_iterator_init(&ci, &device->config_rom[5]); + fw_csr_iterator_init(&ci, &device->config_rom[ROOT_DIR_OFFSET]); while (fw_csr_iterator_next(&ci, &key, &value)) { if (key !=3D (CSR_UNIT | CSR_DIRECTORY)) continue; --=20 2.39.2 From nobody Fri Dec 19 02:19:07 2025 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (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 0B3976FBB for ; Sun, 17 Dec 2023 10:30:22 +0000 (UTC) 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="WBo7FkL2"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="jkJryLQ0" Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 16B1F5C011D; Sun, 17 Dec 2023 05:30:22 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 17 Dec 2023 05:30:22 -0500 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=fm2; t=1702809022; x= 1702895422; bh=zuT1CkGiLdT6oVSTIHR17WNH4PptubpxnOyzoYj857U=; b=W Bo7FkL2AwPXvHa40KrLdpILElFQK7ysX5Rdd9C+ESvBqiQH0UM1VRVNmlfbPYT+r V2rMkimslZnvyUC2FSuXbBV6J+UggE3/Tw6VSN7z2KUera1x63QbT1x/MT7NWA1U +VSADRs8M1sR40ezaePmu2xGXsS3JfTduykhMZ+6FJbO4K06GxLREb2K3dtCC8sw frB11UCPtc296UaFJ0qkRrW45/kYT3xqhYp6d1b2JITIOf3KYPOvvp4yYfi7xXXV epdjiYHxBWml0eJeyX5vWlo+B3Jc/SgUCSf2UqaV1jjeh84JF6BO/hwQWCZbXNvc LcO6pheSLyrIzZZgIG2oQ== 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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1702809022; x= 1702895422; bh=zuT1CkGiLdT6oVSTIHR17WNH4PptubpxnOyzoYj857U=; b=j kJryLQ0fhJvwgnsAkGHT8zFdqlgWmpOozHDyK5JIeC1YOrGOfmi1KnRhGp8AMXRP U8hLKw+TIayJYkYCaspdZl0XR31wl+Z91TUf7COrbnSfCcovfcqHZSAaSVQcg3qt Va2FFmPJUCD3A+GbrShHMdgU3GGbmqaMcHb0TdDkUpiEju9uBRTuOgkZ3WnA4sN1 LCIUMiaethl7HL1S3fZ7ll+3qxLgvnLmpr+VOVS5I/GdkvY7i0i05d6jazN5ylUI dseAo6fbbL1pgQu2QohhUy0jJDkNMSiRK/R0IwYyOt4HPP9znOavhEvV08edbZuK +HheYbfvtbxB9vwBI8CBQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddtiedgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeeugfevtd efhfeffeeuudduhfekhffgveejfeeiiefftdethfduudevjeekveffleenucffohhmrghi nhepthgvshhtrghnhihthhhinhhgrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhi rdhjph X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 17 Dec 2023 05:30:20 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [RFC PATCH 3/8] firewire: test: add KUnit test for internal CSR API Date: Sun, 17 Dec 2023 19:30:06 +0900 Message-Id: <20231217103012.41273-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231217103012.41273-1-o-takashi@sakamocchi.jp> References: <20231217103012.41273-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 operation over CSR space is important since it is related to detection of nodes and units, addition of system devices. Any test of the operation is enough useful. This commit adds a skeleton of KUnit test for the purpose. Signed-off-by: Takashi Sakamoto --- drivers/firewire/.kunitconfig | 1 + drivers/firewire/Kconfig | 16 ++++++++++++++++ drivers/firewire/core-device.c | 4 ++++ drivers/firewire/csr-api-test.c | 19 +++++++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 drivers/firewire/csr-api-test.c diff --git a/drivers/firewire/.kunitconfig b/drivers/firewire/.kunitconfig index 1599e069395f..03104cdd06eb 100644 --- a/drivers/firewire/.kunitconfig +++ b/drivers/firewire/.kunitconfig @@ -2,3 +2,4 @@ CONFIG_KUNIT=3Dy CONFIG_PCI=3Dy CONFIG_FIREWIRE=3Dy CONFIG_FIREWIRE_KUNIT_UAPI_TEST=3Dy +CONFIG_FIREWIRE_KUNIT_CSR_API_TEST=3Dy diff --git a/drivers/firewire/Kconfig b/drivers/firewire/Kconfig index 0a6596b027db..184906fdb77a 100644 --- a/drivers/firewire/Kconfig +++ b/drivers/firewire/Kconfig @@ -34,6 +34,22 @@ config FIREWIRE_KUNIT_UAPI_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_CSR_API_TEST + tristate "KUnit tests for internal CSR API" if !KUNIT_ALL_TESTS + depends on FIREWIRE && KUNIT + default KUNIT_ALL_TESTS + help + This builds the KUnit tests for internal API for Control and + Status Registers. + + 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 && MMU diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index 137001f8a695..14c7461c05f6 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -1313,3 +1313,7 @@ void fw_node_event(struct fw_card *card, struct fw_no= de *node, int event) break; } } + +#ifdef CONFIG_FIREWIRE_KUNIT_CSR_API_TEST +#include "csr-api-test.c" +#endif diff --git a/drivers/firewire/csr-api-test.c b/drivers/firewire/csr-api-tes= t.c new file mode 100644 index 000000000000..a76d767373e9 --- /dev/null +++ b/drivers/firewire/csr-api-test.c @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// csr-api-test.c - An application of Kunit to test implementation for CSR= operation. +// +// Copyright (c) 2023 Takashi Sakamoto +// +// This file can not be built independently since it is intentionally incl= uded in core-device.c. + +#include + +static struct kunit_case csr_api_test_cases[] =3D { + {} +}; + +static struct kunit_suite csr_api_test_suite =3D { + .name =3D "firewire-csr-api", + .test_cases =3D csr_api_test_cases, +}; +kunit_test_suite(csr_api_test_suite); --=20 2.39.2 From nobody Fri Dec 19 02:19:07 2025 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (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 5CFDF79FE for ; Sun, 17 Dec 2023 10:30:24 +0000 (UTC) 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="KvG2nBiK"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="c85hszWK" Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 9ED9D5C00C6; Sun, 17 Dec 2023 05:30:23 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 17 Dec 2023 05:30:23 -0500 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=fm2; t=1702809023; x= 1702895423; bh=T7D+9jTfh4ZrMx7I02CJXosQOWU8TluFcGjtBl8VhDs=; b=K vG2nBiKk2O9qeipWIanfaFHA65T25As644TAUB71MEr76M3ki+M9mqVfYo40vL+9 DU/al48z3VKklj/mLtcn6D9Fb7gqRuaFpV/aQejkR4U8Yql0NIZhLhly2UOw9Z10 V54QAcbPCJtEgvp07jvnS+Jkk3ceOzf9pLAUTWWjrMM4YMUFgYVzqkGnr3q4jM7M faK0/SwJsnwz5wz6eunimhRkVFYRfLy4dKzXK3pVQAU8ELq5asJzi7oo7obGJVP/ KirHXtG5uDD1Pgfk3dVF985vrJCgz792IJu02Xvj6AHMRt8ZndcF32xZWbmwTDb2 2Dap6MrM1i9Y9qrEvvGBw== 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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1702809023; x= 1702895423; bh=T7D+9jTfh4ZrMx7I02CJXosQOWU8TluFcGjtBl8VhDs=; b=c 85hszWKzviDPrRcb3vbezT6Uxt5adx534SWWdRDtBqISCPloy2A3l8GZQbF9mA0m EFXLuv+lJhX4qEZ+2Rw4/jnsC59pDGFocbt7CNvKtsg33fd3Q15CBShiaKT9aSeq bNSSM4XS7tE4KS//Haca4hAJZ0KLHul4/NiOL9rpwHYoMwUSwRWm1SzSof1dO0JF rTthzPjaHNkiOVx01815koz5pfmH+zME1X+yumSBE9ZZiPy47soJ0iwAxP1o+WzM Esw3UXGQzwPbt78BDjcoN8lzvjmpzzY/3077Jw2XsDyNvadgMJQ/hg3WV9RG7sus LygReovFILCiGRscwGjeA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddtiedgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeffvefhff dugeetkeektdegheejheegteegffeihfevvefggfeuueekvdeffeehfeenucffohhmrghi nhepkhgvrhhnvghlrdhorhhgpdguvghvihgtvgdrughirhgvtghtohhrhienucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhi sehsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 17 Dec 2023 05:30:22 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [RFC PATCH 4/8] firewire: test: add test of CSR API for simple AV/C device Date: Sun, 17 Dec 2023 19:30:07 +0900 Message-Id: <20231217103012.41273-5-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231217103012.41273-1-o-takashi@sakamocchi.jp> References: <20231217103012.41273-1-o-takashi@sakamocchi.jp> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" At present, core function can handle node which has configuration ROM similar to AV/C device somehow. The standard layout of configuration ROM for AV/C device is described in the following document. - Configuration ROM for AV/C Devices 1.0 (Dec. 12, 2000, 1394 Trading Association) This commit adds a KUnit test for this case. The following output is the parse result by config-rom-pretty-printer in linux-firewire-utils (https://git.kernel.org/pub/scm/utils/ieee1394/linux-firewire-utils.git/). $ config-rom-pretty-printer < /tmp/rom.img ROM header and bus information block ------------------------------------------------------------= ----- 1024 0404eabf bus_info_length 4, crc_length 4, crc 60095 1028 31333934 bus_name "1394" 1032 e0646102 irmc 1, cmc 1, isc 1, bmc 0, cyc_clk_acc 100, max_rec 6 (12= 8) 1036 ffffffff company_id ffffff | 1040 ffffffff device_id 1099511627775 | EUI-64 18446744073709551615 root directory ------------------------------------------------------------= ----- 1044 00063287 directory_length 6, crc 12935 1048 03ffffff vendor 1052 8100000a --> descriptor leaf at 1092 1056 17ffffff model 1060 8100000e --> descriptor leaf at 1116 1064 0c0083c0 node capabilities: per IEEE 1394 1068 d1000001 --> unit directory at 1072 unit directory at 1072 ------------------------------------------------------------= ----- 1072 0004442d directory_length 4, crc 17453 1076 1200a02d specifier id 1080 13010001 version 1084 17ffffff model 1088 81000007 --> descriptor leaf at 1116 descriptor leaf at 1092 ------------------------------------------------------------= ----- 1092 0005c915 leaf_length 5, crc 51477 1096 00000000 textual descriptor 1100 00000000 minimal ASCII 1104 56656e64 "Vend" 1108 6f72204e "or N" 1112 616d6500 "ame" descriptor leaf at 1116 ------------------------------------------------------------= ----- 1116 00057f16 leaf_length 5, crc 32534 1120 00000000 textual descriptor 1124 00000000 minimal ASCII 1128 4d6f6465 "Mode" 1132 6c204e61 "l Na" 1136 6d650000 "me" Signed-off-by: Takashi Sakamoto --- drivers/firewire/csr-api-test.c | 119 ++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/drivers/firewire/csr-api-test.c b/drivers/firewire/csr-api-tes= t.c index a76d767373e9..d91852825efc 100644 --- a/drivers/firewire/csr-api-test.c +++ b/drivers/firewire/csr-api-test.c @@ -8,7 +8,126 @@ =20 #include =20 +// Configuration ROM for AV/C Devices 1.0 (Dec. 12, 2000, 1394 Trading Ass= ociation) +// Annex C:Configuration ROM example(informative) +// C.1 Simple AV/C device +// +// Copied from the documentation. +static const u32 simple_avc_device[] =3D { + 0x0404eabf, + 0x31333934, + 0xe0646102, + 0xffffffff, + 0xffffffff, + 0x00063287, // root directory. + 0x03ffffff, + 0x8100000a, + 0x17ffffff, + 0x8100000e, + 0x0c0083c0, + 0xd1000001, + 0x0004442d, // unit 0 directory. + 0x1200a02d, + 0x13010001, + 0x17ffffff, + 0x81000007, + 0x0005c915, // leaf. + 0x00000000, + 0x00000000, + 0x56656e64, + 0x6f72204e, + 0x616d6500, + 0x00057f16, // leaf. + 0x00000000, + 0x00000000, + 0x4d6f6465, + 0x6c204e61, + 0x6d650000, +}; + +static void csr_api_simple_avc_device(struct kunit *test) +{ + static const struct fw_device node =3D { + .device =3D { + .type =3D &fw_device_type, + }, + .config_rom =3D simple_avc_device, + .config_rom_length =3D sizeof(simple_avc_device), + }; + static const struct fw_unit unit0 =3D { + .device =3D { + .type =3D &fw_unit_type, + .parent =3D (struct device *)&node.device, + }, + .directory =3D &simple_avc_device[12], + }; + struct device *node_dev =3D (struct device *)&node.device; + struct device *unit0_dev =3D (struct device *)&unit0.device; + static const int unit_expected_ids[] =3D {0x00ffffff, 0x00ffffff, 0x0000a= 02d, 0x00010001}; + char *buf =3D kunit_kzalloc(test, PAGE_SIZE, GFP_KERNEL); + int ids[4] =3D {0, 0, 0, 0}; + + // Ensure associations for node and unit devices. + + KUNIT_ASSERT_TRUE(test, is_fw_device(node_dev)); + KUNIT_ASSERT_FALSE(test, is_fw_unit(node_dev)); + KUNIT_ASSERT_PTR_EQ(test, fw_device(node_dev), &node); + + KUNIT_ASSERT_FALSE(test, is_fw_device(unit0_dev)); + KUNIT_ASSERT_TRUE(test, is_fw_unit(unit0_dev)); + KUNIT_ASSERT_PTR_EQ(test, fw_parent_device((&unit0)), &node); + KUNIT_ASSERT_PTR_EQ(test, fw_unit(unit0_dev), &unit0); + + // For entries in root directory. + + // Vendor immediate entry is found. + KUNIT_EXPECT_GT(test, show_immediate(node_dev, &config_rom_attributes[0].= attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "0xffffff\n"); + + // Model immediate entry is found. + KUNIT_EXPECT_GT(test, show_immediate(node_dev, &config_rom_attributes[4].= attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "0xffffff\n"); + + // Descriptor leaf entry for vendor is found. + KUNIT_EXPECT_GT(test, show_text_leaf(node_dev, &config_rom_attributes[5].= attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "Vendor Name\n"); + + // Descriptor leaf entry for model is found. + KUNIT_EXPECT_GT(test, show_text_leaf(node_dev, &config_rom_attributes[6].= attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "Model Name\n"); + + // For entries in unit 0 directory. + + // Vendor immediate entry is not found. + KUNIT_EXPECT_LT(test, show_immediate(unit0_dev, &config_rom_attributes[0]= .attr, buf), 0); + + // Model immediate entry is found. + KUNIT_EXPECT_GT(test, show_immediate(unit0_dev, &config_rom_attributes[4]= .attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "0xffffff\n"); + + // Descriptor leaf entry for vendor is not found. + KUNIT_EXPECT_LT(test, show_text_leaf(unit0_dev, &config_rom_attributes[5]= .attr, buf), 0); + + // Descriptor leaf entry for model is not found. + KUNIT_EXPECT_GT(test, show_text_leaf(unit0_dev, &config_rom_attributes[6]= .attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "Model Name\n"); + + // Specifier_ID immediate entry is found. + KUNIT_EXPECT_GT(test, show_immediate(unit0_dev, &config_rom_attributes[2]= .attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "0x00a02d\n"); + + // Version immediate entry is found. + KUNIT_EXPECT_GT(test, show_immediate(unit0_dev, &config_rom_attributes[3]= .attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "0x010001\n"); + + kunit_kfree(test, buf); + + get_modalias_ids(&unit0, ids); + KUNIT_EXPECT_MEMEQ(test, ids, unit_expected_ids, sizeof(ids)); +} + static struct kunit_case csr_api_test_cases[] =3D { + KUNIT_CASE(csr_api_simple_avc_device), {} }; =20 --=20 2.39.2 From nobody Fri Dec 19 02:19:07 2025 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (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 35EB0F51E for ; Sun, 17 Dec 2023 10:30:25 +0000 (UTC) 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="wXQiiYFv"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Ot6ilm+J" Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 31C4F5C0071; Sun, 17 Dec 2023 05:30:25 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 17 Dec 2023 05:30:25 -0500 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=fm2; t=1702809025; x= 1702895425; bh=My9Ypl5CIcGspchG4H7P6FMpwoU6YQCrhQk5UHWKnjE=; b=w XQiiYFvR2H5rNzMCTbrunsykEWX3RX+445TfUYsvesPMVvJEKvWda8AmpVhzf5bk ZiKmhe2tXhH6i8z1lrrHxZTn5EPhTB61OnTZAeNlsfXrxJ/6kvnMX9suqu2OD+la BEYwua7f6qon9xelq3SqOwMlZeyAJrespoeftaaalMuDfgw6YhtM4ZrTtp/hS9fz gBXlUiN4iXI/m5Q3wtnDZX0hCQ2VarpxGHlQZWB/22LWTORP6/FWcijNUoav9+Zy lg5H21E2Azh5qx8PBOM09UP44kssEZtXhEtQQ08e9Sc72deCXj/jM1ezOu7PxHlH ICj4lRdbrG3txv3t3T/vw== 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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1702809025; x= 1702895425; bh=My9Ypl5CIcGspchG4H7P6FMpwoU6YQCrhQk5UHWKnjE=; b=O t6ilm+Jcwqoz72Z8EAXdnw8YbtsLmgJCRBp1QayC+B8FdlbxPGvEozKPGz4hL0va fuVx3E3nsxf9ITGOWM3TYGWJO6kPUfZ0nZgoULN99sIRkSFO0rJhxdNIJKzKKGzn a8Bl1hub3FFMbQJQWsH/6tNYqXdbjyxvzFNc8IwL26Dpz4xcVOwHgT09NDDe39+2 27cGp5SMe+xHr8CiohbHfuoUYatJw/DuRo3vzJVYRVlZQ65gVE1aE+kYWr42y+AE Fdn3+/OnEVTVEdFAltfkdtm85BMheZb4ym2uf//RcpUMVV8yOzD38mtBySISIxo5 XOUe9GiqdnDWgnpn1ccSg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddtiedgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeffvefhff dugeetkeektdegheejheegteegffeihfevvefggfeuueekvdeffeehfeenucffohhmrghi nhepkhgvrhhnvghlrdhorhhgpdguvghvihgtvgdrughirhgvtghtohhrhienucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhi sehsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 17 Dec 2023 05:30:23 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [RFC PATCH 5/8] firewire: test: add test of CSR API for legacy AV/C device Date: Sun, 17 Dec 2023 19:30:08 +0900 Message-Id: <20231217103012.41273-6-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231217103012.41273-1-o-takashi@sakamocchi.jp> References: <20231217103012.41273-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 legacy devices have configuration ROM against standard AV/C device. They have vendor directory to store model identifier. It is described in annex of the following document. - Configuration ROM for AV/C Devices 1.0 (Dec. 12, 2000, 1394 Trading Association) In the case, current implementation of core function does not detect the model identifier, thus device attributes and modalias of unit have lack of it. Another KUnit test is required for the case. The following output is the parse result by config-rom-pretty-printer in linux-firewire-utils (https://git.kernel.org/pub/scm/utils/ieee1394/linux-firewire-utils.git/). The content of image is written by my hand. $ config-rom-pretty-printer < /tmp/rom.img ROM header and bus information block ------------------------------------------------------------= ----- 1024 04199fe7 bus_info_length 4, crc_length 25, crc 40935 1028 31333934 bus_name "1394" 1032 e0644000 irmc 1, cmc 1, isc 1, bmc 0, cyc_clk_acc 100, max_rec 4 (32) 1036 00112233 company_id 001122 | 1040 44556677 device_id 220189779575 | EUI-64 4822678189205111 root directory ------------------------------------------------------------= ----- 1044 0005dace directory_length 5, crc 56014 1048 03012345 vendor 1052 0c0083c0 node capabilities: per IEEE 1394 1056 8d000009 --> eui-64 leaf at 1092 1060 d1000002 --> unit directory at 1068 1064 c3000004 --> vendor directory at 1080 unit directory at 1068 ------------------------------------------------------------= ----- 1068 0002e107 directory_length 2, crc 57607 1072 12abcdef specifier id 1076 13543210 version vendor directory at 1080 ------------------------------------------------------------= ----- 1080 0002cb73 directory_length 2, crc 52083 1084 17fedcba model 1088 81000004 --> descriptor leaf at 1104 eui-64 leaf at 1092 ------------------------------------------------------------= ----- 1092 00026dc1 leaf_length 2, crc 28097 1096 00112233 company_id 001122 | 1100 44556677 device_id 220189779575 | EUI-64 4822678189205111 descriptor leaf at 1104 ------------------------------------------------------------= ----- 1104 00050e84 leaf_length 5, crc 3716 1108 00000000 textual descriptor 1112 00000000 minimal ASCII 1116 41424344 "ABCD" 1120 45464748 "EFGH" 1124 494a0000 "IJ" Signed-off-by: Takashi Sakamoto --- drivers/firewire/csr-api-test.c | 111 ++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/drivers/firewire/csr-api-test.c b/drivers/firewire/csr-api-tes= t.c index d91852825efc..2430891c5dcb 100644 --- a/drivers/firewire/csr-api-test.c +++ b/drivers/firewire/csr-api-test.c @@ -45,6 +45,40 @@ static const u32 simple_avc_device[] =3D { 0x6d650000, }; =20 +// Ibid. +// Annex A:Consideration for configuration ROM reader design (informative) +// A.1 Vendor directory +// +// Written by hand. +static const u32 legacy_avc_device[] =3D { + 0x04199fe7, + 0x31333934, + 0xe0644000, + 0x00112233, + 0x44556677, + 0x0005dace, // root directory. + 0x03012345, + 0x0c0083c0, + 0x8d000009, + 0xd1000002, + 0xc3000004, + 0x0002e107, // unit 0 directory. + 0x12abcdef, + 0x13543210, + 0x0002cb73, // vendor directory. + 0x17fedcba, + 0x81000004, + 0x00026dc1, // leaf for EUI-64. + 0x00112233, + 0x44556677, + 0x00050e84, // leaf for text descriptor. + 0x00000000, + 0x00000000, + 0x41424344, + 0x45464748, + 0x494a0000, +}; + static void csr_api_simple_avc_device(struct kunit *test) { static const struct fw_device node =3D { @@ -126,8 +160,85 @@ static void csr_api_simple_avc_device(struct kunit *te= st) KUNIT_EXPECT_MEMEQ(test, ids, unit_expected_ids, sizeof(ids)); } =20 +static void csr_api_legacy_avc_device(struct kunit *test) +{ + static const struct fw_device node =3D { + .device =3D { + .type =3D &fw_device_type, + }, + .config_rom =3D legacy_avc_device, + .config_rom_length =3D sizeof(legacy_avc_device), + }; + static const struct fw_unit unit0 =3D { + .device =3D { + .type =3D &fw_unit_type, + .parent =3D (struct device *)&node.device, + }, + .directory =3D &legacy_avc_device[11], + }; + struct device *node_dev =3D (struct device *)&node.device; + struct device *unit0_dev =3D (struct device *)&unit0.device; + static const int unit_expected_ids[] =3D {0x00012345, 0x00000000, 0x00abc= def, 0x00543210}; + char *buf =3D kunit_kzalloc(test, PAGE_SIZE, GFP_KERNEL); + int ids[4] =3D {0, 0, 0, 0}; + + // Ensure associations for node and unit devices. + + KUNIT_ASSERT_TRUE(test, is_fw_device(node_dev)); + KUNIT_ASSERT_FALSE(test, is_fw_unit(node_dev)); + KUNIT_ASSERT_PTR_EQ(test, fw_device((node_dev)), &node); + + KUNIT_ASSERT_FALSE(test, is_fw_device(unit0_dev)); + KUNIT_ASSERT_TRUE(test, is_fw_unit(unit0_dev)); + KUNIT_ASSERT_PTR_EQ(test, fw_parent_device((&unit0)), &node); + KUNIT_ASSERT_PTR_EQ(test, fw_unit(unit0_dev), &unit0); + + // For entries in root directory. + + // Vendor immediate entry is found. + KUNIT_EXPECT_GT(test, show_immediate(node_dev, &config_rom_attributes[0].= attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "0x012345\n"); + + // Model immediate entry is not found. + KUNIT_EXPECT_LT(test, show_immediate(node_dev, &config_rom_attributes[4].= attr, buf), 0); + + // Descriptor leaf entry for vendor is not found. + KUNIT_EXPECT_LT(test, show_text_leaf(node_dev, &config_rom_attributes[5].= attr, buf), 0); + + // Descriptor leaf entry for model is not found. + KUNIT_EXPECT_LT(test, show_text_leaf(node_dev, &config_rom_attributes[6].= attr, buf), 0); + + // For entries in unit 0 directory. + + // Vendor immediate entry is not found. + KUNIT_EXPECT_LT(test, show_immediate(unit0_dev, &config_rom_attributes[0]= .attr, buf), 0); + + // Model immediate entry is not found. + KUNIT_EXPECT_LT(test, show_immediate(unit0_dev, &config_rom_attributes[4]= .attr, buf), 0); + + // Descriptor leaf entry for vendor is not found. + KUNIT_EXPECT_LT(test, show_text_leaf(unit0_dev, &config_rom_attributes[5]= .attr, buf), 0); + + // Descriptor leaf entry for model is not found. + KUNIT_EXPECT_LT(test, show_text_leaf(unit0_dev, &config_rom_attributes[6]= .attr, buf), 0); + + // Specifier_ID immediate entry is found. + KUNIT_EXPECT_GT(test, show_immediate(unit0_dev, &config_rom_attributes[2]= .attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "0xabcdef\n"); + + // Version immediate entry is found. + KUNIT_EXPECT_GT(test, show_immediate(unit0_dev, &config_rom_attributes[3]= .attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "0x543210\n"); + + kunit_kfree(test, buf); + + get_modalias_ids(&unit0, ids); + KUNIT_EXPECT_MEMEQ(test, ids, unit_expected_ids, sizeof(ids)); +} + static struct kunit_case csr_api_test_cases[] =3D { KUNIT_CASE(csr_api_simple_avc_device), + KUNIT_CASE(csr_api_legacy_avc_device), {} }; =20 --=20 2.39.2 From nobody Fri Dec 19 02:19:07 2025 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (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 71D9410780 for ; Sun, 17 Dec 2023 10:30:27 +0000 (UTC) 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="Rk1TfrRj"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="YAHuSqyy" Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id AEBD45C0121; Sun, 17 Dec 2023 05:30:26 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 17 Dec 2023 05:30:26 -0500 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=fm2; t=1702809026; x= 1702895426; bh=tlbzFSAVTLU8/7G01uILlJQsR6kJ19oJ8HcV/Gzb9L4=; b=R k1TfrRj48BMz1MjS4u8ALG0bH6VytvO3Ks+uyTt3tysT/qxD/F7+qn8ntX0/idLs qifyXWL5c7Ub3mTI6lkCsY0tz+XnWhnnz3JsXdqr6u5yXgJfnUwQ+nkRuxmhSQoy mfGpFgzEuwDHFfekEH3E8H0jtWBOejhWOrUgaVr29ZoCkILA3WJGgejGdZoa+JEh f4lf3Oat5d7R6jvypX5OsPNzgv8l5zCGLS1TU+Q2cpB2hgeTMs0fCNzdK9vZzbUS wh9o67eblJ/PUXZKPCnw5VsLHkGmVUqunTb3WUr6/kWe8CzYkuqglYk3Gb3W9Foo dGK+xCww6cfdoXmbezmBQ== 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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1702809026; x= 1702895426; bh=tlbzFSAVTLU8/7G01uILlJQsR6kJ19oJ8HcV/Gzb9L4=; b=Y AHuSqyylVf0N9ClmS5/VH/M860iogNWeUBXk+e91Mg5z+IXU8tbtQ0hRkc5MlCIk PTRb0qRp0lE+FuQXv1na0aTpKnvWwEViovUFXXIrUGCEABk3ZqTWFb3OjMz2wuWA 2rPuUaN1DB0XiGO9Jimm/9oPbGiLYXRZsYJCy5f1mIYqheAdP5jZm2JBTPD9UzdA 8YGg4e0LnkgUZfnrhlyOyEEeE2GCBPaeylY8OLQ7XXnBz0LOdrs2b/1Sqfb7a1xV qxVobTdUe1R2nTSaedwU1M8KxG2TGtj+jq0MoiGOqeW4MKnXOEP+xAeyuEXdmya6 i+b7Ntj+VlQpjUeIgzNiw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddtiedgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 17 Dec 2023 05:30:25 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [RFC PATCH 6/8] firewire: core: detect numeric model identifier for legacy layout of configuration ROM Date: Sun, 17 Dec 2023 19:30:09 +0900 Message-Id: <20231217103012.41273-7-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231217103012.41273-1-o-takashi@sakamocchi.jp> References: <20231217103012.41273-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" As the part of support for legacy layout of configuration ROM, this commit traverse vendor directory as well as root directory when showing device attribute for node device. This change expects 'model' attribute appears in node device, however it is probable to see the other types of immediate values if the vendor directory includes. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-device.c | 57 +++++++++++++++++++++++++-------- drivers/firewire/csr-api-test.c | 5 +-- 2 files changed, 47 insertions(+), 15 deletions(-) diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index 14c7461c05f6..dad5c9937b78 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -49,6 +49,22 @@ int fw_csr_iterator_next(struct fw_csr_iterator *ci, int= *key, int *value) } EXPORT_SYMBOL(fw_csr_iterator_next); =20 +static const u32 *search_directory(const u32 *directory, int search_key) +{ + struct fw_csr_iterator ci; + int key, value; + + search_key |=3D CSR_DIRECTORY; + + fw_csr_iterator_init(&ci, directory); + while (fw_csr_iterator_next(&ci, &key, &value)) { + if (key =3D=3D search_key) + return ci.p - 1 + value; + } + + return NULL; +} + static const u32 *search_leaf(const u32 *directory, int search_key) { struct fw_csr_iterator ci; @@ -253,27 +269,42 @@ static ssize_t show_immediate(struct device *dev, struct config_rom_attribute *attr =3D container_of(dattr, struct config_rom_attribute, attr); struct fw_csr_iterator ci; - const u32 *dir; - int key, value, ret =3D -ENOENT; + const u32 *directories[] =3D {NULL, NULL}; + int i, value =3D -1; =20 down_read(&fw_device_rwsem); =20 - if (is_fw_unit(dev)) - dir =3D fw_unit(dev)->directory; - else - dir =3D fw_device(dev)->config_rom + ROOT_DIR_OFFSET; + if (is_fw_unit(dev)) { + directories[0] =3D fw_unit(dev)->directory; + } else { + const u32 *root_directory =3D fw_device(dev)->config_rom + ROOT_DIR_OFFS= ET; =20 - fw_csr_iterator_init(&ci, dir); - while (fw_csr_iterator_next(&ci, &key, &value)) - if (attr->key =3D=3D key) { - ret =3D snprintf(buf, buf ? PAGE_SIZE : 0, - "0x%06x\n", value); - break; + directories[0] =3D root_directory; + + // Legacy layout of configuration ROM described in Annex 1 of 'Configura= tion ROM + // for AV/C Devices 1.0 (December 12, 2000, 1394 Trading Association, TA= Document + // 1999027)'. + directories[1] =3D search_directory(root_directory, CSR_VENDOR); + } + + for (i =3D 0; i < ARRAY_SIZE(directories) && !!directories[i]; ++i) { + int key, val; + + fw_csr_iterator_init(&ci, directories[i]); + while (fw_csr_iterator_next(&ci, &key, &val)) { + if (attr->key =3D=3D key) { + value =3D val; + break; + } } + } =20 up_read(&fw_device_rwsem); =20 - return ret; + if (value < 0) + return -ENOENT; + + return snprintf(buf, buf ? PAGE_SIZE : 0, "0x%06x\n", value); } =20 #define IMMEDIATE_ATTR(name, key) \ diff --git a/drivers/firewire/csr-api-test.c b/drivers/firewire/csr-api-tes= t.c index 2430891c5dcb..7278e7b927a8 100644 --- a/drivers/firewire/csr-api-test.c +++ b/drivers/firewire/csr-api-test.c @@ -199,8 +199,9 @@ static void csr_api_legacy_avc_device(struct kunit *tes= t) KUNIT_EXPECT_GT(test, show_immediate(node_dev, &config_rom_attributes[0].= attr, buf), 0); KUNIT_EXPECT_STREQ(test, buf, "0x012345\n"); =20 - // Model immediate entry is not found. - KUNIT_EXPECT_LT(test, show_immediate(node_dev, &config_rom_attributes[4].= attr, buf), 0); + // Model immediate entry is found. + KUNIT_EXPECT_GT(test, show_immediate(node_dev, &config_rom_attributes[4].= attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "0xfedcba\n"); =20 // Descriptor leaf entry for vendor is not found. KUNIT_EXPECT_LT(test, show_text_leaf(node_dev, &config_rom_attributes[5].= attr, buf), 0); --=20 2.39.2 From nobody Fri Dec 19 02:19:07 2025 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (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 324B310974 for ; Sun, 17 Dec 2023 10:30:28 +0000 (UTC) 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="QxVvzmHN"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="rIq1W5qf" Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 4CBB55C0126; Sun, 17 Dec 2023 05:30:28 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 17 Dec 2023 05:30:28 -0500 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=fm2; t=1702809028; x= 1702895428; bh=z73jY6BHHBYZhY9lJ5vLyunAPVGK9kE6VxjU8LqOq38=; b=Q xVvzmHNtLvMdgHrGxjwkBlFWXsuhhYJZaIIFCaKiGA/TzDXFuymTP2S+TDIKVNzz vPVa+UR4Ey13PcFMasMPcvpggQDTI33dlZfhQ0xVC8vsYlcQnF11gxVNTZUCiIyG 7KmHgE3cu52fn0rl8M/7th2ESS4oOJgrjyakhb1naFZKD9Fuor868jUJTxRTaNQ2 MYtwfXl3jmAe3xJ3vrtnDGfdx/yDkb1Y7PJhKJI1sCJWR+T63Gin9LplhXW8jzBH wPyI/eKYTT4xzkxDQOdmq/MwwmojxzCUDVybBCkz7x+94MC5tRWcTLx4K4J0DL9d dgpUZfYXy6/wWAA0tthxA== 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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1702809028; x= 1702895428; bh=z73jY6BHHBYZhY9lJ5vLyunAPVGK9kE6VxjU8LqOq38=; b=r Iq1W5qfdH6+UiUFI6R6DIKEGU/rj7RiVJTS54GjkUqBl/rk9gsj3rBGqNJspMuVQ LJgHTfX23ssDoh/H9C+zpNsRDN4l49ncGyDNRInA/AcTIbsnf6aiM5BFZTJUjKWT iwOHEbv52l+k3Z2Qz95eovnI9DkwVyN82Nw+JK4MsD+yDA/PibvBymA/LKMYq5BK Vg1fdjZc4PJrMSGrbA/ylZZNu/rCibyx7lyPJN3PW0JcEfmLZ5kLB848qJIk9Kzn CMc3LAkmU8dTpOLAu5DacPCYS5yAvL1+aVtbxAdQdqqXzeMR6BMOVQ0aar5LwD9J Zp27HMvM6fKt+7TfYxdyw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddtiedgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 17 Dec 2023 05:30:26 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [RFC PATCH 7/8] firewire: core: detect model name for legacy layout of configuration ROM Date: Sun, 17 Dec 2023 19:30:10 +0900 Message-Id: <20231217103012.41273-8-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231217103012.41273-1-o-takashi@sakamocchi.jp> References: <20231217103012.41273-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" As the part of support for legacy layout of configuration ROM, this commit traverse vendor directory as well as root directory when showing device attribute for node device. This change expects 'model_name' attribute appears in node device, however it is probable to see the other types of descriptor leaf if the vendor directory includes. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-device.c | 23 ++++++++++++++++------- drivers/firewire/csr-api-test.c | 5 +++-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index dad5c9937b78..f7a11004f972 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -315,17 +315,25 @@ static ssize_t show_text_leaf(struct device *dev, { struct config_rom_attribute *attr =3D container_of(dattr, struct config_rom_attribute, attr); - const u32 *dir; + const u32 *directories[] =3D {NULL, NULL}; size_t bufsize; char dummy_buf[2]; - int ret; + int i, ret; =20 down_read(&fw_device_rwsem); =20 - if (is_fw_unit(dev)) - dir =3D fw_unit(dev)->directory; - else - dir =3D fw_device(dev)->config_rom + ROOT_DIR_OFFSET; + if (is_fw_unit(dev)) { + directories[0] =3D fw_unit(dev)->directory; + } else { + const u32 *root_directory =3D fw_device(dev)->config_rom + ROOT_DIR_OFFS= ET; + + directories[0] =3D root_directory; + + // Legacy layout of configuration ROM described in Annex 1 of 'Configura= tion ROM + // for AV/C Devices 1.0 (December 12, 2000, 1394 Trading Association, TA= Document + // 1999027)'. + directories[1] =3D search_directory(root_directory, CSR_VENDOR); + } =20 if (buf) { bufsize =3D PAGE_SIZE - 1; @@ -334,7 +342,8 @@ static ssize_t show_text_leaf(struct device *dev, bufsize =3D 1; } =20 - ret =3D fw_csr_string(dir, attr->key, buf, bufsize); + for (i =3D 0; i < ARRAY_SIZE(directories) && directories[i]; ++i) + ret =3D fw_csr_string(directories[i], attr->key, buf, bufsize); =20 if (ret >=3D 0) { /* Strip trailing whitespace and add newline. */ diff --git a/drivers/firewire/csr-api-test.c b/drivers/firewire/csr-api-tes= t.c index 7278e7b927a8..779146d0cfba 100644 --- a/drivers/firewire/csr-api-test.c +++ b/drivers/firewire/csr-api-test.c @@ -206,8 +206,9 @@ static void csr_api_legacy_avc_device(struct kunit *tes= t) // Descriptor leaf entry for vendor is not found. KUNIT_EXPECT_LT(test, show_text_leaf(node_dev, &config_rom_attributes[5].= attr, buf), 0); =20 - // Descriptor leaf entry for model is not found. - KUNIT_EXPECT_LT(test, show_text_leaf(node_dev, &config_rom_attributes[6].= attr, buf), 0); + // Descriptor leaf entry for model is found. + KUNIT_EXPECT_GT(test, show_text_leaf(node_dev, &config_rom_attributes[6].= attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "ABCDEFGHIJ\n"); =20 // For entries in unit 0 directory. =20 --=20 2.39.2 From nobody Fri Dec 19 02:19:07 2025 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (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 D731E1118B for ; Sun, 17 Dec 2023 10:30:30 +0000 (UTC) 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="EO4DA1b2"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="yWh4dFAt" Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id DDB6B5C0124; Sun, 17 Dec 2023 05:30:29 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Sun, 17 Dec 2023 05:30:29 -0500 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=fm2; t=1702809029; x= 1702895429; bh=GNxJtnuCREIc3LKzjvgp8+1jNOAQR7t6+8ZOIjGQVww=; b=E O4DA1b28hTv8vuM4/sfmjKgMAmMuWZrqriu/6NQl9JMM5QC+Aszgzs6m+lldEYBx m5jUtQBlX109BSNbB2vKL8PWSpRoKc/QdtFNNl3P1SatbZaiAB7d9/eTejJr54WT ZHlYcCt265eUmfwTSELEDlx3qqe55yBfmEnoqNSu/QM3j5Ix24G7iFo1XKOTIO1R +FVRGBCpbT3PU7d2SwY+FNQKzYOd1uh35SQ3UGnJ8TAtA1h0P8nvo7HksbY3VpTi 5w3L1BGaWu4sevgVW7nF4/kT/fKhGkHuhHxwgu5oNvAWhyWRzVx8MddzAwhkEfJf xuqq+ugOhciCWpdsF3xaQ== 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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1702809029; x= 1702895429; bh=GNxJtnuCREIc3LKzjvgp8+1jNOAQR7t6+8ZOIjGQVww=; b=y Wh4dFAtNDIymNi8RauPDjeCH6rnCALqBmJE+ydH7D4LPZuQuI/OD3Yhqrjs9afSd 2h+XE9SxC51Yr1HUomOrvTquFKawgjzrfZyh5qmfNzFG+ZqHQ06ciPZw/uXwT47B tso1Oyx6oHJlvi2WvgzmioryQwpADJCiM1xiG3h7W03iVZC8LWEb5qFKSj58aJ4C wbSrdX/g8GWwcA82ekzIx/NP5idKnXgQB6q9ILS2WBDOH1CYoGh6X6Ddfu1DK70u X16wb4jiQjA9mf0p1/Q9dzEeJjS/rHZeSEkQfW9UM/OEjhZsNtXdymqtJrw6pHWI 0wWbP73aIo57hGQcgbK+Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddtiedgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 17 Dec 2023 05:30:28 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [RFC PATCH 8/8] firewire: core: change modalias of unit device and loss of backward compatibility Date: Sun, 17 Dec 2023 19:30:11 +0900 Message-Id: <20231217103012.41273-9-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231217103012.41273-1-o-takashi@sakamocchi.jp> References: <20231217103012.41273-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" As the last part of support for legacy layout of configuration ROM, this commit traverse vendor directory as well as root directory when constructing modalias for unit device. The change brings loss of backward compatibility since it can fill 'mo' field which is 0 at current implementation in the case. However, we can be optimistic against regression for unit drivers in kernel, due to some points: 1. ALSA drivers for audio and music units uses Model fields to match device, however all of supported devices does not have such legacy layout. 2. the other unit drivers does not use Model field to match device. The rest of concern is user space application. The most of application just take care of node device and does not use the modalias of unit device, thus the change does not affect to them. Although, systemd project gets affects since it includes hwdb to take udev to configure fw character device conveniently. I have a plan to work systemd so that the access permission of character device is kept for the previous and next version of Linux kernel. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-device.c | 21 +++++++++++++++++++-- drivers/firewire/csr-api-test.c | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index f7a11004f972..e04486c5e0eb 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -153,8 +153,25 @@ static void get_ids(const u32 *directory, int *id) =20 static void get_modalias_ids(const struct fw_unit *unit, int *id) { - get_ids(&fw_parent_device(unit)->config_rom[ROOT_DIR_OFFSET], id); - get_ids(unit->directory, id); + const u32 *root_directory =3D &fw_parent_device(unit)->config_rom[ROOT_DI= R_OFFSET]; + const u32 *directories[] =3D {NULL, NULL, NULL}; + const u32 *vendor_directory; + int i; + + directories[0] =3D root_directory; + + // Legacy layout of configuration ROM described in Annex 1 of 'Configurat= ion ROM for AV/C + // Devices 1.0 (December 12, 2000, 1394 Trading Association, TA Document = 1999027)'. + vendor_directory =3D search_directory(root_directory, CSR_DIRECTORY | CSR= _VENDOR); + if (!vendor_directory) { + directories[1] =3D unit->directory; + } else { + directories[1] =3D vendor_directory; + directories[2] =3D unit->directory; + } + + for (i =3D 0; i < ARRAY_SIZE(directories) && directories[i]; ++i) + get_ids(directories[i], id); } =20 static bool match_ids(const struct ieee1394_device_id *id_table, int *id) diff --git a/drivers/firewire/csr-api-test.c b/drivers/firewire/csr-api-tes= t.c index 779146d0cfba..753d8e83b8c2 100644 --- a/drivers/firewire/csr-api-test.c +++ b/drivers/firewire/csr-api-test.c @@ -178,7 +178,7 @@ static void csr_api_legacy_avc_device(struct kunit *tes= t) }; struct device *node_dev =3D (struct device *)&node.device; struct device *unit0_dev =3D (struct device *)&unit0.device; - static const int unit_expected_ids[] =3D {0x00012345, 0x00000000, 0x00abc= def, 0x00543210}; + static const int unit_expected_ids[] =3D {0x00012345, 0x00fedcba, 0x00abc= def, 0x00543210}; char *buf =3D kunit_kzalloc(test, PAGE_SIZE, GFP_KERNEL); int ids[4] =3D {0, 0, 0, 0}; =20 --=20 2.39.2 From nobody Fri Dec 19 02:19:07 2025 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (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 6CC8111CA7 for ; Sun, 17 Dec 2023 10:30:32 +0000 (UTC) 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="OuHjnjhi"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="S9rUBTE4" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 783955C0125; Sun, 17 Dec 2023 05:30:31 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sun, 17 Dec 2023 05:30:31 -0500 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=fm2; t=1702809031; x= 1702895431; bh=GNxJtnuCREIc3LKzjvgp8+1jNOAQR7t6+8ZOIjGQVww=; b=O uHjnjhi0jaHqKYj1X++SCg0PM+W9vd9wJmjYUN5XX87JUwnDzPLmkU9wxzhubLLu oML5gYlSlIGgkzftVYIT/rJMI/V2rYr/FyK9OdmdNqoGQrl3lMBSekFlSRQXIYBs csOyzmg+ZS9nC94Iv8ERLX4bcdNV1idhwiyDoMBWJqJ8SnAaj+ygmjdV9oJH9ZRJ gd9NyYb4MU7UEDUCiRG9EsEh+y46UxhS7KQns5tx3XVhHhzqhcvcgpHaOMjnIei7 sXJ2XEIFe+N+3vbt3qY4JOS5woqQKU4EvJ76n07hUV+1t6pTBnAQvCu/dqzlaeVw 7gbMP1+dsOv2s6IPDM1XQ== 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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1702809031; x= 1702895431; bh=GNxJtnuCREIc3LKzjvgp8+1jNOAQR7t6+8ZOIjGQVww=; b=S 9rUBTE4Ri6Ccm+RtAKvzgTfQqVnaPLoaobNM3jrvWbmXl6hXiEk5dDFH8TbnUmHf P3UolBM9AWABQvSgqVP++zpvRNXlG18w+ugcbFWRWybHqdCI34xrX2ut5dZ5L4/e 6L9FtlTxpWP+ViWcouR8XnO1Z3+QeTMfv2SBA2NEXJ9aGzIAALUKrQWP9yLKc+k7 7codyjuszBI5JlojiN2gDZ5P6D93Lg/ru1SBBGYyYo3Ak1rZAWuQE11LnBgkDJvh d0bNyWfUOfsHun2HoWbdWT4eITNqdgmTw19+F7HPGrWQfgBmyYU308UX8h3Roo9G J0pQptyboMcciwZUhyH5Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddtiedgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 17 Dec 2023 05:30:30 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [RFC PATCH 8/8] firewire: core: change modalias of unit device with backward incompatibility Date: Sun, 17 Dec 2023 19:30:12 +0900 Message-Id: <20231217103012.41273-10-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231217103012.41273-1-o-takashi@sakamocchi.jp> References: <20231217103012.41273-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" As the last part of support for legacy layout of configuration ROM, this commit traverse vendor directory as well as root directory when constructing modalias for unit device. The change brings loss of backward compatibility since it can fill 'mo' field which is 0 at current implementation in the case. However, we can be optimistic against regression for unit drivers in kernel, due to some points: 1. ALSA drivers for audio and music units uses Model fields to match device, however all of supported devices does not have such legacy layout. 2. the other unit drivers does not use Model field to match device. The rest of concern is user space application. The most of application just take care of node device and does not use the modalias of unit device, thus the change does not affect to them. Although, systemd project gets affects since it includes hwdb to take udev to configure fw character device conveniently. I have a plan to work systemd so that the access permission of character device is kept for the previous and next version of Linux kernel. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-device.c | 21 +++++++++++++++++++-- drivers/firewire/csr-api-test.c | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index f7a11004f972..e04486c5e0eb 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -153,8 +153,25 @@ static void get_ids(const u32 *directory, int *id) =20 static void get_modalias_ids(const struct fw_unit *unit, int *id) { - get_ids(&fw_parent_device(unit)->config_rom[ROOT_DIR_OFFSET], id); - get_ids(unit->directory, id); + const u32 *root_directory =3D &fw_parent_device(unit)->config_rom[ROOT_DI= R_OFFSET]; + const u32 *directories[] =3D {NULL, NULL, NULL}; + const u32 *vendor_directory; + int i; + + directories[0] =3D root_directory; + + // Legacy layout of configuration ROM described in Annex 1 of 'Configurat= ion ROM for AV/C + // Devices 1.0 (December 12, 2000, 1394 Trading Association, TA Document = 1999027)'. + vendor_directory =3D search_directory(root_directory, CSR_DIRECTORY | CSR= _VENDOR); + if (!vendor_directory) { + directories[1] =3D unit->directory; + } else { + directories[1] =3D vendor_directory; + directories[2] =3D unit->directory; + } + + for (i =3D 0; i < ARRAY_SIZE(directories) && directories[i]; ++i) + get_ids(directories[i], id); } =20 static bool match_ids(const struct ieee1394_device_id *id_table, int *id) diff --git a/drivers/firewire/csr-api-test.c b/drivers/firewire/csr-api-tes= t.c index 779146d0cfba..753d8e83b8c2 100644 --- a/drivers/firewire/csr-api-test.c +++ b/drivers/firewire/csr-api-test.c @@ -178,7 +178,7 @@ static void csr_api_legacy_avc_device(struct kunit *tes= t) }; struct device *node_dev =3D (struct device *)&node.device; struct device *unit0_dev =3D (struct device *)&unit0.device; - static const int unit_expected_ids[] =3D {0x00012345, 0x00000000, 0x00abc= def, 0x00543210}; + static const int unit_expected_ids[] =3D {0x00012345, 0x00fedcba, 0x00abc= def, 0x00543210}; char *buf =3D kunit_kzalloc(test, PAGE_SIZE, GFP_KERNEL); int ids[4] =3D {0, 0, 0, 0}; =20 --=20 2.39.2