]> xenbits.xensource.com Git - xen.git/commitdiff
hvmloader: Load large devices into high MMIO space as needed
authorGeorge Dunlap <george.dunlap@eu.citrix.com>
Tue, 18 Jun 2013 14:32:35 +0000 (15:32 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 24 Jun 2013 11:20:29 +0000 (12:20 +0100)
Keep track of how much mmio space is left total, as well as the amount
of "low" MMIO space (<4GiB), and only load devices into high memory if
there is not enough low memory for the rest of the devices to fit.

Because devices are processed by size in order from large to small,
this should preferentially relocate devices with large BARs to 64-bit
space.

v3:
 - Just use mmio_total rather than introducing a new variable.
 - Port to using mem_resource directly rather than low_mmio_left

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Ian Campbell <ian.campbell@citrix.com>
CC: Stefano Stabellini <stefano.stabellini@citrix.com>
CC: Hanweidong <hanweidong@huawei.com>
CC: Keir Fraser <keir@xen.org>
tools/firmware/hvmloader/pci.c

index 1fe250ddc7030458f8d311fca39d204b2e2513fa..68d4e44028bea6ca471de97d7eb31d12514dc8f2 100644 (file)
@@ -271,6 +271,11 @@ void pci_setup(void)
         bar_sz  = bars[i].bar_sz;
 
         /*
+         * Relocate to high memory if the total amount of MMIO needed
+         * is more than the low MMIO available.  Because devices are
+         * processed in order of bar_sz, this will preferentially
+         * relocate larger devices to high memory first.
+         *
          * NB: The code here is rather fragile, as the check here to see
          * whether bar_sz will fit in the low MMIO region doesn't match the
          * real check made below, which involves aligning the base offset of the
@@ -284,7 +289,7 @@ void pci_setup(void)
          * Should either of those two conditions change, this code will break.
          */
         using_64bar = bars[i].is_64bar && bar64_relocate
-            && (bar_sz > (mem_resource.max - mem_resource.base));
+            && (mmio_total > (mem_resource.max - mem_resource.base));
         bar_data = pci_readl(devfn, bar_reg);
 
         if ( (bar_data & PCI_BASE_ADDRESS_SPACE) ==
@@ -306,6 +311,7 @@ void pci_setup(void)
                 resource = &mem_resource;
                 bar_data &= ~PCI_BASE_ADDRESS_MEM_MASK;
             }
+            mmio_total -= bar_sz;
         }
         else
         {