stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] usb: chipidea: otg: gadget module load and unload support
@ 2015-10-21  3:23 Peter Chen
  2015-10-22  1:19 ` Jiada Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Chen @ 2015-10-21  3:23 UTC (permalink / raw)
  To: linux-usb; +Cc: Li Jun, Li Jun, Peter Chen, Jiada Wang, stable

From: Li Jun <B47624@freescale.com>

This patch is to support load and unload gadget driver in full OTG mode.

Signed-off-by: Li Jun <jun.li@freescale.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Cc: Jiada Wang <jiada_wang@mentor.com>
(Peter: it fixes a bug that the unload/reload gadget driver can't work
 well at OTG FSM mode)
Cc: <stable@vger.kernel.org> #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;
 }
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] usb: chipidea: otg: gadget module load and unload support
  2015-10-21  3:23 [PATCH 1/1] usb: chipidea: otg: gadget module load and unload support Peter Chen
@ 2015-10-22  1:19 ` Jiada Wang
  2015-10-22  1:44   ` Peter Chen
  0 siblings, 1 reply; 3+ messages in thread
From: Jiada Wang @ 2015-10-22  1:19 UTC (permalink / raw)
  To: Peter Chen, linux-usb; +Cc: Li Jun, Li Jun, stable

Hello


On 10/21/2015 12:23 PM, Peter Chen wrote:
> From: Li Jun <B47624@freescale.com>
>
> This patch is to support load and unload gadget driver in full OTG mode.
>
> Signed-off-by: Li Jun <jun.li@freescale.com>
> Signed-off-by: Peter Chen <peter.chen@freescale.com>
> Cc: Jiada Wang <jiada_wang@mentor.com>
> (Peter: it fixes a bug that the unload/reload gadget driver can't work
>   well at OTG FSM mode)
> Cc: <stable@vger.kernel.org> #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,
Jiada

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] usb: chipidea: otg: gadget module load and unload support
  2015-10-22  1:19 ` Jiada Wang
@ 2015-10-22  1:44   ` Peter Chen
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Chen @ 2015-10-22  1:44 UTC (permalink / raw)
  To: Jiada Wang; +Cc: linux-usb, Li Jun, Li Jun, stable

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 <B47624@freescale.com>
> >
> >This patch is to support load and unload gadget driver in full OTG mode.
> >
> >Signed-off-by: Li Jun <jun.li@freescale.com>
> >Signed-off-by: Peter Chen <peter.chen@freescale.com>
> >Cc: Jiada Wang <jiada_wang@mentor.com>
> >(Peter: it fixes a bug that the unload/reload gadget driver can't work
> >  well at OTG FSM mode)
> >Cc: <stable@vger.kernel.org> #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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-22  1:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-21  3:23 [PATCH 1/1] usb: chipidea: otg: gadget module load and unload support Peter Chen
2015-10-22  1:19 ` Jiada Wang
2015-10-22  1:44   ` Peter Chen

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).