summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2015-02-08 06:21:05 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2015-02-08 06:21:05 +0000
commit29861f9d6f3cf157a67389074bc91cb6423ded20 (patch)
tree7adb89754acc68510ba661a457fd3dc03b393ac6 /sys/arch
parent955461a281f44c6fa053283529a98db609b5f7b1 (diff)
Do not assume that addresses passed to bus_space_map(9) are relative
to the bus base address, that's not the case with radeondrm(9) cards on G5. From miod@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/powerpc/powerpc/bus_space.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/sys/arch/powerpc/powerpc/bus_space.c b/sys/arch/powerpc/powerpc/bus_space.c
index e87d44c5acf..578654bddf5 100644
--- a/sys/arch/powerpc/powerpc/bus_space.c
+++ b/sys/arch/powerpc/powerpc/bus_space.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus_space.c,v 1.2 2015/01/22 17:55:46 mpi Exp $ */
+/* $OpenBSD: bus_space.c,v 1.3 2015/02/08 06:21:04 mpi Exp $ */
/* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */
/*
@@ -59,7 +59,14 @@ bus_space_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size,
/* if bus has base of 0 fail. */
return EINVAL;
}
- bpa |= POWERPC_BUS_TAG_BASE(t);
+
+ /*
+ * The address may, or may not, be relative to the
+ * base address of this bus.
+ */
+ if (bpa < POWERPC_BUS_TAG_BASE(t))
+ bpa += POWERPC_BUS_TAG_BASE(t);
+
if ((error = extent_alloc_region(devio_ex, bpa, size, EX_NOWAIT |
(ppc_malloc_ok ? EX_MALLOCOK : 0))))
return error;
@@ -125,7 +132,12 @@ bus_space_mmap(bus_space_tag_t t, bus_addr_t bpa, off_t off, int prot,
if (POWERPC_BUS_TAG_BASE(t) == 0)
return (-1);
- bpa |= POWERPC_BUS_TAG_BASE(t);
+ /*
+ * The address may, or may not, be relative to the
+ * base address of this bus.
+ */
+ if (bpa < POWERPC_BUS_TAG_BASE(t))
+ bpa += POWERPC_BUS_TAG_BASE(t);
if (flags & BUS_SPACE_MAP_CACHEABLE)
pmapflags &= ~PMAP_NOCACHE;