Module Name:    src
Committed By:   riastradh
Date:           Wed Aug  6 13:35:13 UTC 2014

Modified Files:
        src/sys/external/bsd/drm2/dist/drm/nouveau: nouveau_agp.c nouveau_bo.c
            nouveau_bo.h nouveau_chan.c nouveau_fence.c nouveau_fence.h
            nouveau_ttm.c
        src/sys/external/bsd/drm2/dist/drm/nouveau/core: os.h
        src/sys/external/bsd/drm2/dist/drm/nouveau/core/core:
            nouveau_core_handle.c nouveau_core_object.c
        src/sys/external/bsd/drm2/dist/drm/nouveau/core/include/core: object.h
            subdev.h
        src/sys/external/bsd/drm2/dist/drm/nouveau/core/include/subdev: bar.h

Log Message:
Snapshot of nouveau.  Doesn't build yet, but progress.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.2 \
    src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_agp.c \
    src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_bo.c \
    src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_chan.c \
    src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c \
    src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_ttm.c
cvs rdiff -u -r1.1.1.1 -r1.2 \
    src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_bo.h \
    src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.h
cvs rdiff -u -r1.1.1.1 -r1.2 \
    src/sys/external/bsd/drm2/dist/drm/nouveau/core/os.h
cvs rdiff -u -r1.1.1.1 -r1.2 \
    src/sys/external/bsd/drm2/dist/drm/nouveau/core/core/nouveau_core_handle.c \
    src/sys/external/bsd/drm2/dist/drm/nouveau/core/core/nouveau_core_object.c
cvs rdiff -u -r1.1.1.1 -r1.2 \
    src/sys/external/bsd/drm2/dist/drm/nouveau/core/include/core/object.h \
    src/sys/external/bsd/drm2/dist/drm/nouveau/core/include/core/subdev.h
cvs rdiff -u -r1.1.1.1 -r1.2 \
    src/sys/external/bsd/drm2/dist/drm/nouveau/core/include/subdev/bar.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/dist/drm/nouveau/nouveau_agp.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_agp.c:1.1.1.2 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_agp.c:1.2
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_agp.c:1.1.1.2	Wed Aug  6 12:36:23 2014
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_agp.c	Wed Aug  6 13:35:13 2014
@@ -1,9 +1,10 @@
-/*	$NetBSD: nouveau_agp.c,v 1.1.1.2 2014/08/06 12:36:23 riastradh Exp $	*/
+/*	$NetBSD: nouveau_agp.c,v 1.2 2014/08/06 13:35:13 riastradh Exp $	*/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_agp.c,v 1.1.1.2 2014/08/06 12:36:23 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_agp.c,v 1.2 2014/08/06 13:35:13 riastradh Exp $");
 
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 
 #include <core/device.h>
 
Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_bo.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_bo.c:1.1.1.2 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_bo.c:1.2
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_bo.c:1.1.1.2	Wed Aug  6 12:36:23 2014
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_bo.c	Wed Aug  6 13:35:13 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_bo.c,v 1.1.1.2 2014/08/06 12:36:23 riastradh Exp $	*/
+/*	$NetBSD: nouveau_bo.c,v 1.2 2014/08/06 13:35:13 riastradh Exp $	*/
 
 /*
  * Copyright 2007 Dave Airlied
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_bo.c,v 1.1.1.2 2014/08/06 12:36:23 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_bo.c,v 1.2 2014/08/06 13:35:13 riastradh Exp $");
 
 #include <core/engine.h>
 #include <linux/swiotlb.h>
@@ -420,6 +420,58 @@ nouveau_bo_validate(struct nouveau_bo *n
 	return 0;
 }
 
+#ifdef __NetBSD__
+/*
+ * XXX Can't use bus_space here because this is all mapped through the
+ * radeon_bo abstraction.  Can't assume we're x86 because this is
+ * Nouveau, not Intel.
+ */
+
+#  define	__iomem			volatile
+#  define	ioread16_native		fake_ioread16_native
+#  define	ioread32_native		fake_ioread32_native
+#  define	iowrite16_native	fake_iowrite16_native
+#  define	iowrite32_native	fake_iowrite32_native
+
+static inline uint16_t
+ioread16_native(const void __iomem *ptr)
+{
+	uint16_t v;
+
+	v = *(const uint16_t __iomem *)ptr;
+	membar_consumer();
+
+	return htole16(v);
+}
+
+static inline uint32_t
+ioread32_native(const void __iomem *ptr)
+{
+	uint32_t v;
+
+	v = *(const uint32_t __iomem *)ptr;
+	membar_consumer();
+
+	return htole32(v);
+}
+
+static inline uint16_t
+iowrite16_native(uint16_t v, const void __iomem *ptr)
+{
+
+	membar_producer();
+	*(const uint16_t __iomem *)ptr = le16toh(v);
+}
+
+static inline uint32_t
+iowrite32_native(uint32_t v, const void __iomem *ptr)
+{
+
+	membar_producer();
+	*(const uint32_t __iomem *)ptr = le32toh(v);
+}
+#endif
+
 u16
 nouveau_bo_rd16(struct nouveau_bo *nvbo, unsigned index)
 {
@@ -468,6 +520,14 @@ nouveau_bo_wr32(struct nouveau_bo *nvbo,
 		*mem = val;
 }
 
+#ifdef __NetBSD__
+#  undef	__iomem
+#  undef	ioread16_native
+#  undef	ioread32_native
+#  undef	iowrite16_native
+#  undef	iowrite32_native
+#endif
+
 static struct ttm_tt *
 nouveau_ttm_tt_create(struct ttm_bo_device *bdev, unsigned long size,
 		      uint32_t page_flags, struct page *dummy_read)
@@ -1345,6 +1405,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *t
 	if (ttm->state != tt_unpopulated)
 		return 0;
 
+#ifdef __NetBSD__		/* XXX drm prime */
 	if (slave && ttm->sg) {
 		/* make userspace faulting work */
 		drm_prime_sg_to_page_addr_arrays(ttm->sg, ttm->pages,
@@ -1352,6 +1413,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *t
 		ttm->state = tt_unbound;
 		return 0;
 	}
+#endif
 
 	drm = nouveau_bdev(ttm->bdev);
 	device = nv_device(drm->device);
@@ -1363,6 +1425,9 @@ nouveau_ttm_tt_populate(struct ttm_tt *t
 	}
 #endif
 
+#ifdef __NetBSD__
+	return ttm_bus_dma_populate(ttm_dma);
+#else
 #ifdef CONFIG_SWIOTLB
 	if (swiotlb_nr_tbl()) {
 		return ttm_dma_populate((void *)ttm, dev->dev);
@@ -1388,6 +1453,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *t
 		}
 	}
 	return 0;
+#endif
 }
 
 static void
@@ -1397,7 +1463,9 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt 
 	struct nouveau_drm *drm;
 	struct nouveau_device *device;
 	struct drm_device *dev;
+#ifndef __NetBSD__
 	unsigned i;
+#endif
 	bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG);
 
 	if (slave)
@@ -1414,6 +1482,9 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt 
 	}
 #endif
 
+#ifdef __NetBSD__
+	ttm_bus_dma_unpopulate(ttm_dma);
+#else
 #ifdef CONFIG_SWIOTLB
 	if (swiotlb_nr_tbl()) {
 		ttm_dma_unpopulate((void *)ttm, dev->dev);
@@ -1428,6 +1499,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt 
 	}
 
 	ttm_pool_unpopulate(ttm);
+#endif
 }
 
 void
Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_chan.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_chan.c:1.1.1.2 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_chan.c:1.2
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_chan.c:1.1.1.2	Wed Aug  6 12:36:23 2014
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_chan.c	Wed Aug  6 13:35:13 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_chan.c,v 1.1.1.2 2014/08/06 12:36:23 riastradh Exp $	*/
+/*	$NetBSD: nouveau_chan.c,v 1.2 2014/08/06 13:35:13 riastradh Exp $	*/
 
 /*
  * Copyright 2012 Red Hat Inc.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_chan.c,v 1.1.1.2 2014/08/06 12:36:23 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_chan.c,v 1.2 2014/08/06 13:35:13 riastradh Exp $");
 
 #include <core/object.h>
 #include <core/client.h>
@@ -100,7 +100,8 @@ nouveau_channel_prep(struct nouveau_drm 
 	struct nouveau_vmmgr *vmm = nouveau_vmmgr(device);
 	struct nouveau_fb *pfb = nouveau_fb(device);
 	struct nouveau_client *client = &cli->base;
-	struct nv_dma_class args = {};
+	static const struct nv_dma_class zero_args;
+	struct nv_dma_class args = zero_args;
 	struct nouveau_channel *chan;
 	struct nouveau_object *push;
 	u32 target;
@@ -275,7 +276,8 @@ nouveau_channel_init(struct nouveau_chan
 	struct nouveau_fb *pfb = nouveau_fb(device);
 	struct nouveau_software_chan *swch;
 	struct nouveau_object *object;
-	struct nv_dma_class args = {};
+	static const struct nv_dma_class zero_args;
+	struct nv_dma_class args = zero_args;
 	int ret, i;
 
 	/* allocate dma objects to cover all allowed vram, and gart */
Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c:1.1.1.2 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c:1.2
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c:1.1.1.2	Wed Aug  6 12:36:23 2014
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c	Wed Aug  6 13:35:13 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_fence.c,v 1.1.1.2 2014/08/06 12:36:23 riastradh Exp $	*/
+/*	$NetBSD: nouveau_fence.c,v 1.2 2014/08/06 13:35:13 riastradh Exp $	*/
 
 /*
  * Copyright (C) 2007 Ben Skeggs.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_fence.c,v 1.1.1.2 2014/08/06 12:36:23 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_fence.c,v 1.2 2014/08/06 13:35:13 riastradh Exp $");
 
 #include <drm/drmP.h>
 
@@ -174,7 +174,14 @@ static int
 nouveau_fence_wait_uevent_handler(void *data, int index)
 {
 	struct nouveau_fence_priv *priv = data;
+#ifdef __NetBSD__
+	spin_lock(&priv->waitlock);
+	/* XXX Set a flag...  */
+	DRM_SPIN_WAKEUP_ALL(&priv->waitqueue, &priv->waitlock);
+	spin_unlock(&priv->waitlock);
+#else
 	wake_up_all(&priv->waiting);
+#endif
 	return NVKM_EVENT_KEEP;
 }
 
@@ -200,6 +207,21 @@ nouveau_fence_wait_uevent(struct nouveau
 		unsigned long timeout = fence->timeout - jiffies;
 
 		if (time_before(jiffies, fence->timeout)) {
+#ifdef __NetBSD__
+			spin_lock(&priv->waitlock);
+			if (intr) {
+				DRM_SPIN_TIMED_WAIT_UNITL(ret,
+				    &priv->waitqueue, &priv->waitlock,
+				    timeout,
+				    nouveau_fence_done(fence));
+			} else {
+				DRM_SPIN_TIMED_WAIT_NOINTR_UNITL(ret,
+				    &priv->waitqueue, &priv->waitlock,
+				    timeout,
+				    nouveau_fence_done(fence));
+			}
+			spin_unlock(&priv->waitlock);
+#else
 			if (intr) {
 				ret = wait_event_interruptible_timeout(
 						priv->waiting,
@@ -210,6 +232,7 @@ nouveau_fence_wait_uevent(struct nouveau
 						nouveau_fence_done(fence),
 						timeout);
 			}
+#endif
 		}
 
 		if (ret >= 0) {
@@ -218,12 +241,26 @@ nouveau_fence_wait_uevent(struct nouveau
 				ret = -EBUSY;
 		}
 	} else {
+#ifdef __NetBSD__
+		spin_lock(&priv->waitlock);
+		if (intr) {
+			DRM_SPIN_WAIT_UNTIL(ret, &priv->waitqueue,
+			    &priv->waitlock,
+			    nouveau_fence_done(fence));
+		} else {
+			DRM_SPIN_WAIT_NOINTR_UNTIL(ret, &priv->waitqueue,
+			    &priv->waitlock,
+			    nouveau_fence_done(fence));
+		}
+		spin_unlock(&priv->waitlock);
+#else
 		if (intr) {
 			ret = wait_event_interruptible(priv->waiting,
 					nouveau_fence_done(fence));
 		} else {
 			wait_event(priv->waiting, nouveau_fence_done(fence));
 		}
+#endif
 	}
 
 	nouveau_event_ref(NULL, &handler);
@@ -254,6 +291,12 @@ nouveau_fence_wait(struct nouveau_fence 
 			break;
 		}
 
+#ifdef __NetBSD__
+		if (lazy)
+			kpause("nvfencep", intr, 1, NULL);
+		else
+			DELAY(1);
+#else
 		__set_current_state(intr ? TASK_INTERRUPTIBLE :
 					   TASK_UNINTERRUPTIBLE);
 		if (lazy) {
@@ -268,9 +311,12 @@ nouveau_fence_wait(struct nouveau_fence 
 			ret = -ERESTARTSYS;
 			break;
 		}
+#endif
 	}
 
+#ifndef __NetBSD__
 	__set_current_state(TASK_RUNNING);
+#endif
 	return ret;
 }
 
Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_ttm.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_ttm.c:1.1.1.2 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_ttm.c:1.2
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_ttm.c:1.1.1.2	Wed Aug  6 12:36:23 2014
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_ttm.c	Wed Aug  6 13:35:13 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_ttm.c,v 1.1.1.2 2014/08/06 12:36:23 riastradh Exp $	*/
+/*	$NetBSD: nouveau_ttm.c,v 1.2 2014/08/06 13:35:13 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2007-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA,
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_ttm.c,v 1.1.1.2 2014/08/06 12:36:23 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_ttm.c,v 1.2 2014/08/06 13:35:13 riastradh Exp $");
 
 #include <subdev/fb.h>
 #include <subdev/vm.h>
@@ -369,6 +369,11 @@ nouveau_ttm_init(struct nouveau_drm *drm
 		     !pci_dma_supported(dev->pdev, DMA_BIT_MASK(bits)))
 			bits = 32;
 
+#ifdef __NetBSD__
+		ret = drm_limit_dma_space(dev, 0, DMA_BIT_MASK(bits));
+		if (ret)
+			return ret;
+#else
 		ret = pci_set_dma_mask(dev->pdev, DMA_BIT_MASK(bits));
 		if (ret)
 			return ret;
@@ -378,6 +383,7 @@ nouveau_ttm_init(struct nouveau_drm *drm
 		if (ret)
 			pci_set_consistent_dma_mask(dev->pdev,
 						    DMA_BIT_MASK(32));
+#endif
 	}
 
 	ret = nouveau_ttm_global_init(drm);
@@ -387,7 +393,12 @@ nouveau_ttm_init(struct nouveau_drm *drm
 	ret = ttm_bo_device_init(&drm->ttm.bdev,
 				  drm->ttm.bo_global_ref.ref.object,
 				  &nouveau_bo_driver,
+#ifdef __NetBSD__
+				  dev->bst,
+				  dev->dmat,
+#else
 				  dev->anon_inode->i_mapping,
+#endif
 				  DRM_FILE_PAGE_OFFSET,
 				  bits <= 32 ? true : false);
 	if (ret) {

Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_bo.h
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_bo.h:1.1.1.1 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_bo.h:1.2
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_bo.h:1.1.1.1	Wed Jul 16 19:35:26 2014
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_bo.h	Wed Aug  6 13:35:13 2014
@@ -89,6 +89,11 @@ int  nouveau_bo_vma_add(struct nouveau_b
 			struct nouveau_vma *);
 void nouveau_bo_vma_del(struct nouveau_bo *, struct nouveau_vma *);
 
+#ifdef __NetBSD__
+#  define	__iomem	volatile
+#  define	__force
+#endif
+
 /* TODO: submit equivalent to TTM generic API upstream? */
 static inline void __iomem *
 nvbo_kmap_obj_iovirtual(struct nouveau_bo *nvbo)
@@ -100,4 +105,9 @@ nvbo_kmap_obj_iovirtual(struct nouveau_b
 	return ioptr;
 }
 
+#ifdef __NetBSD__
+#  undef	__iomem
+#  undef	__force
+#endif
+
 #endif
Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.h
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.h:1.1.1.1 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.h:1.2
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.h:1.1.1.1	Wed Jul 16 19:35:26 2014
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.h	Wed Aug  6 13:35:13 2014
@@ -49,7 +49,12 @@ struct nouveau_fence_priv {
 	int  (*context_new)(struct nouveau_channel *);
 	void (*context_del)(struct nouveau_channel *);
 
+#ifdef __NetBSD__
+	spinlock_t waitlock;
+	drm_waitqueue_t waitqueue;
+#else
 	wait_queue_head_t waiting;
+#endif
 	bool uevent;
 };
 

Index: src/sys/external/bsd/drm2/dist/drm/nouveau/core/os.h
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/core/os.h:1.1.1.1 src/sys/external/bsd/drm2/dist/drm/nouveau/core/os.h:1.2
--- src/sys/external/bsd/drm2/dist/drm/nouveau/core/os.h:1.1.1.1	Thu Jul 17 01:50:57 2014
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/core/os.h	Wed Aug  6 13:35:13 2014
@@ -21,6 +21,12 @@
 #include <linux/interrupt.h>
 #include <linux/log2.h>
 #include <linux/pm_runtime.h>
+#include <linux/atomic.h>
+#include <linux/bug.h>
+#include <linux/kernel.h>
+#include <linux/kref.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
 
 #include <asm/unaligned.h>
 

Index: src/sys/external/bsd/drm2/dist/drm/nouveau/core/core/nouveau_core_handle.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/core/core/nouveau_core_handle.c:1.1.1.1 src/sys/external/bsd/drm2/dist/drm/nouveau/core/core/nouveau_core_handle.c:1.2
--- src/sys/external/bsd/drm2/dist/drm/nouveau/core/core/nouveau_core_handle.c:1.1.1.1	Wed Aug  6 12:36:23 2014
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/core/core/nouveau_core_handle.c	Wed Aug  6 13:35:13 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_core_handle.c,v 1.1.1.1 2014/08/06 12:36:23 riastradh Exp $	*/
+/*	$NetBSD: nouveau_core_handle.c,v 1.2 2014/08/06 13:35:13 riastradh Exp $	*/
 
 /*
  * Copyright 2012 Red Hat Inc.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_core_handle.c,v 1.1.1.1 2014/08/06 12:36:23 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_core_handle.c,v 1.2 2014/08/06 13:35:13 riastradh Exp $");
 
 #include <core/object.h>
 #include <core/handle.h>
@@ -70,7 +70,7 @@ fail:
 int
 nouveau_handle_fini(struct nouveau_handle *handle, bool suspend)
 {
-	static char *name[2] = { "fini", "suspend" };
+	static const char *name[2] = { "fini", "suspend" };
 	struct nouveau_handle *item;
 	int ret;
 
Index: src/sys/external/bsd/drm2/dist/drm/nouveau/core/core/nouveau_core_object.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/core/core/nouveau_core_object.c:1.1.1.1 src/sys/external/bsd/drm2/dist/drm/nouveau/core/core/nouveau_core_object.c:1.2
--- src/sys/external/bsd/drm2/dist/drm/nouveau/core/core/nouveau_core_object.c:1.1.1.1	Wed Aug  6 12:36:23 2014
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/core/core/nouveau_core_object.c	Wed Aug  6 13:35:13 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_core_object.c,v 1.1.1.1 2014/08/06 12:36:23 riastradh Exp $	*/
+/*	$NetBSD: nouveau_core_object.c,v 1.2 2014/08/06 13:35:13 riastradh Exp $	*/
 
 /*
  * Copyright 2012 Red Hat Inc.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_core_object.c,v 1.1.1.1 2014/08/06 12:36:23 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_core_object.c,v 1.2 2014/08/06 13:35:13 riastradh Exp $");
 
 #include <core/object.h>
 #include <core/parent.h>
@@ -35,8 +35,28 @@ __KERNEL_RCSID(0, "$NetBSD: nouveau_core
 
 #ifdef NOUVEAU_OBJECT_MAGIC
 static struct list_head _objlist = LIST_HEAD_INIT(_objlist);
+#ifdef __NetBSD__
+static spinlock_t _objlist_lock;
+#else
 static DEFINE_SPINLOCK(_objlist_lock);
 #endif
+#endif
+
+#ifdef __NetBSD__
+void
+nouveau_objects_init(void)
+{
+
+	spin_lock_init(&_objlist_lock);
+}
+
+void
+nouveau_objects_fini(void)
+{
+
+	spin_lock_destroy(&_objlist_lock);
+}
+#endif
 
 int
 nouveau_object_create_(struct nouveau_object *parent,

Index: src/sys/external/bsd/drm2/dist/drm/nouveau/core/include/core/object.h
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/core/include/core/object.h:1.1.1.1 src/sys/external/bsd/drm2/dist/drm/nouveau/core/include/core/object.h:1.2
--- src/sys/external/bsd/drm2/dist/drm/nouveau/core/include/core/object.h:1.1.1.1	Thu Jul 17 01:50:59 2014
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/core/include/core/object.h	Wed Aug  6 13:35:13 2014
@@ -40,6 +40,11 @@ nv_object(void *obj)
 	return obj;
 }
 
+#ifdef __NetBSD__
+void	nouveau_objcets_init(void);
+void	nouveau_objects_fini(void);
+#endif
+
 #define nouveau_object_create(p,e,c,s,d)                                       \
 	nouveau_object_create_((p), (e), (c), (s), sizeof(**d), (void **)d)
 int  nouveau_object_create_(struct nouveau_object *, struct nouveau_object *,
@@ -136,7 +141,7 @@ static inline u8
 nv_ro08(void *obj, u64 addr)
 {
 	u8 data = nv_ofuncs(obj)->rd08(obj, addr);
-	nv_spam(obj, "nv_ro08 0x%08llx 0x%02x\n", addr, data);
+	nv_spam(obj, "nv_ro08 0x%08"PRIx64" 0x%02x\n", addr, data);
 	return data;
 }
 
@@ -144,7 +149,7 @@ static inline u16
 nv_ro16(void *obj, u64 addr)
 {
 	u16 data = nv_ofuncs(obj)->rd16(obj, addr);
-	nv_spam(obj, "nv_ro16 0x%08llx 0x%04x\n", addr, data);
+	nv_spam(obj, "nv_ro16 0x%08"PRIx64" 0x%04x\n", addr, data);
 	return data;
 }
 
@@ -152,28 +157,28 @@ static inline u32
 nv_ro32(void *obj, u64 addr)
 {
 	u32 data = nv_ofuncs(obj)->rd32(obj, addr);
-	nv_spam(obj, "nv_ro32 0x%08llx 0x%08x\n", addr, data);
+	nv_spam(obj, "nv_ro32 0x%08"PRIx64" 0x%08x\n", addr, data);
 	return data;
 }
 
 static inline void
 nv_wo08(void *obj, u64 addr, u8 data)
 {
-	nv_spam(obj, "nv_wo08 0x%08llx 0x%02x\n", addr, data);
+	nv_spam(obj, "nv_wo08 0x%08"PRIx64" 0x%02x\n", addr, data);
 	nv_ofuncs(obj)->wr08(obj, addr, data);
 }
 
 static inline void
 nv_wo16(void *obj, u64 addr, u16 data)
 {
-	nv_spam(obj, "nv_wo16 0x%08llx 0x%04x\n", addr, data);
+	nv_spam(obj, "nv_wo16 0x%08"PRIx64" 0x%04x\n", addr, data);
 	nv_ofuncs(obj)->wr16(obj, addr, data);
 }
 
 static inline void
 nv_wo32(void *obj, u64 addr, u32 data)
 {
-	nv_spam(obj, "nv_wo32 0x%08llx 0x%08x\n", addr, data);
+	nv_spam(obj, "nv_wo32 0x%08"PRIx64" 0x%08x\n", addr, data);
 	nv_ofuncs(obj)->wr32(obj, addr, data);
 }
 
Index: src/sys/external/bsd/drm2/dist/drm/nouveau/core/include/core/subdev.h
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/core/include/core/subdev.h:1.1.1.1 src/sys/external/bsd/drm2/dist/drm/nouveau/core/include/core/subdev.h:1.2
--- src/sys/external/bsd/drm2/dist/drm/nouveau/core/include/core/subdev.h:1.1.1.1	Thu Jul 17 01:50:59 2014
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/core/include/core/subdev.h	Wed Aug  6 13:35:13 2014
@@ -10,7 +10,13 @@ struct nouveau_subdev {
 	struct nouveau_object base;
 	struct mutex mutex;
 	const char *name;
+#ifdef __NetBSD__
+	bus_space_tag_t mmiot;
+	bus_space_handle_t mmioh;
+	bus_size_t mmiosz;
+#else
 	void __iomem *mmio;
+#endif
 	u32 debug;
 	u32 unit;
 
@@ -60,7 +66,11 @@ static inline u8
 nv_rd08(void *obj, u32 addr)
 {
 	struct nouveau_subdev *subdev = nv_subdev(obj);
+#ifdef __NetBSD__
+	u8 data = bus_space_read_stream_1(subdev->mmiot, subdev->mmioh, addr);
+#else
 	u8 data = ioread8(subdev->mmio + addr);
+#endif
 	nv_spam(subdev, "nv_rd08 0x%06x 0x%02x\n", addr, data);
 	return data;
 }
@@ -69,7 +79,11 @@ static inline u16
 nv_rd16(void *obj, u32 addr)
 {
 	struct nouveau_subdev *subdev = nv_subdev(obj);
+#ifdef __NetBSD__
+	u16 data = bus_space_read_stream_2(subdev->mmiot, subdev->mmioh, addr);
+#else
 	u16 data = ioread16_native(subdev->mmio + addr);
+#endif
 	nv_spam(subdev, "nv_rd16 0x%06x 0x%04x\n", addr, data);
 	return data;
 }
@@ -78,7 +92,11 @@ static inline u32
 nv_rd32(void *obj, u32 addr)
 {
 	struct nouveau_subdev *subdev = nv_subdev(obj);
+#ifdef __NetBSD__
+	u32 data = bus_space_read_stream_4(subdev->mmiot, subdev->mmioh, addr);
+#else
 	u32 data = ioread32_native(subdev->mmio + addr);
+#endif
 	nv_spam(subdev, "nv_rd32 0x%06x 0x%08x\n", addr, data);
 	return data;
 }
@@ -88,7 +106,11 @@ nv_wr08(void *obj, u32 addr, u8 data)
 {
 	struct nouveau_subdev *subdev = nv_subdev(obj);
 	nv_spam(subdev, "nv_wr08 0x%06x 0x%02x\n", addr, data);
+#ifdef __NetBSD__
+	bus_space_write_stream_1(subdev->mmiot, subdev->mmioh, addr, data);
+#else
 	iowrite8(data, subdev->mmio + addr);
+#endif
 }
 
 static inline void
@@ -96,7 +118,11 @@ nv_wr16(void *obj, u32 addr, u16 data)
 {
 	struct nouveau_subdev *subdev = nv_subdev(obj);
 	nv_spam(subdev, "nv_wr16 0x%06x 0x%04x\n", addr, data);
+#ifdef __NetBSD__
+	bus_space_write_stream_2(subdev->mmiot, subdev->mmioh, addr, data);
+#else
 	iowrite16_native(data, subdev->mmio + addr);
+#endif
 }
 
 static inline void
@@ -104,7 +130,11 @@ nv_wr32(void *obj, u32 addr, u32 data)
 {
 	struct nouveau_subdev *subdev = nv_subdev(obj);
 	nv_spam(subdev, "nv_wr32 0x%06x 0x%08x\n", addr, data);
+#ifdef __NetBSD__
+	bus_space_write_stream_4(subdev->mmiot, subdev->mmioh, addr, data);
+#else
 	iowrite32_native(data, subdev->mmio + addr);
+#endif
 }
 
 static inline u32

Index: src/sys/external/bsd/drm2/dist/drm/nouveau/core/include/subdev/bar.h
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/core/include/subdev/bar.h:1.1.1.1 src/sys/external/bsd/drm2/dist/drm/nouveau/core/include/subdev/bar.h:1.2
--- src/sys/external/bsd/drm2/dist/drm/nouveau/core/include/subdev/bar.h:1.1.1.1	Thu Jul 17 01:50:59 2014
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/core/include/subdev/bar.h	Wed Aug  6 13:35:13 2014
@@ -12,7 +12,12 @@ struct nouveau_bar {
 
 	int (*alloc)(struct nouveau_bar *, struct nouveau_object *,
 		     struct nouveau_mem *, struct nouveau_object **);
+#ifdef __NetBSD__
+	bus_space_tag_t bst;
+	bus_space_handle_t bsh;
+#else
 	void __iomem *iomem;
+#endif
 
 	int (*kmap)(struct nouveau_bar *, struct nouveau_mem *,
 		    u32 flags, struct nouveau_vma *);

Reply via email to