From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E8746CF11DF for ; Thu, 10 Oct 2024 12:16:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5ySE9bNSKuT5qYnSnWDCToMZ5mkB6pocEqRxSb9gaG0=; b=EVGbilh+nnTnBUNA0bG1VVDc7G dPXqrfylQ/5szdti7rSjMy8UVb30PJTrOZoq7ae+83F2AOqxFUoNbC5QtQz5wrf4hDeGbBZ8l7uDg eRFsV3lmLhQTVNyjGAuPHfIBTQOMc5HI8cgQfc5Qcn/4jHpAooMUDnJtzlKZpHwsZfH+kWgqI2aWd AFOdQKphoixpzShx/xcnf9hyE5IaWcntUav3NoRMqDKKoPo87yvWeYXsJkwDh1wqJmian02ZnSxfO oNDhGaYppe3mufgwMlIERm1oQ1F389ODGdlDCtakuyP0+UFY6R+Bm5sUl8CkFAnNzATy27a+OP4GY 9NUXMkCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sys5T-0000000Cfv6-0XTE; Thu, 10 Oct 2024 12:16:11 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syqzY-0000000CUmu-3HJI for linux-arm-kernel@bombadil.infradead.org; Thu, 10 Oct 2024 11:06:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=5ySE9bNSKuT5qYnSnWDCToMZ5mkB6pocEqRxSb9gaG0=; b=CbqGnl/gcqJhz17ICcF+1A329A 6CaSe5R1uOoxH2KD/mX+ytTMQOpSH/nMYluKZ5AsmK2woOi36oLyY38DxUmqPZjtqkgwjPc7vkFKj DeZUDmsbjHNPyUR4R1EFH9NSG8J5mYIEabpoLN25uvBFw4jo1tnnh+JYFpW7/LI4fl4YlJWSgRfc4 t8AJhivDjXMeIVqyeVKwvh7SKqjXBP2Rwqr5UQAScAqVw5G005A1zugMpcdA4/ghFUqttgqqTF1rm vEmsux0HKL+KKSoXU9IPjiHi0XYBvAOztS5PcQcLhX2AOTOJA0ug3nuMH8XGUqBAdULUZ2qq1WSv8 DVU/r3dw==; Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syqzU-00000005MAR-37n6 for linux-arm-kernel@lists.infradead.org; Thu, 10 Oct 2024 11:05:59 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 582DB497; Thu, 10 Oct 2024 04:06:23 -0700 (PDT) Received: from J2N7QTR9R3 (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1ECE93F58B; Thu, 10 Oct 2024 04:05:51 -0700 (PDT) Date: Thu, 10 Oct 2024 12:05:49 +0100 From: Mark Rutland To: Stephen Boyd Cc: Rob Herring , Saravana Kannan , linux-kernel@vger.kernel.org, patches@lists.linux.dev, David Gow , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Guenter Roeck Subject: Re: [PATCH] of: Skip kunit tests when arm64+ACPI doesn't populate root node Message-ID: References: <20241009204133.1169931-1-sboyd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241009204133.1169931-1-sboyd@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241010_120557_159785_460A9CA0 X-CRM114-Status: GOOD ( 26.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Oct 09, 2024 at 01:41:31PM -0700, Stephen Boyd wrote: > A root node is required to apply DT overlays. A root node is usually > present after commit 7b937cc243e5 ("of: Create of_root if no dtb > provided by firmware"), except for on arm64 systems booted with ACPI > tables. In that case, the root node is intentionally not populated > because it would "allow DT devices to be instantiated atop an ACPI base > system"[1]. > > Introduce an OF function that skips the kunit test if the root node > isn't populated. Limit the test to when both CONFIG_ARM64 and > CONFIG_ACPI are set, because otherwise the lack of a root node is a bug. > Make the function private and take a kunit test parameter so that it > can't be abused to test for the presence of the root node in non-test > code. > > Use this function to skip tests that require the root node. Currently > that's the DT tests and any tests that apply overlays. > > Reported-by: Guenter Roeck > Closes: https://lore.kernel.org/r/6cd337fb-38f0-41cb-b942-5844b84433db@roeck-us.net > Link: https://lore.kernel.org/r/Zd4dQpHO7em1ji67@FVFF77S0Q05N.cambridge.arm.com [1] > Fixes: 893ecc6d2d61 ("of: Add KUnit test to confirm DTB is loaded") > Signed-off-by: Stephen Boyd Acked-by: Mark Rutland Mark. > --- > drivers/of/of_kunit_helpers.c | 15 +++++++++++++++ > drivers/of/of_private.h | 3 +++ > drivers/of/of_test.c | 3 +++ > drivers/of/overlay_test.c | 3 +++ > 4 files changed, 24 insertions(+) > > diff --git a/drivers/of/of_kunit_helpers.c b/drivers/of/of_kunit_helpers.c > index 287d6c91bb37..7b3ed5a382aa 100644 > --- a/drivers/of/of_kunit_helpers.c > +++ b/drivers/of/of_kunit_helpers.c > @@ -10,6 +10,19 @@ > #include > #include > > +#include "of_private.h" > + > +/** > + * of_root_kunit_skip() - Skip test if the root node isn't populated > + * @test: test to skip if the root node isn't populated > + */ > +void of_root_kunit_skip(struct kunit *test) > +{ > + if (IS_ENABLED(CONFIG_ARM64) && IS_ENABLED(CONFIG_ACPI) && !of_root) > + kunit_skip(test, "arm64+acpi doesn't populate a root node"); > +} > +EXPORT_SYMBOL_GPL(of_root_kunit_skip); > + > #if defined(CONFIG_OF_OVERLAY) && defined(CONFIG_OF_EARLY_FLATTREE) > > static void of_overlay_fdt_apply_kunit_exit(void *ovcs_id) > @@ -36,6 +49,8 @@ int of_overlay_fdt_apply_kunit(struct kunit *test, void *overlay_fdt, > int ret; > int *copy_id; > > + of_root_kunit_skip(test); > + > copy_id = kunit_kmalloc(test, sizeof(*copy_id), GFP_KERNEL); > if (!copy_id) > return -ENOMEM; > diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h > index 04aa2a91f851..c235d6c909a1 100644 > --- a/drivers/of/of_private.h > +++ b/drivers/of/of_private.h > @@ -42,6 +42,9 @@ extern raw_spinlock_t devtree_lock; > extern struct list_head aliases_lookup; > extern struct kset *of_kset; > > +struct kunit; > +extern void of_root_kunit_skip(struct kunit *test); > + > #if defined(CONFIG_OF_DYNAMIC) > extern int of_property_notify(int action, struct device_node *np, > struct property *prop, struct property *old_prop); > diff --git a/drivers/of/of_test.c b/drivers/of/of_test.c > index c85a258bc6ae..b0557ded838f 100644 > --- a/drivers/of/of_test.c > +++ b/drivers/of/of_test.c > @@ -7,6 +7,8 @@ > > #include > > +#include "of_private.h" > + > /* > * Test that the root node "/" can be found by path. > */ > @@ -36,6 +38,7 @@ static struct kunit_case of_dtb_test_cases[] = { > > static int of_dtb_test_init(struct kunit *test) > { > + of_root_kunit_skip(test); > if (!IS_ENABLED(CONFIG_OF_EARLY_FLATTREE)) > kunit_skip(test, "requires CONFIG_OF_EARLY_FLATTREE"); > > diff --git a/drivers/of/overlay_test.c b/drivers/of/overlay_test.c > index 19a292cdeee3..7cbf9a472111 100644 > --- a/drivers/of/overlay_test.c > +++ b/drivers/of/overlay_test.c > @@ -11,6 +11,8 @@ > #include > #include > > +#include "of_private.h" > + > static const char * const kunit_node_name = "kunit-test"; > static const char * const kunit_compatible = "test,empty"; > > @@ -62,6 +64,7 @@ static void of_overlay_apply_kunit_cleanup(struct kunit *test) > struct device *dev; > struct device_node *np; > > + of_root_kunit_skip(test); > if (!IS_ENABLED(CONFIG_OF_EARLY_FLATTREE)) > kunit_skip(test, "requires CONFIG_OF_EARLY_FLATTREE for root node"); > > > base-commit: 9852d85ec9d492ebef56dc5f229416c925758edc > -- > https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/ > https://git.kernel.org/pub/scm/linux/kernel/git/sboyd/spmi.git >