ANDROID: stop_machine: stop_one_cpu_async

This new interface allows to trigger a stopper on a given CPU and wait
for the end of the work in a separated function cpu_stop_work_wait().

This differs from stop_one_cpu_nowait() by allowing the usage of the
cpu_stop completion mechanism.

Bug: 161210528
Change-Id: Ida51371e32897d008ece0639190fc21feabb0f28
Signed-off-by: Vincent Donnefort <vincent.donnefort@arm.com>
This commit is contained in:
Vincent Donnefort
2020-11-03 11:47:46 +00:00
committed by Todd Kjos
parent bce40b72a3
commit d9f0cedbaf
2 changed files with 63 additions and 10 deletions

View File

@@ -28,6 +28,16 @@ struct cpu_stop_work {
struct cpu_stop_done *done;
};
/*
* Structure to determine completion condition and record errors. May
* be shared by works on different cpus.
*/
struct cpu_stop_done {
atomic_t nr_todo; /* nr left to execute */
int ret; /* collected return value */
struct completion completion; /* fired if nr_todo reaches 0 */
};
int stop_one_cpu(unsigned int cpu, cpu_stop_fn_t fn, void *arg);
int stop_two_cpus(unsigned int cpu1, unsigned int cpu2, cpu_stop_fn_t fn, void *arg);
bool stop_one_cpu_nowait(unsigned int cpu, cpu_stop_fn_t fn, void *arg,
@@ -35,6 +45,10 @@ bool stop_one_cpu_nowait(unsigned int cpu, cpu_stop_fn_t fn, void *arg,
void stop_machine_park(int cpu);
void stop_machine_unpark(int cpu);
void stop_machine_yield(const struct cpumask *cpumask);
int stop_one_cpu_async(unsigned int cpu, cpu_stop_fn_t fn, void *arg,
struct cpu_stop_work *work_buf,
struct cpu_stop_done *done);
void cpu_stop_work_wait(struct cpu_stop_work *work_buf);
#else /* CONFIG_SMP */