From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HHhue-00032o-4I for qemu-devel@nongnu.org; Thu, 15 Feb 2007 09:48:44 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HHhua-00032c-Kn for qemu-devel@nongnu.org; Thu, 15 Feb 2007 09:48:42 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HHhua-00032Z-EI for qemu-devel@nongnu.org; Thu, 15 Feb 2007 09:48:40 -0500 Received: from ms-smtp-02.texas.rr.com ([24.93.47.41]) by monty-python.gnu.org with esmtp (Exim 4.52) id 1HHhuZ-0003aE-U8 for qemu-devel@nongnu.org; Thu, 15 Feb 2007 09:48:40 -0500 Received: from vaio (cpe-66-68-31-100.austin.res.rr.com [66.68.31.100]) by ms-smtp-02.texas.rr.com (8.13.6/8.13.6) with ESMTP id l1FEmbgr019518 for ; Thu, 15 Feb 2007 08:48:38 -0600 (CST) Subject: RE: [Qemu-devel] USB storage cannot be recognized on guest Linux domain? From: Lonnie Mendez In-Reply-To: References: Content-Type: multipart/mixed; boundary="=-9fUfiSpNFgJ0IWWF/TU/" Date: Thu, 15 Feb 2007 08:48:34 -0600 Message-Id: <1171550915.4091.52.camel@vaio> Mime-Version: 1.0 Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --=-9fUfiSpNFgJ0IWWF/TU/ Content-Type: text/plain Content-Transfer-Encoding: 7bit On Thu, 2007-02-15 at 15:44 +0800, Yu, Xiaoyang wrote: > Hi Lonnie, > > Thanks a lot for the information. > > In our use case, we do not know the USB disk information before it is plugged by customer, so we cannot start qemu with -usbdevice. > > For Linux, reload the uhci_hcd driver works. If we use this solution in our use case, then we need to issue an interrupt (maybe by pic_set_irq_new?) to the guest OS when QEMU detect a USB device is attached, and then the guest OS will reload the uhci_hcd driver. Is that right? Currently there is something wrong with the list archive server, so I haven't search out any example code from it :-( > > I found that there is a patch to add the UHCI suspend/resume support in the archive posted by you, but it cannot be applied to QEMU-DM 0.8.2 directly: > http://lists.gnu.org/archive/html/qemu-devel/2006-04/msg00576.html > > I wonder why there is no official UHCI suspend/resume support in QEMU. To reload the uhci_hcd driver seems to be only a work around. Sometimes it even cause kernel oops. > > I also wonder why the kernel 2.6.11-1.1369_FC4 can recognize USB storage without UHCI suspend/resume support. The attached patch is enough to have a device on linux recognized after usb_add. However, the device must be attached to the uhci controller's root hub. If a device is attached to an emulated usb hub device it will not be detected. --=-9fUfiSpNFgJ0IWWF/TU/ Content-Disposition: attachment; filename=qemu-uhci-resume.diff Content-Type: text/x-patch; name=qemu-uhci-resume.diff; charset=iso-8859-1 Content-Transfer-Encoding: 7bit ? qemu-uhci-resume.diff Index: hw/usb-uhci.c =================================================================== RCS file: /sources/qemu/qemu/hw/usb-uhci.c,v retrieving revision 1.13 diff -u -r1.13 usb-uhci.c --- hw/usb-uhci.c 17 Jan 2007 23:08:17 -0000 1.13 +++ hw/usb-uhci.c 15 Feb 2007 14:44:40 -0000 @@ -26,6 +26,8 @@ //#define DEBUG //#define DEBUG_PACKET +#define UHCI_CMD_FGR (1 << 4) +#define UHCI_CMD_EGSM (1 << 3) #define UHCI_CMD_GRESET (1 << 2) #define UHCI_CMD_HCRESET (1 << 1) #define UHCI_CMD_RS (1 << 0) @@ -327,6 +329,21 @@ return val; } +/* signal resume if controller suspended */ +static void uhci_resume (void *opaque) +{ + UHCIState *s = (UHCIState *)opaque; + + if (!s) + return; + + if (s->cmd & UHCI_CMD_EGSM) { + s->cmd |= UHCI_CMD_FGR; + s->status |= UHCI_STS_RD; + uhci_update_irq(s); + } +} + static void uhci_attach(USBPort *port1, USBDevice *dev) { UHCIState *s = port1->opaque; @@ -344,6 +361,9 @@ port->ctrl |= UHCI_PORT_LSDA; else port->ctrl &= ~UHCI_PORT_LSDA; + + uhci_resume(s); + port->port.dev = dev; /* send the attach message */ usb_send_msg(dev, USB_MSG_ATTACH); @@ -358,6 +378,9 @@ port->ctrl &= ~UHCI_PORT_EN; port->ctrl |= UHCI_PORT_ENC; } + + uhci_resume(s); + dev = port->port.dev; if (dev) { /* send the detach message */ --=-9fUfiSpNFgJ0IWWF/TU/--