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/7c12af8ea25b
branches:  trunk
changeset: 331759:7c12af8ea25b
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Aug 23 08:03:33 2014 +0000

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

diffstat:

 sys/external/bsd/drm2/dist/drm/nouveau/core/engine/copy/nouveau_engine_copy_nva3.c       |   6 +-
 sys/external/bsd/drm2/dist/drm/nouveau/core/engine/crypt/nouveau_engine_crypt_nv84.c     |   6 +-
 sys/external/bsd/drm2/dist/drm/nouveau/core/engine/crypt/nouveau_engine_crypt_nv98.c     |   6 +-
 sys/external/bsd/drm2/dist/drm/nouveau/core/engine/device/nouveau_engine_device_base.c   |  94 +++++++++-
 sys/external/bsd/drm2/dist/drm/nouveau/core/engine/disp/nouveau_engine_disp_dacnv50.c    |   5 +-
 sys/external/bsd/drm2/dist/drm/nouveau/core/engine/disp/nouveau_engine_disp_nv04.c       |   6 +-
 sys/external/bsd/drm2/dist/drm/nouveau/core/engine/disp/nouveau_engine_disp_nv50.c       |  16 +-
 sys/external/bsd/drm2/dist/drm/nouveau/core/engine/disp/nouveau_engine_disp_nvd0.c       |   7 +-
 sys/external/bsd/drm2/dist/drm/nouveau/core/engine/disp/nv50.h                           |   2 +
 sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo/nouveau_engine_fifo_base.c       |  18 +-
 sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo/nouveau_engine_fifo_nvc0.c       |  48 ++++-
 sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo/nouveau_engine_fifo_nve0.c       |  47 ++++-
 sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo/nve0.h                           |   1 +
 sys/external/bsd/drm2/dist/drm/nouveau/core/engine/graph/nouveau_engine_graph_ctxnvd7.c  |   6 +-
 sys/external/bsd/drm2/dist/drm/nouveau/core/engine/graph/nouveau_engine_graph_gm107.c    |   6 +-
 sys/external/bsd/drm2/dist/drm/nouveau/core/engine/graph/nouveau_engine_graph_nv50.c     |  10 +-
 sys/external/bsd/drm2/dist/drm/nouveau/core/engine/graph/nouveau_engine_graph_nvc0.c     |  18 +-
 sys/external/bsd/drm2/dist/drm/nouveau/core/engine/nouveau_engine_xtensa.c               |   8 +-
 sys/external/bsd/drm2/dist/drm/nouveau/core/engine/perfmon/nouveau_engine_perfmon_base.c |   6 +-
 sys/external/bsd/drm2/dist/drm/nouveau/core/include/core/device.h                        |   2 +
 sys/external/bsd/drm2/dist/drm/nouveau/core/include/engine/device.h                      |   5 +
 sys/external/bsd/drm2/dist/drm/nouveau/core/include/subdev/bar.h                         |   5 +-
 sys/external/bsd/drm2/dist/drm/nouveau/core/include/subdev/fb.h                          |   4 +
 sys/external/bsd/drm2/dist/drm/nouveau/core/include/subdev/pwr.h                         |  11 +
 sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/bar/nouveau_subdev_bar_base.c         |  38 +++-
 sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/instmem/nouveau_subdev_instmem_nv04.c |   9 +-
 sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/instmem/nouveau_subdev_instmem_nv40.c |  23 ++-
 sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/instmem/nv04.h                        |   6 +
 sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/pwr/nouveau_subdev_pwr_base.c         |  33 +++-
 sys/external/bsd/drm2/dist/drm/nouveau/dispnv04/nouveau_dispnv04_tvmodesnv17.c           |   5 +-
 sys/external/bsd/drm2/dist/drm/nouveau/dispnv04/nouveau_dispnv04_tvnv17.c                |   8 +-
 sys/external/bsd/drm2/dist/drm/nouveau/nouveau_bo.c                                      |  20 +-
 sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drm.c                                     |  41 +++-
 sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drm.h                                     |   2 +
 sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c                                   |  11 +-
 sys/external/bsd/drm2/dist/drm/nouveau/nouveau_gem.c                                     |  12 +-
 sys/external/bsd/drm2/dist/drm/nouveau/nouveau_nv10_fence.c                              |   6 +-
 sys/external/bsd/drm2/dist/drm/nouveau/nouveau_nv50_display.c                            |  69 ++++++-
 sys/external/bsd/drm2/include/drm/drm_agp_netbsd.h                                       |   5 +-
 sys/external/bsd/drm2/include/linux/bitops.h                                             |   8 +-
 sys/external/bsd/drm2/include/linux/i2c.h                                                |   6 +-
 sys/external/bsd/drm2/include/linux/mutex.h                                              |   5 +-
 sys/external/bsd/drm2/include/linux/pagemap.h                                            |   4 +-
 sys/external/bsd/drm2/include/linux/pm_runtime.h                                         |   7 +-
 sys/external/bsd/drm2/include/linux/spinlock.h                                           |   5 +-
 sys/external/bsd/drm2/include/linux/vmalloc.h                                            |  15 +-
 sys/external/bsd/drm2/nouveau/files.nouveau                                              |  96 +++++++++-
 sys/external/bsd/drm2/nouveau/nouveau_module.c                                           |  11 +-
 48 files changed, 674 insertions(+), 114 deletions(-)

diffs (truncated from 2292 to 300 lines):

diff -r 3a52a02eb116 -r 7c12af8ea25b sys/external/bsd/drm2/dist/drm/nouveau/core/engine/copy/nouveau_engine_copy_nva3.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/copy/nouveau_engine_copy_nva3.c        Sat Aug 23 06:50:18 2014 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/copy/nouveau_engine_copy_nva3.c        Sat Aug 23 08:03:33 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nouveau_engine_copy_nva3.c,v 1.1.1.1 2014/08/06 12:36:24 riastradh Exp $       */
+/*     $NetBSD: nouveau_engine_copy_nva3.c,v 1.2 2014/08/23 08:03:33 riastradh Exp $   */
 
 /*
  * Copyright 2012 Red Hat Inc.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_engine_copy_nva3.c,v 1.1.1.1 2014/08/06 12:36:24 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_engine_copy_nva3.c,v 1.2 2014/08/23 08:03:33 riastradh Exp $");
 
 #include <engine/falcon.h>
 #include <engine/fifo.h>
@@ -107,7 +107,7 @@
        if (stat & 0x00000040) {
                nv_error(falcon, "DISPATCH_ERROR [");
                nouveau_enum_print(nva3_copy_isr_error_name, ssta);
-               pr_cont("] ch %d [0x%010llx %s] subc %d mthd 0x%04x data 0x%08x\n",
+               pr_cont("] ch %d [0x%010"PRIx64" %s] subc %d mthd 0x%04x data 0x%08x\n",
                       chid, inst << 12, nouveau_client_name(engctx), subc,
                       mthd, data);
                nv_wo32(falcon, 0x004, 0x00000040);
diff -r 3a52a02eb116 -r 7c12af8ea25b sys/external/bsd/drm2/dist/drm/nouveau/core/engine/crypt/nouveau_engine_crypt_nv84.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/crypt/nouveau_engine_crypt_nv84.c      Sat Aug 23 06:50:18 2014 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/crypt/nouveau_engine_crypt_nv84.c      Sat Aug 23 08:03:33 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nouveau_engine_crypt_nv84.c,v 1.1.1.1 2014/08/06 12:36:24 riastradh Exp $      */
+/*     $NetBSD: nouveau_engine_crypt_nv84.c,v 1.2 2014/08/23 08:03:33 riastradh Exp $  */
 
 /*
  * Copyright 2012 Red Hat Inc.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_engine_crypt_nv84.c,v 1.1.1.1 2014/08/06 12:36:24 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_engine_crypt_nv84.c,v 1.2 2014/08/23 08:03:33 riastradh Exp $");
 
 #include <core/client.h>
 #include <core/os.h>
@@ -134,7 +134,7 @@
        if (stat) {
                nv_error(priv, "%s", "");
                nouveau_bitfield_print(nv84_crypt_intr_mask, stat);
-               pr_cont(" ch %d [0x%010llx %s] mthd 0x%04x data 0x%08x\n",
+               pr_cont(" ch %d [0x%010"PRIx64" %s] mthd 0x%04x data 0x%08x\n",
                       chid, (u64)inst << 12, nouveau_client_name(engctx),
                       mthd, data);
        }
diff -r 3a52a02eb116 -r 7c12af8ea25b sys/external/bsd/drm2/dist/drm/nouveau/core/engine/crypt/nouveau_engine_crypt_nv98.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/crypt/nouveau_engine_crypt_nv98.c      Sat Aug 23 06:50:18 2014 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/crypt/nouveau_engine_crypt_nv98.c      Sat Aug 23 08:03:33 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nouveau_engine_crypt_nv98.c,v 1.1.1.1 2014/08/06 12:36:24 riastradh Exp $      */
+/*     $NetBSD: nouveau_engine_crypt_nv98.c,v 1.2 2014/08/23 08:03:33 riastradh Exp $  */
 
 /*
  * Copyright 2012 Red Hat Inc.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_engine_crypt_nv98.c,v 1.1.1.1 2014/08/06 12:36:24 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_engine_crypt_nv98.c,v 1.2 2014/08/23 08:03:33 riastradh Exp $");
 
 #include <core/client.h>
 #include <core/os.h>
@@ -108,7 +108,7 @@
        if (stat & 0x00000040) {
                nv_error(priv, "DISPATCH_ERROR [");
                nouveau_enum_print(nv98_crypt_isr_error_name, ssta);
-               pr_cont("] ch %d [0x%010llx %s] subc %d mthd 0x%04x data 0x%08x\n",
+               pr_cont("] ch %d [0x%010"PRIx64" %s] subc %d mthd 0x%04x data 0x%08x\n",
                       chid, (u64)inst << 12, nouveau_client_name(engctx),
                       subc, mthd, data);
                nv_wr32(priv, 0x087004, 0x00000040);
diff -r 3a52a02eb116 -r 7c12af8ea25b sys/external/bsd/drm2/dist/drm/nouveau/core/engine/device/nouveau_engine_device_base.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/device/nouveau_engine_device_base.c    Sat Aug 23 06:50:18 2014 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/device/nouveau_engine_device_base.c    Sat Aug 23 08:03:33 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nouveau_engine_device_base.c,v 1.2 2014/08/06 15:01:33 riastradh Exp $ */
+/*     $NetBSD: nouveau_engine_device_base.c,v 1.3 2014/08/23 08:03:33 riastradh Exp $ */
 
 /*
  * Copyright 2012 Red Hat Inc.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_engine_device_base.c,v 1.2 2014/08/06 15:01:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_engine_device_base.c,v 1.3 2014/08/23 08:03:33 riastradh Exp $");
 
 #include <core/object.h>
 #include <core/device.h>
@@ -36,8 +36,27 @@
 
 #include "priv.h"
 
+#ifdef __NetBSD__
+static struct mutex nv_devices_mutex;
+static struct list_head nv_devices = LIST_HEAD_INIT(nv_devices);
+
+void
+nouveau_devices_init(void)
+{
+
+       linux_mutex_init(&nv_devices_mutex);
+}
+
+void
+nouveau_devices_fini(void)
+{
+
+       linux_mutex_destroy(&nv_devices_mutex);
+}
+#else
 static DEFINE_MUTEX(nv_devices_mutex);
 static LIST_HEAD(nv_devices);
+#endif
 
 struct nouveau_device *
 nouveau_device_find(u64 name)
@@ -112,7 +131,12 @@
        struct nv_device_class *args = data;
        u32 boot0, strap;
        u64 disable, mmio_base, mmio_size;
+#ifdef __NetBSD__
+       bus_space_tag_t mmiot;
+       bus_space_handle_t mmioh;
+#else
        void __iomem *map;
+#endif
        int ret, i, c;
 
        if (size < sizeof(struct nv_device_class))
@@ -136,6 +160,9 @@
        if (ret)
                return ret;
 
+#ifdef __NetBSD__
+       mmiot = nv_device_resource_tag(device, 0);
+#endif
        mmio_base = nv_device_resource_start(device, 0);
        mmio_size = nv_device_resource_len(device, 0);
 
@@ -149,6 +176,21 @@
        /* identify the chipset, and determine classes of subdev/engines */
        if (!(args->disable & NV_DEVICE_DISABLE_IDENTIFY) &&
            !device->card_type) {
+#ifdef __NetBSD__
+               if (bus_space_map(mmiot, mmio_base, mmio_size, 0, &mmioh) != 0)
+                       return -ENOMEM;
+
+#ifndef __BIG_ENDIAN
+               if (bus_space_read_4(mmiot, mmioh, 4) != 0)
+#else
+               if (bus_space_read_4(mmiot, mmioh, 4) == 0)
+#endif
+                       bus_space_write_4(mmiot, mmioh, 4, 0x01000001);
+
+               boot0 = bus_space_read_4(mmiot, mmioh, 0x000000);
+               strap = bus_space_read_4(mmiot, mmioh, 0x101000);
+               bus_space_unmap(mmiot, mmioh, mmio_size);
+#else
                map = ioremap(mmio_base, 0x102000);
                if (map == NULL)
                        return -ENOMEM;
@@ -165,6 +207,7 @@
                boot0 = ioread32_native(map + 0x000000);
                strap = ioread32_native(map + 0x101000);
                iounmap(map);
+#endif
 
                /* determine chipset and derive architecture from it */
                if ((boot0 & 0x1f000000) > 0) {
@@ -247,6 +290,19 @@
                nv_debug(device, "crystal freq: %dKHz\n", device->crystal);
        }
 
+#ifdef __NetBSD__
+       if (!(args->disable & NV_DEVICE_DISABLE_MMIO) &&
+           !nv_subdev(device)->mmiosz) {
+               if (bus_space_map(mmiot, mmio_base, mmio_size, 0,
+                       &nv_subdev(device)->mmioh) != 0) {
+                       nv_error(device, "unable to map device registers\n");
+                       return -ENOMEM;
+               }
+               nv_subdev(device)->mmiot = mmiot;
+               nv_subdev(device)->mmioh = mmioh;
+               nv_subdev(device)->mmiosz = mmio_size;
+       }
+#else
        if (!(args->disable & NV_DEVICE_DISABLE_MMIO) &&
            !nv_subdev(device)->mmio) {
                nv_subdev(device)->mmio  = ioremap(mmio_base, mmio_size);
@@ -255,6 +311,7 @@
                        return -ENOMEM;
                }
        }
+#endif
 
        /* ensure requested subsystems are available for use */
        for (i = 1, c = 1; i < NVDEV_SUBDEV_NR; i++) {
@@ -447,8 +504,14 @@
        list_del(&device->head);
        mutex_unlock(&nv_devices_mutex);
 
+#ifdef __NetBSD__
+       if (nv_subdev(device)->mmiosz)
+               bus_space_unmap(nv_subdev(device)->mmiot,
+                   nv_subdev(device)->mmioh, nv_subdev(device)->mmiosz);
+#else
        if (nv_subdev(device)->mmio)
                iounmap(nv_subdev(device)->mmio);
+#endif
 
        nouveau_engine_destroy(&device->base);
 }
@@ -477,12 +540,17 @@
        if (nv_device_is_pci(device)) {
                return pci_resource_start(device->pdev, bar);
        } else {
+#ifdef __NetBSD__
+               /* XXX nouveau platform device */
+               panic("can't handle non-PCI nouveau devices");
+#else
                struct resource *res;
                res = platform_get_resource(device->platformdev,
                                            IORESOURCE_MEM, bar);
                if (!res)
                        return 0;
                return res->start;
+#endif
        }
 }
 
@@ -492,15 +560,21 @@
        if (nv_device_is_pci(device)) {
                return pci_resource_len(device->pdev, bar);
        } else {
+#ifdef __NetBSD__
+               /* XXX nouveau platform device */
+               panic("can't handle non-PCI nouveau devices");
+#else
                struct resource *res;
                res = platform_get_resource(device->platformdev,
                                            IORESOURCE_MEM, bar);
                if (!res)
                        return 0;
                return resource_size(res);
+#endif
        }
 }
 
+#ifndef __NetBSD__
 dma_addr_t
 nv_device_map_page(struct nouveau_device *device, struct page *page)
 {
@@ -525,15 +599,31 @@
                pci_unmap_page(device->pdev, addr, PAGE_SIZE,
                               PCI_DMA_BIDIRECTIONAL);
 }
+#endif
 
 int
 nv_device_get_irq(struct nouveau_device *device, bool stall)
 {
        if (nv_device_is_pci(device)) {
+#ifdef __NetBSD__
+               pci_intr_handle_t ih;
+
+               CTASSERT(sizeof ih <= sizeof(int)); /* XXX */
+               if (pci_intr_map(&device->pdev->pd_pa, &ih))
+                       panic("unable to map nouveau interrupt"); /* XXX */
+
+               return ih;
+#else
                return device->pdev->irq;
+#endif
        } else {
+#ifdef __NetBSD__
+               /* XXX nouveau platform device */
+               panic("can't handle non-PCI nouveau devices");
+#else
                return platform_get_irq_byname(device->platformdev,
                                               stall ? "stall" : "nonstall");
+#endif
        }
 }
 
diff -r 3a52a02eb116 -r 7c12af8ea25b sys/external/bsd/drm2/dist/drm/nouveau/core/engine/disp/nouveau_engine_disp_dacnv50.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/disp/nouveau_engine_disp_dacnv50.c     Sat Aug 23 06:50:18 2014 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/disp/nouveau_engine_disp_dacnv50.c     Sat Aug 23 08:03:33 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nouveau_engine_disp_dacnv50.c,v 1.1.1.1 2014/08/06 12:36:24 riastradh Exp $    */



Home | Main Index | Thread Index | Old Index