blob: fc53e0ad56d905c820c7d2738514b75408abeadd [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Andrew Morton676dcb82006-12-06 20:31:30 -08002#ifndef _LINUX_BH_H
3#define _LINUX_BH_H
4
Stephen Rothwelle52340d2021-11-08 18:32:43 -08005#include <linux/instruction_pointer.h>
Peter Zijlstra0bd3a172013-11-19 16:13:38 +01006#include <linux/preempt.h>
Peter Zijlstra0bd3a172013-11-19 16:13:38 +01007
Thomas Gleixner8b1c04a2021-03-09 09:55:56 +01008#if defined(CONFIG_PREEMPT_RT) || defined(CONFIG_TRACE_IRQFLAGS)
Peter Zijlstra0bd3a172013-11-19 16:13:38 +01009extern void __local_bh_disable_ip(unsigned long ip, unsigned int cnt);
10#else
11static __always_inline void __local_bh_disable_ip(unsigned long ip, unsigned int cnt)
12{
13 preempt_count_add(cnt);
14 barrier();
15}
16#endif
17
18static inline void local_bh_disable(void)
19{
20 __local_bh_disable_ip(_THIS_IP_, SOFTIRQ_DISABLE_OFFSET);
21}
22
Andrew Morton676dcb82006-12-06 20:31:30 -080023extern void _local_bh_enable(void);
Peter Zijlstra0bd3a172013-11-19 16:13:38 +010024extern void __local_bh_enable_ip(unsigned long ip, unsigned int cnt);
25
26static inline void local_bh_enable_ip(unsigned long ip)
27{
28 __local_bh_enable_ip(ip, SOFTIRQ_DISABLE_OFFSET);
29}
30
31static inline void local_bh_enable(void)
32{
33 __local_bh_enable_ip(_THIS_IP_, SOFTIRQ_DISABLE_OFFSET);
34}
Andrew Morton676dcb82006-12-06 20:31:30 -080035
Thomas Gleixner47c218dc2021-03-09 09:55:57 +010036#ifdef CONFIG_PREEMPT_RT
37extern bool local_bh_blocked(void);
38#else
39static inline bool local_bh_blocked(void) { return false; }
40#endif
41
Andrew Morton676dcb82006-12-06 20:31:30 -080042#endif /* _LINUX_BH_H */