From: Stefano Stabellini Date: Thu, 30 Aug 2012 15:11:32 +0000 (+0100) Subject: qemu-xen-trad: fix msi_translate with PV event delivery X-Git-Tag: xen-4.2.0-rc4~2 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=3e66da7266c84638c0e22a09c9d2b07529802576;p=qemu-xen-4.4-testing.git qemu-xen-trad: fix msi_translate with PV event delivery When switching from msitranslate to straight msi we need to make sure that we respect PV event delivery for the msi if the guest asked for it: - completely disable MSI on the device in pt_disable_msi_translate; - then enable MSI again (pt_msi_setup), mapping the correct pirq to it. Signed-off-by: Stefano Stabellini Tested-by: Rolu --- diff --git a/hw/pass-through.c b/hw/pass-through.c index 6e396e37f..304c438e8 100644 --- a/hw/pass-through.c +++ b/hw/pass-through.c @@ -3841,21 +3841,18 @@ static int pt_msgctrl_reg_write(struct pt_dev *ptdev, PT_LOG("guest enabling MSI, disable MSI-INTx translation\n"); pt_disable_msi_translate(ptdev); } - else + /* Init physical one */ + PT_LOG("setup msi for dev %x\n", pd->devfn); + if (pt_msi_setup(ptdev)) { - /* Init physical one */ - PT_LOG("setup msi for dev %x\n", pd->devfn); - if (pt_msi_setup(ptdev)) - { - /* We do not broadcast the error to the framework code, so - * that MSI errors are contained in MSI emulation code and - * QEMU can go on running. - * Guest MSI would be actually not working. - */ - *value &= ~PCI_MSI_FLAGS_ENABLE; - PT_LOG("Warning: Can not map MSI for dev %x\n", pd->devfn); - return 0; - } + /* We do not broadcast the error to the framework code, so + * that MSI errors are contained in MSI emulation code and + * QEMU can go on running. + * Guest MSI would be actually not working. + */ + *value &= ~PCI_MSI_FLAGS_ENABLE; + PT_LOG("Warning: Can not map MSI for dev %x\n", pd->devfn); + return 0; } if (pt_msi_update(ptdev)) { diff --git a/hw/pt-msi.c b/hw/pt-msi.c index 70c4023ba..73f737d00 100644 --- a/hw/pt-msi.c +++ b/hw/pt-msi.c @@ -263,16 +263,8 @@ void pt_disable_msi_translate(struct pt_dev *dev) uint8_t e_device = 0; uint8_t e_intx = 0; - /* MSI_ENABLE bit should be disabed until the new handler is set */ - msi_set_enable(dev, 0); - - e_device = PCI_SLOT(dev->dev.devfn); - e_intx = pci_intx(dev); - - if (xc_domain_unbind_pt_irq(xc_handle, domid, dev->msi->pirq, - PT_IRQ_TYPE_MSI_TRANSLATE, 0, - e_device, e_intx, 0)) - PT_LOG("Error: Unbinding pt irq for MSI-INTx failed!\n"); + pt_msi_disable(dev); + dev->msi->flags |= MSI_FLAG_UNINIT; if (dev->machine_irq) { @@ -280,8 +272,6 @@ void pt_disable_msi_translate(struct pt_dev *dev) 0, e_device, e_intx)) PT_LOG("Error: Rebinding of interrupt failed!\n"); } - - dev->msi_trans_en = 0; } static int pt_msix_update_one(struct pt_dev *dev, int entry_nr)