From c99b9aca9c2962ef4be1bf3cda8d110e16faab67 Mon Sep 17 00:00:00 2001 From: jhb Date: Thu, 5 Mar 2009 15:28:46 +0000 Subject: Honor the prefetchable flag in memory BARs by setting the RF_PREFETCHABLE flag when calling bus_alloc_resource() to allocate resources from a parent PCI bridge. For PCI-PCI bridges this asks the bridge to satisfy the request using the prefetchable memory range rather than the normal memory range. Reviewed by: imp Reported by: scottl MFC after: 1 week --- sys/dev/pci/pci.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'sys/dev/pci/pci.c') diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index df732ef..2eaff39 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -2313,9 +2313,11 @@ pci_add_map(device_t pcib, device_t bus, device_t dev, PCIB_WRITE_CONFIG(pcib, b, s, f, reg, map, 4); PCIB_WRITE_CONFIG(pcib, b, s, f, PCIR_COMMAND, cmd, 2); - if (PCI_BAR_MEM(map)) + if (PCI_BAR_MEM(map)) { type = SYS_RES_MEMORY; - else + if (map & PCIM_BAR_MEM_PREFETCH) + prefetch = 1; + } else type = SYS_RES_IOPORT; ln2size = pci_mapsize(testval); ln2range = pci_maprange(testval); @@ -3488,6 +3490,8 @@ pci_alloc_map(device_t dev, device_t child, int type, int *rid, count = 1UL << mapsize; if (RF_ALIGNMENT(flags) < mapsize) flags = (flags & ~RF_ALIGNMENT_MASK) | RF_ALIGNMENT_LOG2(mapsize); + if (PCI_BAR_MEM(testval) && (testval & PCIM_BAR_MEM_PREFETCH)) + flags |= RF_PREFETCHABLE; /* * Allocate enough resource, and then write back the -- cgit v1.1