Attention is currently required from: Philipp Hug.
Maximilian Brune has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/87300?usp=email )
Change subject: arch/riscv/smp.c: Add comments and print messages ......................................................................
arch/riscv/smp.c: Add comments and print messages
It should increase readability and make it easier to debug.
Signed-off-by: Maximilian Brune maximilian.brune@9elements.com Change-Id: Ia9d77aa64482d5cd087a5b90c1fc80f8b3d6614c --- M src/arch/riscv/smp.c 1 file changed, 10 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/00/87300/1
diff --git a/src/arch/riscv/smp.c b/src/arch/riscv/smp.c index a08e16b..2378e4e 100644 --- a/src/arch/riscv/smp.c +++ b/src/arch/riscv/smp.c @@ -27,6 +27,7 @@ #define HART_SLEEPING 0x1 #define HART_AWAKE 0x2
+// effectively only executed on harts that are not the working hart void smp_pause(int working_hartid) { int hartid = read_csr(mhartid); @@ -37,6 +38,7 @@ set_msip(hartid, 0); // clear pending interrupts write_csr(mie, MIP_MSIP); // enable only IPI (for smp_resume) barrier(); + atomic_set(&HLS()->entry.sync_a, HART_SLEEPING); // mark the hart as sleeping.
// pause hart @@ -63,12 +65,13 @@ }
int working_hartid = read_csr(mhartid); + printk(BIOS_DEBUG, "working_hartid: %d\n", working_hartid);
int hart_count = CONFIG_MAX_CPUS; if (CONFIG(RISCV_GET_HART_COUNT_AT_RUNTIME)) hart_count = smp_get_hart_count();
- // check that all harts are present + // wake up all harts
u32 count_awake_harts = 0; for (int i = 0; i < hart_count; i++) { @@ -96,21 +99,22 @@ } }
- printk(BIOS_DEBUG, "waiting for all harts to wake up...\n"); - // confirm that all harts are wake + printk(BIOS_SPEW, "waiting for all harts to wake up...\n"); + for (int i = 0; i < hart_count; i++) { // The working hart never sleeps. It is a hard working hart. if (i == working_hartid || !OTHER_HLS(i)->enabled) continue;
- // wait for hart to publish its waking state + printk(BIOS_SPEW, "waiting for hart %d\n", i); while (atomic_read(&OTHER_HLS(i)->entry.sync_a) != HART_AWAKE) - ; + ; //TODO add timeout + // signal to hart that we noticed it woke up atomic_set(&HLS()->entry.sync_b, HART_AWAKE); count_awake_harts++; } - printk(BIOS_DEBUG, "all harts up and running...\n"); + printk(BIOS_DEBUG, "all harts are up and running\n");
if ((hart_count - 1) != count_awake_harts) { // exclude working hart /*