CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2014-03-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar  7 15:39:18 UTC 2014

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: completion.h

Log Message:
Fix return value of wait_for_completion_interruptible_timeout.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.5 -r1.1.2.6 \
src/sys/external/bsd/drm2/include/linux/completion.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/completion.h
diff -u src/sys/external/bsd/drm2/include/linux/completion.h:1.1.2.5 src/sys/external/bsd/drm2/include/linux/completion.h:1.1.2.6
--- src/sys/external/bsd/drm2/include/linux/completion.h:1.1.2.5	Sun Sep  8 16:01:49 2013
+++ src/sys/external/bsd/drm2/include/linux/completion.h	Fri Mar  7 15:39:18 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: completion.h,v 1.1.2.5 2013/09/08 16:01:49 riastradh Exp $	*/
+/*	$NetBSD: completion.h,v 1.1.2.6 2014/03/07 15:39:18 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,6 +38,8 @@
 
 #include machine/limits.h
 
+#include linux/errno.h
+
 struct completion {
 	kmutex_t	c_lock;
 	kcondvar_t	c_cv;
@@ -152,17 +154,25 @@ static inline int
 wait_for_completion_interruptible_timeout(struct completion *completion,
 unsigned long ticks)
 {
+	/* XXX Arithmetic overflow...?  */
+	unsigned int start = hardclock_ticks, now;
 	int error;
 
 	mutex_enter(completion-c_lock);
 
 	/* Wait until c_done is nonzero.  */
 	while (completion-c_done == 0) {
-		/* XXX errno NetBSD-Linux */
-		error = -cv_timedwait_sig(completion-c_cv,
+		error = cv_timedwait_sig(completion-c_cv,
 		completion-c_lock, ticks);
 		if (error)
 			goto out;
+		now = hardclock_ticks;
+		if (ticks  (now - start)) {
+			error = EWOULDBLOCK;
+			goto out;
+		}
+		ticks -= (now - start);
+		start = now;
 	}
 
 	/* Claim a completion if it's not open season.  */
@@ -175,7 +185,14 @@ wait_for_completion_interruptible_timeou
 	error = 0;
 
 out:	mutex_exit(completion-c_lock);
-	return error;
+	if (error == EWOULDBLOCK) {
+		return 0;
+	} else if ((error == EINTR) || (error == ERESTART)) {
+		return -ERESTARTSYS;
+	} else {
+		KASSERTMSG((error == 0), error = %d, error);
+		return ticks;
+	}
 }
 
 #endif	/* _LINUX_COMPLETION_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/drm

2014-03-05 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Mar  5 15:08:00 UTC 2014

Modified Files:
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]: intel-gtt.h

Log Message:
Oops -- define struct intel_gtt::do_idle_maps.

Missed this in last commit.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/sys/external/bsd/drm2/include/drm/intel-gtt.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/intel-gtt.h
diff -u src/sys/external/bsd/drm2/include/drm/intel-gtt.h:1.1.2.2 src/sys/external/bsd/drm2/include/drm/intel-gtt.h:1.1.2.3
--- src/sys/external/bsd/drm2/include/drm/intel-gtt.h:1.1.2.2	Sun Sep  8 15:40:17 2013
+++ src/sys/external/bsd/drm2/include/drm/intel-gtt.h	Wed Mar  5 15:08:00 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: intel-gtt.h,v 1.1.2.2 2013/09/08 15:40:17 riastradh Exp $	*/
+/*	$NetBSD: intel-gtt.h,v 1.1.2.3 2014/03/05 15:08:00 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -48,6 +48,7 @@ struct intel_gtt {
 	bus_dma_segment_t	gtt_scratch_seg;
 	bus_dmamap_t		gtt_scratch_map;
 	bus_space_handle_t	gtt_bsh;
+	bool			do_idle_maps;
 };
 
 struct intel_gtt *



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2014-01-21 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Jan 21 20:49:10 UTC 2014

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: slab.h

Log Message:
Make Linux kmalloc handle a few more gfp flags.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.9 -r1.1.2.10 \
src/sys/external/bsd/drm2/include/linux/slab.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/slab.h
diff -u src/sys/external/bsd/drm2/include/linux/slab.h:1.1.2.9 src/sys/external/bsd/drm2/include/linux/slab.h:1.1.2.10
--- src/sys/external/bsd/drm2/include/linux/slab.h:1.1.2.9	Mon Dec 30 04:51:24 2013
+++ src/sys/external/bsd/drm2/include/linux/slab.h	Tue Jan 21 20:49:10 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: slab.h,v 1.1.2.9 2013/12/30 04:51:24 riastradh Exp $	*/
+/*	$NetBSD: slab.h,v 1.1.2.10 2014/01/21 20:49:10 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -47,16 +47,34 @@ linux_gfp_to_malloc(gfp_t gfp)
 {
 	int flags = 0;
 
-	/* XXX Handle other cases as they arise.  */
-	KASSERT((gfp == GFP_ATOMIC) || (gfp == GFP_KERNEL));
+	/* This has no meaning to us.  */
+	gfp = ~__GFP_NOWARN;
 
-	if (ISSET(gfp, __GFP_WAIT))
-		flags |= M_WAITOK;
-	else
-		flags |= M_NOWAIT;
+	/* Pretend this was the same as not passing __GFP_WAIT.  */
+	if (ISSET(gfp, __GFP_NORETRY)) {
+		gfp = ~__GFP_NORETRY;
+		gfp = ~__GFP_WAIT;
+	}
 
-	if (ISSET(gfp, __GFP_ZERO))
+	if (ISSET(gfp, __GFP_ZERO)) {
 		flags |= M_ZERO;
+		gfp = ~__GFP_ZERO;
+	}
+
+	/*
+	 * XXX Handle other cases as they arise -- prefer to fail early
+	 * rather than allocate memory without respecting parameters we
+	 * don't understand.
+	 */
+	KASSERT((gfp == GFP_ATOMIC) ||
+	((gfp  ~__GFP_WAIT) == (GFP_KERNEL  ~__GFP_WAIT)));
+
+	if (ISSET(gfp, __GFP_WAIT)) {
+		flags |= M_WAITOK;
+		gfp = ~__GFP_WAIT;
+	} else {
+		flags |= M_NOWAIT;
+	}
 
 	return flags;
 }



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/drm

2014-01-21 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Jan 21 20:49:20 UTC 2014

Modified Files:
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]:
drm_copy_netbsd.h

Log Message:
Fix order of arguments in DRM_COPY_TO_USER.

...


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \
src/sys/external/bsd/drm2/include/drm/drm_copy_netbsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/drm_copy_netbsd.h
diff -u src/sys/external/bsd/drm2/include/drm/drm_copy_netbsd.h:1.1.2.3 src/sys/external/bsd/drm2/include/drm/drm_copy_netbsd.h:1.1.2.4
--- src/sys/external/bsd/drm2/include/drm/drm_copy_netbsd.h:1.1.2.3	Wed Jul 24 02:04:16 2013
+++ src/sys/external/bsd/drm2/include/drm/drm_copy_netbsd.h	Tue Jan 21 20:49:20 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_copy_netbsd.h,v 1.1.2.3 2013/07/24 02:04:16 riastradh Exp $	*/
+/*	$NetBSD: drm_copy_netbsd.h,v 1.1.2.4 2014/01/21 20:49:20 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@ DRM_COPY_FROM_USER(void *kernel_addr, co
 }
 
 static inline int
-DRM_COPY_TO_USER(const void *kernel_addr, void *user_addr, size_t len)
+DRM_COPY_TO_USER(void *user_addr, const void *kernel_addr, size_t len)
 {
 	/* XXX errno NetBSD-Linux */
 	return -copyout(kernel_addr, user_addr, len);



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2014-01-15 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jan 15 21:25:39 UTC 2014

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: ktime.h

Log Message:
Use nanouptime, not nanotime, for ktime_get.

As far as I can tell, ktime_get is supposed to provide monotonic
time, not a clock synchronized to TAI.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/sys/external/bsd/drm2/include/linux/ktime.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/ktime.h
diff -u src/sys/external/bsd/drm2/include/linux/ktime.h:1.1.2.2 src/sys/external/bsd/drm2/include/linux/ktime.h:1.1.2.3
--- src/sys/external/bsd/drm2/include/linux/ktime.h:1.1.2.2	Wed Jul 24 02:31:08 2013
+++ src/sys/external/bsd/drm2/include/linux/ktime.h	Wed Jan 15 21:25:39 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ktime.h,v 1.1.2.2 2013/07/24 02:31:08 riastradh Exp $	*/
+/*	$NetBSD: ktime.h,v 1.1.2.3 2014/01/15 21:25:39 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@ ktime_get(void)
 	ktime_t kt;
 
 	/* XXX nanotime or nanouptime?  */
-	nanotime(ts);
+	nanouptime(ts);
 
 	/* XXX Silently truncate?  */
 	kt.kt_sec_nsec.ktsn_sec = ts.tv_sec  0xUL;



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2014-01-15 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jan 15 21:25:49 UTC 2014

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: ktime.h

Log Message:
Initialize the nsec correctly in ktime_get.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \
src/sys/external/bsd/drm2/include/linux/ktime.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/ktime.h
diff -u src/sys/external/bsd/drm2/include/linux/ktime.h:1.1.2.3 src/sys/external/bsd/drm2/include/linux/ktime.h:1.1.2.4
--- src/sys/external/bsd/drm2/include/linux/ktime.h:1.1.2.3	Wed Jan 15 21:25:39 2014
+++ src/sys/external/bsd/drm2/include/linux/ktime.h	Wed Jan 15 21:25:49 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ktime.h,v 1.1.2.3 2014/01/15 21:25:39 riastradh Exp $	*/
+/*	$NetBSD: ktime.h,v 1.1.2.4 2014/01/15 21:25:49 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -137,7 +137,7 @@ ktime_get(void)
 
 	/* XXX Silently truncate?  */
 	kt.kt_sec_nsec.ktsn_sec = ts.tv_sec  0xUL;
-	kt.kt_sec_nsec.ktsn_sec = ts.tv_nsec;
+	kt.kt_sec_nsec.ktsn_nsec = ts.tv_nsec;
 
 	return kt;
 }



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-12-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Dec 30 04:51:24 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: slab.h

Log Message:
Avoid dividing by zero when allocating empty array in kcalloc.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.8 -r1.1.2.9 \
src/sys/external/bsd/drm2/include/linux/slab.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/slab.h
diff -u src/sys/external/bsd/drm2/include/linux/slab.h:1.1.2.8 src/sys/external/bsd/drm2/include/linux/slab.h:1.1.2.9
--- src/sys/external/bsd/drm2/include/linux/slab.h:1.1.2.8	Wed Jul 24 04:01:51 2013
+++ src/sys/external/bsd/drm2/include/linux/slab.h	Mon Dec 30 04:51:24 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: slab.h,v 1.1.2.8 2013/07/24 04:01:51 riastradh Exp $	*/
+/*	$NetBSD: slab.h,v 1.1.2.9 2013/12/30 04:51:24 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -76,7 +76,8 @@ kzalloc(size_t size, gfp_t gfp)
 static inline void *
 kcalloc(size_t n, size_t size, gfp_t gfp)
 {
-	KASSERT(size = (SIZE_MAX / n));
+	KASSERT(size != 0);
+	KASSERT(n = (SIZE_MAX / size));
 	return malloc((n * size), M_TEMP, (linux_gfp_to_malloc(gfp) | M_ZERO));
 }
 



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 15:33:35 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: kref.h

Log Message:
Fix sense of atomic_cas loop condition and use kassertmsg for krefs.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/sys/external/bsd/drm2/include/linux/kref.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/kref.h
diff -u src/sys/external/bsd/drm2/include/linux/kref.h:1.1.2.2 src/sys/external/bsd/drm2/include/linux/kref.h:1.1.2.3
--- src/sys/external/bsd/drm2/include/linux/kref.h:1.1.2.2	Wed Jul 24 01:51:36 2013
+++ src/sys/external/bsd/drm2/include/linux/kref.h	Sun Sep  8 15:33:35 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: kref.h,v 1.1.2.2 2013/07/24 01:51:36 riastradh Exp $	*/
+/*	$NetBSD: kref.h,v 1.1.2.3 2013/09/08 15:33:35 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@ kref_get(struct kref *kref)
 	const unsigned int count __unused =
 	atomic_inc_uint_nv(kref-kr_count);
 
-	KASSERT(count  1);
+	KASSERTMSG((count  1), getting released kref);
 }
 
 static inline int
@@ -64,9 +64,10 @@ kref_sub(struct kref *kref, unsigned int
 
 	do {
 		old = kref-kr_count;
-		KASSERT(count = old);
+		KASSERTMSG((count = old), overreleasing kref: %u - %u,
+		old, count);
 		new = (old - count);
-	} while (atomic_cas_uint(kref-kr_count, old, new) == old);
+	} while (atomic_cas_uint(kref-kr_count, old, new) != old);
 
 	if (new == 0) {
 		(*release)(kref);



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/asm

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 15:35:06 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/asm [riastradh-drm2]: io.h

Log Message:
Define page_to_phys in Linux asm/io.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/external/bsd/drm2/include/asm/io.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/asm/io.h
diff -u src/sys/external/bsd/drm2/include/asm/io.h:1.1.2.3 src/sys/external/bsd/drm2/include/asm/io.h:1.1.2.4
--- src/sys/external/bsd/drm2/include/asm/io.h:1.1.2.3	Wed Jul 24 03:44:10 2013
+++ src/sys/external/bsd/drm2/include/asm/io.h	Sun Sep  8 15:35:06 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.h,v 1.1.2.3 2013/07/24 03:44:10 riastradh Exp $	*/
+/*	$NetBSD: io.h,v 1.1.2.4 2013/09/08 15:35:06 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,6 +32,12 @@
 #ifndef _ASM_IO_H_
 #define _ASM_IO_H_
 
+#include sys/bus.h
+
+#include uvm/uvm_page.h
+
+#include linux/mm_types.h
+
 /*
  * XXX This is bollocks, and is wrong on various architectures (should
  * work for x86; who knows what else), but bus_space_barrier won't work
@@ -43,4 +49,16 @@
 #define	memcpy_toio	memcpy
 #define	memset_io	memset
 
+/*
+ * XXX Not sure why this is here, but so it is in Linux...  Also, not
+ * sure what the right type is: Linux uses dma_addr_t, but I don't
+ * think bus_addr_t is right here -- paddr_t sounds more appropriate.
+ */
+
+static inline bus_addr_t
+page_to_phys(struct page *page)
+{
+	return VM_PAGE_TO_PHYS(page-p_vmp);
+}
+
 #endif  /* _ASM_IO_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/asm

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 15:35:36 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/asm [riastradh-drm2]: uaccess.h

Log Message:
Add some copy_to/from_user variants to Linux asm/uaccess.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 \
src/sys/external/bsd/drm2/include/asm/uaccess.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/asm/uaccess.h
diff -u src/sys/external/bsd/drm2/include/asm/uaccess.h:1.1.2.4 src/sys/external/bsd/drm2/include/asm/uaccess.h:1.1.2.5
--- src/sys/external/bsd/drm2/include/asm/uaccess.h:1.1.2.4	Wed Jul 24 02:12:14 2013
+++ src/sys/external/bsd/drm2/include/asm/uaccess.h	Sun Sep  8 15:35:36 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: uaccess.h,v 1.1.2.4 2013/07/24 02:12:14 riastradh Exp $	*/
+/*	$NetBSD: uaccess.h,v 1.1.2.5 2013/09/08 15:35:36 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -35,6 +35,19 @@
 #include sys/types.h
 #include sys/systm.h
 
+/* XXX This is a cop-out.  */
+#define	VERIFY_READ	0
+#define	VERIFY_WRITE	1
+static inline bool
+access_ok(int verify_op __unused, const void *uaddr __unused,
+size_t nbytes __unused)
+{
+	return true;
+}
+
+#define	__copy_from_user	copy_from_user
+#define	__copy_to_user		copy_to_user
+
 static inline int
 copy_from_user(void *kernel_addr, const void *user_addr, size_t len)
 {
@@ -55,4 +68,33 @@ copy_to_user(void *user_addr, const void
 #define	put_user(KERNEL_LOC, USER_ADDR)	\
 	copy_to_user((USER_ADDR), (KERNEL_LOC), sizeof(KERNEL_LOC))
 
+#if 0
+/*
+ * XXX These `inatomic' versions are a cop out, but they should do for
+ * now -- they are used only in fast paths which can't fault but which
+ * can fall back to slower paths that arrange things so faulting is OK.
+ */
+
+static inline int
+__copy_from_user_inatomic(void *kernel_addr __unused,
+const void *user_addr __unused, size_t len __unused)
+{
+	return -EFAULT;
+}
+
+static inline int
+__copy_to_user_inatomic(void *user_addr __unused,
+const void *kernel_addr __unused, size_t len __unused)
+{
+	return -EFAULT;
+}
+#endif	/* 0 */
+
+static inline int
+__copy_from_user_inatomic_nocache(void *kernel_addr __unused,
+const void *user_addr __unused, size_t len __unused)
+{
+	return -EFAULT;
+}
+
 #endif  /* _ASM_UACCESS_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 15:36:05 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include [riastradh-drm2]: i915_trace.h

Log Message:
Add trace_i915_gem_object_unbind.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 \
src/sys/external/bsd/drm2/include/i915_trace.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/i915_trace.h
diff -u src/sys/external/bsd/drm2/include/i915_trace.h:1.1.2.4 src/sys/external/bsd/drm2/include/i915_trace.h:1.1.2.5
--- src/sys/external/bsd/drm2/include/i915_trace.h:1.1.2.4	Wed Jul 24 03:29:14 2013
+++ src/sys/external/bsd/drm2/include/i915_trace.h	Sun Sep  8 15:36:05 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: i915_trace.h,v 1.1.2.4 2013/07/24 03:29:14 riastradh Exp $	*/
+/*	$NetBSD: i915_trace.h,v 1.1.2.5 2013/09/08 15:36:05 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -105,6 +105,11 @@ trace_i915_gem_object_pwrite(struct drm_
 }
 
 static inline void
+trace_i915_gem_object_unbind(struct drm_i915_gem_object *obj __unused)
+{
+}
+
+static inline void
 trace_i915_gem_request_add(struct intel_ring_buffer *ring __unused,
 uint32_t seqno __unused)
 {



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 15:36:35 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: errno.h

Log Message:
Add ERESTARTSYS as a Linuxoid alias for ERESTART.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/sys/external/bsd/drm2/include/linux/errno.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/errno.h
diff -u src/sys/external/bsd/drm2/include/linux/errno.h:1.1.2.2 src/sys/external/bsd/drm2/include/linux/errno.h:1.1.2.3
--- src/sys/external/bsd/drm2/include/linux/errno.h:1.1.2.2	Wed Jul 24 01:57:50 2013
+++ src/sys/external/bsd/drm2/include/linux/errno.h	Sun Sep  8 15:36:35 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: errno.h,v 1.1.2.2 2013/07/24 01:57:50 riastradh Exp $	*/
+/*	$NetBSD: errno.h,v 1.1.2.3 2013/09/08 15:36:35 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -34,4 +34,6 @@
 
 #include sys/errno.h
 
+#define	ERESTARTSYS	ERESTART
+
 #endif  /* _LINUX_ERRNO_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 15:37:04 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: atomic.h

Log Message:
Fix Linux atomic set/clear/change_bit to work on arrays.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.9 -r1.1.2.10 \
src/sys/external/bsd/drm2/include/linux/atomic.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/atomic.h
diff -u src/sys/external/bsd/drm2/include/linux/atomic.h:1.1.2.9 src/sys/external/bsd/drm2/include/linux/atomic.h:1.1.2.10
--- src/sys/external/bsd/drm2/include/linux/atomic.h:1.1.2.9	Wed Jul 24 03:35:50 2013
+++ src/sys/external/bsd/drm2/include/linux/atomic.h	Sun Sep  8 15:37:04 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: atomic.h,v 1.1.2.9 2013/07/24 03:35:50 riastradh Exp $	*/
+/*	$NetBSD: atomic.h,v 1.1.2.10 2013/09/08 15:37:04 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -34,6 +34,8 @@
 
 #include sys/atomic.h
 
+#include machine/limits.h
+
 struct atomic {
 	union {
 		int au_int;
@@ -125,53 +127,69 @@ atomic_inc_not_zero(atomic_t *atomic)
 }
 
 static inline void
-set_bit(unsigned long bit, volatile unsigned long *ptr)
+set_bit(unsigned int bit, volatile unsigned long *ptr)
 {
-	atomic_or_ulong(ptr, (1  bit));
+	const unsigned int units = (sizeof(*ptr) * CHAR_BIT);
+
+	atomic_or_ulong(ptr[bit / units], (1UL  (bit % units)));
 }
 
 static inline void
-clear_bit(unsigned long bit, volatile unsigned long *ptr)
+clear_bit(unsigned int bit, volatile unsigned long *ptr)
 {
-	atomic_and_ulong(ptr, ~(1  bit));
+	const unsigned int units = (sizeof(*ptr) * CHAR_BIT);
+
+	atomic_and_ulong(ptr[bit / units], ~(1UL  (bit % units)));
 }
 
 static inline void
-change_bit(unsigned long bit, volatile unsigned long *ptr)
+change_bit(unsigned int bit, volatile unsigned long *ptr)
 {
+	const unsigned int units = (sizeof(*ptr) * CHAR_BIT);
+	volatile unsigned long *const p = ptr[bit / units];
+	const unsigned long mask = (1UL  (bit % units));
 	unsigned long v;
 
-	do v = *ptr; while (atomic_cas_ulong(ptr, v, v ^ (1  bit)) != v);
+	do v = *p; while (atomic_cas_ulong(p, v, (v ^ mask)) != v);
 }
 
 static inline unsigned long
-test_and_set_bit(unsigned long bit, volatile unsigned long *ptr)
+test_and_set_bit(unsigned int bit, volatile unsigned long *ptr)
 {
+	const unsigned int units = (sizeof(*ptr) * CHAR_BIT);
+	volatile unsigned long *const p = ptr[bit / units];
+	const unsigned long mask = (1UL  (bit % units));
 	unsigned long v;
 
-	do v = *ptr; while (atomic_cas_ulong(ptr, v, v | (1  bit)) != v);
+	do v = *p; while (atomic_cas_ulong(p, v, (v | mask)) != v);
 
-	return (v  (1  bit));
+	return (v  mask);
 }
 
 static inline unsigned long
-test_and_clear_bit(unsigned long bit, volatile unsigned long *ptr)
+test_and_clear_bit(unsigned int bit, volatile unsigned long *ptr)
 {
+	const unsigned int units = (sizeof(*ptr) * CHAR_BIT);
+	volatile unsigned long *const p = ptr[bit / units];
+	const unsigned long mask = (1UL  (bit % units));
 	unsigned long v;
 
-	do v = *ptr; while (atomic_cas_ulong(ptr, v, v ~ (1  bit)) != v);
+	do v = *p; while (atomic_cas_ulong(p, v, (v  ~mask)) != v);
 
-	return (v  (1  bit));
+	return (v  mask);
 }
 
 static inline unsigned long
-test_and_change_bit(unsigned long bit, volatile unsigned long *ptr)
+test_and_change_bit(unsigned int bit, volatile unsigned long *ptr)
 {
+	const unsigned int units = (sizeof(*ptr) * CHAR_BIT);
+	volatile unsigned long *const p = ptr[bit / units];
+	const unsigned long mask = (1UL  (bit % units));
 	unsigned long v;
 
-	do v = *ptr; while (atomic_cas_ulong(ptr, v, v ^ (1  bit)) != v);
+	do v = *p; while (atomic_cas_ulong(p, v, (v ^ mask)) != v);
 
-	return (v  (1  bit));
+	return (v  mask);
 }
 
 #if defined(MULTIPROCESSOR)  !defined(__HAVE_ATOMIC_AS_MEMBAR)



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 15:38:05 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: jiffies.h
log2.h pagemap.h time.h timer.h types.h

Log Message:
More miscellaneous Linux header cruft.  See patch for details.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \
src/sys/external/bsd/drm2/include/linux/jiffies.h \
src/sys/external/bsd/drm2/include/linux/timer.h
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/sys/external/bsd/drm2/include/linux/log2.h
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/linux/pagemap.h \
src/sys/external/bsd/drm2/include/linux/time.h
cvs rdiff -u -r1.1.2.7 -r1.1.2.8 \
src/sys/external/bsd/drm2/include/linux/types.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/jiffies.h
diff -u src/sys/external/bsd/drm2/include/linux/jiffies.h:1.1.2.3 src/sys/external/bsd/drm2/include/linux/jiffies.h:1.1.2.4
--- src/sys/external/bsd/drm2/include/linux/jiffies.h:1.1.2.3	Wed Jul 24 03:03:23 2013
+++ src/sys/external/bsd/drm2/include/linux/jiffies.h	Sun Sep  8 15:38:04 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: jiffies.h,v 1.1.2.3 2013/07/24 03:03:23 riastradh Exp $	*/
+/*	$NetBSD: jiffies.h,v 1.1.2.4 2013/09/08 15:38:04 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -49,6 +49,12 @@ usecs_to_jiffies(unsigned int usec)
 	return mstohz((usec + (1000 / hz) - 1) / (1000 / hz));
 }
 
+static inline unsigned int
+timespec_to_jiffies(const struct timespec *ts)
+{
+	return tstohz(ts);
+}
+
 /* XXX long is the wrong type here times...  */
 
 #define	__linux_time_compare(A, OP, B)	(((long)(A) - (long)(B)) OP 0)
Index: src/sys/external/bsd/drm2/include/linux/timer.h
diff -u src/sys/external/bsd/drm2/include/linux/timer.h:1.1.2.3 src/sys/external/bsd/drm2/include/linux/timer.h:1.1.2.4
--- src/sys/external/bsd/drm2/include/linux/timer.h:1.1.2.3	Wed Jul 24 03:50:16 2013
+++ src/sys/external/bsd/drm2/include/linux/timer.h	Sun Sep  8 15:38:04 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: timer.h,v 1.1.2.3 2013/07/24 03:50:16 riastradh Exp $	*/
+/*	$NetBSD: timer.h,v 1.1.2.4 2013/09/08 15:38:04 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -78,4 +78,10 @@ round_jiffies_up(unsigned long j)
 	return roundup(j, hz);
 }
 
+static inline unsigned long
+round_jiffies_up_relative(unsigned long j)
+{
+	return roundup(j, hz);
+}
+
 #endif  /* _LINUX_TIMER_H_ */

Index: src/sys/external/bsd/drm2/include/linux/log2.h
diff -u src/sys/external/bsd/drm2/include/linux/log2.h:1.1.2.2 src/sys/external/bsd/drm2/include/linux/log2.h:1.1.2.3
--- src/sys/external/bsd/drm2/include/linux/log2.h:1.1.2.2	Wed Jul 24 02:03:00 2013
+++ src/sys/external/bsd/drm2/include/linux/log2.h	Sun Sep  8 15:38:04 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: log2.h,v 1.1.2.2 2013/07/24 02:03:00 riastradh Exp $	*/
+/*	$NetBSD: log2.h,v 1.1.2.3 2013/09/08 15:38:04 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -34,4 +34,10 @@
 
 #include sys/bitops.h
 
+static inline bool
+is_power_of_2(unsigned long x)
+{
+	return ((x != 0)  (((x - 1)  x) == 0));
+}
+
 #endif  /* _LINUX_LOG2_H_ */

Index: src/sys/external/bsd/drm2/include/linux/pagemap.h
diff -u src/sys/external/bsd/drm2/include/linux/pagemap.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/pagemap.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/pagemap.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/pagemap.h	Sun Sep  8 15:38:04 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: pagemap.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $	*/
+/*	$NetBSD: pagemap.h,v 1.1.2.2 2013/09/08 15:38:04 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,16 @@
 #ifndef _LINUX_PAGEMAP_H_
 #define _LINUX_PAGEMAP_H_
 
+static inline int
+fault_in_multipages_readable(const char *uaddr __unused, size_t len __unused)
+{
+	return 0;
+}
+
+static inline int
+fault_in_multipages_writeable(char *uaddr __unused, size_t len __unused)
+{
+	return 0;
+}
+
 #endif  /* _LINUX_PAGEMAP_H_ */
Index: src/sys/external/bsd/drm2/include/linux/time.h
diff -u src/sys/external/bsd/drm2/include/linux/time.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/time.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/time.h:1.1.2.1	Wed Jul 24 03:18:46 2013
+++ src/sys/external/bsd/drm2/include/linux/time.h	Sun Sep  8 15:38:04 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: time.h,v 1.1.2.1 2013/07/24 03:18:46 riastradh Exp $	*/
+/*	$NetBSD: time.h,v 1.1.2.2 2013/09/08 15:38:04 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -48,4 +48,66 @@ get_seconds(void)
 	return time_second;
 }
 
+static inline void
+getrawmonotonic(struct timespec *ts)
+{
+	getnanouptime(ts);
+}
+
+static inline bool
+timespec_valid(const struct timespec 

CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 15:37:34 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: bitops.h

Log Message:
Add Linuxoid non-atomic __set/clear_bit to linux/bitops.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/sys/external/bsd/drm2/include/linux/bitops.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/bitops.h
diff -u src/sys/external/bsd/drm2/include/linux/bitops.h:1.1.2.2 src/sys/external/bsd/drm2/include/linux/bitops.h:1.1.2.3
--- src/sys/external/bsd/drm2/include/linux/bitops.h:1.1.2.2	Wed Jul 24 03:44:39 2013
+++ src/sys/external/bsd/drm2/include/linux/bitops.h	Sun Sep  8 15:37:34 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: bitops.h,v 1.1.2.2 2013/07/24 03:44:39 riastradh Exp $	*/
+/*	$NetBSD: bitops.h,v 1.1.2.3 2013/09/08 15:37:34 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,6 +32,13 @@
 #ifndef _LINUX_BITOPS_H_
 #define _LINUX_BITOPS_H_
 
+#include sys/types.h
+#include sys/param.h
+#include sys/atomic.h
+#include sys/cdefs.h
+
+#include machine/limits.h
+
 #include lib/libkern/libkern.h
 
 static inline unsigned int
@@ -40,4 +47,45 @@ hweight16(uint16_t n)
 	return popcount32(n);
 }
 
+/*
+ * XXX Don't define BITS_PER_LONG as sizeof(unsigned long)*CHAR_BIT
+ * because that won't work in preprocessor conditionals, where it often
+ * turns up.
+ */
+
+#define	BITS_TO_LONGS(n)		\
+	roundup2((n), (sizeof(unsigned long) * CHAR_BIT))
+
+static inline int
+test_bit(unsigned int n, const volatile unsigned long *p)
+{
+	const unsigned units = (sizeof(unsigned long) * CHAR_BIT);
+
+	return ((p[n / units]  (1UL  (n % units))) != 0);
+}
+
+static inline void
+__set_bit(unsigned int n, volatile unsigned long *p)
+{
+	const unsigned units = (sizeof(unsigned long) * CHAR_BIT);
+
+	p[n / units] |= (1UL  (n % units));
+}
+
+static inline void
+__clear_bit(unsigned int n, volatile unsigned long *p)
+{
+	const unsigned units = (sizeof(unsigned long) * CHAR_BIT);
+
+	p[n / units] = ~(1UL  (n % units));
+}
+
+static inline void
+__change_bit(unsigned int n, volatile unsigned long *p)
+{
+	const unsigned units = (sizeof(unsigned long) * CHAR_BIT);
+
+	p[n / units] ^= (1UL  (n % units));
+}
+
 #endif  /* _LINUX_BITOPS_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 15:38:35 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: mm.h

Log Message:
Fix definition of Linux PAGE_ALIGN in linux/mm.h.

Can't use uvm round_page because that depends on PAGE_MASK, whose
sense we have to invert for Linux!  Plurgh.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 src/sys/external/bsd/drm2/include/linux/mm.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/mm.h
diff -u src/sys/external/bsd/drm2/include/linux/mm.h:1.1.2.4 src/sys/external/bsd/drm2/include/linux/mm.h:1.1.2.5
--- src/sys/external/bsd/drm2/include/linux/mm.h:1.1.2.4	Wed Jul 24 03:58:04 2013
+++ src/sys/external/bsd/drm2/include/linux/mm.h	Sun Sep  8 15:38:35 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: mm.h,v 1.1.2.4 2013/07/24 03:58:04 riastradh Exp $	*/
+/*	$NetBSD: mm.h,v 1.1.2.5 2013/09/08 15:38:35 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -40,12 +40,13 @@
 
 #include uvm/uvm_extern.h
 
-#define	PAGE_ALIGN(x)	round_page(x)
-
 /* XXX Ugh bletch!  Whattakludge!  Linux's sense is reversed...  */
 #undef	PAGE_MASK
 #define	PAGE_MASK	(~(PAGE_SIZE-1))
 
+#define	PAGE_ALIGN(x)		(((x) + (PAGE_SIZE-1))  ~(PAGE_SIZE-1))
+#define	offset_in_page(x)	((x)  (PAGE_SIZE-1))
+
 /*
  * ###
  * ### XXX THIS NEEDS SERIOUS SCRUTINY XXX ###



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 15:39:05 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: workqueue.h

Log Message:
Rename delayed_work::dw_work to delayed_work::work for Linux source.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.7 -r1.1.2.8 \
src/sys/external/bsd/drm2/include/linux/workqueue.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/workqueue.h
diff -u src/sys/external/bsd/drm2/include/linux/workqueue.h:1.1.2.7 src/sys/external/bsd/drm2/include/linux/workqueue.h:1.1.2.8
--- src/sys/external/bsd/drm2/include/linux/workqueue.h:1.1.2.7	Wed Jul 24 03:59:06 2013
+++ src/sys/external/bsd/drm2/include/linux/workqueue.h	Sun Sep  8 15:39:05 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: workqueue.h,v 1.1.2.7 2013/07/24 03:59:06 riastradh Exp $	*/
+/*	$NetBSD: workqueue.h,v 1.1.2.8 2013/09/08 15:39:05 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@ struct work_struct {
 };
 
 struct delayed_work {
-	struct work_struct dw_work;
+	struct work_struct work;
 };
 
 static inline void
@@ -64,13 +64,13 @@ INIT_WORK(struct work_struct *work, void
 static inline void
 INIT_DELAYED_WORK(struct delayed_work *dw, void (*fn)(struct work_struct *))
 {
-	INIT_WORK(dw-dw_work, fn);
+	INIT_WORK(dw-work, fn);
 }
 
 static inline struct delayed_work *
 to_delayed_work(struct work_struct *work)
 {
-	return container_of(work, struct delayed_work, dw_work);
+	return container_of(work, struct delayed_work, work);
 }
 
 static inline void
@@ -83,7 +83,7 @@ static inline void
 schedule_delayed_work(struct delayed_work *dw, unsigned long ticks)
 {
 	KASSERT(ticks  INT_MAX);
-	callout_schedule(dw-dw_work.ws_callout, (int)ticks);
+	callout_schedule(dw-work.ws_callout, (int)ticks);
 }
 
 static inline void
@@ -95,7 +95,7 @@ cancel_work_sync(struct work_struct *wor
 static inline void
 cancel_delayed_work_sync(struct delayed_work *dw)
 {
-	cancel_work_sync(dw-dw_work);
+	cancel_work_sync(dw-work);
 }
 
 /*



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/drm

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 15:39:48 UTC 2013

Added Files:
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]: bus_dma_hacks.h

Log Message:
Implement a bus_dmamem_wire_uvm_object hack.

This is fit only for x86 at the moment -- it parrots the x86
bus_dmamem_alloc code but with uvm_obj_wirepages instead of
uvm_pglistalloc.

XXX THIS IS A MEGA-KLUDGE THAT NEEDS TO BE DONE PROPERLY.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.2.1 \
src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h
diff -u /dev/null src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.1.2.1
--- /dev/null	Sun Sep  8 15:39:48 2013
+++ src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h	Sun Sep  8 15:39:48 2013
@@ -0,0 +1,110 @@
+/*	$NetBSD: bus_dma_hacks.h,v 1.1.2.1 2013/09/08 15:39:48 riastradh Exp $	*/
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#ifndef	_DRM_BUS_DMA_HACKS_H_
+#define	_DRM_BUS_DMA_HACKS_H_
+
+#include sys/cdefs.h
+#include sys/bus.h
+
+#include uvm/uvm.h
+#include uvm/uvm_extern.h
+
+/* XXX This is x86-specific bollocks.  */
+
+static inline int
+bus_dmamem_wire_uvm_object(bus_dma_tag_t tag, struct uvm_object *uobj,
+off_t start, bus_size_t size, struct pglist *pages, bus_size_t alignment,
+bus_size_t boundary, bus_dma_segment_t *segs, int nsegs, int *rsegs,
+int flags)
+{
+	struct pglist pageq;
+	struct vm_page *page;
+	bus_addr_t prev_addr, addr;
+	unsigned int i;
+	int error;
+
+	KASSERT(size = __type_max(off_t));
+	KASSERT(start = (__type_max(off_t) - size));
+	KASSERT(alignment == PAGE_SIZE); /* XXX */
+	KASSERT(0  nsegs);
+
+	if (pages == NULL) {
+		TAILQ_INIT(pageq);
+		pages = pageq;
+	}
+
+	error = uvm_obj_wirepages(uobj, start, (start + size), pages);
+	if (error)
+		goto fail0;
+
+	page = TAILQ_FIRST(pages);
+	KASSERT(page != NULL);
+
+	addr = VM_PAGE_TO_PHYS(page);
+	segs[0].ds_addr = addr;
+	segs[0].ds_len = PAGE_SIZE;
+
+	i = 0;
+	while ((page = TAILQ_NEXT(page, pageq.queue)) != NULL) {
+		prev_addr = addr;
+		addr = VM_PAGE_TO_PHYS(page);
+		if ((addr == (prev_addr + PAGE_SIZE)) 
+		((addr  boundary) == (prev_addr  boundary))) {
+			segs[i].ds_len += PAGE_SIZE;
+		} else {
+			i += 1;
+			if (i = nsegs) {
+error = EFBIG;
+goto fail1;
+			}
+			segs[i].ds_addr = addr;
+			segs[i].ds_len = PAGE_SIZE;
+		}
+	}
+
+	/* Success!  */
+	*rsegs = (i + 1);
+	return 0;
+
+fail1:	uvm_obj_unwirepages(uobj, start, (start + size));
+fail0:	return error;
+}
+
+static inline void
+bus_dmamem_unwire_uvm_object(bus_dma_tag_t tag __unused,
+struct uvm_object *uobj, off_t start, bus_size_t size,
+bus_dma_segment_t *segs __unused, int nsegs __unused)
+{
+	uvm_obj_unwirepages(uobj, start, (start + size));
+}
+
+#endif	/* _DRM_BUS_DMA_HACKS_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/drm

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 15:40:17 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]: intel-gtt.h

Log Message:
Rework Intel GTT abstraction to use bus_dma.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/drm/intel-gtt.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/intel-gtt.h
diff -u src/sys/external/bsd/drm2/include/drm/intel-gtt.h:1.1.2.1 src/sys/external/bsd/drm2/include/drm/intel-gtt.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/drm/intel-gtt.h:1.1.2.1	Wed Jul 24 03:49:20 2013
+++ src/sys/external/bsd/drm2/include/drm/intel-gtt.h	Sun Sep  8 15:40:17 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: intel-gtt.h,v 1.1.2.1 2013/07/24 03:49:20 riastradh Exp $	*/
+/*	$NetBSD: intel-gtt.h,v 1.1.2.2 2013/09/08 15:40:17 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,16 +32,22 @@
 #ifndef _DRM_INTEL_GTT_H_
 #define _DRM_INTEL_GTT_H_
 
+#include sys/bus.h
+
+#include drm/bus_dma_hacks.h
+
+#include linux/pci.h
+
+#include drm/drm_agp_netbsd.h
+
 struct intel_gtt {
-	unsigned int	stolen_size;
-	unsigned int	gtt_total_entries;
-	unsigned int	gtt_mappable_entries;
-	bool		needs_dmar;
-	bool		do_idle_maps;
-	bus_addr_t	scratch_page_dma;
-	struct vm_page	*scratch_page; /* XXX Sensible?  */
-	bus_size_t	gtt;
-	paddr_t		gma_bus_addr;
+	paddr_t			gma_bus_addr;
+	unsigned int		stolen_size;
+	unsigned int		gtt_total_entries;
+	unsigned int		gtt_mappable_entries;
+	bus_dma_segment_t	gtt_scratch_seg;
+	bus_dmamap_t		gtt_scratch_map;
+	bus_space_handle_t	gtt_bsh;
 };
 
 struct intel_gtt *



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/drm

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 15:47:17 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]: drm_mem_util.h

Log Message:
Simplify drm_mem_util.h; fix source compatibility for drm_free_large.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/drm/drm_mem_util.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/drm_mem_util.h
diff -u src/sys/external/bsd/drm2/include/drm/drm_mem_util.h:1.1.2.1 src/sys/external/bsd/drm2/include/drm/drm_mem_util.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/drm/drm_mem_util.h:1.1.2.1	Wed Jul 24 01:56:19 2013
+++ src/sys/external/bsd/drm2/include/drm/drm_mem_util.h	Sun Sep  8 15:47:17 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_mem_util.h,v 1.1.2.1 2013/07/24 01:56:19 riastradh Exp $	*/
+/*	$NetBSD: drm_mem_util.h,v 1.1.2.2 2013/09/08 15:47:17 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,53 +32,27 @@
 #ifndef _DRM_MEM_UTIL_H_
 #define _DRM_MEM_UTIL_H_
 
-#include sys/types.h
-#include sys/kmem.h
-#include sys/systm.h
+#include linux/slab.h
 
 static inline void *
 drm_calloc_large(size_t n, size_t size)
 {
-
-#if 1
-	KASSERT(size != 0);	/* XXX Let's see whether this ever happens.  */
-#else
-	if (size == 0)
-		return NULL;	/* XXX OK?  */
-#endif
-
-	if (n  (SIZE_MAX / size))
-		return NULL;
-
-	return kmem_zalloc((n * size), KM_SLEEP);
+	return kcalloc(n, size, GFP_KERNEL);
 }
 
 static inline void *
 drm_malloc_ab(size_t n, size_t size)
 {
+	if (size  (SIZE_MAX / n))
+		return NULL;
 
-#if 1
-	KASSERT(size != 0);	/* XXX Let's see whether this ever happens.  */
-#else
-	if (size == 0)
-		return NULL;	/* XXX OK?  */
-#endif
-
-	return kmem_alloc((n * size), KM_SLEEP);
+	return kmalloc((n * size), GFP_KERNEL);
 }
 
 static inline void
-drm_free_large(void *ptr, size_t n, size_t size)
+drm_free_large(void *ptr)
 {
-
-#if 0/* XXX */
-	if (ptr != NULL)
-#endif
-	{
-		KASSERT(size != 0);
-		KASSERT(n = (SIZE_MAX / size));
-		kmem_free(ptr, (n * size));
-	}
+	kfree(ptr);
 }
 
 #endif  /* _DRM_MEM_UTIL_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 15:58:24 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: jiffies.h
kernel.h kgdb.h workqueue.h

Log Message:
Buncha new cruft for linux/*.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 \
src/sys/external/bsd/drm2/include/linux/jiffies.h
cvs rdiff -u -r1.1.2.20 -r1.1.2.21 \
src/sys/external/bsd/drm2/include/linux/kernel.h
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/linux/kgdb.h
cvs rdiff -u -r1.1.2.8 -r1.1.2.9 \
src/sys/external/bsd/drm2/include/linux/workqueue.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/jiffies.h
diff -u src/sys/external/bsd/drm2/include/linux/jiffies.h:1.1.2.4 src/sys/external/bsd/drm2/include/linux/jiffies.h:1.1.2.5
--- src/sys/external/bsd/drm2/include/linux/jiffies.h:1.1.2.4	Sun Sep  8 15:38:04 2013
+++ src/sys/external/bsd/drm2/include/linux/jiffies.h	Sun Sep  8 15:58:24 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: jiffies.h,v 1.1.2.4 2013/09/08 15:38:04 riastradh Exp $	*/
+/*	$NetBSD: jiffies.h,v 1.1.2.5 2013/09/08 15:58:24 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -44,6 +44,12 @@ msecs_to_jiffies(unsigned int msec)
 }
 
 static inline unsigned int
+jiffies_to_msecs(unsigned int j)
+{
+	return hztoms(j);
+}
+
+static inline unsigned int
 usecs_to_jiffies(unsigned int usec)
 {
 	return mstohz((usec + (1000 / hz) - 1) / (1000 / hz));

Index: src/sys/external/bsd/drm2/include/linux/kernel.h
diff -u src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.20 src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.21
--- src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.20	Wed Jul 24 03:45:24 2013
+++ src/sys/external/bsd/drm2/include/linux/kernel.h	Sun Sep  8 15:58:24 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernel.h,v 1.1.2.20 2013/07/24 03:45:24 riastradh Exp $	*/
+/*	$NetBSD: kernel.h,v 1.1.2.21 2013/09/08 15:58:24 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -51,6 +51,13 @@
 #define	min_t(T, X, Y)	MIN(X, Y)
 
 /*
+ * Rounding to nearest.
+ */
+#define	DIV_ROUND_CLOSEST(N, D)		\
+	((0  (N)) ? (((N) + ((D) / 2)) / (D))\
+	: (((N) - ((D) / 2)) / (D)))
+
+/*
  * Rounding to what may or may not be powers of two.
  */
 #define	DIV_ROUND_UP(X, N)	(((X) + (N) - 1) / (N))

Index: src/sys/external/bsd/drm2/include/linux/kgdb.h
diff -u src/sys/external/bsd/drm2/include/linux/kgdb.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/kgdb.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/kgdb.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/kgdb.h	Sun Sep  8 15:58:24 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: kgdb.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $	*/
+/*	$NetBSD: kgdb.h,v 1.1.2.2 2013/09/08 15:58:24 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,26 @@
 #ifndef _LINUX_KGDB_H_
 #define _LINUX_KGDB_H_
 
+#if 0/* XXX */
+#include opt_ddb.h
+#else
+#define	DDB
+#endif
+
+#ifdef DDB
+extern int	db_active;
+
+static inline bool
+in_dbg_master(void)
+{
+	return db_active;
+}
+#else
+static inline bool
+in_dbg_master(void)
+{
+	return false;
+}
+#endif
+
 #endif  /* _LINUX_KGDB_H_ */

Index: src/sys/external/bsd/drm2/include/linux/workqueue.h
diff -u src/sys/external/bsd/drm2/include/linux/workqueue.h:1.1.2.8 src/sys/external/bsd/drm2/include/linux/workqueue.h:1.1.2.9
--- src/sys/external/bsd/drm2/include/linux/workqueue.h:1.1.2.8	Sun Sep  8 15:39:05 2013
+++ src/sys/external/bsd/drm2/include/linux/workqueue.h	Sun Sep  8 15:58:24 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: workqueue.h,v 1.1.2.8 2013/09/08 15:39:05 riastradh Exp $	*/
+/*	$NetBSD: workqueue.h,v 1.1.2.9 2013/09/08 15:58:24 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -86,16 +86,28 @@ schedule_delayed_work(struct delayed_wor
 	callout_schedule(dw-work.ws_callout, (int)ticks);
 }
 
-static inline void
+static inline bool
+cancel_work(struct work_struct *work)
+{
+	return !callout_stop(work-ws_callout);
+}
+
+static inline bool
 cancel_work_sync(struct work_struct *work)
 {
-	callout_halt(work-ws_callout, NULL);
+	return !callout_halt(work-ws_callout, NULL);
 }
 
-static inline void
+static inline bool
+cancel_delayed_work(struct delayed_work *dw)
+{
+	return cancel_work(dw-work);
+}
+
+static inline bool
 cancel_delayed_work_sync(struct delayed_work *dw)
 {
-	cancel_work_sync(dw-work);
+	return cancel_work_sync(dw-work);
 }
 
 /*



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 16:01:49 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: completion.h

Log Message:
Destroy the mutex too in destroy_completion.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 \
src/sys/external/bsd/drm2/include/linux/completion.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/completion.h
diff -u src/sys/external/bsd/drm2/include/linux/completion.h:1.1.2.4 src/sys/external/bsd/drm2/include/linux/completion.h:1.1.2.5
--- src/sys/external/bsd/drm2/include/linux/completion.h:1.1.2.4	Sun Sep  8 16:00:50 2013
+++ src/sys/external/bsd/drm2/include/linux/completion.h	Sun Sep  8 16:01:49 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: completion.h,v 1.1.2.4 2013/09/08 16:00:50 riastradh Exp $	*/
+/*	$NetBSD: completion.h,v 1.1.2.5 2013/09/08 16:01:49 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -78,6 +78,7 @@ destroy_completion(struct completion *co
 {
 	KASSERT(!cv_has_waiters(completion-c_cv));
 	cv_destroy(completion-c_cv);
+	mutex_destroy(completion-c_lock);
 }
 
 /*



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/drm

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 16:02:51 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]:
drm_wait_netbsd.h

Log Message:
Fix result of DRM_TIMED_WAIT_UNTIL.

This has to return a positive number of ticks left if we haven't
timed out in order to match the semantics of Linux waitqueues.

This also fixes the amount of time for timeout if we ever wait for
more than one iteration.

Now we can actually wait for results from the ring buffers!


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.6 -r1.1.2.7 \
src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h
diff -u src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.1.2.6 src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.1.2.7
--- src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.1.2.6	Wed Jul 24 03:08:03 2013
+++ src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h	Sun Sep  8 16:02:50 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_wait_netbsd.h,v 1.1.2.6 2013/07/24 03:08:03 riastradh Exp $	*/
+/*	$NetBSD: drm_wait_netbsd.h,v 1.1.2.7 2013/09/08 16:02:50 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -112,13 +112,28 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, 
 
 #define	DRM_TIMED_WAIT_UNTIL(RET, Q, INTERLOCK, TICKS, CONDITION) do	\
 {	\
+	extern int hardclock_ticks;	\
+	const int _dtwu_start = hardclock_ticks;			\
+	int _dtwu_ticks = (TICKS);	\
 	KASSERT(mutex_is_locked((INTERLOCK)));\
-	while (!(CONDITION)) {		\
+	for (;;) {			\
+		if (CONDITION) {	\
+			(RET) = _dtwu_ticks;\
+			break;		\
+		}			\
 		/* XXX errno NetBSD-Linux */\
 		(RET) = -cv_timedwait_sig((Q), (INTERLOCK)-mtx_lock,	\
-		(TICKS));		\
+		_dtwu_ticks);	\
 		if (RET)		\
 			break;		\
+		const int _dtwu_now = hardclock_ticks;			\
+		KASSERT(_dtwu_start = _dtwu_now);			\
+		if ((_dtwu_now - _dtwu_start)  _dtwu_ticks) {		\
+			_dtwu_ticks -= (_dtwu_now - _dtwu_start);	\
+		} else {		\
+			(RET) = 0;	\
+			break;		\
+		}			\
 	}\
 } while (0)
 
@@ -136,13 +151,28 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, 
 #define	DRM_SPIN_TIMED_WAIT_UNTIL(RET, Q, INTERLOCK, TICKS, CONDITION)	\
 	do\
 {	\
+	extern int hardclock_ticks;	\
+	const int _dstwu_start = hardclock_ticks;			\
+	int _dstwu_ticks = (TICKS);	\
 	KASSERT(spin_is_locked((INTERLOCK)));\
-	while (!(CONDITION)) {		\
+	for (;;) {			\
+		if (CONDITION) {	\
+			(RET) = _dstwu_ticks;\
+			break;		\
+		}			\
 		/* XXX errno NetBSD-Linux */\
 		(RET) = -cv_timedwait_sig((Q), (INTERLOCK)-sl_lock,	\
-		(TICKS));		\
+		_dstwu_ticks);	\
 		if (RET)		\
 			break;		\
+		const int _dstwu_now = hardclock_ticks;			\
+		KASSERT(_dstwu_start = _dstwu_now);			\
+		if ((_dstwu_now - _dstwu_start)  _dstwu_ticks) {	\
+			_dstwu_ticks -= (_dstwu_now - _dstwu_start);	\
+		} else {		\
+			(RET) = 0;	\
+			break;		\
+		}			\
 	}\
 } while (0)
 



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 16:00:50 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: completion.h

Log Message:
Implement destroy_completion in linux/completion.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \
src/sys/external/bsd/drm2/include/linux/completion.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/completion.h
diff -u src/sys/external/bsd/drm2/include/linux/completion.h:1.1.2.3 src/sys/external/bsd/drm2/include/linux/completion.h:1.1.2.4
--- src/sys/external/bsd/drm2/include/linux/completion.h:1.1.2.3	Wed Jul 24 03:29:43 2013
+++ src/sys/external/bsd/drm2/include/linux/completion.h	Sun Sep  8 16:00:50 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: completion.h,v 1.1.2.3 2013/07/24 03:29:43 riastradh Exp $	*/
+/*	$NetBSD: completion.h,v 1.1.2.4 2013/09/08 16:00:50 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -71,6 +71,16 @@ init_completion(struct completion *compl
 }
 
 /*
+ * Destroy a completion object.
+ */
+static inline void
+destroy_completion(struct completion *completion)
+{
+	KASSERT(!cv_has_waiters(completion-c_cv));
+	cv_destroy(completion-c_cv);
+}
+
+/*
  * Notify one waiter of completion, but not any future ones.
  */
 static inline void



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 16:07:29 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: atomic.h

Log Message:
Add Linux ATOMIC_INIT, atomic_inc_return, and atomic_dec_return.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.10 -r1.1.2.11 \
src/sys/external/bsd/drm2/include/linux/atomic.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/atomic.h
diff -u src/sys/external/bsd/drm2/include/linux/atomic.h:1.1.2.10 src/sys/external/bsd/drm2/include/linux/atomic.h:1.1.2.11
--- src/sys/external/bsd/drm2/include/linux/atomic.h:1.1.2.10	Sun Sep  8 15:37:04 2013
+++ src/sys/external/bsd/drm2/include/linux/atomic.h	Sun Sep  8 16:07:29 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: atomic.h,v 1.1.2.10 2013/09/08 15:37:04 riastradh Exp $	*/
+/*	$NetBSD: atomic.h,v 1.1.2.11 2013/09/08 16:07:29 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -43,6 +43,8 @@ struct atomic {
 	} a_u;
 };
 
+#define	ATOMIC_INIT(i)	{ .a_u = { .au_int = (i) } }
+
 typedef struct atomic atomic_t;
 
 static inline int
@@ -88,6 +90,18 @@ atomic_dec(atomic_t *atomic)
 }
 
 static inline int
+atomic_inc_return(atomic_t *atomic)
+{
+	return (int)atomic_inc_uint_nv(atomic-a_u.au_uint);
+}
+
+static inline int
+atomic_dec_return(atomic_t *atomic)
+{
+	return (int)atomic_dec_uint_nv(atomic-a_u.au_uint);
+}
+
+static inline int
 atomic_dec_and_test(atomic_t *atomic)
 {
 	return (-1 == (int)atomic_dec_uint_nv(atomic-a_u.au_uint));



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 16:17:58 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: highmem.h

Log Message:
linux_ namespace for kmap and kunmap.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 \
src/sys/external/bsd/drm2/include/linux/highmem.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/highmem.h
diff -u src/sys/external/bsd/drm2/include/linux/highmem.h:1.1.2.4 src/sys/external/bsd/drm2/include/linux/highmem.h:1.1.2.5
--- src/sys/external/bsd/drm2/include/linux/highmem.h:1.1.2.4	Sun Sep  8 16:16:37 2013
+++ src/sys/external/bsd/drm2/include/linux/highmem.h	Sun Sep  8 16:17:58 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: highmem.h,v 1.1.2.4 2013/09/08 16:16:37 riastradh Exp $	*/
+/*	$NetBSD: highmem.h,v 1.1.2.5 2013/09/08 16:17:58 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -43,6 +43,8 @@
 /* XXX Make the nm output a little more greppable...  */
 #define	kmap_atomic	linux_kmap_atomic
 #define	kunmap_atomic	linux_kunmap_atomic
+#define	kmap		linux_kmap
+#define	kunmap		linux_kunmap
 
 int	linux_kmap_init(void);
 void	linux_kmap_fini(void);



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 16:19:15 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: io-mapping.h

Log Message:
Just use bus_space_map for io-mapping, and limit to one at a time.

Reserving the whole region interferes with other parts of the driver
which want to map it in different ways.  It also horrifically wastes
space when actually mapped, because there's no way to map a subregion
of a reservation.  And the bus_space_reservation API is x86-only at
the moment.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/sys/external/bsd/drm2/include/linux/io-mapping.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/io-mapping.h
diff -u src/sys/external/bsd/drm2/include/linux/io-mapping.h:1.1.2.2 src/sys/external/bsd/drm2/include/linux/io-mapping.h:1.1.2.3
--- src/sys/external/bsd/drm2/include/linux/io-mapping.h:1.1.2.2	Wed Jul 24 03:17:48 2013
+++ src/sys/external/bsd/drm2/include/linux/io-mapping.h	Sun Sep  8 16:19:15 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: io-mapping.h,v 1.1.2.2 2013/07/24 03:17:48 riastradh Exp $	*/
+/*	$NetBSD: io-mapping.h,v 1.1.2.3 2013/09/08 16:19:15 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -36,19 +36,13 @@
 #include sys/kmem.h
 #include sys/systm.h
 
-/*
- * XXX This uses NetBSD bus space reservations, which are currently
- * implemented only for x86.
- */
-
 struct io_mapping {
 	bus_space_tag_t		diom_bst;
 	bus_addr_t		diom_addr;
-	bus_addr_t		diom_size;
+	bus_size_t		diom_size;
 	int			diom_flags;
-	bus_space_reservation_t	diom_bsr;
-	bool			diom_mapped;
 	bus_space_handle_t	diom_bsh;
+	void			*diom_vaddr;
 };
 
 static inline struct io_mapping *
@@ -63,13 +57,15 @@ bus_space_io_mapping_create_wc(bus_space
 	mapping-diom_flags = 0;
 	mapping-diom_flags |= BUS_SPACE_MAP_LINEAR;
 	mapping-diom_flags |= BUS_SPACE_MAP_PREFETCHABLE;
-	mapping-diom_mapped = false;
+	mapping-diom_vaddr = NULL;
 
-	if (bus_space_reserve(mapping-diom_bst, addr, size,
-		mapping-diom_flags, mapping-diom_bsr)) {
+	bus_space_handle_t bsh;
+	if (bus_space_map(mapping-diom_bst, addr, PAGE_SIZE,
+		mapping-diom_flags, bsh)) {
 		kmem_free(mapping, sizeof(*mapping));
 		return NULL;
 	}
+	bus_space_unmap(mapping-diom_bst, bsh, PAGE_SIZE);
 
 	return mapping;
 }
@@ -78,8 +74,7 @@ static inline void
 io_mapping_free(struct io_mapping *mapping)
 {
 
-	KASSERT(!mapping-diom_mapped);
-	bus_space_release(mapping-diom_bst, mapping-diom_bsr);
+	KASSERT(mapping-diom_vaddr == NULL);
 	kmem_free(mapping, sizeof(*mapping));
 }
 
@@ -87,25 +82,24 @@ static inline void *
 io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset)
 {
 
-	KASSERT(!mapping-diom_mapped);
+	KASSERT(mapping-diom_vaddr == NULL);
 	KASSERT(ISSET(mapping-diom_flags, BUS_SPACE_MAP_LINEAR));
-	if (bus_space_reservation_map(mapping-diom_bst, mapping-diom_bsr,
-		mapping-diom_flags, mapping-diom_bsh))
+	if (bus_space_map(mapping-diom_bst, (mapping-diom_addr + offset),
+		PAGE_SIZE, mapping-diom_flags, mapping-diom_bsh))
 		panic(Unable to make I/O mapping!); /* XXX */
-	mapping-diom_mapped = true;
+	mapping-diom_vaddr = bus_space_vaddr(mapping-diom_bst,
+	mapping-diom_bsh);
 
-	return (char *)bus_space_vaddr(mapping-diom_bst, mapping-diom_bsh)
-	+ offset;		/* XXX arithmetic overflow */
+	return mapping-diom_vaddr;
 }
 
 static inline void
 io_mapping_unmap(struct io_mapping *mapping, void *vaddr __unused)
 {
 
-	KASSERT(mapping-diom_mapped);
-	bus_space_reservation_unmap(mapping-diom_bst, mapping-diom_bsh,
-	mapping-diom_size);
-	mapping-diom_mapped = false;
+	KASSERT(mapping-diom_vaddr == vaddr);
+	bus_space_unmap(mapping-diom_bst, mapping-diom_bsh, PAGE_SIZE);
+	mapping-diom_vaddr = NULL;
 }
 
 static inline void *



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 16:31:14 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: spinlock.h

Log Message:
Create Linux spin locks at IPL_VM for now.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.8 -r1.1.2.9 \
src/sys/external/bsd/drm2/include/linux/spinlock.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/spinlock.h
diff -u src/sys/external/bsd/drm2/include/linux/spinlock.h:1.1.2.8 src/sys/external/bsd/drm2/include/linux/spinlock.h:1.1.2.9
--- src/sys/external/bsd/drm2/include/linux/spinlock.h:1.1.2.8	Wed Jul 24 04:01:05 2013
+++ src/sys/external/bsd/drm2/include/linux/spinlock.h	Sun Sep  8 16:31:14 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: spinlock.h,v 1.1.2.8 2013/07/24 04:01:05 riastradh Exp $	*/
+/*	$NetBSD: spinlock.h,v 1.1.2.9 2013/09/08 16:31:14 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -85,8 +85,8 @@ spin_unlock_irqrestore(spinlock_t *spinl
 static inline void
 spin_lock_init(spinlock_t *spinlock)
 {
-	/* XXX Need to identify which need to block intrs.  */
-	mutex_init(spinlock-sl_lock, MUTEX_DEFAULT, IPL_NONE);
+	/* XXX What's the right IPL?  IPL_DRM...?  */
+	mutex_init(spinlock-sl_lock, MUTEX_DEFAULT, IPL_VM);
 }
 
 /*



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 16:32:37 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: device.h
kernel.h notifier.h printk.h sysrq.h

Log Message:
Miscellaneous Linux header file crud.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 \
src/sys/external/bsd/drm2/include/linux/device.h
cvs rdiff -u -r1.1.2.21 -r1.1.2.22 \
src/sys/external/bsd/drm2/include/linux/kernel.h
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/linux/notifier.h \
src/sys/external/bsd/drm2/include/linux/sysrq.h
cvs rdiff -u -r1.1.2.5 -r1.1.2.6 \
src/sys/external/bsd/drm2/include/linux/printk.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/device.h
diff -u src/sys/external/bsd/drm2/include/linux/device.h:1.1.2.4 src/sys/external/bsd/drm2/include/linux/device.h:1.1.2.5
--- src/sys/external/bsd/drm2/include/linux/device.h:1.1.2.4	Wed Jul 24 03:26:18 2013
+++ src/sys/external/bsd/drm2/include/linux/device.h	Sun Sep  8 16:32:37 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: device.h,v 1.1.2.4 2013/07/24 03:26:18 riastradh Exp $	*/
+/*	$NetBSD: device.h,v 1.1.2.5 2013/09/08 16:32:37 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,6 +38,9 @@
 #define	dev_err(DEV, FMT, ...)	\
 	device_printf((DEV), error:  FMT, ##__VA_ARGS__)
 
+#define	dev_info(DEV, FMT, ...)	\
+	device_printf((DEV), info:  FMT, ##__VA_ARGS__)
+
 #define	dev_warn(DEV, FMT, ...)	\
 	device_printf((DEV), warning:  FMT, ##__VA_ARGS__)
 

Index: src/sys/external/bsd/drm2/include/linux/kernel.h
diff -u src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.21 src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.22
--- src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.21	Sun Sep  8 15:58:24 2013
+++ src/sys/external/bsd/drm2/include/linux/kernel.h	Sun Sep  8 16:32:37 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernel.h,v 1.1.2.21 2013/09/08 15:58:24 riastradh Exp $	*/
+/*	$NetBSD: kernel.h,v 1.1.2.22 2013/09/08 16:32:37 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -109,4 +109,6 @@ abs64(int64_t x)
 	return (x  0? (-x) : x);
 }
 
+static int panic_timeout __unused = 0;
+
 #endif  /* _LINUX_KERNEL_H_ */

Index: src/sys/external/bsd/drm2/include/linux/notifier.h
diff -u src/sys/external/bsd/drm2/include/linux/notifier.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/notifier.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/notifier.h:1.1.2.1	Wed Jul 24 03:49:42 2013
+++ src/sys/external/bsd/drm2/include/linux/notifier.h	Sun Sep  8 16:32:37 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: notifier.h,v 1.1.2.1 2013/07/24 03:49:42 riastradh Exp $	*/
+/*	$NetBSD: notifier.h,v 1.1.2.2 2013/09/08 16:32:37 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,11 +32,31 @@
 #ifndef _LINUX_NOTIFIER_H_
 #define _LINUX_NOTIFIER_H_
 
+#include sys/cdefs.h
+
+#define	NOTIFY_OK	0
+
 struct notifier_block {
 	int	(*notifier_call)(struct notifier_block *, unsigned long,
 		void *);
 };
 
-#define	NOTIFY_OK	0
+struct atomic_notifier_head {
+	char	anh_blahdittyblahblah;
+};
+
+static struct atomic_notifier_head panic_notifier_list __unused;
+
+static inline void
+atomic_notifier_chain_register(struct atomic_notifier_head *head __unused,
+struct notifier_block *block __unused)
+{
+}
+
+static inline void
+atomic_notifier_chain_unregister(struct atomic_notifier_head *head __unused,
+struct notifier_block *block __unused)
+{
+}
 
 #endif  /* _LINUX_NOTIFIER_H_ */
Index: src/sys/external/bsd/drm2/include/linux/sysrq.h
diff -u src/sys/external/bsd/drm2/include/linux/sysrq.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/sysrq.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/sysrq.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/sysrq.h	Sun Sep  8 16:32:37 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysrq.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $	*/
+/*	$NetBSD: sysrq.h,v 1.1.2.2 2013/09/08 16:32:37 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,18 @@
 #ifndef _LINUX_SYSRQ_H_
 #define _LINUX_SYSRQ_H_
 
+struct sysrq_key_op {
+	char sko_blahdittyblahblah;
+};
+
+static inline void
+register_sysrq_key(char key __unused, struct sysrq_key_op *op __unused)
+{
+}
+
+static inline void
+unregister_sysrq_key(char key __unused, struct sysrq_key_op *op __unused)
+{
+}
+
 #endif  /* _LINUX_SYSRQ_H_ */

Index: src/sys/external/bsd/drm2/include/linux/printk.h
diff -u src/sys/external/bsd/drm2/include/linux/printk.h:1.1.2.5 src/sys/external/bsd/drm2/include/linux/printk.h:1.1.2.6
--- src/sys/external/bsd/drm2/include/linux/printk.h:1.1.2.5	Wed Jul 24 03:50:45 2013
+++ src/sys/external/bsd/drm2/include/linux/printk.h	Sun Sep  8 16:32:37 2013
@@ -1,4 +1,4 @@
-/*	

CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/drm

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 16:35:20 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]:
drm_wait_netbsd.h

Log Message:
Fix DRM_WAIT_UNTIL to initialize (RET) on every exit.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.7 -r1.1.2.8 \
src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h
diff -u src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.1.2.7 src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.1.2.8
--- src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.1.2.7	Sun Sep  8 16:02:50 2013
+++ src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h	Sun Sep  8 16:35:20 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_wait_netbsd.h,v 1.1.2.7 2013/09/08 16:02:50 riastradh Exp $	*/
+/*	$NetBSD: drm_wait_netbsd.h,v 1.1.2.8 2013/09/08 16:35:20 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -102,7 +102,11 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, 
 #define	DRM_WAIT_UNTIL(RET, Q, INTERLOCK, CONDITION)	do		\
 {	\
 	KASSERT(mutex_is_locked((INTERLOCK)));\
-	while (!(CONDITION)) {		\
+	for (;;) {			\
+		if (CONDITION) {	\
+			(RET) = 0;	\
+			break;		\
+		}			\
 		/* XXX errno NetBSD-Linux */\
 		(RET) = -cv_wait_sig((Q), (INTERLOCK)-mtx_lock);	\
 		if (RET)		\



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep  8 16:40:36 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: workqueue.h

Log Message:
Rework Linux `work' to use NetBSD workqueues, not callouts.

Callers expect to be able to allocate in the workers, which callouts
don't allow.

Delayed work uses callouts only to delay enqueueing work.

Linux `workqueues' are still stubs.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.9 -r1.1.2.10 \
src/sys/external/bsd/drm2/include/linux/workqueue.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/workqueue.h
diff -u src/sys/external/bsd/drm2/include/linux/workqueue.h:1.1.2.9 src/sys/external/bsd/drm2/include/linux/workqueue.h:1.1.2.10
--- src/sys/external/bsd/drm2/include/linux/workqueue.h:1.1.2.9	Sun Sep  8 15:58:24 2013
+++ src/sys/external/bsd/drm2/include/linux/workqueue.h	Sun Sep  8 16:40:36 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: workqueue.h,v 1.1.2.9 2013/09/08 15:58:24 riastradh Exp $	*/
+/*	$NetBSD: workqueue.h,v 1.1.2.10 2013/09/08 16:40:36 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -33,81 +33,220 @@
 #define _LINUX_WORKQUEUE_H_
 
 #include sys/callout.h
+#include sys/condvar.h
+#include sys/mutex.h
+#include sys/workqueue.h
 
 #include asm/bug.h
 #include linux/kernel.h
 
 /*
- * XXX This implementation is a load of bollocks -- callouts are
- * expedient, but wrong, if for no reason other than that we never call
- * callout_destroy.
+ * XXX This implementation is a load of bollocks -- callouts and
+ * workqueues are expedient, but wrong, if for no reason other than
+ * that there is no destroy operation.
+ *
+ * XXX The amount of code in here is absurd; it should be given a
+ * proper source file.
  */
 
 struct work_struct {
-	struct callout ws_callout;
+	void 			(*w_fn)(struct work_struct *);
+	struct workqueue	*w_wq;
+	struct work		w_wk;
+	kmutex_t		w_lock;
+	kcondvar_t		w_cv;
+	enum {
+		WORK_IDLE,
+		WORK_QUEUED,
+		WORK_CANCELLED,
+		WORK_INFLIGHT,
+		WORK_REQUEUED,
+	}			w_state;
 };
 
-struct delayed_work {
-	struct work_struct work;
-};
+static void __unused
+linux_work_fn(struct work *wk __unused, void *arg)
+{
+	struct work_struct *const work = arg;
+
+	mutex_spin_enter(work-w_lock);
+	switch (work-w_state) {
+	case WORK_IDLE:
+		panic(work ran while idle: %p, work);
+		break;
+
+	case WORK_QUEUED:
+		work-w_state = WORK_INFLIGHT;
+		mutex_spin_exit(work-w_lock);
+		(*work-w_fn)(work);
+		mutex_spin_enter(work-w_lock);
+		switch (work-w_state) {
+		case WORK_IDLE:
+		case WORK_QUEUED:
+			panic(work hosed while in flight: %p, work);
+			break;
+
+		case WORK_INFLIGHT:
+		case WORK_CANCELLED:
+			work-w_state = WORK_IDLE;
+			cv_broadcast(work-w_cv);
+			break;
+
+		case WORK_REQUEUED:
+			workqueue_enqueue(work-w_wq, work-w_wk, NULL);
+			work-w_state = WORK_QUEUED;
+			break;
+
+		default:
+			panic(work %p in bad state: %d, work,
+			(int)work-w_state);
+			break;
+		}
+		break;
+
+	case WORK_CANCELLED:
+		work-w_state = WORK_IDLE;
+		cv_broadcast(work-w_cv);
+		break;
+
+	case WORK_INFLIGHT:
+		panic(work already in flight: %p, work);
+		break;
+
+	case WORK_REQUEUED:
+		panic(work requeued while not in flight: %p, work);
+		break;
+
+	default:
+		panic(work %p in bad state: %d, work, (int)work-w_state);
+		break;
+	}
+	mutex_spin_exit(work-w_lock);
+}
 
 static inline void
 INIT_WORK(struct work_struct *work, void (*fn)(struct work_struct *))
 {
+	int error;
 
-	callout_init(work-ws_callout, 0);
-
-	/* XXX This cast business is sketchy.  */
-	callout_setfunc(work-ws_callout, (void (*)(void *))fn, work);
+	work-w_fn = fn;
+	error = workqueue_create(work-w_wq, lnxworkq, linux_work_fn,
+	work, PRI_NONE, IPL_VM, WQ_MPSAFE);
+	if (error)
+		panic(workqueue creation failed: %d, error); /* XXX */
+
+	mutex_init(work-w_lock, MUTEX_DEFAULT, IPL_VM);
+	cv_init(work-w_cv, linxwork);
+	work-w_state = WORK_IDLE;
 }
 
 static inline void
-INIT_DELAYED_WORK(struct delayed_work *dw, void (*fn)(struct work_struct *))
+schedule_work(struct work_struct *work)
 {
-	INIT_WORK(dw-work, fn);
+
+	mutex_spin_enter(work-w_lock);
+	switch (work-w_state) {
+	case WORK_IDLE:
+		workqueue_enqueue(work-w_wq, work-w_wk, NULL);
+		work-w_state = WORK_QUEUED;
+		break;
+
+	case WORK_CANCELLED:
+		break;
+
+	case WORK_INFLIGHT:
+		work-w_state = WORK_REQUEUED;
+		break;
+
+	case WORK_QUEUED:
+	case WORK_REQUEUED:
+		break;
+
+	default:
+		panic(work %p in bad state: %d, work, (int)work-w_state);
+		break;
+	}
+	mutex_spin_exit(work-w_lock);
 }
 
-static inline struct delayed_work *
-to_delayed_work(struct work_struct *work)
+/*
+ * XXX This API can't possibly be right because there is no interlock.
+ */
+static inline bool
+cancel_work_sync(struct work_struct *work)
 {
-	return container_of(work, struct delayed_work, work);
+	bool 

CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 00:48:20 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: types.h

Log Message:
Add types u8, u16, u32 to drm2's linux/types.h shim.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/linux/types.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/types.h
diff -u src/sys/external/bsd/drm2/include/linux/types.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/types.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/types.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/types.h	Wed Jul 24 00:48:20 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: types.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $	*/
+/*	$NetBSD: types.h,v 1.1.2.2 2013/07/24 00:48:20 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,10 @@
 #ifndef _LINUX_TYPES_H_
 #define _LINUX_TYPES_H_
 
+#include sys/types.h
+
+typedef uint8_t u8;
+typedef uint16_t u16;
+typedef uint32_t u32;
+
 #endif  /* _LINUX_TYPES_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 00:48:50 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: dma-mapping.h

Log Message:
Define dma_addr_t to be bus_addr_t in drm2's linux/dma-mapping.h shim.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/linux/dma-mapping.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/dma-mapping.h
diff -u src/sys/external/bsd/drm2/include/linux/dma-mapping.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/dma-mapping.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/dma-mapping.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/dma-mapping.h	Wed Jul 24 00:48:50 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: dma-mapping.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $	*/
+/*	$NetBSD: dma-mapping.h,v 1.1.2.2 2013/07/24 00:48:50 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,8 @@
 #ifndef _LINUX_DMA_MAPPING_H_
 #define _LINUX_DMA_MAPPING_H_
 
+#include sys/bus.h
+
+typedef bus_addr_t dma_addr_t;
+
 #endif  /* _LINUX_DMA_MAPPING_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 00:48:34 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: atomic.h

Log Message:
Implement atomic_t and atomic_read in drm2's linux/atomic.h shim.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/linux/atomic.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/atomic.h
diff -u src/sys/external/bsd/drm2/include/linux/atomic.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/atomic.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/atomic.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/atomic.h	Wed Jul 24 00:48:34 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: atomic.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $	*/
+/*	$NetBSD: atomic.h,v 1.1.2.2 2013/07/24 00:48:34 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,14 @@
 #ifndef _LINUX_ATOMIC_H_
 #define _LINUX_ATOMIC_H_
 
+typedef struct {
+	int atomic_value;
+} atomic_t;
+
+static inline int
+atomic_read(atomic_t *atomic)
+{
+	return *(volatile int *)atomic-atomic_value;
+}
+
 #endif  /* _LINUX_ATOMIC_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 00:49:04 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: kernel.h

Log Message:
Define __printf in drm2's linux/kernel.h shim.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/linux/kernel.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/kernel.h
diff -u src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/kernel.h	Wed Jul 24 00:49:04 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernel.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $	*/
+/*	$NetBSD: kernel.h,v 1.1.2.2 2013/07/24 00:49:04 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,8 @@
 #ifndef _LINUX_KERNEL_H_
 #define _LINUX_KERNEL_H_
 
+#include sys/cdefs.h
+
+#define	__printf	__printflike
+
 #endif  /* _LINUX_KERNEL_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 00:49:32 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: kernel.h

Log Message:
Add type-unsafe container_of to drm2's linux/kernel.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/sys/external/bsd/drm2/include/linux/kernel.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/kernel.h
diff -u src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.2 src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.3
--- src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.2	Wed Jul 24 00:49:04 2013
+++ src/sys/external/bsd/drm2/include/linux/kernel.h	Wed Jul 24 00:49:32 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernel.h,v 1.1.2.2 2013/07/24 00:49:04 riastradh Exp $	*/
+/*	$NetBSD: kernel.h,v 1.1.2.3 2013/07/24 00:49:32 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -36,4 +36,7 @@
 
 #define	__printf	__printflike
 
+#define	container_of(PTR, TYPE, FIELD)	\
+	((TYPE *)(((char *)(PTR)) - offsetof(TYPE, FIELD)))
+
 #endif  /* _LINUX_KERNEL_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 00:49:19 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: spinlock.h

Log Message:
Implement Linux spin lock in terms of kmutex_t in drm2's linux/spinlock.h.

Currently a spin lock will be an adaptive mutex, until I identify
cases in drm2 that actually require spinning and interrupt deferral.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/linux/spinlock.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/spinlock.h
diff -u src/sys/external/bsd/drm2/include/linux/spinlock.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/spinlock.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/spinlock.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/spinlock.h	Wed Jul 24 00:49:19 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: spinlock.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $	*/
+/*	$NetBSD: spinlock.h,v 1.1.2.2 2013/07/24 00:49:19 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,43 @@
 #ifndef _LINUX_SPINLOCK_H_
 #define _LINUX_SPINLOCK_H_
 
+#include sys/cdefs.h
+#include sys/mutex.h
+
+typedef struct {
+	kmutex_t sl_lock;
+} spinlock_t;
+
+static inline void
+spin_lock(spinlock_t *spinlock)
+{
+	mutex_enter(spinlock-sl_lock);
+}
+
+static inline void
+spin_unlock(spinlock_t *spinlock)
+{
+	mutex_exit(spinlock-sl_lock);
+}
+
+/* Must be a macro because the second argument is to be assigned.  */
+#define	spin_lock_irqsave(SPINLOCK, FLAGS)\
+	do {\
+		(FLAGS) = 0;		\
+		mutex_enter(((spinlock_t *)(SPINLOCK))-sl_lock);	\
+	} while (0)
+
+static inline void
+spin_lock_irqrestore(spinlock_t *spinlock, unsigned long __unused flags)
+{
+	mutex_exit(spinlock-sl_lock);
+}
+
+static inline void
+spin_lock_init(spinlock_t *spinlock)
+{
+	/* XXX Need to identify which need to block intrs.  */
+	mutex_init(spinlock-sl_lock, MUTEX_DEFAULT, IPL_NONE);
+}
+
 #endif  /* _LINUX_SPINLOCK_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 00:49:48 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: list.h

Log Message:
Add initial draft of Linux list and hlist to linux/list.h.

Implemented in terms of TAILQ and LIST, respectively.
Not yet tested.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/linux/list.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/list.h
diff -u src/sys/external/bsd/drm2/include/linux/list.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/list.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/list.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/list.h	Wed Jul 24 00:49:48 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: list.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $	*/
+/*	$NetBSD: list.h,v 1.1.2.2 2013/07/24 00:49:48 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,75 @@
 #ifndef _LINUX_LIST_H_
 #define _LINUX_LIST_H_
 
+#include sys/null.h
+#include sys/queue.h
+
+#include linux/kernel.h
+
+/*
+ * Doubly-linked lists.
+ */
+
+TAILQ_HEAD(list_head, list_node);
+struct list_node {
+	TAILQ_ENTRY(list_node) ln_entry;
+};
+
+static inline struct list_node *
+list_first(struct list_head *head)
+{
+	return TAILQ_FIRST(head);
+}
+
+static inline struct list_node *
+list_next(struct list_node *node)
+{
+	return TAILQ_NEXT(node, ln_entry);
+}
+
+#define	list_entry(PTR, TYPE, FIELD)	container_of(PTR, TYPE, FIELD)
+#define	list_for_each(VAR, HEAD)	TAILQ_FOREACH(VAR, HEAD, ln_entry)
+#define	list_for_each_safe(VAR, NEXT, HEAD)\
+	TAILQ_FOREACH_SAFE(VAR, HEAD, ln_entry, NEXT)
+
+#define	list_for_each_entry(VAR, HEAD, FIELD)\
+	for ((VAR) = ((TAILQ_FIRST((HEAD)) == NULL)? NULL :		\
+		list_entry(TAILQ_FIRST((HEAD)), typeof(*(VAR)), FIELD)); \
+		(VAR) != NULL;		\
+		(VAR) = ((TAILQ_NEXT((VAR), FIELD) == NULL)? NULL :	\
+		list_entry(TAILQ_NEXT((VAR), FIELD), typeof(*(VAR)), \
+			FIELD)))
+
+/*
+ * `H'ead-only/`H'ash-table doubly-linked lists.
+ */
+
+LIST_HEAD(hlist_head, hlist_node);
+struct hlist_node {
+	LIST_ENTRY(hlist_node) hln_entry;
+};
+
+static inline struct hlist_node *
+hlist_first(struct hlist_head *head)
+{
+	return LIST_FIRST(head);
+}
+
+static inline struct hlist_node *
+hlist_next(struct hlist_node *node)
+{
+	return LIST_NEXT(node, hln_entry);
+}
+
+#define	hlist_entry(PTR, TYPE, FIELD)	container_of(PTR, TYPE, FIELD)
+#define	hlist_for_each(VAR, HEAD)	LIST_FOREACH(VAR, HEAD, hln_entry)
+#define	hlist_for_each_safe(VAR, NEXT, HEAD)\
+	LIST_FOREACH_SAFE(VAR, HEAD, hln_entry, NEXT)
+
+#define	hlist_for_each_entry(VAR, HLIST, HEAD, FIELD)			\
+	for ((HLIST) = LIST_FIRST((HEAD));\
+		((HLIST) != NULL) 	\
+		((VAR) = hlist_entry((HLIST), typeof(*(VAR)), FIELD), 1); \
+		(HLIST) = LIST_NEXT((HLIST), hln_entry))
+
 #endif  /* _LINUX_LIST_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 00:50:51 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: kernel.h

Log Message:
Define __user to be empty in linux/kernel.h.

__user qualifies a pointer into userspace for static analyzers.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \
src/sys/external/bsd/drm2/include/linux/kernel.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/kernel.h
diff -u src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.3 src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.4
--- src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.3	Wed Jul 24 00:49:32 2013
+++ src/sys/external/bsd/drm2/include/linux/kernel.h	Wed Jul 24 00:50:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernel.h,v 1.1.2.3 2013/07/24 00:49:32 riastradh Exp $	*/
+/*	$NetBSD: kernel.h,v 1.1.2.4 2013/07/24 00:50:51 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -35,6 +35,7 @@
 #include sys/cdefs.h
 
 #define	__printf	__printflike
+#define	__user
 
 #define	container_of(PTR, TYPE, FIELD)	\
 	((TYPE *)(((char *)(PTR)) - offsetof(TYPE, FIELD)))



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 00:52:26 UTC 2013

Added Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: uidgid.h

Log Message:
Add shim linux/uidgid.h.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.2.1 src/sys/external/bsd/drm2/include/linux/uidgid.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/sys/external/bsd/drm2/include/linux/uidgid.h
diff -u /dev/null src/sys/external/bsd/drm2/include/linux/uidgid.h:1.1.2.1
--- /dev/null	Wed Jul 24 00:52:26 2013
+++ src/sys/external/bsd/drm2/include/linux/uidgid.h	Wed Jul 24 00:52:26 2013
@@ -0,0 +1,39 @@
+/*	$NetBSD: uidgid.h,v 1.1.2.1 2013/07/24 00:52:26 riastradh Exp $	*/
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#ifndef _LINUX_UIDGID_H_
+#define _LINUX_UIDGID_H_
+
+#include sys/types.h
+
+typedef uid_t kuid_t;
+
+#endif  /* _LINUX_UIDGID_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/drm

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:49:08 UTC 2013

Removed Files:
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]: drm_os_linux.h

Log Message:
Remove now unused drm/drm_os_linux.h shim.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r0 \
src/sys/external/bsd/drm2/include/drm/drm_os_linux.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/drm

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:49:31 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]: drm_os_netbsd.h
Added Files:
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]:
drm_wait_netbsd.h

Log Message:
Implement drm waitqueues with condvars.  Include in drm_os_netbsd.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h
cvs rdiff -u -r0 -r1.1.2.1 \
src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h
diff -u src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.1.2.1 src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.1.2.1	Wed Jul 24 00:51:31 2013
+++ src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h	Wed Jul 24 01:49:31 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_os_netbsd.h,v 1.1.2.1 2013/07/24 00:51:31 riastradh Exp $	*/
+/*	$NetBSD: drm_os_netbsd.h,v 1.1.2.2 2013/07/24 01:49:31 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -36,4 +36,6 @@
 #include opt_drm.h
 #endif
 
+#include drm/drm_wait_netbsd.h
+
 #endif  /* _DRM_DRM_OS_NETBSD_H_ */

Added files:

Index: src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h
diff -u /dev/null src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.1.2.1
--- /dev/null	Wed Jul 24 01:49:31 2013
+++ src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h	Wed Jul 24 01:49:31 2013
@@ -0,0 +1,67 @@
+/*	$NetBSD: drm_wait_netbsd.h,v 1.1.2.1 2013/07/24 01:49:31 riastradh Exp $	*/
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#ifndef _DRM_DRM_WAIT_NETBSD_H_
+#define _DRM_DRM_WAIT_NETBSD_H_
+
+#include sys/condvar.h
+#include sys/mutex.h
+#include sys/systm.h
+
+typedef kcondvar_t drm_waitqueue_t;
+typedef kmutex_t drm_interlock_t;
+
+static inline void
+DRM_INIT_WAITQUEUE(drm_waitqueue_t *q, const char *name)
+{
+
+	cv_init(q, name);
+}
+
+static inline void
+DRM_WAKEUP(drm_waitqueue_t *q, drm_interlock_t *interlock)
+{
+
+	KASSERT(mutex_owned(interlock));
+	cv_broadcast(q);
+}
+
+#define	DRM_WAIT_ON(RET, Q, INTERLOCK, TICKS, CONDITION) do		\
+{	\
+	KASSERT(mutex_owned((INTERLOCK)));\
+	while (!(CONDITION)) {		\
+		(RET) = cv_timedwait_sig((Q), (INTERLOCK), (TICKS));	\
+		if (RET)		\
+			break;		\
+	}\
+} while (0)
+
+#endif  /* _DRM_DRM_WAIT_NETBSD_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:50:51 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: types.h

Log Message:
Add u64, s8, s16, s32, and s64 to linux/types.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/sys/external/bsd/drm2/include/linux/types.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/types.h
diff -u src/sys/external/bsd/drm2/include/linux/types.h:1.1.2.2 src/sys/external/bsd/drm2/include/linux/types.h:1.1.2.3
--- src/sys/external/bsd/drm2/include/linux/types.h:1.1.2.2	Wed Jul 24 00:48:20 2013
+++ src/sys/external/bsd/drm2/include/linux/types.h	Wed Jul 24 01:50:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: types.h,v 1.1.2.2 2013/07/24 00:48:20 riastradh Exp $	*/
+/*	$NetBSD: types.h,v 1.1.2.3 2013/07/24 01:50:51 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -37,5 +37,10 @@
 typedef uint8_t u8;
 typedef uint16_t u16;
 typedef uint32_t u32;
+typedef uint64_t u64;
+typedef int8_t s8;
+typedef int16_t s16;
+typedef int32_t s32;
+typedef int64_t s64;
 
 #endif  /* _LINUX_TYPES_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:51:06 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: types.h

Log Message:
Define resource_size_t to be bus_size_t in linux/types.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \
src/sys/external/bsd/drm2/include/linux/types.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/types.h
diff -u src/sys/external/bsd/drm2/include/linux/types.h:1.1.2.3 src/sys/external/bsd/drm2/include/linux/types.h:1.1.2.4
--- src/sys/external/bsd/drm2/include/linux/types.h:1.1.2.3	Wed Jul 24 01:50:51 2013
+++ src/sys/external/bsd/drm2/include/linux/types.h	Wed Jul 24 01:51:06 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: types.h,v 1.1.2.3 2013/07/24 01:50:51 riastradh Exp $	*/
+/*	$NetBSD: types.h,v 1.1.2.4 2013/07/24 01:51:06 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -33,6 +33,7 @@
 #define _LINUX_TYPES_H_
 
 #include sys/types.h
+#include sys/bus.h
 
 typedef uint8_t u8;
 typedef uint16_t u16;
@@ -43,4 +44,6 @@ typedef int16_t s16;
 typedef int32_t s32;
 typedef int64_t s64;
 
+typedef bus_size_t resource_size_t;
+
 #endif  /* _LINUX_TYPES_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/drm

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:50:35 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]: drm_os_netbsd.h
Added Files:
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]:
drm_agp_netbsd.h

Log Message:
Add drm_agp_netbsd.h and include it in drm_os_netbsd.h.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.2.1 \
src/sys/external/bsd/drm2/include/drm/drm_agp_netbsd.h
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h
diff -u src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.1.2.2 src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.1.2.3
--- src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.1.2.2	Wed Jul 24 01:49:31 2013
+++ src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h	Wed Jul 24 01:50:35 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_os_netbsd.h,v 1.1.2.2 2013/07/24 01:49:31 riastradh Exp $	*/
+/*	$NetBSD: drm_os_netbsd.h,v 1.1.2.3 2013/07/24 01:50:35 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -36,6 +36,7 @@
 #include opt_drm.h
 #endif
 
+#include drm/drm_agp_netbsd.h
 #include drm/drm_wait_netbsd.h
 
 #endif  /* _DRM_DRM_OS_NETBSD_H_ */

Added files:

Index: src/sys/external/bsd/drm2/include/drm/drm_agp_netbsd.h
diff -u /dev/null src/sys/external/bsd/drm2/include/drm/drm_agp_netbsd.h:1.1.2.1
--- /dev/null	Wed Jul 24 01:50:35 2013
+++ src/sys/external/bsd/drm2/include/drm/drm_agp_netbsd.h	Wed Jul 24 01:50:35 2013
@@ -0,0 +1,43 @@
+/*	$NetBSD: drm_agp_netbsd.h,v 1.1.2.1 2013/07/24 01:50:35 riastradh Exp $	*/
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#ifndef _DRM_DRM_AGP_NETBSD_H_
+#define _DRM_DRM_AGP_NETBSD_H_
+
+#include dev/pci/pcivar.h	/* XXX include order botch */
+#include dev/pci/agpvar.h
+
+#define	__OS_HAS_AGP	1
+
+typedef struct agp_memory_info DRM_AGP_MEM;
+typedef struct agp_info DRM_AGP_KERN;
+
+#endif  /* _DRM_DRM_AGP_NETBSD_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:51:36 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: kref.h

Log Message:
Implement krefs in linux/kref.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/linux/kref.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/kref.h
diff -u src/sys/external/bsd/drm2/include/linux/kref.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/kref.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/kref.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/kref.h	Wed Jul 24 01:51:36 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: kref.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $	*/
+/*	$NetBSD: kref.h,v 1.1.2.2 2013/07/24 01:51:36 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,79 @@
 #ifndef _LINUX_KREF_H_
 #define _LINUX_KREF_H_
 
+#include sys/types.h
+#include sys/atomic.h
+#include sys/systm.h
+
+#include linux/mutex.h
+
+struct kref {
+	unsigned int kr_count;
+};
+
+static inline void
+kref_init(struct kref *kref)
+{
+	kref-kr_count = 1;
+}
+
+static inline void
+kref_get(struct kref *kref)
+{
+	const unsigned int count __unused =
+	atomic_inc_uint_nv(kref-kr_count);
+
+	KASSERT(count  1);
+}
+
+static inline int
+kref_sub(struct kref *kref, unsigned int count, void (*release)(struct kref *))
+{
+	unsigned int old, new;
+
+	do {
+		old = kref-kr_count;
+		KASSERT(count = old);
+		new = (old - count);
+	} while (atomic_cas_uint(kref-kr_count, old, new) == old);
+
+	if (new == 0) {
+		(*release)(kref);
+		return 1;
+	}
+
+	return 0;
+}
+
+static inline int
+kref_put(struct kref *kref, void (*release)(struct kref *))
+{
+
+	return kref_sub(kref, 1, release);
+}
+
+static inline int
+kref_put_mutex(struct kref *kref, void (*release)(struct kref *),
+struct mutex *interlock)
+{
+	unsigned int old, new;
+
+	do {
+		old = kref-kr_count;
+		KASSERT(old  0);
+		if (old == 1) {
+			mutex_lock(interlock);
+			if (atomic_add_int_nv(kref-kr_count, -1) == 0) {
+(*release)(kref);
+return 1;
+			}
+			mutex_unlock(interlock);
+			return 0;
+		}
+		new = (old - 1);
+	} while (atomic_cas_uint(kref-kr_count, old, new) != old);
+
+	return 0;
+}
+
 #endif  /* _LINUX_KREF_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:51:21 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: mutex.h

Log Message:
Fill linux/mutex.h with aliases for our mutex abstraction.

mutex_lock_interruptible isn't; this may require revisiting.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/linux/mutex.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/mutex.h
diff -u src/sys/external/bsd/drm2/include/linux/mutex.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/mutex.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/mutex.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/mutex.h	Wed Jul 24 01:51:21 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: mutex.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $	*/
+/*	$NetBSD: mutex.h,v 1.1.2.2 2013/07/24 01:51:21 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,15 @@
 #ifndef _LINUX_MUTEX_H_
 #define _LINUX_MUTEX_H_
 
+#include sys/mutex.h
+
+/* XXX Kludge: Replace `struct mutex' by `struct kmutex'.  */
+#define	mutexkmutex
+
+#define	mutex_lock			mutex_enter
+#define	mutex_lock_interruptible	mutex_enter /* XXX */
+#define	mutex_trylock			mutex_tryenter
+#define	mutex_unlock			mutex_exit
+#define	mutex_is_locked			mutex_owned
+
 #endif  /* _LINUX_MUTEX_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:52:08 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: kernel.h

Log Message:
Include sys/systm.h in linux/kernel.h for offsetof.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 \
src/sys/external/bsd/drm2/include/linux/kernel.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/kernel.h
diff -u src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.4 src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.5
--- src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.4	Wed Jul 24 00:50:51 2013
+++ src/sys/external/bsd/drm2/include/linux/kernel.h	Wed Jul 24 01:52:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernel.h,v 1.1.2.4 2013/07/24 00:50:51 riastradh Exp $	*/
+/*	$NetBSD: kernel.h,v 1.1.2.5 2013/07/24 01:52:08 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -33,6 +33,7 @@
 #define _LINUX_KERNEL_H_
 
 #include sys/cdefs.h
+#include sys/systm.h
 
 #define	__printf	__printflike
 #define	__user



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:52:39 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: i2c.h

Log Message:
Define struct i2c_adapter as a device_t wrapper in linux/i2c.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/linux/i2c.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/i2c.h
diff -u src/sys/external/bsd/drm2/include/linux/i2c.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/i2c.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/i2c.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/i2c.h	Wed Jul 24 01:52:39 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: i2c.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $	*/
+/*	$NetBSD: i2c.h,v 1.1.2.2 2013/07/24 01:52:39 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,10 @@
 #ifndef _LINUX_I2C_H_
 #define _LINUX_I2C_H_
 
+#include sys/device_if.h
+
+struct i2c_adapter {
+	device_t ia_dev;
+};
+
 #endif  /* _LINUX_I2C_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:52:24 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: workqueue.h

Log Message:
Add callout-based delayed_work implementation to linux/workqueue.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/linux/workqueue.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/workqueue.h
diff -u src/sys/external/bsd/drm2/include/linux/workqueue.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/workqueue.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/workqueue.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/workqueue.h	Wed Jul 24 01:52:24 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: workqueue.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $	*/
+/*	$NetBSD: workqueue.h,v 1.1.2.2 2013/07/24 01:52:24 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,44 @@
 #ifndef _LINUX_WORKQUEUE_H_
 #define _LINUX_WORKQUEUE_H_
 
+#include sys/callout.h
+
+#include linux/kernel.h
+
+struct work_struct {
+	struct callout ws_callout;
+};
+
+struct delayed_work {
+	struct work_struct dw_work;
+};
+
+static inline void
+INIT_DELAYED_WORK(struct delayed_work *dw, void (*fn)(struct delayed_work *))
+{
+
+	/* XXX This cast business is sketchy.  */
+	callout_setfunc(dw-dw_work.ws_callout, (void (*)(void *))fn,
+	dw-dw_work);
+}
+
+static inline struct delayed_work *
+to_delayed_work(struct work_struct *work)
+{
+	return container_of(work, struct delayed_work, dw_work);
+}
+
+static inline void
+schedule_delayed_work(struct delayed_work *dw, unsigned long ticks)
+{
+	KASSERT(ticks  INT_MAX);
+	callout_schedule(dw-dw_work.ws_callout, (int)ticks);
+}
+
+static inline void
+cancel_delayed_work_sync(struct delayed_work *dw)
+{
+	callout_stop(dw-dw_work.ws_callout);
+}
+
 #endif  /* _LINUX_WORKQUEUE_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:53:40 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: workqueue.h

Log Message:
Little pseudo-fixes for untested bogus delayed_work implementation.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/sys/external/bsd/drm2/include/linux/workqueue.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/workqueue.h
diff -u src/sys/external/bsd/drm2/include/linux/workqueue.h:1.1.2.2 src/sys/external/bsd/drm2/include/linux/workqueue.h:1.1.2.3
--- src/sys/external/bsd/drm2/include/linux/workqueue.h:1.1.2.2	Wed Jul 24 01:52:24 2013
+++ src/sys/external/bsd/drm2/include/linux/workqueue.h	Wed Jul 24 01:53:40 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: workqueue.h,v 1.1.2.2 2013/07/24 01:52:24 riastradh Exp $	*/
+/*	$NetBSD: workqueue.h,v 1.1.2.3 2013/07/24 01:53:40 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -36,6 +36,12 @@
 
 #include linux/kernel.h
 
+/*
+ * XXX This implementation is a load of bollocks -- callouts are
+ * expedient, but wrong, if for no reason other than that we never call
+ * callout_destroy.
+ */
+
 struct work_struct {
 	struct callout ws_callout;
 };
@@ -48,6 +54,8 @@ static inline void
 INIT_DELAYED_WORK(struct delayed_work *dw, void (*fn)(struct delayed_work *))
 {
 
+	callout_init(dw-dw_work.ws_callout, 0);
+
 	/* XXX This cast business is sketchy.  */
 	callout_setfunc(dw-dw_work.ws_callout, (void (*)(void *))fn,
 	dw-dw_work);
@@ -69,7 +77,7 @@ schedule_delayed_work(struct delayed_wor
 static inline void
 cancel_delayed_work_sync(struct delayed_work *dw)
 {
-	callout_stop(dw-dw_work.ws_callout);
+	callout_halt(dw-dw_work.ws_callout, NULL);
 }
 
 #endif  /* _LINUX_WORKQUEUE_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:54:04 UTC 2013

Added Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: timer.h

Log Message:
Implement a subset of Linux's struct timer_list with callouts.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.2.1 src/sys/external/bsd/drm2/include/linux/timer.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/sys/external/bsd/drm2/include/linux/timer.h
diff -u /dev/null src/sys/external/bsd/drm2/include/linux/timer.h:1.1.2.1
--- /dev/null	Wed Jul 24 01:54:04 2013
+++ src/sys/external/bsd/drm2/include/linux/timer.h	Wed Jul 24 01:54:04 2013
@@ -0,0 +1,66 @@
+/*	$NetBSD: timer.h,v 1.1.2.1 2013/07/24 01:54:04 riastradh Exp $	*/
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#ifndef _LINUX_TIMER_H_
+#define _LINUX_TIMER_H_
+
+#include sys/callout.h
+
+struct timer_list {
+	struct callout tl_callout;
+};
+
+static inline void
+setup_timer(struct timer_list *timer, void (*fn)(unsigned long),
+unsigned long arg)
+{
+
+	callout_init(timer-tl_callout, 0);
+
+	/* XXX Super-sketchy casts!  */
+	callout_setfunc(timer-tl_callout, (void (*)(void *))fn,
+	(void *)(uintptr_t)arg);
+}
+
+static inline void
+mod_timer(struct timer_list *timer, unsigned long ticks)
+{
+	callout_schedule(timer-tl_callout, ticks);
+}
+
+static inline void
+del_timer_sync(struct timer_list *timer)
+{
+	callout_halt(timer-tl_callout, NULL);
+	callout_destroy(timer-tl_callout);
+}
+
+#endif  /* _LINUX_TIMER_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/drm

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:53:26 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]: drm_os_netbsd.h
Added Files:
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]:
drm_irq_netbsd.h

Log Message:
Add DRM IRQ shims.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.2.1 \
src/sys/external/bsd/drm2/include/drm/drm_irq_netbsd.h
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \
src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h
diff -u src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.1.2.3 src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.1.2.4
--- src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.1.2.3	Wed Jul 24 01:50:35 2013
+++ src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h	Wed Jul 24 01:53:26 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_os_netbsd.h,v 1.1.2.3 2013/07/24 01:50:35 riastradh Exp $	*/
+/*	$NetBSD: drm_os_netbsd.h,v 1.1.2.4 2013/07/24 01:53:26 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -37,6 +37,7 @@
 #endif
 
 #include drm/drm_agp_netbsd.h
+#include drm/drm_irq_netbsd.h
 #include drm/drm_wait_netbsd.h
 
 #endif  /* _DRM_DRM_OS_NETBSD_H_ */

Added files:

Index: src/sys/external/bsd/drm2/include/drm/drm_irq_netbsd.h
diff -u /dev/null src/sys/external/bsd/drm2/include/drm/drm_irq_netbsd.h:1.1.2.1
--- /dev/null	Wed Jul 24 01:53:26 2013
+++ src/sys/external/bsd/drm2/include/drm/drm_irq_netbsd.h	Wed Jul 24 01:53:26 2013
@@ -0,0 +1,42 @@
+/*	$NetBSD: drm_irq_netbsd.h,v 1.1.2.1 2013/07/24 01:53:26 riastradh Exp $	*/
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#ifndef _DRM_DRM_IRQ_NETBSD_H_
+#define _DRM_DRM_IRQ_NETBSD_H_
+
+typedef int irqreturn_t;
+
+#define	IRQ_NONE	0
+#define	IRQ_HANDLED	1
+
+#define	DRM_IRQ_ARGS	void *arg
+
+#endif  /* _DRM_DRM_IRQ_NETBSD_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/asm

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:54:57 UTC 2013

Added Files:
src/sys/external/bsd/drm2/include/asm [riastradh-drm2]: barrier.h

Log Message:
Implement Linux memory barriers in asm/barrier.h.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.2.1 src/sys/external/bsd/drm2/include/asm/barrier.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/sys/external/bsd/drm2/include/asm/barrier.h
diff -u /dev/null src/sys/external/bsd/drm2/include/asm/barrier.h:1.1.2.1
--- /dev/null	Wed Jul 24 01:54:57 2013
+++ src/sys/external/bsd/drm2/include/asm/barrier.h	Wed Jul 24 01:54:57 2013
@@ -0,0 +1,59 @@
+/*	$NetBSD: barrier.h,v 1.1.2.1 2013/07/24 01:54:57 riastradh Exp $	*/
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#ifndef _ASM_BARRIER_H_
+#define _ASM_BARRIER_H_
+
+#include sys/atomic.h
+
+#define	mb	membar_sync
+#define	wmb	membar_producer
+#define	rmb	membar_consumer
+
+#ifdef __alpha__		/* XXX As if...  */
+#  define	read_barrier_depends	membar_sync
+#else
+#  define	read_barrier_depends()	do {} while (0)
+#endif
+
+#ifdef MULTIPROCESSOR
+#  define	smp_mbmb
+#  define	smp_wmbwmb
+#  define	smp_rmbrmb
+#  define	smp_read_barrier_depends	read_barrier_depends
+#else
+#  define	smp_mb()			do {} while (0)
+#  define	smp_wmb()			do {} while (0)
+#  define	smp_rmb()			do {} while (0)
+#  define	smp_read_barrier_depends()	do {} while (0)
+#endif
+
+#endif  /* _ASM_BARRIER_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:54:19 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: types.h

Log Message:
Define cycles_t to be unsigned long long for now in linux/types.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 \
src/sys/external/bsd/drm2/include/linux/types.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/types.h
diff -u src/sys/external/bsd/drm2/include/linux/types.h:1.1.2.4 src/sys/external/bsd/drm2/include/linux/types.h:1.1.2.5
--- src/sys/external/bsd/drm2/include/linux/types.h:1.1.2.4	Wed Jul 24 01:51:06 2013
+++ src/sys/external/bsd/drm2/include/linux/types.h	Wed Jul 24 01:54:19 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: types.h,v 1.1.2.4 2013/07/24 01:51:06 riastradh Exp $	*/
+/*	$NetBSD: types.h,v 1.1.2.5 2013/07/24 01:54:19 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -46,4 +46,7 @@ typedef int64_t s64;
 
 typedef bus_size_t resource_size_t;
 
+/* XXX Is this the right type?  */
+typedef unsigned long long cycles_t;
+
 #endif  /* _LINUX_TYPES_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:55:58 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: atomic.h

Log Message:
Add some atomic operations to linux/atomic.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/sys/external/bsd/drm2/include/linux/atomic.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/atomic.h
diff -u src/sys/external/bsd/drm2/include/linux/atomic.h:1.1.2.2 src/sys/external/bsd/drm2/include/linux/atomic.h:1.1.2.3
--- src/sys/external/bsd/drm2/include/linux/atomic.h:1.1.2.2	Wed Jul 24 00:48:34 2013
+++ src/sys/external/bsd/drm2/include/linux/atomic.h	Wed Jul 24 01:55:58 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: atomic.h,v 1.1.2.2 2013/07/24 00:48:34 riastradh Exp $	*/
+/*	$NetBSD: atomic.h,v 1.1.2.3 2013/07/24 01:55:58 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,6 +32,8 @@
 #ifndef _LINUX_ATOMIC_H_
 #define _LINUX_ATOMIC_H_
 
+#include sys/atomic.h
+
 typedef struct {
 	int atomic_value;
 } atomic_t;
@@ -42,4 +44,22 @@ atomic_read(atomic_t *atomic)
 	return *(volatile int *)atomic-atomic_value;
 }
 
+static inline void
+atomic_set(atomic_t *atomic, int value)
+{
+	atomic-atomic_value = value;
+}
+
+static inline void
+atomic_inc(atomic_t *atomic)
+{
+	atomic_inc_uint((unsigned int *)atomic-atomic_value);
+}
+
+static inline int
+atomic_dec_and_test(atomic_t *atomic)
+{
+	return (-1 == (int)atomic_dec_uint_nv(atomic-atomic_value));
+}
+
 #endif  /* _LINUX_ATOMIC_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:55:44 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: list.h

Log Message:
Reimplement (partial) Linux list abstraction directly.

TAILQ_* won't work easily because Linux doesn't distinguish heads from
noses.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/sys/external/bsd/drm2/include/linux/list.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/list.h
diff -u src/sys/external/bsd/drm2/include/linux/list.h:1.1.2.2 src/sys/external/bsd/drm2/include/linux/list.h:1.1.2.3
--- src/sys/external/bsd/drm2/include/linux/list.h:1.1.2.2	Wed Jul 24 00:49:48 2013
+++ src/sys/external/bsd/drm2/include/linux/list.h	Wed Jul 24 01:55:44 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: list.h,v 1.1.2.2 2013/07/24 00:49:48 riastradh Exp $	*/
+/*	$NetBSD: list.h,v 1.1.2.3 2013/07/24 01:55:44 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -41,34 +41,41 @@
  * Doubly-linked lists.
  */
 
-TAILQ_HEAD(list_head, list_node);
-struct list_node {
-	TAILQ_ENTRY(list_node) ln_entry;
+struct list_head {
+	struct list_head *lh_prev;
+	struct list_head *lh_next;
 };
 
-static inline struct list_node *
+static inline struct list_head *
 list_first(struct list_head *head)
 {
-	return TAILQ_FIRST(head);
+	return head-lh_next;
 }
 
-static inline struct list_node *
-list_next(struct list_node *node)
+static inline struct list_head *
+list_next(struct list_head *node)
 {
-	return TAILQ_NEXT(node, ln_entry);
+	return node-lh_next;
 }
 
 #define	list_entry(PTR, TYPE, FIELD)	container_of(PTR, TYPE, FIELD)
-#define	list_for_each(VAR, HEAD)	TAILQ_FOREACH(VAR, HEAD, ln_entry)
+
+#define	list_for_each(VAR, HEAD)	\
+	for ((VAR) = list_first((HEAD));\
+		(VAR) != NULL;		\
+		(VAR) = list_next((VAR))
+
 #define	list_for_each_safe(VAR, NEXT, HEAD)\
-	TAILQ_FOREACH_SAFE(VAR, HEAD, ln_entry, NEXT)
+	for ((VAR) = list_first((HEAD));\
+		((VAR) != NULL)  ((NEXT) = list_next((VAR)), 1);	\
+		(VAR) = (NEXT))
 
 #define	list_for_each_entry(VAR, HEAD, FIELD)\
-	for ((VAR) = ((TAILQ_FIRST((HEAD)) == NULL)? NULL :		\
-		list_entry(TAILQ_FIRST((HEAD)), typeof(*(VAR)), FIELD)); \
+	for ((VAR) = ((list_first((HEAD)) == NULL)? NULL :		\
+		list_entry(list_first((HEAD)), typeof(*(VAR)), FIELD)); \
 		(VAR) != NULL;		\
-		(VAR) = ((TAILQ_NEXT((VAR), FIELD) == NULL)? NULL :	\
-		list_entry(TAILQ_NEXT((VAR), FIELD), typeof(*(VAR)), \
+		(VAR) = ((list_next((VAR)-FIELD) == NULL)? NULL :	\
+		list_entry(list_next((VAR)-FIELD), typeof(*(VAR)), \
 			FIELD)))
 
 /*



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/asm

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:56:33 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/asm [riastradh-drm2]: barrier.h

Log Message:
Include opt_multiprocessor.h for MULTIPROCESSOR in asm/barrier.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/asm/barrier.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/asm/barrier.h
diff -u src/sys/external/bsd/drm2/include/asm/barrier.h:1.1.2.1 src/sys/external/bsd/drm2/include/asm/barrier.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/asm/barrier.h:1.1.2.1	Wed Jul 24 01:54:57 2013
+++ src/sys/external/bsd/drm2/include/asm/barrier.h	Wed Jul 24 01:56:33 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: barrier.h,v 1.1.2.1 2013/07/24 01:54:57 riastradh Exp $	*/
+/*	$NetBSD: barrier.h,v 1.1.2.2 2013/07/24 01:56:33 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -34,6 +34,10 @@
 
 #include sys/atomic.h
 
+#ifdef _KERNEL_OPT
+#include opt_multiprocessor.h
+#endif
+
 #define	mb	membar_sync
 #define	wmb	membar_producer
 #define	rmb	membar_consumer



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/drm

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:56:19 UTC 2013

Added Files:
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]: drm_mem_util.h

Log Message:
Rewrite drm/drm_mem_util.h in terms of kmem.

This requires passing the sizes to drm_free_large, which will require
some changes to the code that uses this abstraction, but they look
like they will be easy changes.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.2.1 \
src/sys/external/bsd/drm2/include/drm/drm_mem_util.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/sys/external/bsd/drm2/include/drm/drm_mem_util.h
diff -u /dev/null src/sys/external/bsd/drm2/include/drm/drm_mem_util.h:1.1.2.1
--- /dev/null	Wed Jul 24 01:56:19 2013
+++ src/sys/external/bsd/drm2/include/drm/drm_mem_util.h	Wed Jul 24 01:56:19 2013
@@ -0,0 +1,84 @@
+/*	$NetBSD: drm_mem_util.h,v 1.1.2.1 2013/07/24 01:56:19 riastradh Exp $	*/
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#ifndef _DRM_MEM_UTIL_H_
+#define _DRM_MEM_UTIL_H_
+
+#include sys/types.h
+#include sys/kmem.h
+#include sys/systm.h
+
+static inline void *
+drm_calloc_large(size_t n, size_t size)
+{
+
+#if 1
+	KASSERT(size != 0);	/* XXX Let's see whether this ever happens.  */
+#else
+	if (size == 0)
+		return NULL;	/* XXX OK?  */
+#endif
+
+	if (n  (SIZE_MAX / size))
+		return NULL;
+
+	return kmem_zalloc((n * size), KM_SLEEP);
+}
+
+static inline void *
+drm_malloc_ab(size_t n, size_t size)
+{
+
+#if 1
+	KASSERT(size != 0);	/* XXX Let's see whether this ever happens.  */
+#else
+	if (size == 0)
+		return NULL;	/* XXX OK?  */
+#endif
+
+	return kmem_alloc((n * size), KM_SLEEP);
+}
+
+static inline void
+drm_free_large(void *ptr, size_t n, size_t size)
+{
+
+#if 0/* XXX */
+	if (ptr != NULL)
+#endif
+	{
+		KASSERT(size != 0);
+		KASSERT(n = (SIZE_MAX / size));
+		kmem_free(ptr, (n * size));
+	}
+}
+
+#endif  /* _DRM_MEM_UTIL_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:57:20 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: mutex.h

Log Message:
Implement Linux's struct mutex less sleazily.

Can't recall why I did it sleazily in the first place.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/sys/external/bsd/drm2/include/linux/mutex.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/mutex.h
diff -u src/sys/external/bsd/drm2/include/linux/mutex.h:1.1.2.2 src/sys/external/bsd/drm2/include/linux/mutex.h:1.1.2.3
--- src/sys/external/bsd/drm2/include/linux/mutex.h:1.1.2.2	Wed Jul 24 01:51:21 2013
+++ src/sys/external/bsd/drm2/include/linux/mutex.h	Wed Jul 24 01:57:20 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: mutex.h,v 1.1.2.2 2013/07/24 01:51:21 riastradh Exp $	*/
+/*	$NetBSD: mutex.h,v 1.1.2.3 2013/07/24 01:57:20 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -34,13 +34,38 @@
 
 #include sys/mutex.h
 
-/* XXX Kludge: Replace `struct mutex' by `struct kmutex'.  */
-#define	mutexkmutex
-
-#define	mutex_lock			mutex_enter
-#define	mutex_lock_interruptible	mutex_enter /* XXX */
-#define	mutex_trylock			mutex_tryenter
-#define	mutex_unlock			mutex_exit
-#define	mutex_is_locked			mutex_owned
+struct mutex {
+	kmutex_t mtx_lock;
+};
+
+static inline void
+mutex_lock(struct mutex *mutex)
+{
+	mutex_enter(mutex-mtx_lock);
+}
+
+static inline void
+mutex_lock_interruptible(struct mutex *mutex)
+{
+	mutex_enter(mutex-mtx_lock); /* XXX */
+}
+
+static inline int
+mutex_trylock(struct mutex *mutex)
+{
+	return mutex_tryenter(mutex-mtx_lock);
+}
+
+static inline void
+mutex_unlock(struct mutex *mutex)
+{
+	mutex_exit(mutex-mtx_lock);
+}
+
+static inline bool
+mutex_is_locked(struct mutex *mutex)
+{
+	return mutex_owned(mutex-mtx_lock);
+}
 
 #endif  /* _LINUX_MUTEX_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:57:50 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: errno.h

Log Message:
Include sys/errno.h in linux/errno.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/linux/errno.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/errno.h
diff -u src/sys/external/bsd/drm2/include/linux/errno.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/errno.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/errno.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/errno.h	Wed Jul 24 01:57:50 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: errno.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $	*/
+/*	$NetBSD: errno.h,v 1.1.2.2 2013/07/24 01:57:50 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,6 @@
 #ifndef _LINUX_ERRNO_H_
 #define _LINUX_ERRNO_H_
 
+#include sys/errno.h
+
 #endif  /* _LINUX_ERRNO_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:59:05 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: slab.h

Log Message:
Add Linux-style kmalloc c. to linux/slab.h.

Defined in terms of malloc(9) with M_TEMP for now, since Linux's
kfree doesn't pass the size, so using kmem(9) is inexpedient.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/linux/slab.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/slab.h
diff -u src/sys/external/bsd/drm2/include/linux/slab.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/slab.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/slab.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/slab.h	Wed Jul 24 01:59:05 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: slab.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $	*/
+/*	$NetBSD: slab.h,v 1.1.2.2 2013/07/24 01:59:05 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,30 @@
 #ifndef _LINUX_SLAB_H_
 #define _LINUX_SLAB_H_
 
+#include sys/malloc.h
+
+#include uvm/uvm_extern.h	/* For PAGE_SIZE.  */
+
+/* XXX Should use kmem, but Linux kfree doesn't take the size.  */
+
+#define	GFP_KERNEL	M_WAITOK
+
+static inline void *
+kmalloc(size_t size, int flags)
+{
+	return malloc(size, M_TEMP, flags);
+}
+
+static inline void *
+kzalloc(size_t size, int flags)
+{
+	return malloc(size, M_TEMP, (flags | M_ZERO));
+}
+
+static inline void
+kfree(void *ptr)
+{
+	free(ptr, M_TEMP);
+}
+
 #endif  /* _LINUX_SLAB_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/drm

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:59:52 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]:
drm_agp_netbsd.h

Log Message:
Fill in drm_agp_netbsd.h a little.

There are some horrible but expedient hacks in here.  Sorry.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/drm/drm_agp_netbsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/drm_agp_netbsd.h
diff -u src/sys/external/bsd/drm2/include/drm/drm_agp_netbsd.h:1.1.2.1 src/sys/external/bsd/drm2/include/drm/drm_agp_netbsd.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/drm/drm_agp_netbsd.h:1.1.2.1	Wed Jul 24 01:50:35 2013
+++ src/sys/external/bsd/drm2/include/drm/drm_agp_netbsd.h	Wed Jul 24 01:59:52 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_agp_netbsd.h,v 1.1.2.1 2013/07/24 01:50:35 riastradh Exp $	*/
+/*	$NetBSD: drm_agp_netbsd.h,v 1.1.2.2 2013/07/24 01:59:52 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,12 +32,124 @@
 #ifndef _DRM_DRM_AGP_NETBSD_H_
 #define _DRM_DRM_AGP_NETBSD_H_
 
+/*
+ * XXX XXX XXX BEWARE!  This file is full of abstraction violations
+ * that are ruthlessly exploited for their value as happy accidents!
+ * You have been warned!
+ */
+
+#include sys/agpio.h
+
 #include dev/pci/pcivar.h	/* XXX include order botch */
 #include dev/pci/agpvar.h
 
+#include linux/kernel.h
+#include linux/pci.h
+
 #define	__OS_HAS_AGP	1
 
-typedef struct agp_memory_info DRM_AGP_MEM;
+typedef struct agp_memory DRM_AGP_MEM;
 typedef struct agp_info DRM_AGP_KERN;
 
+struct agp_bridge_data {
+	struct agp_softc abd_sc; /* XXX Abstraction violation! */
+};
+
+/*
+ * We already have a struct agp_memory, but fortunately it looks like
+ * it may accidentally work out.
+ */
+
+#if 0
+struct agp_memory {
+	void *am_cookie;
+};
+#endif
+
+static inline struct agp_bridge_data *
+agp_find_bridge(struct pci_dev *pdev __unused)
+{
+	/*
+	 * XXX How do we find the agp bridge attached to this
+	 * particular PCI device?
+	 */
+	return container_of(agp_find_device(0), struct agp_bridge_data,
+	abd_sc);
+}
+
+static inline struct agp_bridge_data *
+agp_backend_acquire(struct pci_dev *pdev)
+{
+	struct agp_bridge_data *const bridge = agp_find_bridge(pdev);
+
+	if (bridge == NULL)
+		return NULL;
+
+	/* XXX We lose the error code here.  */
+	if (agp_acquire(bridge-abd_sc) != 0)
+		return NULL;
+
+	return bridge;
+}
+
+static inline void
+agp_backend_release(struct agp_bridge_data *bridge)
+{
+
+	/* XXX We lose the error code here.  */
+	(void)agp_release(bridge-abd_sc);
+}
+
+/*
+ * Happily, agp_enable will accidentally DTRT as is in NetBSD in spite
+ * of the name collision, thanks to a curious `void *' argument in its
+ * declaration...
+ */
+
+#if 0
+static inline void
+agp_enable(struct agp_bridge_data *bridge)
+{
+	...
+}
+#endif
+
+static inline struct agp_memory *
+agp_allocate_memory(struct agp_bridge_data *bridge, size_t npages,
+uint32_t type)
+{
+	return agp_alloc_memory(bridge-abd_sc, (npages  AGP_PAGE_SHIFT),
+	type);
+}
+
+/*
+ * Once again, a happy accident makes agp_free_memory work out.
+ */
+
+#if 0
+static inline void
+agp_free_memory(struct agp_bridge_data *bridge, struct agp_memory *mem)
+{
+	...
+}
+#endif
+
+/*
+ * Unfortunately, Linux's agp_bind_memory doesn't require the agp
+ * device as an argument.  So we'll have to kludge that up as we go.
+ */
+#if 0
+static inline void
+agp_bind_memory(struct agp_memory *mem, size_t npages)
+{
+	agp_bind_memory(???, mem, (npages  AGP_PAGE_SHIFT));
+}
+#endif
+
+static inline void
+agp_copy_info(struct agp_bridge_data *bridge, DRM_AGP_KERN *info)
+{
+	agp_get_info(bridge, info);
+}
+
 #endif  /* _DRM_DRM_AGP_NETBSD_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 01:59:19 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: list.h

Log Message:
Add INIT_LIST_HEAD, list_add, list_add_tail, and list_del.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \
src/sys/external/bsd/drm2/include/linux/list.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/list.h
diff -u src/sys/external/bsd/drm2/include/linux/list.h:1.1.2.3 src/sys/external/bsd/drm2/include/linux/list.h:1.1.2.4
--- src/sys/external/bsd/drm2/include/linux/list.h:1.1.2.3	Wed Jul 24 01:55:44 2013
+++ src/sys/external/bsd/drm2/include/linux/list.h	Wed Jul 24 01:59:19 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: list.h,v 1.1.2.3 2013/07/24 01:55:44 riastradh Exp $	*/
+/*	$NetBSD: list.h,v 1.1.2.4 2013/07/24 01:59:19 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -46,6 +46,13 @@ struct list_head {
 	struct list_head *lh_next;
 };
 
+static inline void
+INIT_LIST_HEAD(struct list_head *head)
+{
+	head-lh_prev = head;
+	head-lh_next = head;
+}
+
 static inline struct list_head *
 list_first(struct list_head *head)
 {
@@ -58,6 +65,35 @@ list_next(struct list_head *node)
 	return node-lh_next;
 }
 
+static inline void
+list_add(struct list_head *new, struct list_head *head)
+{
+	struct list_head *const next = head-lh_next;
+
+	head-lh_next = new;
+	new-lh_prev = head;
+	new-lh_next = next;
+	next-lh_prev = new;
+}
+
+static inline void
+list_add_tail(struct list_head *new, struct list_head *head)
+{
+	struct list_head *const prev = head-lh_prev;
+
+	head-lh_prev = new;
+	new-lh_prev = prev;
+	new-lh_next = head;
+	prev-lh_next = new;
+}
+
+static inline void
+list_del(struct list_head *entry)
+{
+	entry-lh_prev-lh_next = entry-lh_next;
+	entry-lh_next-lh_prev = entry-lh_prev;
+}
+
 #define	list_entry(PTR, TYPE, FIELD)	container_of(PTR, TYPE, FIELD)
 
 #define	list_for_each(VAR, HEAD)	\



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/asm

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:01:13 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/asm [riastradh-drm2]: shmparam.h

Log Message:
Define SHMLBA to be PAGE_SIZE in asm/shmparam.h.

XXX Wait, what?


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/asm/shmparam.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/asm/shmparam.h
diff -u src/sys/external/bsd/drm2/include/asm/shmparam.h:1.1.2.1 src/sys/external/bsd/drm2/include/asm/shmparam.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/asm/shmparam.h:1.1.2.1	Wed Jul 24 00:33:11 2013
+++ src/sys/external/bsd/drm2/include/asm/shmparam.h	Wed Jul 24 02:01:13 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: shmparam.h,v 1.1.2.1 2013/07/24 00:33:11 riastradh Exp $	*/
+/*	$NetBSD: shmparam.h,v 1.1.2.2 2013/07/24 02:01:13 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,8 @@
 #ifndef _ASM_SHMPARAM_H_
 #define _ASM_SHMPARAM_H_
 
+#include uvm/uvm_extern.h
+
+#define	SHMLBA	PAGE_SIZE
+
 #endif  /* _ASM_SHMPARAM_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/drm

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:00:44 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]: drm_os_netbsd.h
Added Files:
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]:
drm_copy_netbsd.h

Log Message:
Implement DRM_COPY_FROM_USER and DRM_COPY_FROM_USER.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.2.1 \
src/sys/external/bsd/drm2/include/drm/drm_copy_netbsd.h
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 \
src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h
diff -u src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.1.2.4 src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.1.2.5
--- src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.1.2.4	Wed Jul 24 01:53:26 2013
+++ src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h	Wed Jul 24 02:00:44 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_os_netbsd.h,v 1.1.2.4 2013/07/24 01:53:26 riastradh Exp $	*/
+/*	$NetBSD: drm_os_netbsd.h,v 1.1.2.5 2013/07/24 02:00:44 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -37,6 +37,7 @@
 #endif
 
 #include drm/drm_agp_netbsd.h
+#include drm/drm_copy_netbsd.h
 #include drm/drm_irq_netbsd.h
 #include drm/drm_wait_netbsd.h
 

Added files:

Index: src/sys/external/bsd/drm2/include/drm/drm_copy_netbsd.h
diff -u /dev/null src/sys/external/bsd/drm2/include/drm/drm_copy_netbsd.h:1.1.2.1
--- /dev/null	Wed Jul 24 02:00:44 2013
+++ src/sys/external/bsd/drm2/include/drm/drm_copy_netbsd.h	Wed Jul 24 02:00:44 2013
@@ -0,0 +1,50 @@
+/*	$NetBSD: drm_copy_netbsd.h,v 1.1.2.1 2013/07/24 02:00:44 riastradh Exp $	*/
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#ifndef _DRM_DRM_COPY_NETBSD_H_
+#define _DRM_DRM_COPY_NETBSD_H_
+
+#include sys/types.h
+#include sys/systm.h
+
+static inline int
+DRM_COPY_FROM_USER(void *kernel_addr, const void *user_addr, size_t len)
+{
+	return copyin(user_addr, kernel_addr, len);
+}
+
+static inline int
+DRM_COPY_TO_USER(const void *kernel_addr, void *user_addr, size_t len)
+{
+	return copyout(kernel_addr, user_addr, len);
+}
+
+#endif  /* _DRM_DRM_OS_NETBSD_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:02:17 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: atomic.h

Log Message:
Use a union rather than casts in linux/atomic.h.  Add atomic_dec.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \
src/sys/external/bsd/drm2/include/linux/atomic.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/atomic.h
diff -u src/sys/external/bsd/drm2/include/linux/atomic.h:1.1.2.3 src/sys/external/bsd/drm2/include/linux/atomic.h:1.1.2.4
--- src/sys/external/bsd/drm2/include/linux/atomic.h:1.1.2.3	Wed Jul 24 01:55:58 2013
+++ src/sys/external/bsd/drm2/include/linux/atomic.h	Wed Jul 24 02:02:17 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: atomic.h,v 1.1.2.3 2013/07/24 01:55:58 riastradh Exp $	*/
+/*	$NetBSD: atomic.h,v 1.1.2.4 2013/07/24 02:02:17 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -35,31 +35,40 @@
 #include sys/atomic.h
 
 typedef struct {
-	int atomic_value;
+	union {
+		int au_int;
+		unsigned int au_uint;
+	} a_u;
 } atomic_t;
 
 static inline int
 atomic_read(atomic_t *atomic)
 {
-	return *(volatile int *)atomic-atomic_value;
+	return *(volatile int *)atomic-a_u.au_int;
 }
 
 static inline void
 atomic_set(atomic_t *atomic, int value)
 {
-	atomic-atomic_value = value;
+	atomic-a_u.au_int = value;
 }
 
 static inline void
 atomic_inc(atomic_t *atomic)
 {
-	atomic_inc_uint((unsigned int *)atomic-atomic_value);
+	atomic_inc_uint(atomic-a_u.au_uint);
+}
+
+static inline void
+atomic_dec(atomic_t *atomic)
+{
+	atomic_dec_uint(atomic-a_u.au_uint);
 }
 
 static inline int
 atomic_dec_and_test(atomic_t *atomic)
 {
-	return (-1 == (int)atomic_dec_uint_nv(atomic-atomic_value));
+	return (-1 == (int)atomic_dec_uint_nv(atomic-a_u.au_uint));
 }
 
 #endif  /* _LINUX_ATOMIC_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:01:28 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: slab.h

Log Message:
Implement krealloc in linux/slab.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/sys/external/bsd/drm2/include/linux/slab.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/slab.h
diff -u src/sys/external/bsd/drm2/include/linux/slab.h:1.1.2.2 src/sys/external/bsd/drm2/include/linux/slab.h:1.1.2.3
--- src/sys/external/bsd/drm2/include/linux/slab.h:1.1.2.2	Wed Jul 24 01:59:05 2013
+++ src/sys/external/bsd/drm2/include/linux/slab.h	Wed Jul 24 02:01:28 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: slab.h,v 1.1.2.2 2013/07/24 01:59:05 riastradh Exp $	*/
+/*	$NetBSD: slab.h,v 1.1.2.3 2013/07/24 02:01:28 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -52,6 +52,12 @@ kzalloc(size_t size, int flags)
 	return malloc(size, M_TEMP, (flags | M_ZERO));
 }
 
+static inline void *
+krealloc(void *ptr, size_t size, int flags)
+{
+	return realloc(ptr, size, M_TEMP, flags);
+}
+
 static inline void
 kfree(void *ptr)
 {



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:02:03 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/asm [riastradh-drm2]: uaccess.h
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: uaccess.h

Log Message:
Define copy_{to,from}_user in linux/uaccess.h  asm/uaccess.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/asm/uaccess.h
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/linux/uaccess.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/asm/uaccess.h
diff -u src/sys/external/bsd/drm2/include/asm/uaccess.h:1.1.2.1 src/sys/external/bsd/drm2/include/asm/uaccess.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/asm/uaccess.h:1.1.2.1	Wed Jul 24 00:33:11 2013
+++ src/sys/external/bsd/drm2/include/asm/uaccess.h	Wed Jul 24 02:02:03 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: uaccess.h,v 1.1.2.1 2013/07/24 00:33:11 riastradh Exp $	*/
+/*	$NetBSD: uaccess.h,v 1.1.2.2 2013/07/24 02:02:03 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,20 @@
 #ifndef _ASM_UACCESS_H_
 #define _ASM_UACCESS_H_
 
+#include sys/types.h
+#include sys/systm.h
+
+static inline int
+copy_from_user(void *kernel_addr, const void *user_addr, size_t len)
+{
+	return -copyin(user_addr, kernel_addr, len);
+}
+
+static inline int
+copy_to_user(void *user_addr, const void *kernel_addr, size_t len)
+{
+	return -copyout(kernel_addr, user_addr, len);
+}
+
+
 #endif  /* _ASM_UACCESS_H_ */

Index: src/sys/external/bsd/drm2/include/linux/uaccess.h
diff -u src/sys/external/bsd/drm2/include/linux/uaccess.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/uaccess.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/uaccess.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/uaccess.h	Wed Jul 24 02:02:03 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: uaccess.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $	*/
+/*	$NetBSD: uaccess.h,v 1.1.2.2 2013/07/24 02:02:03 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,6 @@
 #ifndef _LINUX_UACCESS_H_
 #define _LINUX_UACCESS_H_
 
+#include asm/uaccess.h
+
 #endif  /* _LINUX_UACCESS_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/drm

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:01:42 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]:
drm_copy_netbsd.h

Log Message:
Negate error code in DRM_COPY_{TO,FROM}_USER in drm_copy_netbsd.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/drm/drm_copy_netbsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/drm_copy_netbsd.h
diff -u src/sys/external/bsd/drm2/include/drm/drm_copy_netbsd.h:1.1.2.1 src/sys/external/bsd/drm2/include/drm/drm_copy_netbsd.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/drm/drm_copy_netbsd.h:1.1.2.1	Wed Jul 24 02:00:44 2013
+++ src/sys/external/bsd/drm2/include/drm/drm_copy_netbsd.h	Wed Jul 24 02:01:42 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_copy_netbsd.h,v 1.1.2.1 2013/07/24 02:00:44 riastradh Exp $	*/
+/*	$NetBSD: drm_copy_netbsd.h,v 1.1.2.2 2013/07/24 02:01:42 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,13 +38,13 @@
 static inline int
 DRM_COPY_FROM_USER(void *kernel_addr, const void *user_addr, size_t len)
 {
-	return copyin(user_addr, kernel_addr, len);
+	return -copyin(user_addr, kernel_addr, len);
 }
 
 static inline int
 DRM_COPY_TO_USER(const void *kernel_addr, void *user_addr, size_t len)
 {
-	return copyout(kernel_addr, user_addr, len);
+	return -copyout(kernel_addr, user_addr, len);
 }
 
 #endif  /* _DRM_DRM_OS_NETBSD_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:03:00 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: log2.h

Log Message:
Include sys/bitops.h in linux/log2.h for ilog2.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/linux/log2.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/log2.h
diff -u src/sys/external/bsd/drm2/include/linux/log2.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/log2.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/log2.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/log2.h	Wed Jul 24 02:03:00 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: log2.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $	*/
+/*	$NetBSD: log2.h,v 1.1.2.2 2013/07/24 02:03:00 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,6 @@
 #ifndef _LINUX_LOG2_H_
 #define _LINUX_LOG2_H_
 
+#include sys/bitops.h
+
 #endif  /* _LINUX_LOG2_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:02:45 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: vmalloc.h

Log Message:
Implement vmalloc_user and vfree with malloc(9) in linux/vmalloc.h.

XXX Probably not the right thing here -- uvm_km_alloc is probably
more appropriate, but Linux doesn't pass the size to vfree, so this
is more expedient for now.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/linux/vmalloc.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/vmalloc.h
diff -u src/sys/external/bsd/drm2/include/linux/vmalloc.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/vmalloc.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/vmalloc.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/vmalloc.h	Wed Jul 24 02:02:45 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmalloc.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $	*/
+/*	$NetBSD: vmalloc.h,v 1.1.2.2 2013/07/24 02:02:45 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,18 @@
 #ifndef _LINUX_VMALLOC_H_
 #define _LINUX_VMALLOC_H_
 
+#include sys/malloc.h
+
+static inline void *
+vmalloc_user(unsigned long size)
+{
+	return malloc(size, M_TEMP, (M_WAITOK | M_ZERO));
+}
+
+static inline void
+vfree(void *ptr)
+{
+	return free(ptr, M_TEMP);
+}
+
 #endif  /* _LINUX_VMALLOC_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:02:32 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: list.h

Log Message:
Implement list_empty and list_for_each_entry_safe in linux/list.h.

Also fix the list operations to be consistent about using the head,
rather than NULL, as the sentinel.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 \
src/sys/external/bsd/drm2/include/linux/list.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/list.h
diff -u src/sys/external/bsd/drm2/include/linux/list.h:1.1.2.4 src/sys/external/bsd/drm2/include/linux/list.h:1.1.2.5
--- src/sys/external/bsd/drm2/include/linux/list.h:1.1.2.4	Wed Jul 24 01:59:19 2013
+++ src/sys/external/bsd/drm2/include/linux/list.h	Wed Jul 24 02:02:32 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: list.h,v 1.1.2.4 2013/07/24 01:59:19 riastradh Exp $	*/
+/*	$NetBSD: list.h,v 1.1.2.5 2013/07/24 02:02:32 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -65,6 +65,12 @@ list_next(struct list_head *node)
 	return node-lh_next;
 }
 
+static inline int
+list_empty(struct list_head *head)
+{
+	return (head-lh_next == head);
+}
+
 static inline void
 list_add(struct list_head *new, struct list_head *head)
 {
@@ -98,21 +104,26 @@ list_del(struct list_head *entry)
 
 #define	list_for_each(VAR, HEAD)	\
 	for ((VAR) = list_first((HEAD));\
-		(VAR) != NULL;		\
+		(VAR) != (HEAD);	\
 		(VAR) = list_next((VAR))
 
 #define	list_for_each_safe(VAR, NEXT, HEAD)\
 	for ((VAR) = list_first((HEAD));\
-		((VAR) != NULL)  ((NEXT) = list_next((VAR)), 1);	\
+		((VAR) != (HEAD))  ((NEXT) = list_next((VAR)), 1);	\
 		(VAR) = (NEXT))
 
 #define	list_for_each_entry(VAR, HEAD, FIELD)\
-	for ((VAR) = ((list_first((HEAD)) == NULL)? NULL :		\
-		list_entry(list_first((HEAD)), typeof(*(VAR)), FIELD)); \
-		(VAR) != NULL;		\
-		(VAR) = ((list_next((VAR)-FIELD) == NULL)? NULL :	\
-		list_entry(list_next((VAR)-FIELD), typeof(*(VAR)), \
-			FIELD)))
+	for ((VAR) = list_entry(list_first((HEAD)), typeof(*(VAR)), FIELD); \
+		(VAR)-FIELD != (HEAD);\
+		(VAR) = list_entry(list_next((VAR)-FIELD), typeof(*(VAR)), \
+		FIELD))
+
+#define	list_for_each_entry_safe(VAR, NEXT, HEAD, FIELD)		\
+	for ((VAR) = list_entry(list_first((HEAD)), typeof(*(VAR)), FIELD); \
+		((VAR)-FIELD != (HEAD)) \
+		((NEXT) = list_entry(list_next((VAR)-FIELD),	\
+			typeof(*(VAR)), FIELD), 1);			\
+		(VAR) = (NEXT))
 
 /*
  * `H'ead-only/`H'ash-table doubly-linked lists.



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:03:32 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: sched.h

Log Message:
#define current curproc, and add task_pid_nr, in linux/sched.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/linux/sched.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/sched.h
diff -u src/sys/external/bsd/drm2/include/linux/sched.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/sched.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/sched.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/sched.h	Wed Jul 24 02:03:32 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: sched.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $	*/
+/*	$NetBSD: sched.h,v 1.1.2.2 2013/07/24 02:03:32 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,14 @@
 #ifndef _LINUX_SCHED_H_
 #define _LINUX_SCHED_H_
 
+#include sys/proc.h
+
+#define	current	curproc
+
+static inline pid_t
+task_pid_nr(struct proc *p)
+{
+	return p-p_pid;
+}
+
 #endif  /* _LINUX_SCHED_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/drm

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:03:16 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]:
drm_wait_netbsd.h

Log Message:
Tweak drm waitqueue compatibility interface.

Use (Linux) struct mutex for drm_interlock_t, and split DRM_WAKEUP
into DRM_WAKEUP_ONE (cv_signal) and DRM_WAKEUP_ALL (cv_broadcast).


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h
diff -u src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.1.2.1 src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.1.2.1	Wed Jul 24 01:49:31 2013
+++ src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h	Wed Jul 24 02:03:16 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_wait_netbsd.h,v 1.1.2.1 2013/07/24 01:49:31 riastradh Exp $	*/
+/*	$NetBSD: drm_wait_netbsd.h,v 1.1.2.2 2013/07/24 02:03:16 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -36,29 +36,37 @@
 #include sys/mutex.h
 #include sys/systm.h
 
+#include linux/mutex.h
+
 typedef kcondvar_t drm_waitqueue_t;
-typedef kmutex_t drm_interlock_t;
+typedef struct mutex drm_interlock_t; /* XXX urk */
 
 static inline void
 DRM_INIT_WAITQUEUE(drm_waitqueue_t *q, const char *name)
 {
-
 	cv_init(q, name);
 }
 
 static inline void
-DRM_WAKEUP(drm_waitqueue_t *q, drm_interlock_t *interlock)
+DRM_WAKEUP_ONE(drm_waitqueue_t *q, drm_interlock_t *interlock)
 {
+	KASSERT(mutex_owned(interlock-mtx_lock));
+	cv_signal(q);
+}
 
-	KASSERT(mutex_owned(interlock));
+static inline void
+DRM_WAKEUP_ALL(drm_waitqueue_t *q, drm_interlock_t *interlock)
+{
+	KASSERT(mutex_owned(interlock-mtx_lock));
 	cv_broadcast(q);
 }
 
 #define	DRM_WAIT_ON(RET, Q, INTERLOCK, TICKS, CONDITION) do		\
 {	\
-	KASSERT(mutex_owned((INTERLOCK)));\
+	KASSERT(mutex_owned((INTERLOCK)-mtx_lock));			\
 	while (!(CONDITION)) {		\
-		(RET) = cv_timedwait_sig((Q), (INTERLOCK), (TICKS));	\
+		(RET) = cv_timedwait_sig((Q), (INTERLOCK)-mtx_lock,	\
+		(TICKS));		\
 		if (RET)		\
 			break;		\
 	}\



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/asm

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:03:46 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/asm [riastradh-drm2]: mtrr.h

Log Message:
Partially implement Linux asm/mtrr.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/external/bsd/drm2/include/asm/mtrr.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/asm/mtrr.h
diff -u src/sys/external/bsd/drm2/include/asm/mtrr.h:1.1.2.1 src/sys/external/bsd/drm2/include/asm/mtrr.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/asm/mtrr.h:1.1.2.1	Wed Jul 24 00:33:11 2013
+++ src/sys/external/bsd/drm2/include/asm/mtrr.h	Wed Jul 24 02:03:46 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: mtrr.h,v 1.1.2.1 2013/07/24 00:33:11 riastradh Exp $	*/
+/*	$NetBSD: mtrr.h,v 1.1.2.2 2013/07/24 02:03:46 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,51 @@
 #ifndef _ASM_MTRR_H_
 #define _ASM_MTRR_H_
 
+#ifdef _KERNEL_OPT
+#include opt_mtrr.h
+#endif
+
+#include machine/mtrr.h
+
+#define	MTRR_TYPE_WRCOMB	MTRR_TYPE_WC
+
+static inline int
+mtrr_add(unsigned long base, unsigned long size, int type,
+bool increment __unused)
+{
+#ifdef MTRR
+	struct mtrr mtrr;
+	int n = 1;
+
+	mtrr.base = base;
+	mtrr.len = size;
+	mtrr.type = type;
+	mtrr.flags = MTRR_VALID;
+
+	/* XXX errno NetBSD-Linux */
+	return -mtrr_set(mtrr, n, NULL, MTRR_GETSET_KERNEL);
+#else
+	return 0;
+#endif
+}
+
+static inline int
+mtrr_del(int handle __unused, unsigned long base, unsigned long size)
+{
+#ifdef MTRR
+	struct mtrr mtrr;
+	int n = 1;
+
+	mtrr.base = base;
+	mtrr.len = size;
+	mtrr.type = 0;
+	mtrr.flags = 0;		/* not MTRR_VALID */
+
+	/* XXX errno NetBSD-Linux */
+	return -mtrr_set(mtrr, n, NULL, MTRR_GETSET_KERNEL);
+#else
+	return 0;
+#endif
+}
+
 #endif  /* _ASM_MTRR_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:04:31 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: mm.h

Log Message:
First stab at vm_mmap in linux/mm.h.  Also PAGE_SIZE  round_page.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/external/bsd/drm2/include/linux/mm.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/mm.h
diff -u src/sys/external/bsd/drm2/include/linux/mm.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/mm.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/mm.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/mm.h	Wed Jul 24 02:04:31 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: mm.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $	*/
+/*	$NetBSD: mm.h,v 1.1.2.2 2013/07/24 02:04:31 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,79 @@
 #ifndef _LINUX_MM_H_
 #define _LINUX_MM_H_
 
+#include sys/kauth.h
+#include sys/file.h
+#include sys/mman.h
+#include sys/proc.h
+#include sys/vnode.h
+
+#include uvm/uvm_extern.h
+
+#define	PAGE_ALIGN(x)	round_page(x)
+
+/*
+ * ###
+ * ### XXX THIS NEEDS SERIOUS SCRUTINY XXX ###
+ * ###
+ */
+
+/*
+ * XXX unsigned long is a loser but will probably work accidentally.
+ * XXX struct file might not map quite right between Linux and NetBSD.
+ * XXX This is large enough it should take its own file.
+ */
+
+static inline unsigned long
+vm_mmap(struct file *file, unsigned long base, unsigned long size,
+unsigned long prot, unsigned long flags, unsigned long token)
+{
+	struct vnode *vnode;
+	vaddr_t addr = 0;
+	int error;
+
+	/*
+	 * Cargo-culted from sys_mmap.  Various conditions kasserted
+	 * rather than checked for expedience and safey.
+	 */
+
+	KASSERT(base == 0);
+	KASSERT(prot == (PROT_READ | PROT_WRITE));
+	KASSERT(flags == MAP_SHARED);
+
+	KASSERT(file-f_type == DTYPE_VNODE);
+	vnode = file-f_data;
+
+	KASSERT(vnode-v_type == VCHR);
+	KASSERT((file-f_flag  (FREAD | FWRITE)) == (FREAD | FWRITE));
+
+	{
+		struct vattr va;
+
+		vn_lock(vnode, (LK_SHARED | LK_RETRY));
+		error = VOP_GETATTR(vnode, va, kauth_cred_get());
+		VOP_UNLOCK(vnode);
+		if (error)
+			goto out;
+		/* XXX kassert?  */
+		if ((va.va_flags  (SF_SNAPSHOT | IMMUTABLE | APPEND)) != 0) {
+			error = EACCES;
+			goto out;
+		}
+	}
+
+	/* XXX pax_mprotect?  pax_aslr?  */
+
+	error = uvm_mmap(curproc-p_vmspace-vm_map, addr, size,
+	(VM_PROT_READ | VM_PROT_WRITE), (VM_PROT_READ | VM_PROT_WRITE),
+	MAP_SHARED, vnode, base,
+	curproc-p_rlimit[RLIMIT_MEMLOCK].rlim_cur);
+	if (error)
+		goto out;
+
+	KASSERT(addr = -1024UL); /* XXX Kludgerosity!  */
+
+out:	/* XXX errno NetBSD-Linux (kludgerific) */
+	return (error? (-error) : (unsigned long)addr);
+}
+
 #endif  /* _LINUX_MM_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:04:16 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/asm [riastradh-drm2]: uaccess.h
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]:
drm_copy_netbsd.h

Log Message:
Mark NetBSD-Linux errno translations in copy_{to,from}_user.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/sys/external/bsd/drm2/include/asm/uaccess.h
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/sys/external/bsd/drm2/include/drm/drm_copy_netbsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/asm/uaccess.h
diff -u src/sys/external/bsd/drm2/include/asm/uaccess.h:1.1.2.2 src/sys/external/bsd/drm2/include/asm/uaccess.h:1.1.2.3
--- src/sys/external/bsd/drm2/include/asm/uaccess.h:1.1.2.2	Wed Jul 24 02:02:03 2013
+++ src/sys/external/bsd/drm2/include/asm/uaccess.h	Wed Jul 24 02:04:16 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: uaccess.h,v 1.1.2.2 2013/07/24 02:02:03 riastradh Exp $	*/
+/*	$NetBSD: uaccess.h,v 1.1.2.3 2013/07/24 02:04:16 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,12 +38,14 @@
 static inline int
 copy_from_user(void *kernel_addr, const void *user_addr, size_t len)
 {
+	/* XXX errno NetBSD-Linux */
 	return -copyin(user_addr, kernel_addr, len);
 }
 
 static inline int
 copy_to_user(void *user_addr, const void *kernel_addr, size_t len)
 {
+	/* XXX errno NetBSD-Linux */
 	return -copyout(kernel_addr, user_addr, len);
 }
 

Index: src/sys/external/bsd/drm2/include/drm/drm_copy_netbsd.h
diff -u src/sys/external/bsd/drm2/include/drm/drm_copy_netbsd.h:1.1.2.2 src/sys/external/bsd/drm2/include/drm/drm_copy_netbsd.h:1.1.2.3
--- src/sys/external/bsd/drm2/include/drm/drm_copy_netbsd.h:1.1.2.2	Wed Jul 24 02:01:42 2013
+++ src/sys/external/bsd/drm2/include/drm/drm_copy_netbsd.h	Wed Jul 24 02:04:16 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_copy_netbsd.h,v 1.1.2.2 2013/07/24 02:01:42 riastradh Exp $	*/
+/*	$NetBSD: drm_copy_netbsd.h,v 1.1.2.3 2013/07/24 02:04:16 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,12 +38,14 @@
 static inline int
 DRM_COPY_FROM_USER(void *kernel_addr, const void *user_addr, size_t len)
 {
+	/* XXX errno NetBSD-Linux */
 	return -copyin(user_addr, kernel_addr, len);
 }
 
 static inline int
 DRM_COPY_TO_USER(const void *kernel_addr, void *user_addr, size_t len)
 {
+	/* XXX errno NetBSD-Linux */
 	return -copyout(kernel_addr, user_addr, len);
 }
 



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/drm

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:06:38 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]: drm_os_netbsd.h
Added Files:
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]:
drm_auth_netbsd.h

Log Message:
Implement DRM_SUSER compatibility kludge.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.2.1 \
src/sys/external/bsd/drm2/include/drm/drm_auth_netbsd.h
cvs rdiff -u -r1.1.2.5 -r1.1.2.6 \
src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h
diff -u src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.1.2.5 src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.1.2.6
--- src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.1.2.5	Wed Jul 24 02:00:44 2013
+++ src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h	Wed Jul 24 02:06:38 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_os_netbsd.h,v 1.1.2.5 2013/07/24 02:00:44 riastradh Exp $	*/
+/*	$NetBSD: drm_os_netbsd.h,v 1.1.2.6 2013/07/24 02:06:38 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -37,6 +37,7 @@
 #endif
 
 #include drm/drm_agp_netbsd.h
+#include drm/drm_auth_netbsd.h
 #include drm/drm_copy_netbsd.h
 #include drm/drm_irq_netbsd.h
 #include drm/drm_wait_netbsd.h

Added files:

Index: src/sys/external/bsd/drm2/include/drm/drm_auth_netbsd.h
diff -u /dev/null src/sys/external/bsd/drm2/include/drm/drm_auth_netbsd.h:1.1.2.1
--- /dev/null	Wed Jul 24 02:06:38 2013
+++ src/sys/external/bsd/drm2/include/drm/drm_auth_netbsd.h	Wed Jul 24 02:06:38 2013
@@ -0,0 +1,44 @@
+/*	$NetBSD: drm_auth_netbsd.h,v 1.1.2.1 2013/07/24 02:06:38 riastradh Exp $	*/
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#ifndef _DRM_DRM_AUTH_NETBSD_H_
+#define _DRM_DRM_AUTH_NETBSD_H_
+
+#include sys/kauth.h
+
+static inline bool
+DRM_SUSER(void)
+{
+	return kauth_authorize_generic(kauth_cred_get(), KAUTH_GENERIC_ISSUSER,
+	NULL) == 0;
+}
+
+#endif  /* _DRM_DRM_AUTH_NETBSD_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:07:31 UTC 2013

Added Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: err.h

Log Message:
Implement Linux's kludgerous pointers-as-errors in linux/err.h.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.2.1 src/sys/external/bsd/drm2/include/linux/err.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/sys/external/bsd/drm2/include/linux/err.h
diff -u /dev/null src/sys/external/bsd/drm2/include/linux/err.h:1.1.2.1
--- /dev/null	Wed Jul 24 02:07:31 2013
+++ src/sys/external/bsd/drm2/include/linux/err.h	Wed Jul 24 02:07:31 2013
@@ -0,0 +1,87 @@
+/*	$NetBSD: err.h,v 1.1.2.1 2013/07/24 02:07:31 riastradh Exp $	*/
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#ifndef _LINUX_ERR_H_
+#define _LINUX_ERR_H_
+
+/* XXX Linux uses long and int inconsistently here.  Hope this works out.  */
+
+#include sys/types.h
+#include sys/errno.h
+#include sys/systm.h
+
+#define	MAX_ERRNO	ELAST
+
+static inline bool
+IS_ERR_VALUE(uintptr_t n)
+{
+	return (n = (uintptr_t)-MAX_ERRNO);
+}
+
+static inline void *
+ERR_PTR(int error)
+{
+	KASSERT(error  0);
+	return (void *)(intptr_t)error;
+}
+
+static inline int
+PTR_ERR(const void *ptr)
+{
+	KASSERT((intptr_t)INT_MAX = (intptr_t)ptr);
+	return (int)(intptr_t)ptr;
+}
+
+static inline bool
+IS_ERR(const void *ptr)
+{
+	return IS_ERR_VALUE((uintptr_t)ptr);
+}
+
+static inline bool
+IS_ERR_OR_NULL(const void *ptr)
+{
+	return ((ptr == NULL) || IS_ERR(ptr));
+}
+
+static inline void *
+ERR_CAST(void *ptr)		/* XXX Linux declares with const.  */
+{
+	return ptr;
+}
+
+static inline int
+PTR_RET(const void *ptr)
+{
+	return (IS_ERR(ptr)? PTR_ERR(ptr) : 0);
+}
+
+#endif  /* _LINUX_ERR_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:08:01 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: atomic.h

Log Message:
Add some bit-toggling atomics to linux/atomic.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 \
src/sys/external/bsd/drm2/include/linux/atomic.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/atomic.h
diff -u src/sys/external/bsd/drm2/include/linux/atomic.h:1.1.2.4 src/sys/external/bsd/drm2/include/linux/atomic.h:1.1.2.5
--- src/sys/external/bsd/drm2/include/linux/atomic.h:1.1.2.4	Wed Jul 24 02:02:17 2013
+++ src/sys/external/bsd/drm2/include/linux/atomic.h	Wed Jul 24 02:08:01 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: atomic.h,v 1.1.2.4 2013/07/24 02:02:17 riastradh Exp $	*/
+/*	$NetBSD: atomic.h,v 1.1.2.5 2013/07/24 02:08:01 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -71,4 +71,54 @@ atomic_dec_and_test(atomic_t *atomic)
 	return (-1 == (int)atomic_dec_uint_nv(atomic-a_u.au_uint));
 }
 
+static inline void
+set_bit(unsigned long bit, volatile unsigned long *ptr)
+{
+	atomic_or_ulong(ptr, (1  bit));
+}
+
+static inline void
+clear_bit(unsigned long bit, volatile unsigned long *ptr)
+{
+	atomic_and_ulong(ptr, ~(1  bit));
+}
+
+static inline void
+change_bit(unsigned long bit, volatile unsigned long *ptr)
+{
+	unsigned long v;
+
+	do v = *ptr; while (atomic_cas_ulong(ptr, v, v ^ (1  bit)) != v);
+}
+
+static inline unsigned long
+test_and_set_bit(unsigned long bit, volatile unsigned long *ptr)
+{
+	unsigned long v;
+
+	do v = *ptr; while (atomic_cas_ulong(ptr, v, v | (1  bit)) != v);
+
+	return (v  (1  bit));
+}
+
+static inline unsigned long
+test_and_clear_bit(unsigned long bit, volatile unsigned long *ptr)
+{
+	unsigned long v;
+
+	do v = *ptr; while (atomic_cas_ulong(ptr, v, v ~ (1  bit)) != v);
+
+	return (v  (1  bit));
+}
+
+static inline unsigned long
+test_and_change_bit(unsigned long bit, volatile unsigned long *ptr)
+{
+	unsigned long v;
+
+	do v = *ptr; while (atomic_cas_ulong(ptr, v, v ^ (1  bit)) != v);
+
+	return (v  (1  bit));
+}
+
 #endif  /* _LINUX_ATOMIC_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:10:15 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: mutex.h

Log Message:
Define linux_mutex_init in linux/mutex.h to make its uses greppable.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \
src/sys/external/bsd/drm2/include/linux/mutex.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/mutex.h
diff -u src/sys/external/bsd/drm2/include/linux/mutex.h:1.1.2.3 src/sys/external/bsd/drm2/include/linux/mutex.h:1.1.2.4
--- src/sys/external/bsd/drm2/include/linux/mutex.h:1.1.2.3	Wed Jul 24 01:57:20 2013
+++ src/sys/external/bsd/drm2/include/linux/mutex.h	Wed Jul 24 02:10:15 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: mutex.h,v 1.1.2.3 2013/07/24 01:57:20 riastradh Exp $	*/
+/*	$NetBSD: mutex.h,v 1.1.2.4 2013/07/24 02:10:15 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,6 +38,13 @@ struct mutex {
 	kmutex_t mtx_lock;
 };
 
+/* Name collision.  Pooh.  */
+static inline void
+linux_mutex_init(struct mutex *mutex)
+{
+	mutex_init(mutex-mtx_lock, MUTEX_DEFAULT, IPL_NONE);
+}
+
 static inline void
 mutex_lock(struct mutex *mutex)
 {



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:09:43 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: workqueue.h

Log Message:
Fix signature of INIT_DELAYED_WORK.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \
src/sys/external/bsd/drm2/include/linux/workqueue.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/workqueue.h
diff -u src/sys/external/bsd/drm2/include/linux/workqueue.h:1.1.2.3 src/sys/external/bsd/drm2/include/linux/workqueue.h:1.1.2.4
--- src/sys/external/bsd/drm2/include/linux/workqueue.h:1.1.2.3	Wed Jul 24 01:53:40 2013
+++ src/sys/external/bsd/drm2/include/linux/workqueue.h	Wed Jul 24 02:09:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: workqueue.h,v 1.1.2.3 2013/07/24 01:53:40 riastradh Exp $	*/
+/*	$NetBSD: workqueue.h,v 1.1.2.4 2013/07/24 02:09:43 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -51,7 +51,7 @@ struct delayed_work {
 };
 
 static inline void
-INIT_DELAYED_WORK(struct delayed_work *dw, void (*fn)(struct delayed_work *))
+INIT_DELAYED_WORK(struct delayed_work *dw, void (*fn)(struct work_struct *))
 {
 
 	callout_init(dw-dw_work.ws_callout, 0);



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:09:59 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: spinlock.h

Log Message:
It's spin_unlock_irqrestore, not spin_lock_irqrestore.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/sys/external/bsd/drm2/include/linux/spinlock.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/spinlock.h
diff -u src/sys/external/bsd/drm2/include/linux/spinlock.h:1.1.2.2 src/sys/external/bsd/drm2/include/linux/spinlock.h:1.1.2.3
--- src/sys/external/bsd/drm2/include/linux/spinlock.h:1.1.2.2	Wed Jul 24 00:49:19 2013
+++ src/sys/external/bsd/drm2/include/linux/spinlock.h	Wed Jul 24 02:09:58 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: spinlock.h,v 1.1.2.2 2013/07/24 00:49:19 riastradh Exp $	*/
+/*	$NetBSD: spinlock.h,v 1.1.2.3 2013/07/24 02:09:58 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@ spin_unlock(spinlock_t *spinlock)
 	} while (0)
 
 static inline void
-spin_lock_irqrestore(spinlock_t *spinlock, unsigned long __unused flags)
+spin_unlock_irqrestore(spinlock_t *spinlock, unsigned long __unused flags)
 {
 	mutex_exit(spinlock-sl_lock);
 }



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:10:45 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: module.h

Log Message:
Define empty module_init and module_exit stubs in linux/module.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/linux/module.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/module.h
diff -u src/sys/external/bsd/drm2/include/linux/module.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/module.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/module.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/module.h	Wed Jul 24 02:10:45 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: module.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $	*/
+/*	$NetBSD: module.h,v 1.1.2.2 2013/07/24 02:10:45 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,7 @@
 #ifndef _LINUX_MODULE_H_
 #define _LINUX_MODULE_H_
 
+#define	module_init(INIT)
+#define	module_exit(EXIT)
+
 #endif  /* _LINUX_MODULE_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:10:30 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: moduleparam.h

Log Message:
Define empty module_param_named stub in linux/moduleparam.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/linux/moduleparam.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/moduleparam.h
diff -u src/sys/external/bsd/drm2/include/linux/moduleparam.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/moduleparam.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/moduleparam.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/moduleparam.h	Wed Jul 24 02:10:30 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: moduleparam.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $	*/
+/*	$NetBSD: moduleparam.h,v 1.1.2.2 2013/07/24 02:10:30 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,6 @@
 #ifndef _LINUX_MODULEPARAM_H_
 #define _LINUX_MODULEPARAM_H_
 
+#define	module_param_named(NAME, VAR, TYPE, MODE)
+
 #endif  /* _LINUX_MODULEPARAM_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:12:00 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: kernel.h

Log Message:
Add WARN and WARN_ON to linux/kernel.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.5 -r1.1.2.6 \
src/sys/external/bsd/drm2/include/linux/kernel.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/kernel.h
diff -u src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.5 src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.6
--- src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.5	Wed Jul 24 01:52:08 2013
+++ src/sys/external/bsd/drm2/include/linux/kernel.h	Wed Jul 24 02:12:00 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernel.h,v 1.1.2.5 2013/07/24 01:52:08 riastradh Exp $	*/
+/*	$NetBSD: kernel.h,v 1.1.2.6 2013/07/24 02:12:00 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -41,4 +41,16 @@
 #define	container_of(PTR, TYPE, FIELD)	\
 	((TYPE *)(((char *)(PTR)) - offsetof(TYPE, FIELD)))
 
+#define	ARRAY_SIZE(ARRAY)	__arraycount(ARRAY)
+
+/* XXX Rate limit?  */
+#define WARN(CONDITION, FMT, ...)	do\
+{	\
+	if (CONDITION)			\
+		printf(warning: %s:%d:  FMT, __FILE__, __LINE__,	\
+		##__VA_ARGS__);	\
+} while (0)
+
+#define	WARN_ON(CONDITION)	WARN(CONDITION, %s\n, #CONDITION)
+
 #endif  /* _LINUX_KERNEL_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/asm

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:12:14 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/asm [riastradh-drm2]: uaccess.h

Log Message:
Add hokey (but typeof-free) get_user and put_user to asm/uaccess.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \
src/sys/external/bsd/drm2/include/asm/uaccess.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/asm/uaccess.h
diff -u src/sys/external/bsd/drm2/include/asm/uaccess.h:1.1.2.3 src/sys/external/bsd/drm2/include/asm/uaccess.h:1.1.2.4
--- src/sys/external/bsd/drm2/include/asm/uaccess.h:1.1.2.3	Wed Jul 24 02:04:16 2013
+++ src/sys/external/bsd/drm2/include/asm/uaccess.h	Wed Jul 24 02:12:14 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: uaccess.h,v 1.1.2.3 2013/07/24 02:04:16 riastradh Exp $	*/
+/*	$NetBSD: uaccess.h,v 1.1.2.4 2013/07/24 02:12:14 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -49,5 +49,10 @@ copy_to_user(void *user_addr, const void
 	return -copyout(kernel_addr, user_addr, len);
 }
 
+#define	get_user(KERNEL_LOC, USER_ADDR)	\
+	copy_from_user((KERNEL_LOC), (USER_ADDR), sizeof(KERNEL_LOC))
+
+#define	put_user(KERNEL_LOC, USER_ADDR)	\
+	copy_to_user((USER_ADDR), (KERNEL_LOC), sizeof(KERNEL_LOC))
 
 #endif  /* _ASM_UACCESS_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:11:38 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: list.h

Log Message:
Fix some typos and add some stuff to linux/list.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.5 -r1.1.2.6 \
src/sys/external/bsd/drm2/include/linux/list.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/list.h
diff -u src/sys/external/bsd/drm2/include/linux/list.h:1.1.2.5 src/sys/external/bsd/drm2/include/linux/list.h:1.1.2.6
--- src/sys/external/bsd/drm2/include/linux/list.h:1.1.2.5	Wed Jul 24 02:02:32 2013
+++ src/sys/external/bsd/drm2/include/linux/list.h	Wed Jul 24 02:11:38 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: list.h,v 1.1.2.5 2013/07/24 02:02:32 riastradh Exp $	*/
+/*	$NetBSD: list.h,v 1.1.2.6 2013/07/24 02:11:38 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -46,6 +46,8 @@ struct list_head {
 	struct list_head *lh_next;
 };
 
+#define	LIST_HEAD_INIT(name)	{ .lh_prev = (name), .lh_next = (name) }
+
 static inline void
 INIT_LIST_HEAD(struct list_head *head)
 {
@@ -54,43 +56,43 @@ INIT_LIST_HEAD(struct list_head *head)
 }
 
 static inline struct list_head *
-list_first(struct list_head *head)
+list_first(const struct list_head *head)
 {
 	return head-lh_next;
 }
 
 static inline struct list_head *
-list_next(struct list_head *node)
+list_next(const struct list_head *node)
 {
 	return node-lh_next;
 }
 
 static inline int
-list_empty(struct list_head *head)
+list_empty(const struct list_head *head)
 {
 	return (head-lh_next == head);
 }
 
 static inline void
-list_add(struct list_head *new, struct list_head *head)
+__list_add_between(struct list_head *prev, struct list_head *node,
+struct list_head *next)
 {
-	struct list_head *const next = head-lh_next;
-
-	head-lh_next = new;
-	new-lh_prev = head;
-	new-lh_next = next;
-	next-lh_prev = new;
+	prev-lh_next = node;
+	node-lh_prev = prev;
+	node-lh_next = next;
+	next-lh_prev = node;
 }
 
 static inline void
-list_add_tail(struct list_head *new, struct list_head *head)
+list_add(struct list_head *node, struct list_head *head)
 {
-	struct list_head *const prev = head-lh_prev;
+	__list_add_between(head, node, head-lh_next);
+}
 
-	head-lh_prev = new;
-	new-lh_prev = prev;
-	new-lh_next = head;
-	prev-lh_next = new;
+static inline void
+list_add_tail(struct list_head *node, struct list_head *head)
+{
+	__list_add_between(head-lh_prev, node, head);
 }
 
 static inline void
@@ -100,12 +102,47 @@ list_del(struct list_head *entry)
 	entry-lh_next-lh_prev = entry-lh_prev;
 }
 
+static inline void
+__list_splice_between(struct list_head *prev, const struct list_head *list,
+struct list_head *next)
+{
+	struct list_head *first = list-lh_next;
+	struct list_head *last = list-lh_prev;
+
+	first-lh_prev = prev;
+	prev-lh_next = first;
+
+	last-lh_next = next;
+	next-lh_prev = last;
+}
+
+static inline void
+list_splice(const struct list_head *list, struct list_head *head)
+{
+	if (!list_empty(list))
+		__list_splice_between(head, list, head-lh_next);
+}
+
+static inline void
+list_splice_tail(const struct list_head *list, struct list_head *head)
+{
+	if (!list_empty(list))
+		__list_splice_between(head-lh_prev, list, head);
+}
+
+static inline void
+list_move_tail(struct list_head *node, struct list_head *head)
+{
+	list_del(node);
+	list_add_tail(node, head);
+}
+
 #define	list_entry(PTR, TYPE, FIELD)	container_of(PTR, TYPE, FIELD)
 
 #define	list_for_each(VAR, HEAD)	\
 	for ((VAR) = list_first((HEAD));\
 		(VAR) != (HEAD);	\
-		(VAR) = list_next((VAR))
+		(VAR) = list_next((VAR)))
 
 #define	list_for_each_safe(VAR, NEXT, HEAD)\
 	for ((VAR) = list_first((HEAD));\



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:12:29 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: types.h

Log Message:
Add __le16, __le32, and __le64 to linux/types.h.

As far as I'm aware, these aliases are correct, and the type doesn't
actually have any effect on the byte order of reads and writes.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.5 -r1.1.2.6 \
src/sys/external/bsd/drm2/include/linux/types.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/types.h
diff -u src/sys/external/bsd/drm2/include/linux/types.h:1.1.2.5 src/sys/external/bsd/drm2/include/linux/types.h:1.1.2.6
--- src/sys/external/bsd/drm2/include/linux/types.h:1.1.2.5	Wed Jul 24 01:54:19 2013
+++ src/sys/external/bsd/drm2/include/linux/types.h	Wed Jul 24 02:12:29 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: types.h,v 1.1.2.5 2013/07/24 01:54:19 riastradh Exp $	*/
+/*	$NetBSD: types.h,v 1.1.2.6 2013/07/24 02:12:29 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -39,11 +39,16 @@ typedef uint8_t u8;
 typedef uint16_t u16;
 typedef uint32_t u32;
 typedef uint64_t u64;
+
 typedef int8_t s8;
 typedef int16_t s16;
 typedef int32_t s32;
 typedef int64_t s64;
 
+typedef uint16_t __le16;
+typedef uint32_t __le32;
+typedef uint64_t __le64;
+
 typedef bus_size_t resource_size_t;
 
 /* XXX Is this the right type?  */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:14:10 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: kernel.h

Log Message:
Define swap in linux/kernel.h.

Kinda hokey definition, but this avoids typeof.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.6 -r1.1.2.7 \
src/sys/external/bsd/drm2/include/linux/kernel.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/kernel.h
diff -u src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.6 src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.7
--- src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.6	Wed Jul 24 02:12:00 2013
+++ src/sys/external/bsd/drm2/include/linux/kernel.h	Wed Jul 24 02:14:10 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernel.h,v 1.1.2.6 2013/07/24 02:12:00 riastradh Exp $	*/
+/*	$NetBSD: kernel.h,v 1.1.2.7 2013/07/24 02:14:10 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -53,4 +53,17 @@
 
 #define	WARN_ON(CONDITION)	WARN(CONDITION, %s\n, #CONDITION)
 
+#define	swap(X, Y)	do		\
+{	\
+	/* XXX Kludge for type-safety.  */\
+	if ((X) != (Y)) {		\
+		CTASSERT(sizeof(X) == sizeof(Y));			\
+		/* XXX Can't do this much better without typeof.  */	\
+		char __swap_tmp[sizeof(X)];\
+		(void)memcpy(__swap_tmp, (X), sizeof(X));		\
+		(void)memcpy((X), (Y), sizeof(X));			\
+		(void)memcpy((Y), __swap_tmp, sizeof(X));		\
+	}\
+} while (0)
+
 #endif  /* _LINUX_KERNEL_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/asm

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:15:53 UTC 2013

Added Files:
src/sys/external/bsd/drm2/include/asm [riastradh-drm2]: param.h

Log Message:
Add Linuxoid asm/param.h with hokey HZ.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.2.1 src/sys/external/bsd/drm2/include/asm/param.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/sys/external/bsd/drm2/include/asm/param.h
diff -u /dev/null src/sys/external/bsd/drm2/include/asm/param.h:1.1.2.1
--- /dev/null	Wed Jul 24 02:15:53 2013
+++ src/sys/external/bsd/drm2/include/asm/param.h	Wed Jul 24 02:15:53 2013
@@ -0,0 +1,41 @@
+/*	$NetBSD: param.h,v 1.1.2.1 2013/07/24 02:15:53 riastradh Exp $	*/
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#ifndef _ASM_PARAM_H_
+#define _ASM_PARAM_H_
+
+#include sys/param.h
+#include sys/kernel.h
+
+/* XXX Urk...  */
+#define	HZ	hz
+
+#endif  /* _ASM_PARAM_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:20:09 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: spinlock.h

Log Message:
Define spin_is_locked in linux/spinlock.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \
src/sys/external/bsd/drm2/include/linux/spinlock.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/spinlock.h
diff -u src/sys/external/bsd/drm2/include/linux/spinlock.h:1.1.2.3 src/sys/external/bsd/drm2/include/linux/spinlock.h:1.1.2.4
--- src/sys/external/bsd/drm2/include/linux/spinlock.h:1.1.2.3	Wed Jul 24 02:09:58 2013
+++ src/sys/external/bsd/drm2/include/linux/spinlock.h	Wed Jul 24 02:20:09 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: spinlock.h,v 1.1.2.3 2013/07/24 02:09:58 riastradh Exp $	*/
+/*	$NetBSD: spinlock.h,v 1.1.2.4 2013/07/24 02:20:09 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -39,6 +39,12 @@ typedef struct {
 	kmutex_t sl_lock;
 } spinlock_t;
 
+static inline int
+spin_is_locked(spinlock_t *spinlock)
+{
+	return mutex_owned(spinlock-sl_lock);
+}
+
 static inline void
 spin_lock(spinlock_t *spinlock)
 {



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:20:24 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: list.h

Log Message:
Define list_first_entry in linux/list.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.6 -r1.1.2.7 \
src/sys/external/bsd/drm2/include/linux/list.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/list.h
diff -u src/sys/external/bsd/drm2/include/linux/list.h:1.1.2.6 src/sys/external/bsd/drm2/include/linux/list.h:1.1.2.7
--- src/sys/external/bsd/drm2/include/linux/list.h:1.1.2.6	Wed Jul 24 02:11:38 2013
+++ src/sys/external/bsd/drm2/include/linux/list.h	Wed Jul 24 02:20:24 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: list.h,v 1.1.2.6 2013/07/24 02:11:38 riastradh Exp $	*/
+/*	$NetBSD: list.h,v 1.1.2.7 2013/07/24 02:20:24 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -138,6 +138,8 @@ list_move_tail(struct list_head *node, s
 }
 
 #define	list_entry(PTR, TYPE, FIELD)	container_of(PTR, TYPE, FIELD)
+#define	list_first_entry(PTR, TYPE, FIELD)\
+	list_entry(list_first((PTR)), TYPE, FIELD)
 
 #define	list_for_each(VAR, HEAD)	\
 	for ((VAR) = list_first((HEAD));\



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/drm

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:20:38 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/drm [riastradh-drm2]:
drm_wait_netbsd.h

Log Message:
Add variants of drm wait/wakeup for spin locks in drm_wait_netbsd.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h
diff -u src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.1.2.2 src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.1.2.3
--- src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.1.2.2	Wed Jul 24 02:03:16 2013
+++ src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h	Wed Jul 24 02:20:38 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_wait_netbsd.h,v 1.1.2.2 2013/07/24 02:03:16 riastradh Exp $	*/
+/*	$NetBSD: drm_wait_netbsd.h,v 1.1.2.3 2013/07/24 02:20:38 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -37,9 +37,9 @@
 #include sys/systm.h
 
 #include linux/mutex.h
+#include linux/spinlock.h
 
 typedef kcondvar_t drm_waitqueue_t;
-typedef struct mutex drm_interlock_t; /* XXX urk */
 
 static inline void
 DRM_INIT_WAITQUEUE(drm_waitqueue_t *q, const char *name)
@@ -48,24 +48,74 @@ DRM_INIT_WAITQUEUE(drm_waitqueue_t *q, c
 }
 
 static inline void
-DRM_WAKEUP_ONE(drm_waitqueue_t *q, drm_interlock_t *interlock)
+DRM_WAKEUP_ONE(drm_waitqueue_t *q, struct mutex *interlock)
 {
-	KASSERT(mutex_owned(interlock-mtx_lock));
+	KASSERT(mutex_is_locked(interlock));
 	cv_signal(q);
 }
 
 static inline void
-DRM_WAKEUP_ALL(drm_waitqueue_t *q, drm_interlock_t *interlock)
+DRM_WAKEUP_ALL(drm_waitqueue_t *q, struct mutex *interlock)
 {
-	KASSERT(mutex_owned(interlock-mtx_lock));
+	KASSERT(mutex_is_locked(interlock));
 	cv_broadcast(q);
 }
 
-#define	DRM_WAIT_ON(RET, Q, INTERLOCK, TICKS, CONDITION) do		\
+static inline void
+DRM_SPIN_WAKEUP_ONE(drm_waitqueue_t *q, spinlock_t *interlock)
+{
+	KASSERT(spin_is_locked(interlock));
+	cv_signal(q);
+}
+
+static inline void
+DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, spinlock_t *interlock)
+{
+	KASSERT(spin_is_locked(interlock));
+	cv_broadcast(q);
+}
+
+#define	DRM_WAIT_UNTIL(RET, Q, INTERLOCK, CONDITION)	do		\
+{	\
+	KASSERT(mutex_is_locked((INTERLOCK)));\
+	while (!(CONDITION)) {		\
+		/* XXX errno NetBSD-Linux */\
+		(RET) = -cv_wait_sig((Q), (INTERLOCK)-mtx_lock);	\
+		if (RET)		\
+			break;		\
+	}\
+} while (0)
+
+#define	DRM_TIMED_WAIT_UNTIL(RET, Q, INTERLOCK, TICKS, CONDITION) do	\
+{	\
+	KASSERT(mutex_is_locked((INTERLOCK)));\
+	while (!(CONDITION)) {		\
+		/* XXX errno NetBSD-Linux */\
+		(RET) = -cv_timedwait_sig((Q), (INTERLOCK)-mtx_lock,	\
+		(TICKS));		\
+		if (RET)		\
+			break;		\
+	}\
+} while (0)
+
+#define	DRM_SPIN_WAIT_UNTIL(RET, Q, INTERLOCK, CONDITION)	do	\
+{	\
+	KASSERT(spin_is_locked((INTERLOCK)));\
+	while (!(CONDITION)) {		\
+		/* XXX errno NetBSD-Linux */\
+		(RET) = -cv_wait_sig((Q), (INTERLOCK)-sl_lock);	\
+		if (RET)		\
+			break;		\
+	}\
+} while (0)
+
+#define	DRM_SPIN_TIMED_WAIT_UNTIL(RET, Q, INTERLOCK, TICKS, CONDITION)	\
+	do\
 {	\
-	KASSERT(mutex_owned((INTERLOCK)-mtx_lock));			\
+	KASSERT(spin_is_locked((INTERLOCK)));\
 	while (!(CONDITION)) {		\
-		(RET) = cv_timedwait_sig((Q), (INTERLOCK)-mtx_lock,	\
+		/* XXX errno NetBSD-Linux */\
+		(RET) = -cv_timedwait_sig((Q), (INTERLOCK)-sl_lock,	\
 		(TICKS));		\
 		if (RET)		\
 			break;		\



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:21:43 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: kernel.h
Added Files:
src/sys/external/bsd/drm2/include/asm [riastradh-drm2]: bug.h

Log Message:
Move WARN and WARN_ON to asm/bug.h and add BUG_ON.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.2.1 src/sys/external/bsd/drm2/include/asm/bug.h
cvs rdiff -u -r1.1.2.7 -r1.1.2.8 \
src/sys/external/bsd/drm2/include/linux/kernel.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/kernel.h
diff -u src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.7 src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.8
--- src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.7	Wed Jul 24 02:14:10 2013
+++ src/sys/external/bsd/drm2/include/linux/kernel.h	Wed Jul 24 02:21:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernel.h,v 1.1.2.7 2013/07/24 02:14:10 riastradh Exp $	*/
+/*	$NetBSD: kernel.h,v 1.1.2.8 2013/07/24 02:21:43 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -43,16 +43,6 @@
 
 #define	ARRAY_SIZE(ARRAY)	__arraycount(ARRAY)
 
-/* XXX Rate limit?  */
-#define WARN(CONDITION, FMT, ...)	do\
-{	\
-	if (CONDITION)			\
-		printf(warning: %s:%d:  FMT, __FILE__, __LINE__,	\
-		##__VA_ARGS__);	\
-} while (0)
-
-#define	WARN_ON(CONDITION)	WARN(CONDITION, %s\n, #CONDITION)
-
 #define	swap(X, Y)	do		\
 {	\
 	/* XXX Kludge for type-safety.  */\

Added files:

Index: src/sys/external/bsd/drm2/include/asm/bug.h
diff -u /dev/null src/sys/external/bsd/drm2/include/asm/bug.h:1.1.2.1
--- /dev/null	Wed Jul 24 02:21:43 2013
+++ src/sys/external/bsd/drm2/include/asm/bug.h	Wed Jul 24 02:21:43 2013
@@ -0,0 +1,50 @@
+/*	$NetBSD: bug.h,v 1.1.2.1 2013/07/24 02:21:43 riastradh Exp $	*/
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#ifndef _ASM_BUG_H_
+#define _ASM_BUG_H_
+
+#include sys/cdefs.h
+#include sys/systm.h
+
+#define	BUG_ON(CONDITION)	KASSERT(!(CONDITION))
+
+/* XXX Rate limit?  */
+#define WARN(CONDITION, FMT, ...)	do\
+{	\
+	if (CONDITION)			\
+		printf(warning: %s:%d:  FMT, __FILE__, __LINE__,	\
+		##__VA_ARGS__);	\
+} while (0)
+
+#define	WARN_ON(CONDITION)	WARN(CONDITION, %s\n, #CONDITION)
+
+#endif  /* _LINUX_KERNEL_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:23:48 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: err.h

Log Message:
Avoid INT_MAX in PTR_ERR; check for truncation instead.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/linux/err.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/err.h
diff -u src/sys/external/bsd/drm2/include/linux/err.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/err.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/err.h:1.1.2.1	Wed Jul 24 02:07:31 2013
+++ src/sys/external/bsd/drm2/include/linux/err.h	Wed Jul 24 02:23:48 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: err.h,v 1.1.2.1 2013/07/24 02:07:31 riastradh Exp $	*/
+/*	$NetBSD: err.h,v 1.1.2.2 2013/07/24 02:23:48 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@ ERR_PTR(int error)
 static inline int
 PTR_ERR(const void *ptr)
 {
-	KASSERT((intptr_t)INT_MAX = (intptr_t)ptr);
+	KASSERT(ptr == (void *)(intptr_t)(int)(intptr_t)ptr); /* XXX Hurk!  */
 	return (int)(intptr_t)ptr;
 }
 



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:24:02 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: hash.h

Log Message:
Implement hash_long in linux/hash.h.

Uses the same hash function as in Linux, implemented differently.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/sys/external/bsd/drm2/include/linux/hash.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/hash.h
diff -u src/sys/external/bsd/drm2/include/linux/hash.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/hash.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/hash.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/hash.h	Wed Jul 24 02:24:02 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: hash.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $	*/
+/*	$NetBSD: hash.h,v 1.1.2.2 2013/07/24 02:24:02 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,15 @@
 #ifndef _LINUX_HASH_H_
 #define _LINUX_HASH_H_
 
+#include machine/limits.h
+
+static inline unsigned long
+hash_long(unsigned long value, unsigned int bits)
+{
+	const unsigned long factor = (sizeof(factor)  4?
+	0x9e37fffc0001ull : 0x9e370001ul);
+
+	return ((value * factor)  ((CHAR_BIT * sizeof(value)) - bits));
+}
+
 #endif  /* _LINUX_HASH_H_ */



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:24:16 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: kernel.h

Log Message:
Implement unlikely as __predict_false in linux/kernel.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.8 -r1.1.2.9 \
src/sys/external/bsd/drm2/include/linux/kernel.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/kernel.h
diff -u src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.8 src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.9
--- src/sys/external/bsd/drm2/include/linux/kernel.h:1.1.2.8	Wed Jul 24 02:21:43 2013
+++ src/sys/external/bsd/drm2/include/linux/kernel.h	Wed Jul 24 02:24:16 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernel.h,v 1.1.2.8 2013/07/24 02:21:43 riastradh Exp $	*/
+/*	$NetBSD: kernel.h,v 1.1.2.9 2013/07/24 02:24:16 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,6 +38,8 @@
 #define	__printf	__printflike
 #define	__user
 
+#define	unlikely(X)	__predict_false(X)
+
 #define	container_of(PTR, TYPE, FIELD)	\
 	((TYPE *)(((char *)(PTR)) - offsetof(TYPE, FIELD)))
 



CVS commit: [riastradh-drm2] src/sys/external/bsd/drm2/include/linux

2013-07-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul 24 02:25:12 UTC 2013

Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: vmalloc.h

Log Message:
Add vzalloc to linux/vmalloc.h.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/sys/external/bsd/drm2/include/linux/vmalloc.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/vmalloc.h
diff -u src/sys/external/bsd/drm2/include/linux/vmalloc.h:1.1.2.2 src/sys/external/bsd/drm2/include/linux/vmalloc.h:1.1.2.3
--- src/sys/external/bsd/drm2/include/linux/vmalloc.h:1.1.2.2	Wed Jul 24 02:02:45 2013
+++ src/sys/external/bsd/drm2/include/linux/vmalloc.h	Wed Jul 24 02:25:12 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmalloc.h,v 1.1.2.2 2013/07/24 02:02:45 riastradh Exp $	*/
+/*	$NetBSD: vmalloc.h,v 1.1.2.3 2013/07/24 02:25:12 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -40,6 +40,12 @@ vmalloc_user(unsigned long size)
 	return malloc(size, M_TEMP, (M_WAITOK | M_ZERO));
 }
 
+static inline void *
+vzalloc(unsigned long size)
+{
+	return malloc(size, M_TEMP, (M_WAITOK | M_ZERO));
+}
+
 static inline void
 vfree(void *ptr)
 {



  1   2   3   >