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/via drm: Make via build again.



details:   https://anonhg.NetBSD.org/src/rev/5a091328c60f
branches:  trunk
changeset: 1028929:5a091328c60f
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 12:30:23 2021 +0000

description:
drm: Make via build again.

diffstat:

 sys/external/bsd/drm2/dist/drm/via/via_dmablit.c |  13 ++++-
 sys/external/bsd/drm2/dist/drm/via/via_dmablit.h |   9 +--
 sys/external/bsd/drm2/dist/drm/via/via_drv.c     |   5 +-
 sys/external/bsd/drm2/dist/drm/via/via_drv.h     |  12 ++--
 sys/external/bsd/drm2/dist/drm/via/via_irq.c     |   8 +-
 sys/external/bsd/drm2/include/linux/ktime.h      |   9 +++-
 sys/external/bsd/drm2/include/linux/time.h       |   3 +-
 sys/external/bsd/drm2/via/files.via              |   4 +-
 sys/external/bsd/drm2/via/via_pci.c              |  57 +++++++++++++++++------
 9 files changed, 81 insertions(+), 39 deletions(-)

diffs (truncated from 347 to 300 lines):

diff -r a25918e355dc -r 5a091328c60f sys/external/bsd/drm2/dist/drm/via/via_dmablit.c
--- a/sys/external/bsd/drm2/dist/drm/via/via_dmablit.c  Sun Dec 19 12:30:14 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/via/via_dmablit.c  Sun Dec 19 12:30:23 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: via_dmablit.c,v 1.10 2021/12/19 12:29:47 riastradh Exp $       */
+/*     $NetBSD: via_dmablit.c,v 1.11 2021/12/19 12:30:23 riastradh Exp $       */
 
 /* via_dmablit.c -- PCI DMA BitBlt support for the VIA Unichrome/Pro
  *
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: via_dmablit.c,v 1.10 2021/12/19 12:29:47 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: via_dmablit.c,v 1.11 2021/12/19 12:30:23 riastradh Exp $");
 
 #include <linux/pagemap.h>
 #include <linux/pci.h>
@@ -205,10 +205,11 @@
 
        switch (vsg->state) {
        case dr_via_device_mapped:
-               via_unmap_blit_from_device(pdev, vsg);
+               via_unmap_blit_from_device(dev, pdev, vsg);
                /* fall through */
        case dr_via_desc_pages_alloc:
 #ifdef __NetBSD__
+               __USE(i);
                bus_dmamap_unload(dev->dmat, vsg->desc_dmamap);
                bus_dmamap_destroy(dev->dmat, vsg->desc_dmamap);
                bus_dmamem_unmap(dev->dmat, vsg->desc_kva,
@@ -224,8 +225,13 @@
                kfree(vsg->desc_pages);
                /* fall through */
        case dr_via_pages_locked:
+#ifdef __NetBSD__
+               /* XXX uvm_vsunlock? */
+               bus_dmamap_unload(dev->dmat, vsg->dmamap);
+#else
                unpin_user_pages_dirty_lock(vsg->pages, vsg->num_pages,
                                           (vsg->direction == DMA_FROM_DEVICE));
+#endif
                /* fall through */
        case dr_via_pages_alloc:
 #ifdef __NetBSD__
@@ -299,6 +305,7 @@
                DRM_ERROR("bus_dmamap_create failed: %d\n", ret);
                return ret;
        }
+       /* XXX uvm_vslock? */
        ret = -bus_dmamap_load_uio(dev->dmat, vsg->dmamap, &uio,
            BUS_DMA_WAITOK | (xfer->to_fb? BUS_DMA_WRITE : BUS_DMA_READ));
        if (ret) {
diff -r a25918e355dc -r 5a091328c60f sys/external/bsd/drm2/dist/drm/via/via_dmablit.h
--- a/sys/external/bsd/drm2/dist/drm/via/via_dmablit.h  Sun Dec 19 12:30:14 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/via/via_dmablit.h  Sun Dec 19 12:30:23 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: via_dmablit.h,v 1.4 2021/12/18 23:45:44 riastradh Exp $        */
+/*     $NetBSD: via_dmablit.h,v 1.5 2021/12/19 12:30:23 riastradh Exp $        */
 
 /* via_dmablit.h -- PCI DMA BitBlt support for the VIA Unichrome/Pro
  *
@@ -33,6 +33,9 @@
 #define _VIA_DMABLIT_H
 
 #include <linux/dma-mapping.h>
+#include <linux/workqueue.h>
+
+#include <drm/drm_wait_netbsd.h>
 
 #define VIA_NUM_BLIT_ENGINES 2
 #define VIA_NUM_BLIT_SLOTS 8
@@ -55,11 +58,7 @@
        struct _drm_via_descriptor **desc_pages;
        int num_desc_pages;
        int num_desc;
-#ifdef __NetBSD__
-       enum { DMA_FROM_DEVICE, DMA_TO_DEVICE } direction;
-#else
        enum dma_data_direction direction;
-#endif
        dma_addr_t chain_start;
        uint32_t free_on_sequence;
        unsigned int descriptors_per_page;
diff -r a25918e355dc -r 5a091328c60f sys/external/bsd/drm2/dist/drm/via/via_drv.c
--- a/sys/external/bsd/drm2/dist/drm/via/via_drv.c      Sun Dec 19 12:30:14 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/via/via_drv.c      Sun Dec 19 12:30:23 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: via_drv.c,v 1.8 2021/12/18 23:45:44 riastradh Exp $    */
+/*     $NetBSD: via_drv.c,v 1.9 2021/12/19 12:30:23 riastradh Exp $    */
 
 /*
  * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
@@ -25,13 +25,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: via_drv.c,v 1.8 2021/12/18 23:45:44 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: via_drv.c,v 1.9 2021/12/19 12:30:23 riastradh Exp $");
 
 #include <linux/module.h>
 #include <linux/pci.h>
 
 #include <drm/drm_drv.h>
 #include <drm/drm_file.h>
+#include <drm/drm_pci.h>
 #include <drm/drm_pciids.h>
 #include <drm/via_drm.h>
 
diff -r a25918e355dc -r 5a091328c60f sys/external/bsd/drm2/dist/drm/via/via_drv.h
--- a/sys/external/bsd/drm2/dist/drm/via/via_drv.h      Sun Dec 19 12:30:14 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/via/via_drv.h      Sun Dec 19 12:30:23 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: via_drv.h,v 1.6 2021/12/18 23:45:44 riastradh Exp $    */
+/*     $NetBSD: via_drv.h,v 1.7 2021/12/19 12:30:23 riastradh Exp $    */
 
 /*
  * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
@@ -139,19 +139,19 @@
 /* VIA MMIO register access */
 static inline u32 via_read(struct drm_via_private *dev_priv, u32 reg)
 {
-       return readl((void __iomem *)(dev_priv->mmio->handle + reg));
+       return DRM_READ32(dev_priv->mmio, reg);
 }
 
 static inline void via_write(struct drm_via_private *dev_priv, u32 reg,
                             u32 val)
 {
-       writel(val, (void __iomem *)(dev_priv->mmio->handle + reg));
+       DRM_WRITE32(dev_priv->mmio, reg, val);
 }
 
 static inline void via_write8(struct drm_via_private *dev_priv, u32 reg,
                              u32 val)
 {
-       writeb(val, (void __iomem *)(dev_priv->mmio->handle + reg));
+       DRM_WRITE8(dev_priv->mmio, reg, val);
 }
 
 static inline void via_write8_mask(struct drm_via_private *dev_priv,
@@ -159,9 +159,9 @@
 {
        u32 tmp;
 
-       tmp = readb((void __iomem *)(dev_priv->mmio->handle + reg));
+       tmp = DRM_READ8(dev_priv->mmio, reg);
        tmp = (tmp & ~mask) | (val & mask);
-       writeb(tmp, (void __iomem *)(dev_priv->mmio->handle + reg));
+       DRM_WRITE8(dev_priv->mmio, reg, tmp);
 }
 
 /*
diff -r a25918e355dc -r 5a091328c60f sys/external/bsd/drm2/dist/drm/via/via_irq.c
--- a/sys/external/bsd/drm2/dist/drm/via/via_irq.c      Sun Dec 19 12:30:14 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/via/via_irq.c      Sun Dec 19 12:30:23 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: via_irq.c,v 1.8 2021/12/18 23:45:44 riastradh Exp $    */
+/*     $NetBSD: via_irq.c,v 1.9 2021/12/19 12:30:23 riastradh Exp $    */
 
 /* via_irq.c
  *
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: via_irq.c,v 1.8 2021/12/18 23:45:44 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: via_irq.c,v 1.9 2021/12/19 12:30:23 riastradh Exp $");
 
 #include <drm/drm_device.h>
 #include <drm/drm_vblank.h>
@@ -129,7 +129,7 @@
                        dev_priv->last_vblank_valid = 1;
                }
                if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
-                       DRM_DEBUG("nsec per vblank is: %llu\n",
+                       DRM_DEBUG("nsec per vblank is: %"PRIu64"\n",
                                  ktime_to_ns(dev_priv->nsec_per_vblank));
                }
                drm_handle_vblank(dev, 0);
@@ -252,7 +252,7 @@
        if (masks[real_irq][2] && !force_sequence) {
                DRM_SPIN_WAIT_ON(ret, &cur_irq->irq_queue, &cur_irq->irq_lock,
                    3 * HZ,
-                   ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
+                   ((via_read(dev_priv, masks[irq][2]) & masks[irq][3]) ==
                        masks[irq][4]));
                cur_irq_sequence = cur_irq->irq_received;
        } else {
diff -r a25918e355dc -r 5a091328c60f sys/external/bsd/drm2/include/linux/ktime.h
--- a/sys/external/bsd/drm2/include/linux/ktime.h       Sun Dec 19 12:30:14 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/ktime.h       Sun Dec 19 12:30:23 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ktime.h,v 1.20 2021/12/19 12:24:05 riastradh Exp $     */
+/*     $NetBSD: ktime.h,v 1.21 2021/12/19 12:30:23 riastradh Exp $     */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -223,4 +223,11 @@
        return time_second;
 }
 
+static inline void
+ktime_get_ts64(struct timespec64 *ts)
+{
+
+       nanotime(ts);
+}
+
 #endif  /* _LINUX_KTIME_H_ */
diff -r a25918e355dc -r 5a091328c60f sys/external/bsd/drm2/include/linux/time.h
--- a/sys/external/bsd/drm2/include/linux/time.h        Sun Dec 19 12:30:14 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/time.h        Sun Dec 19 12:30:23 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: time.h,v 1.10 2021/12/19 11:12:36 riastradh Exp $      */
+/*     $NetBSD: time.h,v 1.11 2021/12/19 12:30:23 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -39,6 +39,7 @@
 
 #define        timespec64      timespec        /* take that, 2038 */
 
+#define NSEC_PER_USEC  1000L
 #define NSEC_PER_MSEC  1000000L
 #define        NSEC_PER_SEC    1000000000L
 #define USEC_PER_MSEC  1000L
diff -r a25918e355dc -r 5a091328c60f sys/external/bsd/drm2/via/files.via
--- a/sys/external/bsd/drm2/via/files.via       Sun Dec 19 12:30:14 2021 +0000
+++ b/sys/external/bsd/drm2/via/files.via       Sun Dec 19 12:30:23 2021 +0000
@@ -1,6 +1,6 @@
-#      $NetBSD: files.via,v 1.4 2021/12/19 10:55:28 riastradh Exp $
+#      $NetBSD: files.via,v 1.5 2021/12/19 12:30:23 riastradh Exp $
 
-device viadrmums: drmkms, drmkms_pci
+device viadrmums: drmkms, drmkms_pci, drmums
 attach viadrmums at drm
 
 makeoptions    viadrmums       "CPPFLAGS.viadrmums"+="-I$S/external/bsd/drm2/dist/drm/via"
diff -r a25918e355dc -r 5a091328c60f sys/external/bsd/drm2/via/via_pci.c
--- a/sys/external/bsd/drm2/via/via_pci.c       Sun Dec 19 12:30:14 2021 +0000
+++ b/sys/external/bsd/drm2/via/via_pci.c       Sun Dec 19 12:30:23 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: via_pci.c,v 1.6 2021/12/19 10:33:00 riastradh Exp $    */
+/*     $NetBSD: via_pci.c,v 1.7 2021/12/19 12:30:23 riastradh Exp $    */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: via_pci.c,v 1.6 2021/12/19 10:33:00 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: via_pci.c,v 1.7 2021/12/19 12:30:23 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/device.h>
@@ -39,6 +39,9 @@
 
 #include <linux/pci.h>
 
+#include <drm/drm_device.h>
+#include <drm/drm_drv.h>
+#include <drm/drm_pci.h>
 #include <drm/drm_pciids.h>
 #include <drm/via_drm.h>
 
@@ -50,6 +53,8 @@
        device_t                sc_dev;
        struct pci_dev          sc_pci_dev;
        struct drm_device       *sc_drm_dev;
+       bool                    sc_pci_attached;
+       bool                    sc_dev_registered;
 };
 
 static int     viadrm_match(device_t, cfdata_t, void *);
@@ -120,19 +125,35 @@
        aprint_naive("\n");
        aprint_normal("\n");
 
-       if (!pmf_device_register(self, NULL, NULL))
-               aprint_error_dev(self, "couldn't establish power handler\n");
-
        /* Initialize the Linux PCI device descriptor.  */
        linux_pci_dev_init(&sc->sc_pci_dev, self, device_parent(self), pa, 0);
 
+       sc->sc_drm_dev = drm_dev_alloc(via_drm_driver, self);
+       if (IS_ERR(sc->sc_drm_dev)) {
+               aprint_error_dev(self, "unable to create drm device: %ld\n",
+                   PTR_ERR(sc->sc_drm_dev));
+               sc->sc_drm_dev = NULL;
+               return;
+       }
+
        /* XXX errno Linux->NetBSD */
-       error = -drm_pci_attach(self, pa, &sc->sc_pci_dev, via_drm_driver,
-           *cookiep, &sc->sc_drm_dev);
+       error = -drm_pci_attach(sc->sc_drm_dev, &sc->sc_pci_dev);
        if (error) {
                aprint_error_dev(self, "unable to attach drm: %d\n", error);



Home | Main Index | Thread Index | Old Index