Skip to contentSkip to conversation

ehci: fix Interrupt Threshold Control implementation

PATCH In review Gerd Hoffmann 2 participants 2 messages Aug 15, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ehci: fix Interrupt Threshold Control implementation

First, not all interrupts are subject to Interrupt Threshold Control, some of them must be delivered without delay.

Second, Interrupt Threshold Control state must be part of vmstate, otherwise we might loose IRQs on migration.

---
 hw/usb/hcd-ehci.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
hw/usb/hcd-ehci.c +10 -2
index 2eeef29..b78bf44 100644
@@ -576,7 +576,12 @@ static inline void ehci_update_irq(EHCIState *s)
 /* flag interrupt condition */
 static inline void ehci_raise_irq(EHCIState *s, int intr)
 {
-    s->usbsts_pending |= intr;
+    if (intr & (USBSTS_PCD | USBSTS_FLR | USBSTS_HSE)) {
+        s->usbsts |= intr;
+        ehci_update_irq(s);
+    } else {
+        s->usbsts_pending |= intr;
+    }
 }
 
 /*
@@ -2480,7 +2485,8 @@ static int usb_ehci_post_load(void *opaque, int version_id)
 
 static const VMStateDescription vmstate_ehci = {
     .name        = "ehci",
-    .version_id  = 1,
+    .version_id  = 2,
+    .minimum_version_id  = 1,
     .pre_save    = usb_ehci_pre_save,
     .post_load   = usb_ehci_post_load,
     .fields      = (VMStateField[]) {
@@ -2488,6 +2494,8 @@ static const VMStateDescription vmstate_ehci = {
         /* mmio registers */
         VMSTATE_UINT32(usbcmd, EHCIState),
         VMSTATE_UINT32(usbsts, EHCIState),
+        VMSTATE_UINT32_V(usbsts_pending, EHCIState, 2),
+        VMSTATE_UINT32_V(usbsts_frindex, EHCIState, 2),
         VMSTATE_UINT32(usbintr, EHCIState),
         VMSTATE_UINT32(frindex, EHCIState),
         VMSTATE_UINT32(ctrldssegment, EHCIState),
Signature · 1 line
1.7.1
#1 lore raw

Hi,

Quoted 5 lines · Gerd Hoffmann

First, not all interrupts are subject to Interrupt Threshold Control, some of them must be delivered without delay.

Second, Interrupt Threshold Control state must be part of vmstate, otherwise we might loose IRQs on migration.

Looks good except for 2 things:

1) For some reason it does not fix my redirected usb mass storage device not seen until lsusb issue, I will investigate this further
2) Does not apply cleanly to master, there is no vmstate_ehci.pre_seave in master

Regards,

Hans

Quoted 44 lines
---
  hw/usb/hcd-ehci.c |   12 ++++++++++--
  1 files changed, 10 insertions(+), 2 deletions(-)
hw/usb/hcd-ehci.c +10 -2
index 2eeef29..b78bf44 100644
@@ -576,7 +576,12 @@ static inline void ehci_update_irq(EHCIState *s)
  /* flag interrupt condition */
  static inline void ehci_raise_irq(EHCIState *s, int intr)
  {
-    s->usbsts_pending |= intr;
+    if (intr & (USBSTS_PCD | USBSTS_FLR | USBSTS_HSE)) {
+        s->usbsts |= intr;
+        ehci_update_irq(s);
+    } else {
+        s->usbsts_pending |= intr;
+    }
  }
 
  /*
@@ -2480,7 +2485,8 @@ static int usb_ehci_post_load(void *opaque, int version_id)
 
  static const VMStateDescription vmstate_ehci = {
      .name        = "ehci",
-    .version_id  = 1,
+    .version_id  = 2,
+    .minimum_version_id  = 1,
      .pre_save    = usb_ehci_pre_save,
      .post_load   = usb_ehci_post_load,
      .fields      = (VMStateField[]) {
@@ -2488,6 +2494,8 @@ static const VMStateDescription vmstate_ehci = {
          /* mmio registers */
          VMSTATE_UINT32(usbcmd, EHCIState),
          VMSTATE_UINT32(usbsts, EHCIState),
+        VMSTATE_UINT32_V(usbsts_pending, EHCIState, 2),
+        VMSTATE_UINT32_V(usbsts_frindex, EHCIState, 2),
          VMSTATE_UINT32(usbintr, EHCIState),
          VMSTATE_UINT32(frindex, EHCIState),
          VMSTATE_UINT32(ctrldssegment, EHCIState),