mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
hw/ide/ahci: Decouple from PCI
In some adhoc profiling booting Linux VMs, it's observed that ahci_irq_lower() can be a hot path (10000+ triggers until login prompt appears). Even though the parent device never changes, this method re-determines whether the parent device is a PCI device or not using the rather expensive object_dynamic_cast() function. Avoid this overhead by pushing the interrupt handling to the parent device, essentially turning AHCIState into an "IP block". Note that this change also frees AHCIState from the PCI dependency which wasn't reflected in Kconfig. Reported-by: Peter Xu <peterx@redhat.com> Inspired-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Bernhard Beschow <shentey@gmail.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-ID: <20241212110926.23548-2-shentey@gmail.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
parent
c0179ead95
commit
8a4989f526
5 changed files with 21 additions and 42 deletions
19
hw/ide/ich.c
19
hw/ide/ich.c
|
@ -61,7 +61,6 @@
|
|||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "hw/irq.h"
|
||||
#include "hw/pci/msi.h"
|
||||
#include "hw/pci/pci.h"
|
||||
#include "migration/vmstate.h"
|
||||
|
@ -91,6 +90,19 @@ static const VMStateDescription vmstate_ich9_ahci = {
|
|||
},
|
||||
};
|
||||
|
||||
static void pci_ich9_ahci_update_irq(void *opaque, int irq_num, int level)
|
||||
{
|
||||
PCIDevice *pci_dev = opaque;
|
||||
|
||||
if (msi_enabled(pci_dev)) {
|
||||
if (level) {
|
||||
msi_notify(pci_dev, 0);
|
||||
}
|
||||
} else {
|
||||
pci_set_irq(pci_dev, level);
|
||||
}
|
||||
}
|
||||
|
||||
static void pci_ich9_reset(DeviceState *dev)
|
||||
{
|
||||
AHCIPCIState *d = ICH9_AHCI(dev);
|
||||
|
@ -102,7 +114,9 @@ static void pci_ich9_ahci_init(Object *obj)
|
|||
{
|
||||
AHCIPCIState *d = ICH9_AHCI(obj);
|
||||
|
||||
qemu_init_irq(&d->irq, pci_ich9_ahci_update_irq, d, 0);
|
||||
ahci_init(&d->ahci, DEVICE(obj));
|
||||
d->ahci.irq = &d->irq;
|
||||
}
|
||||
|
||||
static void pci_ich9_ahci_realize(PCIDevice *dev, Error **errp)
|
||||
|
@ -125,8 +139,6 @@ static void pci_ich9_ahci_realize(PCIDevice *dev, Error **errp)
|
|||
/* XXX Software should program this register */
|
||||
dev->config[0x90] = 1 << 6; /* Address Map Register - AHCI mode */
|
||||
|
||||
d->ahci.irq = pci_allocate_irq(dev);
|
||||
|
||||
pci_register_bar(dev, ICH9_IDP_BAR, PCI_BASE_ADDRESS_SPACE_IO,
|
||||
&d->ahci.idp);
|
||||
pci_register_bar(dev, ICH9_MEM_BAR, PCI_BASE_ADDRESS_SPACE_MEMORY,
|
||||
|
@ -161,7 +173,6 @@ static void pci_ich9_uninit(PCIDevice *dev)
|
|||
|
||||
msi_uninit(dev);
|
||||
ahci_uninit(&d->ahci);
|
||||
qemu_free_irq(d->ahci.irq);
|
||||
}
|
||||
|
||||
static void ich_ahci_class_init(ObjectClass *klass, void *data)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue