Miscellaneous fixes for drm2 on i386.diff -r1.3 -r1.4 src/sys/external/bsd/drm2/dist/drm/drm_bufs.c
(riastradh)
--- src/sys/external/bsd/drm2/dist/drm/drm_bufs.c 2014/04/03 05:48:02 1.3
+++ src/sys/external/bsd/drm2/dist/drm/drm_bufs.c 2014/04/03 19:18:29 1.4
@@ -167,33 +167,35 @@ static int drm_addmap_core(struct drm_de | @@ -167,33 +167,35 @@ static int drm_addmap_core(struct drm_de | |||
167 | if (map->type == _DRM_SHM) | 167 | if (map->type == _DRM_SHM) | |
168 | map->size = PAGE_ALIGN(map->size); | 168 | map->size = PAGE_ALIGN(map->size); | |
169 | 169 | |||
170 | if ((map->offset & (~(resource_size_t)PAGE_MASK)) || (map->size & (~PAGE_MASK))) { | 170 | if ((map->offset & (~(resource_size_t)PAGE_MASK)) || (map->size & (~PAGE_MASK))) { | |
171 | kfree(map); | 171 | kfree(map); | |
172 | return -EINVAL; | 172 | return -EINVAL; | |
173 | } | 173 | } | |
174 | map->mtrr = -1; | 174 | map->mtrr = -1; | |
175 | map->handle = NULL; | 175 | map->handle = NULL; | |
176 | 176 | |||
177 | switch (map->type) { | 177 | switch (map->type) { | |
178 | case _DRM_REGISTERS: | 178 | case _DRM_REGISTERS: | |
179 | case _DRM_FRAME_BUFFER: | 179 | case _DRM_FRAME_BUFFER: | |
180 | #ifndef __NetBSD__ /* XXX No idea what this is for... */ | |||
180 | #if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__) && !defined(__powerpc64__) && !defined(__x86_64__) && !defined(__arm__) | 181 | #if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__) && !defined(__powerpc64__) && !defined(__x86_64__) && !defined(__arm__) | |
181 | if (map->offset + (map->size-1) < map->offset || | 182 | if (map->offset + (map->size-1) < map->offset || | |
182 | map->offset < virt_to_phys(high_memory)) { | 183 | map->offset < virt_to_phys(high_memory)) { | |
183 | kfree(map); | 184 | kfree(map); | |
184 | return -EINVAL; | 185 | return -EINVAL; | |
185 | } | 186 | } | |
186 | #endif | 187 | #endif | |
188 | #endif | |||
187 | /* Some drivers preinitialize some maps, without the X Server | 189 | /* Some drivers preinitialize some maps, without the X Server | |
188 | * needing to be aware of it. Therefore, we just return success | 190 | * needing to be aware of it. Therefore, we just return success | |
189 | * when the server tries to create a duplicate map. | 191 | * when the server tries to create a duplicate map. | |
190 | */ | 192 | */ | |
191 | list = drm_find_matching_map(dev, map); | 193 | list = drm_find_matching_map(dev, map); | |
192 | if (list != NULL) { | 194 | if (list != NULL) { | |
193 | if (list->map->size != map->size) { | 195 | if (list->map->size != map->size) { | |
194 | DRM_DEBUG("Matching maps of type %d with " | 196 | DRM_DEBUG("Matching maps of type %d with " | |
195 | "mismatched sizes, (%ld vs %ld)\n", | 197 | "mismatched sizes, (%ld vs %ld)\n", | |
196 | map->type, map->size, | 198 | map->type, map->size, | |
197 | list->map->size); | 199 | list->map->size); | |
198 | list->map->size = map->size; | 200 | list->map->size = map->size; | |
199 | } | 201 | } |
--- src/sys/external/bsd/drm2/dist/include/drm/Attic/drmP.h 2014/03/18 18:20:42 1.2
+++ src/sys/external/bsd/drm2/dist/include/drm/Attic/drmP.h 2014/04/03 19:18:29 1.3
@@ -2100,31 +2100,46 @@ DRM_READ16(struct drm_local_map *map, bu | @@ -2100,31 +2100,46 @@ DRM_READ16(struct drm_local_map *map, bu | |||
2100 | static inline uint32_t | 2100 | static inline uint32_t | |
2101 | DRM_READ32(struct drm_local_map *map, bus_size_t offset) | 2101 | DRM_READ32(struct drm_local_map *map, bus_size_t offset) | |
2102 | { | 2102 | { | |
2103 | if (DRM_IS_BUS_SPACE(map)) | 2103 | if (DRM_IS_BUS_SPACE(map)) | |
2104 | return bus_space_read_4(map->lm_data.bus_space.bst, | 2104 | return bus_space_read_4(map->lm_data.bus_space.bst, | |
2105 | map->lm_data.bus_space.bsh, offset); | 2105 | map->lm_data.bus_space.bsh, offset); | |
2106 | else | 2106 | else | |
2107 | return *(volatile uint32_t *)((vaddr_t)map->handle + offset); | 2107 | return *(volatile uint32_t *)((vaddr_t)map->handle + offset); | |
2108 | } | 2108 | } | |
2109 | 2109 | |||
2110 | static inline uint64_t | 2110 | static inline uint64_t | |
2111 | DRM_READ64(struct drm_local_map *map, bus_size_t offset) | 2111 | DRM_READ64(struct drm_local_map *map, bus_size_t offset) | |
2112 | { | 2112 | { | |
2113 | if (DRM_IS_BUS_SPACE(map)) | 2113 | if (DRM_IS_BUS_SPACE(map)) { | |
2114 | #if _LP64 /* XXX How to detect bus_space_read_8? */ | |||
2114 | return bus_space_read_8(map->lm_data.bus_space.bst, | 2115 | return bus_space_read_8(map->lm_data.bus_space.bst, | |
2115 | map->lm_data.bus_space.bsh, offset); | 2116 | map->lm_data.bus_space.bsh, offset); | |
2116 | else | 2117 | #elif _BYTE_ORDER == _LITTLE_ENDIAN | |
2118 | /* XXX Yes, this is sketchy. */ | |||
2119 | return bus_space_read_4(map->lm_data.bus_space.bst, | |||
2120 | map->lm_data.bus_space.bsh, offset) | | |||
2121 | ((uint64_t)bus_space_read_4(map->lm_data.bus_space.bst, | |||
2122 | map->lm_data.bus_space.bsh, (offset + 4)) << 32); | |||
2123 | #else | |||
2124 | /* XXX Yes, this is sketchy. */ | |||
2125 | return bus_space_read_4(map->lm_data.bus_space.bst, | |||
2126 | map->lm_data.bus_space.bsh, (offset + 4)) | | |||
2127 | ((uint64_t)bus_space_read_4(map->lm_data.bus_space.bst, | |||
2128 | map->lm_data.bus_space.bsh, offset) << 32); | |||
2129 | #endif | |||
2130 | } else { | |||
2117 | return *(volatile uint64_t *)((vaddr_t)map->handle + offset); | 2131 | return *(volatile uint64_t *)((vaddr_t)map->handle + offset); | |
2132 | } | |||
2118 | } | 2133 | } | |
2119 | 2134 | |||
2120 | static inline void | 2135 | static inline void | |
2121 | DRM_WRITE8(struct drm_local_map *map, bus_size_t offset, uint8_t value) | 2136 | DRM_WRITE8(struct drm_local_map *map, bus_size_t offset, uint8_t value) | |
2122 | { | 2137 | { | |
2123 | if (DRM_IS_BUS_SPACE(map)) | 2138 | if (DRM_IS_BUS_SPACE(map)) | |
2124 | bus_space_write_1(map->lm_data.bus_space.bst, | 2139 | bus_space_write_1(map->lm_data.bus_space.bst, | |
2125 | map->lm_data.bus_space.bsh, offset, value); | 2140 | map->lm_data.bus_space.bsh, offset, value); | |
2126 | else | 2141 | else | |
2127 | *(volatile uint8_t *)((vaddr_t)map->handle + offset) = value; | 2142 | *(volatile uint8_t *)((vaddr_t)map->handle + offset) = value; | |
2128 | } | 2143 | } | |
2129 | 2144 | |||
2130 | static inline void | 2145 | static inline void | |
@@ -2140,31 +2155,45 @@ DRM_WRITE16(struct drm_local_map *map, b | @@ -2140,31 +2155,45 @@ DRM_WRITE16(struct drm_local_map *map, b | |||
2140 | static inline void | 2155 | static inline void | |
2141 | DRM_WRITE32(struct drm_local_map *map, bus_size_t offset, uint32_t value) | 2156 | DRM_WRITE32(struct drm_local_map *map, bus_size_t offset, uint32_t value) | |
2142 | { | 2157 | { | |
2143 | if (DRM_IS_BUS_SPACE(map)) | 2158 | if (DRM_IS_BUS_SPACE(map)) | |
2144 | bus_space_write_4(map->lm_data.bus_space.bst, | 2159 | bus_space_write_4(map->lm_data.bus_space.bst, | |
2145 | map->lm_data.bus_space.bsh, offset, value); | 2160 | map->lm_data.bus_space.bsh, offset, value); | |
2146 | else | 2161 | else | |
2147 | *(volatile uint32_t *)((vaddr_t)map->handle + offset) = value; | 2162 | *(volatile uint32_t *)((vaddr_t)map->handle + offset) = value; | |
2148 | } | 2163 | } | |
2149 | 2164 | |||
2150 | static inline void | 2165 | static inline void | |
2151 | DRM_WRITE64(struct drm_local_map *map, bus_size_t offset, uint64_t value) | 2166 | DRM_WRITE64(struct drm_local_map *map, bus_size_t offset, uint64_t value) | |
2152 | { | 2167 | { | |
2153 | if (DRM_IS_BUS_SPACE(map)) | 2168 | if (DRM_IS_BUS_SPACE(map)) { | |
2169 | #if _LP64 /* XXX How to detect bus_space_write_8? */ | |||
2154 | bus_space_write_8(map->lm_data.bus_space.bst, | 2170 | bus_space_write_8(map->lm_data.bus_space.bst, | |
2155 | map->lm_data.bus_space.bsh, offset, value); | 2171 | map->lm_data.bus_space.bsh, offset, value); | |
2156 | else | 2172 | #elif _BYTE_ORDER == _LITTLE_ENDIAN | |
2173 | bus_space_write_4(map->lm_data.bus_space.bst, | |||
2174 | map->lm_data.bus_space.bsh, offset, (value & 0xffffffffU)); | |||
2175 | bus_space_write_4(map->lm_data.bus_space.bst, | |||
2176 | map->lm_data.bus_space.bsh, (offset + 4), (value >> 32)); | |||
2177 | #else | |||
2178 | bus_space_write_4(map->lm_data.bus_space.bst, | |||
2179 | map->lm_data.bus_space.bsh, offset, (value >> 32)); | |||
2180 | bus_space_write_4(map->lm_data.bus_space.bst, | |||
2181 | map->lm_data.bus_space.bsh, (offset + 4), | |||
2182 | (value & 0xffffffffU)); | |||
2183 | #endif | |||
2184 | } else { | |||
2157 | *(volatile uint64_t *)((vaddr_t)map->handle + offset) = value; | 2185 | *(volatile uint64_t *)((vaddr_t)map->handle + offset) = value; | |
2186 | } | |||
2158 | } | 2187 | } | |
2159 | #endif /* defined(__NetBSD__) */ | 2188 | #endif /* defined(__NetBSD__) */ | |
2160 | 2189 | |||
2161 | #ifdef __NetBSD__ | 2190 | #ifdef __NetBSD__ | |
2162 | 2191 | |||
2163 | /* XXX This is pretty kludgerific. */ | 2192 | /* XXX This is pretty kludgerific. */ | |
2164 | 2193 | |||
2165 | #include <linux/io-mapping.h> | 2194 | #include <linux/io-mapping.h> | |
2166 | 2195 | |||
2167 | static inline struct io_mapping * | 2196 | static inline struct io_mapping * | |
2168 | drm_io_mapping_create_wc(struct drm_device *dev, resource_size_t addr, | 2197 | drm_io_mapping_create_wc(struct drm_device *dev, resource_size_t addr, | |
2169 | unsigned long size) | 2198 | unsigned long size) | |
2170 | { | 2199 | { |
--- src/sys/external/bsd/drm2/i915drm/Attic/i915_gem_gtt.c 2014/03/18 18:20:42 1.2
+++ src/sys/external/bsd/drm2/i915drm/Attic/i915_gem_gtt.c 2014/04/03 19:18:29 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: i915_gem_gtt.c,v 1.2 2014/03/18 18:20:42 riastradh Exp $ */ | 1 | /* $NetBSD: i915_gem_gtt.c,v 1.3 2014/04/03 19:18:29 riastradh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Taylor R. Campbell. | 8 | * by Taylor R. Campbell. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -20,27 +20,27 @@ | @@ -20,27 +20,27 @@ | |||
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | __KERNEL_RCSID(0, "$NetBSD: i915_gem_gtt.c,v 1.2 2014/03/18 18:20:42 riastradh Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: i915_gem_gtt.c,v 1.3 2014/04/03 19:18:29 riastradh Exp $"); | |
34 | 34 | |||
35 | #include <sys/types.h> | 35 | #include <sys/types.h> | |
36 | #include <sys/param.h> | 36 | #include <sys/param.h> | |
37 | #include <sys/bus.h> | 37 | #include <sys/bus.h> | |
38 | #include <sys/kmem.h> | 38 | #include <sys/kmem.h> | |
39 | #include <sys/systm.h> | 39 | #include <sys/systm.h> | |
40 | 40 | |||
41 | #include <dev/pci/pcivar.h> | 41 | #include <dev/pci/pcivar.h> | |
42 | 42 | |||
43 | #include <dev/pci/agpvar.h> | 43 | #include <dev/pci/agpvar.h> | |
44 | #include <dev/pci/agp_i810var.h> | 44 | #include <dev/pci/agp_i810var.h> | |
45 | 45 | |||
46 | #include <drm/drmP.h> | 46 | #include <drm/drmP.h> | |
@@ -81,29 +81,31 @@ i915_gem_gtt_init(struct drm_device *dev | @@ -81,29 +81,31 @@ i915_gem_gtt_init(struct drm_device *dev | |||
81 | else | 81 | else | |
82 | ret = gen6_gtt_init(dev); | 82 | ret = gen6_gtt_init(dev); | |
83 | if (ret) | 83 | if (ret) | |
84 | goto fail0; | 84 | goto fail0; | |
85 | 85 | |||
86 | /* | 86 | /* | |
87 | * The GTT entries are limited to 32-bit physical addresses up | 87 | * The GTT entries are limited to 32-bit physical addresses up | |
88 | * until gen4, at and after which they are limited to 36-bit | 88 | * until gen4, at and after which they are limited to 36-bit | |
89 | * physical addresses. | 89 | * physical addresses. | |
90 | * | 90 | * | |
91 | * XXX pci_set_dma_mask? pci_set_consistent_dma_mask? | 91 | * XXX pci_set_dma_mask? pci_set_consistent_dma_mask? | |
92 | */ | 92 | */ | |
93 | if (INTEL_INFO(dev)->gen < 4) | 93 | if (INTEL_INFO(dev)->gen < 4) | |
94 | drm_limit_dma_space(dev, 0, 0x00000000ffffffffULL); | 94 | drm_limit_dma_space(dev, 0, | |
95 | MIN(__type_max(resource_size_t), 0x00000000ffffffffULL)); | |||
95 | else | 96 | else | |
96 | drm_limit_dma_space(dev, 0, 0x0000000fffffffffULL); | 97 | drm_limit_dma_space(dev, 0, | |
98 | MIN(__type_max(resource_size_t), 0x0000000fffffffffULL)); | |||
97 | 99 | |||
98 | /* Success! */ | 100 | /* Success! */ | |
99 | DRM_INFO("Memory usable by graphics device = %dM\n", | 101 | DRM_INFO("Memory usable by graphics device = %dM\n", | |
100 | gtt->gtt_total_entries >> 8); | 102 | gtt->gtt_total_entries >> 8); | |
101 | DRM_DEBUG_DRIVER("GMADR size = %dM\n", gtt->gtt_mappable_entries >> 8); | 103 | DRM_DEBUG_DRIVER("GMADR size = %dM\n", gtt->gtt_mappable_entries >> 8); | |
102 | DRM_DEBUG_DRIVER("GTT stolen size = %dM\n", gtt->stolen_size >> 20); | 104 | DRM_DEBUG_DRIVER("GTT stolen size = %dM\n", gtt->stolen_size >> 20); | |
103 | return 0; | 105 | return 0; | |
104 | 106 | |||
105 | fail1: __unused | 107 | fail1: __unused | |
106 | if (INTEL_INFO(dev)->gen < 6) | 108 | if (INTEL_INFO(dev)->gen < 6) | |
107 | agp_gtt_fini(dev); | 109 | agp_gtt_fini(dev); | |
108 | else | 110 | else | |
109 | gen6_gtt_fini(dev); | 111 | gen6_gtt_fini(dev); | |
@@ -497,27 +499,35 @@ agp_ggtt_clear_range(struct drm_device * | @@ -497,27 +499,35 @@ agp_ggtt_clear_range(struct drm_device * | |||
497 | #define IVB_GMCH_GMS (IVB_GMCH_GMS_MASK << IVB_GMCH_GMS_SHIFT) | 499 | #define IVB_GMCH_GMS (IVB_GMCH_GMS_MASK << IVB_GMCH_GMS_SHIFT) | |
498 | 500 | |||
499 | typedef uint32_t gtt_pte_t; | 501 | typedef uint32_t gtt_pte_t; | |
500 | 502 | |||
501 | #define GEN6_PTE_VALID __BIT(0) | 503 | #define GEN6_PTE_VALID __BIT(0) | |
502 | #define GEN6_PTE_UNCACHED __BIT(1) | 504 | #define GEN6_PTE_UNCACHED __BIT(1) | |
503 | #define HSW_PTE_UNCACHED (0) | 505 | #define HSW_PTE_UNCACHED (0) | |
504 | #define GEN6_PTE_CACHE_LLC __BIT(2) | 506 | #define GEN6_PTE_CACHE_LLC __BIT(2) | |
505 | #define GEN6_PTE_CACHE_LLC_MLC __BIT(3) | 507 | #define GEN6_PTE_CACHE_LLC_MLC __BIT(3) | |
506 | 508 | |||
507 | static uint32_t | 509 | static uint32_t | |
508 | gen6_pte_addr_encode(bus_addr_t addr) | 510 | gen6_pte_addr_encode(bus_addr_t addr) | |
509 | { | 511 | { | |
512 | /* | |||
513 | * XXX `#ifdef __x86_64__' is a horrible way to work around a | |||
514 | * completely stupid GCC warning that encourages unsafe, | |||
515 | * nonportable code and has no obvious way to be selectively | |||
516 | * suppressed. | |||
517 | */ | |||
518 | #if __x86_64__ | |||
510 | KASSERT(addr <= __BITS(39, 0)); | 519 | KASSERT(addr <= __BITS(39, 0)); | |
520 | #endif | |||
511 | return (addr | ((addr >> 28) & 0xff0)); | 521 | return (addr | ((addr >> 28) & 0xff0)); | |
512 | } | 522 | } | |
513 | 523 | |||
514 | static gtt_pte_t | 524 | static gtt_pte_t | |
515 | gen6_pte_encode(struct drm_device *dev, bus_addr_t addr, | 525 | gen6_pte_encode(struct drm_device *dev, bus_addr_t addr, | |
516 | enum i915_cache_level level) | 526 | enum i915_cache_level level) | |
517 | { | 527 | { | |
518 | uint32_t flags = GEN6_PTE_VALID; | 528 | uint32_t flags = GEN6_PTE_VALID; | |
519 | 529 | |||
520 | switch (level) { | 530 | switch (level) { | |
521 | case I915_CACHE_LLC_MLC: | 531 | case I915_CACHE_LLC_MLC: | |
522 | flags |= (IS_HASWELL(dev)? GEN6_PTE_CACHE_LLC | 532 | flags |= (IS_HASWELL(dev)? GEN6_PTE_CACHE_LLC | |
523 | : GEN6_PTE_CACHE_LLC_MLC); | 533 | : GEN6_PTE_CACHE_LLC_MLC); | |
@@ -575,28 +585,28 @@ gen6_gtt_init(struct drm_device *dev) | @@ -575,28 +585,28 @@ gen6_gtt_init(struct drm_device *dev) | |||
575 | if (((gtt->gtt_mappable_entries >> 8) < 64) || | 585 | if (((gtt->gtt_mappable_entries >> 8) < 64) || | |
576 | (gtt->gtt_total_entries < gtt->gtt_mappable_entries)) { | 586 | (gtt->gtt_total_entries < gtt->gtt_mappable_entries)) { | |
577 | DRM_ERROR("unknown GMADR entries: %d\n", | 587 | DRM_ERROR("unknown GMADR entries: %d\n", | |
578 | gtt->gtt_mappable_entries); | 588 | gtt->gtt_mappable_entries); | |
579 | ret = -ENXIO; | 589 | ret = -ENXIO; | |
580 | goto fail0; | 590 | goto fail0; | |
581 | } | 591 | } | |
582 | 592 | |||
583 | /* Linux sez: For GEN6+ the PTEs for the ggtt live at 2MB + BAR0 */ | 593 | /* Linux sez: For GEN6+ the PTEs for the ggtt live at 2MB + BAR0 */ | |
584 | if (dev->bus_maps[0].bm_size < (gtt->gtt_total_entries * | 594 | if (dev->bus_maps[0].bm_size < (gtt->gtt_total_entries * | |
585 | sizeof(gtt_pte_t))) { | 595 | sizeof(gtt_pte_t))) { | |
586 | DRM_ERROR("BAR0 too small for GTT: 0x%"PRIxMAX" < 0x%"PRIxMAX | 596 | DRM_ERROR("BAR0 too small for GTT: 0x%"PRIxMAX" < 0x%"PRIxMAX | |
587 | "\n", | 597 | "\n", | |
588 | dev->bus_maps[0].bm_size, | 598 | (uintmax_t)dev->bus_maps[0].bm_size, | |
589 | (gtt->gtt_total_entries * sizeof(gtt_pte_t))); | 599 | (uintmax_t)(gtt->gtt_total_entries * sizeof(gtt_pte_t))); | |
590 | ret = -ENODEV; | 600 | ret = -ENODEV; | |
591 | goto fail0; | 601 | goto fail0; | |
592 | } | 602 | } | |
593 | if (bus_space_map(dev->bst, (dev->bus_maps[0].bm_base + (2<<20)), | 603 | if (bus_space_map(dev->bst, (dev->bus_maps[0].bm_base + (2<<20)), | |
594 | (gtt->gtt_total_entries * sizeof(gtt_pte_t)), | 604 | (gtt->gtt_total_entries * sizeof(gtt_pte_t)), | |
595 | 0, | 605 | 0, | |
596 | >t->gtt_bsh)) { | 606 | >t->gtt_bsh)) { | |
597 | DRM_ERROR("unable to map GTT\n"); | 607 | DRM_ERROR("unable to map GTT\n"); | |
598 | ret = -ENODEV; | 608 | ret = -ENODEV; | |
599 | goto fail0; | 609 | goto fail0; | |
600 | } | 610 | } | |
601 | 611 | |||
602 | ret = i915_gem_gtt_init_scratch_page(gtt, dev->dmat); | 612 | ret = i915_gem_gtt_init_scratch_page(gtt, dev->dmat); |
--- src/sys/external/bsd/drm2/i915drm/Attic/i915_pci.c 2014/04/03 14:45:44 1.3
+++ src/sys/external/bsd/drm2/i915drm/Attic/i915_pci.c 2014/04/03 19:18:29 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: i915_pci.c,v 1.3 2014/04/03 14:45:44 riastradh Exp $ */ | 1 | /* $NetBSD: i915_pci.c,v 1.4 2014/04/03 19:18:29 riastradh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Taylor R. Campbell. | 8 | * by Taylor R. Campbell. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -20,27 +20,27 @@ | @@ -20,27 +20,27 @@ | |||
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | __KERNEL_RCSID(0, "$NetBSD: i915_pci.c,v 1.3 2014/04/03 14:45:44 riastradh Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: i915_pci.c,v 1.4 2014/04/03 19:18:29 riastradh Exp $"); | |
34 | 34 | |||
35 | #include <sys/types.h> | 35 | #include <sys/types.h> | |
36 | #ifndef _MODULE | 36 | #ifndef _MODULE | |
37 | /* XXX Mega-kludge because modules are broken. */ | 37 | /* XXX Mega-kludge because modules are broken. */ | |
38 | #include <sys/once.h> | 38 | #include <sys/once.h> | |
39 | #endif | 39 | #endif | |
40 | #include <sys/systm.h> | 40 | #include <sys/systm.h> | |
41 | 41 | |||
42 | #include <dev/pci/pciio.h> | 42 | #include <dev/pci/pciio.h> | |
43 | #include <dev/pci/pcireg.h> | 43 | #include <dev/pci/pcireg.h> | |
44 | #include <dev/pci/pcivar.h> | 44 | #include <dev/pci/pcivar.h> | |
45 | 45 | |||
46 | #include <dev/pci/wsdisplay_pci.h> | 46 | #include <dev/pci/wsdisplay_pci.h> | |
@@ -412,28 +412,29 @@ i915drm_fb_probe(struct drm_fb_helper *f | @@ -412,28 +412,29 @@ i915drm_fb_probe(struct drm_fb_helper *f | |||
412 | &sc->sc_fb_bsh); | 412 | &sc->sc_fb_bsh); | |
413 | if (ret) { | 413 | if (ret) { | |
414 | aprint_error_dev(sc->sc_dev, "unable to map framebuffer: %d\n", | 414 | aprint_error_dev(sc->sc_dev, "unable to map framebuffer: %d\n", | |
415 | ret); | 415 | ret); | |
416 | goto fail3; | 416 | goto fail3; | |
417 | } | 417 | } | |
418 | 418 | |||
419 | prop_dictionary_set_bool(dict, "is_console", 1); /* XXX */ | 419 | prop_dictionary_set_bool(dict, "is_console", 1); /* XXX */ | |
420 | prop_dictionary_set_uint32(dict, "width", mode_cmd.width); | 420 | prop_dictionary_set_uint32(dict, "width", mode_cmd.width); | |
421 | prop_dictionary_set_uint32(dict, "height", mode_cmd.height); | 421 | prop_dictionary_set_uint32(dict, "height", mode_cmd.height); | |
422 | prop_dictionary_set_uint8(dict, "depth", sizes->surface_bpp); | 422 | prop_dictionary_set_uint8(dict, "depth", sizes->surface_bpp); | |
423 | prop_dictionary_set_uint16(dict, "linebytes", mode_cmd.pitches[0]); | 423 | prop_dictionary_set_uint16(dict, "linebytes", mode_cmd.pitches[0]); | |
424 | prop_dictionary_set_uint32(dict, "address", 0); /* XXX >32-bit */ | 424 | prop_dictionary_set_uint32(dict, "address", 0); /* XXX >32-bit */ | |
425 | CTASSERT(sizeof(uintptr_t) <= sizeof(uint64_t)); | |||
425 | prop_dictionary_set_uint64(dict, "virtual_address", | 426 | prop_dictionary_set_uint64(dict, "virtual_address", | |
426 | (uint64_t)bus_space_vaddr(dev->bst, sc->sc_fb_bsh)); | 427 | (uint64_t)(uintptr_t)bus_space_vaddr(dev->bst, sc->sc_fb_bsh)); | |
427 | sc->sc_genfb.sc_dev = sc->sc_dev; | 428 | sc->sc_genfb.sc_dev = sc->sc_dev; | |
428 | genfb_init(&sc->sc_genfb); | 429 | genfb_init(&sc->sc_genfb); | |
429 | 430 | |||
430 | genfb_ops.genfb_ioctl = i915drm_genfb_ioctl; | 431 | genfb_ops.genfb_ioctl = i915drm_genfb_ioctl; | |
431 | genfb_ops.genfb_mmap = i915drm_genfb_mmap; | 432 | genfb_ops.genfb_mmap = i915drm_genfb_mmap; | |
432 | 433 | |||
433 | /* XXX errno NetBSD->Linux */ | 434 | /* XXX errno NetBSD->Linux */ | |
434 | ret = -genfb_attach(&sc->sc_genfb, &genfb_ops); | 435 | ret = -genfb_attach(&sc->sc_genfb, &genfb_ops); | |
435 | if (ret) { | 436 | if (ret) { | |
436 | aprint_error_dev(sc->sc_dev, "unable to attach genfb: %d\n", | 437 | aprint_error_dev(sc->sc_dev, "unable to attach genfb: %d\n", | |
437 | ret); | 438 | ret); | |
438 | goto fail4; | 439 | goto fail4; | |
439 | } | 440 | } |
--- src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h 2014/03/18 18:20:43 1.2
+++ src/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h 2014/04/03 19:18:29 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: bus_dma_hacks.h,v 1.2 2014/03/18 18:20:43 riastradh Exp $ */ | 1 | /* $NetBSD: bus_dma_hacks.h,v 1.3 2014/04/03 19:18:29 riastradh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Taylor R. Campbell. | 8 | * by Taylor R. Campbell. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -42,27 +42,36 @@ | @@ -42,27 +42,36 @@ | |||
42 | 42 | |||
43 | static inline int | 43 | static inline int | |
44 | bus_dmamem_wire_uvm_object(bus_dma_tag_t tag, struct uvm_object *uobj, | 44 | bus_dmamem_wire_uvm_object(bus_dma_tag_t tag, struct uvm_object *uobj, | |
45 | off_t start, bus_size_t size, struct pglist *pages, bus_size_t alignment, | 45 | off_t start, bus_size_t size, struct pglist *pages, bus_size_t alignment, | |
46 | bus_size_t boundary, bus_dma_segment_t *segs, int nsegs, int *rsegs, | 46 | bus_size_t boundary, bus_dma_segment_t *segs, int nsegs, int *rsegs, | |
47 | int flags) | 47 | int flags) | |
48 | { | 48 | { | |
49 | struct pglist pageq; | 49 | struct pglist pageq; | |
50 | struct vm_page *page; | 50 | struct vm_page *page; | |
51 | bus_addr_t prev_addr, addr; | 51 | bus_addr_t prev_addr, addr; | |
52 | unsigned int i; | 52 | unsigned int i; | |
53 | int error; | 53 | int error; | |
54 | 54 | |||
55 | /* | |||
56 | * XXX `#ifdef __x86_64__' is a horrible way to work around a | |||
57 | * completely stupid GCC warning that encourages unsafe, | |||
58 | * nonportable code and has no obvious way to be selectively | |||
59 | * suppressed. | |||
60 | */ | |||
61 | #if __x86_64__ | |||
55 | KASSERT(size <= __type_max(off_t)); | 62 | KASSERT(size <= __type_max(off_t)); | |
63 | #endif | |||
64 | ||||
56 | KASSERT(start <= (__type_max(off_t) - size)); | 65 | KASSERT(start <= (__type_max(off_t) - size)); | |
57 | KASSERT(alignment == PAGE_SIZE); /* XXX */ | 66 | KASSERT(alignment == PAGE_SIZE); /* XXX */ | |
58 | KASSERT(0 < nsegs); | 67 | KASSERT(0 < nsegs); | |
59 | 68 | |||
60 | if (pages == NULL) { | 69 | if (pages == NULL) { | |
61 | TAILQ_INIT(&pageq); | 70 | TAILQ_INIT(&pageq); | |
62 | pages = &pageq; | 71 | pages = &pageq; | |
63 | } | 72 | } | |
64 | 73 | |||
65 | error = uvm_obj_wirepages(uobj, start, (start + size), pages); | 74 | error = uvm_obj_wirepages(uobj, start, (start + size), pages); | |
66 | if (error) | 75 | if (error) | |
67 | goto fail0; | 76 | goto fail0; | |
68 | 77 |
--- src/sys/external/bsd/drm2/include/linux/pci.h 2014/03/18 18:20:43 1.2
+++ src/sys/external/bsd/drm2/include/linux/pci.h 2014/04/03 19:18:29 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: pci.h,v 1.2 2014/03/18 18:20:43 riastradh Exp $ */ | 1 | /* $NetBSD: pci.h,v 1.3 2014/04/03 19:18:29 riastradh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Taylor R. Campbell. | 8 | * by Taylor R. Campbell. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -24,26 +24,27 @@ | @@ -24,26 +24,27 @@ | |||
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #ifndef _LINUX_PCI_H_ | 32 | #ifndef _LINUX_PCI_H_ | |
33 | #define _LINUX_PCI_H_ | 33 | #define _LINUX_PCI_H_ | |
34 | 34 | |||
35 | #include <sys/types.h> | 35 | #include <sys/types.h> | |
36 | #include <sys/bus.h> | 36 | #include <sys/bus.h> | |
37 | #include <sys/cdefs.h> | |||
37 | #include <sys/kmem.h> | 38 | #include <sys/kmem.h> | |
38 | #include <sys/systm.h> | 39 | #include <sys/systm.h> | |
39 | 40 | |||
40 | #include <dev/pci/pcidevs.h> | 41 | #include <dev/pci/pcidevs.h> | |
41 | #include <dev/pci/pcireg.h> | 42 | #include <dev/pci/pcireg.h> | |
42 | #include <dev/pci/pcivar.h> | 43 | #include <dev/pci/pcivar.h> | |
43 | 44 | |||
44 | #include <linux/ioport.h> | 45 | #include <linux/ioport.h> | |
45 | 46 | |||
46 | struct pci_bus; | 47 | struct pci_bus; | |
47 | 48 | |||
48 | struct pci_device_id { | 49 | struct pci_device_id { | |
49 | uint32_t vendor; | 50 | uint32_t vendor; | |
@@ -241,27 +242,27 @@ pci_bus_alloc_resource(struct pci_bus *b | @@ -241,27 +242,27 @@ pci_bus_alloc_resource(struct pci_bus *b | |||
241 | case IORESOURCE_MEM: | 242 | case IORESOURCE_MEM: | |
242 | bst = pa->pa_memt; | 243 | bst = pa->pa_memt; | |
243 | break; | 244 | break; | |
244 | 245 | |||
245 | case IORESOURCE_IO: | 246 | case IORESOURCE_IO: | |
246 | bst = pa->pa_iot; | 247 | bst = pa->pa_iot; | |
247 | break; | 248 | break; | |
248 | 249 | |||
249 | default: | 250 | default: | |
250 | panic("I don't know what kind of resource you want!"); | 251 | panic("I don't know what kind of resource you want!"); | |
251 | } | 252 | } | |
252 | 253 | |||
253 | resource->r_bst = bst; | 254 | resource->r_bst = bst; | |
254 | error = bus_space_alloc(bst, start, 0xffffffffffffffffULL /* XXX */, | 255 | error = bus_space_alloc(bst, start, __type_max(bus_addr_t), | |
255 | size, align, 0, 0, &resource->start, &resource->r_bsh); | 256 | size, align, 0, 0, &resource->start, &resource->r_bsh); | |
256 | if (error) | 257 | if (error) | |
257 | return error; | 258 | return error; | |
258 | 259 | |||
259 | resource->size = size; | 260 | resource->size = size; | |
260 | return 0; | 261 | return 0; | |
261 | } | 262 | } | |
262 | 263 | |||
263 | /* | 264 | /* | |
264 | * XXX Mega-kludgerific! pci_get_bus_and_slot and pci_get_class are | 265 | * XXX Mega-kludgerific! pci_get_bus_and_slot and pci_get_class are | |
265 | * defined only for their single purposes in i915drm, in | 266 | * defined only for their single purposes in i915drm, in | |
266 | * i915_get_bridge_dev and intel_detect_pch. We can't define them more | 267 | * i915_get_bridge_dev and intel_detect_pch. We can't define them more | |
267 | * generally without adapting pci_find_device (and pci_enumerate_bus | 268 | * generally without adapting pci_find_device (and pci_enumerate_bus |