From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-bl2on0126.outbound.protection.outlook.com ([65.55.169.126]:33130 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932350AbbJVBpl (ORCPT ); Wed, 21 Oct 2015 21:45:41 -0400 Date: Thu, 22 Oct 2015 09:44:24 +0800 From: Peter Chen To: Jiada Wang CC: , Li Jun , Li Jun , Subject: Re: [PATCH 1/1] usb: chipidea: otg: gadget module load and unload support Message-ID: <20151022014423.GB5624@shlinux2> References: <1445397800-19980-1-git-send-email-peter.chen@freescale.com> <562839B1.9030703@mentor.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <562839B1.9030703@mentor.com> Sender: stable-owner@vger.kernel.org List-ID: On Thu, Oct 22, 2015 at 10:19:45AM +0900, Jiada Wang wrote: > Hello > > > On 10/21/2015 12:23 PM, Peter Chen wrote: > >From: Li Jun > > > >This patch is to support load and unload gadget driver in full OTG mode. > > > >Signed-off-by: Li Jun > >Signed-off-by: Peter Chen > >Cc: Jiada Wang > >(Peter: it fixes a bug that the unload/reload gadget driver can't work > > well at OTG FSM mode) > >Cc: #v4.0+ > >--- > > drivers/usb/chipidea/udc.c | 17 +++++++++++++++++ > > 1 file changed, 17 insertions(+) > > > >diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c > >index e19d8b8..67cfa04 100644 > >--- a/drivers/usb/chipidea/udc.c > >+++ b/drivers/usb/chipidea/udc.c > >@@ -1755,6 +1755,22 @@ static int ci_udc_start(struct usb_gadget *gadget, > > return retval; > > } > > > >+static void ci_udc_stop_for_otg_fsm(struct ci_hdrc *ci) > >+{ > >+ if (!ci_otg_is_fsm_mode(ci)) > >+ return; > >+ > >+ mutex_lock(&ci->fsm.lock); > >+ if (ci->fsm.otg->state == OTG_STATE_A_PERIPHERAL) { > >+ ci->fsm.a_bidl_adis_tmout = 1; > >+ ci_hdrc_otg_fsm_start(ci); > >+ } else if (ci->fsm.otg->state == OTG_STATE_B_PERIPHERAL) { > >+ ci->fsm.protocol = PROTO_UNDEF; > >+ ci->fsm.otg->state = OTG_STATE_UNDEFINED; > >+ } > >+ mutex_unlock(&ci->fsm.lock); > >+} > >+ > > /** > > * ci_udc_stop: unregister a gadget driver > > */ > >@@ -1779,6 +1795,7 @@ static int ci_udc_stop(struct usb_gadget *gadget) > > ci->driver = NULL; > > spin_unlock_irqrestore(&ci->lock, flags); > > > >+ ci_udc_stop_for_otg_fsm(ci); > > return 0; > > } > > > > > I have confirmed this patch resolves my issue with gadget module load/unload > please feel free to add my Tested-by > Thanks, I had tested it before I sent, it fixed the problem. Since I have already added tag for it, I can't add your tested-by. -- Best Regards, Peter Chen