qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: seabios@seabios.org
Cc: qemu-devel@nongnu.org, Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH v2 2/6] pci: split device discovery into multiple steps
Date: Wed, 29 Feb 2012 12:45:06 +0100	[thread overview]
Message-ID: <1330515910-725-3-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1330515910-725-1-git-send-email-kraxel@redhat.com>

First bridge init, next pci bar discovery, finally pci bar ressource
allocation.  Needed because we need to figure whenever we can map 64bit
bars above 4G before doing ressource allocation.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 src/pciinit.c |   39 ++++++++++++++++++++++++++++++++-------
 1 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/src/pciinit.c b/src/pciinit.c
index 9f3fdd4..652564c 100644
--- a/src/pciinit.c
+++ b/src/pciinit.c
@@ -368,22 +368,28 @@ static void pci_bios_check_devices(struct pci_bus *busses)
 {
     dprintf(1, "PCI: check devices\n");
 
-    // Calculate resources needed for regular (non-bus) devices.
     struct pci_device *pci;
+    struct pci_bus *bus;
+    int i;
+
+    // init pci bridges
     foreachpci(pci) {
-        if (pci->class == PCI_CLASS_BRIDGE_PCI) {
-            busses[pci->secondary_bus].bus_dev = pci;
+        if (pci->class != PCI_CLASS_BRIDGE_PCI)
+            continue;
+        bus = &busses[pci->secondary_bus];
+        bus->bus_dev = pci;
+    }
+
+    // discover pci bars
+    foreachpci(pci) {
+        if (pci->class == PCI_CLASS_BRIDGE_PCI)
             continue;
-        }
-        struct pci_bus *bus = &busses[pci_bdf_to_bus(pci->bdf)];
-        int i;
         for (i = 0; i < PCI_NUM_REGIONS; i++) {
             u32 val, size;
             pci_bios_get_bar(pci, i, &val, &size);
             if (val == 0)
                 continue;
 
-            pci_bios_bus_reserve(bus, pci_addr_to_type(val), size);
             pci->bars[i].addr = val;
             pci->bars[i].size = size;
             pci->bars[i].is64 = (!(val & PCI_BASE_ADDRESS_SPACE_IO) &&
@@ -395,6 +401,25 @@ static void pci_bios_check_devices(struct pci_bus *busses)
         }
     }
 
+    // alloc ressources for pci bars
+    foreachpci(pci) {
+        if (pci->class == PCI_CLASS_BRIDGE_PCI)
+            continue;
+        bus = &busses[pci_bdf_to_bus(pci->bdf)];
+        for (i = 0; i < PCI_NUM_REGIONS; i++) {
+            enum pci_region_type type;
+            if (pci->bars[i].addr == 0)
+                continue;
+
+            type = pci_addr_to_type(pci->bars[i].addr);
+            pci_bios_bus_reserve(bus, type,
+                                 pci->bars[i].size);
+
+            if (pci->bars[i].is64)
+                i++;
+        }
+    }
+
     // Propagate required bus resources to parent busses.
     int secondary_bus;
     for (secondary_bus=MaxPCIBus; secondary_bus>0; secondary_bus--) {
-- 
1.7.1

  parent reply	other threads:[~2012-02-29 11:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-29 11:45 [Qemu-devel] [PATCH v2 0/6] pci: 64bit support Gerd Hoffmann
2012-02-29 11:45 ` [Qemu-devel] [PATCH v2 1/6] output: add 64bit hex print support Gerd Hoffmann
2012-03-05 15:23   ` [Qemu-devel] [SeaBIOS] " Kevin O'Connor
2012-03-06  7:03     ` Gerd Hoffmann
2012-02-29 11:45 ` Gerd Hoffmann [this message]
2012-02-29 11:45 ` [Qemu-devel] [PATCH v2 3/6] pci: 64bit support Gerd Hoffmann
2012-02-29 11:45 ` [Qemu-devel] [PATCH v2 4/6] pci: bridges can have two regions too Gerd Hoffmann
2012-02-29 11:45 ` [Qemu-devel] [PATCH v2 5/6] pci: fix bridge ressource allocation Gerd Hoffmann
2012-02-29 11:45 ` [Qemu-devel] [PATCH v2 6/6] pci: add prefmem64 Gerd Hoffmann

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=1330515910-725-3-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=seabios@seabios.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).