
Based on 2 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license version 2 as published by the free software foundation this program is free software you can redistribute it and or modify it under the terms of the gnu general public license version 2 as published by the free software foundation # extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 4122 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Enrico Weigelt <info@metux.net> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Reviewed-by: Allison Randal <allison@lohutok.net> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
49 lines
1.2 KiB
C
49 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (C) 2017 Linaro Ltd. <ard.biesheuvel@linaro.org>
|
|
*/
|
|
|
|
#ifndef __ASM_SIMD_H
|
|
#define __ASM_SIMD_H
|
|
|
|
#include <linux/compiler.h>
|
|
#include <linux/irqflags.h>
|
|
#include <linux/percpu.h>
|
|
#include <linux/preempt.h>
|
|
#include <linux/types.h>
|
|
|
|
#ifdef CONFIG_KERNEL_MODE_NEON
|
|
|
|
DECLARE_PER_CPU(bool, kernel_neon_busy);
|
|
|
|
/*
|
|
* may_use_simd - whether it is allowable at this time to issue SIMD
|
|
* instructions or access the SIMD register file
|
|
*
|
|
* Callers must not assume that the result remains true beyond the next
|
|
* preempt_enable() or return from softirq context.
|
|
*/
|
|
static __must_check inline bool may_use_simd(void)
|
|
{
|
|
/*
|
|
* kernel_neon_busy is only set while preemption is disabled,
|
|
* and is clear whenever preemption is enabled. Since
|
|
* this_cpu_read() is atomic w.r.t. preemption, kernel_neon_busy
|
|
* cannot change under our feet -- if it's set we cannot be
|
|
* migrated, and if it's clear we cannot be migrated to a CPU
|
|
* where it is set.
|
|
*/
|
|
return !in_irq() && !irqs_disabled() && !in_nmi() &&
|
|
!this_cpu_read(kernel_neon_busy);
|
|
}
|
|
|
|
#else /* ! CONFIG_KERNEL_MODE_NEON */
|
|
|
|
static __must_check inline bool may_use_simd(void) {
|
|
return false;
|
|
}
|
|
|
|
#endif /* ! CONFIG_KERNEL_MODE_NEON */
|
|
|
|
#endif
|