gpio: rcar: Fix runtime PM imbalance on error
[linux/fpc-iii.git] / drivers / xen / preempt.c
blob17240c5325a30c799478f1e13df0e503dfa71c09
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Preemptible hypercalls
5 * Copyright (C) 2014 Citrix Systems R&D ltd.
6 */
8 #include <linux/sched.h>
9 #include <xen/xen-ops.h>
11 #ifndef CONFIG_PREEMPTION
14 * Some hypercalls issued by the toolstack can take many 10s of
15 * seconds. Allow tasks running hypercalls via the privcmd driver to
16 * be voluntarily preempted even if full kernel preemption is
17 * disabled.
19 * Such preemptible hypercalls are bracketed by
20 * xen_preemptible_hcall_begin() and xen_preemptible_hcall_end()
21 * calls.
24 DEFINE_PER_CPU(bool, xen_in_preemptible_hcall);
25 EXPORT_SYMBOL_GPL(xen_in_preemptible_hcall);
27 asmlinkage __visible void xen_maybe_preempt_hcall(void)
29 if (unlikely(__this_cpu_read(xen_in_preemptible_hcall)
30 && need_resched())) {
32 * Clear flag as we may be rescheduled on a different
33 * cpu.
35 __this_cpu_write(xen_in_preemptible_hcall, false);
36 local_irq_enable();
37 cond_resched();
38 local_irq_disable();
39 __this_cpu_write(xen_in_preemptible_hcall, true);
42 #endif /* CONFIG_PREEMPTION */