From: E Shattow <e@freeshell.de>
To: Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>,
Yao Zi <me@ziyao.cc>,
u-boot@lists.u-boot-project.org
Cc: Tim Ouyang <tim609@andestech.com>,
Leo Liang <leo.liang@sifive.com>, Tom Rini <trini@konsulko.com>,
Troy Mitchell <troy.mitchell@linux.spacemit.com>
Subject: Re: [PATCH v4] riscv: Mark M-IMSIC and M-APLIC nodes as reserved in DT passed to next stage in S mode
Date: Fri, 4 Dec 2026 03:10:02 -0800 [thread overview]
Message-ID: <c8bd8b8a-b0cc-4a87-989d-e8007874620e@freeshell.de> (raw)
In-Reply-To: <20261203-mimsic_maplic_fixup-v4-1-41acf30f9b68@oss.tenstorrent.com>
Hi Anirudh,
On 12/3/26 08:56, 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.
>
The way it reads now (in my point of view) is as:
"M-IMSIC and M-APLIC controllers are to be managed by M-mode software,
and so enforce any M-mode M-IMSIC and M-APLIC nodes are effectively
status 'reserved' in S-mode U-Boot with a fixup to the received control
Fdt from preceding M-Mode software (e.g. OpenSBI). Enforce again this
same fixup when entering the next S-mode kernel to prevent S-mode
software from trying to probe them."
Is my reading of this an accurate description of the fixup after your
changes?
> 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, marking these
> nodes as reserved. 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 v4:
> - Mark nodes as reserved instead of disabled
> - Added blank lines for readability
> - Check if APLIC/IMSIC nodes are enabled before reserving them
> - Reorder node disabling blocks so that APLIC-only config is disabled at the end
> - Checkpath warning about fdtdec_get_is_enabled() can be ignored as we aren't modifying
> the live DT that u-boot is using
> - Link to v3: https://patch.msgid.link/20261119-mimsic_maplic_fixup-v3-1-e028e28fb958@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 | 94 ++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 94 insertions(+)
>
> diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c
> index 6dfd1a2d5b8..09b6e122cb2 100644
> --- a/arch/riscv/lib/fdt_fixup.c
> +++ b/arch/riscv/lib/fdt_fixup.c
> @@ -117,6 +117,93 @@ 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() - Mark M-APLIC and M-IMSIC nodes in DT as reserved
> + * @fdt: Pointer to the device tree in which nodes are to be fixed up
> + *
> + * 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 mark these nodes as reserved 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;
> +
> + /* Mark M-IMSIC in APLIC-IMSIC configuration as reserved */
> + fdt_for_each_node_by_compatible(offset, fdt, -1, "riscv,imsics") {
> + if (riscv_node_handles_mmode_external_interrupts(fdt, offset)) {
> + if (fdtdec_get_is_enabled(fdt, offset)) {
> + err = fdt_setprop_string(fdt, offset, "status", "reserved");
> + if (err < 0)
> + return err;
> + }
> + }
> + }
> +
> + /* Mark M-APLIC in APLIC-IMSIC configuration as reserved */
> + 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)) {
> + if (fdtdec_get_is_enabled(fdt, offset)) {
> + err = fdt_setprop_string(fdt, offset, "status", "reserved");
> + if (err < 0)
> + return err;
> + }
> + }
> + }
> + }
> +
> + /* Mark M-APLIC in APLIC only configuration as reserved */
> + fdt_for_each_node_by_compatible(offset, fdt, -1, "riscv,aplic") {
> + if (riscv_node_handles_mmode_external_interrupts(fdt, offset)) {
> + if (fdtdec_get_is_enabled(fdt, offset)) {
> + err = fdt_setprop_string(fdt, offset, "status", "reserved");
> + if (err < 0)
> + return err;
> + }
> + }
> + }
> +
> + return 0;
> +}
> +
> #ifdef CONFIG_OF_BOARD_FIXUP
> int board_fix_fdt(void *fdt)
> {
> @@ -165,5 +252,12 @@ int arch_fixup_fdt(void *blob)
> if (err < 0)
> return err;
>
> + /* Mark M-IMSIC and M-APLIC nodes as reserved 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>
>
-E
next prev parent reply other threads:[~2026-12-04 11:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 16:56 [PATCH v4] riscv: Mark M-IMSIC and M-APLIC nodes as reserved in DT passed to next stage in S mode Anirudh Srinivasan
2026-12-04 11:10 ` E Shattow [this message]
2026-12-04 14:25 ` Anirudh Srinivasan
2026-12-05 17:40 ` E Shattow
2026-12-05 21:54 ` Yao Zi
2026-12-05 22:34 ` E Shattow
2026-12-06 0:23 ` Yao Zi
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=c8bd8b8a-b0cc-4a87-989d-e8007874620e@freeshell.de \
--to=e@freeshell.de \
--cc=asrinivasan@oss.tenstorrent.com \
--cc=leo.liang@sifive.com \
--cc=me@ziyao.cc \
--cc=tim609@andestech.com \
--cc=trini@konsulko.com \
--cc=troy.mitchell@linux.spacemit.com \
--cc=u-boot@lists.u-boot-project.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