From: Marcelo Tosatti <mtosatti@redhat.com>
To: qemu-devel@nongnu.org
Cc: Markus Armbruster <armbru@redhat.com>
Subject: [Qemu-devel] [patch 2/2] qemu: switch pci device init functions to accept devfn
Date: Mon, 13 Apr 2009 00:53:13 -0300 [thread overview]
Message-ID: <20090413035340.296329700@amt.cnet> (raw)
In-Reply-To: 20090413035311.009617911@amt.cnet
[-- Attachment #1: pci-refactor-devfn --]
[-- Type: text/plain, Size: 7403 bytes --]
Some pci device initialization functions do not accept a devfn parameter,
but instead use "-1", which caused pci_register_device to find the first
free slot on the given bus.
Have them accept a "devfn" parameter, and use the newly introduced
pci_bus_assign_dev_addr function on platform init code to perform
the "first free" enumeration.
Some pci init functions still hardcode devfn (usually the host bridge of the bus
with devfn 0), those will have be to changed later.
Index: trunk/hw/cirrus_vga.c
===================================================================
--- trunk.orig/hw/cirrus_vga.c
+++ trunk/hw/cirrus_vga.c
@@ -3358,7 +3358,7 @@ static void pci_cirrus_write_config(PCID
vga_dirty_log_start((VGAState *)s);
}
-void pci_cirrus_vga_init(PCIBus *bus, uint8_t *vga_ram_base,
+void pci_cirrus_vga_init(PCIBus *bus, int devfn, uint8_t *vga_ram_base,
ram_addr_t vga_ram_offset, int vga_ram_size)
{
PCICirrusVGAState *d;
@@ -3371,7 +3371,8 @@ void pci_cirrus_vga_init(PCIBus *bus, ui
/* setup PCI configuration registers */
d = (PCICirrusVGAState *)pci_register_device(bus, "Cirrus VGA",
sizeof(PCICirrusVGAState),
- -1, NULL, pci_cirrus_write_config);
+ devfn, NULL,
+ pci_cirrus_write_config);
pci_conf = d->dev.config;
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_CIRRUS);
pci_config_set_device_id(pci_conf, device_id);
Index: trunk/hw/pc.c
===================================================================
--- trunk.orig/hw/pc.c
+++ trunk/hw/pc.c
@@ -946,7 +946,7 @@ vga_bios_error:
if (pci_enabled) {
pci_bus = i440fx_init(&i440fx_state, i8259);
- piix3_devfn = piix3_init(pci_bus, -1);
+ piix3_devfn = piix3_init(pci_bus, pci_bus_assign_dev_addr(pci_bus));
} else {
pci_bus = NULL;
}
@@ -959,6 +959,7 @@ vga_bios_error:
if (cirrus_vga_enabled) {
if (pci_enabled) {
pci_cirrus_vga_init(pci_bus,
+ pci_bus_assign_dev_addr(pci_bus),
phys_ram_base + vga_ram_addr,
vga_ram_addr, vga_ram_size);
} else {
@@ -967,13 +968,15 @@ vga_bios_error:
}
} else if (vmsvga_enabled) {
if (pci_enabled)
- pci_vmsvga_init(pci_bus, phys_ram_base + vga_ram_addr,
+ pci_vmsvga_init(pci_bus, pci_bus_assign_dev_addr(pci_bus),
+ phys_ram_base + vga_ram_addr,
vga_ram_addr, vga_ram_size);
else
fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __FUNCTION__);
} else if (std_vga_enabled) {
if (pci_enabled) {
- pci_vga_init(pci_bus, phys_ram_base + vga_ram_addr,
+ pci_vga_init(pci_bus, pci_bus_assign_dev_addr(pci_bus),
+ phys_ram_base + vga_ram_addr,
vga_ram_addr, vga_ram_size, 0, 0);
} else {
isa_vga_init(phys_ram_base + vga_ram_addr,
@@ -1020,7 +1023,8 @@ vga_bios_error:
if (!pci_enabled || (nd->model && strcmp(nd->model, "ne2k_isa") == 0))
pc_init_ne2k_isa(nd, i8259);
else
- pci_nic_init(pci_bus, nd, -1, "ne2k_pci");
+ pci_nic_init(pci_bus, nd, pci_bus_assign_dev_addr(pci_bus),
+ "ne2k_pci");
}
qemu_system_hot_add_init();
@@ -1091,7 +1095,7 @@ vga_bios_error:
max_bus = drive_get_max_bus(IF_SCSI);
for (bus = 0; bus <= max_bus; bus++) {
- scsi = lsi_scsi_init(pci_bus, -1);
+ scsi = lsi_scsi_init(pci_bus, pci_bus_assign_dev_addr(pci_bus));
for (unit = 0; unit < LSI_MAX_DEVS; unit++) {
index = drive_get_index(IF_SCSI, bus, unit);
if (index == -1)
Index: trunk/hw/pc.h
===================================================================
--- trunk.orig/hw/pc.h
+++ trunk/hw/pc.h
@@ -146,7 +146,7 @@ extern enum vga_retrace_method vga_retra
int isa_vga_init(uint8_t *vga_ram_base,
unsigned long vga_ram_offset, int vga_ram_size);
-int pci_vga_init(PCIBus *bus, uint8_t *vga_ram_base,
+int pci_vga_init(PCIBus *bus, int devfn, uint8_t *vga_ram_base,
unsigned long vga_ram_offset, int vga_ram_size,
unsigned long vga_bios_offset, int vga_bios_size);
int isa_vga_mm_init(uint8_t *vga_ram_base,
@@ -155,7 +155,7 @@ int isa_vga_mm_init(uint8_t *vga_ram_bas
int it_shift);
/* cirrus_vga.c */
-void pci_cirrus_vga_init(PCIBus *bus, uint8_t *vga_ram_base,
+void pci_cirrus_vga_init(PCIBus *bus, int devfn, uint8_t *vga_ram_base,
ram_addr_t vga_ram_offset, int vga_ram_size);
void isa_cirrus_vga_init(uint8_t *vga_ram_base,
ram_addr_t vga_ram_offset, int vga_ram_size);
Index: trunk/hw/pci.h
===================================================================
--- trunk.orig/hw/pci.h
+++ trunk/hw/pci.h
@@ -220,7 +220,7 @@ void lsi_scsi_attach(void *opaque, Block
void *lsi_scsi_init(PCIBus *bus, int devfn);
/* vmware_vga.c */
-void pci_vmsvga_init(PCIBus *bus, uint8_t *vga_ram_base,
+void pci_vmsvga_init(PCIBus *bus, int devfn, uint8_t *vga_ram_base,
unsigned long vga_ram_offset, int vga_ram_size);
/* usb-uhci.c */
Index: trunk/hw/vga.c
===================================================================
--- trunk.orig/hw/vga.c
+++ trunk/hw/vga.c
@@ -2500,7 +2500,7 @@ static void pci_vga_write_config(PCIDevi
vga_dirty_log_start(s);
}
-int pci_vga_init(PCIBus *bus, uint8_t *vga_ram_base,
+int pci_vga_init(PCIBus *bus, int devfn, uint8_t *vga_ram_base,
unsigned long vga_ram_offset, int vga_ram_size,
unsigned long vga_bios_offset, int vga_bios_size)
{
@@ -2510,7 +2510,7 @@ int pci_vga_init(PCIBus *bus, uint8_t *v
d = (PCIVGAState *)pci_register_device(bus, "VGA",
sizeof(PCIVGAState),
- -1, NULL, pci_vga_write_config);
+ devfn, NULL, pci_vga_write_config);
if (!d)
return -1;
s = &d->vga_state;
Index: trunk/hw/vmware_vga.c
===================================================================
--- trunk.orig/hw/vmware_vga.c
+++ trunk/hw/vmware_vga.c
@@ -1215,7 +1215,7 @@ static void pci_vmsvga_map_mem(PCIDevice
#define PCI_CLASS_HEADERTYPE_00h 0x00
-void pci_vmsvga_init(PCIBus *bus, uint8_t *vga_ram_base,
+void pci_vmsvga_init(PCIBus *bus, int devfn, uint8_t *vga_ram_base,
unsigned long vga_ram_offset, int vga_ram_size)
{
struct pci_vmsvga_state_s *s;
@@ -1223,7 +1223,7 @@ void pci_vmsvga_init(PCIBus *bus, uint8_
/* Setup PCI configuration */
s = (struct pci_vmsvga_state_s *)
pci_register_device(bus, "QEMUware SVGA",
- sizeof(struct pci_vmsvga_state_s), -1, 0, 0);
+ sizeof(struct pci_vmsvga_state_s), devfn, 0, 0);
pci_config_set_vendor_id(s->card.config, PCI_VENDOR_ID_VMWARE);
pci_config_set_device_id(s->card.config, SVGA_PCI_DEVICE_ID);
s->card.config[PCI_COMMAND] = 0x07; /* I/O + Memory */
next prev parent reply other threads:[~2009-04-13 3:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-13 3:53 [Qemu-devel] [patch 0/2] RFC: move PCI device enumeration out of pci drivers Marcelo Tosatti
2009-04-13 3:53 ` [Qemu-devel] [patch 1/2] qemu: move pci devfn "first free" assignment to separate function Marcelo Tosatti
2009-04-13 8:08 ` Avi Kivity
2009-04-13 3:53 ` Marcelo Tosatti [this message]
2009-04-13 12:27 ` [Qemu-devel] [patch 2/2] qemu: switch pci device init functions to accept devfn Paul Brook
2009-04-13 13:30 ` Marcelo Tosatti
2009-04-13 13:47 ` Brian Wheeler
2009-04-13 14:34 ` Marcelo Tosatti
2009-04-14 3:29 ` Marcelo Tosatti
2009-04-14 8:17 ` Marcelo Tosatti
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=20090413035340.296329700@amt.cnet \
--to=mtosatti@redhat.com \
--cc=armbru@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 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).