From patchwork Fri Nov 9 06:05:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 10675331 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B6B614D6 for ; Fri, 9 Nov 2018 06:08:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0ABEA2D95A for ; Fri, 9 Nov 2018 06:08:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F24952D9A2; Fri, 9 Nov 2018 06:08:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FF2F2D95A for ; Fri, 9 Nov 2018 06:08:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728091AbeKIPq6 (ORCPT ); Fri, 9 Nov 2018 10:46:58 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:34833 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728054AbeKIPq5 (ORCPT ); Fri, 9 Nov 2018 10:46:57 -0500 Received: by mail-pg1-f195.google.com with SMTP id 32-v6so413549pgu.2; Thu, 08 Nov 2018 22:07:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cuC5fkmMeEqcg/kIc3ytOs24liArJsl1Rxlcr3OwYd0=; b=i3VPxCbYrGTe71MjP0t1QUsx00IzfkHOfhu9a2mGtWx50O17igJWDbLfbsfxSTP6uz iVg6UHdqZpRlfpyTbj+172chJt5YzbEk5tOAzzSf1N9CivOjXRic3/lvwQyOrHTY/3wJ PKEPe4FDdrfIL50/T/KTe9ykaIQ7oO6mykMjtrz+glrhwwsO/TbPTYaqrWRb68R4zSup /WH0dWadrvVqJmjYCGAzyK1Z/2dM0dX71r9Dn6ZuQ4IqmPcAEsvjVDu1XhemPiAvJu+A o/oDRRG9KNTJlbjEaLoJC1etTyEwk7l0ThV/JCDOHwTkBl0Iwy6e2d1z72FNjufA0UM9 iYAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cuC5fkmMeEqcg/kIc3ytOs24liArJsl1Rxlcr3OwYd0=; b=s8MeNjpjisLmNveIFtEAZ3X38PWY9BsQQuBTZLqgKoNgIsFg+jfbIuLaooNQPo/WGo bpxSxg8gQEevUugootP/v6id+N0AXU2A5YwUB+acDWpvB+xZJ8rEZdL02jVR502Bh8MW TYqrLnh5eUmtLq87MG2YMMi5HpFTvFaLTTAkOUBBDvtDpxaDF3ehqj4Rt43c1XPbfcgU jnnoruuEipJpKcryjBvJzS60x3wT5o7H7XqwYUkVTCkmkeyTCHfgWWraS2HJv3nzLVEM JFNqfYImf6BqtflE7zg6L0T8R1DTsxsyNezYfpe2jVpMh03E2Qg3NYRO0lqS9a9VkZph OKnA== X-Gm-Message-State: AGRZ1gIAueFQb8KqThu+iNdNgKvlIB9wkw0f/Cv/OtK8m0Hs1aWroEzr N8h1tZfv2qcT5P8ls9HrZEc= X-Google-Smtp-Source: AJdET5e6TG5NHTtCUpPHzwauFQ08nJ6cTix1vEjDzJy5cHbSoqAbMCDI+P94zDQ9BGMBsWWrLOpaTw== X-Received: by 2002:a63:50b:: with SMTP id 11mr6213835pgf.411.1541743676627; Thu, 08 Nov 2018 22:07:56 -0800 (PST) Received: from localhost.localdomain (c-24-6-192-50.hsd1.ca.comcast.net. [24.6.192.50]) by smtp.gmail.com with ESMTPSA id c70-v6sm6620722pfg.97.2018.11.08.22.07.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Nov 2018 22:07:56 -0800 (PST) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, devicetree@vger.kernel.org, linux-fpga@vger.kernel.org Subject: [PATCH v7 10/17] of: overlay: test case of two fragments adding same node Date: Thu, 8 Nov 2018 22:05:58 -0800 Message-Id: <1541743565-23163-11-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1541743565-23163-1-git-send-email-frowand.list@gmail.com> References: <1541743565-23163-1-git-send-email-frowand.list@gmail.com> Sender: linux-fpga-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Frank Rowand Multiple overlay fragments adding or deleting the same node is not supported. An attempt to do so results in an incorrect devicetree. The node name will be munged for the second add. After adding this patch, the unittest messages will show: Duplicate name in motor-1, renamed to "controller#1" OF: overlay: of_overlay_apply() err=0 ### dt-test ### of_overlay_fdt_apply() expected -22, ret=0, overlay_bad_add_dup_node ### dt-test ### FAIL of_unittest_overlay_high_level():2419 Adding overlay 'overlay_bad_add_dup_node' failed ... ### dt-test ### end of unittest - 210 passed, 1 failed The incorrect (munged) node name "controller#1" can be seen in the /proc filesystem: $ pwd /proc/device-tree/testcase-data-2/substation@100/motor-1 $ ls compatible controller controller#1 name phandle spin $ ls controller power_bus $ ls controller#1 power_bus_emergency Tested-by: Alan Tull Signed-off-by: Frank Rowand --- drivers/of/unittest-data/Makefile | 1 + .../of/unittest-data/overlay_bad_add_dup_node.dts | 28 ++++++++++++++++++++++ drivers/of/unittest.c | 5 ++++ 3 files changed, 34 insertions(+) create mode 100644 drivers/of/unittest-data/overlay_bad_add_dup_node.dts diff --git a/drivers/of/unittest-data/Makefile b/drivers/of/unittest-data/Makefile index 013d85e694c6..166dbdbfd1c5 100644 --- a/drivers/of/unittest-data/Makefile +++ b/drivers/of/unittest-data/Makefile @@ -17,6 +17,7 @@ obj-$(CONFIG_OF_OVERLAY) += overlay.dtb.o \ overlay_12.dtb.o \ overlay_13.dtb.o \ overlay_15.dtb.o \ + overlay_bad_add_dup_node.dtb.o \ overlay_bad_phandle.dtb.o \ overlay_bad_symbol.dtb.o \ overlay_base.dtb.o diff --git a/drivers/of/unittest-data/overlay_bad_add_dup_node.dts b/drivers/of/unittest-data/overlay_bad_add_dup_node.dts new file mode 100644 index 000000000000..145dfc3b1024 --- /dev/null +++ b/drivers/of/unittest-data/overlay_bad_add_dup_node.dts @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; +/plugin/; + +/* + * &electric_1/motor-1 and &spin_ctrl_1 are the same node: + * /testcase-data-2/substation@100/motor-1 + * + * Thus the new node "controller" in each fragment will + * result in an attempt to add the same node twice. + * This will result in an error and the overlay apply + * will fail. + */ + +&electric_1 { + + motor-1 { + controller { + power_bus = < 0x1 0x2 >; + }; + }; +}; + +&spin_ctrl_1 { + controller { + power_bus_emergency = < 0x101 0x102 >; + }; +}; diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 49ae2aa744d6..f82edf829f43 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -2161,6 +2161,7 @@ struct overlay_info { OVERLAY_INFO_EXTERN(overlay_12); OVERLAY_INFO_EXTERN(overlay_13); OVERLAY_INFO_EXTERN(overlay_15); +OVERLAY_INFO_EXTERN(overlay_bad_add_dup_node); OVERLAY_INFO_EXTERN(overlay_bad_phandle); OVERLAY_INFO_EXTERN(overlay_bad_symbol); @@ -2183,6 +2184,7 @@ struct overlay_info { OVERLAY_INFO(overlay_12, 0), OVERLAY_INFO(overlay_13, 0), OVERLAY_INFO(overlay_15, 0), + OVERLAY_INFO(overlay_bad_add_dup_node, -EINVAL), OVERLAY_INFO(overlay_bad_phandle, -EINVAL), OVERLAY_INFO(overlay_bad_symbol, -EINVAL), {} @@ -2430,6 +2432,9 @@ static __init void of_unittest_overlay_high_level(void) unittest(overlay_data_apply("overlay", NULL), "Adding overlay 'overlay' failed\n"); + unittest(overlay_data_apply("overlay_bad_add_dup_node", NULL), + "Adding overlay 'overlay_bad_add_dup_node' failed\n"); + unittest(overlay_data_apply("overlay_bad_phandle", NULL), "Adding overlay 'overlay_bad_phandle' failed\n");