From patchwork Thu Oct 18 22:46: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: 986371 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 42bkmv36RBz9s2P for ; Fri, 19 Oct 2018 09:51: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="jHlJy2yd"; 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 42bkmv1FTVzF3JM for ; Fri, 19 Oct 2018 09:51:27 +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="jHlJy2yd"; 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="jHlJy2yd"; 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 42bkj361hrzF3FK for ; Fri, 19 Oct 2018 09:48:07 +1100 (AEDT) Received: by mail-pg1-x542.google.com with SMTP id 23-v6so14856123pgc.8 for ; Thu, 18 Oct 2018 15:48: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=C494CovzuO9b6he1A/aT23EiOpnTLXoKmWoxMPV+2cw=; b=jHlJy2ydgM4w3zMfbOoS08MLFHPU2KCicOENypQxHZut1p4CcI0pIbY2sIV49DI4D9 D2LEfeGo5Cz2rfyPT44K+bgKYU6dQurgTXVgm6HgW317e1GT5ZMFYUSjMLyea+mSnsdQ FKSlprtBNvIPl41SWxubfbX2GV5osUtq2R3V3fQ+OGGCgl4LwLB21KjDWYYNNgeHDD/8 W2spEeLyK7YFiEes7tIFSm08y3geYKJEYm3nrI5NlDeQGWkDcJHrxSn+GhL4KbQMhSNP wXcMv1zd5SnNxoo4x+po0msPiIapmQlVedJWXV9HQAsDFQmsFCczaw1JK84oeJpb1hAB 6EDA== 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=C494CovzuO9b6he1A/aT23EiOpnTLXoKmWoxMPV+2cw=; b=bJK2Cb+WH5VmbAee16BbheaY1K+tAI4/Xf7lHxmvbhIv6CxTlUU9h6ZAT8mTrq7yvI aaq0JzHzMnwN6Mi/u/xThmUUVPC5bgDflJVa9Xzd4BJR/4QVAEIjOhnqs3wQX/mUKkpa HioalxSdBsy5qmsdXiml0G66IpTMfRx4lzf7yB58D5ulnspWtfrG9F86NhA8TMWWMktg vDmgaA/Rlcf4k2M/gOunN5cw21DtH4f7R67qKR2GT+2EwNyRn0Yzca5ugElsylqVWTEi 7xIunMKip/hTa7NspRRvrH40aFc2zs6zCznvhXbjABf4R4ssZIbwdjxx5fqV6Db2P+kA jruw== X-Gm-Message-State: ABuFfogoagIIitsthqDCoEdWEyXajje+sJVgK+9WNp/MNlF+Wugp+GAm wARPvV8tTQ+pe9mBZ/Ybjd0= X-Google-Smtp-Source: ACcGV60e/uDOxckhIIT7OK2wqEa+HS7phFOjj3n6MwOKyR+PsYv21b4DJ9kqXE3V1iiVOG+P9Vba5A== X-Received: by 2002:a63:4454:: with SMTP id t20-v6mr29636393pgk.102.1539902885772; Thu, 18 Oct 2018 15:48: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 v81-v6sm38129268pfj.25.2018.10.18.15.48.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Oct 2018 15:48: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 v5 01/18] of: overlay: add tests to validate kfrees from overlay removal Date: Thu, 18 Oct 2018 15:46:19 -0700 Message-Id: <1539902796-8382-2-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539902796-8382-1-git-send-email-frowand.list@gmail.com> References: <1539902796-8382-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(), unexpected properties in /testcase-data/overlay-node/test-bus/test-unittest11 OF: ERROR: memory leak, expected refcount 1 instead of 2, of_node_get()/of_node_put() unbalanced - destroy cset entry: attach overlay node /testcase-data-2/substation@100/ hvac-medium-2 Signed-off-by: Frank Rowand --- Changes since v4: - make error message format consistent, error first, path last 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..12c3f9a15e94 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 before free overlay changeset, %pOF\n", + 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(), unexpected properties in %pOF\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, expected refcount 1 instead of %d, of_node_get()/of_node_put() unbalanced - destroy cset entry: attach overlay node %pOF\n", + kref_read(&ce->np->kobj.kref), ce->np); + } 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 Thu Oct 18 22:46: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: 986375 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 42bktW18Ldz9sB7 for ; Fri, 19 Oct 2018 09:56: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="taqEy43K"; 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 42bktV6htCzF2Ds for ; Fri, 19 Oct 2018 09:56: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="taqEy43K"; 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="taqEy43K"; 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 42bkj53tlFzF3FK for ; Fri, 19 Oct 2018 09:48:09 +1100 (AEDT) Received: by mail-pf1-x442.google.com with SMTP id f29-v6so15558858pff.5 for ; Thu, 18 Oct 2018 15:48:09 -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=UkGmi/9uJ2cCYbyUNwZsGr2ZdTjlRhMEjWVQ61ER+Cw=; b=taqEy43Kxhig/LXfGVWqTBnelE+49dshuohkZnlQdp3Qjip9G1jBeYbkAkQxQE345D ZWnI9hdFl7fFXx6XOjTL2zN05hRu/1x+wXFl10W8/nK2PAmQD9iqNNBpRcRQOqho7cmU wzyEvm2y5U2MobAaXQ2sctltsP9zH6+USVIrtwxUbtX+M1+gEADn9iRildNFjFuCEbVi 5xQb8wnNKPlNsgelXgY8AgwPWFM7F8B8W4oCVqzdfc8eKfIuR0D407XmtQDceTlLFBB8 XnBlDSrv+dAZNZkCpdL3CorPp6qeWpaRMMgxyksqL9EDOi+/+jH/Lp4baRJX9sAl1Wi+ YOvw== 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=UkGmi/9uJ2cCYbyUNwZsGr2ZdTjlRhMEjWVQ61ER+Cw=; b=LmdKJuR9G5NyoXzaGMD6DJMvGfdTyF1sHyEdm1dhUWHqPc63iV61PDMyqSDGsU+K4N nlHs+qzXmaCGxLitLbo8uLEyaWnPL+Nt9/9ayccdSrf2liElSJyBhMzCmj1zBkglVy59 kv98pgBDeEnW3mjmCH6fCCP+zpk9czybzsMbHl4U4idBd+xF742Y3XOntPyjLzw+5028 RzJ8XeUPfOCpvDNtU7g9NTOzDUCvrXTvgc+mHev+x3z1UyeirRcQJsZHEhD62LjS08fn vYZYAr3mBvivRxipBLENdxqzxNr1T60s+zwPQKPbnRiCeA/P8o9lIeWDPesNWffeJJJY aHQA== X-Gm-Message-State: ABuFfogi5fPqdrmI+/CUxB+uW6N2pWb3pU1drQ8yljFzFRIIIsaopa7F vJ39iWycXkolcdMvLhcQ7F0= X-Google-Smtp-Source: ACcGV60ZLNKzt1yoclqWHTuCOhkBSXlJ4phdE8lj8UWvA7DtMGvVDgAmSbswV9Beh+dA23ANl2h1RA== X-Received: by 2002:a63:7c5e:: with SMTP id l30-v6mr29773428pgn.45.1539902887329; Thu, 18 Oct 2018 15:48: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 v81-v6sm38129268pfj.25.2018.10.18.15.48.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Oct 2018 15:48: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 v5 02/18] of: overlay: add missing of_node_put() after add new node to changeset Date: Thu, 18 Oct 2018 15:46:20 -0700 Message-Id: <1539902796-8382-3-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539902796-8382-1-git-send-email-frowand.list@gmail.com> References: <1539902796-8382-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 before free overlay changeset, /testcase-data/overlay-node/test-bus/test-unittest4 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 Thu Oct 18 22:46: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: 986376 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 42bkx84nS2z9sCQ for ; Fri, 19 Oct 2018 09:58:36 +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="IKvuIkbT"; 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 42bkx83Dv6zF3DW for ; Fri, 19 Oct 2018 09:58:36 +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="IKvuIkbT"; 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="IKvuIkbT"; 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 42bkj66GNXzF3FK for ; Fri, 19 Oct 2018 09:48:10 +1100 (AEDT) Received: by mail-pf1-x442.google.com with SMTP id r64-v6so15534422pfb.13 for ; Thu, 18 Oct 2018 15:48: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=9C70m4ZYW6bahYInRPebhsLk8Qt5u47Y5Ga7mt8v3gU=; b=IKvuIkbTbm2ZsyB6wxfEV8nvYYPxaG8Q3MWtDjHRUQXn0w4mTsaTEV0nFKlpvxqEJM rtskc9wujBBC8WV9CRHZQusuuIUIbiMqIp5NzT+MGqGuGcNMKTcPVVrphzylade21Gfa J2dA65DcFYors6/9ZFr2bc6WuW9duBueUd7mAU4WnMzvjrpiPuf27m2mlXUTwZMqiVoc 5ePRvOCmowx8I9dwPHiGiDDG5rTFdceTkF4a49QI7Kv2DWP4DyZ2JQ9QKttVOewkOh4a xH5i5DpRzxVpyl9RuXW0+xHw94U0cFM7u9sal+xnS1P5Kek8anhUdz6RPWf1S5yh6OnH lAtg== 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=9C70m4ZYW6bahYInRPebhsLk8Qt5u47Y5Ga7mt8v3gU=; b=Ksr+udQQ2wTO0lxNBUlisLFaFKq5WUsZvu6QFE6wz0hSaBef42/xEPGuWThkgHQ3LV kP+hAREV2Q2Ku/MBZswP8XZvARfBOZe5oav4zfctZ27wlPYLjwWKm+P/GpoHO3qSgEdj 2bXyrfk1IwlPm/7NGnEKZZfRcH2eZhmMFGWEKxYHEiLb6AYC51yWag3+so1REwR4OYbF nQjHb0W83+WH8P4FiukQYWsyYHqe46au6ze+I7dZ/M8h9iih3RB/Thr+LAYMl7+8OYFr vZ86O8OathUnKtlZUN+W14Geg++KBM2Fj6ejRdaK+W+69NI+3+eROo12ZSwapCL/F+5Q A6bQ== X-Gm-Message-State: ABuFfojEgEjcCPw4rLryckTkpARTAYOezm5oA7z927VdVWcgwbNmxsRl R1/DljXMPNv0J8lDbJNTB5I= X-Google-Smtp-Source: ACcGV60DPgY00OK9dxZfMklbl8XGA1jMZMnVsKNtGEQeN9pASNM3SPnDAnDgiPhNchc+PUSFfrOeDA== X-Received: by 2002:a63:5d55:: with SMTP id o21-v6mr29769769pgm.349.1539902888661; Thu, 18 Oct 2018 15:48: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 v81-v6sm38129268pfj.25.2018.10.18.15.48.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Oct 2018 15:48: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 v5 03/18] of: overlay: add missing of_node_get() in __of_attach_node_sysfs Date: Thu, 18 Oct 2018 15:46:21 -0700 Message-Id: <1539902796-8382-4-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539902796-8382-1-git-send-email-frowand.list@gmail.com> References: <1539902796-8382-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 --- This patch should result in powerpc systems that dynamically allocate a node, then later deallocate the node to have a memory leak when the node is deallocated. The next patch in the series will fix the leak. 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 12c3f9a15e94..146681540487 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 Thu Oct 18 22:46: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: 986378 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 42bkzt72Jkz9sCQ for ; Fri, 19 Oct 2018 10:00:58 +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="Pbj7F0ml"; 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 42bkzt5ZlTzF3Fj for ; Fri, 19 Oct 2018 10:00:58 +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="Pbj7F0ml"; 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="Pbj7F0ml"; 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 42bkj76lPCzF3FL for ; Fri, 19 Oct 2018 09:48:11 +1100 (AEDT) Received: by mail-pg1-x541.google.com with SMTP id f18-v6so14877023pgv.3 for ; Thu, 18 Oct 2018 15:48: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=CCjwtqQtCAOwIXfabE6A59py+g67jCSp+upDI4OtmXg=; b=Pbj7F0mlm1BgSQnOhWBMy0EmScJ1rGAPVbM1ESkPvgz/QYnjeV6n3/X708Q27A+3Ky gnjSjL1ZkosSHjqbqF2rVB7ENb0LzyxV3m1KAxDIAyy/garAd6h5XWMlL0gJ2XmBY3iO 6TQoyvAXl72WXezqI/AqXqDnF7hyY3AiTNXJNANgr1CKjZp8JnnM/CgWHIDt+7QXZNJR 0PP2PssKe09PvuVRX4lXRUefrCzY6kWsGN7xtcBhUj84n6FTdN7hc80As7ZWpaPoHAjV jbSrBIrpVTPJue6eB6unNRIAr1A3BXteo90te8718midsNcSEX5BLdNYLVOYisIOnl08 H/DA== 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=CCjwtqQtCAOwIXfabE6A59py+g67jCSp+upDI4OtmXg=; b=FmTF4lI22dvze7EaOEIYuc2ug8259PpZdn+32oDDnyr8EBPO5F1Un89yLCjq8h5oEJ UOJ2hywgknVqJbvRvmo9j9VBJT8k3pdNICAacLE6deC0jUUYlevOyDX+Gy6SjehYqYBR So6SpmipCodFzWxfhqZqT4JqwIalUWawYJznGs3FCVN7tO1m5F2MjWkmkvLS7sGb1fho Fni/ojI9TTNrDYMLoWiRD0FI1YQ0MekNdeGqH2HoG4R4TN+/iTTRcfw9e/VH5ik6aS4t yCGyUsP+fCuQaHQWplbXUsBMWzJo+6YNMs0S1ef9zs4TWSSm6lAyrNGeskmCwBNeLKp5 vSqQ== X-Gm-Message-State: ABuFfohffRAfdicJlnh0fuIg/4NSAHhT2GwVybZlqQ7t1vd2bN3salH3 ME3CWdzE0e2wAU7CllyEg/4= X-Google-Smtp-Source: ACcGV60XEeNoeLiDaAGNjfUHWznT5NSnonm0FxYO4wnp575TXwjcJoFz5ZDNhov90TtKuboI5CU/1Q== X-Received: by 2002:a63:c251:: with SMTP id l17-v6mr2804256pgg.146.1539902889847; Thu, 18 Oct 2018 15:48: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 v81-v6sm38129268pfj.25.2018.10.18.15.48.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Oct 2018 15:48: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 v5 04/18] powerpc/pseries: add of_node_put() in dlpar_detach_node() Date: Thu, 18 Oct 2018 15:46:22 -0700 Message-Id: <1539902796-8382-5-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539902796-8382-1-git-send-email-frowand.list@gmail.com> References: <1539902796-8382-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 --- ***** UNTESTED. I need people with the affected PowerPC systems ***** (systems that dynamically allocate and deallocate ***** devicetree nodes) to test this patch. 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 Thu Oct 18 22:46: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: 986387 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 42blPh2WVCz9sBq for ; Fri, 19 Oct 2018 10:19:52 +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="YhXsdHLC"; 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 42blPh0tkLzF3FW for ; Fri, 19 Oct 2018 10:19:52 +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="YhXsdHLC"; 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="YhXsdHLC"; 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 42bkjJ0d27zF3FW for ; Fri, 19 Oct 2018 09:48:20 +1100 (AEDT) Received: by mail-pf1-x442.google.com with SMTP id l81-v6so15555383pfg.3 for ; Thu, 18 Oct 2018 15:48: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=snE79BS2V8O8WQJmvjxN5XBTUF3JVF3Wmy1gffetaI8=; b=YhXsdHLCgxwsaHuwszA+mzAJ9uKZPbtiZ58fxf1wGV3Fg/iKYbITE9TzOCIlkgBpbC nA7WboR2ADr/J7wldR6SGviOoyHk/YtdTWSWRJ+fRbmMNHSJtvSs/oyeXpQNvXzr/JOP 91vrjxG9KO+IbZ1OSllX0WIMfsFFtr5MX90X6OHCBxhckKmPW3qUdb5EcLXjvMk+C/Br 3tKwyk63f9LwJlxhSRNf75iypRw4NDkJ2NgkgcZ6/tGNoVwg6dmOS8RIixwc3V+CYZ1d iCG/mIsPZtwHE0GR+afoJE/2YWtnHd401Ug62LVTEGe2KPlPtyRL0W0Uz9Vr49vvDYmT n+zA== 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=cbnVjc+5fmDE6CcphIBg/JTxXk3JjJZ6Q7Heq4SpzoU8C65ioHRKwnIJZs/mHK9RTW aULSJMVGRrHXuAPoc35mijTcwdm/3XJSJ+UAXwbAbmyUovZFyK/C3bN5XC/X8thgQiq9 wiwbYeSyUCc3YUuLSBMgjbVwmlbJ+Ohsz8guLlt2WMzOCKFH2zs7KqJWpJcGIfitJtrU coLQ567kqyi30w5/HAQ5u6Ye66Fqm7elWxHnUEM5I5DsutTEJkGqUpq4HGPeagTe4pbp wuZUFrLZa1zEJF+6ZDGOsZufQdFzc/NXZwUm1ijSghk22H6ncRUc8p3wXp8dUXMCdLdq CLxQ== X-Gm-Message-State: ABuFfohc45IiGslus/df0MbDDbJ2fYzgRP9A8ah8isBmKpAfhZZj5Uok TIwejWE1vMWc1F48Y3k920VVLJAs X-Google-Smtp-Source: ACcGV63Rb5p2M4rnpwF8wcGiScKbqYzQPnw5D+2V5/cMFkw+Sq2ZEsiM0lYgT8oJuzcbvviaovROwQ== X-Received: by 2002:a63:785:: with SMTP id 127-v6mr4506236pgh.129.1539902890938; Thu, 18 Oct 2018 15:48:10 -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 v81-v6sm38129268pfj.25.2018.10.18.15.48.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Oct 2018 15:48: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 v5 05/18] of: overlay: use prop add changeset entry for property in new nodes Date: Thu, 18 Oct 2018 15:46:23 -0700 Message-Id: <1539902796-8382-6-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539902796-8382-1-git-send-email-frowand.list@gmail.com> References: <1539902796-8382-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 Thu Oct 18 22:46: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: 986379 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 42bl2S3Kr2z9sB7 for ; Fri, 19 Oct 2018 10:03:12 +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="DsEqbp5m"; 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 42bl2S1j8rzF2yr for ; Fri, 19 Oct 2018 10:03:12 +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="DsEqbp5m"; 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="DsEqbp5m"; 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 42bkj94K0xzF3FK for ; Fri, 19 Oct 2018 09:48:13 +1100 (AEDT) Received: by mail-pg1-x542.google.com with SMTP id s3-v6so1642906pga.12 for ; Thu, 18 Oct 2018 15:48: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=Y8f+zX4OUAoqVg/3NA0TrDwr4Zjok9K4JF3715XNZDg=; b=DsEqbp5maz0a9jQB9S6km5gyjg9OMujfKYuRvlTgDSfBuZK/Gxk4tGs1787JTxgdAW oP6UWhSyWmT6q5iQJ4R+NuF+rbuVOOIK8Z8J1wTk8YIARA9MUIrj+Y+SHbeobtpJ78wd sZcuXIrP3/ArgSICLC0vHTo2eCGTdaMhGjPu5H1FCGIm0vyUufdQBcL3fXINZ6z+Rtmx 8ZHmSyd616uqO/IVWb8Uv+sWEWo+5N3dcalWAU79QTxZrchh+1CwBL4kx798OpOJzHzQ dwkF1Uyv7G+P8WfTXoTzKFG3VncN+Qq19OiaHVtE4t0HpeBeB9orgSLqofAv3k7ILKIZ kCVA== 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=BU2YF1GifM8OtzlDd8XagVUMH0Zy+idIQbIojjVSdwdgVlcFX/e1zNhvANjmCWURIk 9vP31ONfqH5oXVFCveyZA2NpaR7QcLl9LMK2XgXs1eSgtkpSWWCEXLiz0HqpMVkhLSH0 yEWbBWiOFWJcvqw7emNZLRp23ELoG8fX/FWK7S0XOo2r+U62WyR/QycQwkrgzedZG6/N rzjhdloNSfZsJt7pZM7ZRusXPWNzGiXpnZgW6SnRT50DmI7ncnfiISPXlthM5L5yWT6g 3A7dtHAYAbGBjznSZd7Cw4OHzP+Ewpo60PZa+i+VP9NNEHUxFTIpC1v+s8cx8Hs685CU M4Zw== X-Gm-Message-State: ABuFfogOrzNEURdyDXibQe5uqzizzFSkoIzQaYPy4jKGuROYA1Csvz0o 871Jt8jS2IM3hAGapTWHv40= X-Google-Smtp-Source: ACcGV63HjomW5BejkyH0P48UtnxAoYZqja5t4Qt2H3pTR0wep7TuXb+qMrIeSbRzgAKu5mJvSDtKEg== X-Received: by 2002:a63:4a0e:: with SMTP id x14-v6mr29542038pga.34.1539902892048; Thu, 18 Oct 2018 15:48: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 v81-v6sm38129268pfj.25.2018.10.18.15.48.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Oct 2018 15:48: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 v5 06/18] of: overlay: do not duplicate properties from overlay for new nodes Date: Thu, 18 Oct 2018 15:46:24 -0700 Message-Id: <1539902796-8382-7-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539902796-8382-1-git-send-email-frowand.list@gmail.com> References: <1539902796-8382-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 Thu Oct 18 22:46: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: 986380 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 42bl513qMTz9sCQ for ; Fri, 19 Oct 2018 10:05:25 +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="IsjnurNq"; 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 42bl5121HRzDq5k for ; Fri, 19 Oct 2018 10:05:25 +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="IsjnurNq"; 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::544; helo=mail-pg1-x544.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="IsjnurNq"; dkim-atps=neutral Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) (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 42bkjB6c7CzF3Fj for ; Fri, 19 Oct 2018 09:48:14 +1100 (AEDT) Received: by mail-pg1-x544.google.com with SMTP id g12-v6so14867000pgs.1 for ; Thu, 18 Oct 2018 15:48:14 -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=hBF4GTCYQtWD7OTyqHilkMQ3AcRwpf9bLhC6OceDmtA=; b=IsjnurNqMSNRl0sIuQsRMfniBJGTCnIsdWRuifa0ndgANP9IAYYJQaAkl81R/yQHw/ OqH9Zrhe/GDD1nqNiiWmw9gcoIqktJSe7lZ3PVbDxbJ4osDosTCD2MA5r0gvSlJdqgnZ FmZ4uernFdSA64abYrSSAbj0voH9bMlnraL3BD63u8+ts3WxvtbLLJglGlSi5ws34Mop ekrtCc9pYhAAJtLWmNkC5orvi3+Z0isYI6BtgIo02r+FBFtvTGgj8kgBz5LbuIMtHMLT l0Yp9SmDUJ5FR0t86jPxyy8QYtAx2vOl51Iqcpno9wVuHU2zDxP1yv/e1jDoFayHapw9 p5kg== 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=hBF4GTCYQtWD7OTyqHilkMQ3AcRwpf9bLhC6OceDmtA=; b=BE5xYHx0rdgmOjJsYr+7TpbFt6ru8PtS19AMlTmJpq0H2voeowzxG05TXatVt+FLg3 GWmOcGuPXK0k/YG9nC/4RMIw2xnJPOtyt/0Cw7Z7brxqNxzlCS7maAlNtFVaqAUyBhnn lG5YuT2tO650fx2xvViqkExECfQ8FVfIpxr3yFQGrIeiMUlPZV6xW99nX0leZOgO09rY pi3tMPsOPAKpkZAm4djDMUCeRGZib4w44SIdDpQ4XuVgr0VZIp9VfX4A1UDD8ciAyW9r A1K5K3hNmuHJgFkssh2Npa5qRMvXewBs9hGqT0NO2rgbDRmc98Sf/HrA5h14V3ClatYs DwUw== X-Gm-Message-State: ABuFfogm84ufOyKYMFrU5CWtBDPK6abLIEQkunvhUGSlGo1HLWCTxdYd D5w8Eb1zSOpvXJFWRFTC9Xc= X-Google-Smtp-Source: ACcGV61LFJDW7XEZjTnBXaCmFQNnW0lf/zFG9MdU2pjZtJMOhfPrGSXAKiaKY7qh6o0qp0viQpNSfg== X-Received: by 2002:a63:e601:: with SMTP id g1-v6mr30604733pgh.290.1539902893223; Thu, 18 Oct 2018 15:48: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 v81-v6sm38129268pfj.25.2018.10.18.15.48.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Oct 2018 15:48:12 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v5 07/18] of: dynamic: change type of of_{at, de}tach_node() to void Date: Thu, 18 Oct 2018 15:46:25 -0700 Message-Id: <1539902796-8382-8-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539902796-8382-1-git-send-email-frowand.list@gmail.com> References: <1539902796-8382-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 146681540487..beea792debb6 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 Thu Oct 18 22:46: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: 986382 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 42bl7j74wMz9sB7 for ; Fri, 19 Oct 2018 10:07:45 +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="c1uOYwXo"; 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 42bl7j4QtmzF3PJ for ; Fri, 19 Oct 2018 10:07:45 +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="c1uOYwXo"; 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::544; helo=mail-pg1-x544.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="c1uOYwXo"; dkim-atps=neutral Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) (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 42bkjD2fmZzF3Fj for ; Fri, 19 Oct 2018 09:48:16 +1100 (AEDT) Received: by mail-pg1-x544.google.com with SMTP id y18-v6so14877339pge.0 for ; Thu, 18 Oct 2018 15:48: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=zdOcjsQSagxh/0ytfqlFE21zp3hEcz2hdT+yMst4gNc=; b=c1uOYwXosBtCvyj575Wmy7ttuIHcMNK9WOp/qfAIhCEVXIWwLVi/nvSSksbKtHFKk6 vwqJ/TzTagErWp2a6azNCOXFrxllNtmGdHomVGNrcs9LaXZhSjHpgPg0n2juvUueNNOA 98H4XSt0VABliigRqjNwrv4SlO2eO68UVfqTIu8adDRz8ZSiv4gC2WqnC8U2vWyqTSqy zymdMTQ2RTGM2JrvnUcf7hLOPimQR6lqgxbqO3bxwegYcRLhfKZ21hR5xNpp96h4taI9 7HBHgMMWTmtRsUhbdQNFXV+tZ2Kx27721aXVGRjvmtvpxhqoq+YNH1RjX2gYgbZZY1sC hUNg== 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=LD7VpU+IRk0HwJBi5JpvoZv6aJx2/yTGZ2czI+nPTpxcuDEwokkLNDtBL4K6X+umMF 4yFPDP8CmAeO+SOI7xG91pn5cZ4AK23kxzGT7jDrtjsaWWdk3nkIW2GJm6lpikQNdccs uykw/MKSg0w5oLQEyGU1I4FOF9AEjQCf5T1x8oEs73TlegDA/qr2lmWiZXPD/wE6pgnu 5LmVASK5udWUh2o+gPJjik+oBV/p1GmVdlEVG7LoDOQS5yCNB3cxkq29JgHB6sS6DLW7 5f3NRFat4YFBdjAhQ5u4GqjsGPe5xxiQhRAI8mlrgLunTL9ixarOdtjWWu5+RxfKAdny xVvQ== X-Gm-Message-State: ABuFfoiCK/DQALOZKRm2gaZHCgBtBsCUcoG5eA+rNOiQHHGJ1yDi/CAJ J4OnZDbyQ2h5F7204V8CgB8= X-Google-Smtp-Source: ACcGV60ystnSRz3PymYh6lwweFjt6UrpHkGgdyEVaBm+PihEzfeJGpjawOlrkGo5MlBDcSq2mu+lyA== X-Received: by 2002:a63:f553:: with SMTP id e19-v6mr29964960pgk.417.1539902894348; Thu, 18 Oct 2018 15:48:14 -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 v81-v6sm38129268pfj.25.2018.10.18.15.48.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Oct 2018 15:48: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 v5 08/18] of: overlay: reorder fields in struct fragment Date: Thu, 18 Oct 2018 15:46:26 -0700 Message-Id: <1539902796-8382-9-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539902796-8382-1-git-send-email-frowand.list@gmail.com> References: <1539902796-8382-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 Thu Oct 18 22:46: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: 986383 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 42blBj1mdQz9sB7 for ; Fri, 19 Oct 2018 10:10:21 +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="HZR4PRXS"; 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 42blBh6YQszDq5k for ; Fri, 19 Oct 2018 10:10:20 +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="HZR4PRXS"; 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="HZR4PRXS"; 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 42bkjF27CGzF3FL for ; Fri, 19 Oct 2018 09:48:17 +1100 (AEDT) Received: by mail-pf1-x442.google.com with SMTP id 78-v6so13174588pfq.0 for ; Thu, 18 Oct 2018 15:48: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=3p9z0Ehj9iwgF9Lhv52flr3WKpZAxs8EQb4W3gnL4wU=; b=HZR4PRXSXC3f+OMGauO6hcsGtA18EWWZyAT13lTC6JiP5/njGLW9QpgSTrjkm7AeTO Pzmpj4MLhYvoEk+cie1GsGqJaiagsjDi7S0n8R2EhGyO484/VyfjWaH13PygS5PYvk40 WwPi66GZ5/4OCIz7qmmL/QWx9pFrFTdN5CbtAmZIHGRHd5cOn+c1KHWYAukRamdds023 nvmun3DYUlpi+ItHi37r2vXpUD3wQju2cOI6OkHwSlra/QeFcBYY5ASZHKho8CW+xakb Wfb3ySCml32Gdsk8DkDsHlzGzyi5GcS7qIcLChl0fNRPs08grrWiuESLsBbqh5wHJylE JObw== 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=3p9z0Ehj9iwgF9Lhv52flr3WKpZAxs8EQb4W3gnL4wU=; b=uNQsMB+CC06LL/l81KHt3uMWyR3vH3Po0Ey/EmacipDbAKAtRHWYDU7dfMWwg8fFf7 bdkyLjKLdfOelmg8Xxcb8g99mn0gBm7yVCDFd2tZZoLhA9R5OP/n7K8bMgEkj6fIwGD6 EOfreTnJPLD49zBIIU9b7PP7n1N2wyJ08TjzrubwsY2hBOHVpLPJC0rqF6/kON9Y3m1b 0IUFTPZoEeiT/6PgGy7LWqhrrNRSdxD0PSmoQZVLzlGm/7MG3iuLrqzlxsrjffB2iDps UasxBCHXiZT7QVvDH62XRDcY6zNBUJ+sMMxXFl+6FBfWRD7ZaCB+G/CgSVHISqLRh81c pygw== X-Gm-Message-State: ABuFfogtPpl8biovB9efmw4cA6iGdpU7GINBdai/d5OqTnKT97FvCPY0 u6LgeDc+exwAUt2TCjE3yok= X-Google-Smtp-Source: ACcGV62j6brXEhvm6NxaHvXh8fuyuIlHYH77b5IHomUnKE2awpa6wXOXu3BxaUyrg4+cW2Injfp+/g== X-Received: by 2002:a62:8f:: with SMTP id 137-v6mr31996648pfa.24.1539902895523; Thu, 18 Oct 2018 15:48: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 v81-v6sm38129268pfj.25.2018.10.18.15.48.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Oct 2018 15:48: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 v5 09/18] of: overlay: validate overlay properties #address-cells and #size-cells Date: Thu, 18 Oct 2018 15:46:27 -0700 Message-Id: <1539902796-8382-10-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539902796-8382-1-git-send-email-frowand.list@gmail.com> References: <1539902796-8382-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. Signed-off-by: Frank Rowand --- Changes since v4: - create of_prop_val_eq() and change open code to use it - remove extra blank lines drivers/of/overlay.c | 32 +++++++++++++++++++++++++++++--- include/linux/of.h | 6 ++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index 272a0d1a5e18..e20d8923f475 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,12 +328,32 @@ 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 (!of_prop_val_eq(prop, new_prop)) { + pr_err("ERROR: changing value of #address-cells is not allowed in %pOF\n", + target->np); + ret = -EINVAL; + } + } else if (!of_prop_cmp(prop->name, "#size-cells")) { + if (!of_prop_val_eq(prop, new_prop)) { + pr_err("ERROR: changing value of #size-cells is not allowed in %pOF\n", + target->np); + ret = -EINVAL; + } + } 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: memory leak will occur if overlay removed, property: %pOF/%s\n", + target->np, new_prop->name); if (ret) { kfree(new_prop->name); diff --git a/include/linux/of.h b/include/linux/of.h index 72c593455019..1bb14a1f7227 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -947,6 +947,12 @@ static inline int of_cpu_node_to_id(struct device_node *np) #define of_node_cmp(s1, s2) strcasecmp((s1), (s2)) #endif +static inline int of_prop_val_eq(struct property *p1, struct property *p2) +{ + return p1->length == p2->length && + !memcmp(p1->value, p2->value, (size_t)p1->length); +} + #if defined(CONFIG_OF) && defined(CONFIG_NUMA) extern int of_node_to_nid(struct device_node *np); #else From patchwork Thu Oct 18 22:46: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: 986384 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 42blFN4VH1z9s0t for ; Fri, 19 Oct 2018 10:12:40 +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="WYzGiZ6+"; 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 42blFN2pVrzF3SG for ; Fri, 19 Oct 2018 10:12:40 +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="WYzGiZ6+"; 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="WYzGiZ6+"; 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 42bkjG2MtVzF3G8 for ; Fri, 19 Oct 2018 09:48:18 +1100 (AEDT) Received: by mail-pl1-x644.google.com with SMTP id bh10-v6so1577216plb.4 for ; Thu, 18 Oct 2018 15:48: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=WBVPhuC+zMp4YeMuLIQWeeUK2AnKgXRkOXabRgJfDhs=; b=WYzGiZ6+71Q/6yybAIoFn0lP4kJzCAtD55YJC7Ql7UrdDpNRMzEFH1BY7ytARk0kjX P9QKrWdbz9vMZjAPcR6OIYg6jtjlsScBgasC24VYJqYr84L2DraTktfSmMNHiORD58U+ BdzBbciH1xW7cucv4/PGbXfhHqr6uzwdFxQjOop41/WihY5Bl8ZRrKAdk+qlZTZrZ0Ye UBOhhL6ih6foDhLx8D5n+L2n2H6fwh7gEof3PwzAfwICLd5237M0j470gSsVUxgI5rVR ChOg+g72hTCTMNh24umGoeVQY8ZF8nxcA8Gpc0K7y+yAf5fy4AnDjYvXbmWcxoCqNYQX 4iig== 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=WBVPhuC+zMp4YeMuLIQWeeUK2AnKgXRkOXabRgJfDhs=; b=D4Iy2+pIUb35D5/dIGCwrFU2CRKX9D7yhdwCqWS2j6qqWRQFlGANs1T4dFKOMGtuBu KI91x7h/Sh/kokZr77cdm84PXUbULVAx48g0cNR3Y35hAFmVR4Ck3ItZniFTn63TUFV6 PAAtRUouSErIHy3s5vAIJpc8VE/K0hNhELgcrHR6uF3+F32a0fI1pBlvqnQNx/gWxpFy uJAMBikqs/BzS0M0Yhcl7rpEkPjUtyWulC9jJc5JAeG4Bk62hVixX2/3ER1RpaT73qyW WZ6LzJpL0MSSdUjTk9U0yXrdpTRkwEb6VdJUFLDRhMY6FQ1kWGlfSMdiCbTVrMwJTJV5 arqg== X-Gm-Message-State: ABuFfoifgLadgD2teWV4y5ixePW3xF9+XRP67fBfEt/qLPYDmKdqCR4t TmBJ6JHbKxhB+w0Yt3z03HM= X-Google-Smtp-Source: ACcGV63FmqZ3lNg59HzFPmxp5L7bb+yogsba4sl3oTD0lPRzi4cxxvvpPC0EPUswLzau2Gw9vRPk4Q== X-Received: by 2002:a17:902:a9c5:: with SMTP id b5-v6mr27940369plr.340.1539902896647; Thu, 18 Oct 2018 15:48: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 v81-v6sm38129268pfj.25.2018.10.18.15.48.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Oct 2018 15:48:16 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v5 10/18] of: overlay: make all pr_debug() and pr_err() messages unique Date: Thu, 18 Oct 2018 15:46:28 -0700 Message-Id: <1539902796-8382-11-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539902796-8382-1-git-send-email-frowand.list@gmail.com> References: <1539902796-8382-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 e20d8923f475..88e346234ae7 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -507,7 +507,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; } @@ -551,7 +551,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; } } @@ -564,7 +565,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; } } @@ -873,7 +875,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); @@ -1132,7 +1134,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 Thu Oct 18 22:46: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: 986385 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 42blJ41v6Pz9sBq for ; Fri, 19 Oct 2018 10:15: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="fkcCiNJ9"; 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 42blJ40JmgzF3Kr for ; Fri, 19 Oct 2018 10:15:00 +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="fkcCiNJ9"; 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::441; helo=mail-pf1-x441.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="fkcCiNJ9"; dkim-atps=neutral Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) (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 42bkjH632szF3G8 for ; Fri, 19 Oct 2018 09:48:19 +1100 (AEDT) Received: by mail-pf1-x441.google.com with SMTP id j23-v6so15548097pfi.4 for ; Thu, 18 Oct 2018 15:48:19 -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=fkcCiNJ9iEYgfJCEzDWYAdkeW84uc0JXDSBicUmWgvDvbjdMx+/AvMYzXJbKjCagek vaQJWcopNfOSlyItXEqrY0J7+qHjTid0KVlBV5SzpZW1yCZAbth2Rr3fG02QTaRyTqOO inl5ePnmUc38ejQEJ8zvOlkMD6Av7kUr96lt6RfHn8X9Wt2Gcwqr9KhAvpMWqOwkxSV8 XivSRmLZNm+CBwT2Ms0xeeQTAcE8ktnZd39KArkpgOKvbEhOYxon7zJRUZsl8BJfIGY+ G6AmKNRKYQXHKgs4EQG0QK0rISJJzuy1SjCfRmp8LqmvVATe1spatFS16GGIkvZ88i5R zUAw== 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=T/ltLw5OgoWbM7pNexCM8Vptl8ni7lPgDuWcD2IgeSD6MF1OWMtotlSfgaPuKhgFW3 oeQVNVRLoWvBQT2OaGN4VacWrFLXKD4J72CS20dx8GTKBT5/X7KaCkeOXSH0Nbs9hoN9 KusAceE3noQ0b/AVh4e7Ak8I/LvW5Jg5QNZCqyYWsg103ZTa2yIpR+q+gSnwvJjAKHIg j6NTrHhC51TF5mijASN4acTcyBF5Wcq6CUII523iKZkwLr+0ekH5u9IJwC8Ug/CA4/ub 3ubHexdyGMBJY1FS562rwnh6Fw7OS8rbllE4/EvRGSgQf1VF2L67b6JEPFV63q72SxWH Avgw== X-Gm-Message-State: ABuFfogRsMJ52/oWIaRjFEmdXMgI0PTXad5ZYkfdd5qYrPmELngUgXyl TlG2CabtrrymTWC/CuPe0j8= X-Google-Smtp-Source: ACcGV60VhO8ZLuoB5COQd3Li9qrJzOeBPJfQgDCh06RUoKgnwtpj/b5Hb/KcaYt/+sfEuTvf/6G+Uw== X-Received: by 2002:a62:ac1:: with SMTP id 62-v6mr6383653pfk.90.1539902897730; Thu, 18 Oct 2018 15:48: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 v81-v6sm38129268pfj.25.2018.10.18.15.48.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Oct 2018 15:48: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 v5 11/18] of: overlay: test case of two fragments adding same node Date: Thu, 18 Oct 2018 15:46:29 -0700 Message-Id: <1539902796-8382-12-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539902796-8382-1-git-send-email-frowand.list@gmail.com> References: <1539902796-8382-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 Thu Oct 18 22:46: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: 986386 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 42blLw12jFz9sBq for ; Fri, 19 Oct 2018 10:17:28 +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="UDtnt9Js"; 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 42blLv6bfrzF3FW for ; Fri, 19 Oct 2018 10:17:27 +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="UDtnt9Js"; 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="UDtnt9Js"; 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 42bkjJ3SygzF3HY for ; Fri, 19 Oct 2018 09:48:20 +1100 (AEDT) Received: by mail-pl1-x644.google.com with SMTP id y11-v6so14960479plt.3 for ; Thu, 18 Oct 2018 15:48: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=Qu97L87RGKi+8AyH9EKaRg09X+fdaCoy/llppuDOcJE=; b=UDtnt9JsZOsgIUxfbT3FOkloaNseK0BoQaqLhK2Q5jDJHzyIkCDrylzICRqpoqZpL5 WHQDhw7D8FwNugi3DzON7wPSlXZuN3GcqEgte4P5UJ1kXBrOWvDZeT6aAojsoaJID6vU lWkRmpdXgnaDl7RjIWEHBT1cwkoZZgOGAWFbWuWnJpnOAYBkprjW860xwmUh0Kn7nqid HBiJ4uizS/yzz9REdNaLW0Fv79n3f0gAXhvuYr7hoIygDvQCOyrS+fZtXQLkzvVjuPog uRRmc9BHO4hEgL5h3q3kqOOg4HlPOuu/8AOOU2OHNu6g18lUVS/CvLk6sUChRKQqGcki Galw== 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=Qu97L87RGKi+8AyH9EKaRg09X+fdaCoy/llppuDOcJE=; b=Ku+qmR29KgK/eKCZX7zhxGtJ0ByRnBig+Kg4qUdOL/OjsygULaEYj84M7PlIwnlR69 Kiz3Ti63pckOFNqTrlymemTxaFOTNJLj3g2wZoW3SvgJAjpkvnvRgY+BZeXMLjF2W/M/ CUqqI/Jr0ztH1wec2KfZLfgFAlZj9ShUkFA76f8vGTPDgYR7aWGWXg+oiwoaSx+BjJXT tYczu+JdTpcyw4fm07RqpdkT7Vx9GG2nKA/HutbP4bfRHNIlD6sz8swz8jBbcyksh70d gpUjzoFfiKDq4FuDI4X1Phyzr/XRhrG07+FVB04xttbVr2IprC6cICWCd8DNCif8pL6V ZQnA== X-Gm-Message-State: ABuFfohrMMvQk1lQfinfICcp3bUKjn4h6Uilb0WovDmw2VqA9HSQrvVG pS4c/W+QYyMd5AgeVfUAWAg= X-Google-Smtp-Source: ACcGV635nMTW9jOKra4iL+74o8Mn5al0B/pZpNUr+vRp5RQEFPig1YNoGM9XZwnEH3kWyV4xyEFyzg== X-Received: by 2002:a17:902:a50e:: with SMTP id s14-v6mr31667667plq.78.1539902898895; Thu, 18 Oct 2018 15:48: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 v81-v6sm38129268pfj.25.2018.10.18.15.48.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Oct 2018 15:48: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 v5 12/18] of: overlay: check prevents multiple fragments add or delete same node Date: Thu, 18 Oct 2018 15:46:30 -0700 Message-Id: <1539902796-8382-13-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539902796-8382-1-git-send-email-frowand.list@gmail.com> References: <1539902796-8382-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 88e346234ae7..e12f2c28a36a 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -392,14 +392,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. @@ -517,6 +509,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 * @@ -571,7 +611,7 @@ static int build_changeset(struct overlay_changeset *ovcs) } } - return 0; + return check_changeset_dup_add_node(ovcs); } /* From patchwork Thu Oct 18 22:46:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 986388 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 42blSR4ZMNz9sBq for ; Fri, 19 Oct 2018 10:22:15 +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="kJN/J1Wn"; 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 42blSR2qlnzF3Nd for ; Fri, 19 Oct 2018 10:22:15 +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="kJN/J1Wn"; 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="kJN/J1Wn"; 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 42bkjK5GrvzF3FL for ; Fri, 19 Oct 2018 09:48:21 +1100 (AEDT) Received: by mail-pl1-x641.google.com with SMTP id y11-v6so14960496plt.3 for ; Thu, 18 Oct 2018 15:48: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=FBP4hDQvyoNWRFBrCTkuGHkJzZo2uU0sSLnVkIQfb7A=; b=kJN/J1WnkSP4otV1/A8bRfPtne77uYe1xBp3CHaHC3nWg4TS//f2QbkrfXEBRcFvOx K+q777O/ese+U3IB8jA2lmB9aMReKvooDjK9vsq3wNOLiohipPpr67sZLtDf9xkSg+WW GJYWSeHgr4AGB991o8WrOu16W+Q7k4LUygD2JNfLtfHga5RMncha2q1UiGJjb1HD8qlQ NsUmjHP9N3R/0YWszbRV4NfIvKN5Gr6ObYHWi+3372wow/RmLqPafr+CofYrglIqDxT+ qDhB7mzd6XIJ0dpVit20HUgYbTZY1AMQmWX1HUg4E4F0ixXHndd7yC3vitFQLySqP0F+ mhlg== 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=FBP4hDQvyoNWRFBrCTkuGHkJzZo2uU0sSLnVkIQfb7A=; b=mCud1YsKi/FALIPuNcKsU4ixThxXgTGZF2uNTQYHHHT1tnv4PLpO3KI0tL0OfNLN57 buZMzJmZiNxudwUnM33Oib/+jsbqYryjJoZE6W4xec7DVhrmzVj0fZe21GYOh2Hh2oab EsUY9NxB0YEtentNsk6by1jdOtY4RjZ4BVyDiuglRtQRPHwSBwB/AcTR1PsOnYnJozho 8P6C5kbRIFy3I+R9/FftyyD3HVmiSFv8pUr20KLlLZi+Y7nKJhuwp0gF9esaBwiAr0HU PSQQCJbax5l/y8QyceQMxgMrA6wKBvxA7JWUcKppS6q1hCf4CPUW/B2I5eQqnBy/+lww s2BA== X-Gm-Message-State: ABuFfoitqvzVbQmTpz1wLnfYTnmQtMKmNZzm0vci5jlfKjNAONDimdcR z8XCVCC9TVbEOy30S8chQ9c= X-Google-Smtp-Source: ACcGV63Qw9M1opWgmHYn7ILQftTnMvAcQSzp5Gkxxtw6a6dcSBuIPGSDHL5tjEKMgubL19U8chFOdw== X-Received: by 2002:a17:902:b287:: with SMTP id u7-v6mr31286238plr.123.1539902900090; Thu, 18 Oct 2018 15:48:20 -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 v81-v6sm38129268pfj.25.2018.10.18.15.48.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Oct 2018 15:48: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 v5 13/18] of: overlay: check prevents multiple fragments touching same property Date: Thu, 18 Oct 2018 15:46:31 -0700 Message-Id: <1539902796-8382-14-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539902796-8382-1-git-send-email-frowand.list@gmail.com> References: <1539902796-8382-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. Before this patch, the first fragment error would terminate processing. Allow fragment checking to proceed and report all of the fragment errors before terminating the overlay apply. This is not a hot path, thus not a performance issue (the error is not transient and requires fixing the overlay before attempting to apply it again). After applying this patch, the devicetree unittest messages will include: OF: overlay: ERROR: multiple 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 --- 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 e12f2c28a36a..9e4af83c8c62 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -508,52 +508,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 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 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; } /** @@ -611,7 +655,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 Thu Oct 18 22:46:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 986390 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 42blWK44qXz9s9J for ; Fri, 19 Oct 2018 10:24:45 +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="feiwn75i"; 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 42blWK2P8lzF3Rs for ; Fri, 19 Oct 2018 10:24:45 +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="feiwn75i"; 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::643; helo=mail-pl1-x643.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="feiwn75i"; dkim-atps=neutral Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) (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 42bkjL5V4PzF3G8 for ; Fri, 19 Oct 2018 09:48:22 +1100 (AEDT) Received: by mail-pl1-x643.google.com with SMTP id e67-v6so5979106plb.6 for ; Thu, 18 Oct 2018 15:48: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=PMEoU3Gz26JMyroIsJaDweM2uFKnZxU+TruAPOzAvDQ=; b=feiwn75iOpLnPIxs4gwngqeqa/j467bmhlB2Z3uiZc+9axbLGlQhWWo1/6fZWU8ICv 12+8OEffuHNDqGZLDFi7OgTPxddu/jLyY4SF4vrQMxBEnZQAQKPzLgqacySUHlfQIIRE LE6mtjBy3MrJEjCchhPX4zITZi0tJGSvTtJ4XgQqFyVQIHUzcNV05faKh2SrXGbe+Rpz nZIY7xucyuDVkLbGW2z0ZNIQNLG/hF1qPbFPdA3u0YtSel3Bga+33KT+3n88rgOaEKNi wreGa02i6qGfuXn6ceV25RTr9FflMrpZnbgj9im5D4rzA5HzIZWCu/sY48qbzeLuIhyD EEqg== 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=PnYaXb2fCfu2CA1LSuESoXHYqFOi/T3EPSj1FmSLq7F8HhuH0djDI4TvOOgDgnE2x8 7e+sE1EmfOMJ+26DTMugoGhGrNGpZ0OCza5JPXLigFjrNnbJQtR79c6ah4C/uO4LaPdm EsYGOA+8CJBLaskTbZznMk21jcoOfitC9EK8xPUCHOiXSCUkBCc5gwWVSJUlxgrWwTkf +WrIraEiW+xMViZf/83hrn615Q05e11YEr+hl8C3cM2rPFTPXYkbsSbUt18C+8+Zl4J4 ONSZc6yIv3OUesQtiE1wbvVth2MsKDBRY0eUnBAkpbstAZranMQlAu7PfxG2HsM4H+Mu Z0Zg== X-Gm-Message-State: ABuFfoiAbJtpll8BMmy/LRCS72wF5M4wf2PNksnyR/1wRMLLiFENL5r8 c4wuATfmO41sjkjyketQbWPyJOv6 X-Google-Smtp-Source: ACcGV62Y4tBdznBiKteTNtZjqmdZPyj36bkUeDWr8tFt7RnWlFCWjtWwgfBdAQeny6esRrZYO/SyWQ== X-Received: by 2002:a17:902:5993:: with SMTP id p19-v6mr31533651pli.260.1539902901231; Thu, 18 Oct 2018 15:48: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 v81-v6sm38129268pfj.25.2018.10.18.15.48.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Oct 2018 15:48: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 v5 14/18] of: unittest: remove unused of_unittest_apply_overlay() argument Date: Thu, 18 Oct 2018 15:46:32 -0700 Message-Id: <1539902796-8382-15-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539902796-8382-1-git-send-email-frowand.list@gmail.com> References: <1539902796-8382-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 Thu Oct 18 22:46:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 986394 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 42blZ06G58z9s9J for ; Fri, 19 Oct 2018 10:27: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="tPahr7z+"; 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 42blZ04frjzF326 for ; Fri, 19 Oct 2018 10:27: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="tPahr7z+"; 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::643; helo=mail-pl1-x643.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="tPahr7z+"; dkim-atps=neutral Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) (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 42bkjN0FRkzF3HY for ; Fri, 19 Oct 2018 09:48:24 +1100 (AEDT) Received: by mail-pl1-x643.google.com with SMTP id d23-v6so1520750pls.11 for ; Thu, 18 Oct 2018 15:48: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=UyISa4Vgk45B7KLWkPwTcGVnrcGhj2ncy5/h8GMRMMc=; b=tPahr7z+tjGM61BJ7XrxUM2d4duxBQoLxE9WA6LQQMwP1OeMLjZMz17Q2Qx3xfSXnI Ja7Umyzk6lcBgPZYT5HxxXHElsbJRJVdrZ8ibLbeWc7lMd97ZB57sKBkr3P+EI/ZizrF Cb3FHHlWv7C2w26qW3BsfgMp70StEZfIGek7XwEzOKZSD2NxI9zy53OJWUQmhwB0Dwcd uQzYQ/v75v1yrdWxMC6PKGOvIEq5g5851HZ8jWTdhzjy7vH4J9htpNQoe6Rf92Wg6UBu cjvvP2DVVi2WLk+VsJ5Vyt4uTlJY0VlN8XT1Gwb3C94XJ1QVfMwzDvg62brCJZLKQEFs PEhg== 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=UyISa4Vgk45B7KLWkPwTcGVnrcGhj2ncy5/h8GMRMMc=; b=Hs2HnW8n6vcr899URdX96qLrhV3X2sGO5WieZwiU7k7JR6omgrS9Oi0B0vhGyrQYjA ajvyJ3W+Jb1SWSZZGUfIu7BSbfsfwePb/yU054Cb8ozD6XjRDU/6CJMJzkSst1pv/52d euR2buj6Y7uV9WOO3O60mRpFQ+AkL9VrXjFtQlbFiYNSIA0/txlkEV08I4jVdJdS94pu b2U2n4qZzj3P3JabzWyV+MSsUAdreIGKCFmjJTlBLhosDJ6rkJ3wofzduXsfwx3Bb3M6 KqZeZIqOrS8iwtjsXPG/BY29soxM906kyreyScE6gukZPNUeUp265rBGa6BOZfpnWEQv PY5Q== X-Gm-Message-State: ABuFfoiZyicslNxg/3f2kEl16u5zhtHpv5ter/6H65o8KtfwXPMMDj3H ZZ/q7IOpuwvR3T9QL6h19aI= X-Google-Smtp-Source: ACcGV60J7agimDNbHWa/FB2EUSr2pUmCOzaCSwUjGjDK+XORHP4FFsvxv0MZI1zqWMb5t+hMB3tUoA== X-Received: by 2002:a17:902:7109:: with SMTP id a9-v6mr31604083pll.310.1539902902454; Thu, 18 Oct 2018 15:48: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 v81-v6sm38129268pfj.25.2018.10.18.15.48.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Oct 2018 15:48:21 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v5 15/18] of: overlay: set node fields from properties when add new overlay node Date: Thu, 18 Oct 2018 15:46:33 -0700 Message-Id: <1539902796-8382-16-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539902796-8382-1-git-send-email-frowand.list@gmail.com> References: <1539902796-8382-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 beea792debb6..43e1ccb9c387 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 9e4af83c8c62..eaedb3a63077 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); @@ -330,6 +331,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); } else if (!of_prop_cmp(prop->name, "#address-cells")) { @@ -400,9 +405,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); @@ -416,6 +422,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 Thu Oct 18 22:46:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 986395 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 42blcm1FRbz9sCQ for ; Fri, 19 Oct 2018 10:29:28 +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="aO5MGbwP"; 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 42blcl6X83zF326 for ; Fri, 19 Oct 2018 10:29:27 +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="aO5MGbwP"; 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="aO5MGbwP"; 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 42bkjP1L33zF3JG for ; Fri, 19 Oct 2018 09:48:25 +1100 (AEDT) Received: by mail-pl1-x644.google.com with SMTP id f8-v6so14982588plb.2 for ; Thu, 18 Oct 2018 15:48:25 -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=aO5MGbwP6NEhfu+TGj/sWQx7qqzgeshSV+FfjrQkWe9ASGn0rrPUQmdunWIn92naAU JOmJ/L2cLK1qv0SSUOFnwfEBUw6TLcvKTwSeX4mmNgGGtnakVc3kW6odG8hX7QVddPxe eSoNGTvHqII8BVKXIQ6K8yak1b9rsdael+rH8ZHhI9QcRr8Mf9CLBPF25mieL1R4NQUv DdfUT1Onl5FOHEo/2C94rd/lA/jN0sBUxxJyYNq2IThFPVhTEBgP013vnNiGX7wXe2FA LuR+a5SgSI8bTle0ojmgNyfCMNjA/eBpJbtTaimQj+3YQb492niqO9G6dp0/9Yn0szig EAJg== 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=jJgtMLGsSJxi+8I9xCy2H91R5SkVOT8oxJsTeo5DK9RNr94OyTI2nx1I8dkoL7kcrp 1Otupz+eSyxi1Noq4dqBTlo/FGYc/2Jf1XImgBgkeK2WoWZv5ZdP04B2PUHIm8PX1F7Q 4MgRSKTMqIwW5veHT0l16suTmCmtI1EOzbO5xDDO695axYoqyU008cvD9GBneG38a4OW bDdkiLNQXC1uPxEg5BrVkD191mPgd6a3CEimaj6PKd6hwd70S7xo0QoqhEE66Umbwo8J TPs4FCyTfC4TdhUDfo6QxTZjCsa1GQpyw+KBbyf5k/0BjKTe7znCAW4JNO+W5S1nXsgF dawg== X-Gm-Message-State: ABuFfojnlFiL8HgRUjIqgZCvddWEnOeiidmweiHuQBPBHrelx2pxQ68l snBmBcutCBBOcFuE4rRO0n8= X-Google-Smtp-Source: ACcGV61MFmsnwKLZ1WoxOZcHCvX3RcZcEA005oMn+YU3RlnAAII/8pVvc7psYDyzcHwBM0kHNcx69A== X-Received: by 2002:a17:902:70c4:: with SMTP id l4-v6mr31230640plt.194.1539902903574; Thu, 18 Oct 2018 15:48:23 -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 v81-v6sm38129268pfj.25.2018.10.18.15.48.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Oct 2018 15:48:23 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v5 16/18] of: unittest: allow base devicetree to have symbol metadata Date: Thu, 18 Oct 2018 15:46:34 -0700 Message-Id: <1539902796-8382-17-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539902796-8382-1-git-send-email-frowand.list@gmail.com> References: <1539902796-8382-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 Thu Oct 18 22:46:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 986396 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 42blgS6QFjz9s9J for ; Fri, 19 Oct 2018 10:31:48 +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="EtKeeZVB"; 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 42blgS4pQbzDrM9 for ; Fri, 19 Oct 2018 10:31:48 +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="EtKeeZVB"; 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="EtKeeZVB"; 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 42bkjQ1d0nzF3HY for ; Fri, 19 Oct 2018 09:48:26 +1100 (AEDT) Received: by mail-pl1-x641.google.com with SMTP id f18-v6so14973055plr.1 for ; Thu, 18 Oct 2018 15:48:26 -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=EtKeeZVBk+FI0AK+AIQKX9hJ7lWddKg5ePWCoufuY1uIzioLYEKrk2sAOi9YDPyZ9f Nsvof3fYSpBcji78c9eH8sieJRDhYIHLwY510rCSKE8DOttguXPTtDUiwausPKaMmnyn 1ZnYyyrCcvZLaMmtK5NGG/FJe6zhqlDZn6bIdp+HrAwj1KtLIKQhhRWe615YHsDypiu2 3qmDHsF78zpfLJP0RVOn9PFt+AHPWb6bee7dXkg2fAe23hR6NigEsxI+CSGS2xbziBy6 I2/NZxKZ+H4opUEyaX8GoVujQCRn01tqRHTkefpGs66lhh+IhiTviEbNgO2fRmkQxYvs 5DVw== 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=b64va1dQZUrtgC94WcWHR793Whf9AVZEfhHlsiV2aw/YCB/J1nQUcHmq0A2kpUQsYN 3UHGX/h2bDYzpwsLORP/tXX5htYRpLdngYHjYt2tTiTVq3q+xEHQnV9MksQvBvPNZQ1u 2KpPV6IwHeRvJw4dfWMiwnI/HfIR80ciNGYnx2PpZOY8ExCOl032LpgqDJT5yw0O55d9 nWd3mPretUKr+d2yDXXTAUfrF263DPaXNpnjz9d1S4q8kaR/vwc/MFsaQj29JOHQWTd8 uWw+h6wa+v1pqwRDbPrAKM5qPvqSXkLTslzqIvv2ijF9C1pNB6hSvHX7YU/I8v/mdah8 NJ/Q== X-Gm-Message-State: ABuFfohddu6yYcAdv0bySW4nr1FCbKMPipOpRM2Hs9oYM98YtB5eK0rX +uzUxhaJ0lz44yZG4cka/rI= X-Google-Smtp-Source: ACcGV62CSxrRI0KmafYvfiu/kVZDeqOLWCMbM2JNGkQpe2G3kHGkPG/NMzey2SeVUcG2UeijApsIeA== X-Received: by 2002:a17:902:4c85:: with SMTP id b5-v6mr22056163ple.126.1539902904676; Thu, 18 Oct 2018 15:48:24 -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 v81-v6sm38129268pfj.25.2018.10.18.15.48.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Oct 2018 15:48:24 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v5 17/18] of: unittest: find overlays[] entry by name instead of index Date: Thu, 18 Oct 2018 15:46:35 -0700 Message-Id: <1539902796-8382-18-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539902796-8382-1-git-send-email-frowand.list@gmail.com> References: <1539902796-8382-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 Thu Oct 18 22:46:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 986398 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 42blk847pJz9s9J for ; Fri, 19 Oct 2018 10:34: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="bS42HXUe"; 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 42blk82VsVzF3SB for ; Fri, 19 Oct 2018 10:34: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="bS42HXUe"; 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="bS42HXUe"; 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 42bkjS127LzF3FW for ; Fri, 19 Oct 2018 09:48:28 +1100 (AEDT) Received: by mail-pl1-x642.google.com with SMTP id f8-v6so14982617plb.2 for ; Thu, 18 Oct 2018 15:48:27 -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=bS42HXUezmRWOh8roQa+wEPw6WPzcKdYOato/jsp11VbhXCEB2SkyjtGKTOicK/VSL rIZS5H19AJagbC7r7oqWfgXfjibdGSzvMCQ45ATpYJacPgehvE+iOaBQehMSgT44DOSx LLDgDTy1BnYE5BxAig3Wghckm4PoMsMDExZiDYB0GcG6Q5rVX7ArS8wK/1PiOu7O7dr/ bFTviyYKBFinVZbTBVkc/KajKLn9+iDsoJWWG8WfPur7XGynf0BvvxRLBQUrET02Rmvr QRP8wmLMlvkH0Xa30yafQJ6u4cWL+uKSmLP1xUvguQfV4dazlOS7H3ecLb0lnQpgO0aU sJjA== 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=BVr3a1i7Byfe7+/DFAJfqVfuTFMTSxrz7kpv+rZtM/euFBAvRg3S1nCuCNMTMd55qn 96EOkJqCVf6BtxVsmx+MW/pk18onr9nw+54PQHvLCmjHZnguf9czN3PGUS3i8Ar85NFE gBzmJy1WQvy8dpYs/CZ61nKN3H6lQ0cOdF/QLXa8xzECVi+SC/phPiRBtaVcz2QdRXWt gae3IsAFYdH2uB8Ws7msj5H/gtKoQupyYTrxwgEej+feN5SwLIzTaqAIKMrHZHY9VU0o /gqqEJzcsZGPPhDoJQYPfGJ1CxNPuPDUphDwOQ78pVjSKnjEEOQxFY73VDjraG4XzvFp WUcw== X-Gm-Message-State: ABuFfogz+aax8UkM4jZ2xklwvcJRQoC2U9zmzLWLIDVr9pZn07EmeJAW BoCRe2O7ZlQ8q4xhcKFFUj4= X-Google-Smtp-Source: ACcGV63N2cmQnNW5vLNZsxiRb0dsYDWNSCpiDKyw3ENb73gsToWKhTq+KQ3mamwmKcPYm8ZBkpMo6Q== X-Received: by 2002:a17:902:7613:: with SMTP id k19-v6mr566453pll.98.1539902905750; Thu, 18 Oct 2018 15:48:25 -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 v81-v6sm38129268pfj.25.2018.10.18.15.48.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Oct 2018 15:48:25 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Subject: [PATCH v5 18/18] of: unittest: initialize args before calling of_*parse_*() Date: Thu, 18 Oct 2018 15:46:36 -0700 Message-Id: <1539902796-8382-19-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539902796-8382-1-git-send-email-frowand.list@gmail.com> References: <1539902796-8382-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 */