msi: Refactorings and reset fixes
v2 cover msi: Refactorings and reset fixes
Patches 1..3 are now targeting 1.1/stable, the rest are cleanups and refactoring that can go in for 1.2. Not sure who will pick the pure ahci/xhci refactorings, so I just left them in here for my convenience.
Jan Kiszka (10):
ahci: Fix reset of MSI function
intel-hda: Fix reset of MSI function
xhci: Fix reset of MSI function
ahci: Clean up reset functions
xhci: Clean up reset function
msi: Guard msi_reset with msi_present
msi: Invoke msi/msix_reset from PCI core
msi: Guard msi/msix_write_config with msi_present
msi: Invoke msi/msix_write_config from PCI core
msi: Use msi/msix_present more consistently
hw/ide/ahci.c | 25 +++++++++++++++---------- hw/ide/ahci.h | 2 +- hw/ide/ich.c | 19 ++++++++----------- hw/intel-hda.c | 12 ------------ hw/ioh3420.c | 3 +-- hw/msi.c | 11 ++++++++--- hw/msix.c | 15 +++++++++------ hw/pci.c | 8 ++++++++ hw/pci_bridge.c | 4 ++++ hw/usb/hcd-xhci.c | 15 ++++++++++----- hw/virtio-pci.c | 3 --- hw/xio3130_downstream.c | 3 +-- hw/xio3130_upstream.c | 3 +-- 13 files changed, 66 insertions(+), 57 deletions(-)
Signature · 1 line
1.7.3.4
PATCH v2 1/10 ahci: Fix reset of MSI function
Call msi_reset on device reset as still required by the core.
--- hw/ide/ich.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-)
hw/ide/ich.c +10 -2
@@ -84,6 +84,14 @@ static const VMStateDescription vmstate_ahci = { .unmigratable = 1, }; +static void pci_ich9_reset (void *opaque) +{ +struct AHCIPCIState *d = opaque; + +msi_reset (&d->card); +ahci_reset (opaque); +} +static int pci_ich9_ahci_init (PCIDevice *dev) {struct AHCIPCIState *d;
@@ -102,7 +110,7 @@ static int pci_ich9_ahci_init(PCIDevice *dev)/* XXX Software should program this register */ d->card.config[0x90 ] =1 <<6 ;/* Address Map Register - AHCI mode */ -qemu_register_reset (ahci_reset, d); +qemu_register_reset (pci_ich9_reset, d);msi_init (dev,0x50 ,1 , true, false); d->ahci.irq = d->card.irq[0 ];
@@ -133,7 +141,7 @@ static int pci_ich9_uninit(PCIDevice *dev) d = DO_UPCAST(struct AHCIPCIState, card, dev);msi_uninit (dev); -qemu_unregister_reset (ahci_reset, d); +qemu_unregister_reset (pci_ich9_reset, d);ahci_uninit (&d->ahci);return 0 ;
Signature · 1 line
1.7.3.4
PATCH v2 2/10 intel-hda: Fix reset of MSI function
In reply to Jan KiszkaCall msi_reset on device reset as still required by the core.
--- hw/intel-hda.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
hw/intel-hda.c +3 -0
@@ -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);
Signature · 1 line
1.7.3.4
PATCH v2 3/10 xhci: Fix reset of MSI function
In reply to Jan KiszkaCall msi_reset on device reset as still required by the core.
--- hw/usb/hcd-xhci.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-)
hw/usb/hcd-xhci.c +10 -3
@@ -2296,9 +2296,8 @@ static void xhci_update_port(XHCIState *xhci, XHCIPort *port, int is_detach) } } -static void xhci_reset (void *opaque) +static void xhci_reset_full (XHCIState *xhci) { -XHCIState *xhci = opaque;int i;DPRINTF ("xhci: full reset\n" );
@@ -2340,6 +2339,14 @@ static void xhci_reset(void *opaque) xhci->ev_buffer_get =0 ; } +static void xhci_reset (void *opaque) +{ +XHCIState *xhci = opaque; + +msi_reset (&xhci->pci_dev); +xhci_reset_full (xhci); +} +static uint32_t xhci_cap_read (XHCIState *xhci,uint32_t reg) {DPRINTF ("xhci_cap_read(0x%x)\n" , reg);
@@ -2506,7 +2513,7 @@ static void xhci_oper_write(XHCIState *xhci, uint32_t reg, uint32_t val) } xhci->usbcmd = val &0xc0f ;if (val &USBCMD_HCRST ) { -xhci_reset (xhci); +xhci_reset_full (xhci); }xhci_irq_update (xhci);break ;
Signature · 1 line
1.7.3.4
Re: [Qemu-devel] [PATCH v2 03/10] xhci: Fix reset of MSI function
Quoted 1 line · Jan Kiszka
Call
msi_reseton device reset as still required by the core.
Note: msi on xhci is disabled by default (and also broken as far I know).
hw/usb/hcd-xhci.c static void xhci_reset(void *opaque) · line 2345
Quoted 4 lines
hw/usb/hcd-xhci.c +4
-0+static void xhci_reset (void *opaque) +{ +XHCIState *xhci = opaque; +
if (xhci->msi)
Quoted 1 line
+
msi_reset(&xhci->pci_dev);
}
hw/usb/hcd-xhci.c static void xhci_reset(void *opaque) · line 2348
Quoted 2 lines
hw/usb/hcd-xhci.c +2
-0+xhci_reset_full (xhci); +}
And can't we let the pci core handle it so we don't need ugly wrappers like this?
cheers,
Gerd
Re: [Qemu-devel] [PATCH v2 03/10] xhci: Fix reset of MSI function
Quoted 4 lines · Gerd Hoffmann
Quoted 1 line · Jan Kiszka
Call
msi_reseton device reset as still required by the core.Note: msi on xhci is disabled by default (and also broken as far I know).
OK, then we can likely skip this patch for 1.1/stable.
Quoted 7 lines
hw/usb/hcd-xhci.c static void xhci_reset(void *opaque) · line 2345
Quoted 5 lines
hw/usb/hcd-xhci.c +4
-0+static void xhci_reset (void *opaque) +{ +XHCIState *xhci = opaque; +if (
xhci->msi)
Oops.
Quoted 10 lines
Quoted 2 lines
+
msi_reset(&xhci->pci_dev);}
hw/usb/hcd-xhci.c static void xhci_reset(void *opaque) · line 2348
Quoted 2 lines
hw/usb/hcd-xhci.c +2
-0+xhci_reset_full (xhci); +}And can't we let the pci core handle it so we don't need ugly wrappers like this?
That's what patches later in the series do. But Michael was preferring this approach for 1.1 and the cleanup for 1.2.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [Qemu-devel] [PATCH v2 03/10] xhci: Fix reset of MSI function
Hi,
Quoted 5 lines
Quoted 2 lines
And can't we let the pci core handle it so we don't need ugly wrappers like this?
That's what patches later in the series do. But Michael was preferring this approach for 1.1 and the cleanup for 1.2.
Ah, ok, good. Yea, lets leave it alone for 1.1 and fix it properly in 1.2
cheers,
Gerd
PATCH v2 4/10 ahci: Clean up reset functions
In reply to Jan KiszkaProperly register reset functions via the device class.
--- hw/ide/ahci.c | 25 +++++++++++++++---------- hw/ide/ahci.h | 2 +- hw/ide/ich.c | 10 ++++------ 3 files changed, 20 insertions(+), 17 deletions(-)
hw/ide/ahci.c +15 -10
@@ -339,7 +339,7 @@ static void ahci_mem_write(void *opaque, target_phys_addr_t addr,case HOST_CTL :/* R/W */ if (val &HOST_CTL_RESET ) {DPRINTF (-1 ,"HBA Reset\n" ); -ahci_reset (container_of (s, AHCIPCIState, ahci)); +ahci_reset (s); }else { s->control_regs.ghc = (val &0x3 ) |HOST_CTL_AHCI_EN ;ahci_check_irq (s);
@@ -1149,21 +1149,20 @@ void ahci_uninit(AHCIState *s)g_free (s->dev); } -void ahci_reset (void *opaque) +void ahci_reset (AHCIState *s) { -struct AHCIPCIState *d = opaque;AHCIPortRegs *pr;int i; - d->ahci.control_regs.irqstatus =0 ; - d->ahci.control_regs.ghc =0 ; + s->control_regs.irqstatus =0 ; + s->control_regs.ghc =0 ; -for (i =0 ; i < d->ahci.ports; i++) { - pr = &d->ahci.dev[i].port_regs; +for (i =0 ; i < s->ports; i++) { + pr = &s->dev[i].port_regs; pr->irq_stat =0 ; pr->irq_mask =0 ; pr->scr_ctl =0 ; -ahci_reset_port (&d->ahci, i); +ahci_reset_port (s, i); } }
@@ -1178,6 +1177,13 @@ static const VMStateDescription vmstate_sysbus_ahci = { .unmigratable = 1, }; +static void sysbus_ahci_reset (DeviceState *dev) +{ +SysbusAHCIState *s =DO_UPCAST (SysbusAHCIState, busdev.qdev, dev); + +ahci_reset (&s->ahci); +} +static int sysbus_ahci_init (SysBusDevice *dev) {SysbusAHCIState *s =FROM_SYSBUS (SysbusAHCIState, dev);
@@ -1185,8 +1191,6 @@ static int sysbus_ahci_init(SysBusDevice *dev)sysbus_init_mmio (dev, &s->ahci.mem);sysbus_init_irq (dev, &s->ahci.irq); - -qemu_register_reset (ahci_reset, &s->ahci);return 0 ; }
@@ -1203,6 +1207,7 @@ static void sysbus_ahci_class_init(ObjectClass *klass, void *data) sbc->init = sysbus_ahci_init; dc->vmsd = &vmstate_sysbus_ahci; dc->props = sysbus_ahci_properties; + dc->reset = sysbus_ahci_reset; }static TypeInfo sysbus_ahci_info = {
hw/ide/ahci.h +1 -1
@@ -332,6 +332,6 @@ typedef struct NCQFrame {void ahci_init (AHCIState *s,DeviceState *qdev,int ports);void ahci_uninit (AHCIState *s); -void ahci_reset (void *opaque); +void ahci_reset (AHCIState *s);#endif /* HW_IDE_AHCI_H */
hw/ide/ich.c +4 -6
@@ -84,12 +84,12 @@ static const VMStateDescription vmstate_ahci = { .unmigratable = 1, }; -static void pci_ich9_reset (void *opaque) +static void pci_ich9_reset (DeviceState *dev) { -struct AHCIPCIState *d = opaque; + struct AHCIPCIState *d = DO_UPCAST(struct AHCIPCIState, card.qdev, dev);msi_reset (&d->card); -ahci_reset (opaque); +ahci_reset (&d->ahci); }static int pci_ich9_ahci_init (PCIDevice *dev)
@@ -110,8 +110,6 @@ static int pci_ich9_ahci_init(PCIDevice *dev)/* XXX Software should program this register */ d->card.config[0x90 ] =1 <<6 ;/* Address Map Register - AHCI mode */ -qemu_register_reset (pci_ich9_reset, d); -msi_init (dev,0x50 ,1 , true, false); d->ahci.irq = d->card.irq[0 ];
@@ -141,7 +139,6 @@ static int pci_ich9_uninit(PCIDevice *dev) d = DO_UPCAST(struct AHCIPCIState, card, dev);msi_uninit (dev); -qemu_unregister_reset (pci_ich9_reset, d);ahci_uninit (&d->ahci);return 0 ;
@@ -167,6 +164,7 @@ static void ich_ahci_class_init(ObjectClass *klass, void *data) k->revision =0x02 ; k->class_id =PCI_CLASS_STORAGE_SATA ; dc->vmsd = &vmstate_ahci; + dc->reset = pci_ich9_reset; }static TypeInfo ich_ahci_info = {
Signature · 1 line
1.7.3.4
PATCH v2 5/10 xhci: Clean up reset function
In reply to Jan KiszkaProperly register reset function via the device class.
--- hw/usb/hcd-xhci.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
hw/usb/hcd-xhci.c +3 -4
@@ -2339,9 +2339,9 @@ static void xhci_reset_full(XHCIState *xhci) xhci->ev_buffer_get =0 ; } -static void xhci_reset (void *opaque) +static void xhci_reset (DeviceState *dev) { -XHCIState *xhci = opaque; +XHCIState *xhci =DO_UPCAST (XHCIState, pci_dev.qdev, dev);msi_reset (&xhci->pci_dev);xhci_reset_full (xhci);
@@ -2838,8 +2838,6 @@ static void usb_xhci_init(XHCIState *xhci, DeviceState *dev)for (i =0 ; i <MAXSLOTS ; i++) { xhci->slots[i].enabled =0 ; } - -qemu_register_reset (xhci_reset, xhci); }static int usb_xhci_initfn (struct PCIDevice *dev)
@@ -2902,6 +2900,7 @@ static void xhci_class_init(ObjectClass *klass, void *data) dc->vmsd = &vmstate_xhci; dc->props = xhci_properties; + dc->reset = xhci_reset; k->init = usb_xhci_initfn; k->vendor_id =PCI_VENDOR_ID_NEC ; k->device_id =PCI_DEVICE_ID_NEC_UPD720200 ;
Signature · 1 line
1.7.3.4
PATCH v2 6/10 msi: Guard msi_reset with msi_present
In reply to Jan Kiszka--- hw/msi.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
hw/msi.c +4 -0
@@ -191,6 +191,10 @@ void msi_reset(PCIDevice *dev)uint16_t flags;bool msi64bit; +if (!msi_present (dev)) { +return ; + } + flags =pci_get_word (dev->config +msi_flags_off (dev)); flags &= ~(PCI_MSI_FLAGS_QSIZE |PCI_MSI_FLAGS_ENABLE ); msi64bit = flags &PCI_MSI_FLAGS_64BIT ;
Signature · 1 line
1.7.3.4
PATCH v2 7/10 msi: Invoke msi/msix_reset from PCI core
In reply to Jan KiszkaThere is no point in pushing this burden to the devices, they may rather forget to call them (like intel-hda, ahci, xhci did). Instead, reset functions are now called from pci_device_reset and pci_bridge_reset. They do nothing if MSI/MSI-X is not in use.
--- hw/ide/ich.c | 1 - hw/intel-hda.c | 3 --- hw/ioh3420.c | 2 +- hw/pci.c | 5 +++++ hw/pci_bridge.c | 4 ++++ hw/usb/hcd-xhci.c | 1 - hw/virtio-pci.c | 1 - hw/xio3130_downstream.c | 2 +- hw/xio3130_upstream.c | 2 +- 9 files changed, 12 insertions(+), 9 deletions(-)
hw/ide/ich.c +0 -1
@@ -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); }
hw/intel-hda.c +0 -3
@@ -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);
hw/ioh3420.c +1 -1
@@ -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);
hw/pci.c +5 -0
@@ -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); }/*
hw/pci_bridge.c +4 -0
@@ -32,6 +32,8 @@#include "pci_bridge.h" #include "pci_internals.h" #include "range.h" +#include "msi.h" +#include "msix.h" /* PCI bridge subsystem vendor ID helper functions */ #define PCI_SSVID_SIZEOF 8
@@ -296,6 +298,8 @@ void pci_bridge_reset(DeviceState *qdev) {PCIDevice *dev =PCI_DEVICE (qdev);pci_bridge_reset_reg (dev); +msi_reset (dev); +msix_reset (dev); }/* default qdev initialization function for PCI-to-PCI bridge */
hw/usb/hcd-xhci.c +0 -1
@@ -2343,7 +2343,6 @@ static void xhci_reset(DeviceState *dev) {XHCIState *xhci =DO_UPCAST (XHCIState, pci_dev.qdev, dev); -msi_reset (&xhci->pci_dev);xhci_reset_full (xhci); }
hw/virtio-pci.c +0 -1
@@ -277,7 +277,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 ; }
hw/xio3130_downstream.c +1 -1
@@ -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);
hw/xio3130_upstream.c +1 -1
@@ -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); }
Signature · 1 line
1.7.3.4
PATCH v2 8/10 msi: Guard msi/msix_write_config with msi_present
In reply to Jan KiszkaTerminate msi/msix_write_config early if support is not enabled. This allows to remove checks at the caller site if MSI is optional.
--- hw/msi.c | 3 ++- hw/msix.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
hw/msi.c +2 -1
@@ -276,7 +276,8 @@ void msi_write_config(PCIDevice *dev, uint32_t addr, uint32_t val, int len)unsigned int vector;uint32_t pending; -if (!ranges_overlap (addr, len, dev->msi_cap,msi_cap_sizeof (flags))) { +if (!msi_present (dev) || + !ranges_overlap (addr, len, dev->msi_cap,msi_cap_sizeof (flags))) {return ; }
hw/msix.c +1 -1
@@ -157,7 +157,7 @@ void msix_write_config(PCIDevice *dev, uint32_t addr,int vector;bool was_masked; -if (!range_covers_byte (addr, len, enable_pos)) { +if (!msix_present (dev) || !range_covers_byte (addr, len, enable_pos)) {return ; }
Signature · 1 line
1.7.3.4
PATCH v2 9/10 msi: Invoke msi/msix_write_config from PCI core
In reply to Jan KiszkaAlso 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.
--- 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(-)
hw/ide/ich.c +0 -8
@@ -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 ;
hw/intel-hda.c +0 -12
@@ -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 ;
hw/ioh3420.c +0 -1
@@ -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);
hw/msi.c +1 -1
@@ -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));
hw/pci.c +3 -0
@@ -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); }/***********************************************************/
hw/virtio-pci.c +0 -2
@@ -519,8 +519,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)
hw/xio3130_downstream.c +0 -1
@@ -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); }
hw/xio3130_upstream.c +0 -1
@@ -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); }
Signature · 1 line
1.7.3.4
PATCH v2 10/10 msi: Use msi/msix_present more consistently
In reply to Jan KiszkaReplace some open-coded msi/msix_present checks.
--- hw/msi.c | 2 +- hw/msix.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-)
hw/msi.c +1 -1
@@ -175,7 +175,7 @@ void msi_uninit(struct PCIDevice *dev)uint16_t flags;uint8_t cap_size; -if (!(dev->cap_present &QEMU_PCI_CAP_MSI )) { +if (!msi_present (dev)) {return ; } flags =pci_get_word (dev->config +msi_flags_off (dev));
hw/msix.c +8 -5
@@ -285,8 +285,9 @@ static void msix_free_irq_entries(PCIDevice *dev)/* Clean up resources for the device. */ int msix_uninit (PCIDevice *dev,MemoryRegion *bar) { -if (!(dev->cap_present &QEMU_PCI_CAP_MSIX )) +if (!msix_present (dev)) {return 0 ; + }pci_del_capability (dev,PCI_CAP_ID_MSIX ,MSIX_CAP_LENGTH ); dev->msix_cap =0 ;msix_free_irq_entries (dev);
@@ -305,7 +306,7 @@ void msix_save(PCIDevice *dev, QEMUFile *f) {unsigned n = dev->msix_entries_nr; -if (!(dev->cap_present &QEMU_PCI_CAP_MSIX )) { +if (!msix_present (dev)) {return ; }
@@ -318,7 +319,7 @@ void msix_load(PCIDevice *dev, QEMUFile *f) {unsigned n = dev->msix_entries_nr; -if (!(dev->cap_present &QEMU_PCI_CAP_MSIX )) { +if (!msix_present (dev)) {return ; }
@@ -370,8 +371,9 @@ void msix_notify(PCIDevice *dev, unsigned vector)void msix_reset (PCIDevice *dev) { -if (!(dev->cap_present &QEMU_PCI_CAP_MSIX )) +if (!msix_present (dev)) {return ; + }msix_free_irq_entries (dev); dev->config[dev->msix_cap +MSIX_CONTROL_OFFSET ] &= ~dev->wmask[dev->msix_cap +MSIX_CONTROL_OFFSET ];
@@ -410,7 +412,8 @@ void msix_vector_unuse(PCIDevice *dev, unsigned vector)void msix_unuse_all_vectors (PCIDevice *dev) { -if (!(dev->cap_present &QEMU_PCI_CAP_MSIX )) +if (!msix_present (dev)) {return ; + }msix_free_irq_entries (dev); }
Signature · 1 line
1.7.3.4