Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/riastradh-drm2]: src/sys/external/bsd/drm2/include/linux Just use bus_sp...
details: https://anonhg.NetBSD.org/src/rev/362e4bb2436c
branches: riastradh-drm2
changeset: 788558:362e4bb2436c
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Sep 08 16:19:15 2013 +0000
description:
Just use bus_space_map for io-mapping, and limit to one at a time.
Reserving the whole region interferes with other parts of the driver
which want to map it in different ways. It also horrifically wastes
space when actually mapped, because there's no way to map a subregion
of a reservation. And the bus_space_reservation API is x86-only at
the moment.
diffstat:
sys/external/bsd/drm2/include/linux/io-mapping.h | 42 ++++++++++-------------
1 files changed, 18 insertions(+), 24 deletions(-)
diffs (95 lines):
diff -r c298a41698ad -r 362e4bb2436c sys/external/bsd/drm2/include/linux/io-mapping.h
--- a/sys/external/bsd/drm2/include/linux/io-mapping.h Sun Sep 08 16:17:58 2013 +0000
+++ b/sys/external/bsd/drm2/include/linux/io-mapping.h Sun Sep 08 16:19:15 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: io-mapping.h,v 1.1.2.2 2013/07/24 03:17:48 riastradh Exp $ */
+/* $NetBSD: io-mapping.h,v 1.1.2.3 2013/09/08 16:19:15 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -36,19 +36,13 @@
#include <sys/kmem.h>
#include <sys/systm.h>
-/*
- * XXX This uses NetBSD bus space reservations, which are currently
- * implemented only for x86.
- */
-
struct io_mapping {
bus_space_tag_t diom_bst;
bus_addr_t diom_addr;
- bus_addr_t diom_size;
+ bus_size_t diom_size;
int diom_flags;
- bus_space_reservation_t diom_bsr;
- bool diom_mapped;
bus_space_handle_t diom_bsh;
+ void *diom_vaddr;
};
static inline struct io_mapping *
@@ -63,13 +57,15 @@
mapping->diom_flags = 0;
mapping->diom_flags |= BUS_SPACE_MAP_LINEAR;
mapping->diom_flags |= BUS_SPACE_MAP_PREFETCHABLE;
- mapping->diom_mapped = false;
+ mapping->diom_vaddr = NULL;
- if (bus_space_reserve(mapping->diom_bst, addr, size,
- mapping->diom_flags, &mapping->diom_bsr)) {
+ bus_space_handle_t bsh;
+ if (bus_space_map(mapping->diom_bst, addr, PAGE_SIZE,
+ mapping->diom_flags, &bsh)) {
kmem_free(mapping, sizeof(*mapping));
return NULL;
}
+ bus_space_unmap(mapping->diom_bst, bsh, PAGE_SIZE);
return mapping;
}
@@ -78,8 +74,7 @@
io_mapping_free(struct io_mapping *mapping)
{
- KASSERT(!mapping->diom_mapped);
- bus_space_release(mapping->diom_bst, &mapping->diom_bsr);
+ KASSERT(mapping->diom_vaddr == NULL);
kmem_free(mapping, sizeof(*mapping));
}
@@ -87,25 +82,24 @@
io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset)
{
- KASSERT(!mapping->diom_mapped);
+ KASSERT(mapping->diom_vaddr == NULL);
KASSERT(ISSET(mapping->diom_flags, BUS_SPACE_MAP_LINEAR));
- if (bus_space_reservation_map(mapping->diom_bst, &mapping->diom_bsr,
- mapping->diom_flags, &mapping->diom_bsh))
+ if (bus_space_map(mapping->diom_bst, (mapping->diom_addr + offset),
+ PAGE_SIZE, mapping->diom_flags, &mapping->diom_bsh))
panic("Unable to make I/O mapping!"); /* XXX */
- mapping->diom_mapped = true;
+ mapping->diom_vaddr = bus_space_vaddr(mapping->diom_bst,
+ mapping->diom_bsh);
- return (char *)bus_space_vaddr(mapping->diom_bst, mapping->diom_bsh)
- + offset; /* XXX arithmetic overflow */
+ return mapping->diom_vaddr;
}
static inline void
io_mapping_unmap(struct io_mapping *mapping, void *vaddr __unused)
{
- KASSERT(mapping->diom_mapped);
- bus_space_reservation_unmap(mapping->diom_bst, mapping->diom_bsh,
- mapping->diom_size);
- mapping->diom_mapped = false;
+ KASSERT(mapping->diom_vaddr == vaddr);
+ bus_space_unmap(mapping->diom_bst, mapping->diom_bsh, PAGE_SIZE);
+ mapping->diom_vaddr = NULL;
}
static inline void *
Home |
Main Index |
Thread Index |
Old Index