320838263f1e86507d4a958edd93a3f4459edc82
2 * Copyright (C) 2017 Linaro Ltd. <ard.biesheuvel@linaro.org>
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published
6 * by the Free Software Foundation.
12 #include <linux/types.h>
15 * may_use_simd - whether it is allowable at this time to issue SIMD
16 * instructions or access the SIMD register file
18 static __must_check
inline bool may_use_simd(void)
24 * kernel_neon_busy is only set while preemption is disabled,
25 * and is clear whenever preemption is enabled. Since
26 * this_cpu_read() is atomic w.r.t. preemption, kernel_neon_busy
27 * cannot change under our feet -- if it's set we cannot be
28 * migrated, and if it's clear we cannot be migrated to a CPU
31 return !in_irq() && !irqs_disabled() && !in_nmi() &&
32 !this_cpu_read(kernel_neon_busy
);