From: Alan Stern <stern@rowland.harvard.edu> To: Roger Quadros <rogerq@ti.com> Cc: gregkh@linuxfoundation.org, <balbi@ti.com>, <dan.j.williams@intel.com>, <peter.chen@freescale.com>, <jun.li@freescale.com>, <mathias.nyman@linux.intel.com>, <linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-omap@vger.kernel.org> Subject: Re: [RFC][PATCH 1/9] usb: hcd: Introduce usb_start/stop_hcd() Date: Wed, 18 Mar 2015 15:49:08 -0400 (EDT) [thread overview] Message-ID: <Pine.LNX.4.44L0.1503181538170.1497-100000@iolanthe.rowland.org> (raw) In-Reply-To: <1426686963-11613-2-git-send-email-rogerq@ti.com> On Wed, 18 Mar 2015, Roger Quadros wrote: > To support OTG we want a mechanism to start and stop > the HCD from the OTG state machine. Add usb_start_hcd() > and usb_stop_hcd(). > > Signed-off-by: Roger Quadros <rogerq@ti.com> There are a few problems in this proposed patch. > +int usb_start_hcd(struct usb_hcd *hcd) > +{ > + int retval; > + struct usb_device *rhdev = hcd->self.root_hub; > + > + if (hcd->state != HC_STATE_HALT) { > + dev_err(hcd->self.controller, "not starting a running HCD\n"); > + return -EINVAL; > + } > + > + hcd->state = HC_STATE_RUNNING; > + retval = hcd->driver->start(hcd); > + if (retval < 0) { > + dev_err(hcd->self.controller, "startup error %d\n", retval); > + hcd->state = HC_STATE_HALT; > + return retval; > + } > + > + /* starting here, usbcore will pay attention to this root hub */ > + if ((retval = register_root_hub(hcd)) != 0) > + goto err_register_root_hub; If the host controller is started more than once, you will end up unregistering and re-registering the root hub. The device core does not allow this. Once a device has been unregistered, you must not try to register it again -- you have to allocate a new device and register it instead. Also, although you call the driver's ->start method multiple times, the ->reset method is called only once, when the controller is first probed. It's not clear that this will work in a situation where the HC and the UDC share hardware state; after the UDC is stopped it may be necessary to reset the HC before it can run again. It might be possible to make this work, but I suspect quite a few drivers would need rewriting first. As another example of the problems you face, consider how stopping a host controller will interact with the driver's PM support (both system suspend and runtime suspend). It would be a lot simpler to unbind the host controller driver completely when switching to device mode and rebind it when switching back. I guess that is the sort of heavy-duty approach you want to avoid, but it may be the only practical way forward. Alan Stern
WARNING: multiple messages have this Message-ID (diff)
From: Alan Stern <stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org> To: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org> Cc: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org, balbi-l0cyMroinI0@public.gmane.org, dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org, jun.li-KZfg59tc24xl57MIdRCFDg@public.gmane.org, mathias.nyman-VuQAYsv1563Yd54FQh9/CA@public.gmane.org, linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Subject: Re: [RFC][PATCH 1/9] usb: hcd: Introduce usb_start/stop_hcd() Date: Wed, 18 Mar 2015 15:49:08 -0400 (EDT) [thread overview] Message-ID: <Pine.LNX.4.44L0.1503181538170.1497-100000@iolanthe.rowland.org> (raw) In-Reply-To: <1426686963-11613-2-git-send-email-rogerq-l0cyMroinI0@public.gmane.org> On Wed, 18 Mar 2015, Roger Quadros wrote: > To support OTG we want a mechanism to start and stop > the HCD from the OTG state machine. Add usb_start_hcd() > and usb_stop_hcd(). > > Signed-off-by: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org> There are a few problems in this proposed patch. > +int usb_start_hcd(struct usb_hcd *hcd) > +{ > + int retval; > + struct usb_device *rhdev = hcd->self.root_hub; > + > + if (hcd->state != HC_STATE_HALT) { > + dev_err(hcd->self.controller, "not starting a running HCD\n"); > + return -EINVAL; > + } > + > + hcd->state = HC_STATE_RUNNING; > + retval = hcd->driver->start(hcd); > + if (retval < 0) { > + dev_err(hcd->self.controller, "startup error %d\n", retval); > + hcd->state = HC_STATE_HALT; > + return retval; > + } > + > + /* starting here, usbcore will pay attention to this root hub */ > + if ((retval = register_root_hub(hcd)) != 0) > + goto err_register_root_hub; If the host controller is started more than once, you will end up unregistering and re-registering the root hub. The device core does not allow this. Once a device has been unregistered, you must not try to register it again -- you have to allocate a new device and register it instead. Also, although you call the driver's ->start method multiple times, the ->reset method is called only once, when the controller is first probed. It's not clear that this will work in a situation where the HC and the UDC share hardware state; after the UDC is stopped it may be necessary to reset the HC before it can run again. It might be possible to make this work, but I suspect quite a few drivers would need rewriting first. As another example of the problems you face, consider how stopping a host controller will interact with the driver's PM support (both system suspend and runtime suspend). It would be a lot simpler to unbind the host controller driver completely when switching to device mode and rebind it when switching back. I guess that is the sort of heavy-duty approach you want to avoid, but it may be the only practical way forward. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-03-18 19:49 UTC|newest] Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-03-18 13:55 [RFC][PATCH 0/9] USB: OTG Core functionality Roger Quadros 2015-03-18 13:55 ` Roger Quadros 2015-03-18 13:55 ` [RFC][PATCH 1/9] usb: hcd: Introduce usb_start/stop_hcd() Roger Quadros 2015-03-18 13:55 ` Roger Quadros 2015-03-18 19:49 ` Alan Stern [this message] 2015-03-18 19:49 ` Alan Stern 2015-03-18 21:41 ` Tony Lindgren 2015-03-18 21:41 ` Tony Lindgren 2015-03-19 1:51 ` Alan Stern 2015-03-19 1:51 ` Alan Stern 2015-03-19 2:38 ` Tony Lindgren 2015-03-19 2:38 ` Tony Lindgren 2015-03-19 11:38 ` Roger Quadros 2015-03-19 11:38 ` Roger Quadros 2015-03-19 14:17 ` Alan Stern 2015-03-19 14:17 ` Alan Stern 2015-03-20 6:32 ` Peter Chen 2015-03-20 6:32 ` Peter Chen 2015-03-20 9:49 ` Roger Quadros 2015-03-20 9:49 ` Roger Quadros 2015-03-19 1:46 ` Peter Chen 2015-03-19 1:46 ` Peter Chen 2015-03-18 13:55 ` [RFC][PATCH 2/9] usb: gadget: add usb_gadget_start/stop() Roger Quadros 2015-03-18 13:55 ` Roger Quadros 2015-03-19 3:30 ` Peter Chen 2015-03-19 3:30 ` Peter Chen 2015-03-19 10:14 ` Roger Quadros 2015-03-19 10:14 ` Roger Quadros 2015-03-19 14:09 ` Li Jun 2015-03-19 14:09 ` Li Jun 2015-03-19 14:50 ` Roger Quadros 2015-03-19 14:50 ` Roger Quadros 2015-03-20 7:18 ` Peter Chen 2015-03-20 7:18 ` Peter Chen 2015-03-20 9:46 ` Roger Quadros 2015-03-20 9:46 ` Roger Quadros 2015-03-20 11:08 ` Roger Quadros 2015-03-20 11:08 ` Roger Quadros 2015-03-21 1:30 ` Peter Chen 2015-03-21 1:30 ` Peter Chen 2015-03-18 13:55 ` [RFC][PATCH 3/9] usb: otg: add OTG core Roger Quadros 2015-03-18 13:55 ` Roger Quadros 2015-03-19 3:40 ` Peter Chen 2015-03-19 3:40 ` Peter Chen 2015-03-19 10:18 ` Roger Quadros 2015-03-19 10:18 ` Roger Quadros 2015-03-20 7:45 ` Peter Chen 2015-03-20 7:45 ` Peter Chen 2015-03-20 9:18 ` Roger Quadros 2015-03-20 9:18 ` Roger Quadros 2015-03-20 9:32 ` Peter Chen 2015-03-19 8:26 ` Li Jun 2015-03-19 8:26 ` Li Jun 2015-03-19 10:30 ` Roger Quadros 2015-03-19 10:30 ` Roger Quadros 2015-03-19 14:41 ` Li Jun 2015-03-19 14:41 ` Li Jun 2015-03-19 14:54 ` Roger Quadros 2015-03-19 14:54 ` Roger Quadros 2015-03-18 13:55 ` [RFC][PATCH 4/9] usb: otg: hub: Notify OTG fsm when A device sets b_hnp_enable Roger Quadros 2015-03-18 13:55 ` Roger Quadros 2015-03-18 13:55 ` [RFC][PATCH 5/9] usb: hcd: adapt to OTG Roger Quadros 2015-03-18 13:55 ` Roger Quadros 2015-03-18 13:56 ` [RFC][PATCH 6/9] usb: gadget: udc: " Roger Quadros 2015-03-18 13:56 ` Roger Quadros 2015-03-18 13:56 ` [RFC][PATCH 7/9] usb: dwc3: adapt to OTG core Roger Quadros 2015-03-18 13:56 ` Roger Quadros 2015-03-18 13:56 ` [RFC][PATCH 8/9] usb: otg-fsm: Remove unused members in struct otg_fsm Roger Quadros 2015-03-18 13:56 ` Roger Quadros 2015-03-19 3:46 ` Peter Chen 2015-03-19 3:46 ` Peter Chen 2015-03-19 10:20 ` Roger Quadros 2015-03-19 10:20 ` Roger Quadros 2015-03-18 13:56 ` [RFC][PATCH 9/9] usb: otg-fsm: Add documentation for " Roger Quadros 2015-03-18 13:56 ` Roger Quadros 2015-03-18 17:37 ` [RFC][PATCH 0/9] USB: OTG Core functionality Tony Lindgren 2015-03-19 10:31 ` Roger Quadros 2015-03-19 10:31 ` Roger Quadros
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=Pine.LNX.4.44L0.1503181538170.1497-100000@iolanthe.rowland.org \ --to=stern@rowland.harvard.edu \ --cc=balbi@ti.com \ --cc=dan.j.williams@intel.com \ --cc=gregkh@linuxfoundation.org \ --cc=jun.li@freescale.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-omap@vger.kernel.org \ --cc=linux-usb@vger.kernel.org \ --cc=mathias.nyman@linux.intel.com \ --cc=peter.chen@freescale.com \ --cc=rogerq@ti.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.