Patchwork [6/7] pci: teach pci devices that have reset callback how to reset common registers

login
register
mail settings
Submitter Isaku Yamahata
Date Nov. 17, 2010, 4:50 a.m.
Message ID <90576dc101b512d0f9fb0eb63ecb1b078fef507d.1289969012.git.yamahata@valinux.co.jp>
Download mbox | patch
Permalink /patch/71511/
State New
Headers show

Comments

Isaku Yamahata - Nov. 17, 2010, 4:50 a.m.
Each pci devices should know the behavior on reset.
So make each reset functions call pci default reset function.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 hw/e1000.c      |    1 +
 hw/lsi53c895a.c |    2 ++
 hw/pci.c        |    8 +-------
 hw/pcnet.c      |    1 +
 hw/rtl8139.c    |    2 ++
 hw/virtio-pci.c |    1 +
 6 files changed, 8 insertions(+), 7 deletions(-)

Patch

diff --git a/hw/e1000.c b/hw/e1000.c
index 532efdc..747b740 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -1091,6 +1091,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 f97335e..d490c63 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 b6f58de..51c8307 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -165,18 +165,12 @@  void pci_device_reset_default(PCIDevice *dev)
 
 static void pci_device_reset(PCIDevice *dev)
 {
-    if (!dev->qdev.info) {
+    if (!dev->qdev.info || !dev->qdev.info->reset) {
         /* not all pci devices haven't been qdev'fied yet
            TODO: remove this when all pci devices are qdev'fied. */
         pci_device_reset_default(dev);
     } else {
-        /*
-         * TODO:
-         * each device should know what to do on RST#.
-         * move pci_device_reset_default() into each callback.
-         */
         qdev_reset_all(&dev->qdev);
-        pci_device_reset_default(dev);
     }
 }
 
diff --git a/hw/pcnet.c b/hw/pcnet.c
index b52935a..e73e682 100644
--- a/hw/pcnet.c
+++ b/hw/pcnet.c
@@ -2023,6 +2023,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 d92981d..1f35e5d 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 729917d..f4d39f6 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -186,6 +186,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)