xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: George Dunlap <george.dunlap@eu.citrix.com>
To: xen-devel@lists.xen.org
Cc: Keir Fraser <keir@xen.org>,
	Ian Campbell <ian.campbell@citrix.com>,
	Hanweidong <hanweidong@huawei.com>,
	George Dunlap <george.dunlap@eu.citrix.com>,
	Stefano Stabellini <stefano.stabellini@citrix.com>,
	Ian Jackson <ian.jackson@citrix.com>
Subject: [PATCH v3 6/8] hvmloader: Load large devices into high MMIO space as needed
Date: Thu, 20 Jun 2013 17:33:25 +0100	[thread overview]
Message-ID: <1371746007-19073-7-git-send-email-george.dunlap@eu.citrix.com> (raw)
In-Reply-To: <1371746007-19073-1-git-send-email-george.dunlap@eu.citrix.com>

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>
CC: Ian Jackson <ian.jackson@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 |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/firmware/hvmloader/pci.c b/tools/firmware/hvmloader/pci.c
index 606ccca..ac55d3e 100644
--- a/tools/firmware/hvmloader/pci.c
+++ b/tools/firmware/hvmloader/pci.c
@@ -264,8 +264,12 @@ void pci_setup(void)
         bar_reg = bars[i].bar_reg;
         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. */
         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) ==
@@ -287,6 +291,7 @@ void pci_setup(void)
                 resource = &mem_resource;
                 bar_data &= ~PCI_BASE_ADDRESS_MEM_MASK;
             }
+            mmio_total -= bar_sz;
         }
         else
         {
-- 
1.7.9.5

  parent reply	other threads:[~2013-06-20 16:33 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-20 16:33 [PATCH 0/8] Relocate devices rather than memory for qemu-xen George Dunlap
2013-06-20 16:33 ` [PATCH v3 1/8] hvmloader: Remove all 64-bit print arguments George Dunlap
2013-06-20 17:06   ` Stefano Stabellini
2013-06-20 17:09     ` Ian Jackson
2013-06-21  8:37       ` George Dunlap
2013-06-21  8:34     ` George Dunlap
2013-06-21  9:22       ` George Dunlap
2013-06-21 10:22   ` [PATCH v3 1/8] hvmloader: Remove all 64-bit print arguments [and 1 more messages] Ian Jackson
2013-06-21 10:23   ` [PATCH v3 1/8] hvmloader: Remove all 64-bit print arguments Ian Jackson
2013-06-20 16:33 ` [PATCH v3 2/8] hvmloader: Make the printfs more informative George Dunlap
2013-06-20 17:12   ` Stefano Stabellini
2013-06-21  9:35     ` George Dunlap
2013-06-21  9:50       ` George Dunlap
2013-06-21 10:53         ` Stefano Stabellini
2013-06-21 10:53       ` Stefano Stabellini
2013-06-21 10:35   ` Ian Jackson
2013-06-20 16:33 ` [PATCH v3 3/8] hvmloader: Set up highmem resouce appropriately if there is no RAM above 4G George Dunlap
2013-06-20 17:16   ` Stefano Stabellini
2013-06-21  7:01   ` Jan Beulich
2013-06-21  9:06     ` George Dunlap
2013-06-21 10:38   ` Ian Jackson
2013-06-20 16:33 ` [PATCH v3 4/8] hvmloader: Fix check for needing a 64-bit bar George Dunlap
2013-06-20 16:33 ` [PATCH v3 5/8] hvmloader: Correct bug in low mmio region accounting George Dunlap
2013-06-20 17:20   ` Stefano Stabellini
2013-06-21  7:09   ` Jan Beulich
2013-06-20 16:33 ` George Dunlap [this message]
2013-06-20 17:23   ` [PATCH v3 6/8] hvmloader: Load large devices into high MMIO space as needed Stefano Stabellini
2013-06-21  7:12   ` Jan Beulich
2013-06-20 16:33 ` [PATCH v3 7/8] hvmloader: Remove minimum size for BARs to relocate to 64-bit space George Dunlap
2013-06-20 16:33 ` [PATCH v3 8/8] libxl, hvmloader: Don't relocate memory for MMIO hole George Dunlap
2013-06-20 17:38   ` Stefano Stabellini
2013-06-21  8:31     ` George Dunlap
2013-06-21 11:21       ` Stefano Stabellini
2013-06-21 11:31         ` Ian Jackson
2013-06-21  7:17   ` Jan Beulich
2013-06-21  8:32     ` George Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1371746007-19073-7-git-send-email-george.dunlap@eu.citrix.com \
    --to=george.dunlap@eu.citrix.com \
    --cc=hanweidong@huawei.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@citrix.com \
    --cc=keir@xen.org \
    --cc=stefano.stabellini@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).