Hi Markus,

On 23/06/25 17:38, Markus Schneider-Pargmann wrote:
This is a common function that helps to resume from DDR. There are two
pointers which are fetched from DDR to resume, the TIFS context pointer
which points to the context in DDR. There is another pointer to the DM
loadaddr to jump back into DM.

Signed-off-by: Markus Schneider-Pargmann <m...@baylibre.com>
---
  arch/arm/mach-k3/common.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
  arch/arm/mach-k3/common.h |  1 +
  2 files changed, 46 insertions(+)

diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index 
7c3f42e35b0f3a5aa7ed0bf01a1479b29d947540..1ef560e2fb936c4245323bbebc5af3ec277b8792
 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c

+struct lpm_meta_data {
+       u64 dm_jump_address;
+       u64 tifs_context_save_address;
+       u64 reserved[30];
+} __packed__;
+
+void __noreturn lpm_resume_from_ddr(u64 meta_data_addr)
+{
+       struct lpm_meta_data *lpm_data = (struct lpm_meta_data *)meta_data_addr;
+       typedef void __noreturn (*image_entry_noargs_t)(void);
+       image_entry_noargs_t image_entry;
+       int ret;
+
+       ret = lpm_restore_context(lpm_data->tifs_context_save_address);
+       if (ret)
+               panic("Failed to restore context from 0x%p\n",
+                     (void *)lpm_data->tifs_context_save_address);

The above code is reading the value of lpm_data->tifs_context_save_address two times from DDR memory,
1. While requesting TIFS to restore the context
2. When printing the address sent to TIFS to restore the context in case of failure

It is better to read the address once from DDR memory and store in local variable as we need to print the exact address that was sent to TIFS for restoring context. (In case the DDR memory is instable, this read can have different values and can be misleading)

+
+       image_entry = (image_entry_noargs_t)(u64 *)lpm_data->dm_jump_address;
+       printf("Resuming from DDR, jumping to stored DM loadaddr 0x%p, TIFS context 
restored from 0x%p\n",
+              image_entry, (void *)lpm_data->tifs_context_save_address);
+
+       image_entry();
+}
+#else
+

Regards,
Akashdeep Kaur

Reply via email to