* [Qemu-devel] [PATCH] hw/usb-ohci.c: Fix handling of remote wakeup corner cases
@ 2011-06-15 17:22 Peter Maydell
2011-06-16 13:37 ` Gerd Hoffmann
0 siblings, 1 reply; 2+ messages in thread
From: Peter Maydell @ 2011-06-15 17:22 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, patches
Correct a number of minor errors in the OHCI wakeup implementation:
* when the port is suspended but the controller is not, raise RHSC
* when the controller is suspended but the port is not, raise RD
* when the controller is suspended, move it to resume state
These fix some edge cases where a USB device might not successfully get
the attention of the guest OS if it tried to do so at the wrong time.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
Fixed version of ohci_wakeup(), as promised...
hw/usb-ohci.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/hw/usb-ohci.c b/hw/usb-ohci.c
index 832dcd6..755abcb 100644
--- a/hw/usb-ohci.c
+++ b/hw/usb-ohci.c
@@ -373,14 +373,25 @@ static void ohci_wakeup(USBDevice *dev)
OHCIState *s = container_of(bus, OHCIState, bus);
int portnum = dev->port->index;
OHCIPort *port = &s->rhport[portnum];
+ uint32_t intr = 0;
if (port->ctrl & OHCI_PORT_PSS) {
DPRINTF("usb-ohci: port %d: wakeup\n", portnum);
port->ctrl |= OHCI_PORT_PSSC;
port->ctrl &= ~OHCI_PORT_PSS;
- if ((s->ctl & OHCI_CTL_HCFS) == OHCI_USB_SUSPEND) {
- ohci_set_interrupt(s, OHCI_INTR_RD);
- }
+ intr = OHCI_INTR_RHSC;
+ }
+ /* Note that the controller can be suspended even if this port is not */
+ if ((s->ctl & OHCI_CTL_HCFS) == OHCI_USB_SUSPEND) {
+ DPRINTF("usb-ohci: remote-wakeup: SUSPEND->RESUME\n");
+ /* This is the one state transition the controller can do by itself */
+ s->ctl &= ~OHCI_CTL_HCFS;
+ s->ctl |= OHCI_USB_RESUME;
+ /* In suspend mode only ResumeDetected is possible, not RHSC:
+ * see the OHCI spec 5.1.2.3.
+ */
+ intr = OHCI_INTR_RD;
}
+ ohci_set_interrupt(s, intr);
}
/* Reset the controller */
--
1.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/usb-ohci.c: Fix handling of remote wakeup corner cases
2011-06-15 17:22 [Qemu-devel] [PATCH] hw/usb-ohci.c: Fix handling of remote wakeup corner cases Peter Maydell
@ 2011-06-16 13:37 ` Gerd Hoffmann
0 siblings, 0 replies; 2+ messages in thread
From: Gerd Hoffmann @ 2011-06-16 13:37 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel, patches
On 06/15/11 19:22, Peter Maydell wrote:
> Correct a number of minor errors in the OHCI wakeup implementation:
> * when the port is suspended but the controller is not, raise RHSC
> * when the controller is suspended but the port is not, raise RD
> * when the controller is suspended, move it to resume state
>
> These fix some edge cases where a USB device might not successfully get
> the attention of the guest OS if it tried to do so at the wrong time.
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
Patch applied.
thanks,
Gerd
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-06-16 13:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-15 17:22 [Qemu-devel] [PATCH] hw/usb-ohci.c: Fix handling of remote wakeup corner cases Peter Maydell
2011-06-16 13:37 ` Gerd Hoffmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).