mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 01:33:56 -06:00
ide: Register vm change state handler once only
We register the vm change state handler in a PCI BAR map() function. This function can be called multiple times throughout the lifetime of a PCI IDE device. This results in duplicate vm change state handlers being register, none of which are ever unregistered. Instead, register the vm change state handler in the device's init function once and for all. piix tested, cmd646 and via not tested. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
ad7171394f
commit
61d9d6b091
3 changed files with 58 additions and 28 deletions
|
@ -167,10 +167,6 @@ static void bmdma_map(PCIDevice *pci_dev, int region_num,
|
|||
|
||||
for(i = 0;i < 2; i++) {
|
||||
BMDMAState *bm = &d->bmdma[i];
|
||||
bmdma_init(&d->bus[i], bm);
|
||||
bm->bus = d->bus+i;
|
||||
qemu_add_vm_change_state_handler(d->bus[i].dma->ops->restart_cb,
|
||||
&bm->dma);
|
||||
|
||||
if (i == 0) {
|
||||
register_ioport_write(addr, 4, 1, bmdma_writeb_0, d);
|
||||
|
@ -228,6 +224,7 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev)
|
|||
PCIIDEState *d = DO_UPCAST(PCIIDEState, dev, dev);
|
||||
uint8_t *pci_conf = d->dev.config;
|
||||
qemu_irq *irq;
|
||||
int i;
|
||||
|
||||
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_CMD);
|
||||
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_CMD_646);
|
||||
|
@ -253,10 +250,15 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev)
|
|||
pci_conf[PCI_INTERRUPT_PIN] = 0x01; // interrupt on pin 1
|
||||
|
||||
irq = qemu_allocate_irqs(cmd646_set_irq, d, 2);
|
||||
ide_bus_new(&d->bus[0], &d->dev.qdev, 0);
|
||||
ide_bus_new(&d->bus[1], &d->dev.qdev, 1);
|
||||
ide_init2(&d->bus[0], irq[0]);
|
||||
ide_init2(&d->bus[1], irq[1]);
|
||||
for (i = 0; i < 2; i++) {
|
||||
ide_bus_new(&d->bus[i], &d->dev.qdev, i);
|
||||
ide_init2(&d->bus[i], irq[i]);
|
||||
|
||||
bmdma_init(&d->bus[i], &d->bmdma[i]);
|
||||
bm->bus = &d->bus[i];
|
||||
qemu_add_vm_change_state_handler(d->bus[i].dma->ops->restart_cb,
|
||||
&d->bmdma[i]->dma);
|
||||
}
|
||||
|
||||
vmstate_register(&dev->qdev, 0, &vmstate_ide_pci, d);
|
||||
qemu_register_reset(cmd646_reset, d);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue