Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Aug 2020 13:19:17 +0000 (UTC)
From:      Emmanuel Vadot <manu@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r364674 - in stable/12/sys/compat/linuxkpi/common: include/linux src
Message-ID:  <202008241319.07ODJHDN055185@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: manu
Date: Mon Aug 24 13:19:16 2020
New Revision: 364674
URL: https://svnweb.freebsd.org/changeset/base/364674

Log:
  MFC r363564-r363567, r363575, r363835-r363837, r363842-r363843, r364232
  
  r363564:
  linuxkpi: Include linux/sizes.h in dma-mapping.h
  
  Linux does the same, this avoids ifdef or extra includes in ported drivers.
  
  Reviewed by:	emaste, hselasky
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D25701
  
  r363565:
  linuxkpi: Include hardirq.h in preempt.h and lockdep.h in hardirq.h
  
  Linux does the same, this avoids ifdef or extra includes in ported drivers.
  
  Reviewed by:	emaste, hselasky
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D25702
  
  r363566:
  linuxkpi: Add taint* defines
  
  This isn't used for us but allow us to port drivers more easily.
  
  Reviewed by:	hselasky
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D25703
  
  r363567:
  Revert r363564
  
  linux/sizes.h doesn't exists in base ... sorry.
  
  r363575:
  Fix r363565
  
  lockdep.h needs sys/lock.h for LOCK_CLASS
  
  r363835:
  linuxkpi: Add linux/sizes.h
  
  This file contain some defines for common sizes.
  
  Sponsored-by: The FreeBSD Foundation
  Reviewed by:	hselasky, emaste
  Differential Revision:	https://reviews.freebsd.org/D25941
  
  r363836:
  linuxkpi: Add kref_put_lock
  
  Same as kref_put but in addition to calling the rel function it will
  acquire the lock first.
  
  Sponsored by: The FreeBSD Foundation
  Reviewed by:	hselasky, emaste
  Differential Revision:	https://reviews.freebsd.org/D25942
  
  r363837:
  linuxkpi: Add nested variant of mutex_lock_interruptible
  
  We don't do anything with the _nesteds variant so just call mutex_lock_interruptible
  
  Sponsoredby: The FreeBSD Foundation
  Reviewed by:	hselasky
  Differential Revision:	https://reviews.freebsd.org/D25944
  
  r363842:
  linuxkpi: Add clear_bit_unlock
  
  This calls clear_bit and adds a memory barrier.
  
  Sponsored by: The FreeBSD Foundation
  
  Reviewed by:	hselasky
  Differential Revision:	https://reviews.freebsd.org/D25943
  
  r363843:
  linuxkpi: Add time_after32 and time_before32
  
  This compare two 32 bits times
  
  Sponsored by: The FreeBSD Foundation
  Reviewed by:	kib, hselasky
  Differential Revision:	https://reviews.freebsd.org/D25700
  
  r364232:
  linuxkpi: Add a few wait_bit functions
  
  The linux function does a lot more than that as multiple waitqueue could be fetch
  from a static table based on the hash of the argument but since in DRM it's only used
  in one place just add a single variable.
  We will probably need to change that in the futur but it's ok with DRM even with current
  linux.
  
  Reviewed by:	hselasky
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D26054

Added:
  stable/12/sys/compat/linuxkpi/common/include/linux/sizes.h
     - copied unchanged from r363837, head/sys/compat/linuxkpi/common/include/linux/sizes.h
  stable/12/sys/compat/linuxkpi/common/include/linux/wait_bit.h
     - copied unchanged from r364232, head/sys/compat/linuxkpi/common/include/linux/wait_bit.h
Modified:
  stable/12/sys/compat/linuxkpi/common/include/linux/bitops.h
  stable/12/sys/compat/linuxkpi/common/include/linux/hardirq.h
  stable/12/sys/compat/linuxkpi/common/include/linux/jiffies.h
  stable/12/sys/compat/linuxkpi/common/include/linux/kernel.h
  stable/12/sys/compat/linuxkpi/common/include/linux/kref.h
  stable/12/sys/compat/linuxkpi/common/include/linux/lockdep.h
  stable/12/sys/compat/linuxkpi/common/include/linux/mutex.h
  stable/12/sys/compat/linuxkpi/common/include/linux/preempt.h
  stable/12/sys/compat/linuxkpi/common/include/linux/wait.h
  stable/12/sys/compat/linuxkpi/common/src/linux_compat.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/bitops.h
==============================================================================
--- stable/12/sys/compat/linuxkpi/common/include/linux/bitops.h	Mon Aug 24 13:15:08 2020	(r364673)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/bitops.h	Mon Aug 24 13:19:16 2020	(r364674)
@@ -275,6 +275,13 @@ find_next_zero_bit(const unsigned long *addr, unsigned
 #define	test_bit(i, a)							\
     !!(READ_ONCE(((volatile const unsigned long *)(a))[BIT_WORD(i)]) & BIT_MASK(i))
 
+static inline void
+clear_bit_unlock(long bit, volatile unsigned long *var)
+{
+	clear_bit(bit, var);
+	wmb();
+}
+
 static inline int
 test_and_clear_bit(long bit, volatile unsigned long *var)
 {

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/hardirq.h
==============================================================================
--- stable/12/sys/compat/linuxkpi/common/include/linux/hardirq.h	Mon Aug 24 13:15:08 2020	(r364673)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/hardirq.h	Mon Aug 24 13:19:16 2020	(r364674)
@@ -32,6 +32,7 @@
 #define	_LINUX_HARDIRQ_H_
 
 #include <linux/types.h>
+#include <linux/lockdep.h>
 
 #include <sys/param.h>
 #include <sys/bus.h>

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/jiffies.h
==============================================================================
--- stable/12/sys/compat/linuxkpi/common/include/linux/jiffies.h	Mon Aug 24 13:15:08 2020	(r364673)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/jiffies.h	Mon Aug 24 13:19:16 2020	(r364674)
@@ -45,7 +45,9 @@
 #define	MAX_JIFFY_OFFSET	((INT_MAX >> 1) - 1)
 
 #define	time_after(a, b)	((int)((b) - (a)) < 0)
+#define	time_after32(a, b)	((int32_t)((uint32_t)(b) - (uint32_t)(a)) < 0)
 #define	time_before(a, b)	time_after(b,a)
+#define	time_before32(a, b)	time_after32(b, a)
 #define	time_after_eq(a, b)	((int)((a) - (b)) >= 0)
 #define	time_before_eq(a, b)	time_after_eq(b, a)
 #define	time_in_range(a,b,c)	\

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/kernel.h
==============================================================================
--- stable/12/sys/compat/linuxkpi/common/include/linux/kernel.h	Mon Aug 24 13:15:08 2020	(r364673)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/kernel.h	Mon Aug 24 13:19:16 2020	(r364674)
@@ -593,4 +593,7 @@ linux_ratelimited(linux_ratelimit_t *rl)
 			    (is_signed(datatype) ? INT8_MIN : 0) \
 )
 
+#define	TAINT_WARN	0
+#define	test_taint(x)	(0)
+
 #endif	/* _LINUX_KERNEL_H_ */

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/kref.h
==============================================================================
--- stable/12/sys/compat/linuxkpi/common/include/linux/kref.h	Mon Aug 24 13:15:08 2020	(r364673)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/kref.h	Mon Aug 24 13:19:16 2020	(r364674)
@@ -38,6 +38,7 @@
 #include <linux/compiler.h>
 #include <linux/kernel.h>
 #include <linux/mutex.h>
+#include <linux/refcount.h>
 
 #include <asm/atomic.h>
 
@@ -76,6 +77,20 @@ kref_put(struct kref *kref, void (*rel)(struct kref *k
 	}
 	return 0;
 }
+
+static inline int
+kref_put_lock(struct kref *kref, void (*rel)(struct kref *kref),
+    spinlock_t *lock)
+{
+
+	if (refcount_release(&kref->refcount.counter)) {
+		spin_lock(lock);
+		rel(kref);
+		return (1);
+	}
+	return (0);
+}
+
 
 static inline int
 kref_sub(struct kref *kref, unsigned int count,

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/lockdep.h
==============================================================================
--- stable/12/sys/compat/linuxkpi/common/include/linux/lockdep.h	Mon Aug 24 13:15:08 2020	(r364673)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/lockdep.h	Mon Aug 24 13:19:16 2020	(r364674)
@@ -32,6 +32,8 @@
 #ifndef _LINUX_LOCKDEP_H_
 #define	_LINUX_LOCKDEP_H_
 
+#include <sys/lock.h>
+
 struct lock_class_key {
 };
 

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/mutex.h
==============================================================================
--- stable/12/sys/compat/linuxkpi/common/include/linux/mutex.h	Mon Aug 24 13:15:08 2020	(r364673)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/mutex.h	Mon Aug 24 13:19:16 2020	(r364674)
@@ -67,6 +67,8 @@ typedef struct mutex {
 	linux_mutex_lock_interruptible(_m);	\
 })
 
+#define	mutex_lock_interruptible_nested(m, c)	mutex_lock_interruptible(m)
+
 /*
  * Reuse the interruptable method since the SX
  * lock handles both signals and interrupts:

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/preempt.h
==============================================================================
--- stable/12/sys/compat/linuxkpi/common/include/linux/preempt.h	Mon Aug 24 13:15:08 2020	(r364673)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/preempt.h	Mon Aug 24 13:19:16 2020	(r364674)
@@ -29,6 +29,7 @@
 #ifndef _LINUX_PREEMPT_H_
 #define	_LINUX_PREEMPT_H_
 
+#include <linux/hardirq.h>
 #include <linux/list.h>
 
 #define	in_interrupt() \

Copied: stable/12/sys/compat/linuxkpi/common/include/linux/sizes.h (from r363837, head/sys/compat/linuxkpi/common/include/linux/sizes.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/sizes.h	Mon Aug 24 13:19:16 2020	(r364674, copy of r363837, head/sys/compat/linuxkpi/common/include/linux/sizes.h)
@@ -0,0 +1,51 @@
+/*-
+ * Copyright (c) 2020 The FreeBSD Foundation
+ *
+ * This software was developed by Emmanuel Vadot under sponsorship
+ * from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef __LINUX_SIZES_H__
+#define	__LINUX_SIZES_H__
+
+#define SZ_1K	(1024 * 1)
+#define SZ_4K	(1024 * 4)
+#define SZ_8K	(1024 * 8)
+#define SZ_16K	(1024 * 16)
+#define SZ_32K	(1024 * 32)
+#define SZ_64K	(1024 * 64)
+#define SZ_128K	(1024 * 128)
+#define SZ_256K	(1024 * 256)
+#define SZ_512K	(1024 * 512)
+
+#define SZ_1M	(1024 * 1024 * 1)
+#define SZ_2M	(1024 * 1024 * 2)
+#define SZ_8M	(1024 * 1024 * 8)
+#define SZ_16M	(1024 * 1024 * 16)
+#define SZ_32M	(1024 * 1024 * 32)
+#define SZ_64M	(1024 * 1024 * 64)
+
+#endif

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/wait.h
==============================================================================
--- stable/12/sys/compat/linuxkpi/common/include/linux/wait.h	Mon Aug 24 13:15:08 2020	(r364673)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/wait.h	Mon Aug 24 13:19:16 2020	(r364674)
@@ -36,6 +36,7 @@
 #include <linux/compiler.h>
 #include <linux/list.h>
 #include <linux/spinlock.h>
+#include <linux/sched.h>
 
 #include <asm/atomic.h>
 

Copied: stable/12/sys/compat/linuxkpi/common/include/linux/wait_bit.h (from r364232, head/sys/compat/linuxkpi/common/include/linux/wait_bit.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/wait_bit.h	Mon Aug 24 13:19:16 2020	(r364674, copy of r364232, head/sys/compat/linuxkpi/common/include/linux/wait_bit.h)
@@ -0,0 +1,64 @@
+/*-
+ * Copyright (c) 2020 The FreeBSD Foundation
+ *
+ * This software was developed by Emmanuel Vadot under sponsorship
+ * from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef __LINUX_WAITBIT_H__
+#define	__LINUX_WAITBIT_H__
+
+#include <linux/wait.h>
+#include <linux/bitops.h>
+
+extern wait_queue_head_t linux_bit_waitq;
+extern wait_queue_head_t linux_var_waitq;
+
+#define	wait_var_event_killable(var, cond) \
+	wait_event_killable(linux_var_waitq, cond)
+
+static inline void
+clear_and_wake_up_bit(int bit, void *word)
+{
+	clear_bit_unlock(bit, word);
+	wake_up_bit(word, bit);
+}
+
+static inline wait_queue_head_t *
+bit_waitqueue(void *word, int bit)
+{
+
+	return (&linux_bit_waitq);
+}
+
+static inline void
+wake_up_var(void *var)
+{
+
+	wake_up(&linux_var_waitq);
+}
+
+#endif	/* __LINUX_WAITBIT_H__ */

Modified: stable/12/sys/compat/linuxkpi/common/src/linux_compat.c
==============================================================================
--- stable/12/sys/compat/linuxkpi/common/src/linux_compat.c	Mon Aug 24 13:15:08 2020	(r364673)
+++ stable/12/sys/compat/linuxkpi/common/src/linux_compat.c	Mon Aug 24 13:19:16 2020	(r364674)
@@ -85,6 +85,7 @@ __FBSDID("$FreeBSD$");
 #include <linux/compat.h>
 #include <linux/poll.h>
 #include <linux/smp.h>
+#include <linux/wait_bit.h>
 
 #if defined(__i386__) || defined(__amd64__)
 #include <asm/smp.h>
@@ -117,6 +118,9 @@ spinlock_t pci_lock;
 
 unsigned long linux_timer_hz_mask;
 
+wait_queue_head_t linux_bit_waitq;
+wait_queue_head_t linux_var_waitq;
+
 int
 panic_cmp(struct rb_node *one, struct rb_node *two)
 {
@@ -2523,6 +2527,8 @@ linux_compat_init(void *arg)
 	mtx_init(&vmmaplock, "IO Map lock", NULL, MTX_DEF);
 	for (i = 0; i < VMMAP_HASH_SIZE; i++)
 		LIST_INIT(&vmmaphead[i]);
+	init_waitqueue_head(&linux_bit_waitq);
+	init_waitqueue_head(&linux_var_waitq);
 }
 SYSINIT(linux_compat, SI_SUB_DRIVERS, SI_ORDER_SECOND, linux_compat_init, NULL);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008241319.07ODJHDN055185>