Sun Mar 1 10:07:01 2015 UTC ()
fix some comments about the half-working i386 hack.


(mrg)
diff -r1.6 -r1.7 src/sys/external/bsd/drm2/radeon/radeon_pci.c

cvs diff -r1.6 -r1.7 src/sys/external/bsd/drm2/radeon/radeon_pci.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/radeon/radeon_pci.c 2015/02/16 12:17:57 1.6
+++ src/sys/external/bsd/drm2/radeon/radeon_pci.c 2015/03/01 10:07:01 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: radeon_pci.c,v 1.6 2015/02/16 12:17:57 mrg Exp $ */ 1/* $NetBSD: radeon_pci.c,v 1.7 2015/03/01 10:07:01 mrg Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc. 4 * Copyright (c) 2014 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: radeon_pci.c,v 1.6 2015/02/16 12:17:57 mrg Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: radeon_pci.c,v 1.7 2015/03/01 10:07:01 mrg Exp $");
34 34
35#ifdef _KERNEL_OPT 35#ifdef _KERNEL_OPT
36#include "vga.h" 36#include "vga.h"
37#endif 37#endif
38 38
39#include <sys/types.h> 39#include <sys/types.h>
40#include <sys/queue.h> 40#include <sys/queue.h>
41#include <sys/systm.h> 41#include <sys/systm.h>
42#include <sys/workqueue.h> 42#include <sys/workqueue.h>
43 43
44#include <dev/pci/pciio.h> 44#include <dev/pci/pciio.h>
45#include <dev/pci/pcireg.h> 45#include <dev/pci/pcireg.h>
46#include <dev/pci/pcivar.h> 46#include <dev/pci/pcivar.h>
@@ -72,27 +72,27 @@ SIMPLEQ_HEAD(radeon_task_head, radeon_ta @@ -72,27 +72,27 @@ SIMPLEQ_HEAD(radeon_task_head, radeon_ta
72struct radeon_softc { 72struct radeon_softc {
73 device_t sc_dev; 73 device_t sc_dev;
74 struct pci_attach_args sc_pa; 74 struct pci_attach_args sc_pa;
75 enum { 75 enum {
76 RADEON_TASK_ATTACH, 76 RADEON_TASK_ATTACH,
77 RADEON_TASK_WORKQUEUE, 77 RADEON_TASK_WORKQUEUE,
78 } sc_task_state; 78 } sc_task_state;
79 union { 79 union {
80 struct workqueue *workqueue; 80 struct workqueue *workqueue;
81 struct radeon_task_head attach; 81 struct radeon_task_head attach;
82 } sc_task_u; 82 } sc_task_u;
83 struct drm_device *sc_drm_dev; 83 struct drm_device *sc_drm_dev;
84 struct pci_dev sc_pci_dev; 84 struct pci_dev sc_pci_dev;
85#ifdef __i386__ 85#if defined(__i386__)
86#define RADEON_PCI_UGLY_MAP_HACK 86#define RADEON_PCI_UGLY_MAP_HACK
87 /* XXX Used to claim the VGA device before attach_real */ 87 /* XXX Used to claim the VGA device before attach_real */
88 bus_space_handle_t sc_temp_memh; 88 bus_space_handle_t sc_temp_memh;
89 bool sc_temp_set; 89 bool sc_temp_set;
90#endif 90#endif
91}; 91};
92 92
93struct radeon_device * 93struct radeon_device *
94radeon_device_private(device_t self) 94radeon_device_private(device_t self)
95{ 95{
96 struct radeon_softc *const sc = device_private(self); 96 struct radeon_softc *const sc = device_private(self);
97 97
98 return sc->sc_drm_dev->dev_private; 98 return sc->sc_drm_dev->dev_private;
@@ -164,29 +164,30 @@ radeon_attach(device_t parent, device_t  @@ -164,29 +164,30 @@ radeon_attach(device_t parent, device_t
164 pci_aprint_devinfo(pa, NULL); 164 pci_aprint_devinfo(pa, NULL);
165 165
166 /* 166 /*
167 * Trivial initialization first; the rest will come after we 167 * Trivial initialization first; the rest will come after we
168 * have mounted the root file system and can load firmware 168 * have mounted the root file system and can load firmware
169 * images. 169 * images.
170 */ 170 */
171 sc->sc_dev = NULL; 171 sc->sc_dev = NULL;
172 sc->sc_pa = *pa; 172 sc->sc_pa = *pa;
173 173
174#ifdef RADEON_PCI_UGLY_MAP_HACK 174#ifdef RADEON_PCI_UGLY_MAP_HACK
175 /* 175 /*
176 * XXX 176 * XXX
177 * We map the VGA registers, so that other driver don't 177 * We try to map the VGA registers, in case we can prevent vga@isa or
178 * think they can. This stops vga@isa or pcdisplay@isa 178 * pcdisplay@isa attaching, and stealing wsdisplay0. This only works
179 * attaching, and stealing wsdisplay0. Yuck. 179 * with serial console, as actual VGA console has already mapped them.
 180 * The only way to handle that is for vga@isa to not attach.
180 */ 181 */
181 int rv = bus_space_map(pa->pa_memt, 0xb0000, 0x10000, 0, 182 int rv = bus_space_map(pa->pa_memt, 0xb0000, 0x10000, 0,
182 &sc->sc_temp_memh); 183 &sc->sc_temp_memh);
183 sc->sc_temp_set = rv == 0; 184 sc->sc_temp_set = rv == 0;
184 if (rv != 0) 185 if (rv != 0)
185 aprint_error_dev(self, "unable to reserve VGA registers for " 186 aprint_error_dev(self, "unable to reserve VGA registers for "
186 "i386 radeondrmkms hack\n"); 187 "i386 radeondrmkms hack\n");
187#endif 188#endif
188 189
189 config_mountroot(self, &radeon_attach_real); 190 config_mountroot(self, &radeon_attach_real);
190} 191}
191 192
192static void 193static void
@@ -194,27 +195,27 @@ radeon_attach_real(device_t self) @@ -194,27 +195,27 @@ radeon_attach_real(device_t self)
194{ 195{
195 struct radeon_softc *const sc = device_private(self); 196 struct radeon_softc *const sc = device_private(self);
196 const struct pci_attach_args *const pa = &sc->sc_pa; 197 const struct pci_attach_args *const pa = &sc->sc_pa;
197 bool ok __diagused; 198 bool ok __diagused;
198 unsigned long flags; 199 unsigned long flags;
199 int error; 200 int error;
200 201
201 ok = radeon_pci_lookup(pa, &flags); 202 ok = radeon_pci_lookup(pa, &flags);
202 KASSERT(ok); 203 KASSERT(ok);
203 204
204#ifdef RADEON_PCI_UGLY_MAP_HACK 205#ifdef RADEON_PCI_UGLY_MAP_HACK
205 /* 206 /*
206 * XXX 207 * XXX
207 * Unmap the VGA registers so the DRM code can map them. 208 * Unmap the VGA registers.
208 */ 209 */
209 if (sc->sc_temp_set) 210 if (sc->sc_temp_set)
210 bus_space_unmap(pa->pa_memt, sc->sc_temp_memh, 0x10000); 211 bus_space_unmap(pa->pa_memt, sc->sc_temp_memh, 0x10000);
211#endif 212#endif
212 213
213 sc->sc_task_state = RADEON_TASK_ATTACH; 214 sc->sc_task_state = RADEON_TASK_ATTACH;
214 SIMPLEQ_INIT(&sc->sc_task_u.attach); 215 SIMPLEQ_INIT(&sc->sc_task_u.attach);
215 216
216 /* XXX errno Linux->NetBSD */ 217 /* XXX errno Linux->NetBSD */
217 error = -drm_pci_attach(self, pa, &sc->sc_pci_dev, radeon_drm_driver, 218 error = -drm_pci_attach(self, pa, &sc->sc_pci_dev, radeon_drm_driver,
218 flags, &sc->sc_drm_dev); 219 flags, &sc->sc_drm_dev);
219 if (error) { 220 if (error) {
220 aprint_error_dev(self, "unable to attach drm: %d\n", error); 221 aprint_error_dev(self, "unable to attach drm: %d\n", error);