summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2016-05-07 22:46:54 +0000
committerkettenis <kettenis@openbsd.org>2016-05-07 22:46:54 +0000
commita24104fb51fd861f7d242c4f28afab2e22cbf697 (patch)
treedce719b68b3e1b0db8d130bb3549f1746cfaaab3
parentremove reference to file that's only built when dbm is present (diff)
downloadwireguard-openbsd-a24104fb51fd861f7d242c4f28afab2e22cbf697.tar.xz
wireguard-openbsd-a24104fb51fd861f7d242c4f28afab2e22cbf697.zip
Flush page (through the direct map) before mapping it into AGP. Fixes
artifacts seen in X on some G5 machines. Unfortunately not enough to fix G4 machines. With help from Marcus Glocker. ok mpi@
-rw-r--r--sys/arch/powerpc/include/cpu.h18
-rw-r--r--sys/dev/pci/agp_apple.c5
2 files changed, 20 insertions, 3 deletions
diff --git a/sys/arch/powerpc/include/cpu.h b/sys/arch/powerpc/include/cpu.h
index 8efe02d895b..494dccb3b1a 100644
--- a/sys/arch/powerpc/include/cpu.h
+++ b/sys/arch/powerpc/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.62 2015/07/02 01:33:59 dlg Exp $ */
+/* $OpenBSD: cpu.h,v 1.63 2016/05/07 22:46:54 kettenis Exp $ */
/* $NetBSD: cpu.h,v 1.1 1996/09/30 16:34:21 ws Exp $ */
/*
@@ -232,6 +232,22 @@ invdcache(void *from, int len)
__asm volatile ("sync");
}
+static __inline void
+flushdcache(void *from, int len)
+{
+ int l;
+ char *p = from;
+
+ len = len + (((u_int32_t) from) & (CACHELINESIZE - 1));
+ l = len;
+
+ do {
+ __asm volatile ("dcbf 0,%0" :: "r"(p));
+ p += CACHELINESIZE;
+ } while ((l -= CACHELINESIZE) > 0);
+ __asm volatile ("sync");
+}
+
#define FUNC_SPR(n, name) \
static __inline u_int32_t ppc_mf ## name (void) \
{ \
diff --git a/sys/dev/pci/agp_apple.c b/sys/dev/pci/agp_apple.c
index 3b061671ce3..e9b5f81f492 100644
--- a/sys/dev/pci/agp_apple.c
+++ b/sys/dev/pci/agp_apple.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: agp_apple.c,v 1.7 2015/12/19 11:29:41 mpi Exp $ */
+/* $OpenBSD: agp_apple.c,v 1.8 2016/05/07 22:46:54 kettenis Exp $ */
/*
* Copyright (c) 2012 Martin Pieuchot <mpi@openbsd.org>
@@ -187,8 +187,9 @@ agp_apple_bind_page(void *v, bus_addr_t off, paddr_t pa, int flags)
else
entry = htole32(pa | 0x01);
- asc->gatt->ag_virtual[off >> AGP_PAGE_SHIFT] = entry;
+ flushdcache((void *)pa, PAGE_SIZE);
+ asc->gatt->ag_virtual[off >> AGP_PAGE_SHIFT] = entry;
flushd(&asc->gatt->ag_virtual[off >> AGP_PAGE_SHIFT]);
}