From 8e729e3b521d9fcd87fc2e40b6322e684f58bb2e Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Fri, 11 May 2012 11:42:35 -0300 Subject: intel-hda: Fix reset of MSI function Call msi_reset on device reset as still required by the core. CC: Gerd Hoffmann CC: qemu-stable@nongnu.org Signed-off-by: Jan Kiszka Signed-off-by: Michael S. Tsirkin --- hw/intel-hda.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'hw/intel-hda.c') diff --git a/hw/intel-hda.c b/hw/intel-hda.c index bb11af286a..e38861e5de 100644 --- a/hw/intel-hda.c +++ b/hw/intel-hda.c @@ -1107,6 +1107,9 @@ static void intel_hda_reset(DeviceState *dev) DeviceState *qdev; HDACodecDevice *cdev; + if (d->msi) { + msi_reset(&d->pci); + } intel_hda_regs_reset(d); d->wall_base_ns = qemu_get_clock_ns(vm_clock); -- cgit 1.4.1 From cbd2d4342b3d42ab33baa99f5b7a23491b5692f2 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Tue, 15 May 2012 20:09:56 -0300 Subject: msi: Invoke msi/msix_reset from PCI core There is no point in pushing this burden to the devices, they tend to forget to call them (like intel-hda, ahci, xhci did). Instead, reset functions are now called from pci_device_reset. They do nothing if MSI/MSI-X is not in use. CC: Alexander Graf CC: Gerd Hoffmann CC: Isaku Yamahata Signed-off-by: Jan Kiszka Signed-off-by: Michael S. Tsirkin --- hw/ide/ich.c | 1 - hw/intel-hda.c | 3 --- hw/ioh3420.c | 2 +- hw/ivshmem.c | 1 - hw/pci.c | 5 +++++ hw/pci_bridge.c | 10 ++-------- hw/pci_bridge_dev.c | 4 +--- hw/virtio-pci.c | 1 - hw/xio3130_downstream.c | 2 +- hw/xio3130_upstream.c | 2 +- 10 files changed, 11 insertions(+), 20 deletions(-) (limited to 'hw/intel-hda.c') diff --git a/hw/ide/ich.c b/hw/ide/ich.c index e7026bb414..d3bc822831 100644 --- a/hw/ide/ich.c +++ b/hw/ide/ich.c @@ -88,7 +88,6 @@ static void pci_ich9_reset(DeviceState *dev) { struct AHCIPCIState *d = DO_UPCAST(struct AHCIPCIState, card.qdev, dev); - msi_reset(&d->card); ahci_reset(&d->ahci); } diff --git a/hw/intel-hda.c b/hw/intel-hda.c index e38861e5de..bb11af286a 100644 --- a/hw/intel-hda.c +++ b/hw/intel-hda.c @@ -1107,9 +1107,6 @@ static void intel_hda_reset(DeviceState *dev) DeviceState *qdev; HDACodecDevice *cdev; - if (d->msi) { - msi_reset(&d->pci); - } intel_hda_regs_reset(d); d->wall_base_ns = qemu_get_clock_ns(vm_clock); diff --git a/hw/ioh3420.c b/hw/ioh3420.c index 1632d31c19..d1499da4ac 100644 --- a/hw/ioh3420.c +++ b/hw/ioh3420.c @@ -81,7 +81,7 @@ static void ioh3420_write_config(PCIDevice *d, static void ioh3420_reset(DeviceState *qdev) { PCIDevice *d = PCI_DEVICE(qdev); - msi_reset(d); + ioh3420_aer_vector_update(d); pcie_cap_root_reset(d); pcie_cap_deverr_reset(d); diff --git a/hw/ivshmem.c b/hw/ivshmem.c index d48e5f9906..05559b639c 100644 --- a/hw/ivshmem.c +++ b/hw/ivshmem.c @@ -530,7 +530,6 @@ static void ivshmem_reset(DeviceState *d) IVShmemState *s = DO_UPCAST(IVShmemState, dev.qdev, d); s->intrstatus = 0; - msix_reset(&s->dev); ivshmem_use_msix(s); return; } diff --git a/hw/pci.c b/hw/pci.c index c1ebdde91e..2b429c03d1 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -31,6 +31,8 @@ #include "loader.h" #include "range.h" #include "qmp-commands.h" +#include "msi.h" +#include "msix.h" //#define DEBUG_PCI #ifdef DEBUG_PCI @@ -188,6 +190,9 @@ void pci_device_reset(PCIDevice *dev) } } pci_update_mappings(dev); + + msi_reset(dev); + msix_reset(dev); } /* diff --git a/hw/pci_bridge.c b/hw/pci_bridge.c index 866f0b6c52..e0832b4a67 100644 --- a/hw/pci_bridge.c +++ b/hw/pci_bridge.c @@ -254,8 +254,9 @@ void pci_bridge_disable_base_limit(PCIDevice *dev) } /* reset bridge specific configuration registers */ -void pci_bridge_reset_reg(PCIDevice *dev) +void pci_bridge_reset(DeviceState *qdev) { + PCIDevice *dev = PCI_DEVICE(qdev); uint8_t *conf = dev->config; conf[PCI_PRIMARY_BUS] = 0; @@ -291,13 +292,6 @@ void pci_bridge_reset_reg(PCIDevice *dev) pci_set_word(conf + PCI_BRIDGE_CONTROL, 0); } -/* default reset function for PCI-to-PCI bridge */ -void pci_bridge_reset(DeviceState *qdev) -{ - PCIDevice *dev = PCI_DEVICE(qdev); - pci_bridge_reset_reg(dev); -} - /* default qdev initialization function for PCI-to-PCI bridge */ int pci_bridge_initfn(PCIDevice *dev) { diff --git a/hw/pci_bridge_dev.c b/hw/pci_bridge_dev.c index eccaa5831e..b6d5fb7388 100644 --- a/hw/pci_bridge_dev.c +++ b/hw/pci_bridge_dev.c @@ -119,10 +119,8 @@ static void pci_bridge_dev_write_config(PCIDevice *d, static void qdev_pci_bridge_dev_reset(DeviceState *qdev) { PCIDevice *dev = DO_UPCAST(PCIDevice, qdev, qdev); + pci_bridge_reset(qdev); - if (msi_present(dev)) { - msi_reset(dev); - } shpc_reset(dev); } diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index d08c1590d2..4736ba3898 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -278,7 +278,6 @@ void virtio_pci_reset(DeviceState *d) VirtIOPCIProxy *proxy = container_of(d, VirtIOPCIProxy, pci_dev.qdev); virtio_pci_stop_ioeventfd(proxy); virtio_reset(proxy->vdev); - msix_reset(&proxy->pci_dev); proxy->flags &= ~VIRTIO_PCI_FLAG_BUS_MASTER_BUG; } diff --git a/hw/xio3130_downstream.c b/hw/xio3130_downstream.c index 319624f212..3716e4541a 100644 --- a/hw/xio3130_downstream.c +++ b/hw/xio3130_downstream.c @@ -48,7 +48,7 @@ static void xio3130_downstream_write_config(PCIDevice *d, uint32_t address, static void xio3130_downstream_reset(DeviceState *qdev) { PCIDevice *d = PCI_DEVICE(qdev); - msi_reset(d); + pcie_cap_deverr_reset(d); pcie_cap_slot_reset(d); pcie_cap_ari_reset(d); diff --git a/hw/xio3130_upstream.c b/hw/xio3130_upstream.c index 34a99bba08..962d48e63e 100644 --- a/hw/xio3130_upstream.c +++ b/hw/xio3130_upstream.c @@ -47,7 +47,7 @@ static void xio3130_upstream_write_config(PCIDevice *d, uint32_t address, static void xio3130_upstream_reset(DeviceState *qdev) { PCIDevice *d = PCI_DEVICE(qdev); - msi_reset(d); + pci_bridge_reset(qdev); pcie_cap_deverr_reset(d); } -- cgit 1.4.1 From 95d658002401e2e47a5404298ebe9508846e8a39 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Fri, 11 May 2012 11:42:40 -0300 Subject: msi: Invoke msi/msix_write_config from PCI core Also this functions is better invoked by the core than by each and every device. This allows to drop the config_write callbacks from ich and intel-hda. CC: Alexander Graf CC: Gerd Hoffmann CC: Isaku Yamahata Signed-off-by: Jan Kiszka Signed-off-by: Michael S. Tsirkin --- hw/ide/ich.c | 8 -------- hw/intel-hda.c | 12 ------------ hw/ioh3420.c | 1 - hw/msi.c | 2 +- hw/pci.c | 3 +++ hw/virtio-pci.c | 2 -- hw/xio3130_downstream.c | 1 - hw/xio3130_upstream.c | 1 - 8 files changed, 4 insertions(+), 26 deletions(-) (limited to 'hw/intel-hda.c') diff --git a/hw/ide/ich.c b/hw/ide/ich.c index d3bc822831..e3eaaea882 100644 --- a/hw/ide/ich.c +++ b/hw/ide/ich.c @@ -143,13 +143,6 @@ static int pci_ich9_uninit(PCIDevice *dev) return 0; } -static void pci_ich9_write_config(PCIDevice *pci, uint32_t addr, - uint32_t val, int len) -{ - pci_default_write_config(pci, addr, val, len); - msi_write_config(pci, addr, val, len); -} - static void ich_ahci_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -157,7 +150,6 @@ static void ich_ahci_class_init(ObjectClass *klass, void *data) k->init = pci_ich9_ahci_init; k->exit = pci_ich9_uninit; - k->config_write = pci_ich9_write_config; k->vendor_id = PCI_VENDOR_ID_INTEL; k->device_id = PCI_DEVICE_ID_INTEL_82801IR; k->revision = 0x02; diff --git a/hw/intel-hda.c b/hw/intel-hda.c index bb11af286a..8f3b70bd14 100644 --- a/hw/intel-hda.c +++ b/hw/intel-hda.c @@ -1153,17 +1153,6 @@ static int intel_hda_exit(PCIDevice *pci) return 0; } -static void intel_hda_write_config(PCIDevice *pci, uint32_t addr, - uint32_t val, int len) -{ - IntelHDAState *d = DO_UPCAST(IntelHDAState, pci, pci); - - pci_default_write_config(pci, addr, val, len); - if (d->msi) { - msi_write_config(pci, addr, val, len); - } -} - static int intel_hda_post_load(void *opaque, int version) { IntelHDAState* d = opaque; @@ -1252,7 +1241,6 @@ static void intel_hda_class_init(ObjectClass *klass, void *data) k->init = intel_hda_init; k->exit = intel_hda_exit; - k->config_write = intel_hda_write_config; k->vendor_id = PCI_VENDOR_ID_INTEL; k->device_id = 0x2668; k->revision = 1; diff --git a/hw/ioh3420.c b/hw/ioh3420.c index d1499da4ac..0a2601cac4 100644 --- a/hw/ioh3420.c +++ b/hw/ioh3420.c @@ -71,7 +71,6 @@ static void ioh3420_write_config(PCIDevice *d, pci_get_long(d->config + d->exp.aer_cap + PCI_ERR_ROOT_COMMAND); pci_bridge_write_config(d, address, val, len); - msi_write_config(d, address, val, len); ioh3420_aer_vector_update(d); pcie_cap_slot_write_config(d, address, val, len); pcie_aer_write_config(d, address, val, len); diff --git a/hw/msi.c b/hw/msi.c index da12f33728..556c7c4ae8 100644 --- a/hw/msi.c +++ b/hw/msi.c @@ -264,7 +264,7 @@ void msi_notify(PCIDevice *dev, unsigned int vector) stl_le_phys(address, data); } -/* call this function after updating configs by pci_default_write_config(). */ +/* Normally called by pci_default_write_config(). */ void msi_write_config(PCIDevice *dev, uint32_t addr, uint32_t val, int len) { uint16_t flags = pci_get_word(dev->config + msi_flags_off(dev)); diff --git a/hw/pci.c b/hw/pci.c index 2b429c03d1..d5c664c9cd 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -1042,6 +1042,9 @@ void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l) if (range_covers_byte(addr, l, PCI_COMMAND)) pci_update_irq_disabled(d, was_irq_disabled); + + msi_write_config(d, addr, val, l); + msix_write_config(d, addr, val, l); } /***********************************************************/ diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 4736ba3898..9342eed070 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -520,8 +520,6 @@ static void virtio_write_config(PCIDevice *pci_dev, uint32_t address, virtio_set_status(proxy->vdev, proxy->vdev->status & ~VIRTIO_CONFIG_S_DRIVER_OK); } - - msix_write_config(pci_dev, address, val, len); } static unsigned virtio_pci_get_features(void *opaque) diff --git a/hw/xio3130_downstream.c b/hw/xio3130_downstream.c index 3716e4541a..56d1b353d0 100644 --- a/hw/xio3130_downstream.c +++ b/hw/xio3130_downstream.c @@ -41,7 +41,6 @@ static void xio3130_downstream_write_config(PCIDevice *d, uint32_t address, pci_bridge_write_config(d, address, val, len); pcie_cap_flr_write_config(d, address, val, len); pcie_cap_slot_write_config(d, address, val, len); - msi_write_config(d, address, val, len); pcie_aer_write_config(d, address, val, len); } diff --git a/hw/xio3130_upstream.c b/hw/xio3130_upstream.c index 962d48e63e..79725813a2 100644 --- a/hw/xio3130_upstream.c +++ b/hw/xio3130_upstream.c @@ -40,7 +40,6 @@ static void xio3130_upstream_write_config(PCIDevice *d, uint32_t address, { pci_bridge_write_config(d, address, val, len); pcie_cap_flr_write_config(d, address, val, len); - msi_write_config(d, address, val, len); pcie_aer_write_config(d, address, val, len); } -- cgit 1.4.1