Page MenuHomeFreeBSD

D57782.diff
No OneTemporary

D57782.diff

diff --git a/sys/compat/linuxkpi/common/include/linux/hardirq.h b/sys/compat/linuxkpi/common/include/linux/hardirq.h
--- a/sys/compat/linuxkpi/common/include/linux/hardirq.h
+++ b/sys/compat/linuxkpi/common/include/linux/hardirq.h
@@ -36,6 +36,7 @@
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/interrupt.h>
+#include <sys/lock.h>
#define synchronize_irq(irq) _intr_drain((irq))
@@ -49,4 +50,29 @@
*/
#define synchronize_hardirq(irq) _intr_drain((irq))
+/*
+ * irqs_disabled - returns true if the caller should not sleep
+ *
+ * This was originally implemented in drm-kmod in commit 530462939f6.
+ */
+static inline bool
+irqs_disabled(void)
+{
+ return (curthread->td_critnest != 0 || curthread->td_intr_nesting_level != 0);
+}
+
+/*
+ * local_irq_disable / local_irq_enable - mask/unmask hardware interrupts
+ * on the current CPU.
+ *
+ * These map to spinlock_enter()/spinlock_exit(), the machine-independent
+ * primitives already used by kern_mutex.c for this purpose: the first
+ * call in a nested sequence actually disables interrupts and saves the
+ * flags, matching calls unwind it, and only the outermost local_irq_enable()
+ * re-enables interrupts. This also bumps td_critnest, so irqs_disabled()
+ * correctly reports true while interrupts are disabled here.
+ */
+#define local_irq_disable() spinlock_enter()
+#define local_irq_enable() spinlock_exit()
+
#endif /* _LINUXKPI_LINUX_HARDIRQ_H_ */

File Metadata

Mime Type
text/plain
Expires
Mon, Sep 7, 12:54 AM (5 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37325915
Default Alt Text
D57782.diff (1 KB)

Event Timeline