All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: ehabkost@redhat.com, mst@redhat.com, ghammer@redhat.com,
	lersek@redhat.com, lcapitulino@redhat.com
Subject: [Qemu-devel] [PATCH v19 8/9] pc: put PIIX3 in slot 1 explicitly and cleanup functions assignment
Date: Thu, 28 Jan 2016 11:54:29 +0100	[thread overview]
Message-ID: <1453978470-222624-8-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1453978470-222624-1-git-send-email-imammedo@redhat.com>

currently slot for PIIX3 bridge is selected
dynamically but it's always in slot 1 for
existing machine types.
However it's easy to regress if another PCI
device were added before PIIX3 is created and
also requires passing around devfn of the
created bridge.
Replace dynamic slot assignment with a static
one like it's done for ICH9_LPC, explicitly
setting slot # for the bridge.
While at it cleanup IDE/USB/PIIX4_PM functions
assignment, replacing magic offsets with defines.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
Static assignment will help with adding other
functions to multifunction bridge in following
patch.
---
 hw/i386/pc_piix.c    | 17 ++++++++++-------
 hw/pci-host/piix.c   |  9 ++++-----
 include/hw/i386/pc.h |  8 +++++++-
 3 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index bc74557..2ea3d84 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -73,7 +73,6 @@ static void pc_init1(MachineState *machine,
     PCIBus *pci_bus;
     ISABus *isa_bus;
     PCII440FXState *i440fx_state;
-    int piix3_devfn = -1;
     qemu_irq *gsi;
     qemu_irq *i8259;
     qemu_irq smi_irq;
@@ -179,7 +178,7 @@ static void pc_init1(MachineState *machine,
     if (pcmc->pci_enabled) {
         pci_bus = i440fx_init(host_type,
                               pci_type,
-                              &i440fx_state, &piix3_devfn, &isa_bus, gsi,
+                              &i440fx_state, &isa_bus, gsi,
                               system_memory, system_io, machine->ram_size,
                               pcms->below_4g_mem_size,
                               pcms->above_4g_mem_size,
@@ -229,9 +228,11 @@ static void pc_init1(MachineState *machine,
     if (pcmc->pci_enabled) {
         PCIDevice *dev;
         if (xen_enabled()) {
-            dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1);
+            dev = pci_piix3_xen_ide_init(pci_bus, hd,
+                PCI_DEVFN(PIIX3_PCI_SLOT, PIIX3_IDE_FUNC));
         } else {
-            dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1);
+            dev = pci_piix3_ide_init(pci_bus, hd,
+                PCI_DEVFN(PIIX3_PCI_SLOT, PIIX3_IDE_FUNC));
         }
         idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
         idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
@@ -254,7 +255,8 @@ static void pc_init1(MachineState *machine,
     pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state);
 
     if (pcmc->pci_enabled && usb_enabled()) {
-        pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
+        pci_create_simple(pci_bus, PCI_DEVFN(PIIX3_PCI_SLOT, PIIX3_USB_FUNC),
+                          "piix3-usb-uhci");
     }
 
     if (pcmc->pci_enabled && acpi_enabled) {
@@ -263,8 +265,9 @@ static void pc_init1(MachineState *machine,
 
         smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0);
         /* TODO: Populate SPD eeprom data.  */
-        smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
-                              gsi[9], smi_irq,
+        smbus = piix4_pm_init(pci_bus,
+                              PCI_DEVFN(PIIX3_PCI_SLOT, PIIX3_PIIX4_PM_FUNC),
+                              0xb100, gsi[9], smi_irq,
                               pc_machine_is_smm_enabled(pcms),
                               &piix4_pm);
         smbus_eeprom_init(smbus, 8, NULL, 0);
diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index b0d7e31..b8bf1fc 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -310,7 +310,6 @@ static void i440fx_realize(PCIDevice *dev, Error **errp)
 
 PCIBus *i440fx_init(const char *host_type, const char *pci_type,
                     PCII440FXState **pi440fx_state,
-                    int *piix3_devfn,
                     ISABus **isa_bus, qemu_irq *pic,
                     MemoryRegion *address_space_mem,
                     MemoryRegion *address_space_io,
@@ -382,13 +381,15 @@ PCIBus *i440fx_init(const char *host_type, const char *pci_type,
      * These additional routes can be discovered through ACPI. */
     if (xen_enabled()) {
         PCIDevice *pci_dev = pci_create_simple_multifunction(b,
-                             -1, true, "PIIX3-xen");
+                             PCI_DEVFN(PIIX3_PCI_SLOT, PIIX3_PCI_FUNC),
+                             true, "PIIX3-xen");
         piix3 = PIIX3_PCI_DEVICE(pci_dev);
         pci_bus_irqs(b, xen_piix3_set_irq, xen_pci_slot_get_pirq,
                 piix3, XEN_PIIX_NUM_PIRQS);
     } else {
         PCIDevice *pci_dev = pci_create_simple_multifunction(b,
-                             -1, true, "PIIX3");
+                             PCI_DEVFN(PIIX3_PCI_SLOT, PIIX3_PCI_FUNC),
+                             true, "PIIX3");
         piix3 = PIIX3_PCI_DEVICE(pci_dev);
         pci_bus_irqs(b, piix3_set_irq, pci_slot_get_pirq, piix3,
                 PIIX_NUM_PIRQS);
@@ -397,8 +398,6 @@ PCIBus *i440fx_init(const char *host_type, const char *pci_type,
     piix3->pic = pic;
     *isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(piix3), "isa.0"));
 
-    *piix3_devfn = piix3->dev.devfn;
-
     ram_size = ram_size / 8 / 1024 / 1024;
     if (ram_size > 255) {
         ram_size = 255;
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 7713361..69ed687 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -291,8 +291,14 @@ typedef struct PCII440FXState PCII440FXState;
 
 #define TYPE_IGD_PASSTHROUGH_I440FX_PCI_DEVICE "igd-passthrough-i440FX"
 
+#define PIIX3_PCI_SLOT                       1
+#define PIIX3_PCI_FUNC                       0
+#define PIIX3_IDE_FUNC                       1
+#define PIIX3_USB_FUNC                       2
+#define PIIX3_PIIX4_PM_FUNC                  3
+
 PCIBus *i440fx_init(const char *host_type, const char *pci_type,
-                    PCII440FXState **pi440fx_state, int *piix_devfn,
+                    PCII440FXState **pi440fx_state,
                     ISABus **isa_bus, qemu_irq *pic,
                     MemoryRegion *address_space_mem,
                     MemoryRegion *address_space_io,
-- 
1.8.3.1

  parent reply	other threads:[~2016-01-28 10:54 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-28 10:54 [Qemu-devel] [PATCH v19 0/9] Virtual Machine Generation ID Igor Mammedov
2016-01-28 10:54 ` [Qemu-devel] [PATCH v19 1/9] acpi: extend ACPI interface to provide access to ACPI registers and SCI irq Igor Mammedov
2016-01-28 10:54 ` [Qemu-devel] [PATCH v19 2/9] docs: vm generation id device's description Igor Mammedov
2016-01-28 10:54 ` [Qemu-devel] [PATCH v19 3/9] pc: add a Virtual Machine Generation ID device Igor Mammedov
2016-01-28 11:13   ` Michael S. Tsirkin
2016-01-28 12:03     ` Igor Mammedov
2016-01-28 12:59       ` Michael S. Tsirkin
2016-01-29 11:13         ` Igor Mammedov
2016-01-31 16:22           ` Michael S. Tsirkin
2016-02-02  9:59             ` Igor Mammedov
2016-02-02 11:16               ` Michael S. Tsirkin
2016-02-09 10:46                 ` Igor Mammedov
2016-02-09 12:17                   ` Michael S. Tsirkin
2016-02-11 15:16                     ` Igor Mammedov
2016-02-11 16:30                       ` Michael S. Tsirkin
2016-02-11 17:34                         ` Marcel Apfelbaum
2016-02-12  6:15                           ` Michael S. Tsirkin
2016-02-15 10:30                         ` Igor Mammedov
2016-02-15 11:26                           ` Michael S. Tsirkin
2016-02-15 13:56                             ` Igor Mammedov
2016-02-16 10:05                         ` Marcel Apfelbaum
2016-02-16 12:17                           ` Igor Mammedov
2016-02-16 12:36                             ` Marcel Apfelbaum
2016-02-16 13:51                               ` Igor Mammedov
2016-02-16 14:53                                 ` Michael S. Tsirkin
2016-02-16 15:10                               ` Michael S. Tsirkin
2016-02-10  8:51                   ` Michael S. Tsirkin
2016-02-10  9:28                     ` Michael S. Tsirkin
2016-02-10 10:00                       ` Laszlo Ersek
2016-01-28 13:48     ` Laszlo Ersek
2016-01-28 10:54 ` [Qemu-devel] [PATCH v19 4/9] tests: add a unit test for the vmgenid device Igor Mammedov
2016-01-28 10:54 ` [Qemu-devel] [PATCH v19 5/9] qmp/hmp: add query-vm-generation-id and 'info vm-generation-id' commands Igor Mammedov
2016-02-09 17:31   ` Eric Blake
2016-01-28 10:54 ` [Qemu-devel] [PATCH v19 6/9] qmp/hmp: add set-vm-generation-id commands Igor Mammedov
2016-02-09 17:33   ` Eric Blake
2016-01-28 10:54 ` Igor Mammedov [this message]
2016-01-28 10:54 ` [Qemu-devel] [PATCH v19 9/9] pc/q53: by default put vmgenid device as an function of ISA bridge Igor Mammedov
2016-01-28 10:58 ` [Qemu-devel] [PATCH v19 7/9] machine: add properties to compat_props incrementaly Igor Mammedov
2016-01-28 14:02   ` Eduardo Habkost
2016-01-28 17:00     ` Igor Mammedov
2016-02-03 17:55       ` [Qemu-devel] qdev & hw/core owner? (was Re: [PATCH v19 7/9] machine: add properties to compat_props incrementaly) Eduardo Habkost
2016-02-03 18:46         ` Laszlo Ersek
2016-02-03 19:06         ` Michael S. Tsirkin
2016-02-04 11:31           ` Paolo Bonzini
2016-02-04 11:41             ` Andreas Färber
2016-02-04 11:55               ` Paolo Bonzini
2016-02-04 12:06                 ` Michael S. Tsirkin
2016-02-05  7:49                   ` Markus Armbruster
2016-02-05  7:51                     ` Marcel Apfelbaum
2016-02-11 19:41                       ` Eduardo Habkost
2016-02-12  9:17                         ` Marcel Apfelbaum
2016-02-12 11:22                           ` Andreas Färber
2016-02-12 18:17                             ` Eduardo Habkost
2016-02-12 22:30                               ` Paolo Bonzini
2016-02-12 18:09                           ` Eduardo Habkost
2016-02-05  7:52                 ` Markus Armbruster
2016-02-04 12:03               ` Michael S. Tsirkin
2016-02-04 12:12               ` Marcel Apfelbaum
2016-01-29 12:51   ` [Qemu-devel] [PATCH v19 7/9] machine: add properties to compat_props incrementaly Cornelia Huck

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=1453978470-222624-8-git-send-email-imammedo@redhat.com \
    --to=imammedo@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=ghammer@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=lersek@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.