From: Roger Quadros <rogerq@ti.com>
To: Peter Chen <peter.chen@freescale.com>
Cc: Li Jun <b47624@freescale.com>,
gregkh@linuxfoundation.org, balbi@ti.com,
stern@rowland.harvard.edu, dan.j.williams@intel.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 2/9] usb: gadget: add usb_gadget_start/stop()
Date: Fri, 20 Mar 2015 13:08:25 +0200 [thread overview]
Message-ID: <550BFFA9.7050400@ti.com> (raw)
In-Reply-To: <550BEC7F.8050303@ti.com>
On 20/03/15 11:46, Roger Quadros wrote:
> On 20/03/15 09:18, Peter Chen wrote:
>> On Thu, Mar 19, 2015 at 04:50:31PM +0200, Roger Quadros wrote:
>>> On 19/03/15 16:09, Li Jun wrote:
>>>> On Thu, Mar 19, 2015 at 12:14:39PM +0200, Roger Quadros wrote:
>>>>> On 19/03/15 05:30, Peter Chen wrote:
>>>>>> On Wed, Mar 18, 2015 at 03:55:56PM +0200, Roger Quadros wrote:
>>>>>>> The OTG state machine needs a mechanism to start and
>>>>>>> stop the gadget controller. Add usb_gadget_start()
>>>>>>> and usb_gadget_stop().
>>>>>>>
>>>>>>> Signed-off-by: Roger Quadros <rogerq@ti.com>
>>>>>>> ---
>>>>>>> drivers/usb/gadget/udc/udc-core.c | 166 +++++++++++++++++++++++++++++++++++---
>>>>>>> include/linux/usb/gadget.h | 3 +
>>>>>>> 2 files changed, 158 insertions(+), 11 deletions(-)
>>>>>>>
>>>>>>> diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c
>>>>>>> index 5a81cb0..69b4123 100644
>>>>>>> --- a/drivers/usb/gadget/udc/udc-core.c
>>>>>>> +++ b/drivers/usb/gadget/udc/udc-core.c
>>>>>>> @@ -35,6 +35,8 @@
>>>>>>> * @dev - the child device to the actual controller
>>>>>>> * @gadget - the gadget. For use by the class code
>>>>>>> * @list - for use by the udc class driver
>>>>>>> + * @running - udc is running
>>>>>>
>>>>>> Doesn't OTG FSM should know it?
>>>>>
>>>>> Not really, as the gadget driver might not have been loaded yet or userspace might
>>>>> have disabled softconnect when the OTG FSM wants UDC to start.
>>>>>
>>>>> So only UDC knows if it has really started or not based on this flag.
>>>>>
>>>>
>>>> why this can not be known by check the otg fsm state? i.e. if the device in
>>>> b_peripheral or a_peripheral state, udc should had started, isn't it?
>>>
>>> If gadget function driver (which is different from UDC driver) is not yet loaded
>>> then we can't start UDC even if otg fsm is in b_peripheral.
>>> Also, if userspace has disabled softconnect we can't start UDC.
>>>
>>> So, b_peripheral != UDC_started.
>>>
>>> I've tried to address this issue by adding the checks in usb_gadget_start().
>>>
>>
>> Ok, maybe we have different understanding for 'B-Device' at software,
>> In spec, it says the Micro-AB receptacle with nothing connected can be
>> 'B-Device', but in fact, we may not enable device mode before loading
>> gadget driver, in chipidea fsm design, if the gadget driver is not
>> loaded, the FSM will not start, and it is at OTG_STATE_UNDEFINED.
>
> Right. I mixed up into thinking that we should respect the softconnect
> while in OTG mode. It seems that we should ignore it.
>
>>
>> One more thing is we may need to find a place to issue SRP when we
>> load gadget driver, since we may at b_idle at that time due to host
>> closes the vbus (timeout for a_wait_bcon).
>
> Issuing SRP should be done by the otg-fsm and not udc-core.
> The udc-core can at the least call usb_otg_kick_fsm() after setting the gadget
> driver so that otg-fsm knows that we now have a valid gadget and can take
> necessary action. i.e. change from b_idle to b_srp_init and then to b_peripheral.
To clarify further. Is it right to assume that OTG FSM will not be started till
both gadget UDC driver _AND_ gadget function driver are loaded?
And it will be stopped when either of them unloads.
This simplifies things a lot.
cheers,
-roger
>
>>
>> What is the "softconnect" used for? In otg fsm, we use b_bus_req for FSM.
>>
> I understand now that we shouldn't bother with softconnect when we are in OTG fsm mode.
> That solves our problem with the running flags.
>
> So now, b_peripheral == UDC_started.
>
> I will address this in v2.
>
> cheers,
> -roger
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2015-03-20 11:08 UTC|newest]
Thread overview: 40+ 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 ` [RFC][PATCH 1/9] usb: hcd: Introduce usb_start/stop_hcd() Roger Quadros
[not found] ` <1426686963-11613-2-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2015-03-18 19:49 ` Alan Stern
[not found] ` <Pine.LNX.4.44L0.1503181538170.1497-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2015-03-18 21:41 ` Tony Lindgren
2015-03-19 1:51 ` Alan Stern
[not found] ` <Pine.LNX.4.44L0.1503182147410.32267-100000-pYrvlCTfrz9XsRXLowluHWD2FQJk+8+b@public.gmane.org>
2015-03-19 2:38 ` Tony Lindgren
2015-03-19 11:38 ` Roger Quadros
2015-03-19 14:17 ` Alan Stern
[not found] ` <550AB538.7090806-l0cyMroinI0@public.gmane.org>
2015-03-20 6:32 ` Peter Chen
2015-03-20 9:49 ` Roger Quadros
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
[not found] ` <1426686963-11613-3-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2015-03-19 3:30 ` Peter Chen
2015-03-19 10:14 ` Roger Quadros
[not found] ` <550AA18F.2000106-l0cyMroinI0@public.gmane.org>
2015-03-19 14:09 ` Li Jun
[not found] ` <20150319140859.GA7950-KgLukfWpBlCctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2015-03-19 14:50 ` Roger Quadros
2015-03-20 7:18 ` Peter Chen
2015-03-20 9:46 ` Roger Quadros
2015-03-20 11:08 ` Roger Quadros [this message]
[not found] ` <550BFFA9.7050400-l0cyMroinI0@public.gmane.org>
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-19 3:40 ` Peter Chen
2015-03-19 10:18 ` Roger Quadros
2015-03-20 7:45 ` Peter Chen
2015-03-20 9:18 ` Roger Quadros
2015-03-20 9:32 ` Peter Chen
[not found] ` <1426686963-11613-4-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2015-03-19 8:26 ` Li Jun
2015-03-19 10:30 ` Roger Quadros
[not found] ` <550AA556.1030301-l0cyMroinI0@public.gmane.org>
2015-03-19 14:41 ` Li Jun
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 ` [RFC][PATCH 5/9] usb: hcd: adapt to OTG Roger Quadros
2015-03-18 13:56 ` [RFC][PATCH 6/9] usb: gadget: udc: " Roger Quadros
2015-03-18 13:56 ` [RFC][PATCH 7/9] usb: dwc3: adapt to OTG core 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-19 3:46 ` Peter Chen
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 17:37 ` [RFC][PATCH 0/9] USB: OTG Core functionality Tony Lindgren
[not found] ` <20150318173726.GS31346-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
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=550BFFA9.7050400@ti.com \
--to=rogerq@ti.com \
--cc=b47624@freescale.com \
--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=stern@rowland.harvard.edu \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).