FreeBSD: don't set the MTRR if it's the default mode (uncacheable).
authorEric Anholt <eric@anholt.net>
Tue, 9 Oct 2007 19:12:34 +0000 (12:12 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 9 Oct 2007 19:12:34 +0000 (12:12 -0700)
src/freebsd_pci.c

index 84a0a78..be934a8 100644 (file)
@@ -108,8 +108,11 @@ pci_device_freebsd_map_range(struct pci_device *dev,
     mro.mo_desc = &mrd;
     mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
 
-    if (ioctl(fd, MEMRANGE_SET, &mro)) {
-       fprintf(stderr, "failed to set mtrr: %s\n", strerror(errno));
+    /* No need to set an MTRR if it's the default mode. */
+    if (mrd.mr_flags != MDF_UNCACHEABLE) {
+       if (ioctl(fd, MEMRANGE_SET, &mro)) {
+           fprintf(stderr, "failed to set mtrr: %s\n", strerror(errno));
+       }
     }
 
     close(fd);