Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1543525imm; Fri, 12 Oct 2018 21:57:01 -0700 (PDT) X-Google-Smtp-Source: ACcGV63QTpJG1B5dpzGpfbtHf1D+eZeP6PklYhgakQltSW7gqXUvZ32Kz8DZiFGnF6vsnugwrO75 X-Received: by 2002:a65:65c6:: with SMTP id y6-v6mr7892537pgv.233.1539406621203; Fri, 12 Oct 2018 21:57:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539406621; cv=none; d=google.com; s=arc-20160816; b=gKTRuZF5AXNC2jnOJz6NJfj0HCa0saT9aT4eD8at4RVuMDWRFiIWHuj5hKT4lg/l5e T3v8N+CyMzYdPmMAdKWVwK1Ge/v2H0T0zlj7rS6qZKQxCPFJo8bvqNt+s9oj2cOAFyNg FJ4lLiCbT6i3WE7J+5OKcTj8Iybl1BS4KdWBPrfk1Ihb30KUDDY05QUgQasUUbrZ4/XP oyARVd0MewzpVkQ8qKJ0+hibaTcEe+OHraAE083sKbw+Wj5uFvkrZqX8zxbQohLSK5Nb MJElb8r98dx3yAb/ayd8ykZVHGL6MmAACUtBsUWhqpqyHm/w6H+JQTJ9KhexdzCZ6/mY Gjww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=1eIq+bpAJjW92EtiaqYATBx5CfeVYNbB6/35CF3TsEg=; b=yosZJYMfCH7+cl/t1KantC472kuY4rzMIX00x7IhvgT0ih4FWJMppM1zv+1QUGZ/l+ NsFbKslDvHhbAQgpUEaMFaxchqRmIqPJu/mGszc0nWgRajEYQ9RmbNsyKvYMPStKy/4v wSbYcmBydD/sSO66yd5HQoHevobyr0AsLsX4Q+rYkBnyPIY4dO+m4cA1detEd870C4px FWxemhII5vVo+N1nMhPHHCQULP/8q9ATD7SOGe+mmblLaLnvh9EA1qz3zzFQU0Z64HMb RyWXgRpiiFeb5lDksBiuxMZYIusQ7TabsA2e8ssapsfvS45QEP0OXX4bvDr0o8poaUjx LVzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Edv51Tm5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si3516094plk.405.2018.10.12.21.56.46; Fri, 12 Oct 2018 21:57:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Edv51Tm5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727050AbeJMMbA (ORCPT + 99 others); Sat, 13 Oct 2018 08:31:00 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:36304 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726964AbeJMMa7 (ORCPT ); Sat, 13 Oct 2018 08:30:59 -0400 Received: by mail-pl1-f196.google.com with SMTP id y11-v6so6820413plt.3; Fri, 12 Oct 2018 21:55:18 -0700 (PDT) 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=1eIq+bpAJjW92EtiaqYATBx5CfeVYNbB6/35CF3TsEg=; b=Edv51Tm5V+YnME4rTFQTKB40mZvmwboEh9HvLGiqvuiyZiH9Cp4Kost2sdbjNoYb4i tZexQpai48vDDvNZXqGzyPpes38YGfx7gqYLHsU74Y/t/8qlsA6toCz0PEdOaR5hZKAu X4tHVB4keiunliqmKHH3wQ0LEbl+ItUWJVlblRO2k0SjGu93yg99C+S14v9otBIohJKU rl4hphaqE2Z+NzWThHWzyRgjFiFk1AR+muRq4R5/TFHJWGZqmHIZnIQbgTHJZUJJINrJ ghENYWIquz6CzE3ETEX4jB4CpwmCU4ofZy33jLs72JeL4Q8A0Em9rgBiwRwo9kk4PEdA chsg== 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=1eIq+bpAJjW92EtiaqYATBx5CfeVYNbB6/35CF3TsEg=; b=hzdM2tYnxb2j5y00fRfv2lCWsodIS6kP7yJAQ9MYbtd61XoONCG/h99aJkHl8IP7mu GW/DIHkoktsWk3zKuo9NyOAhw9o41ugt/AddfkcwVMmCmHGKoSoi2mlPO5L2s+peF5DX RYj3C/7MYqqjSRfSWlhiR5sNZxoVWY5vnu0pqp8BUpdrt2cXub8b3SEmSzoIwxXm6zqW 5/7t3NompbYrkQdXBknEaZXqYYXpu7ywvIykea2aRZGtKBdCg2itYy0opCFOIy9rtKcD VrZ5g2FmYDZrXF905EeTZXgeMaAT6BKX5tfwE07C8EUJeeaUmdqc60HhdsKu6bJfAnlS 6O8g== X-Gm-Message-State: ABuFfogAm/7sp/+5TlBeJbDYJ0Hj/cCCOprFqNRQkVPc/pMSRIfw81fQ YKsjcMoN/uQZ27MZqvlslgk= X-Received: by 2002:a17:902:8609:: with SMTP id f9-v6mr8577932plo.134.1539406518567; Fri, 12 Oct 2018 21:55:18 -0700 (PDT) Received: from localhost.localdomain (c-24-6-192-50.hsd1.ca.comcast.net. [24.6.192.50]) by smtp.gmail.com with ESMTPSA id h87-v6sm6959462pfj.78.2018.10.12.21.55.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Oct 2018 21:55:18 -0700 (PDT) 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 v2 11/18] of: overlay: test case of two fragments adding same node Date: Fri, 12 Oct 2018 21:53:31 -0700 Message-Id: <1539406418-18162-12-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539406418-18162-1-git-send-email-frowand.list@gmail.com> References: <1539406418-18162-1-git-send-email-frowand.list@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 722537e14848..471b8eb6e842 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -2147,6 +2147,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); @@ -2169,6 +2170,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), {} @@ -2413,6 +2415,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"); -- Frank Rowand