From nobody Sun Feb 8 06:53:47 2026 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (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 D5F442206B1; Wed, 30 Apr 2025 12:49:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746017362; cv=none; b=O8fW/0hJuwLSCo5LdTlluDHYtF4m8g/W+CxsmIm5mTqdL4xZCqidB3eHgH/+eRRRTMUzVEYnEef3tqYf4Hhd9dTjmv16xLDAJ3/zf4DanpDKYUYdZahksprZVqY15ukl9JehcekuTdR/15DMSCTURqk4LZBAf+JF2PmoQNDXiZg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746017362; c=relaxed/simple; bh=HEvTwRzxmeE2NAfpgz9SSxXMD/XmjgIztjzYO9Oa8xY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A3AuAIaRZ179oMWQ8gVqQGrcPrFTub8onNtYRSFQMPQrU9Qa6khTz1KzjQndfntkiObAUe3fBcz5t6VNe1Zt7WgoqktVRcUagXWBCRivkKo+zofg0X8pHmheYGhOw+i6ccQrJRzDWxpoGQOfpmF3gop1/14aGI+OdKkRMHl7UeE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=SH6VWcrb; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="SH6VWcrb" Received: by mail.gandi.net (Postfix) with ESMTPA id 55CD343A1F; Wed, 30 Apr 2025 12:49:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1746017358; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PksiWeDnJhw5poQ866xXWaCAoSzsYk7jz7dyOJiWxTo=; b=SH6VWcrbWZivuHlWVIN5x/wxmQJf4Kujj1bK2LHQ5sqB6IkbIEkzVdwoGZRwsHX/g0JNXw WwQbNd7skqU3+qjV1q9WA4hrZnc+kBY4leQSEYdRbjO8UCfPod9rGiujvOiXdCXIh2xRYA mP5NuZm1viNCAWq3G6QkVit95cSzQDJvQkUr+cNerM6/xF1wvFtrzy8Mzh6we9xvz0mLoV vLzAQqIheIKwLxB4FQirISGh5B5XYIAMjEolmZA2xnFSDJAckAHjNpcBgENKu1ujJJ4w26 VFdxNo6CbiagCRYgIDRm1Uvpj62A662v6wH+y2vne331pNHWPM/zQhs/wilZHA== From: Herve Codina To: David Gibson , Andrew Davis , Ayush Singh , Geert Uytterhoeven , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Herve Codina , Arnd Bergmann , Greg Kroah-Hartman , Saravana Kannan Cc: devicetree@vger.kernel.org, devicetree-compiler@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Ceresoli , Thomas Petazzoni Subject: [PATCH 1/7] dt-bindings: Add support for export-symbols node Date: Wed, 30 Apr 2025 14:49:00 +0200 Message-ID: <20250430124910.195368-2-herve.codina@bootlin.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250430124910.195368-1-herve.codina@bootlin.com> References: <20250430124910.195368-1-herve.codina@bootlin.com> 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 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvieeijeegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefjvghrvhgvucevohguihhnrgcuoehhvghrvhgvrdgtohguihhnrgessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepfefhhfefveduvedutdetfedvvedufeetieetfeejtefgteeigefgkeejgfegtddunecuffhomhgrihhnpeguvghvihgtvghtrhgvvgdrohhrghenucfkphepledtrdekledrudeifedruddvjeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeeltddrkeelrdduieefrdduvdejpdhhvghloheplhhotggrlhhhohhsthdrlhhotggrlhguohhmrghinhdpmhgrihhlfhhrohhmpehhvghrvhgvrdgtohguihhnrgessghoohhtlhhinhdrtghomhdpnhgspghrtghpthhtohepudeipdhrtghpthhtohepuggrvhhiugesghhisghsohhnrdgurhhophgsvggrrhdrihgurdgruhdprhgtphhtthhopegrfhgusehtihdrtghomhdprhgtphhtthhopegrhihushhhsegsvggrghhlvggsohgrrhgurdhorhhgpdhrtghpthhtohepghgvvghrtheslhhinhhugidqmheikehkrdhorhhgpdhrtghpthhtohepr hhosghhsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehkrhiikhdoughtsehkvghrnhgvlhdrohhrghdprhgtphhtthhopegtohhnohhrodgutheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohephhgvrhhvvgdrtghoughinhgrsegsohhothhlihhnrdgtohhm X-GND-Sasl: herve.codina@bootlin.com Content-Type: text/plain; charset="utf-8" An export-symbols node allows to export symbols for symbols resolution performed when applying a device tree overlay. When a device tree overlay is applied on a node having an export-symbols node, symbols listed in the export-symbols node are used to resolve undefined symbols referenced from the overlay. This allows: - Referencing symbols from an device tree overlay without the need to know the full base board. Only the connector definition is needed. - Using the exact same overlay on several connectors available on a given board. For instance, the following description is supported with the export-symbols node: - Base device tree board A: ... foo_connector: connector1 { export-symbols { connector =3D <&foo_connector>; }; }; bar_connector: connector2 { export-symbols { connector =3D <&bar_connector>; }; }; ... - Base device tree board B: ... front_connector: addon-connector { export-symbols { connector =3D <&front_connector>; }; }; ... - Overlay describing an addon board the can be connected on connectors: ... node { ... connector =3D <&connector>; ... }; ... Thanks to the export-symbols node, the overlay can be applied on connector1 or connector2 available on board A but also on addon-connector available on board B. Signed-off-by: Herve Codina Tested-by: Ayush Singh --- .../devicetree/bindings/export-symbols.yaml | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Documentation/devicetree/bindings/export-symbols.yaml diff --git a/Documentation/devicetree/bindings/export-symbols.yaml b/Docume= ntation/devicetree/bindings/export-symbols.yaml new file mode 100644 index 000000000000..0e404eff8937 --- /dev/null +++ b/Documentation/devicetree/bindings/export-symbols.yaml @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/export-symbols.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Export symbols + +maintainers: + - Herve Codina + +description: | + An export-symbols node allows to export symbols for symbols resolution + performed when applying a device tree overlay. + + When a device tree overlay is applied on a node having an export-symbols + node, symbols listed in the export-symbols node are used to resolve unde= fined + symbols referenced from the overlay. + +properties: + $nodename: + const: export-symbols + +patternProperties: + "^[a-zA-Z_]?[a-zA-Z0-9_]*$": + $ref: /schemas/types.yaml#/definitions/phandle + description: + A symbol exported in the form =3D. + +additionalProperties: false + +examples: + - | + /* + * Allows 'connector' symbol used in a device-tree overlay to be resol= ved to + * connector0 when the device-tree overlay is applied on connector0 no= de. + */ + connector0: connector0 { + export-symbols { + connector =3D <&connector0>; + }; + }; +... --=20 2.49.0 From nobody Sun Feb 8 06:53:47 2026 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (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 8D31025B1ED; Wed, 30 Apr 2025 12:49:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746017363; cv=none; b=dCDoKNR6BbqBaJhVyaluZwALTnMa09s0IKz5OcM6GBAlWsBDT9DWfT74HOvHL15yPDFIHeRRLmv5IVKpBQHjtk2qrbOw4cQlO636B5DmMMT1rzNGBC7jAF72+kPHUHyAtf0swAdo+X1SslaH6oIewf4DJ4hHxnf0JoRbOzZ0q3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746017363; c=relaxed/simple; bh=04Lgsevk075WoZNcBOi6TghRMwt8xkLiKvl4P7+VTdQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k5G0QqvF7XmMGbwaHB9u2BMhV2aQ9TEpNVU7QaV11x3X/FuG017jKoN3z3jt1JCKP7bsbQHYsrC2dSquq7IZuwYq0ujyNRmf/j40FHrzcDa23k/o+LPgdq+PpsqZPT4TcK5AzjmWD3KG8F1nsXHaduBLDG+svI/9QPLYirbWM8A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=cgMUN41r; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="cgMUN41r" Received: by mail.gandi.net (Postfix) with ESMTPA id 3639243A20; Wed, 30 Apr 2025 12:49:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1746017359; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MeC3Blleg5ID5FjARVSQZ7w0x3ZCmA8mRG7YjX82K+A=; b=cgMUN41rz0j5Hn/kW6LtBkT82ZawzHmcxf2xAk9kY6r44Xtkqm64/Ls9XflMX+tfsfkVJT pdVjC8NGRagn9GYnL1/q+OxPOR5T4o65ebmnH9GzUXfC9cPhm1+PVBiOj6XFpw7fAYXQkF q6DirTKNhpxghdwFt1lgS9jwCl/Gl94kOFYxcn86yDPW/RzNczID3hcPVDeXJwpr+wx5Z3 NUCSWX7hzXRswHuK3j2FnBxSs7+u3B56A8NVq5wST9u0gbftDFVeq8qckUJHXv9q0gdSb4 AN06n1MR8pW0RVXplgZDgbMC97ufC6tekm4Y3NA3HPDh7c8nRhvmQifZ7uMf7g== From: Herve Codina To: David Gibson , Andrew Davis , Ayush Singh , Geert Uytterhoeven , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Herve Codina , Arnd Bergmann , Greg Kroah-Hartman , Saravana Kannan Cc: devicetree@vger.kernel.org, devicetree-compiler@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Ceresoli , Thomas Petazzoni Subject: [PATCH 2/7] of: resolver: Introduce get_phandle_from_symbols_node() Date: Wed, 30 Apr 2025 14:49:01 +0200 Message-ID: <20250430124910.195368-3-herve.codina@bootlin.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250430124910.195368-1-herve.codina@bootlin.com> References: <20250430124910.195368-1-herve.codina@bootlin.com> 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 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvieeijeegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefjvghrvhgvucevohguihhnrgcuoehhvghrvhgvrdgtohguihhnrgessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepheffiefgjeeuleeuueffleeufefglefhjefhheeigedukeetieeltddthfffkeffnecukfhppeeltddrkeelrdduieefrdduvdejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepledtrdekledrudeifedruddvjedphhgvlhhopehlohgtrghlhhhoshhtrdhlohgtrghlughomhgrihhnpdhmrghilhhfrhhomhephhgvrhhvvgdrtghoughinhgrsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopeduiedprhgtphhtthhopegurghvihgusehgihgsshhonhdrughrohhpsggvrghrrdhiugdrrghupdhrtghpthhtoheprghfugesthhirdgtohhmpdhrtghpthhtoheprgihuhhshhessggvrghglhgvsghorghrugdrohhrghdprhgtphhtthhopehgvggvrhhtsehlihhnuhigqdhmieekkhdrohhrghdprhgtphhtthhopehrohgshheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepk hhriihkodgutheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheptghonhhorhdoughtsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehhvghrvhgvrdgtohguihhnrgessghoohhtlhhinhdrtghomh X-GND-Sasl: herve.codina@bootlin.com Content-Type: text/plain; charset="utf-8" In order to simplify the introduction of the export symbols node handling, group necessary operations done to get a phandle from the __symbols__ node in this dedicated get_phandle_from_symbols_node() function. Signed-off-by: Herve Codina Tested-by: Ayush Singh --- drivers/of/resolver.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c index 86424e145919..2c7a3b479b15 100644 --- a/drivers/of/resolver.c +++ b/drivers/of/resolver.c @@ -212,6 +212,28 @@ static int adjust_local_phandle_references(const struc= t device_node *local_fixup return 0; } =20 +static int get_phandle_from_symbols_node(const struct device_node *tree_sy= mbols, + const char *symbol_name, + phandle *phandle) +{ + struct device_node *refnode; + const char *refpath; + int err; + + err =3D of_property_read_string(tree_symbols, symbol_name, &refpath); + if (err) + return err; + + refnode =3D of_find_node_by_path(refpath); + if (!refnode) + return -ENOENT; + + *phandle =3D refnode->phandle; + of_node_put(refnode); + + return 0; +} + /** * of_resolve_phandles - Relocate and resolve overlay against live tree * @@ -247,11 +269,9 @@ static int adjust_local_phandle_references(const struc= t device_node *local_fixup */ int of_resolve_phandles(struct device_node *overlay) { - struct device_node *child, *refnode; - struct device_node *overlay_fixups; + struct device_node *child, *overlay_fixups; struct device_node __free(device_node) *local_fixups =3D NULL; struct property *prop; - const char *refpath; phandle phandle, phandle_delta; int err; =20 @@ -298,21 +318,14 @@ int of_resolve_phandles(struct device_node *overlay) if (!of_prop_cmp(prop->name, "name")) continue; =20 - err =3D of_property_read_string(tree_symbols, - prop->name, &refpath); + err =3D get_phandle_from_symbols_node(tree_symbols, prop->name, + &phandle); if (err) { - pr_err("node label '%s' not found in live devicetree symbols table\n", + pr_err("node label '%s' not found or invalid in live devicetree symbols= table\n", prop->name); return err; } =20 - refnode =3D of_find_node_by_path(refpath); - if (!refnode) - return -ENOENT; - - phandle =3D refnode->phandle; - of_node_put(refnode); - err =3D update_usages_of_a_phandle_reference(overlay, prop, phandle); if (err) break; --=20 2.49.0 From nobody Sun Feb 8 06:53:47 2026 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (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 BE1E025CC60; Wed, 30 Apr 2025 12:49:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746017364; cv=none; b=KhqJUqkqcj14ZUkmoD9xEuAoq7dkxr+Zu6rsprHcXDQFg9ZL2WPolNPZ8K55bBTYOUeu9pgCW0Cxq7+E/Ad8XCSC0AsK2+k5Yz5dCKWftHGGoY9RwG+tZeg40QS6y5pAmahzNFJNuopf3qm8MMv3EL0Bec0CTVOwIVpC/qa1iDs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746017364; c=relaxed/simple; bh=Y7Zm8w9wG8YslhOw/WDwwhycO9VpWrlfhSRsBRFKNw8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uH6uGptYTh396sg0Uqpc9odmtWaeTZpW2YtTQ16aTQcc3R1U+lx4OJmQlV4ZCjQ9AB0y7HDszQ04UuofZOa9coBEzHhhHtGD+3SmVPhrttt8ExUHkMpL0Pk7C6OW/y784etWeCzmMxVgJ94sNAzGGmKPSaTY3X0PPVamux1jAE0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=KPGJlb9A; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="KPGJlb9A" Received: by mail.gandi.net (Postfix) with ESMTPA id 11D2943A17; Wed, 30 Apr 2025 12:49:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1746017360; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zc5KU+vZ9ltSWyx9XaPn8D3Abm11V5SwRuQjnQVNZsw=; b=KPGJlb9AYG5I/aMhUjP/A/eUXR2Iuk5UtmmIJ62S0up8ZQxjhxGHi9M7++iM5C343KybwI Ladmpcp50bnNbimcgej0U+iVet4HsxdpWpaxOIboiG+Q6yWR1V/4yzgWMvg8nfu4HR3Dxb feHAPwvalmwW52KAd0w47mmWSJhC5ckrD9UkQ7kfXsBpXXuELlJj/mOUIptjueBTGZ+aA0 3VeVU5XSxXNOzZYoqbSUkRfPp/eXOBfl/yWzP1G3s5kaXEAyNpa+EYY3H6nVysvRuvXrmg 1usISGe1UFUhusjz1c8CNtuK3Wfw4g14AEMlqcKdOxwK8jyaDdG5k+e8WROjGQ== From: Herve Codina To: David Gibson , Andrew Davis , Ayush Singh , Geert Uytterhoeven , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Herve Codina , Arnd Bergmann , Greg Kroah-Hartman , Saravana Kannan Cc: devicetree@vger.kernel.org, devicetree-compiler@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Ceresoli , Thomas Petazzoni Subject: [PATCH 3/7] of: resolver: Add export_symbols in of_resolve_phandles() parameters Date: Wed, 30 Apr 2025 14:49:02 +0200 Message-ID: <20250430124910.195368-4-herve.codina@bootlin.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250430124910.195368-1-herve.codina@bootlin.com> References: <20250430124910.195368-1-herve.codina@bootlin.com> 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 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvieeijeegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefjvghrvhgvucevohguihhnrgcuoehhvghrvhgvrdgtohguihhnrgessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepheffiefgjeeuleeuueffleeufefglefhjefhheeigedukeetieeltddthfffkeffnecukfhppeeltddrkeelrdduieefrdduvdejnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehinhgvthepledtrdekledrudeifedruddvjedphhgvlhhopehlohgtrghlhhhoshhtrdhlohgtrghlughomhgrihhnpdhmrghilhhfrhhomhephhgvrhhvvgdrtghoughinhgrsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopeduiedprhgtphhtthhopegurghvihgusehgihgsshhonhdrughrohhpsggvrghrrdhiugdrrghupdhrtghpthhtoheprghfugesthhirdgtohhmpdhrtghpthhtoheprgihuhhshhessggvrghglhgvsghorghrugdrohhrghdprhgtphhtthhopehgvggvrhhtsehlihhnuhigqdhmieekkhdrohhrghdprhgtphhtthhopehrohgshheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepk hhriihkodgutheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheptghonhhorhdoughtsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehhvghrvhgvrdgtohguihhnrgessghoohhtlhhinhdrtghomh X-GND-Sasl: herve.codina@bootlin.com Content-Type: text/plain; charset="utf-8" In order to prepare the introduction of the export symbols node handling, add a export_symbols parameter in of_resolve_phandles(). The export_symbols is the export symbols device tree node the resolver will use for the overlay symbols resolution. Signed-off-by: Herve Codina Tested-by: Ayush Singh --- drivers/of/of_private.h | 2 +- drivers/of/overlay.c | 2 +- drivers/of/resolver.c | 9 +++++++-- drivers/of/unittest.c | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h index df0bb00349e0..cf68edb873ab 100644 --- a/drivers/of/of_private.h +++ b/drivers/of/of_private.h @@ -94,7 +94,7 @@ static inline void __of_detach_node_sysfs(struct device_n= ode *np) {} #endif =20 #if defined(CONFIG_OF_RESOLVE) -int of_resolve_phandles(struct device_node *tree); +int of_resolve_phandles(struct device_node *tree, const struct device_node= *export_symbols); #endif =20 void __of_phandle_cache_inv_entry(phandle handle); diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index 1af6f52d0708..aa1b97e634aa 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -919,7 +919,7 @@ static int of_overlay_apply(struct overlay_changeset *o= vcs, { int ret =3D 0, ret_revert, ret_tmp; =20 - ret =3D of_resolve_phandles(ovcs->overlay_root); + ret =3D of_resolve_phandles(ovcs->overlay_root, NULL); if (ret) goto out; =20 diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c index 2c7a3b479b15..5c492711b21f 100644 --- a/drivers/of/resolver.c +++ b/drivers/of/resolver.c @@ -237,7 +237,8 @@ static int get_phandle_from_symbols_node(const struct d= evice_node *tree_symbols, /** * of_resolve_phandles - Relocate and resolve overlay against live tree * - * @overlay: Pointer to devicetree overlay to relocate and resolve + * @overlay: Pointer to devicetree overlay to relocate and resolve + * @export_symbols: Pointer to devicetree export symbols node. * * Modify (relocate) values of local phandles in @overlay to a range that * does not conflict with the live expanded devicetree. Update references @@ -257,6 +258,10 @@ static int get_phandle_from_symbols_node(const struct = device_node *tree_symbols, * corresponding to that symbol in the live tree. Update the references in * the overlay with the phandle values in the live tree. * + * @export_symbols can be use in this references update. The resolver tries + * first to find a match in the @export_symbols. If not found, it uses the + * "__symbol__" node in the live tree. + * * @overlay must be detached. * * Resolving and applying @overlay to the live expanded devicetree must be @@ -267,7 +272,7 @@ static int get_phandle_from_symbols_node(const struct d= evice_node *tree_symbols, * * Return: %0 on success or a negative error value on error. */ -int of_resolve_phandles(struct device_node *overlay) +int of_resolve_phandles(struct device_node *overlay, const struct device_n= ode *export_symbols) { struct device_node *child, *overlay_fixups; struct device_node __free(device_node) *local_fixups =3D NULL; diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 64d301893af7..620237365566 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -2026,7 +2026,7 @@ static int __init unittest_data_add(void) */ of_overlay_mutex_lock(); =20 - rc =3D of_resolve_phandles(unittest_data_node); + rc =3D of_resolve_phandles(unittest_data_node, NULL); if (rc) { pr_err("%s: Failed to resolve phandles (rc=3D%i)\n", __func__, rc); of_overlay_mutex_unlock(); @@ -3915,7 +3915,7 @@ static __init void of_unittest_overlay_high_level(voi= d) * because kmalloc() was not yet available. */ of_overlay_mutex_lock(); - of_resolve_phandles(overlay_base_root); + of_resolve_phandles(overlay_base_root, NULL); of_overlay_mutex_unlock(); =20 =20 --=20 2.49.0 From nobody Sun Feb 8 06:53:47 2026 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (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 8A9D425D21E; Wed, 30 Apr 2025 12:49:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746017365; cv=none; b=FtVZJBHsAWrepSEZtfn0QyDFAh44cC0WxmS7w+MJr4SBWQ2KphiG9Cn8I1jrM//hq1ufEwpYgAWCu7yDfXJ/7cJy7pRlAn6vAhe7PcVjJH+u0NLMfdvwljWxW6a2Jf8PbCMp/X9Rexz/ebBEKbDRtgpSAYyp90DLGyOHd0y3uxI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746017365; c=relaxed/simple; bh=MLKFKlOcqD3JrCWLLX9Qo1rkuxqN8kw5WpQ7AXVTpbc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Xg3i+PmpXU2vwfBX9UnnreyjLdGCtgp6lh4pamb10WDOnXCQjPyZ3YwfB0lUfX657SS/VVd+hBaZKAUEsPtM2FPqOpRfV/PxwMfPxAlMAN/lUiOgbUyM/zeWGv9jCek+Bb5N9e3XiXqj1WoDnaj6w7aCz5uy2FrIP0TTizdd5Ng= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=ZOgXW/hh; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="ZOgXW/hh" Received: by mail.gandi.net (Postfix) with ESMTPA id 0F9D943A24; Wed, 30 Apr 2025 12:49:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1746017361; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iuXqI1mGwNYFzjUQZRY2v46st1QeOvBPHRc4DlxvEp4=; b=ZOgXW/hhPU6EJE4aEd/ReRqRiatj328XMSO3B7UjPtqGnxXuicwOV4sMEmDRZ75GwwGC9P QHwmb+qODuZX+Z4kHuxikkbFhAhvxM/MZeFLEoP4MkJBmGpRQpeHdipdd/faNW11I4s79l 5fDMk4aezUXvb6pv4ciNSRG2jgR60CQ3J36r4FqCN3fzhTDsO4N3Di/fCBmGmxdMU9Vzq1 cYGl2lw7KAkkYRQVl5haUnTZaROn/id5FtCrWWNYQP88TQuAIMC8vls3dn4PggMIHJQqa4 /rMq2719o8zpyB3aP+81vmyAQ7JwLp6mfTSHU5lGqB8/Q6hva09urHaBJ0KQKg== From: Herve Codina To: David Gibson , Andrew Davis , Ayush Singh , Geert Uytterhoeven , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Herve Codina , Arnd Bergmann , Greg Kroah-Hartman , Saravana Kannan Cc: devicetree@vger.kernel.org, devicetree-compiler@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Ceresoli , Thomas Petazzoni Subject: [PATCH 4/7] of: resolver: Add support for the export symbols node Date: Wed, 30 Apr 2025 14:49:03 +0200 Message-ID: <20250430124910.195368-5-herve.codina@bootlin.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250430124910.195368-1-herve.codina@bootlin.com> References: <20250430124910.195368-1-herve.codina@bootlin.com> 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 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvieeijeegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefjvghrvhgvucevohguihhnrgcuoehhvghrvhgvrdgtohguihhnrgessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepheffiefgjeeuleeuueffleeufefglefhjefhheeigedukeetieeltddthfffkeffnecukfhppeeltddrkeelrdduieefrdduvdejnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehinhgvthepledtrdekledrudeifedruddvjedphhgvlhhopehlohgtrghlhhhoshhtrdhlohgtrghlughomhgrihhnpdhmrghilhhfrhhomhephhgvrhhvvgdrtghoughinhgrsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopeduiedprhgtphhtthhopegurghvihgusehgihgsshhonhdrughrohhpsggvrghrrdhiugdrrghupdhrtghpthhtoheprghfugesthhirdgtohhmpdhrtghpthhtoheprgihuhhshhessggvrghglhgvsghorghrugdrohhrghdprhgtphhtthhopehgvggvrhhtsehlihhnuhigqdhmieekkhdrohhrghdprhgtphhtthhopehrohgshheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepk hhriihkodgutheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheptghonhhorhdoughtsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehhvghrvhgvrdgtohguihhnrgessghoohhtlhhinhdrtghomh X-GND-Sasl: herve.codina@bootlin.com Content-Type: text/plain; charset="utf-8" Symbols resolution done when an overlay is applied looks only at the global __symbol__ node to resolve unknown symbols from the overlay (i.e symbols listed in the overlay __fixups__ node). In order to provide flexibilities and allow to define some additional symbols visible only when an overlay is applied to a specific node, introduce the export symbols node. The export symbols node adds some additional symbols that can be used in the symbols resolution. The resolver tries to match unresolved symbols first using the export symbols node and, if a match is not found, it tries to match using the global __symbol__ node. Contrary to symbols available in the global __symbols__ node, symbols listed in the export symbols node can be considered as local symbols. Indeed, they can be changed depending on the node the overlay is going to be applied to and are only visibible from the current recolver call. Handle those additional symbols given by the export symbols node in the symbols resolution. Signed-off-by: Herve Codina Tested-by: Ayush Singh --- drivers/of/resolver.c | 33 +++++++++++++++++++++++++++++---- drivers/of/unittest.c | 4 ++-- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c index 5c492711b21f..c2b63cec1865 100644 --- a/drivers/of/resolver.c +++ b/drivers/of/resolver.c @@ -220,6 +220,9 @@ static int get_phandle_from_symbols_node(const struct d= evice_node *tree_symbols, const char *refpath; int err; =20 + if (!tree_symbols) + return -ENOENT; + err =3D of_property_read_string(tree_symbols, symbol_name, &refpath); if (err) return err; @@ -234,6 +237,25 @@ static int get_phandle_from_symbols_node(const struct = device_node *tree_symbols, return 0; } =20 +static int get_phandle_from_export_node(const struct device_node *export_s= ymbols, + const char *symbol_name, + phandle *phandle) +{ + struct device_node *refnode; + + if (!export_symbols) + return -ENOENT; + + refnode =3D of_parse_phandle(export_symbols, symbol_name, 0); + if (!refnode) + return -ENOENT; + + *phandle =3D refnode->phandle; + of_node_put(refnode); + + return 0; +} + /** * of_resolve_phandles - Relocate and resolve overlay against live tree * @@ -312,7 +334,7 @@ int of_resolve_phandles(struct device_node *overlay, co= nst struct device_node *e return 0; =20 struct device_node __free(device_node) *tree_symbols =3D of_find_node_by_= path("/__symbols__"); - if (!tree_symbols) { + if (!tree_symbols && !export_symbols) { pr_err("no symbols in root of device tree.\n"); return -EINVAL; } @@ -323,10 +345,13 @@ int of_resolve_phandles(struct device_node *overlay, = const struct device_node *e if (!of_prop_cmp(prop->name, "name")) continue; =20 - err =3D get_phandle_from_symbols_node(tree_symbols, prop->name, - &phandle); + err =3D get_phandle_from_export_node(export_symbols, prop->name, + &phandle); + if (err) + err =3D get_phandle_from_symbols_node(tree_symbols, prop->name, + &phandle); if (err) { - pr_err("node label '%s' not found or invalid in live devicetree symbols= table\n", + pr_err("node label '%s' not found or invalid in live devicetree symbols= or export tables\n", prop->name); return err; } diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 620237365566..658690fd6980 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -4146,7 +4146,7 @@ static __init void of_unittest_overlay_high_level(voi= d) /* --- overlay_bad_unresolved --- */ =20 EXPECT_BEGIN(KERN_ERR, - "OF: resolver: node label 'this_label_does_not_exist' not found in = live devicetree symbols table"); + "OF: resolver: node label 'this_label_does_not_exist' not found or = invalid in live devicetree symbols or export tables"); EXPECT_BEGIN(KERN_ERR, "OF: resolver: overlay phandle fixup failed: -22"); =20 @@ -4156,7 +4156,7 @@ static __init void of_unittest_overlay_high_level(voi= d) EXPECT_END(KERN_ERR, "OF: resolver: overlay phandle fixup failed: -22"); EXPECT_END(KERN_ERR, - "OF: resolver: node label 'this_label_does_not_exist' not found in li= ve devicetree symbols table"); + "OF: resolver: node label 'this_label_does_not_exist' not found or in= valid in live devicetree symbols or export tables"); =20 return; =20 --=20 2.49.0 From nobody Sun Feb 8 06:53:47 2026 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (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 5BAF625DAF0; Wed, 30 Apr 2025 12:49:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746017366; cv=none; b=thXZuXhlODFTmwJFkunYkk3AO0WPRQW9kZ2o7SJHcrg8jp30OjM1MkNpzLP++C+SLfE67r3vC5HVgwTWz8EsRraEtPxd7EcQTwG8ijQ0q9VsEKXK6z/Lwezayr274qkblz7SMrFv+OguUV/Md/DJbECRXb4plaPeEFmKimigoF0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746017366; c=relaxed/simple; bh=GJIUO/LfuuEyx2C59Bql/hQ7zaQ2Afe6Myf8SeIhfEA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C0TeNSAa8xcIE/kE8VKM0NyoQeirpzG9T0M88WxvgNnKaeU39khGR4fZZG+5RMQx+uaPTLqUKKiQrQROuLxSeo6NBapFB4YDmzKD6Xy+QNXREAc3ltu10z9JZHOcrP87r8PCNySXw7sZ1p7dAmu8GxjW7ye0psE7WH9oZt8+b9o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=H0NDP85r; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="H0NDP85r" Received: by mail.gandi.net (Postfix) with ESMTPA id E84B043A22; Wed, 30 Apr 2025 12:49:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1746017362; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JCHiV2KgzmFR5ylUD36LT9XNI75ngLRnaSotflKdIX8=; b=H0NDP85rZDuS3g/mqoOWhq72r3tzTaAvGnOKUvLwGhDfE6Mcf7woC70mfEqaKUVRWhXWeF YP31cQ7bJb12vBHDNEhJkDxNQiGSJTMipfyMHxDTJmDlKDIkE4pTvLlwRlCaN8OBv5+Xlc dJ7l/RU/we5th7Fqfby5Cd8xmURCD2WRYnP3XFiNGEGgpiXMWtuBfzSNthJ1+cLzwj3X8t o8g4apZH9VEJ+iIjypAo4zftnuoDfEGC53MNLvMxkB8ePfHJl2JWKZsZnAZyVIVPHCzJv9 kttMpORJ3V7NKz0pn3CZtg/Z0UMkwj6UU+yb7kFVRZxqxIc5vVaSZmIVLmgnBw== From: Herve Codina To: David Gibson , Andrew Davis , Ayush Singh , Geert Uytterhoeven , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Herve Codina , Arnd Bergmann , Greg Kroah-Hartman , Saravana Kannan Cc: devicetree@vger.kernel.org, devicetree-compiler@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Ceresoli , Thomas Petazzoni Subject: [PATCH 5/7] of: overlay: Add export_symbols_name in of_overlay_fdt_apply() parameters Date: Wed, 30 Apr 2025 14:49:04 +0200 Message-ID: <20250430124910.195368-6-herve.codina@bootlin.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250430124910.195368-1-herve.codina@bootlin.com> References: <20250430124910.195368-1-herve.codina@bootlin.com> 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 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvieeijeegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefjvghrvhgvucevohguihhnrgcuoehhvghrvhgvrdgtohguihhnrgessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepheffiefgjeeuleeuueffleeufefglefhjefhheeigedukeetieeltddthfffkeffnecukfhppeeltddrkeelrdduieefrdduvdejnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehinhgvthepledtrdekledrudeifedruddvjedphhgvlhhopehlohgtrghlhhhoshhtrdhlohgtrghlughomhgrihhnpdhmrghilhhfrhhomhephhgvrhhvvgdrtghoughinhgrsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopeduiedprhgtphhtthhopegurghvihgusehgihgsshhonhdrughrohhpsggvrghrrdhiugdrrghupdhrtghpthhtoheprghfugesthhirdgtohhmpdhrtghpthhtoheprgihuhhshhessggvrghglhgvsghorghrugdrohhrghdprhgtphhtthhopehgvggvrhhtsehlihhnuhigqdhmieekkhdrohhrghdprhgtphhtthhopehrohgshheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepk hhriihkodgutheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheptghonhhorhdoughtsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehhvghrvhgvrdgtohguihhnrgessghoohhtlhhinhdrtghomh X-GND-Sasl: herve.codina@bootlin.com Content-Type: text/plain; charset="utf-8" In order to prepare the introduction of the export symbols node handling, add a export_symbols_name parameter in of_overlay_fdt_apply(). The export_symbols_name is the name of the export symbols subnode available in the base node that will be used by the resolver to handle export symbols resolution. Having the name of the subnode in parameters instead of the subnode itself avoids the use of an export symbol node that is not directly related to the base node. Signed-off-by: Herve Codina Tested-by: Ayush Singh --- drivers/misc/lan966x_pci.c | 3 ++- drivers/of/of_kunit_helpers.c | 2 +- drivers/of/overlay.c | 7 ++++++- drivers/of/unittest.c | 4 ++-- include/linux/of.h | 6 ++++-- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/misc/lan966x_pci.c b/drivers/misc/lan966x_pci.c index 9c79b58137e5..f05cb040ec69 100644 --- a/drivers/misc/lan966x_pci.c +++ b/drivers/misc/lan966x_pci.c @@ -128,7 +128,8 @@ static int lan966x_pci_load_overlay(struct lan966x_pci = *data) u32 dtbo_size =3D __dtbo_lan966x_pci_end - __dtbo_lan966x_pci_begin; void *dtbo_start =3D __dtbo_lan966x_pci_begin; =20 - return of_overlay_fdt_apply(dtbo_start, dtbo_size, &data->ovcs_id, dev_of= _node(data->dev)); + return of_overlay_fdt_apply(dtbo_start, dtbo_size, &data->ovcs_id, + dev_of_node(data->dev), NULL); } =20 static void lan966x_pci_unload_overlay(struct lan966x_pci *data) diff --git a/drivers/of/of_kunit_helpers.c b/drivers/of/of_kunit_helpers.c index 7b3ed5a382aa..476b43474168 100644 --- a/drivers/of/of_kunit_helpers.c +++ b/drivers/of/of_kunit_helpers.c @@ -56,7 +56,7 @@ int of_overlay_fdt_apply_kunit(struct kunit *test, void *= overlay_fdt, return -ENOMEM; =20 ret =3D of_overlay_fdt_apply(overlay_fdt, overlay_fdt_size, - ovcs_id, NULL); + ovcs_id, NULL, NULL); if (ret) return ret; =20 diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index aa1b97e634aa..73ff38c41de2 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -968,6 +968,10 @@ static int of_overlay_apply(struct overlay_changeset *= ovcs, * @overlay_fdt_size: number of bytes in @overlay_fdt * @ret_ovcs_id: pointer for returning created changeset id * @base: pointer for the target node to apply overlay + * @export_symbols_name: + * Name of the export symbol subnode of the @base node to + * provide extra symbols. Those extra symbols are used in + * the overlay symbols resolution. * * Creates and applies an overlay changeset. * @@ -983,7 +987,8 @@ static int of_overlay_apply(struct overlay_changeset *o= vcs, */ =20 int of_overlay_fdt_apply(const void *overlay_fdt, u32 overlay_fdt_size, - int *ret_ovcs_id, const struct device_node *base) + int *ret_ovcs_id, const struct device_node *base, + const char *export_symbols_name) { void *new_fdt; void *new_fdt_align; diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 658690fd6980..11091b0176e0 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -3858,7 +3858,7 @@ static int __init overlay_data_apply(const char *over= lay_name, int *ovcs_id) pr_err("no overlay data for %s\n", overlay_name); =20 ret =3D of_overlay_fdt_apply(info->dtbo_begin, size, &info->ovcs_id, - NULL); + NULL, NULL); if (ovcs_id) *ovcs_id =3D info->ovcs_id; if (ret < 0) @@ -4198,7 +4198,7 @@ static int testdrv_probe(struct pci_dev *pdev, const = struct pci_device_id *id) } =20 size =3D info->dtbo_end - info->dtbo_begin; - ret =3D of_overlay_fdt_apply(info->dtbo_begin, size, &ovcs_id, dn); + ret =3D of_overlay_fdt_apply(info->dtbo_begin, size, &ovcs_id, dn, NULL); of_node_put(dn); if (ret) return ret; diff --git a/include/linux/of.h b/include/linux/of.h index a62154aeda1b..d8e0dd210e09 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -1749,7 +1749,8 @@ struct of_overlay_notify_data { #ifdef CONFIG_OF_OVERLAY =20 int of_overlay_fdt_apply(const void *overlay_fdt, u32 overlay_fdt_size, - int *ovcs_id, const struct device_node *target_base); + int *ovcs_id, const struct device_node *target_base, + const char *export_symbols_name); int of_overlay_remove(int *ovcs_id); int of_overlay_remove_all(void); =20 @@ -1759,7 +1760,8 @@ int of_overlay_notifier_unregister(struct notifier_bl= ock *nb); #else =20 static inline int of_overlay_fdt_apply(const void *overlay_fdt, u32 overla= y_fdt_size, - int *ovcs_id, const struct device_node *target_base) + int *ovcs_id, const struct device_node *target_base, + const char *export_symbols_name) { return -ENOTSUPP; } --=20 2.49.0 From nobody Sun Feb 8 06:53:47 2026 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (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 1C20D25A642; Wed, 30 Apr 2025 12:49:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746017367; cv=none; b=kU9I1daGB//dxnaZUZJkuH/tV6bNWTeBY7ZH+hnyFOUipxPai2adzu9d6b0SV4OTnlWX4eqX98b9U/gTWe0AXyShm1wGXrhGxHV7zlFRLx04ReooyPBPTG9mV8NyQqQTQ+nBR2oOY47nbEh/yyOcAgFn8Pf2ojwo84Y7JacJg3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746017367; c=relaxed/simple; bh=Zlo0JIAVBhVcxhoeRxFpnpqdS1ScVVuHOETJuuNopRY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=loPoM5N5t2GvBA9KUw+tdHS4Uz5ZJZ7TqlS9bAC/UaVplxZsklpMUmFwyv1cICmKdwY5gAjSlGlVuZcvYx6GCIjpM2F7hJWABym9xidxIQ6xyKo2gAXWMNNieUEcLWdNA7NKQanI+qsUEuHjnR22y0B+v6QdFGXLuV/oE/QcjP8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=U7BOWd6y; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="U7BOWd6y" Received: by mail.gandi.net (Postfix) with ESMTPA id C0C2D43A23; Wed, 30 Apr 2025 12:49:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1746017363; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nLx+9dvUsBPx0JucbrUMlWbWrTUIqTh5/5kioAg10L8=; b=U7BOWd6yAvH7Qrqkc5aO+agXbyN4f9TSYFRh6wPbaJFPEyeHgb0YRJ+dyGxa3VDvNR530R 6apuZYIXL9JXsdZoPktxotOpyEZeCEo3ooKbbg4V+26vnyo0O9Lw3IraXLfVIJlqoIcq2b 9PQTTBR+T36TmcqcBWthygybVVwV2jEnSghs6ng1aFgx0MW11SKot5vd7Qmm/LXoYYp0cU p4jG4Q9RliSwHp3Q0W1MqYECHkkKibXsrrUk7Ebl5DhtUUFLH+MNaZYeNT7Vp5/2LWYnQY j2dsRqSIPBfI8mWKEOLDYdrcGGepC1jF7pu7bConLuGtEyOMwMpxDOM5I5ryqw== From: Herve Codina To: David Gibson , Andrew Davis , Ayush Singh , Geert Uytterhoeven , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Herve Codina , Arnd Bergmann , Greg Kroah-Hartman , Saravana Kannan Cc: devicetree@vger.kernel.org, devicetree-compiler@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Ceresoli , Thomas Petazzoni Subject: [PATCH 6/7] of: overlay: Add support for the export symbols node Date: Wed, 30 Apr 2025 14:49:05 +0200 Message-ID: <20250430124910.195368-7-herve.codina@bootlin.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250430124910.195368-1-herve.codina@bootlin.com> References: <20250430124910.195368-1-herve.codina@bootlin.com> 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 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvieeijeegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefjvghrvhgvucevohguihhnrgcuoehhvghrvhgvrdgtohguihhnrgessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepheffiefgjeeuleeuueffleeufefglefhjefhheeigedukeetieeltddthfffkeffnecukfhppeeltddrkeelrdduieefrdduvdejnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehinhgvthepledtrdekledrudeifedruddvjedphhgvlhhopehlohgtrghlhhhoshhtrdhlohgtrghlughomhgrihhnpdhmrghilhhfrhhomhephhgvrhhvvgdrtghoughinhgrsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopeduiedprhgtphhtthhopegurghvihgusehgihgsshhonhdrughrohhpsggvrghrrdhiugdrrghupdhrtghpthhtoheprghfugesthhirdgtohhmpdhrtghpthhtoheprgihuhhshhessggvrghglhgvsghorghrugdrohhrghdprhgtphhtthhopehgvggvrhhtsehlihhnuhigqdhmieekkhdrohhrghdprhgtphhtthhopehrohgshheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepk hhriihkodgutheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheptghonhhorhdoughtsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehhvghrvhgvrdgtohguihhnrgessghoohhtlhhinhdrtghomh X-GND-Sasl: herve.codina@bootlin.com Content-Type: text/plain; charset="utf-8" The resolver already supports the use of the export symbol node. Add support of the export symbol node feature in of_overlay_fdt_apply() simply getting the export node from its name and passing it to the resolver. Signed-off-by: Herve Codina Tested-by: Ayush Singh --- drivers/of/overlay.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index 73ff38c41de2..7c55d39f89af 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -891,6 +891,10 @@ static void free_overlay_changeset(struct overlay_chan= geset *ovcs) * of_overlay_apply() - Create and apply an overlay changeset * @ovcs: overlay changeset * @base: point to the target node to apply overlay + * @export_symbols_name: + * Name of the export symbol subnode of the @base node to + * provide extra symbols. Those extra symbols are used in + * the overlay symbols resolution. * * Creates and applies an overlay changeset. * @@ -915,11 +919,24 @@ static void free_overlay_changeset(struct overlay_cha= ngeset *ovcs) */ =20 static int of_overlay_apply(struct overlay_changeset *ovcs, - const struct device_node *base) + const struct device_node *base, + const char *export_symbols_name) { + struct device_node *export_symbols =3D NULL; int ret =3D 0, ret_revert, ret_tmp; =20 - ret =3D of_resolve_phandles(ovcs->overlay_root, NULL); + if (base && export_symbols_name) { + export_symbols =3D of_get_child_by_name(base, export_symbols_name); + if (!export_symbols) { + pr_err("overlay get export symbols '%s' from %pOF failed\n", + export_symbols_name, base); + ret =3D -EINVAL; + goto out; + } + } + + ret =3D of_resolve_phandles(ovcs->overlay_root, export_symbols); + of_node_put(export_symbols); if (ret) goto out; =20 @@ -1059,7 +1076,7 @@ int of_overlay_fdt_apply(const void *overlay_fdt, u32= overlay_fdt_size, } ovcs->overlay_mem =3D overlay_mem; =20 - ret =3D of_overlay_apply(ovcs, base); + ret =3D of_overlay_apply(ovcs, base, export_symbols_name); /* * If of_overlay_apply() error, calling free_overlay_changeset() may * result in a memory leak if the apply partly succeeded, so do NOT --=20 2.49.0 From nobody Sun Feb 8 06:53:47 2026 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (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 B031B2641E4; Wed, 30 Apr 2025 12:49:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746017368; cv=none; b=a3UoH2FQhjzxpiFO3xV8PdOwvJSXiixTjXUzaQqtVQIqt2+VY7Y9gD0Cok38JAO7Xb2hoALEhWhIfRI2zgpMp0JDo48S/x0fUN5agKruGaxZUBe/rBnnzu4hUCLDVBKcBRHdJlXAkYWE//4XQgLGWmxEUezv2aDMLt19IlyxHmA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746017368; c=relaxed/simple; bh=lhY3UhDu5nx+O1Fi44z/mcLChAzZrf0RUHIYCmu8iL8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pY2CTjjJWPPfNL9u6jRmWWzR25LlIbWCW6d521lUzAG0UJmC+pvae4/Wmewbl2pZ/QEqi/uwdV7dKNHFk7RvDxTrBZT4/YjisuNafqHrfS6WbLZtf5nKxbb8l0ljvMEjKw/N5jbOTZhjlAAuV+PeayZgF7tHdv0I6aMHAuRoCZY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Ebwegr2r; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Ebwegr2r" Received: by mail.gandi.net (Postfix) with ESMTPA id 92F1A43A27; Wed, 30 Apr 2025 12:49:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1746017364; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H/OUpl+c2QHHtmrmXPqlciNY816qMvdz6fKciUiS4VQ=; b=Ebwegr2rIAxBxL8bhqE5Pba9Oj2gUFEWboHFOgeUMV00aAtSmU/5yM0rsb/XgKfRv+lOkf s8EbNI4+/jEoC18NFn21QM+5hAUjZJ24pIcIEOjncTCmWeu7mt1oTSS6mHg6q+e8ittex3 5zFAThF+WhaZDSUVoxm01BxdvI8HVo/NlLbwTne2/1gFF6Y9z6vDOoh3evuh40bzwz85QE qJFi8KNbJXoaykxJcf4C2MpffEZT++8NY3+CqGVt7ct6tToIx47/f1z1I5+v21CyfhfW0O d8H+TKzCFJWqKqAoV9rOIYk/GQOAI5p3Qe9UXT3+eDRiu/6O5ak4Eny7Pm0NyQ== From: Herve Codina To: David Gibson , Andrew Davis , Ayush Singh , Geert Uytterhoeven , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Herve Codina , Arnd Bergmann , Greg Kroah-Hartman , Saravana Kannan Cc: devicetree@vger.kernel.org, devicetree-compiler@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Ceresoli , Thomas Petazzoni Subject: [PATCH 7/7] of: unittest: Add tests for export symbols Date: Wed, 30 Apr 2025 14:49:06 +0200 Message-ID: <20250430124910.195368-8-herve.codina@bootlin.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250430124910.195368-1-herve.codina@bootlin.com> References: <20250430124910.195368-1-herve.codina@bootlin.com> 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 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvieeijeegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefjvghrvhgvucevohguihhnrgcuoehhvghrvhgvrdgtohguihhnrgessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepheffiefgjeeuleeuueffleeufefglefhjefhheeigedukeetieeltddthfffkeffnecukfhppeeltddrkeelrdduieefrdduvdejnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehinhgvthepledtrdekledrudeifedruddvjedphhgvlhhopehlohgtrghlhhhoshhtrdhlohgtrghlughomhgrihhnpdhmrghilhhfrhhomhephhgvrhhvvgdrtghoughinhgrsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopeduiedprhgtphhtthhopegurghvihgusehgihgsshhonhdrughrohhpsggvrghrrdhiugdrrghupdhrtghpthhtoheprghfugesthhirdgtohhmpdhrtghpthhtoheprgihuhhshhessggvrghglhgvsghorghrugdrohhrghdprhgtphhtthhopehgvggvrhhtsehlihhnuhigqdhmieekkhdrohhrghdprhgtphhtthhopehrohgshheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepk hhriihkodgutheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheptghonhhorhdoughtsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehhvghrvhgvrdgtohguihhnrgessghoohhtlhhinhdrtghomh X-GND-Sasl: herve.codina@bootlin.com Content-Type: text/plain; charset="utf-8" The export symbols feature allows to use some additional symbols provided in an export symbols node to resolve overlay symbols. Add tests to exercise the export symbols feature. Signed-off-by: Herve Codina Tested-by: Ayush Singh --- drivers/of/unittest-data/Makefile | 5 ++ .../unittest-data/overlay_export_symbols.dtso | 15 +++++ .../of/unittest-data/testcases_common.dtsi | 1 + .../unittest-data/tests-export-symbols.dtsi | 30 +++++++++ drivers/of/unittest.c | 65 +++++++++++++++++++ 5 files changed, 116 insertions(+) create mode 100644 drivers/of/unittest-data/overlay_export_symbols.dtso create mode 100644 drivers/of/unittest-data/tests-export-symbols.dtsi diff --git a/drivers/of/unittest-data/Makefile b/drivers/of/unittest-data/M= akefile index 01a966e39f23..b51be046749a 100644 --- a/drivers/of/unittest-data/Makefile +++ b/drivers/of/unittest-data/Makefile @@ -34,6 +34,7 @@ obj-$(CONFIG_OF_OVERLAY) +=3D overlay.dtbo.o \ overlay_gpio_04a.dtbo.o \ overlay_gpio_04b.dtbo.o \ overlay_pci_node.dtbo.o \ + overlay_export_symbols.dtbo.o \ overlay_bad_unresolved.dtbo.o =20 # enable creation of __symbols__ node @@ -66,6 +67,10 @@ DTC_FLAGS_testcases +=3D -Wno-interrupts_property \ # overlay_bad_add_dup_prop.dtbo \ # overlay_bad_phandle.dtbo \ # overlay_bad_symbol.dtbo \ +# +# Also overlay_export_symbols_ovl.dtbo is designed to be applied to a spec= ific +# node and cannot be applied statically with fdtoverlay + =20 apply_static_overlay_1 :=3D overlay_0.dtbo \ overlay_1.dtbo \ diff --git a/drivers/of/unittest-data/overlay_export_symbols.dtso b/drivers= /of/unittest-data/overlay_export_symbols.dtso new file mode 100644 index 000000000000..89c9df4ef89b --- /dev/null +++ b/drivers/of/unittest-data/overlay_export_symbols.dtso @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; +/plugin/; + +/ { + fragment@0 { + target-path=3D""; + __overlay__ { + ovl_node { + ref-base =3D <&test_export_base>; + ref-node =3D <&test_export_node>; + }; + }; + }; +}; diff --git a/drivers/of/unittest-data/testcases_common.dtsi b/drivers/of/un= ittest-data/testcases_common.dtsi index 1c2cdf353ae3..21ffe0fb03ef 100644 --- a/drivers/of/unittest-data/testcases_common.dtsi +++ b/drivers/of/unittest-data/testcases_common.dtsi @@ -18,4 +18,5 @@ node-remove { #include "tests-address.dtsi" #include "tests-platform.dtsi" #include "tests-overlay.dtsi" +#include "tests-export-symbols.dtsi" #include "tests-lifecycle.dtsi" diff --git a/drivers/of/unittest-data/tests-export-symbols.dtsi b/drivers/o= f/unittest-data/tests-export-symbols.dtsi new file mode 100644 index 000000000000..1650289b34cd --- /dev/null +++ b/drivers/of/unittest-data/tests-export-symbols.dtsi @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0 + +/ { + testcase-data { + test-export-symbols { + test_export_symbols_b0: base0 { + test_export_symbols_n0: node { + dummy; + }; + + export-symbols { + test_export_base =3D <&test_export_symbols_b0>; + test_export_node =3D <&test_export_symbols_n0>; + }; + }; + + test_export_symbols_b1: base1 { + + test_export_symbols_n1: node { + dummy; + }; + + export-symbols { + test_export_base =3D <&test_export_symbols_b1>; + test_export_node =3D <&test_export_symbols_n1>; + }; + }; + }; + }; +}; diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 11091b0176e0..bf286902c65b 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -4164,6 +4164,69 @@ static __init void of_unittest_overlay_high_level(vo= id) mutex_unlock(&of_mutex); } =20 +OVERLAY_INFO_EXTERN(overlay_export_symbols); + +static __init void of_unittest_export_symbols(const char *prefix, + const char *base_full_path) +{ + const struct overlay_info ovl =3D OVERLAY_INFO(overlay_export_symbols, 0,= 0); + struct device_node *ovl_node; + struct device_node *base; + struct device_node *node; + struct device_node *ref; + int ovcs_id; + u32 size; + int ret; + + base =3D of_find_node_by_path(base_full_path); + if (unittest(base, "%s: Get base (%s) failed\n", prefix, base_full_path)) + return; + + node =3D of_get_child_by_name(base, "node"); + if (unittest(base, "%s: Get node from %pOF failed\n", prefix, base)) + goto end_put_base; + + size =3D ovl.dtbo_end - ovl.dtbo_begin; + ret =3D of_overlay_fdt_apply(ovl.dtbo_begin, size, &ovcs_id, base, "expor= t-symbols"); + if (unittest(!ret, "%s: Apply '%s' failed (%d)\n", prefix, ovl.name, ret)) + goto end_put_node; + + ovl_node =3D of_get_child_by_name(base, "ovl_node"); + if (unittest(ovl_node, "%s: Get ovl_node from %pOF failed\n", prefix, bas= e)) + goto end_remove_overlay; + + ref =3D of_parse_phandle(ovl_node, "ref-base", 0); + if (unittest(ref, "%s: Parse 'ref-base' from %pOF failed\n", prefix, ovl_= node)) + goto end_put_ovl_node; + unittest(ref =3D=3D base, + "%s: Node from 'ref-base' phandle mismatches (got %pOF, expected %pOF)\= n", + prefix, ref, base); + of_node_put(ref); + + ref =3D of_parse_phandle(ovl_node, "ref-node", 0); + if (unittest(ref, "%s: Parse 'ref-node' from %pOF failed\n", prefix, ovl_= node)) + goto end_put_ovl_node; + unittest(ref =3D=3D node, + "%s: Node from 'ref-node' phandle mismatches (got %pOF, expected %pOF)\= n", + prefix, ref, node); + of_node_put(ref); + +end_put_ovl_node: + of_node_put(ovl_node); +end_remove_overlay: + of_overlay_remove(&ovcs_id); +end_put_node: + of_node_put(node); +end_put_base: + of_node_put(base); +} + +static __init void of_unittest_overlay_export_symbols(void) +{ + of_unittest_export_symbols("base0", "/testcase-data/test-export-symbols/b= ase0"); + of_unittest_export_symbols("base1", "/testcase-data/test-export-symbols/b= ase1"); +} + static int of_unittest_pci_dev_num; static int of_unittest_pci_child_num; =20 @@ -4349,6 +4412,7 @@ static void __init of_unittest_pci_node(void) #else =20 static inline __init void of_unittest_overlay_high_level(void) {} +static inline __init void of_unittest_overlay_export_symbols(void) {} static inline __init void of_unittest_pci_node(void) { } =20 #endif @@ -4404,6 +4468,7 @@ static int __init of_unittest(void) of_unittest_overlay(); of_unittest_lifecycle(); of_unittest_pci_node(); + of_unittest_overlay_export_symbols(); =20 /* Double check linkage after removing testcase data */ of_unittest_check_tree_linkage(); --=20 2.49.0