OSDN Git Service

Kludge around linux bug and turn off write-through and cache-disable bits
authorKeith Packard <keithp@keithp.com>
Wed, 16 Apr 2008 19:10:52 +0000 (12:10 -0700)
committerKeith Packard <keithp@keithp.com>
Wed, 16 Apr 2008 19:11:18 +0000 (12:11 -0700)
When mmaping the PCI device, the kernel turns on the write-through and
cache-disable bits in the allocated PTEs. This disables write-combining mode
and dramatically reduces write bandwidth to the frame buffer. While that
should be fixed in the kernel, we'll kludge around it here by using mprotect
to rewrite the PTEs and get those bits turned off.

src/linux_sysfs.c

index 873dc02..78584d6 100644 (file)
@@ -558,6 +558,9 @@ pci_device_linux_sysfs_map_range(struct pci_device *dev,
                    strerror(errno), errno);
 /*            err = errno;*/
        }
+       /* KLUDGE ALERT -- rewrite the PTEs to turn off the CD and WT bits */
+       mprotect (map->memory, map->size, PROT_NONE);
+       mprotect (map->memory, map->size, PROT_READ|PROT_WRITE);
     }
 #endif