diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c index a60df25..dfb7af7 100644 --- a/hw/xfree86/os-support/bus/linuxPci.c +++ b/hw/xfree86/os-support/bus/linuxPci.c @@ -392,22 +392,26 @@ pointer xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev, ADDRESS Base, unsigned long Size) { - int fd = -1; - pointer addr; + pointer addr = NULL; /* * We use /proc/bus/pci on non-legacy addresses or if the Linux sysfs * legacy_mem interface is unavailable. */ - if ((Base > 1024*1024) || ((fd = linuxOpenLegacy(dev, "legacy_mem")) < 0)) - return linuxMapPci(ScreenNum, Flags, dev, Base, Size, + if (Base <= 1024*1024) { + int fd = linuxOpenLegacy(dev, "legacy_mem"); + + if (fd >= 0) { + addr = mmap(NULL, Size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, Base); + close(fd); + } + } + + if (addr == NULL || addr == MAP_FAILED) + addr = linuxMapPci(ScreenNum, Flags, dev, Base, Size, PCIIOC_MMAP_IS_MEM); - else - addr = mmap(NULL, Size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, Base); - if (fd >= 0) - close(fd); - if (addr == NULL || addr == MAP_FAILED) { + if ((Base <= 1024*1024) && (addr == NULL || addr == MAP_FAILED)) { perror("mmap failure"); FatalError("xf86MapDomainMem(): mmap() failure\n"); }