1 /* SPDX-License-Identifier: MIT */ 2 /* 3 * Copyright © 2018 Intel Corporation 4 */ 5 6 #ifndef IGT_ATOMIC_H 7 #define IGT_ATOMIC_H 8 9 #include <linux/preempt.h> 10 #include <linux/bottom_half.h> 11 #include <linux/irqflags.h> 12 13 static void __preempt_begin(void) 14 { 15 preempt_disable(); 16 } 17 18 static void __preempt_end(void) 19 { 20 preempt_enable(); 21 } 22 23 static void __softirq_begin(void) 24 { 25 local_bh_disable(); 26 } 27 28 static void __softirq_end(void) 29 { 30 local_bh_enable(); 31 } 32 33 static void __hardirq_begin(void) 34 { 35 local_irq_disable(); 36 } 37 38 static void __hardirq_end(void) 39 { 40 local_irq_enable(); 41 } 42 43 struct igt_atomic_section { 44 const char *name; 45 void (*critical_section_begin)(void); 46 void (*critical_section_end)(void); 47 }; 48 49 static const struct igt_atomic_section igt_atomic_phases[] = { 50 { "preempt", __preempt_begin, __preempt_end }, 51 { "softirq", __softirq_begin, __softirq_end }, 52 { "hardirq", __hardirq_begin, __hardirq_end }, 53 { } 54 }; 55 56 #endif /* IGT_ATOMIC_H */ 57