Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/drm2/include/linux io_mapping_init/fini
details: https://anonhg.NetBSD.org/src/rev/3857f7fd43e7
branches: trunk
changeset: 1028001:3857f7fd43e7
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Dec 19 01:34:30 2021 +0000
description:
io_mapping_init/fini
diffstat:
sys/external/bsd/drm2/include/linux/io-mapping.h | 43 +++++++++++++++++------
1 files changed, 32 insertions(+), 11 deletions(-)
diffs (81 lines):
diff -r 5c1c4e4a8821 -r 3857f7fd43e7 sys/external/bsd/drm2/include/linux/io-mapping.h
--- a/sys/external/bsd/drm2/include/linux/io-mapping.h Sun Dec 19 01:34:23 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/io-mapping.h Sun Dec 19 01:34:30 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: io-mapping.h,v 1.6 2021/12/19 01:25:28 riastradh Exp $ */
+/* $NetBSD: io-mapping.h,v 1.7 2021/12/19 01:34:30 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -48,11 +48,10 @@
bool diom_mapped;
};
-static inline struct io_mapping *
-bus_space_io_mapping_create_wc(bus_space_tag_t bst, bus_addr_t addr,
- bus_size_t size)
+static inline bool
+bus_space_io_mapping_init_wc(bus_space_tag_t bst, struct io_mapping *mapping,
+ bus_addr_t addr, bus_size_t size)
{
- struct io_mapping *mapping;
bus_size_t offset;
KASSERT(PAGE_SIZE <= size);
@@ -71,11 +70,10 @@
if (bus_space_mmap(bst, addr, offset, PROT_READ|PROT_WRITE,
BUS_SPACE_MAP_LINEAR|BUS_SPACE_MAP_PREFETCHABLE)
== (paddr_t)-1)
- return NULL;
+ return false;
}
- /* Create a mapping record. */
- mapping = kmem_alloc(sizeof(*mapping), KM_SLEEP);
+ /* Initialize the mapping record. */
mapping->diom_bst = bst;
mapping->diom_addr = addr;
mapping->diom_size = size;
@@ -86,6 +84,31 @@
UVM_KMF_VAONLY | UVM_KMF_WAITVA);
KASSERT(mapping->diom_va != 0);
+ return true;
+}
+
+static inline void
+io_mapping_fini(struct io_mapping *mapping)
+{
+
+ KASSERT(!mapping->diom_mapped);
+
+ uvm_km_free(kernel_map, mapping->diom_va, PAGE_SIZE, UVM_KMF_VAONLY);
+ mapping->diom_va = 0; /* paranoia */
+}
+
+static inline struct io_mapping *
+bus_space_io_mapping_create_wc(bus_space_tag_t bst, bus_addr_t addr,
+ bus_size_t size)
+{
+ struct io_mapping *mapping;
+
+ mapping = kmem_alloc(sizeof(*mapping), KM_SLEEP);
+ if (!bus_space_io_mapping_init_wc(bst, mapping, addr, size)) {
+ kmem_free(mapping, sizeof(*mapping));
+ return NULL;
+ }
+
return mapping;
}
@@ -93,9 +116,7 @@
io_mapping_free(struct io_mapping *mapping)
{
- KASSERT(!mapping->diom_mapped);
-
- uvm_km_free(kernel_map, mapping->diom_va, PAGE_SIZE, UVM_KMF_VAONLY);
+ io_mapping_fini(mapping);
kmem_free(mapping, sizeof(*mapping));
}
Home |
Main Index |
Thread Index |
Old Index