From patchwork Mon Feb 13 18:56:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 653309 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 145F3C64EC7 for ; Mon, 13 Feb 2023 18:57:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230201AbjBMS5s (ORCPT ); Mon, 13 Feb 2023 13:57:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230160AbjBMS5r (ORCPT ); Mon, 13 Feb 2023 13:57:47 -0500 Received: from mail-oa1-x2b.google.com (mail-oa1-x2b.google.com [IPv6:2001:4860:4864:20::2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D347126E5; Mon, 13 Feb 2023 10:57:46 -0800 (PST) Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-16a7f5b6882so16261768fac.10; Mon, 13 Feb 2023 10:57:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kHyn+Iq5kDFceNl3I1U0GgQ46vN33MHSRz9J5NGp5vU=; b=U7JpZQ1g9CQpoTz6vURu+kEOjs3644ilNrBedisqBKcqVEJHUBlupRfJwgqLsatmsW nZHnilMgjXEPezYlYBRISCkAKZGV+fgpAIUhvbUZi5HT8luC7CAgOVKsFgGrnIF6c0cI cxtvgvmk2o+ln4w1Uibo3ZNNoLaTgt+emFpNFbhSZFeDsDX643H6GaXxD0icFkiZozpT dlPqzwIHj46a3GTF/SxKI+xJeTQsttNdKdswDP2Ld7K+FMPbs76kTRln7sIrob3ptVNc NsEXnOu9SXViqe+DPs2TdQq88esSxvTWT+WDv9jHUohu+p2n6DPxGQJ+JWfmV4AtOy3w ajGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kHyn+Iq5kDFceNl3I1U0GgQ46vN33MHSRz9J5NGp5vU=; b=3cAdeUm0TkH4fEzm0wuLTl1Gy/GRN//C7I5q0RxJAitSNCdFQyxee62JUIFXFbd8pH G75qmT3mG5x4NUm3PKH2lerBZVSx/O4V8XvhRdb3BK78JEilQFZ1DZc5kkId8BRiuaq1 i20V6XHz38+UDqQRbRNclm3QdYHoh6gJjh3TNaDzvqmgbdUJXSO6ojaQPVoOMfvTTE1j ad76h5rGF+LNoTDKw2PfgldzV6WMwOyFSVBpM6w5SHwYkcIXLjrYRXfBAfVPAtJPXPsB hvfoW4Xhnz0xkGdYGdX0ucIwlP0UaxYn0WaDVn9kHOp8xa+EEQRPS5BptsnFVzIs8SYW Znhg== X-Gm-Message-State: AO0yUKU+5aN5wmH38b2gxrPXg2yq2WtJ2nAU2lgZ0av7VTs9oZxJXKp3 dGEpuBHE5yEmkRv+dxOLQmE= X-Google-Smtp-Source: AK7set+2LBWf35QE6xiy+azV7ia9bEwuLtOMhN18OWjoNN6uPJXsvHXV3Rw4TohnNyc7Bof3k4snHw== X-Received: by 2002:a05:6870:470e:b0:16a:a965:87e0 with SMTP id b14-20020a056870470e00b0016aa96587e0mr10937388oaq.54.1676314665730; Mon, 13 Feb 2023 10:57:45 -0800 (PST) Received: from xps8900.attlocal.net ([2600:1700:2442:6db0:5829:dabf:a50e:e9f2]) by smtp.gmail.com with ESMTPSA id ef15-20020a0568701a8f00b0016df97ab05bsm1654958oab.31.2023.02.13.10.57.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 10:57:45 -0800 (PST) From: Frank Rowand To: Rob Herring Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/7] of: update kconfig unittest help Date: Mon, 13 Feb 2023 12:56:58 -0600 Message-Id: <20230213185702.395776-4-frowand.list@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230213185702.395776-1-frowand.list@gmail.com> References: <20230213185702.395776-1-frowand.list@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add more information about the impact the of unittests have on the live devicetree and why the tests should only be enabled for developer kernels. Add information about processing the test output such that the results are more complete and comprehendable. Signed-off-by: Frank Rowand --- drivers/of/Kconfig | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index 80b5fd44ab1c..644386833a7b 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig @@ -23,7 +23,19 @@ config OF_UNITTEST that are executed once at boot time, and the results dumped to the console. - If unsure, say N here, but this option is safe to enable. + This option should only be enabled for a development kernel. The tests + will taint the kernel with TAINT_TEST. The tests will cause ERROR and + WARNING messages to print on the console. The tests will cause stack + traces to print on the console. It is possible that the tests will + leave the devicetree in a corrupted state. + + The unittest output will be verbose. Copy the output to a file + via capturing the console output or via the dmesg command. Process + this file with scripts/dtc/of_unittest_expect to reduce the + verbosity, test whether expected output is present, and to + summarize the results. + + If unsure, say N here. This option is not safe to enable. config OF_ALL_DTBS bool "Build all Device Tree Blobs" From patchwork Mon Feb 13 18:57:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 653308 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E38EDC636D4 for ; Mon, 13 Feb 2023 18:57:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230344AbjBMS5x (ORCPT ); Mon, 13 Feb 2023 13:57:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230216AbjBMS5t (ORCPT ); Mon, 13 Feb 2023 13:57:49 -0500 Received: from mail-oa1-x30.google.com (mail-oa1-x30.google.com [IPv6:2001:4860:4864:20::30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C52ECE; Mon, 13 Feb 2023 10:57:48 -0800 (PST) Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-16aa71c1600so16261621fac.11; Mon, 13 Feb 2023 10:57:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=25JgBmt061z2zUT7Rn2AWSIssQrUdgZ1DK2ZqeBawkI=; b=L084l8ve1Ciy9gxw+ILSf96unYRjmyPf/PxoHxG+SxAAX/2DkIR2JvJHS2CqbB8XjA kw+KBbylhH6Ewqr6jyhyjsOPA9LaRrWw1f9I/okg+5dHf0DDj8PKvJwLQNddwuez8X6l Jkn4NWYHgEK5+pvjxE38jgrCXnkuBStmnktqTWGfVWyGsTiQVPO2UxRr/hwQqdqVSi52 crKpqNqQDwXs4fJVe3fR0uMIQ6Dnid2mZLM0tYl/nYcWPeWq4iVAxM4sB4fvG+Qn3OHJ coJcHRycyNmV9ebEADPcWVT7Mso4QDkl/Fhzg8b/3Ol6f78ao/Bcc9O5nqg7vC6Tlhc5 CaAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=25JgBmt061z2zUT7Rn2AWSIssQrUdgZ1DK2ZqeBawkI=; b=2xv3sHDq5bEc+08inDKH5JBgp8H4VuOmjOky6AHwYGZWJuG5cxm4XW3PDftJUdlGtC fU/gtB2Qr33QudRKtnlhpJb3Xe9QGBeo8Cuc+3XnExUrRghfbps2aONiOBokoSWz9NXi HEHuujSH+WE3KXq+fSpdtnIjx8SLDcJ75ZQc2vnhpSj4t+feP1vOf3yvB1wDbp8nS+O6 kBZh6kwgERp2/zidNjaiTC5JBF+zRXQyu/p/cEtqPq9gkAABU4girkOHCB9uvH2UHTxf YfePILTJtwjKIEJcjEuDCHeqHpNTaGlS+slrInoLwAK5eLUjZTYGUtUC/f6YWV5oXRhY YCMA== X-Gm-Message-State: AO0yUKWhrLQmEdD5FaRLzeEThtxt6qCNvPunUhGQBmj3WzlON54r5D9R wEtVQAfZu6dA0I0x9idcmv+78PhxGng= X-Google-Smtp-Source: AK7set8zPRWtI61BPb9IaZ/DhhTOYGxaoLctcu5yQ2PxdMyaLws4rgQgo9e+eoi7a0GTR4Q3i8547A== X-Received: by 2002:a05:6870:d1c5:b0:16d:f4aa:2c9c with SMTP id b5-20020a056870d1c500b0016df4aa2c9cmr4072490oac.33.1676314667421; Mon, 13 Feb 2023 10:57:47 -0800 (PST) Received: from xps8900.attlocal.net ([2600:1700:2442:6db0:5829:dabf:a50e:e9f2]) by smtp.gmail.com with ESMTPSA id ef15-20020a0568701a8f00b0016df97ab05bsm1654958oab.31.2023.02.13.10.57.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 10:57:46 -0800 (PST) From: Frank Rowand To: Rob Herring Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/7] of: do not use "%pOF" printk format on node with refcount of zero Date: Mon, 13 Feb 2023 12:57:00 -0600 Message-Id: <20230213185702.395776-6-frowand.list@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230213185702.395776-1-frowand.list@gmail.com> References: <20230213185702.395776-1-frowand.list@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org of_node_release() can not use the "%pOF" printk format to report the node name of a node when the node reference count is zero. This is because the formatter device_node_string() calls fwnode_full_name_string() which indirectly calls of_node_get(). Calling of_node_get() on the node with a zero reference count results in a WARNING and stack trace. When the reference count has been decremented to zero, this function is in the subsequent call path which frees memory related to the node. This commit resolves the unittest EXPECT errors that were created in the previous commmit. Signed-off-by: Frank Rowand --- The scripts/dtc/of_unittest_expect summary statistics before this commit: ** EXPECT statistics: ** ** non-zero values expected: ** ** EXPECT found : 50 ** EXPECT_NOT not found : 4 ** ** zero values expected: ** ** EXPECT not found : 0 ** missing EXPECT begin : 5 ** missing EXPECT end : 0 ** ** EXPECT_NOT found : 0 ** missing EXPECT_NOT begin : 0 ** missing EXPECT_NOT end : 0 ** ** unittest FAIL : 0 ** internal error : 0 The scripts/dtc/of_unittest_expect summary statistics after this commit: ** EXPECT statistics: ** ** non-zero values expected: ** ** EXPECT found : 55 ** EXPECT_NOT not found : 4 ** ** zero values expected: ** ** EXPECT not found : 0 ** missing EXPECT begin : 0 ** missing EXPECT end : 0 ** ** EXPECT_NOT found : 0 ** missing EXPECT_NOT begin : 0 ** missing EXPECT_NOT end : 0 ** ** unittest FAIL : 0 ** internal error : 0 drivers/of/dynamic.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index becb80f762c8..dbcbc41f3465 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -329,9 +329,17 @@ void of_node_release(struct kobject *kobj) { struct device_node *node = kobj_to_device_node(kobj); + /* + * can not use '"%pOF", node' in pr_err() calls from this function + * because an of_node_get(node) when refcount is already zero + * will result in an error and a stack dump + */ + /* We should never be releasing nodes that haven't been detached. */ if (!of_node_check_flag(node, OF_DETACHED)) { - pr_err("ERROR: Bad of_node_put() on %pOF\n", node); + + pr_err("ERROR: %s() detected bad of_node_put() on %pOF/%s\n", + __func__, node->parent, node->full_name); /* * of unittests will test this path. Do not print the stack From patchwork Mon Feb 13 18:57:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 653307 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C77EC636CC for ; Mon, 13 Feb 2023 18:58:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230378AbjBMS6B (ORCPT ); Mon, 13 Feb 2023 13:58:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230315AbjBMS5v (ORCPT ); Mon, 13 Feb 2023 13:57:51 -0500 Received: from mail-oa1-x2b.google.com (mail-oa1-x2b.google.com [IPv6:2001:4860:4864:20::2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97482212F; Mon, 13 Feb 2023 10:57:48 -0800 (PST) Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-16a7f5b6882so16261904fac.10; Mon, 13 Feb 2023 10:57:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=70NV1ToQYw50ymKhliFnw04sCbSTdpnLCftKunJ8RHg=; b=g9sh5Qacww+llc+gZ856ZATND/GgMxZmJwDrrtBnaKgEjkHC9HhL54iHcxadntNZe4 GRl3VCNHl6m76J0dEebp8wkYjxq796dfRE1az472jTwiWwcTUY4buwcCj59n1ZADxf+y sD+qVetPtACRyLrtREXLIhnjO7Gzk9Rj1ikXBkJL3KKhhoTsvjJIBZYcPqAasR/IJAyP 5mA3P7Eiv4/c8Ty1/S9VKNG/i9nR+9zMfnPyqgGcKqu9cugjiItlBaBVKDQ6xUYwisVK 8tou11iSWFraZ1qBqqshAHKBu0RrdFVSbESIIuDSCWumnjWUuajZz5ZXiVQwQQjVEO9Y GD+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=70NV1ToQYw50ymKhliFnw04sCbSTdpnLCftKunJ8RHg=; b=UEX4beqUh/ySTAoGzvytlBfO/za9kg0fsjApiox0RbOf5ckMCPBblU8g5ReqfgPMIR FFM9BbYq5TlVP/k6U2nGkWwkHolvoM+pG4hpL306dNoH93F6lS6aRI+orsvDWSFmljhY ZexHPyfa+ydsU48vJVOrxQ6sVIBdNi8yLewv0QD5P5EUoShS6ZXpld1ZGMOwlZryG5CZ TNL6rERpenGAW0AlqvjkpIp6l4VdIGs/xRq3+fNXlxFmXJetQRUv4ik1Q42/xlPYfmRZ 3zOQVpR+58oPaFSvGYH3HU0K+fuF7eDzjF2rZ8QoW12jJS6sGPjoKvx7JiLcKNw8IU2o AA3w== X-Gm-Message-State: AO0yUKXNJHIg6tMcoiiOL4tVoEA3XkSTKg5OMh8NmZygcD7U+6YKiIDL N+1ZumBle1v6Bf5zIltpoqc= X-Google-Smtp-Source: AK7set+cvl5+hpmINRUSDSryaTu8+KC6HXmo+LEi3o7wg74EiR7EvbaCqJUXMaN5mxLyhJKZxk7/2Q== X-Received: by 2002:a05:6870:c68c:b0:16d:bbce:29d6 with SMTP id cv12-20020a056870c68c00b0016dbbce29d6mr6703085oab.25.1676314668277; Mon, 13 Feb 2023 10:57:48 -0800 (PST) Received: from xps8900.attlocal.net ([2600:1700:2442:6db0:5829:dabf:a50e:e9f2]) by smtp.gmail.com with ESMTPSA id ef15-20020a0568701a8f00b0016df97ab05bsm1654958oab.31.2023.02.13.10.57.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 10:57:47 -0800 (PST) From: Frank Rowand To: Rob Herring Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/7] of: add consistency check to of_node_release() Date: Mon, 13 Feb 2023 12:57:01 -0600 Message-Id: <20230213185702.395776-7-frowand.list@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230213185702.395776-1-frowand.list@gmail.com> References: <20230213185702.395776-1-frowand.list@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add an additional consistency check to of_node_release(), which is called when the reference count of a devicetree node is decremented to zero. The node's children should have been deleted before the node is deleted so check that no children exist. Signed-off-by: Frank Rowand --- drivers/of/dynamic.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index dbcbc41f3465..657a65006056 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -377,6 +377,10 @@ void of_node_release(struct kobject *kobj) __func__, node); } + if (node->child) + pr_err("ERROR: %s() unexpected children for %pOF/%s\n", + __func__, node->parent, node->full_name); + property_list_free(node->properties); property_list_free(node->deadprops); fwnode_links_purge(of_fwnode_handle(node));