From a091726622ef3a14e8e277d974997d6d41910669 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Tigeot?= Date: Fri, 24 Jun 2016 16:32:20 +0200 Subject: [PATCH] drm/linux: Implement some spin_lock_irq* functions They are not just simple spin_lock/spin_unlock() variants but disable hardware interrupt processing on the current cpu. Suggested-by: Matt Macy --- sys/dev/drm/include/linux/spinlock.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/sys/dev/drm/include/linux/spinlock.h b/sys/dev/drm/include/linux/spinlock.h index 10f0814a56..1d9908deb8 100644 --- a/sys/dev/drm/include/linux/spinlock.h +++ b/sys/dev/drm/include/linux/spinlock.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 François Tigeot + * Copyright (c) 2015-2016 François Tigeot * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,4 +37,25 @@ #define assert_spin_locked(x) KKASSERT(lockcountnb(x)) +/* + * The spin_lock_irq() family of functions stop hardware interrupts + * from being delivered to the local CPU. + * A crit_enter()/crit_exit() sequence does the same thing on the + * DragonFly kernel + */ +static inline void spin_lock_irq(struct lock *lock) +{ + lockmgr(lock, LK_EXCLUSIVE); + crit_enter(); +} + +static inline void spin_unlock_irq(struct lock *lock) +{ + crit_exit(); + lockmgr(lock, LK_RELEASE); +} + +#define spin_lock_irqsave(lock, flags) do { flags = 0; spin_lock_irq(lock); } while(0) +#define spin_unlock_irqrestore(lock, flags) spin_unlock_irq(lock) + #endif /* _LINUX_SPINLOCK_H_ */ -- 2.11.4.GIT