Skip to contentSkip to conversation

pci: Fix clearing IRQs on reset

PATCH Applied Cole Robinson 4 participants 4 messages Mar 31, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pci: Fix clearing IRQs on reset

irq_state is cleared before calling pci_device_deassert_intx, but the latter misbehaves if the former isn't accurate. In this case, any raised IRQs are not cleared, which hits an assertion in pcibus_reset:

qemu-system-x86_64: hw/pci/pci.c:250: pcibus_reset: Assertion `bus->irq_count[i] == 0' failed.

pci_device_deassert_intx should clear irq_state anyways, so add an assert.

This fixes migration with usb2 + usb-tablet.

---
 hw/pci/pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/pci/pci.c +2 -2
index 8f722dd..2a9f08e 100644
@@ -189,9 +189,9 @@ static void pci_do_device_reset(PCIDevice *dev)
 {
     int r;
 
-    dev->irq_state = 0;
-    pci_update_irq_status(dev);
     pci_device_deassert_intx(dev);
+    assert(dev->irq_state == 0);
+
     /* Clear all writable bits */
     pci_word_test_and_clear_mask(dev->config + PCI_COMMAND,
                                  pci_get_word(dev->wmask + PCI_COMMAND) |
Signature · 1 line
1.8.5.3
Reviewed-by on v1 1/1
#1 lore raw

Il 31/03/2014 20:31, Cole Robinson ha scritto:

Quoted 24 lines

irq_state is cleared before calling pci_device_deassert_intx, but the latter misbehaves if the former isn't accurate. In this case, any raised IRQs are not cleared, which hits an assertion in pcibus_reset:

qemu-system-x86_64: hw/pci/pci.c:250: pcibus_reset: Assertion `bus->irq_count[i] == 0' failed.

pci_device_deassert_intx should clear irq_state anyways, so add an assert.

This fixes migration with usb2 + usb-tablet.

---
 hw/pci/pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/pci/pci.c +0 -0
index 8f722dd..2a9f08e 100644
@@ -189,9 +189,9 @@ static void pci_do_device_reset(PCIDevice *dev)
 {

hw/pci/pci.c static void pci_do_device_reset(PCIDevice *dev) · line 197

Quoted 10 lines
hw/pci/pci.c +2 -2
     int r;
 
-    dev->irq_state = 0;
-    pci_update_irq_status(dev);
     pci_device_deassert_intx(dev);
+    assert(dev->irq_state == 0);
+
     /* Clear all writable bits */
     pci_word_test_and_clear_mask(dev->config + PCI_COMMAND,
                                  pci_get_word(dev->wmask + PCI_COMMAND) |
Reviewed-by on v1 1/1
#2 lore raw
In reply to Cole Robinson
Quoted 7 lines · Cole Robinson

irq_state is cleared before calling pci_device_deassert_intx, but the latter misbehaves if the former isn't accurate. In this case, any raised IRQs are not cleared, which hits an assertion in pcibus_reset:

qemu-system-x86_64: hw/pci/pci.c:250: pcibus_reset: Assertion `bus->irq_count[i] == 0' failed.

Quoted 6 lines

pci_device_deassert_intx should clear irq_state anyways, so add an assert.

This fixes migration with usb2 + usb-tablet.

Peter, could you pick this up for RC3 if not too late?

Quoted 22 lines
---
 hw/pci/pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/pci/pci.c +2 -2
index 8f722dd..2a9f08e 100644
@@ -189,9 +189,9 @@ static void pci_do_device_reset(PCIDevice *dev)
 {
     int r;
 
-    dev->irq_state = 0;
-    pci_update_irq_status(dev);
     pci_device_deassert_intx(dev);
+    assert(dev->irq_state == 0);
+
     /* Clear all writable bits */
     pci_word_test_and_clear_mask(dev->config + PCI_COMMAND,
                                  pci_get_word(dev->wmask + PCI_COMMAND) |
Signature · 1 line
1.8.5.3
#3 lore raw
Quoted 11 lines · Michael S. Tsirkin
Quoted 10 lines · Cole Robinson

irq_state is cleared before calling pci_device_deassert_intx, but the latter misbehaves if the former isn't accurate. In this case, any raised IRQs are not cleared, which hits an assertion in pcibus_reset:

qemu-system-x86_64: hw/pci/pci.c:250: pcibus_reset: Assertion `bus->irq_count[i] == 0' failed.

pci_device_deassert_intx should clear irq_state anyways, so add an assert.

Quoted 8 lines
Quoted 3 lines

This fixes migration with usb2 + usb-tablet.

Peter, could you pick this up for RC3 if not too late?

Applied to master, thanks.

thanks
-- PMM