Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elfloader: NVIDIA Jetson Orin support #190

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions elfloader-tool/src/arch-arm/armv/armv8-a/64/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ void core_entry(uint64_t sp)

int is_core_up(int i)
{
/* Secondary core may be booted with caches disabled,
* this value might be written in memory, invalidate our
* copy and get a new one. */
asm volatile("dc ivac, %0\n\t"
"dmb nsh\n\t"
:: "r"(&core_up[i]));
return core_up[i] == i;
}

Expand Down
9 changes: 8 additions & 1 deletion elfloader-tool/src/arch-arm/drivers/smp-psci.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*
* SPDX-License-Identifier: GPL-2.0-only
*/
#include <autoconf.h>
#include <elfloader_common.h>
#include <devices_gen.h>
#include <drivers/common.h>
Expand All @@ -24,7 +25,13 @@ static int smp_psci_cpu_on(UNUSED struct elfloader_device *dev,
}
secondary_data.entry = entry;
secondary_data.stack = stack;
dmb();
#if defined(CONFIG_ARCH_AARCH64)
/* If the secondary core caches are off, need to make sure that the info
* is clean to the physical memory so that the sedcondary cores can read it.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: "sedcondary".

*/
asm volatile("dc cvac, %0" :: "r"(&secondary_data));
dsb();
#endif
int ret = psci_cpu_on(cpu->cpu_id, (unsigned long)&secondary_startup, 0);
if (ret != PSCI_SUCCESS) {
printf("Failed to bring up core 0x%x with error %d\n", cpu->cpu_id, ret);
Expand Down
21 changes: 19 additions & 2 deletions elfloader-tool/src/arch-arm/smp_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ void non_boot_main(void)
#endif
/* Spin until the first CPU has finished initialisation. */
while (!non_boot_lock) {
#ifndef CONFIG_ARCH_AARCH64
#ifdef CONFIG_ARCH_AARCH64
/* The compiler may optimize this loop away, add a dsb()
* to force a reload. */
dsb();
Comment on lines +38 to +40
Copy link

@Indanz Indanz Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also applies to non-aarch64, so this doesn't look like the right solution. Using standard atomics may be better and more portable here.

Edit: The problem may be masked by cpu_idle() in 32-bit, but this still feels wrong.

#else
cpu_idle();
#endif
}
Expand Down Expand Up @@ -124,7 +128,13 @@ WEAK void init_cpus(void)
abort();
}

while (!is_core_up(num_cpus));
while (!is_core_up(num_cpus)) {
#if defined(CONFIG_ARCH_AARCH64)
/* The compiler may optimize this loop away, add a dsb()
* to force a reload. */
dsb();
#endif
}
printf("Core %d is up with logic id %d\n", elfloader_cpus[i].cpu_id, num_cpus);
num_cpus++;
}
Expand All @@ -141,6 +151,13 @@ void smp_boot(void)
arm_disable_dcaches();
#endif
init_cpus();
#if defined(CONFIG_ARCH_AARCH64)
dsb();
non_boot_lock = 1;
/* Secondary CPUs may still run with MMU & caches off. Force the update to be visible. */
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same is true for 32-bit, right?

asm volatile("dc civac, %0\n\t" :: "r"(&non_boot_lock) : "memory");;
#else
non_boot_lock = 1;
#endif
}
#endif /* CONFIG_MAX_NUM_NODES */