* [PATCH v3] riscv: Disable M-IMSIC and M-APLIC nodes in DT passed to next stage in S mode
@ 2026-11-19 15:47 Anirudh Srinivasan
2026-11-19 21:31 ` E Shattow
2026-11-20 10:46 ` Yao Zi
0 siblings, 2 replies; 7+ messages in thread
From: Anirudh Srinivasan @ 2026-11-19 15:47 UTC (permalink / raw)
To: Yao Zi, u-boot
Cc: Tim Ouyang, Leo Liang, Tom Rini, E Shattow, Troy Mitchell,
Anirudh Srinivasan
When U-Boot is running in S mode, the DT passed to the next S mode stage
can either be the bundled in DT U-Boot and the previous M mode stage
use, or be loaded by U-Boot from some boot media. In the former case,
the M mode stage can fix up the DT to disable the M-IMSIC and M-APLIC
nodes on an AIA system (for example, OpenSBI does this fixup). These
controllers are to be managed by M-mode software, so this is done to
prevent S mode software from trying to probe them.
This fixup doesn't happen in the latter case because U-Boot loads a
fresh DT from boot media. Add a fdt fixup to do this similar to OpenSBI.
This gets rid of prints like this during linux boots.
[ 0.000000] riscv-imsic: interrupt-controller@a0000000: no parent irqs available
[ 0.000000] riscv-imsic: interrupt-controller@a0000000: failed to setup state (error -22)
[ 0.000000] OF: of_irq_init: Failed to init /soc/interrupt-controller@a0000000 ((____ptrval____)), parent (____ptrval____)
[ 10.727605] platform cc000000.interrupt-controller: deferred probe pending: platform: supplier a0000000.interrupt-controller not ready
Reviewed-by: E Shattow <e@freeshell.de>
Signed-off-by: Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
---
Changes in v3:
- Reword commit title to say M-APLIC/M-IMSIC and drop references to M Mode to avoid any confusion
- Link to v2: https://patch.msgid.link/20261119-mimsic_maplic_fixup-v2-1-e29e04bf1b76@oss.tenstorrent.com
Changes in v2:
- Rename riscv_aia_mmode_aplic_imsic_fixup to riscv_aia_mimsic_maplic_fixup
- Drop most references to OpenSBI/Linux in commit message and just use M-mode/s-mode software
- Link to v1: https://patch.msgid.link/20261118-mimsic_maplic_fixup-v1-1-52dea8f39779@oss.tenstorrent.com
---
arch/riscv/lib/fdt_fixup.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 86 insertions(+)
diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c
index 6dfd1a2d5b8..49f5b3b5bb6 100644
--- a/arch/riscv/lib/fdt_fixup.c
+++ b/arch/riscv/lib/fdt_fixup.c
@@ -117,6 +117,85 @@ int riscv_board_reserved_mem_fixup(void *fdt)
return 0;
}
+/**
+ * riscv_node_handles_mmode_external_interrupts() - Check if interrupt controller handles M-mode
+ * external interrupts
+ * @fdt: Pointer to the device tree
+ * @offset: Offset of node in DT to check
+ *
+ * Return: true if controller handles M-mode external interrupts IRQ_M_EXT (11), else false
+ */
+static bool riscv_node_handles_mmode_external_interrupts(void *fdt, int offset)
+{
+ int i, len;
+ const fdt32_t *interrupts_extended = fdt_getprop(fdt, offset, "interrupts-extended", &len);
+
+ /*
+ * Each entry is <phandle irq>. The phandle points to a riscv,cpu-intc
+ * node, whose DT binding sets #interrupt-cells = <1>, so each entry is
+ * 2 cells.
+ */
+ if (!interrupts_extended || !len || len % (2 * sizeof(u32)))
+ return false;
+ for (i = 1; i < len / sizeof(u32); i += 2) {
+ if (fdt32_to_cpu(interrupts_extended[i]) == IRQ_M_EXT)
+ return true;
+ }
+ return false;
+}
+
+/**
+ * riscv_aia_mimsic_maplic_fixup() - Disable M-APLIC and M-IMSIC nodes in DT
+ * @fdt: Pointer to the device tree in which nodes are to be disabled
+ *
+ * On RISC-V AIA systems, M-mode software manages the M-APLIC and M-IMSIC.
+ * If S-mode U-Boot loads a device tree from boot media, the DT nodes for these
+ * could still be enabled, so fixup the DT to disable these nodes before passing
+ * it to the next S-mode stage.
+ *
+ * Return: 0 on success or error otherwise.
+ */
+static int riscv_aia_mimsic_maplic_fixup(void *fdt)
+{
+ int offset, err;
+
+ /* Disable M-IMSIC in APLIC-IMSIC configuration */
+ fdt_for_each_node_by_compatible(offset, fdt, -1, "riscv,imsics") {
+ if (riscv_node_handles_mmode_external_interrupts(fdt, offset)) {
+ err = fdt_status_disabled(fdt, offset);
+ if (err < 0)
+ return err;
+ }
+ }
+
+ /* Disable M-APLIC in APLIC only configuration */
+ fdt_for_each_node_by_compatible(offset, fdt, -1, "riscv,aplic") {
+ if (riscv_node_handles_mmode_external_interrupts(fdt, offset)) {
+ err = fdt_status_disabled(fdt, offset);
+ if (err < 0)
+ return err;
+ }
+ }
+
+ /* Disable M-APLIC in APLIC-IMSIC configuration */
+ fdt_for_each_node_by_compatible(offset, fdt, -1, "riscv,aplic") {
+ int len, imsic_offset;
+ const fdt32_t *msi_parent = fdt_getprop(fdt, offset, "msi-parent", &len);
+
+ if (msi_parent && len >= sizeof(fdt32_t)) {
+ imsic_offset = fdt_node_offset_by_phandle(fdt, fdt32_to_cpu(*msi_parent));
+ if (imsic_offset >= 0 &&
+ riscv_node_handles_mmode_external_interrupts(fdt, imsic_offset)) {
+ err = fdt_status_disabled(fdt, offset);
+ if (err < 0)
+ return err;
+ }
+ }
+ }
+
+ return 0;
+}
+
#ifdef CONFIG_OF_BOARD_FIXUP
int board_fix_fdt(void *fdt)
{
@@ -165,5 +244,12 @@ int arch_fixup_fdt(void *blob)
if (err < 0)
return err;
+ /* Disable M-IMSIC and M-APLIC nodes when we're not in M-mode */
+ if (!CONFIG_IS_ENABLED(RISCV_MMODE)) {
+ err = riscv_aia_mimsic_maplic_fixup(blob);
+ if (err < 0)
+ return err;
+ }
+
return 0;
}
---
base-commit: 83b1ec64ede9998566e6a82b22848c20a33f4aff
change-id: 20261118-mimsic_maplic_fixup-051bd38d0985
Best regards,
--
Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3] riscv: Disable M-IMSIC and M-APLIC nodes in DT passed to next stage in S mode
2026-11-19 15:47 [PATCH v3] riscv: Disable M-IMSIC and M-APLIC nodes in DT passed to next stage in S mode Anirudh Srinivasan
@ 2026-11-19 21:31 ` E Shattow
2026-11-20 1:04 ` Anirudh Srinivasan
2026-11-20 10:46 ` Yao Zi
1 sibling, 1 reply; 7+ messages in thread
From: E Shattow @ 2026-11-19 21:31 UTC (permalink / raw)
To: Anirudh Srinivasan, Yao Zi, u-boot
Cc: Tim Ouyang, Leo Liang, Tom Rini, Troy Mitchell
On 11/19/26 07:47, Anirudh Srinivasan wrote:
> When U-Boot is running in S mode, the DT passed to the next S mode stage
> can either be the bundled in DT U-Boot and the previous M mode stage
> use, or be loaded by U-Boot from some boot media. In the former case,
> the M mode stage can fix up the DT to disable the M-IMSIC and M-APLIC
> nodes on an AIA system (for example, OpenSBI does this fixup). These
> controllers are to be managed by M-mode software, so this is done to
> prevent S mode software from trying to probe them.
>
> This fixup doesn't happen in the latter case because U-Boot loads a
> fresh DT from boot media. Add a fdt fixup to do this similar to OpenSBI.
> This gets rid of prints like this during linux boots.
>
> [ 0.000000] riscv-imsic: interrupt-controller@a0000000: no parent irqs available
> [ 0.000000] riscv-imsic: interrupt-controller@a0000000: failed to setup state (error -22)
> [ 0.000000] OF: of_irq_init: Failed to init /soc/interrupt-controller@a0000000 ((____ptrval____)), parent (____ptrval____)
>
> [ 10.727605] platform cc000000.interrupt-controller: deferred probe pending: platform: supplier a0000000.interrupt-controller not ready
>
> Reviewed-by: E Shattow <e@freeshell.de>
> Signed-off-by: Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
> ---
> Changes in v3:
> - Reword commit title to say M-APLIC/M-IMSIC and drop references to M Mode to avoid any confusion
> - Link to v2: https://patch.msgid.link/20261119-mimsic_maplic_fixup-v2-1-e29e04bf1b76@oss.tenstorrent.com
>
> Changes in v2:
> - Rename riscv_aia_mmode_aplic_imsic_fixup to riscv_aia_mimsic_maplic_fixup
> - Drop most references to OpenSBI/Linux in commit message and just use M-mode/s-mode software
> - Link to v1: https://patch.msgid.link/20261118-mimsic_maplic_fixup-v1-1-52dea8f39779@oss.tenstorrent.com
> ---
> arch/riscv/lib/fdt_fixup.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 86 insertions(+)
>
> diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c
> index 6dfd1a2d5b8..49f5b3b5bb6 100644
> --- a/arch/riscv/lib/fdt_fixup.c
> +++ b/arch/riscv/lib/fdt_fixup.c
> @@ -117,6 +117,85 @@ int riscv_board_reserved_mem_fixup(void *fdt)
> return 0;
> }
>
> +/**
> + * riscv_node_handles_mmode_external_interrupts() - Check if interrupt controller handles M-mode
> + * external interrupts
> + * @fdt: Pointer to the device tree
> + * @offset: Offset of node in DT to check
> + *
> + * Return: true if controller handles M-mode external interrupts IRQ_M_EXT (11), else false
> + */
> +static bool riscv_node_handles_mmode_external_interrupts(void *fdt, int offset)
> +{
> + int i, len;
> + const fdt32_t *interrupts_extended = fdt_getprop(fdt, offset, "interrupts-extended", &len);
> +
> + /*
> + * Each entry is <phandle irq>. The phandle points to a riscv,cpu-intc
> + * node, whose DT binding sets #interrupt-cells = <1>, so each entry is
> + * 2 cells.
> + */
> + if (!interrupts_extended || !len || len % (2 * sizeof(u32)))
> + return false;
> + for (i = 1; i < len / sizeof(u32); i += 2) {
> + if (fdt32_to_cpu(interrupts_extended[i]) == IRQ_M_EXT)
> + return true;
> + }
> + return false;
> +}
> +
> +/**
> + * riscv_aia_mimsic_maplic_fixup() - Disable M-APLIC and M-IMSIC nodes in DT
> + * @fdt: Pointer to the device tree in which nodes are to be disabled
> + *
> + * On RISC-V AIA systems, M-mode software manages the M-APLIC and M-IMSIC.
> + * If S-mode U-Boot loads a device tree from boot media, the DT nodes for these
> + * could still be enabled, so fixup the DT to disable these nodes before passing
> + * it to the next S-mode stage.
> + *
> + * Return: 0 on success or error otherwise.
> + */
> +static int riscv_aia_mimsic_maplic_fixup(void *fdt)
> +{
> + int offset, err;
> +
> + /* Disable M-IMSIC in APLIC-IMSIC configuration */
> + fdt_for_each_node_by_compatible(offset, fdt, -1, "riscv,imsics") {
> + if (riscv_node_handles_mmode_external_interrupts(fdt, offset)) {
> + err = fdt_status_disabled(fdt, offset);
> + if (err < 0)
> + return err;
> + }
> + }
> +
> + /* Disable M-APLIC in APLIC only configuration */
> + fdt_for_each_node_by_compatible(offset, fdt, -1, "riscv,aplic") {
> + if (riscv_node_handles_mmode_external_interrupts(fdt, offset)) {
> + err = fdt_status_disabled(fdt, offset);
> + if (err < 0)
> + return err;
> + }
> + }
> +
> + /* Disable M-APLIC in APLIC-IMSIC configuration */
> + fdt_for_each_node_by_compatible(offset, fdt, -1, "riscv,aplic") {
> + int len, imsic_offset;
> + const fdt32_t *msi_parent = fdt_getprop(fdt, offset, "msi-parent", &len);
> +
> + if (msi_parent && len >= sizeof(fdt32_t)) {
> + imsic_offset = fdt_node_offset_by_phandle(fdt, fdt32_to_cpu(*msi_parent));
> + if (imsic_offset >= 0 &&
> + riscv_node_handles_mmode_external_interrupts(fdt, imsic_offset)) {
> + err = fdt_status_disabled(fdt, offset);
> + if (err < 0)
> + return err;
> + }
> + }
> + }
> +
> + return 0;
> +}
> +
> #ifdef CONFIG_OF_BOARD_FIXUP
> int board_fix_fdt(void *fdt)
> {
> @@ -165,5 +244,12 @@ int arch_fixup_fdt(void *blob)
> if (err < 0)
> return err;
>
> + /* Disable M-IMSIC and M-APLIC nodes when we're not in M-mode */
> + if (!CONFIG_IS_ENABLED(RISCV_MMODE)) {
> + err = riscv_aia_mimsic_maplic_fixup(blob);
> + if (err < 0)
> + return err;
> + }
> +
> return 0;
> }
>
> ---
> base-commit: 83b1ec64ede9998566e6a82b22848c20a33f4aff
> change-id: 20261118-mimsic_maplic_fixup-051bd38d0985
>
> Best regards,
> --
> Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
>
The code and function call-out comments LGTM, thanks for updating those.
nit: If I am understanding this correctly, then I suggest to drop
references to "boot media" in the commit description of where DT
originates from; we simply have the U-Boot control Fdt (in-memory dtb
with whatever modifications happened before it gets to our present
state) as it was passed from M-mode or SBI S-mode handoff regardless of
where it originates from. It exists, and we need to validate in U-Boot
runtime for uniformity with the current operating mode since U-Boot
source tree is a likely source of overrides [1] and non-uniformity in
handoff to S-mode kernels.
From what I understand of reading the code then that commit message
could be clearer as e.g.:
"Introduce fixup of initial control Fdt in S-mode for the current
operating mode to disable non-applicable M-mode specific M-IMSIC and
M-APLIC nodes.
This fixup is evaluated once for the control Fdt passed from the
previous stage and does not affect any replacement Fdt loaded from boot
media."
...unless this does filter again on subsequent actions loading DT from
boot media, as that's what the present commit message has me confused
about now. I don't think that it does, from what I understand reading
the code.
Keep my R-by tag, and up to you to refine the commit message or not as
you like. I appreciate your help with this as a follow-up to [1]. Thanks!
-E
1: https://lore.kernel.org/lkml/20261029162343.1896134-1-e@freeshell.de/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] riscv: Disable M-IMSIC and M-APLIC nodes in DT passed to next stage in S mode
2026-11-19 21:31 ` E Shattow
@ 2026-11-20 1:04 ` Anirudh Srinivasan
0 siblings, 0 replies; 7+ messages in thread
From: Anirudh Srinivasan @ 2026-11-20 1:04 UTC (permalink / raw)
To: E Shattow; +Cc: Yao Zi, u-boot, Tim Ouyang, Leo Liang, Tom Rini, Troy Mitchell
Hi E,
On Thu, Nov 19, 2026 at 3:32 PM E Shattow <e@freeshell.de> wrote:
>
> On 11/19/26 07:47, Anirudh Srinivasan wrote:
> > When U-Boot is running in S mode, the DT passed to the next S mode stage
> > can either be the bundled in DT U-Boot and the previous M mode stage
> > use, or be loaded by U-Boot from some boot media. In the former case,
> > the M mode stage can fix up the DT to disable the M-IMSIC and M-APLIC
> > nodes on an AIA system (for example, OpenSBI does this fixup). These
> > controllers are to be managed by M-mode software, so this is done to
> > prevent S mode software from trying to probe them.
> >
> > This fixup doesn't happen in the latter case because U-Boot loads a
> > fresh DT from boot media. Add a fdt fixup to do this similar to OpenSBI.
> > This gets rid of prints like this during linux boots.
> >
> > [ 0.000000] riscv-imsic: interrupt-controller@a0000000: no parent irqs available
> > [ 0.000000] riscv-imsic: interrupt-controller@a0000000: failed to setup state (error -22)
> > [ 0.000000] OF: of_irq_init: Failed to init /soc/interrupt-controller@a0000000 ((____ptrval____)), parent (____ptrval____)
> >
> > [ 10.727605] platform cc000000.interrupt-controller: deferred probe pending: platform: supplier a0000000.interrupt-controller not ready
> >
> > Reviewed-by: E Shattow <e@freeshell.de>
> > Signed-off-by: Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
> > ---
> > Changes in v3:
> > - Reword commit title to say M-APLIC/M-IMSIC and drop references to M Mode to avoid any confusion
> > - Link to v2: https://patch.msgid.link/20261119-mimsic_maplic_fixup-v2-1-e29e04bf1b76@oss.tenstorrent.com
> >
> > Changes in v2:
> > - Rename riscv_aia_mmode_aplic_imsic_fixup to riscv_aia_mimsic_maplic_fixup
> > - Drop most references to OpenSBI/Linux in commit message and just use M-mode/s-mode software
> > - Link to v1: https://patch.msgid.link/20261118-mimsic_maplic_fixup-v1-1-52dea8f39779@oss.tenstorrent.com
> > ---
> > arch/riscv/lib/fdt_fixup.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 86 insertions(+)
> >
> > diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c
> > index 6dfd1a2d5b8..49f5b3b5bb6 100644
> > --- a/arch/riscv/lib/fdt_fixup.c
> > +++ b/arch/riscv/lib/fdt_fixup.c
> > @@ -117,6 +117,85 @@ int riscv_board_reserved_mem_fixup(void *fdt)
> > return 0;
> > }
> >
> > +/**
> > + * riscv_node_handles_mmode_external_interrupts() - Check if interrupt controller handles M-mode
> > + * external interrupts
> > + * @fdt: Pointer to the device tree
> > + * @offset: Offset of node in DT to check
> > + *
> > + * Return: true if controller handles M-mode external interrupts IRQ_M_EXT (11), else false
> > + */
> > +static bool riscv_node_handles_mmode_external_interrupts(void *fdt, int offset)
> > +{
> > + int i, len;
> > + const fdt32_t *interrupts_extended = fdt_getprop(fdt, offset, "interrupts-extended", &len);
> > +
> > + /*
> > + * Each entry is <phandle irq>. The phandle points to a riscv,cpu-intc
> > + * node, whose DT binding sets #interrupt-cells = <1>, so each entry is
> > + * 2 cells.
> > + */
> > + if (!interrupts_extended || !len || len % (2 * sizeof(u32)))
> > + return false;
> > + for (i = 1; i < len / sizeof(u32); i += 2) {
> > + if (fdt32_to_cpu(interrupts_extended[i]) == IRQ_M_EXT)
> > + return true;
> > + }
> > + return false;
> > +}
> > +
> > +/**
> > + * riscv_aia_mimsic_maplic_fixup() - Disable M-APLIC and M-IMSIC nodes in DT
> > + * @fdt: Pointer to the device tree in which nodes are to be disabled
> > + *
> > + * On RISC-V AIA systems, M-mode software manages the M-APLIC and M-IMSIC.
> > + * If S-mode U-Boot loads a device tree from boot media, the DT nodes for these
> > + * could still be enabled, so fixup the DT to disable these nodes before passing
> > + * it to the next S-mode stage.
> > + *
> > + * Return: 0 on success or error otherwise.
> > + */
> > +static int riscv_aia_mimsic_maplic_fixup(void *fdt)
> > +{
> > + int offset, err;
> > +
> > + /* Disable M-IMSIC in APLIC-IMSIC configuration */
> > + fdt_for_each_node_by_compatible(offset, fdt, -1, "riscv,imsics") {
> > + if (riscv_node_handles_mmode_external_interrupts(fdt, offset)) {
> > + err = fdt_status_disabled(fdt, offset);
> > + if (err < 0)
> > + return err;
> > + }
> > + }
> > +
> > + /* Disable M-APLIC in APLIC only configuration */
> > + fdt_for_each_node_by_compatible(offset, fdt, -1, "riscv,aplic") {
> > + if (riscv_node_handles_mmode_external_interrupts(fdt, offset)) {
> > + err = fdt_status_disabled(fdt, offset);
> > + if (err < 0)
> > + return err;
> > + }
> > + }
> > +
> > + /* Disable M-APLIC in APLIC-IMSIC configuration */
> > + fdt_for_each_node_by_compatible(offset, fdt, -1, "riscv,aplic") {
> > + int len, imsic_offset;
> > + const fdt32_t *msi_parent = fdt_getprop(fdt, offset, "msi-parent", &len);
> > +
> > + if (msi_parent && len >= sizeof(fdt32_t)) {
> > + imsic_offset = fdt_node_offset_by_phandle(fdt, fdt32_to_cpu(*msi_parent));
> > + if (imsic_offset >= 0 &&
> > + riscv_node_handles_mmode_external_interrupts(fdt, imsic_offset)) {
> > + err = fdt_status_disabled(fdt, offset);
> > + if (err < 0)
> > + return err;
> > + }
> > + }
> > + }
> > +
> > + return 0;
> > +}
> > +
> > #ifdef CONFIG_OF_BOARD_FIXUP
> > int board_fix_fdt(void *fdt)
> > {
> > @@ -165,5 +244,12 @@ int arch_fixup_fdt(void *blob)
> > if (err < 0)
> > return err;
> >
> > + /* Disable M-IMSIC and M-APLIC nodes when we're not in M-mode */
> > + if (!CONFIG_IS_ENABLED(RISCV_MMODE)) {
> > + err = riscv_aia_mimsic_maplic_fixup(blob);
> > + if (err < 0)
> > + return err;
> > + }
> > +
> > return 0;
> > }
> >
> > ---
> > base-commit: 83b1ec64ede9998566e6a82b22848c20a33f4aff
> > change-id: 20261118-mimsic_maplic_fixup-051bd38d0985
> >
> > Best regards,
> > --
> > Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
> >
>
> The code and function call-out comments LGTM, thanks for updating those.
>
> nit: If I am understanding this correctly, then I suggest to drop
> references to "boot media" in the commit description of where DT
> originates from; we simply have the U-Boot control Fdt (in-memory dtb
> with whatever modifications happened before it gets to our present
> state) as it was passed from M-mode or SBI S-mode handoff regardless of
> where it originates from. It exists, and we need to validate in U-Boot
> runtime for uniformity with the current operating mode since U-Boot
> source tree is a likely source of overrides [1] and non-uniformity in
> handoff to S-mode kernels.
>
> From what I understand of reading the code then that commit message
> could be clearer as e.g.:
>
> "Introduce fixup of initial control Fdt in S-mode for the current
> operating mode to disable non-applicable M-mode specific M-IMSIC and
> M-APLIC nodes.
>
> This fixup is evaluated once for the control Fdt passed from the
> previous stage and does not affect any replacement Fdt loaded from boot
> media."
>
> ...unless this does filter again on subsequent actions loading DT from
> boot media, as that's what the present commit message has me confused
> about now. I don't think that it does, from what I understand reading
> the code.
>
> Keep my R-by tag, and up to you to refine the commit message or not as
> you like. I appreciate your help with this as a follow-up to [1]. Thanks!
These U-boot FDT fixups are done just before U-Boot passes the DT to
the next stage (i.e when you run booti and bootefi). The fixup is run
irrespective of where the DT came from. If the OpenSBI supplied DT is
used for booting, it is run on it too and has no effect on it.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] riscv: Disable M-IMSIC and M-APLIC nodes in DT passed to next stage in S mode
2026-11-19 15:47 [PATCH v3] riscv: Disable M-IMSIC and M-APLIC nodes in DT passed to next stage in S mode Anirudh Srinivasan
2026-11-19 21:31 ` E Shattow
@ 2026-11-20 10:46 ` Yao Zi
2026-11-20 16:09 ` Anirudh Srinivasan
1 sibling, 1 reply; 7+ messages in thread
From: Yao Zi @ 2026-11-20 10:46 UTC (permalink / raw)
To: Anirudh Srinivasan, Yao Zi, u-boot
Cc: Tim Ouyang, Leo Liang, Tom Rini, E Shattow, Troy Mitchell
On Thu, Nov 19, 2026 at 09:47:07AM -0600, Anirudh Srinivasan wrote:
> When U-Boot is running in S mode, the DT passed to the next S mode stage
> can either be the bundled in DT U-Boot and the previous M mode stage
> use, or be loaded by U-Boot from some boot media. In the former case,
> the M mode stage can fix up the DT to disable the M-IMSIC and M-APLIC
> nodes on an AIA system (for example, OpenSBI does this fixup). These
> controllers are to be managed by M-mode software, so this is done to
> prevent S mode software from trying to probe them.
>
> This fixup doesn't happen in the latter case because U-Boot loads a
> fresh DT from boot media. Add a fdt fixup to do this similar to OpenSBI.
> This gets rid of prints like this during linux boots.
>
> [ 0.000000] riscv-imsic: interrupt-controller@a0000000: no parent irqs available
> [ 0.000000] riscv-imsic: interrupt-controller@a0000000: failed to setup state (error -22)
> [ 0.000000] OF: of_irq_init: Failed to init /soc/interrupt-controller@a0000000 ((____ptrval____)), parent (____ptrval____)
>
> [ 10.727605] platform cc000000.interrupt-controller: deferred probe pending: platform: supplier a0000000.interrupt-controller not ready
>
> Reviewed-by: E Shattow <e@freeshell.de>
> Signed-off-by: Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
> ---
> Changes in v3:
> - Reword commit title to say M-APLIC/M-IMSIC and drop references to M Mode to avoid any confusion
> - Link to v2: https://patch.msgid.link/20261119-mimsic_maplic_fixup-v2-1-e29e04bf1b76@oss.tenstorrent.com
>
> Changes in v2:
> - Rename riscv_aia_mmode_aplic_imsic_fixup to riscv_aia_mimsic_maplic_fixup
> - Drop most references to OpenSBI/Linux in commit message and just use M-mode/s-mode software
> - Link to v1: https://patch.msgid.link/20261118-mimsic_maplic_fixup-v1-1-52dea8f39779@oss.tenstorrent.com
> ---
> arch/riscv/lib/fdt_fixup.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 86 insertions(+)
>
> diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c
> index 6dfd1a2d5b8..49f5b3b5bb6 100644
> --- a/arch/riscv/lib/fdt_fixup.c
> +++ b/arch/riscv/lib/fdt_fixup.c
> @@ -117,6 +117,85 @@ int riscv_board_reserved_mem_fixup(void *fdt)
> return 0;
> }
>
> +/**
> + * riscv_node_handles_mmode_external_interrupts() - Check if interrupt controller handles M-mode
> + * external interrupts
> + * @fdt: Pointer to the device tree
> + * @offset: Offset of node in DT to check
> + *
> + * Return: true if controller handles M-mode external interrupts IRQ_M_EXT (11), else false
> + */
> +static bool riscv_node_handles_mmode_external_interrupts(void *fdt, int offset)
> +{
> + int i, len;
> + const fdt32_t *interrupts_extended = fdt_getprop(fdt, offset, "interrupts-extended", &len);
> +
> + /*
> + * Each entry is <phandle irq>. The phandle points to a riscv,cpu-intc
> + * node, whose DT binding sets #interrupt-cells = <1>, so each entry is
> + * 2 cells.
> + */
> + if (!interrupts_extended || !len || len % (2 * sizeof(u32)))
> + return false;
Please add a blank line after this if for readability.
Isn't the !len check here redundant? With len = 0, the loop would never
execute. I'm not sure whether it's better to remove it or not since it
might make the purpose more clear. It depends on you.
> + for (i = 1; i < len / sizeof(u32); i += 2) {
> + if (fdt32_to_cpu(interrupts_extended[i]) == IRQ_M_EXT)
> + return true;
> + }
Please and another blank line after this loop.
> + return false;
> +}
> +
> +/**
> + * riscv_aia_mimsic_maplic_fixup() - Disable M-APLIC and M-IMSIC nodes in DT
> + * @fdt: Pointer to the device tree in which nodes are to be disabled
> + *
> + * On RISC-V AIA systems, M-mode software manages the M-APLIC and M-IMSIC.
> + * If S-mode U-Boot loads a device tree from boot media, the DT nodes for these
> + * could still be enabled, so fixup the DT to disable these nodes before passing
> + * it to the next S-mode stage.
> + *
> + * Return: 0 on success or error otherwise.
> + */
> +static int riscv_aia_mimsic_maplic_fixup(void *fdt)
> +{
> + int offset, err;
> +
> + /* Disable M-IMSIC in APLIC-IMSIC configuration */
> + fdt_for_each_node_by_compatible(offset, fdt, -1, "riscv,imsics") {
> + if (riscv_node_handles_mmode_external_interrupts(fdt, offset)) {
> + err = fdt_status_disabled(fdt, offset);
Should we use "reserved" instead of "disabled"? Quoting the devicetree
specification,
> "disabled"
> Indicates that the device is not presently operational, but it
> might become operational in the future (for example, something
> is not plugged in, or switched off).
>
> "reserved"
> Indicates that the device is operational, but should not be
> used. Typically this is used for devices that are controlled by
> another software component, such as platform firmware.
Another possible problem is that these loops overrides the status
unconditionally, turning already "reserved" devices into "disabled".
> + if (err < 0)
> + return err;
> + }
> + }
> +
> + /* Disable M-APLIC in APLIC only configuration */
> + fdt_for_each_node_by_compatible(offset, fdt, -1, "riscv,aplic") {
> + if (riscv_node_handles_mmode_external_interrupts(fdt, offset)) {
> + err = fdt_status_disabled(fdt, offset);
> + if (err < 0)
> + return err;
> + }
> + }
It should be possible for an APLIC to deliver interrupts to both the HART
and the IMSIC, and this branch seems to disable such an IMSIC, too.
Please update the comment.
> + /* Disable M-APLIC in APLIC-IMSIC configuration */
> + fdt_for_each_node_by_compatible(offset, fdt, -1, "riscv,aplic") {
> + int len, imsic_offset;
> + const fdt32_t *msi_parent = fdt_getprop(fdt, offset, "msi-parent", &len);
> +
> + if (msi_parent && len >= sizeof(fdt32_t)) {
> + imsic_offset = fdt_node_offset_by_phandle(fdt, fdt32_to_cpu(*msi_parent));
> + if (imsic_offset >= 0 &&
> + riscv_node_handles_mmode_external_interrupts(fdt, imsic_offset)) {
> + err = fdt_status_disabled(fdt, offset);
> + if (err < 0)
> + return err;
> + }
> + }
> + }
> +
> + return 0;
> +}
> +
> #ifdef CONFIG_OF_BOARD_FIXUP
> int board_fix_fdt(void *fdt)
> {
> @@ -165,5 +244,12 @@ int arch_fixup_fdt(void *blob)
> if (err < 0)
> return err;
>
> + /* Disable M-IMSIC and M-APLIC nodes when we're not in M-mode */
> + if (!CONFIG_IS_ENABLED(RISCV_MMODE)) {
> + err = riscv_aia_mimsic_maplic_fixup(blob);
> + if (err < 0)
> + return err;
> + }
> +
> return 0;
> }
>
> ---
> base-commit: 83b1ec64ede9998566e6a82b22848c20a33f4aff
> change-id: 20261118-mimsic_maplic_fixup-051bd38d0985
>
> Best regards,
> --
> Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
>
--
Thanks,
Yao Zi
Meow-mrrp-mrow, I'm a cat.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] riscv: Disable M-IMSIC and M-APLIC nodes in DT passed to next stage in S mode
2026-11-20 10:46 ` Yao Zi
@ 2026-11-20 16:09 ` Anirudh Srinivasan
2026-11-20 17:07 ` Yao Zi
0 siblings, 1 reply; 7+ messages in thread
From: Anirudh Srinivasan @ 2026-11-20 16:09 UTC (permalink / raw)
To: Yao Zi; +Cc: u-boot, Tim Ouyang, Leo Liang, Tom Rini, E Shattow, Troy Mitchell
Hi Yao,
On Fri, Nov 20, 2026 at 4:47 AM Yao Zi <me@ziyao.cc> wrote:
>
> On Thu, Nov 19, 2026 at 09:47:07AM -0600, Anirudh Srinivasan wrote:
> > When U-Boot is running in S mode, the DT passed to the next S mode stage
> > can either be the bundled in DT U-Boot and the previous M mode stage
> > use, or be loaded by U-Boot from some boot media. In the former case,
> > the M mode stage can fix up the DT to disable the M-IMSIC and M-APLIC
> > nodes on an AIA system (for example, OpenSBI does this fixup). These
> > controllers are to be managed by M-mode software, so this is done to
> > prevent S mode software from trying to probe them.
> >
> > This fixup doesn't happen in the latter case because U-Boot loads a
> > fresh DT from boot media. Add a fdt fixup to do this similar to OpenSBI.
> > This gets rid of prints like this during linux boots.
> >
> > [ 0.000000] riscv-imsic: interrupt-controller@a0000000: no parent irqs available
> > [ 0.000000] riscv-imsic: interrupt-controller@a0000000: failed to setup state (error -22)
> > [ 0.000000] OF: of_irq_init: Failed to init /soc/interrupt-controller@a0000000 ((____ptrval____)), parent (____ptrval____)
> >
> > [ 10.727605] platform cc000000.interrupt-controller: deferred probe pending: platform: supplier a0000000.interrupt-controller not ready
> >
> > Reviewed-by: E Shattow <e@freeshell.de>
> > Signed-off-by: Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
> > ---
> > Changes in v3:
> > - Reword commit title to say M-APLIC/M-IMSIC and drop references to M Mode to avoid any confusion
> > - Link to v2: https://patch.msgid.link/20261119-mimsic_maplic_fixup-v2-1-e29e04bf1b76@oss.tenstorrent.com
> >
> > Changes in v2:
> > - Rename riscv_aia_mmode_aplic_imsic_fixup to riscv_aia_mimsic_maplic_fixup
> > - Drop most references to OpenSBI/Linux in commit message and just use M-mode/s-mode software
> > - Link to v1: https://patch.msgid.link/20261118-mimsic_maplic_fixup-v1-1-52dea8f39779@oss.tenstorrent.com
> > ---
> > arch/riscv/lib/fdt_fixup.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 86 insertions(+)
> >
> > diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c
> > index 6dfd1a2d5b8..49f5b3b5bb6 100644
> > --- a/arch/riscv/lib/fdt_fixup.c
> > +++ b/arch/riscv/lib/fdt_fixup.c
> > @@ -117,6 +117,85 @@ int riscv_board_reserved_mem_fixup(void *fdt)
> > return 0;
> > }
> >
> > +/**
> > + * riscv_node_handles_mmode_external_interrupts() - Check if interrupt controller handles M-mode
> > + * external interrupts
> > + * @fdt: Pointer to the device tree
> > + * @offset: Offset of node in DT to check
> > + *
> > + * Return: true if controller handles M-mode external interrupts IRQ_M_EXT (11), else false
> > + */
> > +static bool riscv_node_handles_mmode_external_interrupts(void *fdt, int offset)
> > +{
> > + int i, len;
> > + const fdt32_t *interrupts_extended = fdt_getprop(fdt, offset, "interrupts-extended", &len);
> > +
> > + /*
> > + * Each entry is <phandle irq>. The phandle points to a riscv,cpu-intc
> > + * node, whose DT binding sets #interrupt-cells = <1>, so each entry is
> > + * 2 cells.
> > + */
> > + if (!interrupts_extended || !len || len % (2 * sizeof(u32)))
> > + return false;
>
> Please add a blank line after this if for readability.
>
> Isn't the !len check here redundant? With len = 0, the loop would never
> execute. I'm not sure whether it's better to remove it or not since it
> might make the purpose more clear. It depends on you.
>
> > + for (i = 1; i < len / sizeof(u32); i += 2) {
> > + if (fdt32_to_cpu(interrupts_extended[i]) == IRQ_M_EXT)
> > + return true;
> > + }
>
> Please and another blank line after this loop.
>
> > + return false;
> > +}
> > +
> > +/**
> > + * riscv_aia_mimsic_maplic_fixup() - Disable M-APLIC and M-IMSIC nodes in DT
> > + * @fdt: Pointer to the device tree in which nodes are to be disabled
> > + *
> > + * On RISC-V AIA systems, M-mode software manages the M-APLIC and M-IMSIC.
> > + * If S-mode U-Boot loads a device tree from boot media, the DT nodes for these
> > + * could still be enabled, so fixup the DT to disable these nodes before passing
> > + * it to the next S-mode stage.
> > + *
> > + * Return: 0 on success or error otherwise.
> > + */
> > +static int riscv_aia_mimsic_maplic_fixup(void *fdt)
> > +{
> > + int offset, err;
> > +
> > + /* Disable M-IMSIC in APLIC-IMSIC configuration */
> > + fdt_for_each_node_by_compatible(offset, fdt, -1, "riscv,imsics") {
> > + if (riscv_node_handles_mmode_external_interrupts(fdt, offset)) {
> > + err = fdt_status_disabled(fdt, offset);
>
> Should we use "reserved" instead of "disabled"? Quoting the devicetree
> specification,
>
> > "disabled"
> > Indicates that the device is not presently operational, but it
> > might become operational in the future (for example, something
> > is not plugged in, or switched off).
> >
> > "reserved"
> > Indicates that the device is operational, but should not be
> > used. Typically this is used for devices that are controlled by
> > another software component, such as platform firmware.
>
> Another possible problem is that these loops overrides the status
> unconditionally, turning already "reserved" devices into "disabled".
I don't think we should be using reserved here. OpenSBI sets the node
to disabled, so we should be doing the same thing.
I'll add a check to see if the node is enabled and disable it only then.
>
> > + if (err < 0)
> > + return err;
> > + }
> > + }
> > +
> > + /* Disable M-APLIC in APLIC only configuration */
> > + fdt_for_each_node_by_compatible(offset, fdt, -1, "riscv,aplic") {
> > + if (riscv_node_handles_mmode_external_interrupts(fdt, offset)) {
> > + err = fdt_status_disabled(fdt, offset);
> > + if (err < 0)
> > + return err;
> > + }
> > + }
>
> It should be possible for an APLIC to deliver interrupts to both the HART
> and the IMSIC, and this branch seems to disable such an IMSIC, too.
> Please update the comment.
I'll move this disable block to the end. Then I think this comment
will be correct.
The APLIC that support both MSIs and Wired interrupts case would be
covered by the block below this (which would now run before this
block).
>
> > + /* Disable M-APLIC in APLIC-IMSIC configuration */
> > + fdt_for_each_node_by_compatible(offset, fdt, -1, "riscv,aplic") {
> > + int len, imsic_offset;
> > + const fdt32_t *msi_parent = fdt_getprop(fdt, offset, "msi-parent", &len);
> > +
> > + if (msi_parent && len >= sizeof(fdt32_t)) {
> > + imsic_offset = fdt_node_offset_by_phandle(fdt, fdt32_to_cpu(*msi_parent));
> > + if (imsic_offset >= 0 &&
> > + riscv_node_handles_mmode_external_interrupts(fdt, imsic_offset)) {
> > + err = fdt_status_disabled(fdt, offset);
> > + if (err < 0)
> > + return err;
> > + }
> > + }
> > + }
> > +
> > + return 0;
> > +}
> > +
> > #ifdef CONFIG_OF_BOARD_FIXUP
> > int board_fix_fdt(void *fdt)
> > {
> > @@ -165,5 +244,12 @@ int arch_fixup_fdt(void *blob)
> > if (err < 0)
> > return err;
> >
> > + /* Disable M-IMSIC and M-APLIC nodes when we're not in M-mode */
> > + if (!CONFIG_IS_ENABLED(RISCV_MMODE)) {
> > + err = riscv_aia_mimsic_maplic_fixup(blob);
> > + if (err < 0)
> > + return err;
> > + }
> > +
> > return 0;
> > }
> >
> > ---
> > base-commit: 83b1ec64ede9998566e6a82b22848c20a33f4aff
> > change-id: 20261118-mimsic_maplic_fixup-051bd38d0985
> >
> > Best regards,
> > --
> > Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
> >
Thanks for your comments. I'll address the style issues.
>
> --
> Thanks,
> Yao Zi
>
> Meow-mrrp-mrow, I'm a cat.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] riscv: Disable M-IMSIC and M-APLIC nodes in DT passed to next stage in S mode
2026-11-20 16:09 ` Anirudh Srinivasan
@ 2026-11-20 17:07 ` Yao Zi
2026-11-20 17:24 ` Anirudh Srinivasan
0 siblings, 1 reply; 7+ messages in thread
From: Yao Zi @ 2026-11-20 17:07 UTC (permalink / raw)
To: Anirudh Srinivasan, Yao Zi
Cc: u-boot, Tim Ouyang, Leo Liang, Tom Rini, E Shattow, Troy Mitchell
On Fri, Nov 20, 2026 at 10:09:49AM -0600, Anirudh Srinivasan wrote:
> Hi Yao,
>
> On Fri, Nov 20, 2026 at 4:47 AM Yao Zi <me@ziyao.cc> wrote:
> >
> > On Thu, Nov 19, 2026 at 09:47:07AM -0600, Anirudh Srinivasan wrote:
> > > When U-Boot is running in S mode, the DT passed to the next S mode stage
> > > can either be the bundled in DT U-Boot and the previous M mode stage
> > > use, or be loaded by U-Boot from some boot media. In the former case,
> > > the M mode stage can fix up the DT to disable the M-IMSIC and M-APLIC
> > > nodes on an AIA system (for example, OpenSBI does this fixup). These
> > > controllers are to be managed by M-mode software, so this is done to
> > > prevent S mode software from trying to probe them.
> > >
> > > This fixup doesn't happen in the latter case because U-Boot loads a
> > > fresh DT from boot media. Add a fdt fixup to do this similar to OpenSBI.
> > > This gets rid of prints like this during linux boots.
> > >
> > > [ 0.000000] riscv-imsic: interrupt-controller@a0000000: no parent irqs available
> > > [ 0.000000] riscv-imsic: interrupt-controller@a0000000: failed to setup state (error -22)
> > > [ 0.000000] OF: of_irq_init: Failed to init /soc/interrupt-controller@a0000000 ((____ptrval____)), parent (____ptrval____)
> > >
> > > [ 10.727605] platform cc000000.interrupt-controller: deferred probe pending: platform: supplier a0000000.interrupt-controller not ready
> > >
> > > Reviewed-by: E Shattow <e@freeshell.de>
> > > Signed-off-by: Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
> > > ---
> > > Changes in v3:
> > > - Reword commit title to say M-APLIC/M-IMSIC and drop references to M Mode to avoid any confusion
> > > - Link to v2: https://patch.msgid.link/20261119-mimsic_maplic_fixup-v2-1-e29e04bf1b76@oss.tenstorrent.com
> > >
> > > Changes in v2:
> > > - Rename riscv_aia_mmode_aplic_imsic_fixup to riscv_aia_mimsic_maplic_fixup
> > > - Drop most references to OpenSBI/Linux in commit message and just use M-mode/s-mode software
> > > - Link to v1: https://patch.msgid.link/20261118-mimsic_maplic_fixup-v1-1-52dea8f39779@oss.tenstorrent.com
> > > ---
> > > arch/riscv/lib/fdt_fixup.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++
> > > 1 file changed, 86 insertions(+)
...
> > > + * riscv_aia_mimsic_maplic_fixup() - Disable M-APLIC and M-IMSIC nodes in DT
> > > + * @fdt: Pointer to the device tree in which nodes are to be disabled
> > > + *
> > > + * On RISC-V AIA systems, M-mode software manages the M-APLIC and M-IMSIC.
> > > + * If S-mode U-Boot loads a device tree from boot media, the DT nodes for these
> > > + * could still be enabled, so fixup the DT to disable these nodes before passing
> > > + * it to the next S-mode stage.
> > > + *
> > > + * Return: 0 on success or error otherwise.
> > > + */
> > > +static int riscv_aia_mimsic_maplic_fixup(void *fdt)
> > > +{
> > > + int offset, err;
> > > +
> > > + /* Disable M-IMSIC in APLIC-IMSIC configuration */
> > > + fdt_for_each_node_by_compatible(offset, fdt, -1, "riscv,imsics") {
> > > + if (riscv_node_handles_mmode_external_interrupts(fdt, offset)) {
> > > + err = fdt_status_disabled(fdt, offset);
> >
> > Should we use "reserved" instead of "disabled"? Quoting the devicetree
> > specification,
> >
> > > "disabled"
> > > Indicates that the device is not presently operational, but it
> > > might become operational in the future (for example, something
> > > is not plugged in, or switched off).
> > >
> > > "reserved"
> > > Indicates that the device is operational, but should not be
> > > used. Typically this is used for devices that are controlled by
> > > another software component, such as platform firmware.
> >
> > Another possible problem is that these loops overrides the status
> > unconditionally, turning already "reserved" devices into "disabled".
>
> I don't think we should be using reserved here. OpenSBI sets the node
> to disabled, so we should be doing the same thing.
>
> I'll add a check to see if the node is enabled and disable it only then.
I think this is probably an OpenSBI defect, please try raising this to
OpenSBI upstream.
[...]
> Thanks for your comments. I'll address the style issues.
>
> >
> > --
> > Thanks,
> > Yao Zi
> >
> > Meow-mrrp-mrow, I'm a cat.
--
Thanks,
Yao Zi
Meow-mrrp-mrow, I'm a cat.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] riscv: Disable M-IMSIC and M-APLIC nodes in DT passed to next stage in S mode
2026-11-20 17:07 ` Yao Zi
@ 2026-11-20 17:24 ` Anirudh Srinivasan
0 siblings, 0 replies; 7+ messages in thread
From: Anirudh Srinivasan @ 2026-11-20 17:24 UTC (permalink / raw)
To: Yao Zi, Anup Patel
Cc: u-boot, Tim Ouyang, Leo Liang, Tom Rini, E Shattow, Troy Mitchell
Hi Yao,
+Anup to this thread
On Fri, Nov 20, 2026 at 11:07 AM Yao Zi <me@ziyao.cc> wrote:
>
> On Fri, Nov 20, 2026 at 10:09:49AM -0600, Anirudh Srinivasan wrote:
> > Hi Yao,
> >
> > On Fri, Nov 20, 2026 at 4:47 AM Yao Zi <me@ziyao.cc> wrote:
> > >
> > > On Thu, Nov 19, 2026 at 09:47:07AM -0600, Anirudh Srinivasan wrote:
> > > > When U-Boot is running in S mode, the DT passed to the next S mode stage
> > > > can either be the bundled in DT U-Boot and the previous M mode stage
> > > > use, or be loaded by U-Boot from some boot media. In the former case,
> > > > the M mode stage can fix up the DT to disable the M-IMSIC and M-APLIC
> > > > nodes on an AIA system (for example, OpenSBI does this fixup). These
> > > > controllers are to be managed by M-mode software, so this is done to
> > > > prevent S mode software from trying to probe them.
> > > >
> > > > This fixup doesn't happen in the latter case because U-Boot loads a
> > > > fresh DT from boot media. Add a fdt fixup to do this similar to OpenSBI.
> > > > This gets rid of prints like this during linux boots.
> > > >
> > > > [ 0.000000] riscv-imsic: interrupt-controller@a0000000: no parent irqs available
> > > > [ 0.000000] riscv-imsic: interrupt-controller@a0000000: failed to setup state (error -22)
> > > > [ 0.000000] OF: of_irq_init: Failed to init /soc/interrupt-controller@a0000000 ((____ptrval____)), parent (____ptrval____)
> > > >
> > > > [ 10.727605] platform cc000000.interrupt-controller: deferred probe pending: platform: supplier a0000000.interrupt-controller not ready
> > > >
> > > > Reviewed-by: E Shattow <e@freeshell.de>
> > > > Signed-off-by: Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
> > > > ---
> > > > Changes in v3:
> > > > - Reword commit title to say M-APLIC/M-IMSIC and drop references to M Mode to avoid any confusion
> > > > - Link to v2: https://patch.msgid.link/20261119-mimsic_maplic_fixup-v2-1-e29e04bf1b76@oss.tenstorrent.com
> > > >
> > > > Changes in v2:
> > > > - Rename riscv_aia_mmode_aplic_imsic_fixup to riscv_aia_mimsic_maplic_fixup
> > > > - Drop most references to OpenSBI/Linux in commit message and just use M-mode/s-mode software
> > > > - Link to v1: https://patch.msgid.link/20261118-mimsic_maplic_fixup-v1-1-52dea8f39779@oss.tenstorrent.com
> > > > ---
> > > > arch/riscv/lib/fdt_fixup.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++
> > > > 1 file changed, 86 insertions(+)
>
> ...
>
> > > > + * riscv_aia_mimsic_maplic_fixup() - Disable M-APLIC and M-IMSIC nodes in DT
> > > > + * @fdt: Pointer to the device tree in which nodes are to be disabled
> > > > + *
> > > > + * On RISC-V AIA systems, M-mode software manages the M-APLIC and M-IMSIC.
> > > > + * If S-mode U-Boot loads a device tree from boot media, the DT nodes for these
> > > > + * could still be enabled, so fixup the DT to disable these nodes before passing
> > > > + * it to the next S-mode stage.
> > > > + *
> > > > + * Return: 0 on success or error otherwise.
> > > > + */
> > > > +static int riscv_aia_mimsic_maplic_fixup(void *fdt)
> > > > +{
> > > > + int offset, err;
> > > > +
> > > > + /* Disable M-IMSIC in APLIC-IMSIC configuration */
> > > > + fdt_for_each_node_by_compatible(offset, fdt, -1, "riscv,imsics") {
> > > > + if (riscv_node_handles_mmode_external_interrupts(fdt, offset)) {
> > > > + err = fdt_status_disabled(fdt, offset);
> > >
> > > Should we use "reserved" instead of "disabled"? Quoting the devicetree
> > > specification,
> > >
> > > > "disabled"
> > > > Indicates that the device is not presently operational, but it
> > > > might become operational in the future (for example, something
> > > > is not plugged in, or switched off).
> > > >
> > > > "reserved"
> > > > Indicates that the device is operational, but should not be
> > > > used. Typically this is used for devices that are controlled by
> > > > another software component, such as platform firmware.
> > >
> > > Another possible problem is that these loops overrides the status
> > > unconditionally, turning already "reserved" devices into "disabled".
> >
> > I don't think we should be using reserved here. OpenSBI sets the node
> > to disabled, so we should be doing the same thing.
> >
> > I'll add a check to see if the node is enabled and disable it only then.
>
> I think this is probably an OpenSBI defect, please try raising this to
> OpenSBI upstream.
Hello Anup, I've added you to this thread as you had added the code to
OpenSBI that marks M-APLIC and M-IMSIC nodes as disabled. This current
patch does the same for a DT that U-boot loads from boot media (hence
is missing the fixup OpenSBI does) and passes to linux.
Do think these nodes should be marked as "reserved" instead? It seems
that "reserved" is to be used for devices controlled by different a sw
component, which seems to line up with what's happening here.
Please let me know what you think.
>
> [...]
>
> > Thanks for your comments. I'll address the style issues.
> >
> > >
> > > --
> > > Thanks,
> > > Yao Zi
> > >
> > > Meow-mrrp-mrow, I'm a cat.
>
> --
> Thanks,
> Yao Zi
>
> Meow-mrrp-mrow, I'm a cat.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-20 17:24 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 15:47 [PATCH v3] riscv: Disable M-IMSIC and M-APLIC nodes in DT passed to next stage in S mode Anirudh Srinivasan
2026-11-19 21:31 ` E Shattow
2026-11-20 1:04 ` Anirudh Srinivasan
2026-11-20 10:46 ` Yao Zi
2026-11-20 16:09 ` Anirudh Srinivasan
2026-11-20 17:07 ` Yao Zi
2026-11-20 17:24 ` Anirudh Srinivasan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.