This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new f5411a362e9 arch/arm/src/imx9: rptun: Add option to copy the resource
table on every start.
f5411a362e9 is described below
commit f5411a362e96b74bc1a83409467c99d21a4169c1
Author: Phil-Engljaehringer <[email protected]>
AuthorDate: Wed Oct 28 16:02:48 2026 +0100
arch/arm/src/imx9: rptun: Add option to copy the resource table on every
start.
imx9_rptun_get_resource() returned the cached table pointer on every
rptun start after the first one. Restarting rptun while the core keeps
running (e.g. after the host rebooted or crashed) therefore reused the
old vdev status with DRIVER_OK still set, so the core did not wait for
the new host and used vrings the host had not set up yet.
Remove the cache and add IMX9_RPTUN_ALWAYS_COPY_RSC_TABLE. When enabled,
the built-in resource table is copied to RESOURCE_TABLE_BASE on every
start, which resets the vdev status.
The copy is not unconditional because when Linux remoteproc loads the
firmware ELF, Linux writes the resource table before starting the core
and sets the guest features and DRIVER_OK afterwards; copying the table
would erase that state. There is no reliable way to detect at runtime
how the core was started, so this is a build option. When disabled, the
existing check is kept and the table is only copied when
RESOURCE_TABLE_BASE does not already hold a table.
Assisted-by: Claude-Code:claude-opus-5-5
Signed-off-by: Phil-Engljaehringer <[email protected]>
---
arch/arm/src/imx9/Kconfig | 16 ++++++++++++++++
arch/arm/src/imx9/imx9_rptun.c | 10 +++++-----
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/arch/arm/src/imx9/Kconfig b/arch/arm/src/imx9/Kconfig
index d53d9670e63..bd1ca1f12f7 100644
--- a/arch/arm/src/imx9/Kconfig
+++ b/arch/arm/src/imx9/Kconfig
@@ -75,6 +75,22 @@ config IMX9_WFI_AWAKES_AT_SYSTICK
Configure the GPC to wake up from systick interrupts at WFI
instruction
+config IMX9_RPTUN_ALWAYS_COPY_RSC_TABLE
+ bool "Always copy resource table on rptun start"
+ default n
+ depends on RPTUN
+ ---help---
+ Copy the built-in resource table to RESOURCE_TABLE_BASE on every
+ rptun start, resetting the vdev status. This allows rptun to be
+ restarted while the core keeps running, e.g. after Linux
reboots.
+
+ Do not enable this when Linux remoteproc loads the firmware ELF.
+ Linux then writes the resource table before starting the core
and
+ sets DRIVER_OK afterwards, so copying it would erase that state.
+
+ If disabled, the table is only copied when RESOURCE_TABLE_BASE
+ does not already hold a table.
+
menu "i.MX9 Peripheral Selection"
config IMX9_EDMA
diff --git a/arch/arm/src/imx9/imx9_rptun.c b/arch/arm/src/imx9/imx9_rptun.c
index 97978e5dec1..1eb07d219ad 100644
--- a/arch/arm/src/imx9/imx9_rptun.c
+++ b/arch/arm/src/imx9/imx9_rptun.c
@@ -155,17 +155,17 @@ imx9_rptun_get_resource(struct rptun_dev_s *dev)
struct imx9_rptun_dev_s *priv =
container_of(dev, struct imx9_rptun_dev_s, rptun);
- if (priv->shmem != NULL)
- {
- return &priv->shmem->rsc.rsc_tbl_hdr;
- }
-
priv->shmem = (struct imx9_rptun_shmem_s *)RESOURCE_TABLE_BASE;
+
+#ifdef CONFIG_IMX9_RPTUN_ALWAYS_COPY_RSC_TABLE
+ imx9_rsctable_copy();
+#else
if (priv->shmem->rsc.rsc_tbl_hdr.offset
!= g_imx9_rsc_table.rsc_tbl_hdr.offset)
{
imx9_rsctable_copy();
}
+#endif
return &priv->shmem->rsc.rsc_tbl_hdr;
}