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 Miscellaneous fixes for drm2 on i386.



details:   https://anonhg.NetBSD.org/src/rev/a77e3dd62553
branches:  trunk
changeset: 328461:a77e3dd62553
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Thu Apr 03 19:18:29 2014 +0000

description:
Miscellaneous fixes for drm2 on i386.

diffstat:

 sys/external/bsd/drm2/dist/drm/drm_bufs.c         |   2 +
 sys/external/bsd/drm2/dist/include/drm/drmP.h     |  37 ++++++++++++++++++++--
 sys/external/bsd/drm2/i915drm/i915_gem_gtt.c      |  22 +++++++++---
 sys/external/bsd/drm2/i915drm/i915_pci.c          |   7 ++-
 sys/external/bsd/drm2/include/drm/bus_dma_hacks.h |  11 ++++++-
 sys/external/bsd/drm2/include/linux/pci.h         |   5 +-
 6 files changed, 68 insertions(+), 16 deletions(-)

diffs (219 lines):

diff -r dfd921525a2c -r a77e3dd62553 sys/external/bsd/drm2/dist/drm/drm_bufs.c
--- a/sys/external/bsd/drm2/dist/drm/drm_bufs.c Thu Apr 03 19:15:43 2014 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_bufs.c Thu Apr 03 19:18:29 2014 +0000
@@ -177,6 +177,7 @@
        switch (map->type) {
        case _DRM_REGISTERS:
        case _DRM_FRAME_BUFFER:
+#ifndef __NetBSD__             /* XXX No idea what this is for...  */
 #if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__) && !defined(__powerpc64__) && !defined(__x86_64__) && !defined(__arm__)
                if (map->offset + (map->size-1) < map->offset ||
                    map->offset < virt_to_phys(high_memory)) {
@@ -184,6 +185,7 @@
                        return -EINVAL;
                }
 #endif
+#endif
                /* Some drivers preinitialize some maps, without the X Server
                 * needing to be aware of it.  Therefore, we just return success
                 * when the server tries to create a duplicate map.
diff -r dfd921525a2c -r a77e3dd62553 sys/external/bsd/drm2/dist/include/drm/drmP.h
--- a/sys/external/bsd/drm2/dist/include/drm/drmP.h     Thu Apr 03 19:15:43 2014 +0000
+++ b/sys/external/bsd/drm2/dist/include/drm/drmP.h     Thu Apr 03 19:18:29 2014 +0000
@@ -2110,11 +2110,26 @@
 static inline uint64_t
 DRM_READ64(struct drm_local_map *map, bus_size_t offset)
 {
-       if (DRM_IS_BUS_SPACE(map))
+       if (DRM_IS_BUS_SPACE(map)) {
+#if _LP64                      /* XXX How to detect bus_space_read_8?  */
                return bus_space_read_8(map->lm_data.bus_space.bst,
                    map->lm_data.bus_space.bsh, offset);
-       else
+#elif _BYTE_ORDER == _LITTLE_ENDIAN
+               /* XXX Yes, this is sketchy.  */
+               return bus_space_read_4(map->lm_data.bus_space.bst,
+                   map->lm_data.bus_space.bsh, offset) |
+                   ((uint64_t)bus_space_read_4(map->lm_data.bus_space.bst,
+                       map->lm_data.bus_space.bsh, (offset + 4)) << 32);
+#else
+               /* XXX Yes, this is sketchy.  */
+               return bus_space_read_4(map->lm_data.bus_space.bst,
+                   map->lm_data.bus_space.bsh, (offset + 4)) |
+                   ((uint64_t)bus_space_read_4(map->lm_data.bus_space.bst,
+                       map->lm_data.bus_space.bsh, offset) << 32);
+#endif
+       } else {
                return *(volatile uint64_t *)((vaddr_t)map->handle + offset);
+       }
 }
 
 static inline void
@@ -2150,11 +2165,25 @@
 static inline void
 DRM_WRITE64(struct drm_local_map *map, bus_size_t offset, uint64_t value)
 {
-       if (DRM_IS_BUS_SPACE(map))
+       if (DRM_IS_BUS_SPACE(map)) {
+#if _LP64                      /* XXX How to detect bus_space_write_8?  */
                bus_space_write_8(map->lm_data.bus_space.bst,
                    map->lm_data.bus_space.bsh, offset, value);
-       else
+#elif _BYTE_ORDER == _LITTLE_ENDIAN
+               bus_space_write_4(map->lm_data.bus_space.bst,
+                   map->lm_data.bus_space.bsh, offset, (value & 0xffffffffU));
+               bus_space_write_4(map->lm_data.bus_space.bst,
+                   map->lm_data.bus_space.bsh, (offset + 4), (value >> 32));
+#else
+               bus_space_write_4(map->lm_data.bus_space.bst,
+                   map->lm_data.bus_space.bsh, offset, (value >> 32));
+               bus_space_write_4(map->lm_data.bus_space.bst,
+                   map->lm_data.bus_space.bsh, (offset + 4),
+                   (value & 0xffffffffU));
+#endif
+       } else {
                *(volatile uint64_t *)((vaddr_t)map->handle + offset) = value;
+       }
 }
 #endif /* defined(__NetBSD__) */
 
diff -r dfd921525a2c -r a77e3dd62553 sys/external/bsd/drm2/i915drm/i915_gem_gtt.c
--- a/sys/external/bsd/drm2/i915drm/i915_gem_gtt.c      Thu Apr 03 19:15:43 2014 +0000
+++ b/sys/external/bsd/drm2/i915drm/i915_gem_gtt.c      Thu Apr 03 19:18:29 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_gem_gtt.c,v 1.2 2014/03/18 18:20:42 riastradh Exp $       */
+/*     $NetBSD: i915_gem_gtt.c,v 1.3 2014/04/03 19:18:29 riastradh Exp $       */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_gtt.c,v 1.2 2014/03/18 18:20:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_gtt.c,v 1.3 2014/04/03 19:18:29 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -91,9 +91,11 @@
         * XXX pci_set_dma_mask?  pci_set_consistent_dma_mask?
         */
        if (INTEL_INFO(dev)->gen < 4)
-               drm_limit_dma_space(dev, 0, 0x00000000ffffffffULL);
+               drm_limit_dma_space(dev, 0,
+                   MIN(__type_max(resource_size_t), 0x00000000ffffffffULL));
        else
-               drm_limit_dma_space(dev, 0, 0x0000000fffffffffULL);
+               drm_limit_dma_space(dev, 0,
+                   MIN(__type_max(resource_size_t), 0x0000000fffffffffULL));
 
        /* Success!  */
        DRM_INFO("Memory usable by graphics device = %dM\n",
@@ -507,7 +509,15 @@
 static uint32_t
 gen6_pte_addr_encode(bus_addr_t addr)
 {
+       /*
+        * XXX `#ifdef __x86_64__' is a horrible way to work around a
+        * completely stupid GCC warning that encourages unsafe,
+        * nonportable code and has no obvious way to be selectively
+        * suppressed.
+        */
+#if __x86_64__
        KASSERT(addr <= __BITS(39, 0));
+#endif
        return (addr | ((addr >> 28) & 0xff0));
 }
 
@@ -585,8 +595,8 @@
                sizeof(gtt_pte_t))) {
                DRM_ERROR("BAR0 too small for GTT: 0x%"PRIxMAX" < 0x%"PRIxMAX
                    "\n",
-                   dev->bus_maps[0].bm_size,
-                   (gtt->gtt_total_entries * sizeof(gtt_pte_t)));
+                   (uintmax_t)dev->bus_maps[0].bm_size,
+                   (uintmax_t)(gtt->gtt_total_entries * sizeof(gtt_pte_t)));
                ret = -ENODEV;
                goto fail0;
        }
diff -r dfd921525a2c -r a77e3dd62553 sys/external/bsd/drm2/i915drm/i915_pci.c
--- a/sys/external/bsd/drm2/i915drm/i915_pci.c  Thu Apr 03 19:15:43 2014 +0000
+++ b/sys/external/bsd/drm2/i915drm/i915_pci.c  Thu Apr 03 19:18:29 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_pci.c,v 1.3 2014/04/03 14:45:44 riastradh Exp $   */
+/*     $NetBSD: i915_pci.c,v 1.4 2014/04/03 19:18:29 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_pci.c,v 1.3 2014/04/03 14:45:44 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_pci.c,v 1.4 2014/04/03 19:18:29 riastradh Exp $");
 
 #include <sys/types.h>
 #ifndef _MODULE
@@ -422,8 +422,9 @@
        prop_dictionary_set_uint8(dict, "depth", sizes->surface_bpp);
        prop_dictionary_set_uint16(dict, "linebytes", mode_cmd.pitches[0]);
        prop_dictionary_set_uint32(dict, "address", 0); /* XXX >32-bit */
+       CTASSERT(sizeof(uintptr_t) <= sizeof(uint64_t));
        prop_dictionary_set_uint64(dict, "virtual_address",
-           (uint64_t)bus_space_vaddr(dev->bst, sc->sc_fb_bsh));
+           (uint64_t)(uintptr_t)bus_space_vaddr(dev->bst, sc->sc_fb_bsh));
        sc->sc_genfb.sc_dev = sc->sc_dev;
        genfb_init(&sc->sc_genfb);
 
diff -r dfd921525a2c -r a77e3dd62553 sys/external/bsd/drm2/include/drm/bus_dma_hacks.h
--- a/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h Thu Apr 03 19:15:43 2014 +0000
+++ b/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h Thu Apr 03 19:18:29 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_dma_hacks.h,v 1.2 2014/03/18 18:20:43 riastradh Exp $      */
+/*     $NetBSD: bus_dma_hacks.h,v 1.3 2014/04/03 19:18:29 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -52,7 +52,16 @@
        unsigned int i;
        int error;
 
+       /*
+        * XXX `#ifdef __x86_64__' is a horrible way to work around a
+        * completely stupid GCC warning that encourages unsafe,
+        * nonportable code and has no obvious way to be selectively
+        * suppressed.
+        */
+#if __x86_64__
        KASSERT(size <= __type_max(off_t));
+#endif
+
        KASSERT(start <= (__type_max(off_t) - size));
        KASSERT(alignment == PAGE_SIZE); /* XXX */
        KASSERT(0 < nsegs);
diff -r dfd921525a2c -r a77e3dd62553 sys/external/bsd/drm2/include/linux/pci.h
--- a/sys/external/bsd/drm2/include/linux/pci.h Thu Apr 03 19:15:43 2014 +0000
+++ b/sys/external/bsd/drm2/include/linux/pci.h Thu Apr 03 19:18:29 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci.h,v 1.2 2014/03/18 18:20:43 riastradh Exp $        */
+/*     $NetBSD: pci.h,v 1.3 2014/04/03 19:18:29 riastradh Exp $        */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -34,6 +34,7 @@
 
 #include <sys/types.h>
 #include <sys/bus.h>
+#include <sys/cdefs.h>
 #include <sys/kmem.h>
 #include <sys/systm.h>
 
@@ -251,7 +252,7 @@
        }
 
        resource->r_bst = bst;
-       error = bus_space_alloc(bst, start, 0xffffffffffffffffULL /* XXX */,
+       error = bus_space_alloc(bst, start, __type_max(bus_addr_t),
            size, align, 0, 0, &resource->start, &resource->r_bsh);
        if (error)
                return error;



Home | Main Index | Thread Index | Old Index