From patchwork Mon Oct 15 00:24:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 983829 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YK9h6Lwwz9s55 for ; Mon, 15 Oct 2018 11:31:04 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OYBKWYXt"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42YK9h4c56zF13T for ; Mon, 15 Oct 2018 11:31:04 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OYBKWYXt"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::443; helo=mail-pf1-x443.google.com; envelope-from=frowand.list@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OYBKWYXt"; dkim-atps=neutral Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42YK3t4PvZzDrq6 for ; Mon, 15 Oct 2018 11:26:02 +1100 (AEDT) Received: by mail-pf1-x443.google.com with SMTP id u12-v6so8742711pfn.12 for ; Sun, 14 Oct 2018 17:26:02 -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=lPoDioj489a2/oR5DkZXnv7vgj2sX9AQIbb7kmBjERc=; b=OYBKWYXtaP2d8/q3dAQOCiXzFRReqKvSNXY2p8bFxVaO3kNRaETkbkqVoLhNmWpzEM um/Q5m9Evqg5D2JIr3yAixtCv+VXks800bSiFdu+XCOJPa1lqdg0CMc+ZRu7hP+sr7Z7 cbDH5amgTS226LJr5aWhUgpy+wwoyUdayHIwfdBAtFznHgtq0h4IdoLJkX9YMfwwJndl 6AF88DNCi/JoXfJSV0p4GCq4/28Kb2+qKcKLBoT7OU6AP7Abz7mSAsH/JGMRq4PYnsxp zBxnuz6ErH9nN3dCTLBeqVi2DSeKB0qesYpELGAamb3io4ss/7iw6mkpxXtucF0XDzc5 DmfQ== 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=lPoDioj489a2/oR5DkZXnv7vgj2sX9AQIbb7kmBjERc=; b=SxLM3pOEw8KlrZDOucMxvoJvP4AT673D3860pErDR8odAuQtf9paMi7i/omzMyhj7j Wx4i51oTOyIg9rr6/IVqJNgDjahzDSs0av9St5n67n6GbqWucDm/mPEVyLD8oBFuDfl3 7jtCqDv5f9P218xUFiI361mNdT/vj1EX26HjbkLT61WWK0iepVIwZ1tkcn8FUAFazQsw tYYwG2tC81JJE0XbEP1f+Sm+c+YyB4vt6WDr5oyxC2kkLr7b3Eu3PbnMuLYTgfQ0tnNk wzOYkjkgMn6Ay1QwGotSV4l6kJyW9ECYqX+3LplteuUjU38TpdANZ46LPaKDAC4j0We1 NFiQ== X-Gm-Message-State: ABuFfoiBp/Dh3F3s0CDPIO9QrbVP+l2ME5FZ1LghtexbWbadPPTXujJ0 uf3khB58JO6N1hl8V4R19sw= X-Google-Smtp-Source: ACcGV60pao8i5uAW7LjOqXI/qvGVnpTKieOfyQn6zutUSEh0PbDKDaIgFvQhCDixLYEHKQrupLCoDQ== X-Received: by 2002:a63:d14a:: with SMTP id c10-v6mr14073372pgj.384.1539563160724; Sun, 14 Oct 2018 17:26:00 -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 j14-v6sm11387110pgh.52.2018.10.14.17.25.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Oct 2018 17:26:00 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v3 01/18] of: overlay: add tests to validate kfrees from overlay removal Date: Sun, 14 Oct 2018 17:24:13 -0700 Message-Id: <1539563070-12969-2-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> References: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-fpga@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Frank Rowand Add checks: - attempted kfree due to refcount reaching zero before overlay is removed - properties linked to an overlay node when the node is removed - node refcount > one during node removal in a changeset destroy, if the node was created by the changeset After applying this patch, several validation warnings will be reported from the devicetree unittest during boot due to pre-existing devicetree bugs. The warnings will be similar to: OF: ERROR: of_node_release() overlay node /testcase-data/overlay-node/test-bus/test-unittest11/test-unittest111 contains unexpected properties OF: ERROR: memory leak - destroy cset entry: attach overlay node /testcase-data-2/substation@100/hvac-medium-2 with refcount 2 Signed-off-by: Frank Rowand --- drivers/of/dynamic.c | 29 +++++++++++++++++++++++++++++ drivers/of/overlay.c | 1 + include/linux/of.h | 15 ++++++++++----- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index f4f8ed9b5454..b04ee021a891 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -330,6 +330,25 @@ void of_node_release(struct kobject *kobj) if (!of_node_check_flag(node, OF_DYNAMIC)) return; + if (of_node_check_flag(node, OF_OVERLAY)) { + + if (!of_node_check_flag(node, OF_OVERLAY_FREE_CSET)) { + /* premature refcount of zero, do not free memory */ + pr_err("ERROR: memory leak %s() overlay node %pOF before free overlay changeset\n", + __func__, node); + return; + } + + /* + * If node->properties non-empty then properties were added + * to this node either by different overlay that has not + * yet been removed, or by a non-overlay mechanism. + */ + if (node->properties) + pr_err("ERROR: %s() overlay node %pOF contains unexpected properties\n", + __func__, node); + } + property_list_free(node->properties); property_list_free(node->deadprops); @@ -434,6 +453,16 @@ struct device_node *__of_node_dup(const struct device_node *np, static void __of_changeset_entry_destroy(struct of_changeset_entry *ce) { + if (ce->action == OF_RECONFIG_ATTACH_NODE && + of_node_check_flag(ce->np, OF_OVERLAY)) { + if (kref_read(&ce->np->kobj.kref) > 1) { + pr_err("ERROR: memory leak - destroy cset entry: attach overlay node %pOF with refcount %d\n", + ce->np, kref_read(&ce->np->kobj.kref)); + } else { + of_node_set_flag(ce->np, OF_OVERLAY_FREE_CSET); + } + } + of_node_put(ce->np); list_del(&ce->node); kfree(ce); diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index eda57ef12fd0..1176cb4b6e4e 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -373,6 +373,7 @@ static int add_changeset_node(struct overlay_changeset *ovcs, return -ENOMEM; tchild->parent = target_node; + of_node_set_flag(tchild, OF_OVERLAY); ret = of_changeset_attach_node(&ovcs->cset, tchild); if (ret) diff --git a/include/linux/of.h b/include/linux/of.h index 4d25e4f952d9..aa1dafaec6ae 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -138,11 +138,16 @@ static inline void of_node_put(struct device_node *node) { } extern struct device_node *of_stdout; extern raw_spinlock_t devtree_lock; -/* flag descriptions (need to be visible even when !CONFIG_OF) */ -#define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */ -#define OF_DETACHED 2 /* node has been detached from the device tree */ -#define OF_POPULATED 3 /* device already created for the node */ -#define OF_POPULATED_BUS 4 /* of_platform_populate recursed to children of this node */ +/* + * struct device_node flag descriptions + * (need to be visible even when !CONFIG_OF) + */ +#define OF_DYNAMIC 1 /* (and properties) allocated via kmalloc */ +#define OF_DETACHED 2 /* detached from the device tree */ +#define OF_POPULATED 3 /* device already created */ +#define OF_POPULATED_BUS 4 /* platform bus created for children */ +#define OF_OVERLAY 5 /* allocated for an overlay */ +#define OF_OVERLAY_FREE_CSET 6 /* in overlay cset being freed */ #define OF_BAD_ADDR ((u64)-1) From patchwork Mon Oct 15 00:24:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 983830 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YKDH0m6pz9s5b for ; Mon, 15 Oct 2018 11:33:19 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BYiaTm9M"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42YKDG6LTkzF13F for ; Mon, 15 Oct 2018 11:33:18 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BYiaTm9M"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::543; helo=mail-pg1-x543.google.com; envelope-from=frowand.list@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BYiaTm9M"; dkim-atps=neutral Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42YK3v5T4LzDrpw for ; Mon, 15 Oct 2018 11:26:03 +1100 (AEDT) Received: by mail-pg1-x543.google.com with SMTP id i4-v6so8289367pgq.9 for ; Sun, 14 Oct 2018 17:26:03 -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=6jwtNAKUA0bImQ+OzjBieSYaakSLUGtiTllRPSG9WlA=; b=BYiaTm9Mf5LbmJ5N7U+2g/I5x34CyW/qXhGU63isvMPHa6v43UylPoMGsYp3Z28jOz PYl5YjbMrZh78LkYxRr1kl4g21hr8YYZFqItJd5+jRjK1t6EDvTHyYV4jVynBXLzMCVQ fNf4iZNRFm99eDsj0tG5Fyel5nMXIg4kMWb3YZCQqkng88TWZ/+xNhnO2LLqx9t1ZeLr TjHvAtDUvBS3/FLNmdL8Y5UEQ/BbLMUVdQaOMVG1dzGKne6C8HK7QDmmCyvndFMTkj9X 53edHuD/QwJKftiemwVxdbbOxN/aLHX3a3CQwba9tbAxDF0YSibVK8wJRZsKHI7R+T+O eOuw== 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=6jwtNAKUA0bImQ+OzjBieSYaakSLUGtiTllRPSG9WlA=; b=JoWryG9pjl+0vv8WxNsecKeugQL58vtuY6FJB2ZANcvFtzrLQNavW04buoo+7K5Eck mqsd69R59LRd+IqHKLm9pza75ha8u+QnxurtIET788DqR5KtzNQ+qFZ3VbE7oc9Wa3/6 btUG54YZqSDZ6VCEyobVGu3OLIWPPEcTy+DlxkhXHQtYdjqw06OgK0l0Jkih1THkd6Nl SXJg8axpTWmGOwbI8JIYvf5LFlRQWZkTjp4jwt0TJFUjo58mug29X2oOloKel0xCK/sM 7MsurCHPf6VVOvLVA7IqQgItvR8H6SXblnEeqN/L57qpYgkzB6PxDxu2Qt4qFCBmNQDw pNLQ== X-Gm-Message-State: ABuFfoiJLtA1YtzoDlRCfnRgRn2adP7BtOGDhOFHlxZ8b/2FzG1aNcN6 2sx7Qq2NcDaI9FRLujqooHs= X-Google-Smtp-Source: ACcGV61bTCYF5x9UYhIzNsm/Qtb2Zv3fJBPszdApXHSBQp/9PoPVwi16dtocxt2lVI3BWXDsCZMkxg== X-Received: by 2002:a62:564e:: with SMTP id k75-v6mr15351308pfb.33.1539563162140; Sun, 14 Oct 2018 17:26:02 -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 j14-v6sm11387110pgh.52.2018.10.14.17.26.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Oct 2018 17:26:01 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v3 02/18] of: overlay: add missing of_node_put() after add new node to changeset Date: Sun, 14 Oct 2018 17:24:14 -0700 Message-Id: <1539563070-12969-3-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> References: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-fpga@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Frank Rowand The refcount of a newly added overlay node decrements to one (instead of zero) when the overlay changeset is destroyed. This change will cause the final decrement be to zero. After applying this patch, new validation warnings will be reported from the devicetree unittest during boot due to a pre-existing devicetree bug. The warnings will be similar to: OF: ERROR: memory leak of_node_release() overlay node /testcase-data/overlay-node/test-bus/test-unittest4 before free overlay changeset This pre-existing devicetree bug will also trigger a WARN_ONCE() from refcount_sub_and_test_checked() when an overlay changeset is destroyed without having first been applied. This scenario occurs when an error in the overlay is detected during the overlay changeset creation: WARNING: CPU: 0 PID: 1 at lib/refcount.c:187 refcount_sub_and_test_checked+0xa8/0xbc refcount_t: underflow; use-after-free. (unwind_backtrace) from (show_stack+0x10/0x14) (show_stack) from (dump_stack+0x6c/0x8c) (dump_stack) from (__warn+0xdc/0x104) (__warn) from (warn_slowpath_fmt+0x44/0x6c) (warn_slowpath_fmt) from (refcount_sub_and_test_checked+0xa8/0xbc) (refcount_sub_and_test_checked) from (kobject_put+0x24/0x208) (kobject_put) from (of_changeset_destroy+0x2c/0xb4) (of_changeset_destroy) from (free_overlay_changeset+0x1c/0x9c) (free_overlay_changeset) from (of_overlay_remove+0x284/0x2cc) (of_overlay_remove) from (of_unittest_apply_revert_overlay_check.constprop.4+0xf8/0x1e8) (of_unittest_apply_revert_overlay_check.constprop.4) from (of_unittest_overlay+0x960/0xed8) (of_unittest_overlay) from (of_unittest+0x1cc4/0x2138) (of_unittest) from (do_one_initcall+0x4c/0x28c) (do_one_initcall) from (kernel_init_freeable+0x29c/0x378) (kernel_init_freeable) from (kernel_init+0x8/0x110) (kernel_init) from (ret_from_fork+0x14/0x2c) Signed-off-by: Frank Rowand --- drivers/of/overlay.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index 1176cb4b6e4e..32cfee68f2e3 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -379,7 +379,9 @@ static int add_changeset_node(struct overlay_changeset *ovcs, if (ret) return ret; - return build_changeset_next_level(ovcs, tchild, node); + ret = build_changeset_next_level(ovcs, tchild, node); + of_node_put(tchild); + return ret; } if (node->phandle && tchild->phandle) From patchwork Mon Oct 15 00:24:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 983831 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YKGt1cwxz9s5b for ; Mon, 15 Oct 2018 11:35:34 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Uzv6Yjjx"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42YKGt06fGzF0Pd for ; Mon, 15 Oct 2018 11:35:34 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Uzv6Yjjx"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::442; helo=mail-pf1-x442.google.com; envelope-from=frowand.list@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Uzv6Yjjx"; dkim-atps=neutral Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42YK3x0z0XzDrpw for ; Mon, 15 Oct 2018 11:26:05 +1100 (AEDT) Received: by mail-pf1-x442.google.com with SMTP id 78-v6so6382262pfq.0 for ; Sun, 14 Oct 2018 17:26:04 -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=LkfoWFcm35ZeWsmFJr143DG24LEUdEKPjd4pwB8vYwk=; b=Uzv6YjjxexlLzpyU+vjvP21HgRYfNv92lYn/zG7KSH2fGoP3pgfyjAjHPzNdVF3LPg SNve7sEbcEVMTRbSGO+4c3Dmq8fR9CthPMJw9tFMUVzBo2d+JqcpJfMaT/TRyrNgvfN+ CiPUaOHBdAPQAWhZsGI6XHFk6hhnVG6egN3bM7LS3r7pvPM9srLgW4HURs8AgrJsP+tO /6qTvoisEioyMFau2UAhuL4mTmZfJ9n1zDrKGiADiPT8y0c7khGZwWvZke44vh847DAF 3gARD4Tl8o/no2EyXjTKUkJG953PpXqY7EUngcm08NTM36fMim5OWWskPrpPTBJbuQYy ACNA== 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=LkfoWFcm35ZeWsmFJr143DG24LEUdEKPjd4pwB8vYwk=; b=qSjFMyva6BF9GHuHBIFNZIbBHkgAlQCpjZ7Rok3i0T3u392635GjlkKrtcocqL+30p E8WblX4fgwmiLkuKq/LeQcg8jPGqJQAWSxJ3JI4u913jPrdaSSjcE2F8hGaLisAX6CAL lH+qYFm/7TsNsNMQBQazO8YEdRdFdZGyhPRJ8QZA/GUOIoivsmK3H+fX0n/5KA88/IVR wYGHlF7K0K24X33L/+Eh5J+iefHpZkrQeOCoG98mBXSIFFouzv4tR7S9wqpm4BnRQQe6 K6/YEAY/bycdXUNfdlYnFguTy4xDw3kG0bgp5qjsLQt1QfBefgWpS6CM+bTG8NJaIipf 1glw== X-Gm-Message-State: ABuFfojctZbqxhAWsIWLk+cGtpBg+NMZ0QdeJL/at5RthLPuGYG94zJH jvr3lRBuhYgI678XA8i3mQK/efIK X-Google-Smtp-Source: ACcGV63OIkeAqDgCl/OdYrs584MihorD9M9bqZZ8Kbp8SsSc4pi9nWKmqCOzvVGHS/DHhbEg0pz5vw== X-Received: by 2002:a65:664e:: with SMTP id z14-v6mr13542613pgv.347.1539563163410; Sun, 14 Oct 2018 17:26:03 -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 j14-v6sm11387110pgh.52.2018.10.14.17.26.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Oct 2018 17:26:02 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v3 03/18] of: overlay: add missing of_node_get() in __of_attach_node_sysfs Date: Sun, 14 Oct 2018 17:24:15 -0700 Message-Id: <1539563070-12969-4-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> References: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-fpga@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Frank Rowand There is a matching of_node_put() in __of_detach_node_sysfs() Remove misleading comment from function header comment for of_detach_node(). This patch may result in memory leaks from code that directly calls the dynamic node add and delete functions directly instead of using changesets. Signed-off-by: Frank Rowand --- drivers/of/dynamic.c | 3 --- drivers/of/kobj.c | 4 +++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index b04ee021a891..275c0d7e2268 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -272,9 +272,6 @@ void __of_detach_node(struct device_node *np) /** * of_detach_node() - "Unplug" a node from the device tree. - * - * The caller must hold a reference to the node. The memory associated with - * the node is not freed until its refcount goes to zero. */ int of_detach_node(struct device_node *np) { diff --git a/drivers/of/kobj.c b/drivers/of/kobj.c index 7a0a18980b98..c72eef988041 100644 --- a/drivers/of/kobj.c +++ b/drivers/of/kobj.c @@ -133,6 +133,9 @@ int __of_attach_node_sysfs(struct device_node *np) } if (!name) return -ENOMEM; + + of_node_get(np); + rc = kobject_add(&np->kobj, parent, "%s", name); kfree(name); if (rc) @@ -159,6 +162,5 @@ void __of_detach_node_sysfs(struct device_node *np) kobject_del(&np->kobj); } - /* finally remove the kobj_init ref */ of_node_put(np); } From patchwork Mon Oct 15 00:24:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 983832 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YKKV3THgz9s4s for ; Mon, 15 Oct 2018 11:37:50 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Wnr+8LIC"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42YKKV1v3qzF1Cq for ; Mon, 15 Oct 2018 11:37:50 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Wnr+8LIC"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::442; helo=mail-pf1-x442.google.com; envelope-from=frowand.list@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Wnr+8LIC"; dkim-atps=neutral Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42YK3y2jq2zDrqN for ; Mon, 15 Oct 2018 11:26:06 +1100 (AEDT) Received: by mail-pf1-x442.google.com with SMTP id f26-v6so8753689pfn.9 for ; Sun, 14 Oct 2018 17:26:06 -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=2V0SSjUhWRPC5W4OdqGfdKbaaGUGCT0NLhr5UzIi3kQ=; b=Wnr+8LIC1PVd+cR+XFwtzb94AQJUTHPMc8z1qC2M9v2nyrBF3I8nvB/v5WeMstwlbi bT9o5Nj1pzNAlrctIxXg/qgHTW6nmUP91nwKfhb89hBFcFRV/kR6VkFbEqu84RE/Qb+f Z3wMG8+CNokXVeDAKI6DkMkgHNdShb8wUimvnKxigjyyHKG3OFb52pGyA+VWh4Iux2gB 8sy9WQ7YbxYCOwNWNN27/zXeGVZw99HSBA2mp5jyxNn/LJB0uPAA24+zh7w1jLsGpXSB QKsWwpBdnYMzoEomC5a8IBDfq/kdYB321XO9DRY/n/8YfolwKAw8SC4SFn2R8iwyLGo5 PSXw== 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=2V0SSjUhWRPC5W4OdqGfdKbaaGUGCT0NLhr5UzIi3kQ=; b=iI6tkJEbh49c0OZbULrXHkKhb7X/tBx2X+zocBnJQfx9Kl2kygG5Gy9DN89aPlN4L8 rTJE0mu60BHhCTskGHE0kul/ebK+3AhPB4OU9mF2uoH+fzEVEl3xHpl1Qz1XBM9OBABL d+VVaB/HyUN5vrqaQWBmvZPFtCo5+EnGyZATrBLcpflssmw8ZCr6nUJ0mp0YEgjZp0pd pdHrLJBIJq0jQi5iHyvQKX/xManrIu6r1jSA11aYJBJ/ZXMymTUglZdAMsiAAijsKoED gdB4j9AltleaEEzFzgScdpFhrVFlI5td3S9uIqh+tgKIxJtuKDV9aM9OyL6YE1Hb4h4x dOLw== X-Gm-Message-State: ABuFfohC4eaOfMtU7S+GIt0wToDFBQN+SGhFMm2swjtOIaUmNhDwNwST BVu5BMD3MSbcoxODE+3gK8A= X-Google-Smtp-Source: ACcGV63YiTii26iv8CTGNE+zWkdSWeEpJc2NTAH/PvOKTanhSexqc2OmDQ8I9YpIfVUaG6/8G+cXiA== X-Received: by 2002:a62:7501:: with SMTP id q1-v6mr15164034pfc.225.1539563164629; Sun, 14 Oct 2018 17:26:04 -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 j14-v6sm11387110pgh.52.2018.10.14.17.26.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Oct 2018 17:26:04 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v3 04/18] powerpc/pseries: add of_node_put() in dlpar_detach_node() Date: Sun, 14 Oct 2018 17:24:16 -0700 Message-Id: <1539563070-12969-5-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> References: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-fpga@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Frank Rowand "of: overlay: add missing of_node_get() in __of_attach_node_sysfs" added a missing of_node_get() to __of_attach_node_sysfs(). This results in a refcount imbalance for nodes attached with dlpar_attach_node(). The calling sequence from dlpar_attach_node() to __of_attach_node_sysfs() is: dlpar_attach_node() of_attach_node() __of_attach_node_sysfs() Signed-off-by: Frank Rowand --- arch/powerpc/platforms/pseries/dlpar.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c index a0b20c03f078..e3010b14aea5 100644 --- a/arch/powerpc/platforms/pseries/dlpar.c +++ b/arch/powerpc/platforms/pseries/dlpar.c @@ -272,6 +272,8 @@ int dlpar_detach_node(struct device_node *dn) if (rc) return rc; + of_node_put(dn); + return 0; } From patchwork Mon Oct 15 00:24:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 983833 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YKQc5pWXz9s5b for ; Mon, 15 Oct 2018 11:42:16 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="NqXkJRVo"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42YKQc0kdCzDrDf for ; Mon, 15 Oct 2018 11:42:16 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="NqXkJRVo"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::542; helo=mail-pg1-x542.google.com; envelope-from=frowand.list@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="NqXkJRVo"; dkim-atps=neutral Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42YK3z6M4MzF0QC for ; Mon, 15 Oct 2018 11:26:07 +1100 (AEDT) Received: by mail-pg1-x542.google.com with SMTP id 23-v6so8291779pgc.8 for ; Sun, 14 Oct 2018 17:26:07 -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=snE79BS2V8O8WQJmvjxN5XBTUF3JVF3Wmy1gffetaI8=; b=NqXkJRVotp/1Rjq6KAkZOV2RLEy7tUObWO50dW5O95opeKqjqwRaBdZjkAWRaJP0SG xIwDZy7CwxlbcMA1XW5XUvybEc94bMxQz/nl7Yulvg0E4HbaFG5GDz+RPFujjXwSWkeP wP4YwbpYANaR9Ytquk/FuGZkaJ1d8jUtSnDkPVnu+KIB3VMQjTGKJmjlRkFY3lalo+nC MMZVbG9pDstnpsHNya13I6onBAec+y5yRzMQgJ8IjzQ6b+0aSPyKThpunBVtJUTwLgjN dRjT11dKUfed6aUTcU4bXoA4Y2DPZHu+V7XFtybWpWhDejUURS938jzxJ6jHpxg6OBmj 00DA== 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=snE79BS2V8O8WQJmvjxN5XBTUF3JVF3Wmy1gffetaI8=; b=NFeDa9x0Gda/BKjX2+RD2hURMTGFl2zOHv+PcYQWsPoZlGqb3z/6fu9kr/TVWGFteX 3nh2mm9zdsqKR8vuny/hR559BOsha/hAuIJCAHx5Dz4xm0bjH1sDY1WNNLzjYj5I4iTz LQTqMSaX/zkYcV3dHu+jjmOCKmghBDM7gywhgRGUhXKsnqGMIAjGt984NfKmQv+WnFvW uBu9CmPg+Vk0/B8u19sIUEFR+6NlnfJac772FgbHRlikTwYhd9ELKSV4hcPMF8m2vG89 lVuafwQuUr+B94kQ197X+8zld6NcHYupWdBmqU/R8AE6NMfCSzyVL5bWtcMlJTE0pYGr IRIQ== X-Gm-Message-State: ABuFfogX+brONrGmywprbqeuyPMWIFZ9NsuPeCGPc1apXJjonBDFyRwA scrXX48kZ6EnpiFdZw2Ye4g= X-Google-Smtp-Source: ACcGV61i6cR21o616AD8W0w0L9VsAO/ZrOWOt59sizyp+MYp2pQahD0k67RkENV9KwaTUm0YmPY2Gw== X-Received: by 2002:a63:b4b:: with SMTP id a11-v6mr13269875pgl.97.1539563165881; Sun, 14 Oct 2018 17:26:05 -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 j14-v6sm11387110pgh.52.2018.10.14.17.26.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Oct 2018 17:26:05 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v3 05/18] of: overlay: use prop add changeset entry for property in new nodes Date: Sun, 14 Oct 2018 17:24:17 -0700 Message-Id: <1539563070-12969-6-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> References: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-fpga@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Frank Rowand The changeset entry 'update property' was used for new properties in an overlay instead of 'add property'. The decision of whether to use 'update property' was based on whether the property already exists in the subtree where the node is being spliced into. At the top level of creating a changeset describing the overlay, the target node is in the live devicetree, so checking whether the property exists in the target node returns the correct result. As soon as the changeset creation algorithm recurses into a new node, the target is no longer in the live devicetree, but is instead in the detached overlay tree, thus all properties are incorrectly found to already exist in the target. This fix will expose another devicetree bug that will be fixed in the following patch in the series. When this patch is applied the errors reported by the devictree unittest will change, and the unittest results will change from: ### dt-test ### end of unittest - 210 passed, 0 failed to ### dt-test ### end of unittest - 203 passed, 7 failed Signed-off-by: Frank Rowand --- drivers/of/overlay.c | 112 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 74 insertions(+), 38 deletions(-) diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index 32cfee68f2e3..94740f4ee34c 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -24,6 +24,26 @@ #include "of_private.h" /** + * struct target - info about current target node as recursing through overlay + * @np: node where current level of overlay will be applied + * @in_livetree: @np is a node in the live devicetree + * + * Used in the algorithm to create the portion of a changeset that describes + * an overlay fragment, which is a devicetree subtree. Initially @np is a node + * in the live devicetree where the overlay subtree is targeted to be grafted + * into. When recursing to the next level of the overlay subtree, the target + * also recurses to the next level of the live devicetree, as long as overlay + * subtree node also exists in the live devicetree. When a node in the overlay + * subtree does not exist at the same level in the live devicetree, target->np + * points to a newly allocated node, and all subsequent targets in the subtree + * will be newly allocated nodes. + */ +struct target { + struct device_node *np; + bool in_livetree; +}; + +/** * struct fragment - info about fragment nodes in overlay expanded device tree * @target: target of the overlay operation * @overlay: pointer to the __overlay__ node @@ -72,8 +92,7 @@ static int devicetree_corrupt(void) } static int build_changeset_next_level(struct overlay_changeset *ovcs, - struct device_node *target_node, - const struct device_node *overlay_node); + struct target *target, const struct device_node *overlay_node); /* * of_resolve_phandles() finds the largest phandle in the live tree. @@ -257,14 +276,17 @@ static struct property *dup_and_fixup_symbol_prop( /** * add_changeset_property() - add @overlay_prop to overlay changeset * @ovcs: overlay changeset - * @target_node: where to place @overlay_prop in live tree + * @target: where @overlay_prop will be placed * @overlay_prop: property to add or update, from overlay tree * @is_symbols_prop: 1 if @overlay_prop is from node "/__symbols__" * - * If @overlay_prop does not already exist in @target_node, add changeset entry - * to add @overlay_prop in @target_node, else add changeset entry to update + * If @overlay_prop does not already exist in live devicetree, add changeset + * entry to add @overlay_prop in @target, else add changeset entry to update * value of @overlay_prop. * + * @target may be either in the live devicetree or in a new subtree that + * is contained in the changeset. + * * Some special properties are not updated (no error returned). * * Update of property in symbols node is not allowed. @@ -273,20 +295,22 @@ static struct property *dup_and_fixup_symbol_prop( * invalid @overlay. */ static int add_changeset_property(struct overlay_changeset *ovcs, - struct device_node *target_node, - struct property *overlay_prop, + struct target *target, struct property *overlay_prop, bool is_symbols_prop) { struct property *new_prop = NULL, *prop; int ret = 0; - prop = of_find_property(target_node, overlay_prop->name, NULL); - if (!of_prop_cmp(overlay_prop->name, "name") || !of_prop_cmp(overlay_prop->name, "phandle") || !of_prop_cmp(overlay_prop->name, "linux,phandle")) return 0; + if (target->in_livetree) + prop = of_find_property(target->np, overlay_prop->name, NULL); + else + prop = NULL; + if (is_symbols_prop) { if (prop) return -EINVAL; @@ -299,10 +323,10 @@ static int add_changeset_property(struct overlay_changeset *ovcs, return -ENOMEM; if (!prop) - ret = of_changeset_add_property(&ovcs->cset, target_node, + ret = of_changeset_add_property(&ovcs->cset, target->np, new_prop); else - ret = of_changeset_update_property(&ovcs->cset, target_node, + ret = of_changeset_update_property(&ovcs->cset, target->np, new_prop); if (ret) { @@ -315,14 +339,14 @@ static int add_changeset_property(struct overlay_changeset *ovcs, /** * add_changeset_node() - add @node (and children) to overlay changeset - * @ovcs: overlay changeset - * @target_node: where to place @node in live tree - * @node: node from within overlay device tree fragment + * @ovcs: overlay changeset + * @target: where @node will be placed in live tree or changeset + * @node: node from within overlay device tree fragment * - * If @node does not already exist in @target_node, add changeset entry - * to add @node in @target_node. + * If @node does not already exist in @target, add changeset entry + * to add @node in @target. * - * If @node already exists in @target_node, and the existing node has + * If @node already exists in @target, and the existing node has * a phandle, the overlay node is not allowed to have a phandle. * * If @node has child nodes, add the children recursively via @@ -355,15 +379,16 @@ static int add_changeset_property(struct overlay_changeset *ovcs, * invalid @overlay. */ static int add_changeset_node(struct overlay_changeset *ovcs, - struct device_node *target_node, struct device_node *node) + struct target *target, struct device_node *node) { const char *node_kbasename; struct device_node *tchild; + struct target target_child; int ret = 0; node_kbasename = kbasename(node->full_name); - for_each_child_of_node(target_node, tchild) + for_each_child_of_node(target->np, tchild) if (!of_node_cmp(node_kbasename, kbasename(tchild->full_name))) break; @@ -372,22 +397,28 @@ static int add_changeset_node(struct overlay_changeset *ovcs, if (!tchild) return -ENOMEM; - tchild->parent = target_node; + tchild->parent = target->np; of_node_set_flag(tchild, OF_OVERLAY); ret = of_changeset_attach_node(&ovcs->cset, tchild); if (ret) return ret; - ret = build_changeset_next_level(ovcs, tchild, node); + target_child.np = tchild; + target_child.in_livetree = false; + + ret = build_changeset_next_level(ovcs, &target_child, node); of_node_put(tchild); return ret; } - if (node->phandle && tchild->phandle) + if (node->phandle && tchild->phandle) { ret = -EINVAL; - else - ret = build_changeset_next_level(ovcs, tchild, node); + } else { + target_child.np = tchild; + target_child.in_livetree = target->in_livetree; + ret = build_changeset_next_level(ovcs, &target_child, node); + } of_node_put(tchild); return ret; @@ -396,7 +427,7 @@ static int add_changeset_node(struct overlay_changeset *ovcs, /** * build_changeset_next_level() - add level of overlay changeset * @ovcs: overlay changeset - * @target_node: where to place @overlay_node in live tree + * @target: where to place @overlay_node in live tree * @overlay_node: node from within an overlay device tree fragment * * Add the properties (if any) and nodes (if any) from @overlay_node to the @@ -409,27 +440,26 @@ static int add_changeset_node(struct overlay_changeset *ovcs, * invalid @overlay_node. */ static int build_changeset_next_level(struct overlay_changeset *ovcs, - struct device_node *target_node, - const struct device_node *overlay_node) + struct target *target, const struct device_node *overlay_node) { struct device_node *child; struct property *prop; int ret; for_each_property_of_node(overlay_node, prop) { - ret = add_changeset_property(ovcs, target_node, prop, 0); + ret = add_changeset_property(ovcs, target, prop, 0); if (ret) { pr_debug("Failed to apply prop @%pOF/%s, err=%d\n", - target_node, prop->name, ret); + target->np, prop->name, ret); return ret; } } for_each_child_of_node(overlay_node, child) { - ret = add_changeset_node(ovcs, target_node, child); + ret = add_changeset_node(ovcs, target, child); if (ret) { pr_debug("Failed to apply node @%pOF/%s, err=%d\n", - target_node, child->name, ret); + target->np, child->name, ret); of_node_put(child); return ret; } @@ -442,17 +472,17 @@ static int build_changeset_next_level(struct overlay_changeset *ovcs, * Add the properties from __overlay__ node to the @ovcs->cset changeset. */ static int build_changeset_symbols_node(struct overlay_changeset *ovcs, - struct device_node *target_node, + struct target *target, const struct device_node *overlay_symbols_node) { struct property *prop; int ret; for_each_property_of_node(overlay_symbols_node, prop) { - ret = add_changeset_property(ovcs, target_node, prop, 1); + ret = add_changeset_property(ovcs, target, prop, 1); if (ret) { pr_debug("Failed to apply prop @%pOF/%s, err=%d\n", - target_node, prop->name, ret); + target->np, prop->name, ret); return ret; } } @@ -475,6 +505,7 @@ static int build_changeset_symbols_node(struct overlay_changeset *ovcs, static int build_changeset(struct overlay_changeset *ovcs) { struct fragment *fragment; + struct target target; int fragments_count, i, ret; /* @@ -489,7 +520,9 @@ static int build_changeset(struct overlay_changeset *ovcs) for (i = 0; i < fragments_count; i++) { fragment = &ovcs->fragments[i]; - ret = build_changeset_next_level(ovcs, fragment->target, + target.np = fragment->target; + target.in_livetree = true; + ret = build_changeset_next_level(ovcs, &target, fragment->overlay); if (ret) { pr_debug("apply failed '%pOF'\n", fragment->target); @@ -499,7 +532,10 @@ static int build_changeset(struct overlay_changeset *ovcs) if (ovcs->symbols_fragment) { fragment = &ovcs->fragments[ovcs->count - 1]; - ret = build_changeset_symbols_node(ovcs, fragment->target, + + target.np = fragment->target; + target.in_livetree = true; + ret = build_changeset_symbols_node(ovcs, &target, fragment->overlay); if (ret) { pr_debug("apply failed '%pOF'\n", fragment->target); @@ -517,7 +553,7 @@ static int build_changeset(struct overlay_changeset *ovcs) * 1) "target" property containing the phandle of the target * 2) "target-path" property containing the path of the target */ -static struct device_node *find_target_node(struct device_node *info_node) +static struct device_node *find_target(struct device_node *info_node) { struct device_node *node; const char *path; @@ -623,7 +659,7 @@ static int init_overlay_changeset(struct overlay_changeset *ovcs, fragment = &fragments[cnt]; fragment->overlay = overlay_node; - fragment->target = find_target_node(node); + fragment->target = find_target(node); if (!fragment->target) { of_node_put(fragment->overlay); ret = -EINVAL; From patchwork Mon Oct 15 00:24:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 983834 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YKVH0QqJz9s5b for ; Mon, 15 Oct 2018 11:45:27 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="vddVpi1A"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42YKVG5PG0zDqyH for ; Mon, 15 Oct 2018 11:45:26 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="vddVpi1A"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::542; helo=mail-pg1-x542.google.com; envelope-from=frowand.list@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="vddVpi1A"; dkim-atps=neutral Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42YK4102LMzF0QC for ; Mon, 15 Oct 2018 11:26:08 +1100 (AEDT) Received: by mail-pg1-x542.google.com with SMTP id y18-v6so8314202pge.0 for ; Sun, 14 Oct 2018 17:26:08 -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=Y8f+zX4OUAoqVg/3NA0TrDwr4Zjok9K4JF3715XNZDg=; b=vddVpi1AmJhyFbWAVOaSGOLGGucg2BUuxTM5wvJ2OvyCwJtjgqZm+XdzDCZpavXCyU OHf2twaNg8dWJQzJNbvwF549GEuholfxTpWdf1BO2ooOHKlvRDiBqzabv7gqpNNN9Fca xhtud/n/B/hJ1WGlCuBwNV0m29wxzMCMwqIFprGB+M+MzS/JtMy3M727yeJEgCfJ1v3V OJZRRR2fde/vphpuw+ehqPqGiYuvoensA4vLkD1bA0/xRGvHiaTTkA+0TimUIZWUUdhk 4F4UroT+e6b1mgkKbGgZPNVOqrDT2jsw71tiCh2PulVy29g8I0hTnovjscE6BLugImS2 vfBg== 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=Y8f+zX4OUAoqVg/3NA0TrDwr4Zjok9K4JF3715XNZDg=; b=lveiboTw8Xz7Pw+PIAcqBBC2UNLMfDPvFTOwc8nnwqlGc4dTGvIQUNQgkZ3J2lB0Pt PEwQAeqASzgPDaIkGRJthx9nGl0VGmjjl8AJEgWn+fbmaqu4oNZTifnq0dYKcUOFYHTU gVZceKTVWmbiEM6rkgTmw1MXmT9bCcwnzDSrwOh+Zz2DXD+tsw5VPUh8e0zpUKjzNBA3 V07A09pfkBUzODG9z8PVEZybDcZ7pfaDcwLK7I5q7Zff3fW8HzrKViStlgc2W25ZDtcu XeojGzWronBUt3H0rEolg+J3XxKixOJu4q3NspaxiIHt9KTtvCD4JFZIYM0WznvyKqKm e+2A== X-Gm-Message-State: ABuFfohdDbcOkn5E7+7HpXwfIRbIHcElLp7+RaxVMqZiBVee5NBIu0g9 iYWVmSF+x18U+yELou/BHFo= X-Google-Smtp-Source: ACcGV612kGF23lI/IBRSGRLXD3+AHwU4TUXp3SRw7aP+4Ccv262X6c7pQUwBVf4mxnRI6LNGyoyr3w== X-Received: by 2002:a63:1122:: with SMTP id g34-v6mr13827364pgl.85.1539563167453; Sun, 14 Oct 2018 17:26:07 -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 j14-v6sm11387110pgh.52.2018.10.14.17.26.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Oct 2018 17:26:06 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v3 06/18] of: overlay: do not duplicate properties from overlay for new nodes Date: Sun, 14 Oct 2018 17:24:18 -0700 Message-Id: <1539563070-12969-7-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> References: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-fpga@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Frank Rowand When allocating a new node, add_changeset_node() was duplicating the properties from the respective node in the overlay instead of allocating a node with no properties. When this patch is applied the errors reported by the devictree unittest from patch "of: overlay: add tests to validate kfrees from overlay removal" will no longer occur. These error messages are of the form: "OF: ERROR: ..." and the unittest results will change from: ### dt-test ### end of unittest - 203 passed, 7 failed to ### dt-test ### end of unittest - 210 passed, 0 failed Signed-off-by: Frank Rowand --- drivers/of/overlay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index 94740f4ee34c..7fcf4a812d06 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -393,7 +393,7 @@ static int add_changeset_node(struct overlay_changeset *ovcs, break; if (!tchild) { - tchild = __of_node_dup(node, node_kbasename); + tchild = __of_node_dup(NULL, node_kbasename); if (!tchild) return -ENOMEM; From patchwork Mon Oct 15 00:24:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 983835 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YKZ64gBYz9s5b for ; Mon, 15 Oct 2018 11:48:46 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rOFupecs"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42YKZ637QnzF1Q2 for ; Mon, 15 Oct 2018 11:48:46 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rOFupecs"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::442; helo=mail-pf1-x442.google.com; envelope-from=frowand.list@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rOFupecs"; dkim-atps=neutral Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42YK423RnZzF0Pl for ; Mon, 15 Oct 2018 11:26:10 +1100 (AEDT) Received: by mail-pf1-x442.google.com with SMTP id c25-v6so8763464pfe.6 for ; Sun, 14 Oct 2018 17:26:10 -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=zTyDK37nEPqC274OyD1pd7pErEfzjwmbQUNIOEBPW0Q=; b=rOFupecs8uTq1HCS83YABmAFUtfc2S7NKQjJAy1w3qd2U3tbwJCQQuPzA1AM/ru5Pf dZ3XYWUtScm5BIO6TIBqeAGHwhrbc9cwDbzT6hh/TctWuSxyFmU2GEZfdZBQNehS/B2z KOXq/VR3rALX21JhtNrYFeJlLd2vK+eamqbI0kRq3i+jKrPt1qOGoUJiA7Q7s/2rWT5i umo5ILA41q6XH9WwA8jNuZA8rgERTwaX5h/MwVff9Pq/42iIlcUi9mump6U81kefyJXX esqISCJ62+RZc/TLyYGH7yBSaeUOko8XzsbiDOuwYwGv4WwZ4MOsAUrYF5IykejRVfof v2Tw== 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=zTyDK37nEPqC274OyD1pd7pErEfzjwmbQUNIOEBPW0Q=; b=RGuNKh6wleGfsNL7wajVTBL66RZewRSOe/VcbMkWsHle8tMd3uy3MFm3BvKk8gSCP0 NQXrm9gNdJh1ND3Kmbcy05A4sEl5OGuEvNpAP86GvnSjq+dY6AwYCLBIDENgBx8DBiE9 lIdnBKxiQ+aiCBwAVQcGL9PV180XByMauxTg/yQqD0mZmxfIsGchCGbgP0HeE5eBKC72 nHZox7NxG+nXbr7d0CXqzvStX6FDsBqMqgrU7+kBDNylL00SFMQl653Sk+YTg4Bc2cUW 87cYZqNLuib8vFUnl+Fxx8gTW01rynpZCEg5d0rUNFsd0ITcB/mb25xj2f0380ZTF06j 9QEQ== X-Gm-Message-State: ABuFfoh4DaBSJ5dLz0nGNzNE9m1/uh9CGFEPcfMoDkqIxTdshfODUklN YwCZReyKPvJUgWBIrM3SgC0= X-Google-Smtp-Source: ACcGV60sDBBrCEtzm46WG8j5isz5tHoq5Ljd76Na6Y7S/wv3OKzkIdf0H/6fnCDMq/ihxtGtIHsSCg== X-Received: by 2002:a63:4860:: with SMTP id x32-v6mr13865741pgk.375.1539563168776; Sun, 14 Oct 2018 17:26:08 -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 j14-v6sm11387110pgh.52.2018.10.14.17.26.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Oct 2018 17:26:08 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v3 07/18] of: dynamic: change type of of_{at, de}tach_node() to void Date: Sun, 14 Oct 2018 17:24:19 -0700 Message-Id: <1539563070-12969-8-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> References: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-fpga@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Frank Rowand of_attach_node() and of_detach_node() always return zero, so their return value is meaningless. Change their type to void and fix all callers to ignore return value. Signed-off-by: Frank Rowand --- arch/powerpc/platforms/pseries/dlpar.c | 13 ++----------- arch/powerpc/platforms/pseries/reconfig.c | 6 +----- drivers/of/dynamic.c | 9 ++------- include/linux/of.h | 4 ++-- 4 files changed, 7 insertions(+), 25 deletions(-) diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c index e3010b14aea5..0027eea94a8b 100644 --- a/arch/powerpc/platforms/pseries/dlpar.c +++ b/arch/powerpc/platforms/pseries/dlpar.c @@ -244,15 +244,9 @@ struct device_node *dlpar_configure_connector(__be32 drc_index, int dlpar_attach_node(struct device_node *dn, struct device_node *parent) { - int rc; - dn->parent = parent; - rc = of_attach_node(dn); - if (rc) { - printk(KERN_ERR "Failed to add device node %pOF\n", dn); - return rc; - } + of_attach_node(dn); return 0; } @@ -260,7 +254,6 @@ int dlpar_attach_node(struct device_node *dn, struct device_node *parent) int dlpar_detach_node(struct device_node *dn) { struct device_node *child; - int rc; child = of_get_next_child(dn, NULL); while (child) { @@ -268,9 +261,7 @@ int dlpar_detach_node(struct device_node *dn) child = of_get_next_child(dn, child); } - rc = of_detach_node(dn); - if (rc) - return rc; + of_detach_node(dn); of_node_put(dn); diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c index 0e0208117e77..0b72098da454 100644 --- a/arch/powerpc/platforms/pseries/reconfig.c +++ b/arch/powerpc/platforms/pseries/reconfig.c @@ -47,11 +47,7 @@ static int pSeries_reconfig_add_node(const char *path, struct property *proplist goto out_err; } - err = of_attach_node(np); - if (err) { - printk(KERN_ERR "Failed to add device node %s\n", path); - goto out_err; - } + of_attach_node(np); of_node_put(np->parent); diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index 275c0d7e2268..5f7c99b9de0d 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -224,7 +224,7 @@ static void __of_attach_node(struct device_node *np) /** * of_attach_node() - Plug a device node into the tree and global list. */ -int of_attach_node(struct device_node *np) +void of_attach_node(struct device_node *np) { struct of_reconfig_data rd; unsigned long flags; @@ -241,8 +241,6 @@ int of_attach_node(struct device_node *np) mutex_unlock(&of_mutex); of_reconfig_notify(OF_RECONFIG_ATTACH_NODE, &rd); - - return 0; } void __of_detach_node(struct device_node *np) @@ -273,11 +271,10 @@ void __of_detach_node(struct device_node *np) /** * of_detach_node() - "Unplug" a node from the device tree. */ -int of_detach_node(struct device_node *np) +void of_detach_node(struct device_node *np) { struct of_reconfig_data rd; unsigned long flags; - int rc = 0; memset(&rd, 0, sizeof(rd)); rd.dn = np; @@ -291,8 +288,6 @@ int of_detach_node(struct device_node *np) mutex_unlock(&of_mutex); of_reconfig_notify(OF_RECONFIG_DETACH_NODE, &rd); - - return rc; } EXPORT_SYMBOL_GPL(of_detach_node); diff --git a/include/linux/of.h b/include/linux/of.h index aa1dafaec6ae..72c593455019 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -406,8 +406,8 @@ extern int of_phandle_iterator_args(struct of_phandle_iterator *it, #define OF_RECONFIG_REMOVE_PROPERTY 0x0004 #define OF_RECONFIG_UPDATE_PROPERTY 0x0005 -extern int of_attach_node(struct device_node *); -extern int of_detach_node(struct device_node *); +extern void of_attach_node(struct device_node *np); +extern void of_detach_node(struct device_node *np); #define of_match_ptr(_ptr) (_ptr) From patchwork Mon Oct 15 00:24:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 983836 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YKch71CVz9s5b for ; Mon, 15 Oct 2018 11:51:00 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="iOMyYo7c"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42YKcg5n0gzF0Vv for ; Mon, 15 Oct 2018 11:50:59 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="iOMyYo7c"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::443; helo=mail-pf1-x443.google.com; envelope-from=frowand.list@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="iOMyYo7c"; dkim-atps=neutral Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42YK433WNGzF0QC for ; Mon, 15 Oct 2018 11:26:11 +1100 (AEDT) Received: by mail-pf1-x443.google.com with SMTP id p24-v6so8751181pff.10 for ; Sun, 14 Oct 2018 17:26:11 -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=zdOcjsQSagxh/0ytfqlFE21zp3hEcz2hdT+yMst4gNc=; b=iOMyYo7cQGkHcR4M21tMOuqmXENQrywNbXP/BiYtiQjNER4f7ceGq8FB9+tO5XgKsp PGa1zDu659YIwqT1kEcV1QR6bDtpD2lJY9n0rPCXI9qDi2z2lI+vl08sK/EpKQFF0kYf Ol4SmKQxwNBJCIu0MbhfEnQBcjakp6tlEHBv9Sj1SVc1aQSvlYdXF0enIIC+QJrUwius 6youP2KEfv2hs+JuDsitUvzR7Us5qRBbbrlUcXMj+EgbUHRm6w45y8mFn8I6Y0B5AWDM UEreYywyhJcK8TL0jqKOGl3Fxdt3827T3CEI4wACtyz1mvFLS0u9rPnGm82sVgXImBbc +PGg== 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=zdOcjsQSagxh/0ytfqlFE21zp3hEcz2hdT+yMst4gNc=; b=B5En912awoRwJivfyaNTSn7CmURzzaXXG+XyL36kti1+iVkexl+ebEo7WZqPSOWekD c2DqcN09Wul6yVXgNNWGyGMOFAfrrvE2cA7+DGUHLKOOer87o3NoP9VNH658qABT5W3C 3QziBFAzeWtpS63AB7fUpsaLRFg+Ipy91uPVzX6nwASYlEsRfwH54rHyAWu1OoVZCw66 6f8/IXWZdDpyArK1N99kC1BElEPsLU1OSjD1ogYAVhEQTCi/eO2dXDEGxG2suW8hnD3N SF0P80OEO/Hqkh/LdR1nLF2lx5ttrkXrpNx4b2W2GeXFL1Ty52PcAjZ8vfptVhVZhjyM jQdQ== X-Gm-Message-State: ABuFfoho2bLBQhYOSpe2dFAP1EeAkDZLXFoqK0ZhzjJM2eW1I6PbiIaX uhPesDPVh+mio2dF5wZTQtc= X-Google-Smtp-Source: ACcGV616gXF14EvbCBZbigcydPI5LsDgstZBQWiK9CyU4KDlnfDthsmeNvoELqh5MZIYjt/CKZNGgA== X-Received: by 2002:a63:455e:: with SMTP id u30-v6mr14101901pgk.30.1539563169975; Sun, 14 Oct 2018 17:26:09 -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 j14-v6sm11387110pgh.52.2018.10.14.17.26.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Oct 2018 17:26:09 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v3 08/18] of: overlay: reorder fields in struct fragment Date: Sun, 14 Oct 2018 17:24:20 -0700 Message-Id: <1539563070-12969-9-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> References: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-fpga@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Frank Rowand Order the fields of struct fragment in the same order as struct of_overlay_notify_data. The order in struct fragment is not significant. If both structs are ordered the same then when examining the data in a debugger or dump the human involved does not have to remember which context they are examining. Signed-off-by: Frank Rowand --- drivers/of/overlay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index 7fcf4a812d06..272a0d1a5e18 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -49,8 +49,8 @@ struct target { * @overlay: pointer to the __overlay__ node */ struct fragment { - struct device_node *target; struct device_node *overlay; + struct device_node *target; }; /** From patchwork Mon Oct 15 00:24:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 983837 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YKgM1vn7z9s7W for ; Mon, 15 Oct 2018 11:53:19 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="IbdZSPqR"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42YKgM0MgpzDrYf for ; Mon, 15 Oct 2018 11:53:19 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="IbdZSPqR"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::641; helo=mail-pl1-x641.google.com; envelope-from=frowand.list@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="IbdZSPqR"; dkim-atps=neutral Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42YK450hb8zF0Vv for ; Mon, 15 Oct 2018 11:26:12 +1100 (AEDT) Received: by mail-pl1-x641.google.com with SMTP id y11-v6so8395827plt.3 for ; Sun, 14 Oct 2018 17:26:12 -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=BwKhWXvi9uObifIA2caG7KxBnrbJ0SRY7Oj5Ow4g1sM=; b=IbdZSPqRTU12HVAPHQC4U1kmpBQ/wG7dpte77EPwS66x6e8kFeTncfdzvPTuAGU7J1 JtsvQDXItXJDfO7QBnceRhyyxDm7Y1LxQtK+TQ+MlS+z9Iafk8rDkv44qeORwZE4YwIE AAlKpJpIjxY9kbWSxyZ33822j2MVCqBhTOPsy3+6Xtk0jxO+jXp7uAo8nJHbduiRuM5S eTTsVtkeVoVilYKVoNFrGRPIix+27qVqMyOYbadmOVqVXplefpDodNy0CWfnVoVU6NtB cjXugPeUdfm4jShYIhwELZyBoDSlmWLma0bPKcDnRiNkkGMFaXD2Ge2qV0Vl576JB26p e9uA== 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=BwKhWXvi9uObifIA2caG7KxBnrbJ0SRY7Oj5Ow4g1sM=; b=Ql8pPLrteO/kH4W2rHX/EKhcCCZLy9ZQXxC9n6hvRIOokpa6F4WotT78xHix7lPVJK ZmOVmv5zj9SpQ2ssedKOt8mPyHNCSEaJ0Xs93jkoIckvxob/LHnpAbg2DTLZMrOrhjSf +WJxJscD9eqKmhvFp+CxqfkOo0Q6ePhmSf8tbf67Tgq4gNjnzqdhihP1FROcqAEl6Msy VCk/qOWi1ZLIuJOvd5ij64bRuba6dDxDmyz6R1Xj1Dl8YdVnaQRc5R3ggCU5TAs4y8RA 2TfQ9R2upYZm5lnwcyXGWQZNpiNc7aPPkH08KKAcVx3TzYfY6sNYm44WPrD8S4mKByc/ ktdw== X-Gm-Message-State: ABuFfoi4rdvsfj8IDmYsCuN/cd2woZ3C9Eax0UdGtSdpV7C6/VXAv5DM 3xsX1E5YdpEfvFzXuaoGKjA= X-Google-Smtp-Source: ACcGV62ywluIyp6JpHbWu/PeeqzKheUynLyUIcb7WKzM6BBqBdM2qDzXyzJKjBOd9MjYJYlS0/RJ5Q== X-Received: by 2002:a17:902:1129:: with SMTP id d38-v6mr9609107pla.270.1539563171237; Sun, 14 Oct 2018 17:26:11 -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 j14-v6sm11387110pgh.52.2018.10.14.17.26.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Oct 2018 17:26:10 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v3 09/18] of: overlay: validate overlay properties #address-cells and #size-cells Date: Sun, 14 Oct 2018 17:24:21 -0700 Message-Id: <1539563070-12969-10-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> References: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-fpga@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Frank Rowand If overlay properties #address-cells or #size-cells are already in the live devicetree for any given node, then the values in the overlay must match the values in the live tree. If the properties are already in the live tree then there is no need to create a changeset entry to add them since they must have the same value. This reduces the memory used by the changeset and eliminates a possible memory leak. This is verified by 12 fewer warnings during the devicetree unittest, as the possible memory leak warnings about #address-cells and Signed-off-by: Frank Rowand --- drivers/of/overlay.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index 272a0d1a5e18..ee66651db553 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -287,7 +287,12 @@ static struct property *dup_and_fixup_symbol_prop( * @target may be either in the live devicetree or in a new subtree that * is contained in the changeset. * - * Some special properties are not updated (no error returned). + * Some special properties are not added or updated (no error returned): + * "name", "phandle", "linux,phandle". + * + * Properties "#address-cells" and "#size-cells" are not updated if they + * are already in the live tree, but if present in the live tree, the values + * in the overlay must match the values in the live tree. * * Update of property in symbols node is not allowed. * @@ -300,6 +305,7 @@ static int add_changeset_property(struct overlay_changeset *ovcs, { struct property *new_prop = NULL, *prop; int ret = 0; + bool check_for_non_overlay_node = false; if (!of_prop_cmp(overlay_prop->name, "name") || !of_prop_cmp(overlay_prop->name, "phandle") || @@ -322,13 +328,39 @@ static int add_changeset_property(struct overlay_changeset *ovcs, if (!new_prop) return -ENOMEM; - if (!prop) + if (!prop) { + + check_for_non_overlay_node = true; ret = of_changeset_add_property(&ovcs->cset, target->np, new_prop); - else + + } else if (!of_prop_cmp(prop->name, "#address-cells")) { + + if (prop->length != 4 || new_prop->length != 4 || + *(u32 *)prop->value != *(u32 *)new_prop->value) + pr_err("ERROR: overlay and/or live tree #address-cells invalid in node %pOF\n", + target->np); + + } else if (!of_prop_cmp(prop->name, "#size-cells")) { + + if (prop->length != 4 || new_prop->length != 4 || + *(u32 *)prop->value != *(u32 *)new_prop->value) + pr_err("ERROR: overlay and/or live tree #size-cells invalid in node %pOF\n", + target->np); + + } else { + + check_for_non_overlay_node = true; ret = of_changeset_update_property(&ovcs->cset, target->np, new_prop); + } + + if (check_for_non_overlay_node && + !of_node_check_flag(target->np, OF_OVERLAY)) + pr_err("WARNING: %s(), memory leak will occur if overlay removed. Property: %pOF/%s\n", + __func__, target->np, new_prop->name); + if (ret) { kfree(new_prop->name); kfree(new_prop->value); From patchwork Mon Oct 15 00:24:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 983838 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YKjz3kSKz9s7W for ; Mon, 15 Oct 2018 11:55:35 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CVujcNsM"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42YKjz25sBzF116 for ; Mon, 15 Oct 2018 11:55:35 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CVujcNsM"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::444; helo=mail-pf1-x444.google.com; envelope-from=frowand.list@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CVujcNsM"; dkim-atps=neutral Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42YK45731tzF0wj for ; Mon, 15 Oct 2018 11:26:13 +1100 (AEDT) Received: by mail-pf1-x444.google.com with SMTP id c25-v6so8763519pfe.6 for ; Sun, 14 Oct 2018 17:26:13 -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=7GuCPMc1W5/wwPeXRUqL1/hLo5USFMzrx8T5Pgg4dsU=; b=CVujcNsMF1oqGxEW1W1tfddklDnHVfzOi38qrQ3lUc5o3ttgoO9iNa2L7imWUWNycv 1isqsO/ojbuG70hnPatC/o+JeHQ9U4Y42vKuGZ/LXdFnyjPyfpG+hUS5CiTzxHF+hoFq fz1TZ0y+TGXMANkhae02ElLmKKNKNDVN/LHtq4dg8tfpHUssBD8eULAVbIxoR2yqhRcI AiA4mC8WmDVSt9srxnfHnr7LPjlHeGdHRFErKSiobJs4G84O9Y4PH6TCx2ACPoLK3Tzd aE3olzk7wjLgkkEQqryGLJW8Uhcf48UCEUe7Hp97AHHQUxJE7+qc4ASNOHe8l+aYmH2r i8rg== 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=7GuCPMc1W5/wwPeXRUqL1/hLo5USFMzrx8T5Pgg4dsU=; b=nPF2Xcb2ZO71gstjw14zvptGpkSMqd7y1l/W23dVDHxSoc0/6D/Pm6z+9okofns/lI 5PpHst68RgtP650jAtefEf1ZCobqyoXUOLLAunO1GSFo0CLujirX8//1o5FEKiXV0LhT suFQnE/drJsQCiubBZNliLYHenbnAtqQELVNfJfTGgHDFArlVIxg8RslH2T3clIsyd16 cZ4mb+LOlcg3uOhRgpKykREl9na2RYsjEF+PqNqFyLqy8aDnQXy6odooyFBsCPKyI5lY Qk5vhBEO+k5Jbq31+LusPxvfxY1353Iwlh7tZzLYwO2TPzTm4RVchsJ8KuXJO+53kePd I9Rw== X-Gm-Message-State: ABuFfohJpOoeVah0MMAgFBL50IlN7lx76EkdgJeNVelVBfUfcYbi/4af P9qNMrn0kEWSXOYDCefy/fg= X-Google-Smtp-Source: ACcGV63ssYWjlCFHwaaVc/eCX8YJpLLwgSEzwk0hms7zkMjTKVEzZMXoD/HSgCRvYE9InqS2HNOYng== X-Received: by 2002:a62:7885:: with SMTP id t127-v6mr15196324pfc.259.1539563172417; Sun, 14 Oct 2018 17:26:12 -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 j14-v6sm11387110pgh.52.2018.10.14.17.26.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Oct 2018 17:26:11 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v3 10/18] of: overlay: make all pr_debug() and pr_err() messages unique Date: Sun, 14 Oct 2018 17:24:22 -0700 Message-Id: <1539563070-12969-11-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> References: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-fpga@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Frank Rowand Make overlay.c debug and error messages unique so that they can be unambiguously found by grep. Signed-off-by: Frank Rowand --- drivers/of/overlay.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index ee66651db553..a3990c20e210 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -513,7 +513,7 @@ static int build_changeset_symbols_node(struct overlay_changeset *ovcs, for_each_property_of_node(overlay_symbols_node, prop) { ret = add_changeset_property(ovcs, target, prop, 1); if (ret) { - pr_debug("Failed to apply prop @%pOF/%s, err=%d\n", + pr_debug("Failed to apply symbols prop @%pOF/%s, err=%d\n", target->np, prop->name, ret); return ret; } @@ -557,7 +557,8 @@ static int build_changeset(struct overlay_changeset *ovcs) ret = build_changeset_next_level(ovcs, &target, fragment->overlay); if (ret) { - pr_debug("apply failed '%pOF'\n", fragment->target); + pr_debug("fragment apply failed '%pOF'\n", + fragment->target); return ret; } } @@ -570,7 +571,8 @@ static int build_changeset(struct overlay_changeset *ovcs) ret = build_changeset_symbols_node(ovcs, &target, fragment->overlay); if (ret) { - pr_debug("apply failed '%pOF'\n", fragment->target); + pr_debug("symbols fragment apply failed '%pOF'\n", + fragment->target); return ret; } } @@ -879,7 +881,7 @@ static int of_overlay_apply(const void *fdt, struct device_node *tree, ret = __of_changeset_apply_notify(&ovcs->cset); if (ret) - pr_err("overlay changeset entry notify error %d\n", ret); + pr_err("overlay apply changeset entry notify error %d\n", ret); /* notify failure is not fatal, continue */ list_add_tail(&ovcs->ovcs_list, &ovcs_list); @@ -1138,7 +1140,7 @@ int of_overlay_remove(int *ovcs_id) ret = __of_changeset_revert_notify(&ovcs->cset); if (ret) - pr_err("overlay changeset entry notify error %d\n", ret); + pr_err("overlay remove changeset entry notify error %d\n", ret); /* notify failure is not fatal, continue */ *ovcs_id = 0; From patchwork Mon Oct 15 00:24:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 983839 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YKn60PLZz9s7W for ; Mon, 15 Oct 2018 11:58:18 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="LoFoG0z4"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42YKn55cBmzDrq6 for ; Mon, 15 Oct 2018 11:58:17 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="LoFoG0z4"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::642; helo=mail-pl1-x642.google.com; envelope-from=frowand.list@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="LoFoG0z4"; dkim-atps=neutral Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42YK4749NdzDrqN for ; Mon, 15 Oct 2018 11:26:15 +1100 (AEDT) Received: by mail-pl1-x642.google.com with SMTP id q19-v6so5320050pll.5 for ; Sun, 14 Oct 2018 17:26:15 -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=LoFoG0z4djWfCNWrmlTfkOJ8gI3cf0TUCAFw5Ul6YGRCTrmapvDPGir/nsVK0/68+o vdipEEeCp9Yh83lLDvN0ccG+nu7bk3zBjY5ZxOyDhsOUN57h6HAJ20dtfmoRP1LjqeKz wQJdgi4L6aF57vqe/JG0FnaZYt4C7gXR6B4S17D/MVIZl7g4PcywhZwx9NmnlWwoRyJT pHh7bgr1txoXhPrgehFjL78ihE1LraMbOg7XLbTJ93LZGRFe2jSJqUxNnnbZDqAUmHS7 e0X3JHMd5V6uEaWh5XXWk+kDSzxcey7doBAAkwmrZarDZI5JfwS72DyQ+8CPqS0G0NB/ 6F3A== 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=cSUMVa83qeg3Mwf/YziEIbrBzvnyRL9/wSIV4ziafk/8gr1BkKJaVgNYaHnvIabCzY 01z54XiWWENb6D1vTZFD9eitjM/uj2ukjoGdlq1U8zDVf3alqyFsZe1Zx0mvPKMXeIA4 wbPjzQ1EAPyf9oFsNToElvazIhD1OYDaO++XqQl7JlTovE8eHhpos8uiFHZMbPEbB9SA ByaxKbh2QWwjuNZnPPxupdKARlj+F6sfUk6xmcgEJBFR0RXTsYA1SXgWVIW2n2bazcrI pcqOca0dZK5bx/lmPrICZ5qmne/W5ON/EKO9ppmjoSfKWJjBB6bteTQMx0aPLiAu+Og6 fbHA== X-Gm-Message-State: ABuFfohZB7vCUASjc8DvOu0IRS//C2tus2Nrs8yaqg34zME2KesJI0rV mtjvIYPSnkndkV1DjFwE0z8= X-Google-Smtp-Source: ACcGV618xE1lA4L3Mkze3dqIWBO1N64nQOACIO4CENbAMUAOYN+yUSXwAlElTjtEzf+S9SOmQzgvRg== X-Received: by 2002:a17:902:70c3:: with SMTP id l3-v6mr15376728plt.125.1539563173692; Sun, 14 Oct 2018 17:26:13 -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 j14-v6sm11387110pgh.52.2018.10.14.17.26.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Oct 2018 17:26:13 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v3 11/18] of: overlay: test case of two fragments adding same node Date: Sun, 14 Oct 2018 17:24:23 -0700 Message-Id: <1539563070-12969-12-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> References: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-fpga@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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"); From patchwork Mon Oct 15 00:24:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 983840 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YKrT6vW0z9s7W for ; Mon, 15 Oct 2018 12:01:13 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="TAVh63kY"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42YKrT50Q0zF0PM for ; Mon, 15 Oct 2018 12:01:13 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="TAVh63kY"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::641; helo=mail-pl1-x641.google.com; envelope-from=frowand.list@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="TAVh63kY"; dkim-atps=neutral Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42YK492qGWzDrq8 for ; Mon, 15 Oct 2018 11:26:17 +1100 (AEDT) Received: by mail-pl1-x641.google.com with SMTP id 1-v6so8396594plv.7 for ; Sun, 14 Oct 2018 17:26:17 -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=GLwPvaFYCJWZOyI89dqGxvTQx+54pbaTdFZFvSr2/M0=; b=TAVh63kY9xXRmT+EiDuTEiTz8d+ieMTayJqJiXk53CojmotSIDGIgzumO+/+CU8gyu l2e2aGXeMJMTmJQwmRwQh3Z6lMyJhQiATjvGr8xGly4guj3aylP4WPw782SNJjqmvP6I 7VukfvzGe6CEMuBFOtJ4Cj3Rfp8gtXnj+xgsJ90PccTpDRafRAb3FpjN4DdgLFQcBXfL R/A0P2PmVRR+ZBsd5S8BJhPH0UVV2wFnI5XCrg8v6zRaXiPtctqnYAeSd0hddxWbBC/I /E8HsYAILQvwAKEDurN0NXhBeD78S+XDuT095XyWzxZMRPp1faiycZMUBv6y/D45RBw9 /nHQ== 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=GLwPvaFYCJWZOyI89dqGxvTQx+54pbaTdFZFvSr2/M0=; b=bN+SQn1X8R+lCe56m+fsCYhyEaFy91wcgZww5B4Dega8mM03y++TibI+dX1wxk2HMg FsCA6hhFArAmCs9tTpSPYRNZ0oHgvL8zVmkJuAnn4D0bQTiMf2qqQnLjaJFDRLgVlYwK GiX0cEKH+XhM0sjpQNbM6jV701ar3rXLQ7lVUkB2M8ac3BsaKk+WsOSInOwOk/27PCYQ hp+tanu7uC8Z0NwVppGB+5FX65NSJvsVCxhzMAAkB1ckYv1R4Eq41imR/52twB+RpX9u OMWLHJ50PRqTdUS/aAlvMxmEAyLh543nR+5G1h3xj8oWuOQ9wVfXe4LToiTU+NH3DyP+ XgZg== X-Gm-Message-State: ABuFfog7Tmorsvc1xVvqaQnjCysYOKFpFSQoTf7FAhzOhKhWPiN0WlOn NIEKIu1n/UknZxCLayGVO7M= X-Google-Smtp-Source: ACcGV637ZvZNTt1REpw2C6XXXc8Cd5uPerW9fBMgrL4jj+R6tCd0H+l6bcJeoyOVpxy6KvXX8fjQaQ== X-Received: by 2002:a17:902:d908:: with SMTP id c8-v6mr14633141plz.227.1539563175157; Sun, 14 Oct 2018 17:26:15 -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 j14-v6sm11387110pgh.52.2018.10.14.17.26.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Oct 2018 17:26:14 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v3 12/18] of: overlay: check prevents multiple fragments add or delete same node Date: Sun, 14 Oct 2018 17:24:24 -0700 Message-Id: <1539563070-12969-13-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> References: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-fpga@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Frank Rowand Multiple overlay fragments adding or deleting the same node is not supported. Replace code comment of such, with check to detect the attempt and fail the overlay apply. Devicetree unittest where multiple fragments added the same node was added in the previous patch in the series. After applying this patch the unittest messages will no longer include: 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 but will instead include: OF: overlay: ERROR: multiple overlay fragments add and/or delete node /testcase-data-2/substation@100/motor-1/controller ... ### dt-test ### end of unittest - 211 passed, 0 failed Signed-off-by: Frank Rowand --- checkpatch errors "line over 80 characters" and "Too many leading tabs" are ok, they will be fixed later in this series drivers/of/overlay.c | 58 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index a3990c20e210..b0a0dafb6a13 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -398,14 +398,6 @@ static int add_changeset_property(struct overlay_changeset *ovcs, * a live devicetree created from Open Firmware. * * NOTE_2: Multiple mods of created nodes not supported. - * If more than one fragment contains a node that does not already exist - * in the live tree, then for each fragment of_changeset_attach_node() - * will add a changeset entry to add the node. When the changeset is - * applied, __of_attach_node() will attach the node twice (once for - * each fragment). At this point the device tree will be corrupted. - * - * TODO: add integrity check to ensure that multiple fragments do not - * create the same node. * * Returns 0 on success, -ENOMEM if memory allocation failure, or -EINVAL if * invalid @overlay. @@ -523,6 +515,54 @@ static int build_changeset_symbols_node(struct overlay_changeset *ovcs, } /** + * check_changeset_dup_add_node() - changeset validation: duplicate add node + * @ovcs: Overlay changeset + * + * Check changeset @ovcs->cset for multiple add node entries for the same + * node. + * + * Returns 0 on success, -ENOMEM if memory allocation failure, or -EINVAL if + * invalid overlay in @ovcs->fragments[]. + */ +static int check_changeset_dup_add_node(struct overlay_changeset *ovcs) +{ + struct of_changeset_entry *ce_1, *ce_2; + char *fn_1, *fn_2; + int name_match; + + list_for_each_entry(ce_1, &ovcs->cset.entries, node) { + + if (ce_1->action == OF_RECONFIG_ATTACH_NODE || + ce_1->action == OF_RECONFIG_DETACH_NODE) { + + ce_2 = ce_1; + list_for_each_entry_continue(ce_2, &ovcs->cset.entries, node) { + if (ce_2->action == OF_RECONFIG_ATTACH_NODE || + ce_2->action == OF_RECONFIG_DETACH_NODE) { + /* inexpensive name compare */ + if (!of_node_cmp(ce_1->np->full_name, + ce_2->np->full_name)) { + /* expensive full path name compare */ + fn_1 = kasprintf(GFP_KERNEL, "%pOF", ce_1->np); + fn_2 = kasprintf(GFP_KERNEL, "%pOF", ce_2->np); + name_match = !strcmp(fn_1, fn_2); + kfree(fn_1); + kfree(fn_2); + if (name_match) { + pr_err("ERROR: multiple overlay fragments add and/or delete node %pOF\n", + ce_1->np); + return -EINVAL; + } + } + } + } + } + } + + return 0; +} + +/** * build_changeset() - populate overlay changeset in @ovcs from @ovcs->fragments * @ovcs: Overlay changeset * @@ -577,7 +617,7 @@ static int build_changeset(struct overlay_changeset *ovcs) } } - return 0; + return check_changeset_dup_add_node(ovcs); } /* From patchwork Mon Oct 15 00:24:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 983841 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YKvr4Q74z9s7h for ; Mon, 15 Oct 2018 12:04:08 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="koc+J4MD"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42YKvr2ChxzDqf9 for ; Mon, 15 Oct 2018 12:04:08 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="koc+J4MD"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::442; helo=mail-pf1-x442.google.com; envelope-from=frowand.list@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="koc+J4MD"; dkim-atps=neutral Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42YK4B0FYgzF0Vv for ; Mon, 15 Oct 2018 11:26:18 +1100 (AEDT) Received: by mail-pf1-x442.google.com with SMTP id 78-v6so6382433pfq.0 for ; Sun, 14 Oct 2018 17:26:17 -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=wiP1rYr32Lf/QXaWyA9yA91bv6hFIJaCasE1H+3zy38=; b=koc+J4MDojZpcz36xvOSkjoqfevRszDz3UqfQY+rfB37qfKorTU9rO4a0pWj4I5KTc 0UYqguaolPopPFCFbLg9bP0MJOXwLkW7aPjTg7aZsbEHFLY/LR5a9Iv88JLEAhvp22YA cqv98ZiU2WrRmGxx5nmP3RSBt050epgcevrsltleuS9+X6s07r3dNbMF73RU90cTfToG S5FL3aFnbyjCZ3G2PL0cqm2yh39B8AqoKVOFHTnOtHQjSuHmPqDkYSUvze4KHdJEZY6j GU6X88P/OVxdkVNz2xi98McNgCeL+cI10zrZ7DbPHGr8cYjRivF/OYwFWofJ0/WC+V0u dV3g== 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=wiP1rYr32Lf/QXaWyA9yA91bv6hFIJaCasE1H+3zy38=; b=Sq9GQGUZZ9OCluGrGa4gDukLEVzQmfPS1SDVrw7gDT1gt2Owpc4opzaL63axJBuNBC lsDJL7E1iHWQa2dGd8QQqwqOAklAUyBxcbzsXiLfT5USBKOs13WZxwTInwF9ieehrUTd /f4LV6nAPozqXqlGHqAseiJ7jlOmhtqIphmOEQumSYF9jAtdVgD3lfUNPk65Pq5nT3O4 QtB7y/oRt/gVuHnyxRU9YNXaN0CRawsV8LliGUKpGdZv4rj9nW76khRJuc0v9TH2XNs7 PHSE1yWHd3kukMEcGrorpIqNc3Ng65+vcEEgl9AdXliqWhSaIKQV0cvwTOB40dPoxti9 78cg== X-Gm-Message-State: ABuFfogu2OqiviGFQOZggkk8yDuostR/9nLuF/bPYCk5wOU00JSpiSMM MHYJLr1Viht/J/Rt9dEaru8= X-Google-Smtp-Source: ACcGV63kvseQYHhjyZLy3eAW/eJY77Hbvyfxp/HTbLvY4vVI5zr3xecqwY00JcTXJfwg+ikKq8o2Aw== X-Received: by 2002:a63:b08:: with SMTP id 8-v6mr13870320pgl.130.1539563176346; Sun, 14 Oct 2018 17:26:16 -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 j14-v6sm11387110pgh.52.2018.10.14.17.26.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Oct 2018 17:26:15 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v3 13/18] of: overlay: check prevents multiple fragments touching same property Date: Sun, 14 Oct 2018 17:24:25 -0700 Message-Id: <1539563070-12969-14-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> References: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-fpga@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Frank Rowand Add test case of two fragments updating the same property. After adding the test case, the system hangs at end of boot, after after slub stack dumps from kfree() in crypto modprobe code. Multiple overlay fragments adding, modifying, or deleting the same property is not supported. Add check to detect the attempt and fail the overlay apply. After applying this patch, the devicetree unittest messages will include: OF: overlay: ERROR: multiple overlay fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/rpm_avail ... ### dt-test ### end of unittest - 212 passed, 0 failed The check to detect two fragments updating the same property is folded into the patch that created the test case to maintain bisectability. Signed-off-by: Frank Rowand --- Changes since v2: - Use continue to reduce indentation in find_dup_cset_node_entry() and find_dup_cset_prop() drivers/of/overlay.c | 118 ++++++++++++++------- drivers/of/unittest-data/Makefile | 1 + .../of/unittest-data/overlay_bad_add_dup_prop.dts | 24 +++++ drivers/of/unittest-data/overlay_base.dts | 1 + drivers/of/unittest.c | 5 + 5 files changed, 112 insertions(+), 37 deletions(-) create mode 100644 drivers/of/unittest-data/overlay_bad_add_dup_prop.dts diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index b0a0dafb6a13..908bcc62019b 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -514,52 +514,96 @@ static int build_changeset_symbols_node(struct overlay_changeset *ovcs, return 0; } +static int find_dup_cset_node_entry(struct overlay_changeset *ovcs, + struct of_changeset_entry *ce_1) +{ + struct of_changeset_entry *ce_2; + char *fn_1, *fn_2; + int node_path_match; + + if (ce_1->action != OF_RECONFIG_ATTACH_NODE && + ce_1->action != OF_RECONFIG_DETACH_NODE) + return 0; + + ce_2 = ce_1; + list_for_each_entry_continue(ce_2, &ovcs->cset.entries, node) { + if ((ce_2->action != OF_RECONFIG_ATTACH_NODE && + ce_2->action != OF_RECONFIG_DETACH_NODE) || + of_node_cmp(ce_1->np->full_name, ce_2->np->full_name)) + continue; + + fn_1 = kasprintf(GFP_KERNEL, "%pOF", ce_1->np); + fn_2 = kasprintf(GFP_KERNEL, "%pOF", ce_2->np); + node_path_match = !strcmp(fn_1, fn_2); + kfree(fn_1); + kfree(fn_2); + if (node_path_match) { + pr_err("ERROR: multiple overlay fragments add and/or delete node %pOF\n", + ce_1->np); + return -EINVAL; + } + } + + return 0; +} + +static int find_dup_cset_prop(struct overlay_changeset *ovcs, + struct of_changeset_entry *ce_1) +{ + struct of_changeset_entry *ce_2; + char *fn_1, *fn_2; + int node_path_match; + + if (ce_1->action != OF_RECONFIG_ADD_PROPERTY && + ce_1->action != OF_RECONFIG_REMOVE_PROPERTY && + ce_1->action != OF_RECONFIG_UPDATE_PROPERTY) + return 0; + + ce_2 = ce_1; + list_for_each_entry_continue(ce_2, &ovcs->cset.entries, node) { + if ((ce_2->action != OF_RECONFIG_ADD_PROPERTY && + ce_2->action != OF_RECONFIG_REMOVE_PROPERTY && + ce_2->action != OF_RECONFIG_UPDATE_PROPERTY) || + of_node_cmp(ce_1->np->full_name, ce_2->np->full_name)) + continue; + + fn_1 = kasprintf(GFP_KERNEL, "%pOF", ce_1->np); + fn_2 = kasprintf(GFP_KERNEL, "%pOF", ce_2->np); + node_path_match = !strcmp(fn_1, fn_2); + kfree(fn_1); + kfree(fn_2); + if (node_path_match && + !of_prop_cmp(ce_1->prop->name, ce_2->prop->name)) { + pr_err("ERROR: multiple overlay fragments add, update, and/or delete property %pOF/%s\n", + ce_1->np, ce_1->prop->name); + return -EINVAL; + } + } + + return 0; +} + /** - * check_changeset_dup_add_node() - changeset validation: duplicate add node + * changeset_dup_entry_check() - check for duplicate entries * @ovcs: Overlay changeset * - * Check changeset @ovcs->cset for multiple add node entries for the same - * node. + * Check changeset @ovcs->cset for multiple {add or delete} node entries for + * the same node or duplicate {add, delete, or update} properties entries + * for the same property. * - * Returns 0 on success, -ENOMEM if memory allocation failure, or -EINVAL if - * invalid overlay in @ovcs->fragments[]. + * Returns 0 on success, or -EINVAL if duplicate changeset entry found. */ -static int check_changeset_dup_add_node(struct overlay_changeset *ovcs) +static int changeset_dup_entry_check(struct overlay_changeset *ovcs) { - struct of_changeset_entry *ce_1, *ce_2; - char *fn_1, *fn_2; - int name_match; + struct of_changeset_entry *ce_1; + int dup_entry = 0; list_for_each_entry(ce_1, &ovcs->cset.entries, node) { - - if (ce_1->action == OF_RECONFIG_ATTACH_NODE || - ce_1->action == OF_RECONFIG_DETACH_NODE) { - - ce_2 = ce_1; - list_for_each_entry_continue(ce_2, &ovcs->cset.entries, node) { - if (ce_2->action == OF_RECONFIG_ATTACH_NODE || - ce_2->action == OF_RECONFIG_DETACH_NODE) { - /* inexpensive name compare */ - if (!of_node_cmp(ce_1->np->full_name, - ce_2->np->full_name)) { - /* expensive full path name compare */ - fn_1 = kasprintf(GFP_KERNEL, "%pOF", ce_1->np); - fn_2 = kasprintf(GFP_KERNEL, "%pOF", ce_2->np); - name_match = !strcmp(fn_1, fn_2); - kfree(fn_1); - kfree(fn_2); - if (name_match) { - pr_err("ERROR: multiple overlay fragments add and/or delete node %pOF\n", - ce_1->np); - return -EINVAL; - } - } - } - } - } + dup_entry |= find_dup_cset_node_entry(ovcs, ce_1); + dup_entry |= find_dup_cset_prop(ovcs, ce_1); } - return 0; + return dup_entry ? -EINVAL : 0; } /** @@ -617,7 +661,7 @@ static int build_changeset(struct overlay_changeset *ovcs) } } - return check_changeset_dup_add_node(ovcs); + return changeset_dup_entry_check(ovcs); } /* diff --git a/drivers/of/unittest-data/Makefile b/drivers/of/unittest-data/Makefile index 166dbdbfd1c5..9b6807065827 100644 --- a/drivers/of/unittest-data/Makefile +++ b/drivers/of/unittest-data/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_OF_OVERLAY) += overlay.dtb.o \ overlay_13.dtb.o \ overlay_15.dtb.o \ overlay_bad_add_dup_node.dtb.o \ + overlay_bad_add_dup_prop.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_prop.dts b/drivers/of/unittest-data/overlay_bad_add_dup_prop.dts new file mode 100644 index 000000000000..c190da54f175 --- /dev/null +++ b/drivers/of/unittest-data/overlay_bad_add_dup_prop.dts @@ -0,0 +1,24 @@ +// 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 property "rpm_avail" in each fragment will + * result in an attempt to update the same property twice. + * This will result in an error and the overlay apply + * will fail. + */ + +&electric_1 { + + motor-1 { + rpm_avail = < 100 >; + }; +}; + +&spin_ctrl_1 { + rpm_avail = < 100 200 >; +}; diff --git a/drivers/of/unittest-data/overlay_base.dts b/drivers/of/unittest-data/overlay_base.dts index 820b79ca378a..99ab9d12d00b 100644 --- a/drivers/of/unittest-data/overlay_base.dts +++ b/drivers/of/unittest-data/overlay_base.dts @@ -30,6 +30,7 @@ spin_ctrl_1: motor-1 { compatible = "ot,ferris-wheel-motor"; spin = "clockwise"; + rpm_avail = < 50 >; }; spin_ctrl_2: motor-8 { diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 471b8eb6e842..efd9c947f192 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -2148,6 +2148,7 @@ struct overlay_info { OVERLAY_INFO_EXTERN(overlay_13); OVERLAY_INFO_EXTERN(overlay_15); OVERLAY_INFO_EXTERN(overlay_bad_add_dup_node); +OVERLAY_INFO_EXTERN(overlay_bad_add_dup_prop); OVERLAY_INFO_EXTERN(overlay_bad_phandle); OVERLAY_INFO_EXTERN(overlay_bad_symbol); @@ -2171,6 +2172,7 @@ struct overlay_info { OVERLAY_INFO(overlay_13, 0), OVERLAY_INFO(overlay_15, 0), OVERLAY_INFO(overlay_bad_add_dup_node, -EINVAL), + OVERLAY_INFO(overlay_bad_add_dup_prop, -EINVAL), OVERLAY_INFO(overlay_bad_phandle, -EINVAL), OVERLAY_INFO(overlay_bad_symbol, -EINVAL), {} @@ -2418,6 +2420,9 @@ static __init void of_unittest_overlay_high_level(void) 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_add_dup_prop", NULL), + "Adding overlay 'overlay_bad_add_dup_prop' failed\n"); + unittest(overlay_data_apply("overlay_bad_phandle", NULL), "Adding overlay 'overlay_bad_phandle' failed\n"); From patchwork Mon Oct 15 00:24:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 983842 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YKzZ5zJ1z9s7W for ; Mon, 15 Oct 2018 12:07:22 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FoSppvLU"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42YKzZ42wMzF2Pp for ; Mon, 15 Oct 2018 12:07:22 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FoSppvLU"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::443; helo=mail-pf1-x443.google.com; envelope-from=frowand.list@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FoSppvLU"; dkim-atps=neutral Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42YK4C0YQMzDrq8 for ; Mon, 15 Oct 2018 11:26:19 +1100 (AEDT) Received: by mail-pf1-x443.google.com with SMTP id j23-v6so8758984pfi.4 for ; Sun, 14 Oct 2018 17:26: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=PMEoU3Gz26JMyroIsJaDweM2uFKnZxU+TruAPOzAvDQ=; b=FoSppvLUNXKwT2xa/fbQw7RLd1Q/dfkrbveBbCpBA/i034kCFgJHV06NKyQIJv7VNo Jj9/VMVgt2aesbhYwPrzfr7e4cF2QT0I0j2AtCuoaSgLnAGq/NJoaqZ5wXg0XRZ4iKro sqbiQ52A2j11jcMMaYK593iSmBisDlHgNjKabMECdwD+VUsTmAG8CUNnCxDj5NfQZjoM guQ2u3I5hSh1eUhkanjBJ3uVByBvHLLtbkBAzCTaTfhURzJ9V2BXY8mbTaPq34dvK+gj zL0EpmCo7LR4D359gOqlWjIby1UMJNW+K4AZzob//b2I9FWlUIk5VfeT/n7mTxqUV6bV orug== 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=PMEoU3Gz26JMyroIsJaDweM2uFKnZxU+TruAPOzAvDQ=; b=RWLBcm9yDrIzPzT6+2X1KI9w2lvVf5KnViGLG7+DkiwbkcOVp2c5jvVdu9vCiiyuHk wsbiW5SmUdfL8j2Jqm/vOYB+JQOy1eBjjPNPVYnCK3B24Pjo8McCsyXeI+O4n+slXXmj TOrwO88PF4MHXmyblCC5mK+2hDrd2H4CQT+P6qRdBq4WlrJTi/r9na1fCVd7IDhBOgX1 uMINoWeY4QJ+x2cY2u4CE9PKcBD7b/HyWd30a5rDZhJSlSfG23wXERqhqRKcfQPX6EMY FO378dCRqCtFwlyUoDURC2Nfo5DK7DYqcyhOxRLvjiBLJigC8NSOHl7pFahL2jurvrnp M4gA== X-Gm-Message-State: ABuFfogdqmJ5yaR9xu/63Bh3ezXleY06vyO4BUk8TXdFVegUw1IJaPav qpruloFgbT+aJc3vDKYwmAU= X-Google-Smtp-Source: ACcGV61mcTj1VHj1Xm2Jp29axakqI/Ib5fkIEivegpv+3y4RdMrCOAZHVnbgSyEAufJoAyLnEzrWyQ== X-Received: by 2002:a63:2066:: with SMTP id r38-v6mr13951559pgm.289.1539563177544; Sun, 14 Oct 2018 17:26:17 -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 j14-v6sm11387110pgh.52.2018.10.14.17.26.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Oct 2018 17:26:17 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v3 14/18] of: unittest: remove unused of_unittest_apply_overlay() argument Date: Sun, 14 Oct 2018 17:24:26 -0700 Message-Id: <1539563070-12969-15-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> References: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-fpga@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Frank Rowand Argument unittest_nr is not used in of_unittest_apply_overlay(), remove it. Signed-off-by: Frank Rowand --- drivers/of/unittest.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index efd9c947f192..6d80f474c8f2 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -1419,8 +1419,7 @@ static void of_unittest_destroy_tracked_overlays(void) } while (defers > 0); } -static int __init of_unittest_apply_overlay(int overlay_nr, int unittest_nr, - int *overlay_id) +static int __init of_unittest_apply_overlay(int overlay_nr, int *overlay_id) { const char *overlay_name; @@ -1453,7 +1452,7 @@ static int __init of_unittest_apply_overlay_check(int overlay_nr, } ovcs_id = 0; - ret = of_unittest_apply_overlay(overlay_nr, unittest_nr, &ovcs_id); + ret = of_unittest_apply_overlay(overlay_nr, &ovcs_id); if (ret != 0) { /* of_unittest_apply_overlay already called unittest() */ return ret; @@ -1489,7 +1488,7 @@ static int __init of_unittest_apply_revert_overlay_check(int overlay_nr, /* apply the overlay */ ovcs_id = 0; - ret = of_unittest_apply_overlay(overlay_nr, unittest_nr, &ovcs_id); + ret = of_unittest_apply_overlay(overlay_nr, &ovcs_id); if (ret != 0) { /* of_unittest_apply_overlay already called unittest() */ return ret; From patchwork Mon Oct 15 00:24:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 983843 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YL2x0MG5z9s7W for ; Mon, 15 Oct 2018 12:10:17 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Bh5+o4A0"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42YL2w5S79zF310 for ; Mon, 15 Oct 2018 12:10:16 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Bh5+o4A0"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::644; helo=mail-pl1-x644.google.com; envelope-from=frowand.list@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Bh5+o4A0"; dkim-atps=neutral Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42YK4D21cPzDrqN for ; Mon, 15 Oct 2018 11:26:20 +1100 (AEDT) Received: by mail-pl1-x644.google.com with SMTP id f18-v6so8407160plr.1 for ; Sun, 14 Oct 2018 17:26:20 -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=lcuTd93Zs0lVeU8vKhWhv5GEua+bMb9Vyzo19XuwRmc=; b=Bh5+o4A0M2N6QlVmdomIjWhFrf4xvr1abWLG9NqdVLB+bcy3AGcqSRkPGCzn3wYY8s YtrjktZUaz3bFyJ5EdvmqqSTA/TOp5SXaQgEs+SYh432/4j9sAzcMDoeQxgMmmy6e7vG hJivODcbGojVwlm/x3puKgANs5bB0KO7x38C8+NlPRvJjUdKCNssiEL67egRZJ7rN0l4 JCCMqHpGmaiDkKA+/L4GVpLbDQ8y2pmK/ScEiWklxud0Mt8dqEwb2+zXF9WC+Ne9CQe0 gdN7+8B07io3RvzaWnpkK0p5iYXxmhXtHLZ1UQX/6p+V/jNl+hUThrSR0Fiikasmxpl3 bABA== 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=lcuTd93Zs0lVeU8vKhWhv5GEua+bMb9Vyzo19XuwRmc=; b=tq0MMikZ9s31mxyUMDMTKFHmdZ+gQZXbcPP7Zn+QVCws3qMWt2HmvTjTlLpjfZAPk2 aiy8SieyYFDO7H1cGU3ylsHn5xtjZ35CehaTDTlXkBqKsIUq++bkTCJ1PbxcbkJ1LPOP unkMphSPnqZFpyXT/+XHKiAdq8NqEAjgK+PSPkShmYIzKfT5yKN3A0s3zm047KZ5/ZRR SvkHJ3Pg30IriDtlXyFBUlCk/MpeKacCeouHeEQIKbIz2S/yIvxYHvQBKqdF4y+4Sf08 KHv1lLnK3QgpuVsCrnY35gr2kFWayspo/+Bd06seBMgW+Y+88ftaRrIL3yyqmJWEHnTf 6h5g== X-Gm-Message-State: ABuFfojUn5VOvzSG3Eafjt8lQxyjGukNBqXvlY4yveDEcEVjESB8imrk izdKCmlbbWlP3VnWz0VdNgo= X-Google-Smtp-Source: ACcGV63xgSMZmmfakM1xgmwWpxXa2OCrH10UuSWo8uVM11CtijeadZtv2y99CZR1xD+Gk91tNXiRLw== X-Received: by 2002:a17:902:6848:: with SMTP id f8-v6mr15031222pln.27.1539563178699; Sun, 14 Oct 2018 17:26: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 j14-v6sm11387110pgh.52.2018.10.14.17.26.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Oct 2018 17:26:18 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v3 15/18] of: overlay: set node fields from properties when add new overlay node Date: Sun, 14 Oct 2018 17:24:27 -0700 Message-Id: <1539563070-12969-16-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> References: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-fpga@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Frank Rowand Overlay nodes added by add_changeset_node() do not have the node fields name, phandle, and type set. The node passed to __of_attach_node() when the add node changeset entry is processed does not contain any properties. The node's properties are located in add property changeset entries that will be processed after the add node changeset is applied. Set the node's fields in the node contained in the add node changeset entry and do not set them to incorrect values in add_changeset_node(). A visible symptom that is fixed by this patch is the names of nodes added by overlays that have an entry in /sys/bus/platform/drivers/*/ will contain the unit-address but the node-name will be , for example, "fc4ab000.". After applying the patch the name, in this example, for node restart@fc4ab000 is "fc4ab000.restart". Signed-off-by: Frank Rowand --- drivers/of/dynamic.c | 27 ++++++++++++++++++--------- drivers/of/overlay.c | 29 ++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index 5f7c99b9de0d..5b740114dbdc 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -205,15 +205,24 @@ static void __of_attach_node(struct device_node *np) const __be32 *phandle; int sz; - np->name = __of_get_property(np, "name", NULL) ? : ""; - np->type = __of_get_property(np, "device_type", NULL) ? : ""; - - phandle = __of_get_property(np, "phandle", &sz); - if (!phandle) - phandle = __of_get_property(np, "linux,phandle", &sz); - if (IS_ENABLED(CONFIG_PPC_PSERIES) && !phandle) - phandle = __of_get_property(np, "ibm,phandle", &sz); - np->phandle = (phandle && (sz >= 4)) ? be32_to_cpup(phandle) : 0; + if (!of_node_check_flag(np, OF_OVERLAY)) { + np->name = __of_get_property(np, "name", NULL); + np->type = __of_get_property(np, "device_type", NULL); + if (!np->name) + np->name = ""; + if (!np->type) + np->type = ""; + + phandle = __of_get_property(np, "phandle", &sz); + if (!phandle) + phandle = __of_get_property(np, "linux,phandle", &sz); + if (IS_ENABLED(CONFIG_PPC_PSERIES) && !phandle) + phandle = __of_get_property(np, "ibm,phandle", &sz); + if (phandle && (sz >= 4)) + np->phandle = be32_to_cpup(phandle); + else + np->phandle = 0; + } np->child = NULL; np->sibling = np->parent->child; diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index 908bcc62019b..f5c3330567b6 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -307,10 +307,11 @@ static int add_changeset_property(struct overlay_changeset *ovcs, int ret = 0; bool check_for_non_overlay_node = false; - if (!of_prop_cmp(overlay_prop->name, "name") || - !of_prop_cmp(overlay_prop->name, "phandle") || - !of_prop_cmp(overlay_prop->name, "linux,phandle")) - return 0; + if (target->in_livetree) + if (!of_prop_cmp(overlay_prop->name, "name") || + !of_prop_cmp(overlay_prop->name, "phandle") || + !of_prop_cmp(overlay_prop->name, "linux,phandle")) + return 0; if (target->in_livetree) prop = of_find_property(target->np, overlay_prop->name, NULL); @@ -331,6 +332,10 @@ static int add_changeset_property(struct overlay_changeset *ovcs, if (!prop) { check_for_non_overlay_node = true; + if (!target->in_livetree) { + new_prop->next = target->np->deadprops; + target->np->deadprops = new_prop; + } ret = of_changeset_add_property(&ovcs->cset, target->np, new_prop); @@ -406,9 +411,10 @@ static int add_changeset_node(struct overlay_changeset *ovcs, struct target *target, struct device_node *node) { const char *node_kbasename; + const __be32 *phandle; struct device_node *tchild; struct target target_child; - int ret = 0; + int ret = 0, size; node_kbasename = kbasename(node->full_name); @@ -422,6 +428,19 @@ static int add_changeset_node(struct overlay_changeset *ovcs, return -ENOMEM; tchild->parent = target->np; + tchild->name = __of_get_property(node, "name", NULL); + tchild->type = __of_get_property(node, "device_type", NULL); + + if (!tchild->name) + tchild->name = ""; + if (!tchild->type) + tchild->type = ""; + + /* ignore obsolete "linux,phandle" */ + phandle = __of_get_property(node, "phandle", &size); + if (phandle && (size == 4)) + tchild->phandle = be32_to_cpup(phandle); + of_node_set_flag(tchild, OF_OVERLAY); ret = of_changeset_attach_node(&ovcs->cset, tchild); From patchwork Mon Oct 15 00:24:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 983844 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YL672MdDz9s3l for ; Mon, 15 Oct 2018 12:13:03 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gWyRcxwj"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42YL670h0HzF0PM for ; Mon, 15 Oct 2018 12:13:03 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gWyRcxwj"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::541; helo=mail-pg1-x541.google.com; envelope-from=frowand.list@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gWyRcxwj"; dkim-atps=neutral Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42YK4F3s1tzDrqN for ; Mon, 15 Oct 2018 11:26:21 +1100 (AEDT) Received: by mail-pg1-x541.google.com with SMTP id v133-v6so8304938pgb.2 for ; Sun, 14 Oct 2018 17:26:21 -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=M4dGHNWK9yvMCplN74sEUY4ZcqWQ+poGeb6zjVC5TlY=; b=gWyRcxwjcQIHmXE3ZziNd+GcsFcruZnlEBbPXRlGsVou9U8Iw0tlYr3VAR3cBksx9G N7tySGgEP/HFuxeC843p+3bnWGpTsgKPZ03NxEqjRm7gPsftSfRTCzU4G6eXXA8mG9IG zr4r8HyF9JyNyuWc52elnRofPsuMQYZKkZ3xBs+MBcN8+e49lHo0aXHnwqenZptAuVH5 Fr0duPpaar6ht3gsyjM9U1eKgG3fX7JLhD4pit240ydQvLfc7hWQNxHlxNZDjqSPMfXP TscVakrTjOgukthrFt2MNfub0PK2ZsovcKCxPI3kt5e6DwO1BMdXfNwHH0pC8YObF7vy JWFw== 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=M4dGHNWK9yvMCplN74sEUY4ZcqWQ+poGeb6zjVC5TlY=; b=a2EddSvKS5Ap/5exV/Re0flZT4XLFpbF+q/qB/3QhO5Q7cgvBOU6i1FcUY14dnEfow Ap+Z6dMjLJ8e/npS+dT8D4b0inwTBOpXxeZLCuCeXQJe0ys8Ce93rRadexM6e7oaM/Fa WcvsMu01ZE6pyIO2WQJD5BYZ82+RtnpPrPdcPsGb1hp9FZvAexLbSEDrqtjMPVa3Gr9W HE8c515f/sQdTuq66VbvjheG8k/DBPB0ZH18RydYAKIoMFoeCswKEPlVvF0XVPqaERov 3u3raUlrzBFT0hZLwF1LP/Nk9q3Wq49BnBWIU4ej5VL2eZVBWM2n+fAgmaOtPBwBiBi1 Iqhg== X-Gm-Message-State: ABuFfoiHFfCC8N3LZ+Fe4FDgmC3jUSU6xH/3Zeu+MdQFDSpZ1UEoOMYc kYzI7KU+K+ai96Xq8Gz2V2E= X-Google-Smtp-Source: ACcGV61eeK3CD8b67f0r0rPDG7tY7h66TMSoIRK9LgsqCTBu5Q5Wiy3lma9WvBqS6q6scIZnfmt1/g== X-Received: by 2002:a63:f5a:: with SMTP id 26-v6mr14016650pgp.100.1539563179957; Sun, 14 Oct 2018 17:26:19 -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 j14-v6sm11387110pgh.52.2018.10.14.17.26.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Oct 2018 17:26:19 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v3 16/18] of: unittest: allow base devicetree to have symbol metadata Date: Sun, 14 Oct 2018 17:24:28 -0700 Message-Id: <1539563070-12969-17-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> References: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-fpga@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Frank Rowand The overlay metadata nodes in the FDT created from testcases.dts are not handled properly. The __fixups__ and __local_fixups__ node were added to the live devicetree, but should not be. Only the first property in the /__symbols__ node was added to the live devicetree if the live devicetree already contained a /__symbols node. All of the node's properties must be added. Signed-off-by: Frank Rowand --- drivers/of/unittest.c | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 6d80f474c8f2..1c2bd8503095 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -1057,20 +1057,44 @@ static void __init of_unittest_platform_populate(void) * of np into dup node (present in live tree) and * updates parent of children of np to dup. * - * @np: node already present in live tree + * @np: node whose properties are being added to the live tree * @dup: node present in live tree to be updated */ static void update_node_properties(struct device_node *np, struct device_node *dup) { struct property *prop; + struct property *save_next; struct device_node *child; - - for_each_property_of_node(np, prop) - of_add_property(dup, prop); + int ret; for_each_child_of_node(np, child) child->parent = dup; + + /* + * "unittest internal error: unable to add testdata property" + * + * If this message reports a property in node '/__symbols__' then + * the respective unittest overlay contains a label that has the + * same name as a label in the live devicetree. The label will + * be in the live devicetree only if the devicetree source was + * compiled with the '-@' option. If you encounter this error, + * please consider renaming __all__ of the labels in the unittest + * overlay dts files with an odd prefix that is unlikely to be + * used in a real devicetree. + */ + + /* + * open code for_each_property_of_node() because of_add_property() + * sets prop->next to NULL + */ + for (prop = np->properties; prop != NULL; prop = save_next) { + save_next = prop->next; + ret = of_add_property(dup, prop); + if (ret) + pr_err("unittest internal error: unable to add testdata property %pOF/%s", + np, prop->name); + } } /** @@ -1079,18 +1103,23 @@ static void update_node_properties(struct device_node *np, * * @np: Node to attach to live tree */ -static int attach_node_and_children(struct device_node *np) +static void attach_node_and_children(struct device_node *np) { struct device_node *next, *dup, *child; unsigned long flags; const char *full_name; full_name = kasprintf(GFP_KERNEL, "%pOF", np); + + if (!strcmp(full_name, "/__local_fixups__") || + !strcmp(full_name, "/__fixups__")) + return; + dup = of_find_node_by_path(full_name); kfree(full_name); if (dup) { update_node_properties(np, dup); - return 0; + return; } child = np->child; @@ -1111,8 +1140,6 @@ static int attach_node_and_children(struct device_node *np) attach_node_and_children(child); child = next; } - - return 0; } /** From patchwork Mon Oct 15 00:24:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 983845 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YL8z6MXVz9s7W for ; Mon, 15 Oct 2018 12:15:31 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="aTlxhko5"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42YL8z4LwkzF0wj for ; Mon, 15 Oct 2018 12:15:31 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="aTlxhko5"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::443; helo=mail-pf1-x443.google.com; envelope-from=frowand.list@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="aTlxhko5"; dkim-atps=neutral Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42YK4G5BfhzDrqN for ; Mon, 15 Oct 2018 11:26:22 +1100 (AEDT) Received: by mail-pf1-x443.google.com with SMTP id l81-v6so8768898pfg.3 for ; Sun, 14 Oct 2018 17:26:22 -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=VS64Bboo/cHvVCqyzYbNqD36WUkYJGIhe/8UN1uSi10=; b=aTlxhko51/9f7aed6ItraXbkxoe6kGvYd83E/fHXVWgFecy1Olmna2VISAbwpqOokE LuaNWMwGnLMWgIg948vD01hZG/GNZblxL922C/9Fc/e7xHjtbXS7Kjg7HxCS4XbcRoRu CVLARIIFO8rqZ45rvZHsjHlNGNb87L3/itRq+5izC/wpR0DUY/Ac/7HOzkaqAykeHXOj n07owHvlwnmicy5P+Dp07Rbk/KEchuh64vcsLT+kneWaEdLfG94ayH+CWdL7RhPaSig7 dCLqzIvxrb+5QwrZJNJeqBP2sjhtHT33Wb4eEc3wM/WYRm4vaos6Hy8CX9MV5gVOSihH Koaw== 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=VS64Bboo/cHvVCqyzYbNqD36WUkYJGIhe/8UN1uSi10=; b=BKd/QvAfB4Fx9ru5x1nTu2lb+ySr4V9oEj074/V/wCKtR6/4tn9+x24mxxZkEWB3Wl BO9gC3+diB7q546suPLcJdTbw6bHnqAJTHaNOgIbYwxL/nQkiz/XCoawTdfJj/ksjTaM 1VNeok59tK4A7ZyO3j4j4g5yNI15zBC6E80oYsznZasEbNDdE4m5YTvrDurgdaxDWkgm x40H3aygTSiMoxy1aoNMkBQVgssh0rBVP31FxOTxyD1bwKlQGt3xbGsd6KWpXThuedOP 0LyECmKE7R8zaOqHvxlZsF73w1hIx3pR5VWqu3OXXb6Nppq13+AG5Ae7YnoZsRXl7f8Z OVQQ== X-Gm-Message-State: ABuFfoj0r5o+eyIP4N6BkOi4noGsv1qz+48vt12dlL971V7TyVN6Nvt8 w+ajZMfq58cglD0bnsiSEEc= X-Google-Smtp-Source: ACcGV62cH2LaLFQyIx7k8xHppqHRC53HiLEbyEcmwS8FL2NXLjV9+e87gtgKtMJ2jHGrJyQArApd1g== X-Received: by 2002:a63:9742:: with SMTP id d2-v6mr14079573pgo.278.1539563181169; Sun, 14 Oct 2018 17:26:21 -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 j14-v6sm11387110pgh.52.2018.10.14.17.26.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Oct 2018 17:26:20 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v3 17/18] of: unittest: find overlays[] entry by name instead of index Date: Sun, 14 Oct 2018 17:24:29 -0700 Message-Id: <1539563070-12969-18-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> References: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-fpga@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Frank Rowand One accessor of overlays[] was using a hard coded index value to find the correct array entry instead of searching for the entry containing the correct name. Signed-off-by: Frank Rowand --- drivers/of/unittest.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 1c2bd8503095..785985bdbfa6 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -2178,7 +2178,7 @@ struct overlay_info { OVERLAY_INFO_EXTERN(overlay_bad_phandle); OVERLAY_INFO_EXTERN(overlay_bad_symbol); -/* order of entries is hard-coded into users of overlays[] */ +/* entries found by name */ static struct overlay_info overlays[] = { OVERLAY_INFO(overlay_base, -9999), OVERLAY_INFO(overlay, 0), @@ -2201,7 +2201,8 @@ struct overlay_info { OVERLAY_INFO(overlay_bad_add_dup_prop, -EINVAL), OVERLAY_INFO(overlay_bad_phandle, -EINVAL), OVERLAY_INFO(overlay_bad_symbol, -EINVAL), - {} + /* end marker */ + {.dtb_begin = NULL, .dtb_end = NULL, .expected_result = 0, .name = NULL} }; static struct device_node *overlay_base_root; @@ -2231,6 +2232,19 @@ void __init unittest_unflatten_overlay_base(void) u32 data_size; void *new_fdt; u32 size; + int found = 0; + const char *overlay_name = "overlay_base"; + + for (info = overlays; info && info->name; info++) { + if (!strcmp(overlay_name, info->name)) { + found = 1; + break; + } + } + if (!found) { + pr_err("no overlay data for %s\n", overlay_name); + return; + } info = &overlays[0]; @@ -2278,11 +2292,10 @@ static int __init overlay_data_apply(const char *overlay_name, int *overlay_id) { struct overlay_info *info; int found = 0; - int k; int ret; u32 size; - for (k = 0, info = overlays; info && info->name; info++, k++) { + for (info = overlays; info && info->name; info++) { if (!strcmp(overlay_name, info->name)) { found = 1; break; From patchwork Mon Oct 15 00:24:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 983846 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YLCg2Sd5z9s3C for ; Mon, 15 Oct 2018 12:17:51 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Rpnfi/Yt"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42YLCg0gz8zF2Fb for ; Mon, 15 Oct 2018 12:17:51 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Rpnfi/Yt"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::542; helo=mail-pg1-x542.google.com; envelope-from=frowand.list@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Rpnfi/Yt"; dkim-atps=neutral Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42YK4J03LqzDrqN for ; Mon, 15 Oct 2018 11:26:24 +1100 (AEDT) Received: by mail-pg1-x542.google.com with SMTP id f8-v6so8295785pgq.5 for ; Sun, 14 Oct 2018 17:26:23 -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=Q0blMRhqNPiCrzvXWEp+FPb/ePWbrdIXRWW/hT0vdeE=; b=Rpnfi/YthBio9UGW3cAii3/UHa+crCMwoFN5Oto2G1OkPcu8ysLW+KK/4QpUsopwRv Lnz9ziL806pO0q7YNFw7EbgGUFsl4DG4O7xUb/r9eZwLq6ETJQ6rrPtFGKvnV+1qXNv8 2bUhTR6vKfo5AVq9NSIIcNk1BFn/HMNsq3dpG8etwwVDmobqZLekiwfY4O6CjzjomhcR M4w2Tm1iz65XZv1N7sqDa1jJTQ7lyXMBcPerQF7TXakdAjxOuSet8NMRenJ8Tgs6gnzE vnQm4aeXzQ1opWNem9ObFAV2NqevDdeq7zLHy8+Wk5LD7wwJ4KbyzbndRJyVWBjBRc0b 9XJA== 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=Q0blMRhqNPiCrzvXWEp+FPb/ePWbrdIXRWW/hT0vdeE=; b=jviDm1T8NC4lVA6D3CuHX1HnqY9hY6JSc4UM3M4wZzHnmYFyrGpL+VkCjtXpZBGh3e L10f8WKqD9ALSSRXEkyaSoEM5h+/VVB41AA5adWZtJ5LuqTVZsNG5DDc5Ae4v9Gq9BWt 9d1t1wHsTr1Qf8jGmenQCgjpiwpquvTyQiyeQq7SDw02eraqx6G4+jy15MUVP0JXd5Pd MYv/lUO/t4mHHOkFjDT+yRRNPIzkIwIyJ1QfeJnZRdE9r3aca7sc2K6a0aexeFZlvnfY wXcQ20y1BG3cBbB10pA8GmmPyEcw6/m9pokbT2Eso3Yoi1srAfRXgrDEcRucxRQ3rp40 Ktrw== X-Gm-Message-State: ABuFfojx5JISLxBXEG0sjR2S4PPa55dfxAyhUGktXokFaFe9iJEn19Qn 5hmxHQNs4GckoO6FnCvFewdH+R+k X-Google-Smtp-Source: ACcGV6275KnxkNqcgg9GpxC63431k7mMMSWVrq4RyGUzuS9IctokQ4CexUC09S6v7nK38ZgBVIN3dA== X-Received: by 2002:a63:e04d:: with SMTP id n13-v6mr14238400pgj.426.1539563182425; Sun, 14 Oct 2018 17:26:22 -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 j14-v6sm11387110pgh.52.2018.10.14.17.26.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Oct 2018 17:26:21 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer , Guenter Roeck Subject: [PATCH v3 18/18] of: unittest: initialize args before calling of_*parse_*() Date: Sun, 14 Oct 2018 17:24:30 -0700 Message-Id: <1539563070-12969-19-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> References: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-fpga@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Frank Rowand Callers of of_irq_parse_one() blindly use the pointer args.np without checking whether of_irq_parse_one() had an error and thus did not set the value of args.np. Initialize args to zero so that using the format "%pOF" to show the value of args.np will show "(null)" when of_irq_parse_one() has an error. This prevents the dereference of a random value. Make the same fix for callers of of_parse_phandle_with_args() and of_parse_phandle_with_args_map(). Reported-by: Guenter Roeck Signed-off-by: Frank Rowand --- drivers/of/unittest.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 785985bdbfa6..5f4db23e4752 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -375,6 +375,7 @@ static void __init of_unittest_parse_phandle_with_args(void) for (i = 0; i < 8; i++) { bool passed = true; + memset(&args, 0, sizeof(args)); rc = of_parse_phandle_with_args(np, "phandle-list", "#phandle-cells", i, &args); @@ -428,6 +429,7 @@ static void __init of_unittest_parse_phandle_with_args(void) } /* Check for missing list property */ + memset(&args, 0, sizeof(args)); rc = of_parse_phandle_with_args(np, "phandle-list-missing", "#phandle-cells", 0, &args); unittest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc); @@ -436,6 +438,7 @@ static void __init of_unittest_parse_phandle_with_args(void) unittest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc); /* Check for missing cells property */ + memset(&args, 0, sizeof(args)); rc = of_parse_phandle_with_args(np, "phandle-list", "#phandle-cells-missing", 0, &args); unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); @@ -444,6 +447,7 @@ static void __init of_unittest_parse_phandle_with_args(void) unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); /* Check for bad phandle in list */ + memset(&args, 0, sizeof(args)); rc = of_parse_phandle_with_args(np, "phandle-list-bad-phandle", "#phandle-cells", 0, &args); unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); @@ -452,6 +456,7 @@ static void __init of_unittest_parse_phandle_with_args(void) unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); /* Check for incorrectly formed argument list */ + memset(&args, 0, sizeof(args)); rc = of_parse_phandle_with_args(np, "phandle-list-bad-args", "#phandle-cells", 1, &args); unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); @@ -502,6 +507,7 @@ static void __init of_unittest_parse_phandle_with_args_map(void) for (i = 0; i < 8; i++) { bool passed = true; + memset(&args, 0, sizeof(args)); rc = of_parse_phandle_with_args_map(np, "phandle-list", "phandle", i, &args); @@ -559,21 +565,25 @@ static void __init of_unittest_parse_phandle_with_args_map(void) } /* Check for missing list property */ + memset(&args, 0, sizeof(args)); rc = of_parse_phandle_with_args_map(np, "phandle-list-missing", "phandle", 0, &args); unittest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc); /* Check for missing cells,map,mask property */ + memset(&args, 0, sizeof(args)); rc = of_parse_phandle_with_args_map(np, "phandle-list", "phandle-missing", 0, &args); unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); /* Check for bad phandle in list */ + memset(&args, 0, sizeof(args)); rc = of_parse_phandle_with_args_map(np, "phandle-list-bad-phandle", "phandle", 0, &args); unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); /* Check for incorrectly formed argument list */ + memset(&args, 0, sizeof(args)); rc = of_parse_phandle_with_args_map(np, "phandle-list-bad-args", "phandle", 1, &args); unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); @@ -780,7 +790,7 @@ static void __init of_unittest_parse_interrupts(void) for (i = 0; i < 4; i++) { bool passed = true; - args.args_count = 0; + memset(&args, 0, sizeof(args)); rc = of_irq_parse_one(np, i, &args); passed &= !rc; @@ -801,7 +811,7 @@ static void __init of_unittest_parse_interrupts(void) for (i = 0; i < 4; i++) { bool passed = true; - args.args_count = 0; + memset(&args, 0, sizeof(args)); rc = of_irq_parse_one(np, i, &args); /* Test the values from tests-phandle.dtsi */ @@ -854,6 +864,7 @@ static void __init of_unittest_parse_interrupts_extended(void) for (i = 0; i < 7; i++) { bool passed = true; + memset(&args, 0, sizeof(args)); rc = of_irq_parse_one(np, i, &args); /* Test the values from tests-phandle.dtsi */