Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci don't access registers when they're not mapped
details: https://anonhg.NetBSD.org/src/rev/3789d8930d79
branches: trunk
changeset: 783417:3789d8930d79
user: macallan <macallan%NetBSD.org@localhost>
date: Thu Dec 20 03:08:39 2012 +0000
description:
don't access registers when they're not mapped
now X works on i386 with radeonfb
diffstat:
sys/dev/pci/radeonfb.c | 44 ++++++++++++++++++++++++++++++--------------
sys/dev/pci/radeonfbvar.h | 4 +++-
2 files changed, 33 insertions(+), 15 deletions(-)
diffs (110 lines):
diff -r c3974aedf966 -r 3789d8930d79 sys/dev/pci/radeonfb.c
--- a/sys/dev/pci/radeonfb.c Thu Dec 20 02:58:32 2012 +0000
+++ b/sys/dev/pci/radeonfb.c Thu Dec 20 03:08:39 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: radeonfb.c,v 1.67 2012/12/20 02:58:32 macallan Exp $ */
+/* $NetBSD: radeonfb.c,v 1.68 2012/12/20 03:08:39 macallan Exp $ */
/*-
* Copyright (c) 2006 Itronix Inc.
@@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.67 2012/12/20 02:58:32 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.68 2012/12/20 03:08:39 macallan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -547,6 +547,8 @@
}
sc->sc_romt = sc->sc_memt;
+ sc->sc_mapped = TRUE;
+
/* scratch register test... */
if (radeonfb_scratch_test(sc, RADEON_BIOS_0_SCRATCH, 0x55555555) ||
radeonfb_scratch_test(sc, RADEON_BIOS_0_SCRATCH, 0xaaaaaaaa)) {
@@ -974,24 +976,32 @@
static void
radeonfb_map(struct radeonfb_softc *sc)
{
- if (bus_space_map(sc->sc_regt, sc->sc_regaddr, sc->sc_regsz, 0,
- &sc->sc_regh) != 0) {
- aprint_error("%s: unable to map registers!\n", XNAME(sc));
- return;
- }
- if (bus_space_map(sc->sc_memt, sc->sc_memaddr, sc->sc_memsz,
- BUS_SPACE_MAP_LINEAR, &sc->sc_memh) != 0) {
- sc->sc_memsz = 0;
- aprint_error("%s: Unable to map frame buffer\n", XNAME(sc));
- return;
+ if (!sc->sc_mapped) {
+ if (bus_space_map(sc->sc_regt, sc->sc_regaddr, sc->sc_regsz, 0,
+ &sc->sc_regh) != 0) {
+ aprint_error_dev(sc->sc_dev,
+ "unable to map registers!\n");
+ return;
+ }
+ if (bus_space_map(sc->sc_memt, sc->sc_memaddr, sc->sc_memsz,
+ BUS_SPACE_MAP_LINEAR, &sc->sc_memh) != 0) {
+ sc->sc_memsz = 0;
+ aprint_error_dev(sc->sc_dev,
+ "Unable to map frame buffer\n");
+ return;
+ }
+ sc->sc_mapped = TRUE;
}
}
static void
radeonfb_unmap(struct radeonfb_softc *sc)
{
- bus_space_unmap(sc->sc_regt, sc->sc_regh, sc->sc_regsz);
- bus_space_unmap(sc->sc_memt, sc->sc_memh, sc->sc_memsz);
+ if (sc->sc_mapped) {
+ bus_space_unmap(sc->sc_regt, sc->sc_regh, sc->sc_regsz);
+ bus_space_unmap(sc->sc_memt, sc->sc_memh, sc->sc_memsz);
+ sc->sc_mapped = FALSE;
+ }
}
static int
@@ -2177,6 +2187,9 @@
{
uint32_t reg, mask;
+ if(!dp->rd_softc->sc_mapped)
+ return 1;
+
if (dp->rd_crtcs[0].rc_number) {
reg = RADEON_CRTC2_GEN_CNTL;
mask = RADEON_CRTC2_DISP_DIS;
@@ -2195,6 +2208,9 @@
uint32_t fpreg, fpval;
int i;
+ if (!sc->sc_mapped)
+ return;
+
for (i = 0; i < dp->rd_ncrtcs; i++) {
if (dp->rd_crtcs[i].rc_number) {
diff -r c3974aedf966 -r 3789d8930d79 sys/dev/pci/radeonfbvar.h
--- a/sys/dev/pci/radeonfbvar.h Thu Dec 20 02:58:32 2012 +0000
+++ b/sys/dev/pci/radeonfbvar.h Thu Dec 20 03:08:39 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: radeonfbvar.h,v 1.16 2012/03/15 05:47:19 macallan Exp $ */
+/* $NetBSD: radeonfbvar.h,v 1.17 2012/12/20 03:08:39 macallan Exp $ */
/*-
* Copyright (c) 2006 Itronix Inc.
@@ -233,6 +233,8 @@
bus_size_t sc_iosz;
bus_addr_t sc_ioaddr;
+ int sc_mapped;
+
/* size of a single display */
int sc_maxx;
int sc_maxy;
Home |
Main Index |
Thread Index |
Old Index