CVS commit: src/sys/external/bsd/drm2/include/drm

2020-02-20 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Feb 20 09:07:39 UTC 2020

Modified Files:
src/sys/external/bsd/drm2/include/drm: bus_dma_hacks.h

Log Message:
in bus_dmamap_load_pglist() try a 32-element array of
bus_dma_segment_t's before attempting to allocate.

this hopefully avoids hangs i've had in X since updating
from netbsd-8 to netbsd-9 that i've tracked down to this
function failing with ENOMEM.

XXX: maybe can avoid the alloc entirely by batching these
calls in 32 segments each.

XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 \
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.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h
diff -u src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.19 src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.20
--- src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.19	Wed Jan 22 07:53:45 2020
+++ src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h	Thu Feb 20 09:07:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_dma_hacks.h,v 1.19 2020/01/22 07:53:45 jmcneill Exp $	*/
+/*	$NetBSD: bus_dma_hacks.h,v 1.20 2020/02/20 09:07:39 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -118,12 +118,15 @@ bus_dmatag_bounces_paddr(bus_dma_tag_t d
 #endif
 }
 
+#define MAX_STACK_SEGS 32	/* XXXMRG: 512 bytes on 16 byte seg platforms */
+
 static inline int
 bus_dmamap_load_pglist(bus_dma_tag_t tag, bus_dmamap_t map,
 struct pglist *pglist, bus_size_t size, int flags)
 {
 	km_flag_t kmflags;
 	bus_dma_segment_t *segs;
+	bus_dma_segment_t stacksegs[MAX_STACK_SEGS];
 	int nsegs, seg;
 	struct vm_page *page;
 	int error;
@@ -136,14 +139,23 @@ bus_dmamap_load_pglist(bus_dma_tag_t tag
 	}
 
 	KASSERT(nsegs <= (SIZE_MAX / sizeof(segs[0])));
-	switch (flags & (BUS_DMA_WAITOK|BUS_DMA_NOWAIT)) {
-	case BUS_DMA_WAITOK:	kmflags = KM_SLEEP;	break;
-	case BUS_DMA_NOWAIT:	kmflags = KM_NOSLEEP;	break;
-	default:		panic("invalid flags: %d", flags);
-	}
-	segs = kmem_alloc((nsegs * sizeof(segs[0])), kmflags);
-	if (segs == NULL)
-		return ENOMEM;
+	if (nsegs > MAX_STACK_SEGS) {
+		switch (flags & (BUS_DMA_WAITOK|BUS_DMA_NOWAIT)) {
+		case BUS_DMA_WAITOK:
+			kmflags = KM_SLEEP;
+			break;
+		case BUS_DMA_NOWAIT:
+			kmflags = KM_NOSLEEP;
+			break;
+		default:
+			panic("invalid flags: %d", flags);
+		}
+		segs = kmem_alloc((nsegs * sizeof(segs[0])), kmflags);
+		if (segs == NULL)
+			return ENOMEM;
+	} else {
+		segs = stacksegs;
+	}
 
 	seg = 0;
 	TAILQ_FOREACH(page, pglist, pageq.queue) {
@@ -166,7 +178,10 @@ bus_dmamap_load_pglist(bus_dma_tag_t tag
 fail1: __unused
 	bus_dmamap_unload(tag, map);
 fail0:	KASSERT(error);
-out:	kmem_free(segs, (nsegs * sizeof(segs[0])));
+out:	if (segs != stacksegs) {
+		KASSERT(nsegs > MAX_STACK_SEGS);
+		kmem_free(segs, (nsegs * sizeof(segs[0])));
+	}
 	return error;
 }
 



CVS commit: src/sys/external/bsd/drm2/include/drm

2020-01-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jan 22 07:53:45 UTC 2020

Modified Files:
src/sys/external/bsd/drm2/include/drm: bus_dma_hacks.h

Log Message:
Fix PHYS_TO_BUS_MEM and BUS_MEM_TO_PHYS on arm and aarch64


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 \
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.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h
diff -u src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.18 src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.19
--- src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.18	Tue Nov  5 23:27:23 2019
+++ src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h	Wed Jan 22 07:53:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_dma_hacks.h,v 1.18 2019/11/05 23:27:23 jmcneill Exp $	*/
+/*	$NetBSD: bus_dma_hacks.h,v 1.19 2020/01/22 07:53:45 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@ PHYS_TO_BUS_MEM(bus_dma_tag_t dmat, padd
 		const struct arm32_dma_range *dr = >_ranges[i];
 
 		if (dr->dr_sysbase <= pa && pa - dr->dr_sysbase <= dr->dr_len)
-			return dr->dr_busbase + (dr->dr_sysbase - pa);
+			return pa - dr->dr_sysbase + dr->dr_busbase;
 	}
 	panic("paddr has no bus address in dma tag %p: %"PRIxPADDR, dmat, pa);
 }
@@ -74,7 +74,7 @@ BUS_MEM_TO_PHYS(bus_dma_tag_t dmat, bus_
 		const struct arm32_dma_range *dr = >_ranges[i];
 
 		if (dr->dr_busbase <= ba && ba - dr->dr_busbase <= dr->dr_len)
-			return dr->dr_sysbase + (dr->dr_busbase - ba);
+			return ba - dr->dr_busbase + dr->dr_sysbase;
 	}
 	panic("bus addr has no bus address in dma tag %p: %"PRIxPADDR, dmat,
 	ba);



CVS commit: src/sys/external/bsd/drm2/include/drm

2019-04-07 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sun Apr  7 20:28:41 UTC 2019

Modified Files:
src/sys/external/bsd/drm2/include/drm: drm_os_netbsd.h
Removed Files:
src/sys/external/bsd/drm2/include/drm: drm_copy_netbsd.h

Log Message:
Remove unused definitions.

(These appear to have existed in old-drm)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r0 \
src/sys/external/bsd/drm2/include/drm/drm_copy_netbsd.h
cvs rdiff -u -r1.13 -r1.14 \
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.13 src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.14
--- src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.13	Tue Aug 28 03:41:39 2018
+++ src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h	Sun Apr  7 20:28:41 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_os_netbsd.h,v 1.13 2018/08/28 03:41:39 riastradh Exp $	*/
+/*	$NetBSD: drm_os_netbsd.h,v 1.14 2019/04/07 20:28:41 maya Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -69,7 +69,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 



CVS commit: src/sys/external/bsd/drm2/include/drm

2018-08-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 27 16:20:35 UTC 2018

Modified Files:
src/sys/external/bsd/drm2/include/drm: drm_os_netbsd.h

Log Message:
Ifdef out pnpbios for now.  Presumably needs to use bus_space_alloc.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 \
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.11 src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.12
--- src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.11	Mon Aug 27 15:12:09 2018
+++ src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h	Mon Aug 27 16:20:35 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_os_netbsd.h,v 1.11 2018/08/27 15:12:09 riastradh Exp $	*/
+/*	$NetBSD: drm_os_netbsd.h,v 1.12 2018/08/27 16:20:35 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -49,6 +49,7 @@
 #define	CONFIG_PCI	1
 #endif
 
+#ifdef notyet
 #if defined(__i386__)
 #include "pnpbios.h"
 #endif
@@ -56,6 +57,7 @@
 #if NPNPBIOS > 0
 #define CONFIG_PNP
 #endif
+#endif
 
 #if defined(__i386__) || defined(__x86_64__)
 #if defined(_KERNEL_OPT)



CVS commit: src/sys/external/bsd/drm2/include/drm

2018-08-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 27 15:32:20 UTC 2018

Modified Files:
src/sys/external/bsd/drm2/include/drm: bus_dma_hacks.h

Log Message:
Implement BUS_DMA_TO_PHYS/PHYS_TO_BUS_DMA on arm respecting ranges.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 \
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.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h
diff -u src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.15 src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.16
--- src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.15	Mon Aug 27 15:29:31 2018
+++ src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h	Mon Aug 27 15:32:20 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_dma_hacks.h,v 1.15 2018/08/27 15:29:31 riastradh Exp $	*/
+/*	$NetBSD: bus_dma_hacks.h,v 1.16 2018/08/27 15:32:20 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -46,8 +46,33 @@
 #  define	PHYS_TO_BUS_MEM(dmat, paddr)	((bus_addr_t)(paddr))
 #  define	BUS_MEM_TO_PHYS(dmat, baddr)	((paddr_t)(baddr))
 #elif defined(__arm__) || defined(__aarch64__)
-#  define	PHYS_TO_BUS_MEM(dmat, paddr)	((bus_addr_t)(paddr))
-#  define	BUS_MEM_TO_PHYS(dmat, baddr)	((paddr_t)(baddr))
+static inline bus_addr_t
+PHYS_TO_BUS_MEM(bus_dma_tag_t dmat, paddr_t pa)
+{
+	unsigned i;
+
+	for (i = 0; i < dmat->_nranges; i++) {
+		const struct arm32_dma_range *dr = >_ranges[i];
+
+		if (dr->dr_sysbase <= pa && pa - dr->dr_sysbase <= dr->dr_len)
+			return dr->dr_busbase + (dr->dr_sysbase - pa);
+	}
+	panic("paddr has no bus address in dma tag %p: %"PRIxPADDR, dmat, pa);
+}
+static inline paddr_t
+BUS_MEM_TO_PHYS(bus_dma_tag_t dmat, bus_addr_t ba)
+{
+	unsigned i;
+
+	for (i = 0; i < dmat->_nranges; i++) {
+		const struct arm32_dma_range *dr = >_ranges[i];
+
+		if (dr->dr_busbase <= ba && ba - dr->dr_busbase <= dr->dr_len)
+			return dr->dr_sysbase + (dr->dr_busbase - ba);
+	}
+	panic("bus addr has no bus address in dma tag %p: %"PRIxPADDR, dmat,
+	ba);
+}
 #elif defined(__sparc__) || defined(__sparc64__)
 #  define	PHYS_TO_BUS_MEM(dmat, paddr)	((bus_addr_t)(paddr))
 #  define	BUS_MEM_TO_PHYS(dmat, baddr)	((paddr_t)(baddr))



CVS commit: src/sys/external/bsd/drm2/include/drm

2018-08-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 27 15:29:08 UTC 2018

Modified Files:
src/sys/external/bsd/drm2/include/drm: bus_dma_hacks.h

Log Message:
sparc seems to treat bus/phys addrs in bus dmamem the same.

This is just about bus dmamem -- not about bus dmamap, which rightly
uses an iommu to remap things and which we don't interfere with.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 \
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.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h
diff -u src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.13 src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.14
--- src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.13	Mon Aug 27 15:27:28 2018
+++ src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h	Mon Aug 27 15:29:08 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_dma_hacks.h,v 1.13 2018/08/27 15:27:28 riastradh Exp $	*/
+/*	$NetBSD: bus_dma_hacks.h,v 1.14 2018/08/27 15:29:08 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -48,6 +48,9 @@
 #elif defined(__arm__) || defined(__aarch64__)
 #  define	PHYS_TO_BUS_MEM(dmat, paddr)	((bus_addr_t)(paddr))
 #  define	BUS_MEM_TO_PHYS(dmat, baddr)	((paddr_t)(baddr))
+#elif defined(__sparc__) || defined(__sparc64__)
+#  define	PHYS_TO_BUS_MEM(dmat, paddr)	((bus_addr_t)(paddr))
+#  define	BUS_MEM_TO_PHYS(dmat, baddr)	((paddr_t)(baddr))
 #elif defined(__powerpc__)
 #else
 #  error DRM GEM/TTM need new MI bus_dma APIs!  Halp!



CVS commit: src/sys/external/bsd/drm2/include/drm

2018-08-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 27 15:27:28 UTC 2018

Modified Files:
src/sys/external/bsd/drm2/include/drm: bus_dma_hacks.h

Log Message:
Eliminate now-unused bus_dmamap_load_pgarray.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 \
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.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h
diff -u src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.12 src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.13
--- src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.12	Mon Aug 27 15:26:50 2018
+++ src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h	Mon Aug 27 15:27:28 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_dma_hacks.h,v 1.12 2018/08/27 15:26:50 riastradh Exp $	*/
+/*	$NetBSD: bus_dma_hacks.h,v 1.13 2018/08/27 15:27:28 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -116,48 +116,6 @@ out:	kmem_free(segs, (nsegs * sizeof(seg
 }
 
 static inline int
-bus_dmamap_load_pgarray(bus_dma_tag_t tag, bus_dmamap_t map,
-struct vm_page **pgs, unsigned npgs, bus_size_t size, int flags)
-{
-	km_flag_t kmflags;
-	bus_dma_segment_t *segs;
-	unsigned i;
-	int error;
-
-	KASSERT((int)npgs <= (SIZE_MAX / sizeof(segs[0])));
-	switch (flags & (BUS_DMA_WAITOK|BUS_DMA_NOWAIT)) {
-	case BUS_DMA_WAITOK:	kmflags = KM_SLEEP;	break;
-	case BUS_DMA_NOWAIT:	kmflags = KM_NOSLEEP;	break;
-	default:		panic("invalid flags: %d", flags);
-	}
-	segs = kmem_alloc((npgs * sizeof(segs[0])), kmflags);
-	if (segs == NULL)
-		return ENOMEM;
-
-	for (i = 0; i < npgs; i++) {
-		paddr_t paddr = VM_PAGE_TO_PHYS(pgs[i]);
-		bus_addr_t baddr = PHYS_TO_BUS_MEM(tag, paddr);
-
-		segs[i].ds_addr = baddr;
-		segs[i].ds_len = PAGE_SIZE;
-	}
-
-	error = bus_dmamap_load_raw(tag, map, segs, npgs, size, flags);
-	if (error)
-		goto fail0;
-
-	/* Success!  */
-	error = 0;
-	goto out;
-
-fail1: __unused
-	bus_dmamap_unload(tag, map);
-fail0:	KASSERT(error);
-out:	kmem_free(segs, (npgs * sizeof(segs[0])));
-	return error;
-}
-
-static inline int
 bus_dmamem_export_pages(bus_dma_tag_t dmat, const bus_dma_segment_t *segs,
 int nsegs, struct vm_page **pgs, unsigned npgs)
 {



CVS commit: src/sys/external/bsd/drm2/include/drm

2018-08-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 27 15:23:40 UTC 2018

Added Files:
src/sys/external/bsd/drm2/include/drm: drm_trace_netbsd.h

Log Message:
Forgot to commit drm_trace_netbsd.h.  Too late to force an update...


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 \
src/sys/external/bsd/drm2/include/drm/drm_trace_netbsd.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_trace_netbsd.h
diff -u /dev/null src/sys/external/bsd/drm2/include/drm/drm_trace_netbsd.h:1.1
--- /dev/null	Mon Aug 27 15:23:40 2018
+++ src/sys/external/bsd/drm2/include/drm/drm_trace_netbsd.h	Mon Aug 27 15:23:40 2018
@@ -0,0 +1,70 @@
+/*	$NetBSD: drm_trace_netbsd.h,v 1.1 2018/08/27 15:23:40 riastradh Exp $	*/
+
+/*-
+ * Copyright (c) 2018 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_TRACE_NETBSD_H_
+#define	_DRM_DRM_TRACE_NETBSD_H_
+
+#include 
+
+#ifdef CREATE_TRACE_POINTS
+#define	DEFINE_TRACE0(m,p,n)		SDT_PROBE_DEFINE0(sdt,m,p,n)
+#define	DEFINE_TRACE1(m,p,n,a)		SDT_PROBE_DEFINE1(sdt,m,p,n,a)
+#define	DEFINE_TRACE2(m,p,n,a,b)	SDT_PROBE_DEFINE2(sdt,m,p,n,a,b)
+#define	DEFINE_TRACE3(m,p,n,a,b,c)	SDT_PROBE_DEFINE3(sdt,m,p,n,a,b,c)
+#define	DEFINE_TRACE4(m,p,n,a,b,c,d)	SDT_PROBE_DEFINE4(sdt,m,p,n,a,b,c,d)
+#define	DEFINE_TRACE5(m,p,n,a,b,c,d,e)	SDT_PROBE_DEFINE5(sdt,m,p,n,a,b,c,d,e)
+#define	DEFINE_TRACE6(m,p,n,a,b,c,d,e,f)  \
+	SDT_PROBE_DEFINE6(sdt,m,p,n,a,b,c,d,e,f)
+#define	DEFINE_TRACE7(m,p,n,a,b,c,d,e,f,g)  \
+	SDT_PROBE_DEFINE7(sdt,m,p,n,a,b,c,d,e,f,g)
+#else
+#define	DEFINE_TRACE0(m,p,n)		SDT_PROBE_DECLARE(sdt,m,p,n)
+#define	DEFINE_TRACE1(m,p,n,a)		SDT_PROBE_DECLARE(sdt,m,p,n)
+#define	DEFINE_TRACE2(m,p,n,a,b)	SDT_PROBE_DECLARE(sdt,m,p,n)
+#define	DEFINE_TRACE3(m,p,n,a,b,c)	SDT_PROBE_DECLARE(sdt,m,p,n)
+#define	DEFINE_TRACE4(m,p,n,a,b,c,d)	SDT_PROBE_DECLARE(sdt,m,p,n)
+#define	DEFINE_TRACE5(m,p,n,a,b,c,d,e)	SDT_PROBE_DECLARE(sdt,m,p,n)
+#define	DEFINE_TRACE6(m,p,n,a,b,c,d,e,f)  \
+	SDT_PROBE_DECLARE(sdt,m,p,n)
+#define	DEFINE_TRACE7(m,p,n,a,b,c,d,e,f,g)  \
+	SDT_PROBE_DECLARE(sdt,m,p,n)
+#endif
+
+#define	TRACE0(m,p,n)			SDT_PROBE0(sdt,m,p,n)
+#define	TRACE1(m,p,n,a)			SDT_PROBE1(sdt,m,p,n,a)
+#define	TRACE2(m,p,n,a,b)		SDT_PROBE2(sdt,m,p,n,a,b)
+#define	TRACE3(m,p,n,a,b,c)		SDT_PROBE3(sdt,m,p,n,a,b,c)
+#define	TRACE4(m,p,n,a,b,c,d)		SDT_PROBE4(sdt,m,p,n,a,b,c,d)
+#define	TRACE5(m,p,n,a,b,c,d,e)		SDT_PROBE5(sdt,m,p,n,a,b,c,d,e)
+#define	TRACE6(m,p,n,a,b,c,d,e,f)	SDT_PROBE6(sdt,m,p,n,a,b,c,d,e,f)
+#define	TRACE7(m,p,n,a,b,c,d,e,f,g)	SDT_PROBE7(sdt,m,p,n,a,b,c,d,e,f,g)
+
+#endif	/* _LINUX_TRACEPOINT_H_ */



CVS commit: src/sys/external/bsd/drm2/include/drm

2018-08-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 27 15:12:09 UTC 2018

Modified Files:
src/sys/external/bsd/drm2/include/drm: drm_os_netbsd.h

Log Message:
opt_mtrr.h is x86-only.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 \
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.10 src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.11
--- src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.10	Mon Aug 27 13:53:09 2018
+++ src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h	Mon Aug 27 15:12:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_os_netbsd.h,v 1.10 2018/08/27 13:53:09 riastradh Exp $	*/
+/*	$NetBSD: drm_os_netbsd.h,v 1.11 2018/08/27 15:12:09 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -57,9 +57,11 @@
 #define CONFIG_PNP
 #endif
 
+#if defined(__i386__) || defined(__x86_64__)
 #if defined(_KERNEL_OPT)
 #include "opt_mtrr.h"
 #endif
+#endif
 
 #ifdef MTRR
 #define	CONFIG_MTRR	1



CVS commit: src/sys/external/bsd/drm2/include/drm

2018-08-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 27 15:11:58 UTC 2018

Modified Files:
src/sys/external/bsd/drm2/include/drm: bus_dma_hacks.h

Log Message:
Use PHYS_TO_BUS_MEM in generic bus_dmamap_load_pglist code.

For arm and x86, this is a noop.  For powerpc, it is defined by some
relevant header file.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 \
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.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h
diff -u src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.10 src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.11
--- src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.10	Mon Aug 27 07:17:47 2018
+++ src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h	Mon Aug 27 15:11:58 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_dma_hacks.h,v 1.10 2018/08/27 07:17:47 riastradh Exp $	*/
+/*	$NetBSD: bus_dma_hacks.h,v 1.11 2018/08/27 15:11:58 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -41,11 +41,14 @@
 #include 
 
 #if defined(__i386__) || defined(__x86_64__)
-#include 
-#include 
+#  include 
+#  include 
+#  define	PHYS_TO_BUS_MEM(dmat, paddr)	(paddr)
 #elif defined(__arm__) || defined(__aarch64__)
+#  define	PHYS_TO_BUS_MEM(dmat, paddr)	(paddr)
+#elif defined(__powerpc__)
 #else
-#error DRM GEM/TTM need new MI bus_dma APIs!  Halp!
+#  error DRM GEM/TTM need new MI bus_dma APIs!  Halp!
 #endif
 
 static inline int
@@ -87,7 +90,10 @@ bus_dmamap_load_pglist(bus_dma_tag_t tag
 
 	seg = 0;
 	TAILQ_FOREACH(page, pglist, pageq.queue) {
-		segs[seg].ds_addr = VM_PAGE_TO_PHYS(page);
+		paddr_t paddr = VM_PAGE_TO_PHYS(page);
+		bus_addr_t baddr = PHYS_TO_BUS_MEM(tag, paddr);
+
+		segs[seg].ds_addr = baddr;
 		segs[seg].ds_len = PAGE_SIZE;
 		seg++;
 	}



CVS commit: src/sys/external/bsd/drm2/include/drm

2018-08-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 27 13:53:09 UTC 2018

Modified Files:
src/sys/external/bsd/drm2/include/drm: drm_os_netbsd.h

Log Message:
Guard #include "pci.h" with _KERNEL_OPT.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 \
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.9 src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.10
--- src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.9	Mon Aug 27 07:50:08 2018
+++ src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h	Mon Aug 27 13:53:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_os_netbsd.h,v 1.9 2018/08/27 07:50:08 riastradh Exp $	*/
+/*	$NetBSD: drm_os_netbsd.h,v 1.10 2018/08/27 13:53:09 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -41,7 +41,10 @@
 #define	CONFIG_X86_PAT	1
 #endif
 
+#if defined(_KERNEL_OPT)
 #include "pci.h"
+#endif
+
 #if NPCI > 0
 #define	CONFIG_PCI	1
 #endif



CVS commit: src/sys/external/bsd/drm2/include/drm

2018-08-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 27 07:50:08 UTC 2018

Modified Files:
src/sys/external/bsd/drm2/include/drm: drm_os_netbsd.h

Log Message:
Define CONFIG_MTRR and CONFIG_X86_PAT.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 \
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.8 src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.9
--- src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.8	Mon Aug 27 06:42:54 2018
+++ src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h	Mon Aug 27 07:50:08 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_os_netbsd.h,v 1.8 2018/08/27 06:42:54 riastradh Exp $	*/
+/*	$NetBSD: drm_os_netbsd.h,v 1.9 2018/08/27 07:50:08 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -36,12 +36,9 @@
 #include "opt_drmkms.h"
 #endif
 
-/*
- * XXX Better to get rid of CONFIG_X86, but that's not convenient at
- * the moment.
- */
 #if defined(__i386__) || defined(__x86_64__)
 #define	CONFIG_X86	1
+#define	CONFIG_X86_PAT	1
 #endif
 
 #include "pci.h"
@@ -57,6 +54,14 @@
 #define CONFIG_PNP
 #endif
 
+#if defined(_KERNEL_OPT)
+#include "opt_mtrr.h"
+#endif
+
+#ifdef MTRR
+#define	CONFIG_MTRR	1
+#endif
+
 #include 
 #include 
 #include 



CVS commit: src/sys/external/bsd/drm2/include/drm

2018-08-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 27 07:17:47 UTC 2018

Modified Files:
src/sys/external/bsd/drm2/include/drm: bus_dma_hacks.h

Log Message:
Kill bus_dmamem_wire_uvm_object, which never made sense!


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 \
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.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h
diff -u src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.9 src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.10
--- src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.9	Sun Apr  1 04:35:06 2018
+++ src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h	Mon Aug 27 07:17:47 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_dma_hacks.h,v 1.9 2018/04/01 04:35:06 ryo Exp $	*/
+/*	$NetBSD: bus_dma_hacks.h,v 1.10 2018/08/27 07:17:47 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -49,71 +49,6 @@
 #endif
 
 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;
-	unsigned i;
-	int error;
-
-	/*
-	 * XXX `#ifdef __x86_64__' is a horrible way to work around a
-	 * completely stupid GCC warning that encourages unsafe,
-	 * nonportable code and has no obvious way to be selectively
-	 * suppressed.
-	 */
-#if __x86_64__
-	KASSERT(size <= __type_max(off_t));
-#endif
-
-	KASSERT(start <= (__type_max(off_t) - size));
-	KASSERT(alignment == PAGE_SIZE); /* XXX */
-	KASSERT(0 < nsegs);
-
-	if (pages == NULL) {
-		TAILQ_INIT();
-		pages = 
-	}
-
-	error = uvm_obj_wirepages(uobj, start, (start + size), pages);
-	if (error)
-		goto fail0;
-
-	page = TAILQ_FIRST(pages);
-	KASSERT(page != NULL);
-
-	for (i = 0; i < nsegs; i++) {
-		if (page == NULL) {
-			error = EFBIG;
-			goto fail1;
-		}
-		segs[i].ds_addr = VM_PAGE_TO_PHYS(page);
-		segs[i].ds_len = MIN(PAGE_SIZE, size);
-		size -= PAGE_SIZE;
-		page = TAILQ_NEXT(page, pageq.queue);
-	}
-	KASSERT(page == NULL);
-
-	/* Success!  */
-	*rsegs = nsegs;
-	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));
-}
-
-static inline int
 bus_dmamem_pgfl(bus_dma_tag_t tag)
 {
 #if defined(__i386__) || defined(__x86_64__)



CVS commit: src/sys/external/bsd/drm2/include/drm

2018-08-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 27 06:19:26 UTC 2018

Modified Files:
src/sys/external/bsd/drm2/include/drm: drm_os_netbsd.h

Log Message:
Define CONFIG_PCI to 1, not empty.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
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.6 src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.7
--- src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.6	Mon Aug 27 06:18:51 2018
+++ src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h	Mon Aug 27 06:19:26 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_os_netbsd.h,v 1.6 2018/08/27 06:18:51 riastradh Exp $	*/
+/*	$NetBSD: drm_os_netbsd.h,v 1.7 2018/08/27 06:19:26 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -46,7 +46,7 @@
 
 #include "pci.h"
 #if NPCI > 0
-#define CONFIG_PCI
+#define	CONFIG_PCI	1
 #endif
 
 #if defined(__i386__)



CVS commit: src/sys/external/bsd/drm2/include/drm

2018-08-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 27 06:18:51 UTC 2018

Modified Files:
src/sys/external/bsd/drm2/include/drm: drm_os_netbsd.h

Log Message:
provide CONFIG_PNP if it's defined. i386 only apparently.

XXX I'm not actually building i386 kernels

Author: coypu 
Committer: Taylor R Campbell 


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.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.5 src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.6
--- src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.5	Mon Aug 27 05:57:42 2018
+++ src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h	Mon Aug 27 06:18:51 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_os_netbsd.h,v 1.5 2018/08/27 05:57:42 riastradh Exp $	*/
+/*	$NetBSD: drm_os_netbsd.h,v 1.6 2018/08/27 06:18:51 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -49,6 +49,14 @@
 #define CONFIG_PCI
 #endif
 
+#if defined(__i386__)
+#include "pnpbios.h"
+#endif
+
+#if NPNPBIOS > 0
+#define CONFIG_PNP
+#endif
+
 #include 
 #include 
 #include 



CVS commit: src/sys/external/bsd/drm2/include/drm

2018-08-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 27 05:57:42 UTC 2018

Modified Files:
src/sys/external/bsd/drm2/include/drm: drm_os_netbsd.h

Log Message:
bring in changes from OLDER drmP.h to go forward with compilation

Author: coypu 
Committer: Taylor R Campbell 


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.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.4 src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.5
--- src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.4	Mon Aug 27 05:34:49 2018
+++ src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h	Mon Aug 27 05:57:42 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_os_netbsd.h,v 1.4 2018/08/27 05:34:49 riastradh Exp $	*/
+/*	$NetBSD: drm_os_netbsd.h,v 1.5 2018/08/27 05:57:42 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -44,6 +44,11 @@
 #define	CONFIG_X86	1
 #endif
 
+#include "pci.h"
+#if NPCI > 0
+#define CONFIG_PCI
+#endif
+
 #include 
 #include 
 #include 



CVS commit: src/sys/external/bsd/drm2/include/drm

2018-08-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 27 05:34:49 UTC 2018

Modified Files:
src/sys/external/bsd/drm2/include/drm: drm_os_netbsd.h
Added Files:
src/sys/external/bsd/drm2/include/drm: drm_iomap_netbsd.h

Log Message:
Move old DRM_READn definitions into new drm_iomap_netbsd.h

These got deleted from drmP.h.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 \
src/sys/external/bsd/drm2/include/drm/drm_iomap_netbsd.h
cvs rdiff -u -r1.3 -r1.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.3 src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.4
--- src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h:1.3	Sat Jul 26 18:13:44 2014
+++ src/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h	Mon Aug 27 05:34:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_os_netbsd.h,v 1.3 2014/07/26 18:13:44 riastradh Exp $	*/
+/*	$NetBSD: drm_os_netbsd.h,v 1.4 2018/08/27 05:34:49 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -47,6 +47,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 

Added files:

Index: src/sys/external/bsd/drm2/include/drm/drm_iomap_netbsd.h
diff -u /dev/null src/sys/external/bsd/drm2/include/drm/drm_iomap_netbsd.h:1.1
--- /dev/null	Mon Aug 27 05:34:49 2018
+++ src/sys/external/bsd/drm2/include/drm/drm_iomap_netbsd.h	Mon Aug 27 05:34:49 2018
@@ -0,0 +1,185 @@
+/*	$NetBSD: drm_iomap_netbsd.h,v 1.1 2018/08/27 05:34:49 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_IOMAP_NETBSD_H_
+#define	_DRM_DRM_IOMAP_NETBSD_H_
+
+#include 
+#include 
+
+#include 
+
+static inline bool
+DRM_IS_BUS_SPACE(struct drm_local_map *map)
+{
+	switch (map->type) {
+	case _DRM_FRAME_BUFFER:
+		panic("I don't know how to access drm frame buffer memory!");
+
+	case _DRM_REGISTERS:
+		return true;
+
+	case _DRM_SHM:
+		panic("I don't know how to access drm shared memory!");
+
+	case _DRM_AGP:
+		panic("I don't know how to access drm agp memory!");
+
+	case _DRM_SCATTER_GATHER:
+		panic("I don't know how to access drm scatter-gather memory!");
+
+	case _DRM_CONSISTENT:
+		/*
+		 * XXX Old drm uses bus space access for this, but
+		 * consistent maps don't have bus space handles!  They
+		 * do, however, have kernel virtual addresses in the
+		 * map->handle, so maybe that's right.
+		 */
+#if 0
+		return false;
+#endif
+		panic("I don't know how to access drm consistent memory!");
+
+	default:
+		panic("I don't know what kind of memory you mean!");
+	}
+}
+
+static inline uint8_t
+DRM_READ8(struct drm_local_map *map, bus_size_t offset)
+{
+	if (DRM_IS_BUS_SPACE(map))
+		return bus_space_read_1(map->lm_data.bus_space.bst,
+		map->lm_data.bus_space.bsh, offset);
+	else
+		return *(volatile uint8_t *)((vaddr_t)map->handle + offset);
+}
+
+static inline uint16_t
+DRM_READ16(struct drm_local_map *map, bus_size_t offset)
+{
+	if (DRM_IS_BUS_SPACE(map))
+		return bus_space_read_2(map->lm_data.bus_space.bst,
+		map->lm_data.bus_space.bsh, offset);
+	else
+		return *(volatile uint16_t *)((vaddr_t)map->handle + offset);
+}
+
+static inline uint32_t
+DRM_READ32(struct drm_local_map *map, bus_size_t offset)
+{
+	if (DRM_IS_BUS_SPACE(map))
+		return 

CVS commit: src/sys/external/bsd/drm2/include/drm

2016-05-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri May 13 15:25:57 UTC 2016

Modified Files:
src/sys/external/bsd/drm2/include/drm: drm_wait_netbsd.h

Log Message:
We now use cpu_intr_p() all the time.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 \
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.13 src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.14
--- src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.13	Sun Apr 12 16:55:02 2015
+++ src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h	Fri May 13 11:25:57 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_wait_netbsd.h,v 1.13 2015/04/12 20:55:02 riastradh Exp $	*/
+/*	$NetBSD: drm_wait_netbsd.h,v 1.14 2016/05/13 15:25:57 christos Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -34,9 +34,7 @@
 
 #include 
 #include 
-#if DIAGNOSTIC
 #include 		/* cpu_intr_p */
-#endif
 #include 
 #include 
 #include 



CVS commit: src/sys/external/bsd/drm2/include/drm

2015-10-17 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 17 21:09:49 UTC 2015

Modified Files:
src/sys/external/bsd/drm2/include/drm: drm_agp_netbsd.h

Log Message:
only define __OS_HAS_AGP if x86 and NAGP > 0


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
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.4 src/sys/external/bsd/drm2/include/drm/drm_agp_netbsd.h:1.5
--- src/sys/external/bsd/drm2/include/drm/drm_agp_netbsd.h:1.4	Sat Aug 23 08:03:33 2014
+++ src/sys/external/bsd/drm2/include/drm/drm_agp_netbsd.h	Sat Oct 17 21:09:49 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_agp_netbsd.h,v 1.4 2014/08/23 08:03:33 riastradh Exp $	*/
+/*	$NetBSD: drm_agp_netbsd.h,v 1.5 2015/10/17 21:09:49 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -47,12 +47,16 @@
 #include 
 #include 
 
-#define	__OS_HAS_AGP	1
-
 #define	PCI_AGP_COMMAND_FW	AGPCMD_FWEN
 
+#if defined(__i386__) || defined(__x86_64__)
+#include "agp.h"
+#if NAGP > 0
+#define	__OS_HAS_AGP	1
+#endif
 __CTASSERT(PAGE_SIZE == AGP_PAGE_SIZE);
 __CTASSERT(PAGE_SHIFT == AGP_PAGE_SHIFT);
+#endif
 
 struct agp_kern_info {
 	struct agp_info aki_info;



CVS commit: src/sys/external/bsd/drm2/include/drm

2015-10-17 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 17 21:11:06 UTC 2015

Modified Files:
src/sys/external/bsd/drm2/include/drm: bus_dma_hacks.h

Log Message:
use VM_FREELIST_DEFAULT on arm


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
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.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h
diff -u src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.7 src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.8
--- src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.7	Sat Jul 26 14:27:40 2014
+++ src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h	Sat Oct 17 21:11:06 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_dma_hacks.h,v 1.7 2014/07/26 14:27:40 riastradh Exp $	*/
+/*	$NetBSD: bus_dma_hacks.h,v 1.8 2015/10/17 21:11:06 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -40,13 +40,13 @@
 #include 
 #include 
 
-/* XXX This is x86-specific bollocks.  */
-#if !defined(__i386__) && !defined(__x86_64__)
-#error DRM GEM/TTM need new MI bus_dma APIs!  Halp!
-#endif
-
+#if defined(__i386__) || defined(__x86_64__)
 #include 
 #include 
+#elif defined(__arm__)
+#else
+#error DRM GEM/TTM need new MI bus_dma APIs!  Halp!
+#endif
 
 static inline int
 bus_dmamem_wire_uvm_object(bus_dma_tag_t tag, struct uvm_object *uobj,
@@ -116,7 +116,11 @@ bus_dmamem_unwire_uvm_object(bus_dma_tag
 static inline int
 bus_dmamem_pgfl(bus_dma_tag_t tag)
 {
+#if defined(__i386__) || defined(__x86_64__)
 	return x86_select_freelist(tag->_bounce_alloc_hi - 1);
+#else
+	return VM_FREELIST_DEFAULT;
+#endif
 }
 
 static inline int



CVS commit: src/sys/external/bsd/drm2/include/drm

2015-10-17 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 17 21:27:02 UTC 2015

Modified Files:
src/sys/external/bsd/drm2/include/drm: drm_agp_netbsd.h

Log Message:
dont pull in agp.h when building as a module


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
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.5 src/sys/external/bsd/drm2/include/drm/drm_agp_netbsd.h:1.6
--- src/sys/external/bsd/drm2/include/drm/drm_agp_netbsd.h:1.5	Sat Oct 17 21:09:49 2015
+++ src/sys/external/bsd/drm2/include/drm/drm_agp_netbsd.h	Sat Oct 17 21:27:02 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_agp_netbsd.h,v 1.5 2015/10/17 21:09:49 jmcneill Exp $	*/
+/*	$NetBSD: drm_agp_netbsd.h,v 1.6 2015/10/17 21:27:02 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -50,7 +50,11 @@
 #define	PCI_AGP_COMMAND_FW	AGPCMD_FWEN
 
 #if defined(__i386__) || defined(__x86_64__)
+#if defined(_KERNEL_OPT)
 #include "agp.h"
+#else
+#define NAGP 1
+#endif
 #if NAGP > 0
 #define	__OS_HAS_AGP	1
 #endif



CVS commit: src/sys/external/bsd/drm2/include/drm

2015-04-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr 12 20:55:02 UTC 2015

Modified Files:
src/sys/external/bsd/drm2/include/drm: drm_wait_netbsd.h

Log Message:
Don't break when hardclock_ticks wraps around.

Since we now only count time spent in wait, rather than determining
the end time and checking whether we've passed it, timeouts might be
marginally longer in effect.  Unlikely to be an issue.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 \
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.12 src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.13
--- src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.12	Sat Apr  4 15:46:53 2015
+++ src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h	Sun Apr 12 20:55:02 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_wait_netbsd.h,v 1.12 2015/04/04 15:46:53 riastradh Exp $	*/
+/*	$NetBSD: drm_wait_netbsd.h,v 1.13 2015/04/12 20:55:02 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -124,9 +124,8 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, 
 
 #define	DRM_SPIN_WAIT_ON(RET, Q, INTERLOCK, TICKS, CONDITION)	do	  \
 {	  \
-	extern int hardclock_ticks;	  \
-	const int _dswo_start = hardclock_ticks;			  \
-	const int _dswo_end = _dswo_start + (TICKS);			  \
+	unsigned _dswo_ticks = (TICKS);	  \
+	unsigned _dswo_start, _dswo_end;  \
 	  \
 	KASSERT(spin_is_locked((INTERLOCK)));  \
 	KASSERT(!cpu_intr_p());		  \
@@ -138,13 +137,18 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, 
 			(RET) = 0;	  \
 			break;		  \
 		}			  \
-		const int _dswo_now = hardclock_ticks;			  \
-		if (_dswo_end  _dswo_now) {  \
+		if (_dswo_ticks == 0) {	  \
 			(RET) = -EBUSY;		/* Match Linux...  */	  \
 			break;		  \
 		}			  \
+		_dswo_start = hardclock_ticks;  \
 		/* XXX errno NetBSD-Linux */  \
 		(RET) = -cv_timedwait_sig((Q), (INTERLOCK)-sl_lock, 1); \
+		_dswo_end = hardclock_ticks;  \
+		if (_dswo_end - _dswo_start  _dswo_ticks)		  \
+			_dswo_ticks -= _dswo_end - _dswo_start;		  \
+		else			  \
+			_dswo_ticks = 0;  \
 		if (RET) {		  \
 			if ((RET) == -EWOULDBLOCK)			  \
 /* Waited only one tick.  */		  \
@@ -212,33 +216,36 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, 
 
 #define	_DRM_TIMED_WAIT_UNTIL(RET, WAIT, Q, INTERLOCK, TICKS, CONDITION) do \
 {	\
-	extern int hardclock_ticks;	\
-	const int _dtwu_start = hardclock_ticks;			\
-	int _dtwu_ticks = (TICKS);	\
+	unsigned _dtwu_ticks = (TICKS);	\
+	unsigned _dtwu_start, _dtwu_end;\
+	\
 	KASSERT(mutex_is_locked((INTERLOCK)));\
 	ASSERT_SLEEPABLE();		\
 	KASSERT(!cold);			\
+	\
 	for (;;) {			\
 		if (CONDITION) {	\
-			(RET) = _dtwu_ticks;\
+			(RET) = MAX(_dtwu_ticks, 1);			\
 			break;		\
 		}			\
+		if (_dtwu_ticks == 0) {	\
+			(RET) = 0;	\
+			break;		\
+		}			\
+		_dtwu_start = hardclock_ticks;\
 		/* XXX errno NetBSD-Linux */\
 		(RET) = -WAIT((Q), (INTERLOCK)-mtx_lock,		\
-		_dtwu_ticks);	\
+		MIN(_dtwu_ticks, INT_MAX/2));			\
+		_dtwu_end = hardclock_ticks;\
+		if ((_dtwu_end - _dtwu_start)  _dtwu_ticks)		\
+			_dtwu_ticks -= _dtwu_end - _dtwu_start;		\
+		else			\
+			_dtwu_ticks = 0;\
 		if (RET) {		\
 			if ((RET) == -EWOULDBLOCK)			\
 (RET) = (CONDITION) ? 1 : 0;		\
 			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) = (CONDITION) ? 1 : 0;			\
-			break;		\
-		}			\
 	}\
 } while (0)
 
@@ -279,34 +286,37 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, 
 #define	_DRM_SPIN_TIMED_WAIT_UNTIL(RET, WAIT, Q, INTERLOCK, TICKS, CONDITION) \
 	do\
 {	\
-	extern int hardclock_ticks;	\
-	const int _dstwu_start = hardclock_ticks;			\
-	int _dstwu_ticks = (TICKS);	\
+	unsigned _dstwu_ticks = (TICKS);\
+	unsigned _dstwu_start, _dstwu_end;\
+	\
 	KASSERT(spin_is_locked((INTERLOCK)));\
 	KASSERT(!cpu_intr_p());		\
 	KASSERT(!cpu_softintr_p());	\
 	KASSERT(!cold);			\
+	\
 	for (;;) {			\
 		if (CONDITION) {	\
-			(RET) = _dstwu_ticks;\
+			(RET) = MAX(_dstwu_ticks, 1);			\
 			break;		\
 		}			\
+		if (_dstwu_ticks == 0) {\
+			(RET) = 0;	\
+			break;		\
+		}			\
+		_dstwu_start = hardclock_ticks;\
 		/* XXX errno NetBSD-Linux */\
 		(RET) = -WAIT((Q), 

CVS commit: src/sys/external/bsd/drm2/include/drm

2015-04-04 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Apr  4 15:46:53 UTC 2015

Modified Files:
src/sys/external/bsd/drm2/include/drm: drm_wait_netbsd.h

Log Message:
In DRM_SPIN_WAIT_ON, don't stop after waiting only one tick.

Continue the loop to recheck the condition and count the whole
duration.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 \
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.11 src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.12
--- src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.11	Sat Feb 28 21:30:22 2015
+++ src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h	Sat Apr  4 15:46:53 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_wait_netbsd.h,v 1.11 2015/02/28 21:30:22 riastradh Exp $	*/
+/*	$NetBSD: drm_wait_netbsd.h,v 1.12 2015/04/04 15:46:53 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -147,7 +147,8 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, 
 		(RET) = -cv_timedwait_sig((Q), (INTERLOCK)-sl_lock, 1); \
 		if (RET) {		  \
 			if ((RET) == -EWOULDBLOCK)			  \
-(RET) = (CONDITION) ? 0 : -EBUSY;	  \
+/* Waited only one tick.  */		  \
+continue;  \
 			break;		  \
 		}			  \
 	}  \



CVS commit: src/sys/external/bsd/drm2/include/drm

2015-02-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 28 21:17:32 UTC 2015

Modified Files:
src/sys/external/bsd/drm2/include/drm: drm_wait_netbsd.h

Log Message:
Remove extraneous blank line.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 \
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.9 src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.10
--- src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.9	Sat Feb 28 18:25:39 2015
+++ src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h	Sat Feb 28 21:17:32 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_wait_netbsd.h,v 1.9 2015/02/28 18:25:39 riastradh Exp $	*/
+/*	$NetBSD: drm_wait_netbsd.h,v 1.10 2015/02/28 21:17:32 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -149,7 +149,6 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, 
 		if (RET) {		  \
 			if ((RET) == -EWOULDBLOCK)			  \
 (RET) = (CONDITION) ? 0 : -EBUSY;	  \
-	  \
 			break;		  \
 		}			  \
 	}  \



CVS commit: src/sys/external/bsd/drm2/include/drm

2015-02-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 28 21:30:22 UTC 2015

Modified Files:
src/sys/external/bsd/drm2/include/drm: drm_wait_netbsd.h

Log Message:
Actually poll every tick as advertised.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 \
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.10 src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.11
--- src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.10	Sat Feb 28 21:17:32 2015
+++ src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h	Sat Feb 28 21:30:22 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_wait_netbsd.h,v 1.10 2015/02/28 21:17:32 riastradh Exp $	*/
+/*	$NetBSD: drm_wait_netbsd.h,v 1.11 2015/02/28 21:30:22 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -144,8 +144,7 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, 
 			break;		  \
 		}			  \
 		/* XXX errno NetBSD-Linux */  \
-		(RET) = -cv_timedwait_sig((Q), (INTERLOCK)-sl_lock,	  \
-		(_dswo_end - _dswo_now));  \
+		(RET) = -cv_timedwait_sig((Q), (INTERLOCK)-sl_lock, 1); \
 		if (RET) {		  \
 			if ((RET) == -EWOULDBLOCK)			  \
 (RET) = (CONDITION) ? 0 : -EBUSY;	  \



CVS commit: src/sys/external/bsd/drm2/include/drm

2015-02-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 28 03:22:50 UTC 2015

Modified Files:
src/sys/external/bsd/drm2/include/drm: drm_wait_netbsd.h

Log Message:
Write an essay to remind myself about (timed) wait return values.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.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.6 src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.7
--- src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.6	Thu Feb 26 23:27:41 2015
+++ src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h	Sat Feb 28 03:22:50 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_wait_netbsd.h,v 1.6 2015/02/26 23:27:41 riastradh Exp $	*/
+/*	$NetBSD: drm_wait_netbsd.h,v 1.7 2015/02/28 03:22:50 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -104,6 +104,28 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, 
 	cv_broadcast(q);
 }
 
+/*
+ * WARNING: These DRM_*WAIT*_UNTIL macros are designed to replace the
+ * Linux wait_event_* macros.  They have a different return value
+ * convention from the legacy portability DRM_WAIT_ON macro and a
+ * different return value convention from cv_*wait*.  Specifically,
+ * DRM_*WAIT*_UNTIL and Linux wait_event_*
+ *
+ * - return negative error code on failure (e.g., interruption),
+ * - return zero on timeout, and
+ * - return one on success.
+ *
+ * Contrast DRM_WAIT_ON which returns -EINTR/-ERESTART on interruption,
+ * -EBUSY on timeout, and zero on success; and cv_*wait*, which return
+ * -EINTR/-ERESTART on interruption, -EWOULDBLOCK on timeout, and zero
+ * on success.
+ *
+ * We don't simply implement DRM_WAIT_ON because, like Linux
+ * wait_event_*, it lacks an interlock, whereas we require an interlock
+ * for any waits in order to avoid the standard race conditions
+ * associated with non-interlocked waits that plague Linux drivers.
+ */
+
 #define	_DRM_WAIT_UNTIL(RET, WAIT, Q, INTERLOCK, CONDITION) do		\
 {	\
 	KASSERT(mutex_is_locked((INTERLOCK)));\
@@ -135,7 +157,7 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, 
  * - 0 if condition is false after timeout,
  * - 1 if condition is true after timeout or one tick before timeout,
  * - number of ticks left if condition evaluated to true before timeout, or
- * - error if failure (e.g., interrupted).
+ * - negative error if failure (e.g., interrupted).
  *
  * XXX Comments in Linux say it returns -ERESTARTSYS if interrupted.
  * What if by a signal without SA_RESTART?  Shouldn't it be -EINTR



CVS commit: src/sys/external/bsd/drm2/include/drm

2015-02-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 28 04:57:12 UTC 2015

Modified Files:
src/sys/external/bsd/drm2/include/drm: drm_wait_netbsd.h

Log Message:
Elaborate on essay about DRM_*WAIT*_UNTIL reutrn convention.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.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.7 src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.8
--- src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.7	Sat Feb 28 03:22:50 2015
+++ src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h	Sat Feb 28 04:57:12 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_wait_netbsd.h,v 1.7 2015/02/28 03:22:50 riastradh Exp $	*/
+/*	$NetBSD: drm_wait_netbsd.h,v 1.8 2015/02/28 04:57:12 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -106,12 +106,18 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, 
 
 /*
  * WARNING: These DRM_*WAIT*_UNTIL macros are designed to replace the
- * Linux wait_event_* macros.  They have a different return value
+ * Linux wait_event* macros.  They have a different return value
  * convention from the legacy portability DRM_WAIT_ON macro and a
- * different return value convention from cv_*wait*.  Specifically,
- * DRM_*WAIT*_UNTIL and Linux wait_event_*
+ * different return value convention from cv_*wait*.
  *
- * - return negative error code on failure (e.g., interruption),
+ * Specifically, the untimed macros
+ *
+ * - return negative error code on failure (interruption), and
+ * - return zero on sucess.
+ *
+ * The timed macros
+ *
+ * - return negative error code on failure (interruption),
  * - return zero on timeout, and
  * - return one on success.
  *
@@ -121,9 +127,14 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, 
  * on success.
  *
  * We don't simply implement DRM_WAIT_ON because, like Linux
- * wait_event_*, it lacks an interlock, whereas we require an interlock
+ * wait_event*, it lacks an interlock, whereas we require an interlock
  * for any waits in order to avoid the standard race conditions
  * associated with non-interlocked waits that plague Linux drivers.
+ *
+ * XXX In retrospect, giving the timed and untimed macros a different
+ * return convention from one another to match Linux may have been a
+ * bad idea.  All of this inconsistent timeout return convention logic
+ * has been a consistent source of bugs.
  */
 
 #define	_DRM_WAIT_UNTIL(RET, WAIT, Q, INTERLOCK, CONDITION) do		\



CVS commit: src/sys/external/bsd/drm2/include/drm

2015-02-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 26 23:27:41 UTC 2015

Modified Files:
src/sys/external/bsd/drm2/include/drm: drm_wait_netbsd.h

Log Message:
Another attempt to fix the drm timed wait blarf blugh blahhh.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
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.5 src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.6
--- src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.5	Tue Aug 26 00:48:29 2014
+++ src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h	Thu Feb 26 23:27:41 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_wait_netbsd.h,v 1.5 2014/08/26 00:48:29 riastradh Exp $	*/
+/*	$NetBSD: drm_wait_netbsd.h,v 1.6 2015/02/26 23:27:41 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -129,6 +129,19 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, 
 #define	DRM_WAIT_UNTIL(RET, Q, I, C)\
 	_DRM_WAIT_UNTIL(RET, cv_wait_sig, Q, I, C)
 
+/*
+ * Timed wait.  Return:
+ *
+ * - 0 if condition is false after timeout,
+ * - 1 if condition is true after timeout or one tick before timeout,
+ * - number of ticks left if condition evaluated to true before timeout, or
+ * - error if failure (e.g., interrupted).
+ *
+ * XXX Comments in Linux say it returns -ERESTARTSYS if interrupted.
+ * What if by a signal without SA_RESTART?  Shouldn't it be -EINTR
+ * then?  I'm going to leave it as what cv_timedwait returned, which is
+ * ERESTART for signals with SA_RESTART and EINTR otherwise.
+ */
 #define	_DRM_TIMED_WAIT_UNTIL(RET, WAIT, Q, INTERLOCK, TICKS, CONDITION) do \
 {	\
 	extern int hardclock_ticks;	\
@@ -145,14 +158,17 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, 
 		/* XXX errno NetBSD-Linux */\
 		(RET) = -WAIT((Q), (INTERLOCK)-mtx_lock,		\
 		_dtwu_ticks);	\
-		if (RET)		\
+		if (RET) {		\
+			if ((RET) == -EWOULDBLOCK)			\
+(RET) = (CONDITION) ? 1 : 0;		\
 			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;	\
+			(RET) = (CONDITION) ? 1 : 0;			\
 			break;		\
 		}			\
 	}\
@@ -210,14 +226,17 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, 
 		/* XXX errno NetBSD-Linux */\
 		(RET) = -WAIT((Q), (INTERLOCK)-sl_lock,		\
 		_dstwu_ticks);	\
-		if (RET)		\
+		if (RET) {		\
+			if ((RET) == -EWOULDBLOCK)			\
+(RET) = (CONDITION) ? 1 : 0;		\
 			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;	\
+			(RET) = (CONDITION) ? 1 : 0;			\
 			break;		\
 		}			\
 	}\



CVS commit: src/sys/external/bsd/drm2/include/drm

2014-08-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Aug 26 00:48:29 UTC 2014

Modified Files:
src/sys/external/bsd/drm2/include/drm: drm_wait_netbsd.h

Log Message:
Return 0, not uninitialized, if the condition is already true.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
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.4 src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.5
--- src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.4	Wed Jul 16 20:59:58 2014
+++ src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h	Tue Aug 26 00:48:29 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_wait_netbsd.h,v 1.4 2014/07/16 20:59:58 riastradh Exp $	*/
+/*	$NetBSD: drm_wait_netbsd.h,v 1.5 2014/08/26 00:48:29 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -177,6 +177,7 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, 
 	KASSERT(!cpu_intr_p());		\
 	KASSERT(!cpu_softintr_p());	\
 	KASSERT(!cold);			\
+	(RET) = 0;			\
 	while (!(CONDITION)) {		\
 		/* XXX errno NetBSD-Linux */\
 		(RET) = -WAIT((Q), (INTERLOCK)-sl_lock);		\



CVS commit: src/sys/external/bsd/drm2/include/drm

2014-07-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Jul 26 14:27:40 UTC 2014

Modified Files:
src/sys/external/bsd/drm2/include/drm: bus_dma_hacks.h

Log Message:
Avoid needless #ifdef __i386__ with judicious use of MIN.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
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.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h
diff -u src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.6 src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.7
--- src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.6	Tue Jul 22 22:14:22 2014
+++ src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h	Sat Jul 26 14:27:40 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_dma_hacks.h,v 1.6 2014/07/22 22:14:22 riastradh Exp $	*/
+/*	$NetBSD: bus_dma_hacks.h,v 1.7 2014/07/26 14:27:40 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -131,12 +131,8 @@ bus_dmamap_load_pglist(bus_dma_tag_t tag
 
 	nsegs = 0;
 	TAILQ_FOREACH(page, pglist, pageq.queue) {
-		if (nsegs == INT_MAX)
+		if (nsegs == MIN(INT_MAX, (SIZE_MAX / sizeof(segs[0]
 			return ENOMEM;
-#if __i386__
-		if (nsegs == (SIZE_MAX / sizeof(segs[0])))
-			return ENOMEM;
-#endif
 		nsegs++;
 	}
 



CVS commit: src/sys/external/bsd/drm2/include/drm

2014-07-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Jul 22 22:14:22 UTC 2014

Modified Files:
src/sys/external/bsd/drm2/include/drm: bus_dma_hacks.h

Log Message:
Free temporary segs on the way out of bus_dmamap_load_pglist.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
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.

Modified files:

Index: src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h
diff -u src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.5 src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.6
--- src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h:1.5	Wed Jul 16 20:59:58 2014
+++ src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h	Tue Jul 22 22:14:22 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_dma_hacks.h,v 1.5 2014/07/16 20:59:58 riastradh Exp $	*/
+/*	$NetBSD: bus_dma_hacks.h,v 1.6 2014/07/22 22:14:22 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -162,12 +162,13 @@ bus_dmamap_load_pglist(bus_dma_tag_t tag
 		goto fail0;
 
 	/* Success!  */
-	return 0;
+	error = 0;
+	goto out;
 
 fail1: __unused
 	bus_dmamap_unload(tag, map);
 fail0:	KASSERT(error);
-	kmem_free(segs, (nsegs * sizeof(segs[0])));
+out:	kmem_free(segs, (nsegs * sizeof(segs[0])));
 	return error;
 }
 



CVS commit: src/sys/external/bsd/drm2/include/drm

2014-05-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May 28 16:13:02 UTC 2014

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

Log Message:
Explain the fields of struct intel_gtt for future reference.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.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.2 src/sys/external/bsd/drm2/include/drm/intel-gtt.h:1.3
--- src/sys/external/bsd/drm2/include/drm/intel-gtt.h:1.2	Tue Mar 18 18:20:43 2014
+++ src/sys/external/bsd/drm2/include/drm/intel-gtt.h	Wed May 28 16:13:02 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: intel-gtt.h,v 1.2 2014/03/18 18:20:43 riastradh Exp $	*/
+/*	$NetBSD: intel-gtt.h,v 1.3 2014/05/28 16:13:02 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -41,13 +41,47 @@
 #include drm/drm_agp_netbsd.h
 
 struct intel_gtt {
+	/*
+	 * GMADR, graphics memory address, a.k.a. the `aperture'.
+	 * Access to bus addresses in the region starting here are
+	 * remapped to physical system memory addresses programmed into
+	 * the GTT (or GPU-local memory, for i810 chipsets, depending
+	 * on the GTT entries).  This corresponds to a prefix of the
+	 * GPU's virtual address space.  The virtual address space may
+	 * be larger: in that case, there will be more GTT entries than
+	 * pages in the aperture.
+	 */
 	paddr_t			gma_bus_addr;
+
+	/*
+	 * Number of bytes of system memory stolen by the graphics
+	 * device for frame buffer memory (but not for the GTT).  These
+	 * pages in memory -- if you know where they are -- can't be
+	 * used by the CPU, but they can be programmed into the GTT for
+	 * access from the GPU.
+	 */
 	unsigned int		stolen_size;
+
+	/*
+	 * Total number of GTT entries, including entries for the GPU's
+	 * virtual address space beyond the aperture.
+	 */
 	unsigned int		gtt_total_entries;
+
+	/*
+	 * Number of GTT entries for pages that we can actually map
+	 * into the aperture.
+	 */
 	unsigned int		gtt_mappable_entries;
+
+	/* Scratch page for unbound GTT entries.  */
 	bus_dma_segment_t	gtt_scratch_seg;
 	bus_dmamap_t		gtt_scratch_map;
+
+	/* Bus space handle for the GTT itself.  */
 	bus_space_handle_t	gtt_bsh;
+
+	/* IOMMU-related quirk for certain chipsets.  */
 	bool			do_idle_maps;
 };