From 042735df2aa5846fcabfd74c5f73877132728b25 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 9 Oct 2007 12:12:34 -0700 Subject: [PATCH] FreeBSD: don't set the MTRR if it's the default mode (uncacheable). --- src/freebsd_pci.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/freebsd_pci.c b/src/freebsd_pci.c index 84a0a78..be934a8 100644 --- a/src/freebsd_pci.c +++ b/src/freebsd_pci.c @@ -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); -- 2.11.0