From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752623AbbCUBbp (ORCPT ); Fri, 20 Mar 2015 21:31:45 -0400 Received: from mail-bl2on0105.outbound.protection.outlook.com ([65.55.169.105]:53662 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752245AbbCUBbm (ORCPT ); Fri, 20 Mar 2015 21:31:42 -0400 Date: Sat, 21 Mar 2015 09:30:32 +0800 From: Peter Chen To: Roger Quadros CC: Li Jun , , , , , , , , , Subject: Re: [RFC][PATCH 2/9] usb: gadget: add usb_gadget_start/stop() Message-ID: <20150321013031.GC19849@shlinux2> References: <1426686963-11613-1-git-send-email-rogerq@ti.com> <1426686963-11613-3-git-send-email-rogerq@ti.com> <20150319032944.GA2476@shlinux2> <550AA18F.2000106@ti.com> <20150319140859.GA7950@shlinux1.ap.freescale.net> <550AE237.8000404@ti.com> <20150320071818.GF7537@shlinux2> <550BEC7F.8050303@ti.com> <550BFFA9.7050400@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <550BFFA9.7050400@ti.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-EOPAttributedMessage: 0 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=peter.chen@freescale.com; vger.kernel.org; dkim=none (message not signed) header.d=none; X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;BMV:1;SFV:NSPM;SFS:(10019020)(6009001)(339900001)(479174004)(199003)(189002)(51704005)(24454002)(46406003)(6806004)(47776003)(87936001)(33656002)(77156002)(19580395003)(19580405001)(86362001)(85426001)(92566002)(97756001)(23726002)(62966003)(54356999)(15975445007)(93886004)(50466002)(104016003)(106466001)(33716001)(77096005)(110136001)(46102003)(105606002)(76176999)(2950100001)(83506001)(50986999);DIR:OUT;SFP:1102;SCL:1;SRVR:BN3PR0301MB1219;H:az84smr01.freescale.net;FPR:;SPF:Fail;MLV:sfv;A:1;MX:1;LANG:en; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0301MB1219;UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0301MB1282; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5002010)(5005006);SRVR:BN3PR0301MB1219;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0301MB1219; X-Forefront-PRVS: 05220145DE X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2015 01:31:37.2886 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0301MB1219 X-OriginatorOrg: freescale.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 20, 2015 at 01:08:25PM +0200, Roger Quadros wrote: > 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 > >>>>>>> --- > >>>>>>> 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. Yes, you are right. > > 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 > > > -- Best Regards, Peter Chen