Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Add mm_md_page_color hook and use to support better ...
details: https://anonhg.NetBSD.org/src/rev/cd4c51c08d25
branches: trunk
changeset: 346391:cd4c51c08d25
user: matt <matt%NetBSD.org@localhost>
date: Mon Jul 11 16:13:28 2016 +0000
description:
Add mm_md_page_color hook and use to support better page coloring.
diffstat:
sys/dev/mm.c | 21 +++++++++++++++------
sys/dev/mm.h | 8 +++++---
2 files changed, 20 insertions(+), 9 deletions(-)
diffs (89 lines):
diff -r 5a45a9e8af0f -r cd4c51c08d25 sys/dev/mm.c
--- a/sys/dev/mm.c Mon Jul 11 16:10:10 2016 +0000
+++ b/sys/dev/mm.c Mon Jul 11 16:13:28 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mm.c,v 1.20 2016/01/17 23:17:04 christos Exp $ */
+/* $NetBSD: mm.c,v 1.21 2016/07/11 16:13:28 matt Exp $ */
/*-
* Copyright (c) 2002, 2008, 2010 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mm.c,v 1.20 2016/01/17 23:17:04 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mm.c,v 1.21 2016/07/11 16:13:28 matt Exp $");
#include "opt_compat_netbsd.h"
@@ -128,11 +128,11 @@
* constant, general mapping address otherwise.
*/
static inline vaddr_t
-dev_mem_getva(paddr_t pa)
+dev_mem_getva(paddr_t pa, int color)
{
#ifdef __HAVE_MM_MD_CACHE_ALIASING
return uvm_km_alloc(kernel_map, PAGE_SIZE,
- atop(pa) & uvmexp.colormask,
+ color & uvmexp.colormask,
UVM_KMF_VAONLY | UVM_KMF_WAITVA | UVM_KMF_COLORMATCH);
#else
return dev_mem_addr;
@@ -161,6 +161,7 @@
size_t len, offset;
bool have_direct;
int error;
+ int color = 0;
/* Check for wrap around. */
if ((intptr_t)uio->uio_offset != uio->uio_offset) {
@@ -175,16 +176,24 @@
offset = uio->uio_offset & PAGE_MASK;
len = MIN(uio->uio_resid, PAGE_SIZE - offset);
+#ifdef __HAVE_MM_MD_CACHE_ALIASING
+ have_direct = mm_md_page_color(paddr, &color);
+#else
+ have_direct = true;
+ color = 0;
+#endif
+
#ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS
/* Is physical address directly mapped? Return VA. */
- have_direct = mm_md_direct_mapped_phys(paddr, &vaddr);
+ if (have_direct)
+ have_direct = mm_md_direct_mapped_phys(paddr, &vaddr);
#else
vaddr = 0;
have_direct = false;
#endif
if (!have_direct) {
/* Get a special virtual address. */
- const vaddr_t va = dev_mem_getva(paddr);
+ const vaddr_t va = dev_mem_getva(paddr, color);
/* Map selected KVA to physical address. */
mutex_enter(&dev_mem_lock);
diff -r 5a45a9e8af0f -r cd4c51c08d25 sys/dev/mm.h
--- a/sys/dev/mm.h Mon Jul 11 16:10:10 2016 +0000
+++ b/sys/dev/mm.h Mon Jul 11 16:13:28 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mm.h,v 1.2 2011/06/12 03:35:51 rmind Exp $ */
+/* $NetBSD: mm.h,v 1.3 2016/07/11 16:13:28 matt Exp $ */
/*-
* Copyright (c) 2008 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
@@ -88,8 +88,10 @@
/*
* Some architectures may need to deal with cache aliasing issues.
- *
- * machine/types.h must define __HAVE_MM_MD_CACHE_ALIASING to note that.
+ * Optional hook to fetch a page's current color and returns whether
+ * that page can be direct mapped.
+ * machine/types.h must define __HAVE_MM_MD_CACHE_ALIASING to use this.
*/
+bool mm_md_page_color(paddr_t, int *);
#endif /* _SYS_DEV_MM_H_ */
Home |
Main Index |
Thread Index |
Old Index