aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeel Chauhan <nc@FreeBSD.org>2021-04-26 15:15:49 +0000
committerNeel Chauhan <nc@FreeBSD.org>2021-04-26 15:44:30 +0000
commitda6a8ccfa293c3c831fdde51169754fcb9587657 (patch)
treee3d657db0f1c224e83034877e3261f825ef7a4af
parent3e6b8bcf6e8ee41591e2d27879f0a3baa9ebbb16 (diff)
downloadsrc-da6a8ccfa293c3c831fdde51169754fcb9587657.tar.gz
src-da6a8ccfa293c3c831fdde51169754fcb9587657.zip
linuxkpi: Implement atomic_dec_and_lock_irqsave()
This is needed by the drm-kmod 5.5 update. Reviewed by: hselasky, manu MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D29988 (cherry picked from commit ce65353ac1a17677bef03e96df8da967c9086743)
-rw-r--r--sys/compat/linuxkpi/common/include/linux/spinlock.h13
-rw-r--r--sys/sys/param.h2
2 files changed, 14 insertions, 1 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/spinlock.h b/sys/compat/linuxkpi/common/include/linux/spinlock.h
index 2309794b26ec..7ef474b671dc 100644
--- a/sys/compat/linuxkpi/common/include/linux/spinlock.h
+++ b/sys/compat/linuxkpi/common/include/linux/spinlock.h
@@ -31,6 +31,7 @@
#ifndef _LINUX_SPINLOCK_H_
#define _LINUX_SPINLOCK_H_
+#include <asm/atomic.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/lock.h>
@@ -160,4 +161,16 @@ spin_lock_destroy(spinlock_t *lock)
mtx_assert(&(_l)->m, MA_OWNED); \
} while (0)
+static inline int
+atomic_dec_and_lock_irqsave(atomic_t *cnt, spinlock_t *lock,
+ unsigned long flags)
+{
+ spin_lock_irqsave(lock, flags);
+ if (atomic_dec_and_test(cnt)) {
+ return (1);
+ }
+ spin_unlock_irqrestore(lock, flags);
+ return (0);
+}
+
#endif /* _LINUX_SPINLOCK_H_ */
diff --git a/sys/sys/param.h b/sys/sys/param.h
index 1930af51f7da..a08ec36f6fcc 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -60,7 +60,7 @@
* in the range 5 to 9.
*/
#undef __FreeBSD_version
-#define __FreeBSD_version 1300501 /* Master, propagated to newvers */
+#define __FreeBSD_version 1300502 /* Master, propagated to newvers */
/*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,