On 29/05/2017 15:58, Andrew Jones wrote: > Paolo inspired me to add x86's on_cpu and on_cpu_asynch to ARM's API. > I messed around with it a while, but haven't really settled on what > I want to do. I played with the following approaches: > - wfe/sev, requires the concept of an idle state and knowing that the > target CPU is in that state - i.e. no arbitrary preemption. WFE really is just a power-save NOP. I think you'd do something like spin_lock(&dest->ipi_lock); assert(dest->ipi_cb == NULL); dest->ipi_cb = fn; dest->ipi_opaque = opaque; spin_unlock(&dest->ipi_lock); asm("dsb; sev"); while (dest->ipi_cb != NULL) asm("wfe"); and on the other side: while (dest->ipi_cb == NULL) asm("wfe"); spin_lock(&dest->ipi_lock); cb = dest->ipi_cb; opaque = dest->ipi_opaque; dest->ipi_cb = NULL; spin_unlock(&dest->ipi_lock); asm("dsb; sev"); cb(opaque); Thanks, Paolo > - IPI, allows arbitrary preemption, but requires the GIC to be setup > enough to receive SGIs and also a dedicated SGI for the scheduling > - PSCI, poweroff state isn't better than an idle state, and PSCI works > asynchronously wrt CPUs