qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 06/10] pci: eliminate work around in pci_device_rese


From: Isaku Yamahata
Subject: [Qemu-devel] [PATCH 06/10] pci: eliminate work around in pci_device_reset().
Date: Thu, 17 Jun 2010 15:15:48 +0900

Eliminate work around in pci_device_reset() by
making each pci reset function to call pci_device_reset_default().
If a driver reset function isn't specified, set it to pci default reset
function.

Signed-off-by: Isaku Yamahata <address@hidden>
---
 hw/e1000.c      |    1 +
 hw/lsi53c895a.c |    2 ++
 hw/pci.c        |   12 ++++++++----
 hw/pcnet.c      |    1 +
 hw/rtl8139.c    |    2 ++
 hw/virtio-pci.c |    1 +
 6 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/hw/e1000.c b/hw/e1000.c
index 0da65f9..448a743 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -1069,6 +1069,7 @@ static void e1000_reset(void *opaque)
     memmove(d->mac_reg, mac_reg_init, sizeof mac_reg_init);
     d->rxbuf_min_shift = 1;
     memset(&d->tx, 0, sizeof d->tx);
+    pci_device_reset_default(&d->dev);
 }
 
 static NetClientInfo net_e1000_info = {
diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c
index f5a91ba..68723e3 100644
--- a/hw/lsi53c895a.c
+++ b/hw/lsi53c895a.c
@@ -358,6 +358,8 @@ static void lsi_soft_reset(LSIState *s)
         qemu_free(s->current);
         s->current = NULL;
     }
+
+    pci_device_reset_default(&s->dev);
 }
 
 static int lsi_dma_40bit(LSIState *s)
diff --git a/hw/pci.c b/hw/pci.c
index 87f5e6c..5dee102 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -171,6 +171,11 @@ void pci_device_reset_default(PCIDevice *dev)
     pci_update_mappings(dev);
 }
 
+static void pci_device_reset_default_fn(DeviceState *qdev)
+{
+    pci_device_reset_default(DO_UPCAST(PCIDevice, qdev, qdev));
+}
+
 void pci_device_reset(PCIDevice *dev)
 {
     if (!dev->qdev.info) {
@@ -180,10 +185,6 @@ void pci_device_reset(PCIDevice *dev)
     }
 
     qdev_reset(&dev->qdev);
-
-    /* TODO: make DeviceInfo::reset call
-       pci_device_reset_default() itself. */
-    pci_device_reset_default(dev);
 }
 
 void pci_bus_reset(PCIBus *bus)
@@ -1614,6 +1615,9 @@ void pci_qdev_register(PCIDeviceInfo *info)
     info->qdev.unplug = pci_unplug_device;
     info->qdev.exit = pci_unregister_device;
     info->qdev.bus_info = &pci_bus_info;
+    if (!info->qdev.reset) {
+        info->qdev.reset = pci_device_reset_default_fn;
+    }
     qdev_register(&info->qdev);
 }
 
diff --git a/hw/pcnet.c b/hw/pcnet.c
index 5e63eb5..c894d13 100644
--- a/hw/pcnet.c
+++ b/hw/pcnet.c
@@ -2036,6 +2036,7 @@ static void pci_reset(DeviceState *dev)
     PCIPCNetState *d = DO_UPCAST(PCIPCNetState, pci_dev.qdev, dev);
 
     pcnet_h_reset(&d->state);
+    pci_device_reset_default(&d->pci_dev);
 }
 
 static PCIDeviceInfo pcnet_info = {
diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index 72e2242..bfa7cde 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -1260,6 +1260,8 @@ static void rtl8139_reset(DeviceState *d)
 
     /* reset tally counters */
     RTL8139TallyCounters_clear(&s->tally_counters);
+
+    pci_device_reset_default(&s->dev);
 }
 
 static void RTL8139TallyCounters_clear(RTL8139TallyCounters* counters)
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index e101fa0..ea8ea6a 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -184,6 +184,7 @@ static void virtio_pci_reset(DeviceState *d)
     virtio_reset(proxy->vdev);
     msix_reset(&proxy->pci_dev);
     proxy->bugs = 0;
+    pci_device_reset_default(&proxy->pci_dev);
 }
 
 static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
-- 
1.6.6.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]