The use of of_property_read_bool() for non-boolean properties is
deprecated. The primary use of it was to test property presence, but
that has been replaced in favor of of_property_present(). With those
uses now fixed, add a warning to discourage new ones.
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
---
drivers/of/property.c | 26 ++++++++++++++++++++++++++
include/linux/of.h | 25 +++++++------------------
2 files changed, 33 insertions(+), 18 deletions(-)
diff --git a/drivers/of/property.c b/drivers/of/property.c
index 1b46be88cc0498fcbe74e7b988f22a86245c366e..9a6d84d19ff371def8bedc009bb6ab488458a29b 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -31,6 +31,32 @@
#include "of_private.h"
+/**
+ * of_property_read_bool - Find a property
+ * @np: device node from which the property value is to be read.
+ * @propname: name of the property to be searched.
+ *
+ * Search for a boolean property in a device node. Usage on non-boolean
+ * property types is deprecated.
+ *
+ * Return: true if the property exists false otherwise.
+ */
+bool of_property_read_bool(const struct device_node *np, const char *propname)
+{
+ struct property *prop = of_find_property(np, propname, NULL);
+
+ /*
+ * Boolean properties should not have a value. Testing for property
+ * presence should either use of_property_present() or just read the
+ * property value and check the returned error code.
+ */
+ if (prop && prop->length)
+ pr_warn("%pOF: Read of boolean property '%s' with a value.\n", np, propname);
+
+ return prop ? true : false;
+}
+EXPORT_SYMBOL(of_property_read_bool);
+
/**
* of_graph_is_present() - check graph's presence
* @node: pointer to device_node containing graph port
diff --git a/include/linux/of.h b/include/linux/of.h
index 1cb4eb7fc2eded2246c697c3bcaf1b85d43108ab..0cdd58ff0a4190724309ba1eddbac51b188b6136 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -311,6 +311,7 @@ extern struct device_node *of_find_node_with_property(
extern struct property *of_find_property(const struct device_node *np,
const char *name,
int *lenp);
+extern bool of_property_read_bool(const struct device_node *np, const char *propname);
extern int of_property_count_elems_of_size(const struct device_node *np,
const char *propname, int elem_size);
extern int of_property_read_u32_index(const struct device_node *np,
@@ -615,6 +616,12 @@ static inline struct device_node *of_find_compatible_node(
return NULL;
}
+static inline bool of_property_read_bool(const struct device_node *np,
+ const char *propname)
+{
+ return false;
+}
+
static inline int of_property_count_elems_of_size(const struct device_node *np,
const char *propname, int elem_size)
{
@@ -1242,24 +1249,6 @@ static inline int of_property_read_string_index(const struct device_node *np,
return rc < 0 ? rc : 0;
}
-/**
- * of_property_read_bool - Find a property
- * @np: device node from which the property value is to be read.
- * @propname: name of the property to be searched.
- *
- * Search for a boolean property in a device node. Usage on non-boolean
- * property types is deprecated.
- *
- * Return: true if the property exists false otherwise.
- */
-static inline bool of_property_read_bool(const struct device_node *np,
- const char *propname)
-{
- const struct property *prop = of_find_property(np, propname, NULL);
-
- return prop ? true : false;
-}
-
/**
* of_property_present - Test if a property is present in a node
* @np: device node to search for the property.
--
2.45.2
Hi Rob,
On Thu, Jan 9, 2025 at 8:42 PM Rob Herring (Arm) <robh@kernel.org> wrote:
> The use of of_property_read_bool() for non-boolean properties is
> deprecated. The primary use of it was to test property presence, but
> that has been replaced in favor of of_property_present(). With those
> uses now fixed, add a warning to discourage new ones.
>
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Thanks for your patch, which is now commit c141ecc3cecd7647 ("of:
Warn when of_property_read_bool() is used on non-boolean properties")
in dt-rh/for-next.
I have bisected a failure in secondary CPU bring-up on R-Car H1 (quad
Cortex-A9 MPCore) to this commit:
Detected Renesas R-Car Gen1 r8a7779 ES1.0
smp: Bringing up secondary CPUs ...
-CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
-CPU1: Spectre v2: using BPIALL workaround
-CPU2: thread -1, cpu 2, socket 0, mpidr 80000002
-CPU2: Spectre v2: using BPIALL workaround
-CPU3: thread -1, cpu 3, socket 0, mpidr 80000003
-CPU3: Spectre v2: using BPIALL workaround
-smp: Brought up 1 node, 4 CPUs
-SMP: Total of 4 processors activated (2000.00 BogoMIPS).
+CPU1: failed to come online
+CPU2: failed to come online
+CPU3: failed to come online
+smp: Brought up 1 node, 1 CPU
+SMP: Total of 1 processors activated (500.00 BogoMIPS).
CPU: All CPU(s) started in SVC mode.
Reverting this commit on top of my work tree fixes the issue, too.
However, I do not see how this commit could impact CPU bring-up?
I added debug code to of_property_read_bool(), to print all look-ups.
I only saw a few before CPU bring-up, nothing relevant:
NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
+OF: of_property_read_bool(interrupt-controller): 1
rcu: srcu_init: Setting srcu_struct sizes based on contention.
+OF: of_property_read_bool(interrupt-controller): 1
sched_clock: 64 bits at 250MHz, resolution 4ns, wraps every 4398046511102ns
clocksource: arm_global_timer: mask: 0xffffffffffffffff
max_cycles: 0x7350b89c29, max_idle_ns: 881590431910 ns
Switching to timer-based delay loop, resolution 4ns
+OF: of_property_read_bool(interrupt-controller): 1
+OF: of_property_read_bool(always-on): 0
Console: colour dummy device 80x30
printk: legacy console [tty0] enabled
Perhaps something shifted in the code layout? The obvious suspects
(shmobile_boot_* and shmobile_smp_* asm code, secondary_startup(),
addresses in arch/arm/mach-shmobile/platsmp-scu.c) are still at the
same addresses as before...
Anyone with a clue?
Thanks!
> --- a/drivers/of/property.c
> +++ b/drivers/of/property.c
> @@ -31,6 +31,32 @@
>
> #include "of_private.h"
>
> +/**
> + * of_property_read_bool - Find a property
> + * @np: device node from which the property value is to be read.
> + * @propname: name of the property to be searched.
> + *
> + * Search for a boolean property in a device node. Usage on non-boolean
> + * property types is deprecated.
> + *
> + * Return: true if the property exists false otherwise.
> + */
> +bool of_property_read_bool(const struct device_node *np, const char *propname)
> +{
> + struct property *prop = of_find_property(np, propname, NULL);
> +
> + /*
> + * Boolean properties should not have a value. Testing for property
> + * presence should either use of_property_present() or just read the
> + * property value and check the returned error code.
> + */
> + if (prop && prop->length)
> + pr_warn("%pOF: Read of boolean property '%s' with a value.\n", np, propname);
> +
> + return prop ? true : false;
> +}
> +EXPORT_SYMBOL(of_property_read_bool);
> +
> /**
> * of_graph_is_present() - check graph's presence
> * @node: pointer to device_node containing graph port
> diff --git a/include/linux/of.h b/include/linux/of.h
> index 1cb4eb7fc2eded2246c697c3bcaf1b85d43108ab..0cdd58ff0a4190724309ba1eddbac51b188b6136 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -311,6 +311,7 @@ extern struct device_node *of_find_node_with_property(
> extern struct property *of_find_property(const struct device_node *np,
> const char *name,
> int *lenp);
> +extern bool of_property_read_bool(const struct device_node *np, const char *propname);
> extern int of_property_count_elems_of_size(const struct device_node *np,
> const char *propname, int elem_size);
> extern int of_property_read_u32_index(const struct device_node *np,
> @@ -615,6 +616,12 @@ static inline struct device_node *of_find_compatible_node(
> return NULL;
> }
>
> +static inline bool of_property_read_bool(const struct device_node *np,
> + const char *propname)
> +{
> + return false;
> +}
> +
> static inline int of_property_count_elems_of_size(const struct device_node *np,
> const char *propname, int elem_size)
> {
> @@ -1242,24 +1249,6 @@ static inline int of_property_read_string_index(const struct device_node *np,
> return rc < 0 ? rc : 0;
> }
>
> -/**
> - * of_property_read_bool - Find a property
> - * @np: device node from which the property value is to be read.
> - * @propname: name of the property to be searched.
> - *
> - * Search for a boolean property in a device node. Usage on non-boolean
> - * property types is deprecated.
> - *
> - * Return: true if the property exists false otherwise.
> - */
> -static inline bool of_property_read_bool(const struct device_node *np,
> - const char *propname)
> -{
> - const struct property *prop = of_find_property(np, propname, NULL);
> -
> - return prop ? true : false;
> -}
> -
> /**
> * of_property_present - Test if a property is present in a node
> * @np: device node to search for the property.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
On Tue, Jan 14, 2025 at 12:35 PM Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
>
> Hi Rob,
>
> On Thu, Jan 9, 2025 at 8:42 PM Rob Herring (Arm) <robh@kernel.org> wrote:
> > The use of of_property_read_bool() for non-boolean properties is
> > deprecated. The primary use of it was to test property presence, but
> > that has been replaced in favor of of_property_present(). With those
> > uses now fixed, add a warning to discourage new ones.
> >
> > Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
>
> Thanks for your patch, which is now commit c141ecc3cecd7647 ("of:
> Warn when of_property_read_bool() is used on non-boolean properties")
> in dt-rh/for-next.
>
> I have bisected a failure in secondary CPU bring-up on R-Car H1 (quad
> Cortex-A9 MPCore) to this commit:
>
> Detected Renesas R-Car Gen1 r8a7779 ES1.0
> smp: Bringing up secondary CPUs ...
> -CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
> -CPU1: Spectre v2: using BPIALL workaround
> -CPU2: thread -1, cpu 2, socket 0, mpidr 80000002
> -CPU2: Spectre v2: using BPIALL workaround
> -CPU3: thread -1, cpu 3, socket 0, mpidr 80000003
> -CPU3: Spectre v2: using BPIALL workaround
> -smp: Brought up 1 node, 4 CPUs
> -SMP: Total of 4 processors activated (2000.00 BogoMIPS).
> +CPU1: failed to come online
> +CPU2: failed to come online
> +CPU3: failed to come online
> +smp: Brought up 1 node, 1 CPU
> +SMP: Total of 1 processors activated (500.00 BogoMIPS).
> CPU: All CPU(s) started in SVC mode.
>
> Reverting this commit on top of my work tree fixes the issue, too.
> However, I do not see how this commit could impact CPU bring-up?
Strange. Perhaps the of_property_read_bool was inlined into some
special section before?
Rob
On Tue, Jan 14, 2025 at 8:19 PM Rob Herring <robh@kernel.org> wrote:
> On Tue, Jan 14, 2025 at 12:35 PM Geert Uytterhoeven
> <geert@linux-m68k.org> wrote:
> > On Thu, Jan 9, 2025 at 8:42 PM Rob Herring (Arm) <robh@kernel.org> wrote:
> > > The use of of_property_read_bool() for non-boolean properties is
> > > deprecated. The primary use of it was to test property presence, but
> > > that has been replaced in favor of of_property_present(). With those
> > > uses now fixed, add a warning to discourage new ones.
> > >
> > > Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> >
> > Thanks for your patch, which is now commit c141ecc3cecd7647 ("of:
> > Warn when of_property_read_bool() is used on non-boolean properties")
> > in dt-rh/for-next.
> >
> > I have bisected a failure in secondary CPU bring-up on R-Car H1 (quad
> > Cortex-A9 MPCore) to this commit:
> >
> > Detected Renesas R-Car Gen1 r8a7779 ES1.0
> > smp: Bringing up secondary CPUs ...
> > -CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
> > -CPU1: Spectre v2: using BPIALL workaround
> > -CPU2: thread -1, cpu 2, socket 0, mpidr 80000002
> > -CPU2: Spectre v2: using BPIALL workaround
> > -CPU3: thread -1, cpu 3, socket 0, mpidr 80000003
> > -CPU3: Spectre v2: using BPIALL workaround
> > -smp: Brought up 1 node, 4 CPUs
> > -SMP: Total of 4 processors activated (2000.00 BogoMIPS).
> > +CPU1: failed to come online
> > +CPU2: failed to come online
> > +CPU3: failed to come online
> > +smp: Brought up 1 node, 1 CPU
> > +SMP: Total of 1 processors activated (500.00 BogoMIPS).
> > CPU: All CPU(s) started in SVC mode.
> >
> > Reverting this commit on top of my work tree fixes the issue, too.
> > However, I do not see how this commit could impact CPU bring-up?
>
> Strange. Perhaps the of_property_read_bool was inlined into some
> special section before?
I re-added the old inline of_property_read_bool(), but with a different
name. CPU bringup starts working again if I replace at least one call
to of_property_read_bool() in arch/arm/mm/cache-l2x0.c:aurora_of_parse()
by a call to the inline variant, or even if I just add
pr_info("xf_property_read_bool(np, \"wt-override\") = %d\n",
xf_property_read_bool(np, "wt-override"));
to that function. Note that that function is not called at all on my platform.
This small change causes quite some reordering in arch/arm/mm/cache-l2x0.s,
so it looks like a layout issue. More analysis will follow...
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
On Wed, 15 Jan 2025 at 12:20, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> On Tue, Jan 14, 2025 at 8:19 PM Rob Herring <robh@kernel.org> wrote:
> > On Tue, Jan 14, 2025 at 12:35 PM Geert Uytterhoeven
> > <geert@linux-m68k.org> wrote:
> > > On Thu, Jan 9, 2025 at 8:42 PM Rob Herring (Arm) <robh@kernel.org> wrote:
> > > > The use of of_property_read_bool() for non-boolean properties is
> > > > deprecated. The primary use of it was to test property presence, but
> > > > that has been replaced in favor of of_property_present(). With those
> > > > uses now fixed, add a warning to discourage new ones.
> > > >
> > > > Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> > >
> > > Thanks for your patch, which is now commit c141ecc3cecd7647 ("of:
> > > Warn when of_property_read_bool() is used on non-boolean properties")
> > > in dt-rh/for-next.
> > >
> > > I have bisected a failure in secondary CPU bring-up on R-Car H1 (quad
> > > Cortex-A9 MPCore) to this commit:
> > >
> > > Detected Renesas R-Car Gen1 r8a7779 ES1.0
> > > smp: Bringing up secondary CPUs ...
> > > -CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
> > > -CPU1: Spectre v2: using BPIALL workaround
> > > -CPU2: thread -1, cpu 2, socket 0, mpidr 80000002
> > > -CPU2: Spectre v2: using BPIALL workaround
> > > -CPU3: thread -1, cpu 3, socket 0, mpidr 80000003
> > > -CPU3: Spectre v2: using BPIALL workaround
> > > -smp: Brought up 1 node, 4 CPUs
> > > -SMP: Total of 4 processors activated (2000.00 BogoMIPS).
> > > +CPU1: failed to come online
> > > +CPU2: failed to come online
> > > +CPU3: failed to come online
> > > +smp: Brought up 1 node, 1 CPU
> > > +SMP: Total of 1 processors activated (500.00 BogoMIPS).
> > > CPU: All CPU(s) started in SVC mode.
> > >
> > > Reverting this commit on top of my work tree fixes the issue, too.
> > > However, I do not see how this commit could impact CPU bring-up?
> >
> > Strange. Perhaps the of_property_read_bool was inlined into some
> > special section before?
>
> I re-added the old inline of_property_read_bool(), but with a different
> name. CPU bringup starts working again if I replace at least one call
> to of_property_read_bool() in arch/arm/mm/cache-l2x0.c:aurora_of_parse()
> by a call to the inline variant, or even if I just add
>
> pr_info("xf_property_read_bool(np, \"wt-override\") = %d\n",
> xf_property_read_bool(np, "wt-override"));
>
> to that function. Note that that function is not called at all on my platform.
>
> This small change causes quite some reordering in arch/arm/mm/cache-l2x0.s,
> so it looks like a layout issue. More analysis will follow...
The assembler SMP bring-up code for Renesas SoCs lacked an alignment
directive. I have posted a fix:
https://lore.kernel.org/r/CAMuHMdU=QR-JLgEHKWpsr6SbaZRc-Hz9r91JfpP8c3n2G-OjqA@mail.gmail.com
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
On Tue, Jan 14, 2025 at 07:35:22PM +0100, Geert Uytterhoeven wrote:
> Hi Rob,
>
> On Thu, Jan 9, 2025 at 8:42 PM Rob Herring (Arm) <robh@kernel.org> wrote:
> > The use of of_property_read_bool() for non-boolean properties is
> > deprecated. The primary use of it was to test property presence, but
> > that has been replaced in favor of of_property_present(). With those
> > uses now fixed, add a warning to discourage new ones.
> >
> > Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
>
> Thanks for your patch, which is now commit c141ecc3cecd7647 ("of:
> Warn when of_property_read_bool() is used on non-boolean properties")
> in dt-rh/for-next.
>
> I have bisected a failure in secondary CPU bring-up on R-Car H1 (quad
> Cortex-A9 MPCore) to this commit:
>
> Detected Renesas R-Car Gen1 r8a7779 ES1.0
> smp: Bringing up secondary CPUs ...
> -CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
> -CPU1: Spectre v2: using BPIALL workaround
> -CPU2: thread -1, cpu 2, socket 0, mpidr 80000002
> -CPU2: Spectre v2: using BPIALL workaround
> -CPU3: thread -1, cpu 3, socket 0, mpidr 80000003
> -CPU3: Spectre v2: using BPIALL workaround
> -smp: Brought up 1 node, 4 CPUs
> -SMP: Total of 4 processors activated (2000.00 BogoMIPS).
> +CPU1: failed to come online
> +CPU2: failed to come online
> +CPU3: failed to come online
> +smp: Brought up 1 node, 1 CPU
> +SMP: Total of 1 processors activated (500.00 BogoMIPS).
> CPU: All CPU(s) started in SVC mode.
>
> Reverting this commit on top of my work tree fixes the issue, too.
> However, I do not see how this commit could impact CPU bring-up?
>
> I added debug code to of_property_read_bool(), to print all look-ups.
> I only saw a few before CPU bring-up, nothing relevant:
>
> NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
> +OF: of_property_read_bool(interrupt-controller): 1
> rcu: srcu_init: Setting srcu_struct sizes based on contention.
> +OF: of_property_read_bool(interrupt-controller): 1
> sched_clock: 64 bits at 250MHz, resolution 4ns, wraps every 4398046511102ns
> clocksource: arm_global_timer: mask: 0xffffffffffffffff
> max_cycles: 0x7350b89c29, max_idle_ns: 881590431910 ns
> Switching to timer-based delay loop, resolution 4ns
> +OF: of_property_read_bool(interrupt-controller): 1
> +OF: of_property_read_bool(always-on): 0
> Console: colour dummy device 80x30
> printk: legacy console [tty0] enabled
>
> Perhaps something shifted in the code layout? The obvious suspects
> (shmobile_boot_* and shmobile_smp_* asm code, secondary_startup(),
> addresses in arch/arm/mach-shmobile/platsmp-scu.c) are still at the
> same addresses as before...
>
> Anyone with a clue?
Hmm... You meant the patch 2 troubles this?
--
With Best Regards,
Andy Shevchenko
On Thu, Jan 09, 2025 at 01:42:06PM -0600, Rob Herring (Arm) wrote: > The use of of_property_read_bool() for non-boolean properties is > deprecated. The primary use of it was to test property presence, but > that has been replaced in favor of of_property_present(). With those > uses now fixed, add a warning to discourage new ones. > > Signed-off-by: Rob Herring (Arm) <robh@kernel.org> > --- > drivers/of/property.c | 26 ++++++++++++++++++++++++++ > include/linux/of.h | 25 +++++++------------------ > 2 files changed, 33 insertions(+), 18 deletions(-) Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org> Best regards, Krzysztof
© 2016 - 2026 Red Hat, Inc.