e7739c1
From b30d458202bc0304c705eb081b12ead860584bea Mon Sep 17 00:00:00 2001
e7739c1
From: Keith Packard <keithp@keithp.com>
e7739c1
Date: Wed, 16  Apr  2008  19:10:52  +0000
e7739c1
Subject: Kludge around linux bug and turn off write-through and cache-disable bits
e7739c1
e7739c1
When mmaping the PCI device, the kernel turns on the write-through and
e7739c1
cache-disable bits in the allocated PTEs. This disables write-combining mode
e7739c1
and dramatically reduces write bandwidth to the frame buffer. While that
e7739c1
should be fixed in the kernel, we'll kludge around it here by using mprotect
e7739c1
to rewrite the PTEs and get those bits turned off.
e7739c1
---
e7739c1
diff --git a/src/linux_sysfs.c b/src/linux_sysfs.c
e7739c1
index 873dc02..78584d6 100644
e7739c1
--- a/src/linux_sysfs.c
e7739c1
+++ b/src/linux_sysfs.c
e7739c1
@@ -558,6 +558,9 @@ pci_device_linux_sysfs_map_range(struct pci_device *dev,
e7739c1
 		    strerror(errno), errno);
e7739c1
 /*            err = errno;*/
e7739c1
 	}
e7739c1
+	/* KLUDGE ALERT -- rewrite the PTEs to turn off the CD and WT bits */
e7739c1
+	mprotect (map->memory, map->size, PROT_NONE);
e7739c1
+	mprotect (map->memory, map->size, PROT_READ|PROT_WRITE);
e7739c1
     }
e7739c1
 #endif
e7739c1
 
e7739c1
--
e7739c1
cgit v0.7.2-37-g538c
e7739c1