public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Rob Herring <robh@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v2] arm64: Simplify checking for populated DT
Date: Fri, 29 Oct 2021 16:01:25 +0100	[thread overview]
Message-ID: <20211029150125.GE24060@lakrids.cambridge.arm.com> (raw)
In-Reply-To: <20211029144055.2365814-1-robh@kernel.org>

On Fri, Oct 29, 2021 at 09:40:55AM -0500, Rob Herring wrote:
> Use of the of_scan_flat_dt() function predates libfdt and is discouraged
> as libfdt provides a nicer set of APIs. Rework dt_scan_depth1_nodes to
> use libfdt calls directly, and rename it to dt_is_stub() to reflect
> exactly what it checking.
> 
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Signed-off-by: Rob Herring <robh@kernel.org>

Thanks for reworking this; it looks good to me:

Reviewed-by: Mark Rutland <mark.rutland@arm.com>

Thanks,
Mark.

> ---
> v2:
>  - Keep checking for only stub nodes
> 
>  arch/arm64/kernel/acpi.c | 35 ++++++++++++++---------------------
>  1 file changed, 14 insertions(+), 21 deletions(-)
> 
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index 1c9c2f7a1c04..7df733427e04 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -22,6 +22,7 @@
>  #include <linux/irq_work.h>
>  #include <linux/memblock.h>
>  #include <linux/of_fdt.h>
> +#include <linux/libfdt.h>
>  #include <linux/smp.h>
>  #include <linux/serial_core.h>
>  #include <linux/pgtable.h>
> @@ -62,29 +63,22 @@ static int __init parse_acpi(char *arg)
>  }
>  early_param("acpi", parse_acpi);
>  
> -static int __init dt_scan_depth1_nodes(unsigned long node,
> -				       const char *uname, int depth,
> -				       void *data)
> +static bool __init dt_is_stub(void)
>  {
> -	/*
> -	 * Ignore anything not directly under the root node; we'll
> -	 * catch its parent instead.
> -	 */
> -	if (depth != 1)
> -		return 0;
> +	int node;
>  
> -	if (strcmp(uname, "chosen") == 0)
> -		return 0;
> +	fdt_for_each_subnode(node, initial_boot_params, 0) {
> +		const char *name = fdt_get_name(initial_boot_params, node, NULL);
> +		if (strcmp(name, "chosen") == 0)
> +			continue;
> +		if (strcmp(name, "hypervisor") == 0 &&
> +		    of_flat_dt_is_compatible(node, "xen,xen"))
> +			continue;
>  
> -	if (strcmp(uname, "hypervisor") == 0 &&
> -	    of_flat_dt_is_compatible(node, "xen,xen"))
> -		return 0;
> +		return false;
> +	}
>  
> -	/*
> -	 * This node at depth 1 is neither a chosen node nor a xen node,
> -	 * which we do not expect.
> -	 */
> -	return 1;
> +	return true;
>  }
>  
>  /*
> @@ -205,8 +199,7 @@ void __init acpi_boot_table_init(void)
>  	 *   and ACPI has not been [force] enabled (acpi=on|force)
>  	 */
>  	if (param_acpi_off ||
> -	    (!param_acpi_on && !param_acpi_force &&
> -	     of_scan_flat_dt(dt_scan_depth1_nodes, NULL)))
> +	    (!param_acpi_on && !param_acpi_force && !dt_is_stub()))
>  		goto done;
>  
>  	/*
> -- 
> 2.32.0
> 

  reply	other threads:[~2021-10-29 15:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-29 14:40 [PATCH v2] arm64: Simplify checking for populated DT Rob Herring
2021-10-29 15:01 ` Mark Rutland [this message]
2021-12-06 17:29 ` Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211029150125.GE24060@lakrids.cambridge.arm.com \
    --to=mark.rutland@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=robh@kernel.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox