Module Name:    src
Committed By:   riastradh
Date:           Wed Feb 25 14:57:05 UTC 2015

Modified Files:
        src/sys/external/bsd/drm2/dist/drm/nouveau: nouveau_nv50_display.c
            nouveau_nv84_fence.c
        src/sys/external/bsd/drm2/dist/drm/nouveau/core: os.h
        src/sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/bios:
            nouveau_subdev_bios_base.c
        src/sys/external/bsd/drm2/nouveau: files.nouveau

Log Message:
Another round of nouveau whack-a-mole.

Derived from a patch by chs@.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
    src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_nv50_display.c
cvs rdiff -u -r1.1.1.1 -r1.2 \
    src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_nv84_fence.c
cvs rdiff -u -r1.3 -r1.4 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/subdev/bios/nouveau_subdev_bios_base.c
cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/drm2/nouveau/files.nouveau

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_nv50_display.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_nv50_display.c:1.2 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_nv50_display.c:1.3
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_nv50_display.c:1.2	Sat Aug 23 08:03:33 2014
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_nv50_display.c	Wed Feb 25 14:57:04 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_nv50_display.c,v 1.2 2014/08/23 08:03:33 riastradh Exp $	*/
+/*	$NetBSD: nouveau_nv50_display.c,v 1.3 2015/02/25 14:57:04 riastradh Exp $	*/
 
 	/*
  * Copyright 2011 Red Hat Inc.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_nv50_display.c,v 1.2 2014/08/23 08:03:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_nv50_display.c,v 1.3 2015/02/25 14:57:04 riastradh Exp $");
 
 #include <linux/dma-mapping.h>
 #include <linux/err.h>
@@ -51,6 +51,37 @@ __KERNEL_RCSID(0, "$NetBSD: nouveau_nv50
 #include <subdev/fb.h>
 #include <subdev/i2c.h>
 
+#ifdef __NetBSD__
+/*
+ * XXX Can't use bus_space here because this is all mapped through the
+ * nvbo_kmap abstraction.  Can't assume we're x86 because this is
+ * Nouveau, not Intel.
+ */
+
+#  define	__iomem		volatile
+#  define	readw		fake_readw
+#  define	writew		fake_writew
+
+static inline uint32_t
+fake_readw(const void __iomem *ptr)
+{
+	uint16_t v;
+
+	v = *(const uint16_t __iomem *)ptr;
+	membar_consumer();
+
+	return v;
+}
+
+static inline void
+fake_writew(uint16_t v, void __iomem *ptr)
+{
+
+	membar_producer();
+	*(uint16_t __iomem *)ptr = v;
+}
+#endif
+
 #define EVO_DMA_NR 9
 
 #define EVO_MASTER  (0x00)
@@ -151,17 +182,18 @@ static void
 nv50_dmac_destroy(struct nouveau_object *core, struct nv50_dmac *dmac)
 {
 	if (dmac->ptr) {
+		struct pci_dev *pdev = nv_device(core)->pdev;
 #ifdef __NetBSD__
-		const bus_dma_tag_t dmat = nv_device(core)->dmat;
+		/* XXX pa_dmat or pa_dmat64? */
+		const bus_dma_tag_t dmat = pdev->pd_pa.pa_dmat64;
 
-		bus_dmamem_unload(dmat, dmac->dmamap);
+		bus_dmamap_unload(dmat, dmac->dmamap);
 		bus_dmamem_unmap(dmat, dmac->dmakva, PAGE_SIZE);
 		bus_dmamap_destroy(dmat, dmac->dmamap);
 		bus_dmamem_free(dmat, &dmac->dmaseg, 1);
 		dmac->handle = 0;
 		dmac->ptr = NULL;
 #else
-		struct pci_dev *pdev = nv_device(core)->pdev;
 		pci_free_consistent(pdev, PAGE_SIZE, dmac->ptr, dmac->handle);
 #endif
 	}
@@ -311,7 +343,7 @@ nv50_dmac_create(struct nouveau_object *
 
 #ifdef __NetBSD__
     {
-	const bus_dma_tag_t dmat = nv_device(core)->dmat;
+	const bus_dma_tag_t dmat = nv_device(core)->pdev->pd_pa.pa_dmat64;
 	int rsegs;
 
 	/* XXX errno NetBSD->Linux */
@@ -336,7 +368,7 @@ nv50_dmac_create(struct nouveau_object *
 		return ret;
 	}
 	ret = -bus_dmamap_load(dmat, dmac->dmamap, dmac->dmakva, PAGE_SIZE,
-	    BUS_DMA_WAITOK);
+	    NULL, BUS_DMA_WAITOK);
 	if (ret) {
 		bus_dmamem_unmap(dmat, dmac->dmakva, PAGE_SIZE);
 		bus_dmamap_destroy(dmat, dmac->dmamap);
@@ -1262,13 +1294,13 @@ nv50_crtc_lut_load(struct drm_crtc *crtc
 		u16 b = nv_crtc->lut.b[i] >> 2;
 
 		if (nv_mclass(disp->core) < NVD0_DISP_CLASS) {
-			writew(r + 0x0000, lut + (i * 0x08) + 0);
-			writew(g + 0x0000, lut + (i * 0x08) + 2);
-			writew(b + 0x0000, lut + (i * 0x08) + 4);
+			writew(r + 0x0000, (char __iomem *)lut + (i * 0x08) + 0);
+			writew(g + 0x0000, (char __iomem *)lut + (i * 0x08) + 2);
+			writew(b + 0x0000, (char __iomem *)lut + (i * 0x08) + 4);
 		} else {
-			writew(r + 0x6000, lut + (i * 0x20) + 0);
-			writew(g + 0x6000, lut + (i * 0x20) + 2);
-			writew(b + 0x6000, lut + (i * 0x20) + 4);
+			writew(r + 0x6000, (char __iomem *)lut + (i * 0x20) + 0);
+			writew(g + 0x6000, (char __iomem *)lut + (i * 0x20) + 2);
+			writew(b + 0x6000, (char __iomem *)lut + (i * 0x20) + 4);
 		}
 	}
 }

Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_nv84_fence.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_nv84_fence.c:1.1.1.1 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_nv84_fence.c:1.2
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_nv84_fence.c:1.1.1.1	Wed Aug  6 12:36:23 2014
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_nv84_fence.c	Wed Feb 25 14:57:04 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_nv84_fence.c,v 1.1.1.1 2014/08/06 12:36:23 riastradh Exp $	*/
+/*	$NetBSD: nouveau_nv84_fence.c,v 1.2 2015/02/25 14:57:04 riastradh Exp $	*/
 
 /*
  * Copyright 2012 Red Hat Inc.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_nv84_fence.c,v 1.1.1.1 2014/08/06 12:36:23 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_nv84_fence.c,v 1.2 2015/02/25 14:57:04 riastradh Exp $");
 
 #include <core/object.h>
 #include <core/client.h>
@@ -215,6 +215,12 @@ static void
 nv84_fence_destroy(struct nouveau_drm *drm)
 {
 	struct nv84_fence_priv *priv = drm->fence;
+
+#ifdef __NetBSD__
+	spin_lock_destroy(&priv->base.waitlock);
+	DRM_DESTROY_WAITQUEUE(&priv->base.waitqueue);
+#endif
+
 	nouveau_bo_unmap(priv->bo_gart);
 	if (priv->bo_gart)
 		nouveau_bo_unpin(priv->bo_gart);
@@ -244,7 +250,12 @@ nv84_fence_create(struct nouveau_drm *dr
 	priv->base.context_new = nv84_fence_context_new;
 	priv->base.context_del = nv84_fence_context_del;
 
+#ifdef __NetBSD__
+	spin_lock_init(&priv->base.waitlock);
+	DRM_INIT_WAITQUEUE(&priv->base.waitqueue, "nvfenceq");
+#else
 	init_waitqueue_head(&priv->base.waiting);
+#endif
 	priv->base.uevent = true;
 
 	ret = nouveau_bo_new(drm->dev, 16 * (pfifo->max + 1), 0,

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.3 src/sys/external/bsd/drm2/dist/drm/nouveau/core/os.h:1.4
--- src/sys/external/bsd/drm2/dist/drm/nouveau/core/os.h:1.3	Wed Aug  6 15:01:33 2014
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/core/os.h	Wed Feb 25 14:57:05 2015
@@ -28,6 +28,8 @@
 #include <linux/list.h>
 #include <linux/spinlock.h>
 
+#include <asm/byteorder.h>
+#include <asm/io.h>
 #include <asm/unaligned.h>
 
 #ifndef __NetBSD__		/* XXX ioread */

Index: src/sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/bios/nouveau_subdev_bios_base.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/bios/nouveau_subdev_bios_base.c:1.1.1.1 src/sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/bios/nouveau_subdev_bios_base.c:1.2
--- src/sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/bios/nouveau_subdev_bios_base.c:1.1.1.1	Wed Aug  6 12:36:28 2014
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/bios/nouveau_subdev_bios_base.c	Wed Feb 25 14:57:05 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_subdev_bios_base.c,v 1.1.1.1 2014/08/06 12:36:28 riastradh Exp $	*/
+/*	$NetBSD: nouveau_subdev_bios_base.c,v 1.2 2015/02/25 14:57:05 riastradh Exp $	*/
 
 /*
  * Copyright 2012 Red Hat Inc.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_subdev_bios_base.c,v 1.1.1.1 2014/08/06 12:36:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_subdev_bios_base.c,v 1.2 2015/02/25 14:57:05 riastradh Exp $");
 
 #include <core/object.h>
 #include <core/device.h>
@@ -262,6 +262,10 @@ nouveau_bios_shadow_acpi(struct nouveau_
 	}
 }
 
+#ifdef __NetBSD__
+#  define	__iomem	__pci_rom_iomem
+#endif
+
 static void
 nouveau_bios_shadow_pci(struct nouveau_bios *bios)
 {
@@ -300,6 +304,10 @@ nouveau_bios_shadow_platform(struct nouv
 	}
 }
 
+#ifdef __NetBSD__
+#  undef	__iomem
+#endif
+
 static int
 nouveau_bios_score(struct nouveau_bios *bios, const bool writeable)
 {

Index: src/sys/external/bsd/drm2/nouveau/files.nouveau
diff -u src/sys/external/bsd/drm2/nouveau/files.nouveau:1.4 src/sys/external/bsd/drm2/nouveau/files.nouveau:1.5
--- src/sys/external/bsd/drm2/nouveau/files.nouveau:1.4	Wed Dec  3 22:59:22 2014
+++ src/sys/external/bsd/drm2/nouveau/files.nouveau	Wed Feb 25 14:57:04 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: files.nouveau,v 1.4 2014/12/03 22:59:22 riastradh Exp $
+#	$NetBSD: files.nouveau,v 1.5 2015/02/25 14:57:04 riastradh Exp $
 
 device	nouveau: drmkms, drmkms_pci, drmkms_ttm, genfb, wsemuldisplaydev
 attach	nouveau at pci
@@ -112,7 +112,9 @@ makeoptions	nouveau	"CWARNFLAGS.nouveau_
 makeoptions	nouveau	"CWARNFLAGS.nouveau_engine_vp_nvc0.c"+="-Wno-missing-field-initializers"
 makeoptions	nouveau	"CWARNFLAGS.nouveau_engine_vp_nve0.c"+="-Wno-missing-field-initializers"
 makeoptions	nouveau	"CWARNFLAGS.nouveau_nv50_fence.c"+="-Wno-shadow"
+makeoptions	nouveau	"CWARNFLAGS.nouveau_nv50_display.c"+="-Wno-unused-but-set-variable"
 makeoptions	nouveau	"CWARNFLAGS.nouveau_subdev_bar_base.c"+="-Wno-missing-field-initializers"
+makeoptions	nouveau	"CWARNFLAGS.nouveau_subdev_bar_nv50.c"+="-Wno-missing-field-initializers"
 makeoptions	nouveau	"CWARNFLAGS.nouveau_subdev_bar_nvc0.c"+="-Wno-missing-field-initializers"
 
 file	external/bsd/drm2/nouveau/nouveau_module.c	nouveau

Reply via email to