From: George Dunlap <george.dunlap@eu.citrix.com>
To: xen-devel@lists.xen.org
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
Ian Jackson <ian.jackson@citrix.com>,
Stefano Stabellini <stefano.stabellini@citrix.com>,
Ian Campbell <ian.campbell@citrix.com>,
Hanweidong <hanweidong@huawei.com>
Subject: [PATCH v2 2/5] hvmloader: Load large devices into high MMIO space as needed
Date: Tue, 18 Jun 2013 17:46:21 +0100 [thread overview]
Message-ID: <1371573984-28514-2-git-send-email-george.dunlap@eu.citrix.com> (raw)
In-Reply-To: <1371573984-28514-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.
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>
---
tools/firmware/hvmloader/pci.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/tools/firmware/hvmloader/pci.c b/tools/firmware/hvmloader/pci.c
index 8691a19..7f306a1 100644
--- a/tools/firmware/hvmloader/pci.c
+++ b/tools/firmware/hvmloader/pci.c
@@ -38,7 +38,8 @@ void pci_setup(void)
{
uint8_t is_64bar, using_64bar, bar64_relocate = 0;
uint32_t devfn, bar_reg, cmd, bar_data, bar_data_upper;
- uint64_t base, bar_sz, bar_sz_upper, low_mmio_left, mmio_total = 0;
+ uint64_t base, bar_sz, bar_sz_upper, low_mmio_left, mmio_total = 0,
+ mmio_left;
uint32_t vga_devfn = 256;
uint16_t class, vendor_id, device_id;
unsigned int bar, pin, link, isa_irq;
@@ -244,6 +245,7 @@ void pci_setup(void)
io_resource.max = 0x10000;
low_mmio_left = pci_mem_end - pci_mem_start;
+ mmio_left = mmio_total;
/* Assign iomem and ioport resources in descending order of size. */
for ( i = 0; i < nr_bars; i++ )
@@ -252,7 +254,12 @@ void pci_setup(void)
bar_reg = bars[i].bar_reg;
bar_sz = bars[i].bar_sz;
- using_64bar = bars[i].is_64bar && bar64_relocate && (low_mmio_left < 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
+ && (mmio_left > low_mmio_left);
bar_data = pci_readl(devfn, bar_reg);
if ( (bar_data & PCI_BASE_ADDRESS_SPACE) ==
@@ -276,6 +283,7 @@ void pci_setup(void)
low_mmio_left -= bar_sz;
bar_data &= ~PCI_BASE_ADDRESS_MEM_MASK;
}
+ mmio_left -= bar_sz;
}
else
{
--
1.7.9.5
next prev parent reply other threads:[~2013-06-18 16:46 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-18 16:46 [PATCH v2 1/5] hvmloader: Correct bug in low mmio region accounting George Dunlap
2013-06-18 16:46 ` George Dunlap [this message]
2013-06-19 17:18 ` [PATCH v2 2/5] hvmloader: Load large devices into high MMIO space as needed Stefano Stabellini
2013-06-20 9:23 ` George Dunlap
2013-06-20 9:47 ` Jan Beulich
2013-06-18 16:46 ` [PATCH v2 3/5] hvmloader: Remove minimum size for BARs to relocate to 64-bit space George Dunlap
2013-06-19 17:18 ` Stefano Stabellini
2013-06-19 21:14 ` Wei Liu
2013-06-20 9:01 ` George Dunlap
2013-06-20 9:48 ` Jan Beulich
2013-06-18 16:46 ` [PATCH v2 4/5] hvmloader: Fix check for needing a 64-bit bar George Dunlap
2013-06-19 17:18 ` Stefano Stabellini
2013-06-20 10:01 ` Jan Beulich
2013-06-20 10:21 ` George Dunlap
2013-06-18 16:46 ` [PATCH v2 5/5] libxl, hvmloader: Don't relocate memory for MMIO hole George Dunlap
2013-06-18 17:16 ` George Dunlap
2013-06-19 17:18 ` Stefano Stabellini
2013-06-20 9:22 ` George Dunlap
2013-06-20 10:12 ` Jan Beulich
2013-06-20 10:20 ` George Dunlap
2013-06-20 10:29 ` Stefano Stabellini
2013-06-20 10:56 ` Jan Beulich
2013-06-20 10:59 ` George Dunlap
2013-06-20 11:01 ` George Dunlap
2013-06-20 13:35 ` Ian Jackson
2013-06-20 14:06 ` George Dunlap
2013-06-20 10:37 ` Ian Jackson
2013-06-20 10:44 ` George Dunlap
2013-06-20 10:52 ` Jan Beulich
2013-06-20 10:49 ` Stefano Stabellini
2013-06-25 9:56 ` Ian Campbell
2013-06-25 10:15 ` George Dunlap
2013-06-18 16:53 ` [PATCH v2 1/5] hvmloader: Correct bug in low mmio region accounting George Dunlap
2013-06-19 17:18 ` Stefano Stabellini
2013-06-20 8:56 ` George Dunlap
2013-06-20 10:40 ` Stefano Stabellini
2013-06-20 10:43 ` George Dunlap
2013-06-20 9:36 ` Jan Beulich
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=1371573984-28514-2-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=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).