Skip to content

Commit

Permalink
riscv64: sync cores only if SMP is enabled
Browse files Browse the repository at this point in the history
JIRA: RTOS-813
  • Loading branch information
lukileczo authored and agkaminski committed Jun 25, 2024
1 parent 5cdf3a9 commit 47ac14e
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions hal/riscv64/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,17 +353,23 @@ void hal_cpuBroadcastIPI(unsigned int intr)
/* Sync instruction & data stores across SMP */
void hal_cpuSmpSync(void)
{
unsigned long hart_mask = (1 << hal_cpuGetCount()) - 1;
RISCV_FENCE(rw, rw);
hal_cpuInstrBarrier();
hal_sbiRfenceI(hart_mask, 0);
unsigned long hart_mask;
if (hal_cpuGetCount() > 1) {
hart_mask = (1 << hal_cpuGetCount()) - 1;
RISCV_FENCE(rw, rw);
hal_cpuInstrBarrier();
hal_sbiRfenceI(hart_mask, 0);
}
}


void hal_cpuRfenceI(void)
{
unsigned long hart_mask = (1 << hal_cpuGetCount()) - 1;
hal_sbiRfenceI(hart_mask, 0);
unsigned long hart_mask;
if (hal_cpuGetCount() > 1) {
hart_mask = (1 << hal_cpuGetCount()) - 1;
hal_sbiRfenceI(hart_mask, 0);
}
}


Expand All @@ -386,8 +392,15 @@ void hal_cpuRemoteFlushTLB(const struct _pmap_t *pmap, const void *vaddr, size_t
{
(void)pmap; /* TODO: ASID support */

unsigned long hart_mask = (1 << hal_cpuGetCount()) - 1;
hal_sbiSfenceVma(hart_mask, 0, (unsigned long)vaddr, size);
unsigned long hart_mask;

if (hal_cpuGetCount() > 1) {
hart_mask = (1 << hal_cpuGetCount()) - 1;
hal_sbiSfenceVma(hart_mask, 0, (unsigned long)vaddr, size);
}
else {
hal_cpuLocalFlushTLB(pmap, vaddr);
}
}


Expand Down

0 comments on commit 47ac14e

Please sign in to comment.