Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2 Another round of nouveau whack-a-mole.



details:   https://anonhg.NetBSD.org/src/rev/879ee36e9cd5
branches:  trunk
changeset: 806471:879ee36e9cd5
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Feb 25 22:11:59 2015 +0000

description:
Another round of nouveau whack-a-mole.

Nouveau compiles now, though it doesn't link yet.

Need to write driver attachment, wscons framebuffer, &c.  Probably
also some i2c stuff.

diffstat:

 sys/external/bsd/drm2/dist/drm/nouveau/core/include/subdev/pwr.h                     |   2 +-
 sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/pwr/nouveau_subdev_pwr_base.c     |   6 +-
 sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/therm/nouveau_subdev_therm_ic.c   |   8 +-
 sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/timer/nouveau_subdev_timer_nv04.c |   6 +-
 sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/vm/nouveau_subdev_vm_base.c       |  54 +++++++++-
 sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/vm/nouveau_subdev_vm_nv04.c       |  17 ++-
 sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/vm/nouveau_subdev_vm_nv44.c       |  47 ++++++++-
 sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/vm/nv04.h                         |   4 +
 sys/external/bsd/drm2/dist/drm/nouveau/nouveau_ttm.c                                 |  31 +++++-
 sys/external/bsd/drm2/dist/drm/nouveau/nouveau_ttm.h                                 |   5 +
 sys/external/bsd/drm2/nouveau/files.nouveau                                          |  15 ++-
 11 files changed, 173 insertions(+), 22 deletions(-)

diffs (truncated from 447 to 300 lines):

diff -r cc91563a070c -r 879ee36e9cd5 sys/external/bsd/drm2/dist/drm/nouveau/core/include/subdev/pwr.h
--- a/sys/external/bsd/drm2/dist/drm/nouveau/core/include/subdev/pwr.h  Wed Feb 25 21:55:30 2015 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/core/include/subdev/pwr.h  Wed Feb 25 22:11:59 2015 +0000
@@ -66,7 +66,7 @@
 int nouveau_pwr_create_(struct nouveau_object *, struct nouveau_object *,
                           struct nouveau_oclass *, int, void **);
 #ifdef __NetBSD__
-int _nouveau_pwr_dtor(struct nouveau_object *);
+void _nouveau_pwr_dtor(struct nouveau_object *);
 #else
 #define _nouveau_pwr_dtor _nouveau_subdev_dtor
 #endif
diff -r cc91563a070c -r 879ee36e9cd5 sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/pwr/nouveau_subdev_pwr_base.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/pwr/nouveau_subdev_pwr_base.c  Wed Feb 25 21:55:30 2015 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/pwr/nouveau_subdev_pwr_base.c  Wed Feb 25 22:11:59 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nouveau_subdev_pwr_base.c,v 1.3 2015/02/25 17:29:43 riastradh Exp $    */
+/*     $NetBSD: nouveau_subdev_pwr_base.c,v 1.4 2015/02/25 22:12:00 riastradh Exp $    */
 
 /*
  * Copyright 2013 Red Hat Inc.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_subdev_pwr_base.c,v 1.3 2015/02/25 17:29:43 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_subdev_pwr_base.c,v 1.4 2015/02/25 22:12:00 riastradh Exp $");
 
 #include <subdev/pwr.h>
 #include <subdev/timer.h>
@@ -271,7 +271,7 @@
 }
 
 #ifdef __NetBSD__
-int
+void
 _nouveau_pwr_dtor(struct nouveau_object *object)
 {
        struct nouveau_pwr *ppwr = (void *)object;
diff -r cc91563a070c -r 879ee36e9cd5 sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/therm/nouveau_subdev_therm_ic.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/therm/nouveau_subdev_therm_ic.c        Wed Feb 25 21:55:30 2015 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/therm/nouveau_subdev_therm_ic.c        Wed Feb 25 22:11:59 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nouveau_subdev_therm_ic.c,v 1.1.1.1 2014/08/06 12:36:32 riastradh Exp $        */
+/*     $NetBSD: nouveau_subdev_therm_ic.c,v 1.2 2015/02/25 22:12:00 riastradh Exp $    */
 
 /*
  * Copyright 2012 Nouveau community
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_subdev_therm_ic.c,v 1.1.1.1 2014/08/06 12:36:32 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_subdev_therm_ic.c,v 1.2 2015/02/25 22:12:00 riastradh Exp $");
 
 #include "priv.h"
 
@@ -36,6 +36,9 @@
 probe_monitoring_device(struct nouveau_i2c_port *i2c,
                        struct i2c_board_info *info, void *data)
 {
+#ifdef __NetBSD__
+       return false;
+#else
        struct nouveau_therm_priv *priv = data;
        struct nvbios_therm_sensor *sensor = &priv->bios_sensor;
        struct i2c_client *client;
@@ -59,6 +62,7 @@
        priv->ic = client;
 
        return true;
+#endif
 }
 
 static struct nouveau_i2c_board_info
diff -r cc91563a070c -r 879ee36e9cd5 sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/timer/nouveau_subdev_timer_nv04.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/timer/nouveau_subdev_timer_nv04.c      Wed Feb 25 21:55:30 2015 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/timer/nouveau_subdev_timer_nv04.c      Wed Feb 25 22:11:59 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nouveau_subdev_timer_nv04.c,v 1.1.1.1 2014/08/06 12:36:32 riastradh Exp $      */
+/*     $NetBSD: nouveau_subdev_timer_nv04.c,v 1.2 2015/02/25 22:12:00 riastradh Exp $  */
 
 /*
  * Copyright 2012 Red Hat Inc.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_subdev_timer_nv04.c,v 1.1.1.1 2014/08/06 12:36:32 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_subdev_timer_nv04.c,v 1.2 2015/02/25 22:12:00 riastradh Exp $");
 
 #include "nv04.h"
 
@@ -49,7 +49,7 @@
        struct nv04_timer_priv *priv = (void *)ptimer;
        struct nouveau_alarm *alarm, *atemp;
        unsigned long flags;
-       LIST_HEAD(exec);
+       struct list_head exec = LIST_HEAD_INIT(exec);
 
        /* move any due alarms off the pending list */
        spin_lock_irqsave(&priv->lock, flags);
diff -r cc91563a070c -r 879ee36e9cd5 sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/vm/nouveau_subdev_vm_base.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/vm/nouveau_subdev_vm_base.c    Wed Feb 25 21:55:30 2015 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/vm/nouveau_subdev_vm_base.c    Wed Feb 25 22:11:59 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nouveau_subdev_vm_base.c,v 1.1.1.1 2014/08/06 12:36:32 riastradh Exp $ */
+/*     $NetBSD: nouveau_subdev_vm_base.c,v 1.2 2015/02/25 22:12:00 riastradh Exp $     */
 
 /*
  * Copyright 2010 Red Hat Inc.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_subdev_vm_base.c,v 1.1.1.1 2014/08/06 12:36:32 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_subdev_vm_base.c,v 1.2 2015/02/25 22:12:00 riastradh Exp $");
 
 #include <core/gpuobj.h>
 #include <core/mm.h>
@@ -77,6 +77,47 @@
        vmm->flush(vm);
 }
 
+#ifdef __NetBSD__
+
+static void
+nouveau_vm_map_dma(struct nouveau_vma *vma, u64 delta, u64 length,
+    struct nouveau_mem *mem)
+{
+       struct nouveau_vm *vm = vma->vm;
+       struct nouveau_vmmgr *vmm = vm->vmm;
+       int big = vma->node->type != vmm->spg_shift;
+       u32 offset = vma->node->offset + (delta >> 12);
+       u32 bits = vma->node->type - 12;
+       u32 num  = length >> vma->node->type;
+       u32 pde  = (offset >> vmm->pgt_bits) - vm->fpde;
+       u32 pte  = (offset & ((1 << vmm->pgt_bits) - 1)) >> bits;
+       u32 max  = 1 << (vmm->pgt_bits - bits);
+       unsigned seg;
+
+       for (seg = 0; seg < mem->pages->dm_nsegs; seg++) {
+               struct nouveau_gpuobj *pgt = vm->pgt[pde].obj[big];
+               dma_addr_t addr = mem->pages->dm_segs[seg].ds_addr;
+
+               KASSERT(mem->pages->dm_segs[seg].ds_len == PAGE_SIZE);
+               vmm->map_sg(vma, pgt, mem, pte, 1, &addr);
+               num--;
+               pte++;
+
+               if (num == 0)
+                       goto finish;
+
+               if (__predict_false(pte >= max)) {
+                       pde++;
+                       pte = 0;
+               }
+       }
+
+finish:
+       vmm->flush(vm);
+}
+
+#else
+
 static void
 nouveau_vm_map_sg_table(struct nouveau_vma *vma, u64 delta, u64 length,
                        struct nouveau_mem *mem)
@@ -173,9 +214,17 @@
        vmm->flush(vm);
 }
 
+#endif
+
 void
 nouveau_vm_map(struct nouveau_vma *vma, struct nouveau_mem *node)
 {
+#ifdef __NetBSD__
+       if (node->pages)
+               nouveau_vm_map_dma(vma, 0, node->size << 12, node);
+       else
+               nouveau_vm_map_at(vma, 0, node);
+#else
        if (node->sg)
                nouveau_vm_map_sg_table(vma, 0, node->size << 12, node);
        else
@@ -183,6 +232,7 @@
                nouveau_vm_map_sg(vma, 0, node->size << 12, node);
        else
                nouveau_vm_map_at(vma, 0, node);
+#endif
 }
 
 void
diff -r cc91563a070c -r 879ee36e9cd5 sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/vm/nouveau_subdev_vm_nv04.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/vm/nouveau_subdev_vm_nv04.c    Wed Feb 25 21:55:30 2015 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/vm/nouveau_subdev_vm_nv04.c    Wed Feb 25 22:11:59 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nouveau_subdev_vm_nv04.c,v 1.1.1.1 2014/08/06 12:36:32 riastradh Exp $ */
+/*     $NetBSD: nouveau_subdev_vm_nv04.c,v 1.2 2015/02/25 22:12:00 riastradh Exp $     */
 
 /*
  * Copyright 2012 Red Hat Inc.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_subdev_vm_nv04.c,v 1.1.1.1 2014/08/06 12:36:32 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_subdev_vm_nv04.c,v 1.2 2015/02/25 22:12:00 riastradh Exp $");
 
 #include <core/gpuobj.h>
 
@@ -137,10 +137,23 @@
                nouveau_gpuobj_ref(NULL, &priv->vm->pgt[0].obj[0]);
                nouveau_vm_ref(NULL, &priv->vm, NULL);
        }
+#ifdef __NetBSD__
+       if (priv->nullp) {
+               /* XXX pa_dmat or pa_dmat64?  */
+               struct nouveau_device *device = nv_device(priv);
+               const bus_dma_tag_t dmat = device->pdev->pd_pa.pa_dmat64;
+
+               bus_dmamap_unload(dmat, priv->nullmap);
+               bus_dmamem_unmap(dmat, priv->nullp, PAGE_SIZE);
+               bus_dmamap_destroy(dmat, priv->nullmap);
+               bus_dmamem_free(dmat, &priv->nullseg, 1);
+       }
+#else
        if (priv->nullp) {
                pci_free_consistent(nv_device(priv)->pdev, 16 * 1024,
                                    priv->nullp, priv->null);
        }
+#endif
        nouveau_vmmgr_destroy(&priv->base);
 }
 
diff -r cc91563a070c -r 879ee36e9cd5 sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/vm/nouveau_subdev_vm_nv44.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/vm/nouveau_subdev_vm_nv44.c    Wed Feb 25 21:55:30 2015 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/vm/nouveau_subdev_vm_nv44.c    Wed Feb 25 22:11:59 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nouveau_subdev_vm_nv44.c,v 1.1.1.1 2014/08/06 12:36:32 riastradh Exp $ */
+/*     $NetBSD: nouveau_subdev_vm_nv44.c,v 1.2 2015/02/25 22:12:00 riastradh Exp $     */
 
 /*
  * Copyright 2012 Red Hat Inc.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_subdev_vm_nv44.c,v 1.1.1.1 2014/08/06 12:36:32 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_subdev_vm_nv44.c,v 1.2 2015/02/25 22:12:00 riastradh Exp $");
 
 #include <core/gpuobj.h>
 #include <core/option.h>
@@ -190,11 +190,54 @@
        priv->base.unmap = nv44_vm_unmap;
        priv->base.flush = nv44_vm_flush;
 
+#ifdef __NetBSD__
+    {
+       /* XXX pa_dmat or pa_dmat64?  */
+       const bus_dma_tag_t dmat = device->pdev->pd_pa.pa_dmat64;
+       int nsegs;
+
+       /* XXX errno NetBSD->Linux */
+       ret = -bus_dmamem_alloc(dmat, PAGE_SIZE, PAGE_SIZE, 0,
+           &priv->nullseg, 1, &nsegs, BUS_DMA_WAITOK);
+       if (ret) {
+               /* XXX Need to destroy stuff...  */
+fail0:         nv_error(priv, "unable to allocate dummy pages\n");
+               return ret;
+       }
+       KASSERT(nsegs == 1);
+
+       /* XXX errno NetBSD->Linux */
+       ret = -bus_dmamap_create(dmat, PAGE_SIZE, 1, PAGE_SIZE, 0,
+           BUS_DMA_WAITOK, &priv->nullmap);
+       if (ret) {
+fail1:         bus_dmamem_free(dmat, &priv->nullseg, 1);
+               goto fail0;
+       }
+
+       /* XXX errno NetBSD->Linux */
+       ret = -bus_dmamem_map(dmat, &priv->nullseg, 1, PAGE_SIZE,
+           &priv->nullp, BUS_DMA_WAITOK);
+       if (ret) {
+fail2:         bus_dmamap_destroy(dmat, priv->nullmap);
+               goto fail1;
+       }
+
+       /* XXX errno NetBSD->Linux */
+       ret = -bus_dmamap_load(dmat, priv->nullmap, priv->nullp, PAGE_SIZE,
+           NULL, BUS_DMA_WAITOK);
+       if (ret) {
+fail3: __unused        bus_dmamem_unmap(dmat, priv->nullp, PAGE_SIZE);
+               goto fail2;
+       }
+       priv->null = priv->nullmap->dm_segs[0].ds_addr;
+    }
+#else



Home | Main Index | Thread Index | Old Index