From: Simon Horman <horms@verge.net.au>
To: qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [patch 4/5] iommu: Define PCI_DEVFN_AUTO and use it
Date: Mon, 23 Feb 2009 20:18:14 +1100 [thread overview]
Message-ID: <20090223092901.973758655@vergenet.net> (raw)
In-Reply-To: 20090223091810.891526738@vergenet.net
[-- Attachment #1: qemu-PCI_DEVFN_AUTO.patch --]
[-- Type: text/plain, Size: 16635 bytes --]
Signed-off-by: Simon Horman <horms@verge.net.au>
Index: qemu/hw/pci.c
===================================================================
--- qemu.orig/hw/pci.c 2009-02-23 18:45:57.000000000 +1100
+++ qemu/hw/pci.c 2009-02-23 18:46:30.000000000 +1100
@@ -235,7 +235,6 @@ int pci_assign_devaddr(const char *addr,
return pci_parse_devaddr(devaddr, domp, busp, slotp);
}
-/* -1 for devfn means auto assign */
PCIDevice *pci_register_device(PCIBus *bus, const char *name,
int instance_size, int devfn,
PCIConfigReadFunc *config_read,
@@ -246,7 +245,7 @@ PCIDevice *pci_register_device(PCIBus *b
if (pci_irq_index >= PCI_DEVICES_MAX)
return NULL;
- if (devfn < 0) {
+ if (devfn == PCI_DEVFN_AUTO) {
for(devfn = bus->devfn_min ; devfn < 256; devfn += 8) {
if (!bus->devices[devfn])
goto found;
Index: qemu/hw/ac97.c
===================================================================
--- qemu.orig/hw/ac97.c 2009-02-23 18:45:57.000000000 +1100
+++ qemu/hw/ac97.c 2009-02-23 18:46:30.000000000 +1100
@@ -1326,7 +1326,7 @@ int ac97_init (PCIBus *bus, AudioState *
d = (PCIAC97LinkState *) pci_register_device (bus, "AC97",
sizeof (PCIAC97LinkState),
- -1, NULL, NULL);
+ PCI_DEVFN_AUTO, NULL, NULL);
if (!d) {
AUD_log ("ac97", "Failed to register PCI device\n");
Index: qemu/hw/cirrus_vga.c
===================================================================
--- qemu.orig/hw/cirrus_vga.c 2009-02-23 18:45:57.000000000 +1100
+++ qemu/hw/cirrus_vga.c 2009-02-23 18:46:30.000000000 +1100
@@ -3373,7 +3373,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);
+ PCI_DEVFN_AUTO, 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: qemu/hw/eepro100.c
===================================================================
--- qemu.orig/hw/eepro100.c 2009-02-23 18:45:57.000000000 +1100
+++ qemu/hw/eepro100.c 2009-02-23 18:46:30.000000000 +1100
@@ -1744,8 +1744,8 @@ static PCIDevice *nic_init(PCIBus * bus,
logout("\n");
d = (PCIEEPRO100State *) pci_register_device(bus, name,
- sizeof(PCIEEPRO100State), -1,
- NULL, NULL);
+ sizeof(PCIEEPRO100State),
+ PCI_DEVFN_AUTO, NULL, NULL);
s = &d->eepro100;
s->device = device;
Index: qemu/hw/es1370.c
===================================================================
--- qemu.orig/hw/es1370.c 2009-02-23 18:45:57.000000000 +1100
+++ qemu/hw/es1370.c 2009-02-23 18:46:30.000000000 +1100
@@ -1023,7 +1023,7 @@ int es1370_init (PCIBus *bus, AudioState
d = (PCIES1370State *) pci_register_device (bus, "ES1370",
sizeof (PCIES1370State),
- -1, NULL, NULL);
+ PCI_DEVFN_AUTO, NULL, NULL);
if (!d) {
AUD_log (NULL, "Failed to register PCI device for ES1370\n");
Index: qemu/hw/ide.c
===================================================================
--- qemu.orig/hw/ide.c 2009-02-23 18:45:57.000000000 +1100
+++ qemu/hw/ide.c 2009-02-23 18:46:30.000000000 +1100
@@ -3286,7 +3286,7 @@ void pci_cmd646_ide_init(PCIBus *bus, Bl
d = (PCIIDEState *)pci_register_device(bus, "CMD646 IDE",
sizeof(PCIIDEState),
- -1,
+ PCI_DEVFN_AUTO,
NULL, NULL);
d->type = IDE_TYPE_CMD646;
pci_conf = d->dev.config;
Index: qemu/hw/macio.c
===================================================================
--- qemu.orig/hw/macio.c 2009-02-23 18:45:57.000000000 +1100
+++ qemu/hw/macio.c 2009-02-23 18:46:30.000000000 +1100
@@ -89,7 +89,7 @@ void macio_init (PCIBus *bus, int device
d = pci_register_device(bus, "macio",
sizeof(PCIDevice) + sizeof(macio_state_t),
- -1, NULL, NULL);
+ PCI_DEVFN_AUTO, NULL, NULL);
macio_state = (macio_state_t *)(d + 1);
macio_state->is_oldworld = is_oldworld;
macio_state->pic_mem_index = pic_mem_index;
Index: qemu/hw/openpic.c
===================================================================
--- qemu.orig/hw/openpic.c 2009-02-23 18:45:57.000000000 +1100
+++ qemu/hw/openpic.c 2009-02-23 18:46:30.000000000 +1100
@@ -1143,7 +1143,7 @@ qemu_irq *openpic_init (PCIBus *bus, int
return NULL;
if (bus) {
opp = (openpic_t *)pci_register_device(bus, "OpenPIC", sizeof(openpic_t),
- -1, NULL, NULL);
+ PCI_DEVFN_AUTO, NULL, NULL);
if (opp == NULL)
return NULL;
pci_conf = opp->pci_dev.config;
Index: qemu/hw/pci.h
===================================================================
--- qemu.orig/hw/pci.h 2009-02-23 18:45:57.000000000 +1100
+++ qemu/hw/pci.h 2009-02-23 18:46:30.000000000 +1100
@@ -144,6 +144,8 @@ typedef struct PCIIORegion {
#define PCI_ROM_SLOT 6
#define PCI_NUM_REGIONS 7
+#define PCI_DEVFN_AUTO -1
+
#define PCI_DEVICES_MAX 64
#define PCI_VENDOR_ID 0x00 /* 16 bits */
Index: qemu/hw/versatile_pci.c
===================================================================
--- qemu.orig/hw/versatile_pci.c 2009-02-23 18:45:58.000000000 +1100
+++ qemu/hw/versatile_pci.c 2009-02-23 18:46:30.000000000 +1100
@@ -117,7 +117,8 @@ PCIBus *pci_vpb_init(qemu_irq *pic, int
/* Normal config area. */
cpu_register_physical_memory(base + 0x02000000, 0x1000000, mem_config);
- d = pci_register_device(s, name, sizeof(PCIDevice), -1, NULL, NULL);
+ d = pci_register_device(s, name, sizeof(PCIDevice), PCI_DEVFN_AUTO,
+ NULL, NULL);
if (realview) {
/* IO memory area. */
Index: qemu/hw/vga.c
===================================================================
--- qemu.orig/hw/vga.c 2009-02-23 18:45:58.000000000 +1100
+++ qemu/hw/vga.c 2009-02-23 18:46:30.000000000 +1100
@@ -2492,7 +2492,7 @@ int pci_vga_init(PCIBus *bus, uint8_t *v
d = (PCIVGAState *)pci_register_device(bus, "VGA",
sizeof(PCIVGAState),
- -1, NULL, NULL);
+ PCI_DEVFN_AUTO, NULL, NULL);
if (!d)
return -1;
s = &d->vga_state;
Index: qemu/hw/vmware_vga.c
===================================================================
--- qemu.orig/hw/vmware_vga.c 2009-02-23 18:45:58.000000000 +1100
+++ qemu/hw/vmware_vga.c 2009-02-23 18:46:30.000000000 +1100
@@ -1214,7 +1214,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), PCI_DEVFN_AUTO, 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 */
Index: qemu/hw/lsi53c895a.c
===================================================================
--- qemu.orig/hw/lsi53c895a.c 2009-02-23 18:45:58.000000000 +1100
+++ qemu/hw/lsi53c895a.c 2009-02-23 18:46:30.000000000 +1100
@@ -1980,7 +1980,7 @@ void *lsi_scsi_init(PCIBus *bus)
uint8_t *pci_conf;
s = (LSIState *)pci_register_device(bus, "LSI53C895A SCSI HBA",
- sizeof(*s), -1, NULL, NULL);
+ sizeof(*s), PCI_DEVFN_AUTO, NULL, NULL);
if (s == NULL) {
fprintf(stderr, "lsi-scsi: Failed to register PCI device\n");
return NULL;
Index: qemu/hw/mips_malta.c
===================================================================
--- qemu.orig/hw/mips_malta.c 2009-02-23 18:45:58.000000000 +1100
+++ qemu/hw/mips_malta.c 2009-02-23 18:46:30.000000000 +1100
@@ -489,7 +489,7 @@ static void network_init (PCIBus *pci_bu
for(i = 0; i < nb_nics; i++) {
NICInfo *nd = &nd_table[i];
- int devfn = -1;
+ int devfn = PCI_DEVFN_AUTO;
if (i == 0 && (!nd->model || strcmp(nd->model, "pcnet") == 0))
/* The malta board has a PCNet card using PCI SLOT 11 */
Index: qemu/hw/pc.c
===================================================================
--- qemu.orig/hw/pc.c 2009-02-23 18:45:58.000000000 +1100
+++ qemu/hw/pc.c 2009-02-23 18:46:30.000000000 +1100
@@ -1007,7 +1007,7 @@ 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_DEVFN_AUTO, "ne2k_pci");
}
qemu_system_hot_add_init();
Index: qemu/hw/ppc_oldworld.c
===================================================================
--- qemu.orig/hw/ppc_oldworld.c 2009-02-23 18:45:58.000000000 +1100
+++ qemu/hw/ppc_oldworld.c 2009-02-23 18:46:30.000000000 +1100
@@ -306,7 +306,7 @@ static void ppc_heathrow_init (ram_addr_
serial_hds[1], ESCC_CLOCK, 4);
for(i = 0; i < nb_nics; i++)
- pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci");
+ pci_nic_init(pci_bus, &nd_table[i], PCI_DEVFN_AUTO, "ne2k_pci");
/* First IDE channel is a CMD646 on the PCI bus */
Index: qemu/hw/ppc_prep.c
===================================================================
--- qemu.orig/hw/ppc_prep.c 2009-02-23 18:45:58.000000000 +1100
+++ qemu/hw/ppc_prep.c 2009-02-23 18:46:30.000000000 +1100
@@ -674,7 +674,7 @@ static void ppc_prep_init (ram_addr_t ra
if (strcmp(nd_table[i].model, "ne2k_isa") == 0) {
isa_ne2000_init(ne2000_io[i], i8259[ne2000_irq[i]], &nd_table[i]);
} else {
- pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci");
+ pci_nic_init(pci_bus, &nd_table[i], PCI_DEVFN_AUTO, "ne2k_pci");
}
}
Index: qemu/hw/realview.c
===================================================================
--- qemu.orig/hw/realview.c 2009-02-23 18:45:58.000000000 +1100
+++ qemu/hw/realview.c 2009-02-23 18:46:30.000000000 +1100
@@ -126,7 +126,7 @@ static void realview_init(ram_addr_t ram
smc91c111_init(nd, 0x4e000000, pic[28]);
done_smc = 1;
} else {
- pci_nic_init(pci_bus, nd, -1, "rtl8139");
+ pci_nic_init(pci_bus, nd, PCI_DEVFN_AUTO, "rtl8139");
}
}
Index: qemu/hw/piix_pci.c
===================================================================
--- qemu.orig/hw/piix_pci.c 2009-02-23 18:45:58.000000000 +1100
+++ qemu/hw/piix_pci.c 2009-02-23 18:46:30.000000000 +1100
@@ -328,7 +328,7 @@ int piix3_init(PCIBus *bus)
uint8_t *pci_conf;
d = pci_register_device(bus, "PIIX3", sizeof(PCIDevice),
- -1, NULL, NULL);
+ PCI_DEVFN_AUTO, NULL, NULL);
register_savevm("PIIX3", 0, 2, piix_save, piix_load, d);
piix3_dev = d;
Index: qemu/hw/usb-ohci.c
===================================================================
--- qemu.orig/hw/usb-ohci.c 2009-02-23 18:45:58.000000000 +1100
+++ qemu/hw/usb-ohci.c 2009-02-23 18:46:30.000000000 +1100
@@ -1673,7 +1673,7 @@ void usb_ohci_init_pci(struct PCIBus *bu
OHCIPCIState *ohci;
ohci = (OHCIPCIState *)pci_register_device(bus, "OHCI USB", sizeof(*ohci),
- -1, NULL, NULL);
+ PCI_DEVFN_AUTO, NULL, NULL);
if (ohci == NULL) {
fprintf(stderr, "usb-ohci: Failed to register PCI device\n");
return;
Index: qemu/hw/pci-hotplug.c
===================================================================
--- qemu.orig/hw/pci-hotplug.c 2009-02-23 18:47:05.000000000 +1100
+++ qemu/hw/pci-hotplug.c 2009-02-23 18:47:25.000000000 +1100
@@ -40,7 +40,7 @@ static PCIDevice *qemu_pci_hot_add_nic(P
ret = net_client_init ("nic", opts);
if (ret < 0 || !nd_table[ret].model)
return NULL;
- return pci_nic_init (pci_bus, &nd_table[ret], -1, "rtl8139");
+ return pci_nic_init (pci_bus, &nd_table[ret], PCI_DEVFN_AUTO, "rtl8139");
}
void drive_hot_add(const char *pci_addr, const char *opts)
Index: qemu/hw/ppc440_bamboo.c
===================================================================
--- qemu.orig/hw/ppc440_bamboo.c 2009-02-23 18:47:43.000000000 +1100
+++ qemu/hw/ppc440_bamboo.c 2009-02-23 18:48:35.000000000 +1100
@@ -124,7 +124,7 @@ static void bamboo_init(ram_addr_t ram_s
for (i = 0; i < nb_nics; i++) {
/* There are no PCI NICs on the Bamboo board, but there are
* PCI slots, so we can pick whatever default model we want. */
- pci_nic_init(pcibus, &nd_table[i], -1, "e1000");
+ pci_nic_init(pcibus, &nd_table[i], PCI_DEVFN_AUTO, "e1000");
}
}
Index: qemu/hw/ppc_newworld.c
===================================================================
--- qemu.orig/hw/ppc_newworld.c 2009-02-23 18:48:18.000000000 +1100
+++ qemu/hw/ppc_newworld.c 2009-02-23 18:48:43.000000000 +1100
@@ -276,7 +276,7 @@ static void ppc_core99_init (ram_addr_t
serial_hds[0], serial_hds[1], ESCC_CLOCK, 4);
for(i = 0; i < nb_nics; i++)
- pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci");
+ pci_nic_init(pci_bus, &nd_table[i], PCI_DEVFN_AUTO, "ne2k_pci");
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
fprintf(stderr, "qemu: too many IDE bus\n");
Index: qemu/hw/r2d.c
===================================================================
--- qemu.orig/hw/r2d.c 2009-02-23 18:49:23.000000000 +1100
+++ qemu/hw/r2d.c 2009-02-23 18:49:38.000000000 +1100
@@ -230,7 +230,7 @@ static void r2d_init(ram_addr_t ram_size
/* NIC: rtl8139 on-board, and 2 slots. */
pci_nic_init(pci, &nd_table[0], 2 << 3, "rtl8139");
for (i = 1; i < nb_nics; i++)
- pci_nic_init(pci, &nd_table[i], -1, "ne2k_pci");
+ pci_nic_init(pci, &nd_table[i], PCI_DEVFN_AUTO, "ne2k_pci");
/* Todo: register on board registers */
{
Index: qemu/hw/sun4u.c
===================================================================
--- qemu.orig/hw/sun4u.c 2009-02-23 18:49:23.000000000 +1100
+++ qemu/hw/sun4u.c 2009-02-23 18:50:41.000000000 +1100
@@ -510,7 +510,7 @@ static void sun4uv_init(ram_addr_t RAM_s
0, 0);
// XXX Should be pci_bus3
- pci_ebus_init(pci_bus, -1);
+ pci_ebus_init(pci_bus, PCI_DEVFN_AUTO);
i = 0;
if (hwdef->console_serial_base) {
@@ -533,7 +533,7 @@ static void sun4uv_init(ram_addr_t RAM_s
}
for(i = 0; i < nb_nics; i++)
- pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci");
+ pci_nic_init(pci_bus, &nd_table[i], PCI_DEVFN_AUTO, "ne2k_pci");
irq = qemu_allocate_irqs(cpu_set_irq, env, MAX_PILS);
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
Index: qemu/hw/versatilepb.c
===================================================================
--- qemu.orig/hw/versatilepb.c 2009-02-23 18:49:23.000000000 +1100
+++ qemu/hw/versatilepb.c 2009-02-23 18:50:49.000000000 +1100
@@ -197,7 +197,7 @@ static void versatile_init(ram_addr_t ra
smc91c111_init(nd, 0x10010000, sic[25]);
done_smc = 1;
} else {
- pci_nic_init(pci_bus, nd, -1, "rtl8139");
+ pci_nic_init(pci_bus, nd, PCI_DEVFN_AUTO, "rtl8139");
}
}
if (usb_enabled) {
--
--
Simon Horman
VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en
next prev parent reply other threads:[~2009-02-23 9:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-23 9:18 [Qemu-devel] [patch 0/5] PCI clean-up Simon Horman
2009-02-23 9:18 ` [Qemu-devel] [patch 1/5] ioemu: Remove lsi_scsi_init()s devfn parameter as it is always passed as -1 Simon Horman
2009-02-23 9:18 ` [Qemu-devel] [patch 2/5] " Simon Horman
2009-02-23 9:18 ` [Qemu-devel] [patch 3/5] ioemu: Remove usb_ohci_init*()s devfn parameter as they are " Simon Horman
2009-02-23 9:18 ` Simon Horman [this message]
2009-02-23 9:18 ` [Qemu-devel] [patch 5/5] iommu: Use PCI_DEVFN, PCI_SLOT and PCI_FUNC Simon Horman
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=20090223092901.973758655@vergenet.net \
--to=horms@verge.net.au \
--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).