Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1251267 > unrolled thread

[PATCH] usb: chipidea: udc: clear vbus_active flag in udc_stop

Started byJiada Wang <jiada_wang@mentor.com>
First post2015-10-20 04:40 +0200
Last post2015-10-20 08:40 +0200
Articles 3 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] usb: chipidea: udc: clear vbus_active flag in udc_stop Jiada Wang <jiada_wang@mentor.com> - 2015-10-20 04:40 +0200
    Re: [PATCH] usb: chipidea: udc: clear vbus_active flag in udc_stop Jiada Wang <jiada_wang@mentor.com> - 2015-10-20 08:20 +0200
      Re: [PATCH] usb: chipidea: udc: clear vbus_active flag in udc_stop Jiada Wang <jiada_wang@mentor.com> - 2015-10-20 08:40 +0200

#1251267 — [PATCH] usb: chipidea: udc: clear vbus_active flag in udc_stop

FromJiada Wang <jiada_wang@mentor.com>
Date2015-10-20 04:40 +0200
Subject[PATCH] usb: chipidea: udc: clear vbus_active flag in udc_stop
Message-ID<qlv0d-70J-1@gated-at.bofh.it>
Currently in udc_stop, if vbus_active flag is true, all USB activities
will be stopped, but vbus_active flag is still left to be true,
this causes issue, when afterwards driver tries to connect gadget
device to host, But due to the uncleared vbus_active, some necessary
setup steps are skipped.

This patch clears vbus_active flag in udc_stop callback.

Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
---
 drivers/usb/chipidea/udc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 8223fe7..b9ac228 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1762,6 +1762,7 @@ static int ci_udc_stop(struct usb_gadget *gadget)
 	spin_lock_irqsave(&ci->lock, flags);
 
 	if (ci->vbus_active) {
+		ci->vbus_active = 0;
 		hw_device_state(ci, 0);
 		if (ci->platdata->notify_event)
 			ci->platdata->notify_event(ci,
-- 
2.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1251305

FromJiada Wang <jiada_wang@mentor.com>
Date2015-10-20 08:20 +0200
Message-ID<qlyr7-3CX-3@gated-at.bofh.it>
In reply to#1251267
Hi

On 10/20/2015 03:01 PM, Peter Chen wrote:
> On Tue, Oct 20, 2015 at 11:29:18AM +0900, Jiada Wang wrote:
>> Currently in udc_stop, if vbus_active flag is true, all USB activities
>> will be stopped, but vbus_active flag is still left to be true,
>> this causes issue, when afterwards driver tries to connect gadget
>> device to host, But due to the uncleared vbus_active, some necessary
>> setup steps are skipped.
>>
>> This patch clears vbus_active flag in udc_stop callback.
>>
>> Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
>> ---
>>   drivers/usb/chipidea/udc.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
>> index 8223fe7..b9ac228 100644
>> --- a/drivers/usb/chipidea/udc.c
>> +++ b/drivers/usb/chipidea/udc.c
>> @@ -1762,6 +1762,7 @@ static int ci_udc_stop(struct usb_gadget *gadget)
>>   	spin_lock_irqsave(&ci->lock, flags);
>>
>>   	if (ci->vbus_active) {
>> +		ci->vbus_active = 0;
>>   		hw_device_state(ci, 0);
>>   		if (ci->platdata->notify_event)
>>   			ci->platdata->notify_event(ci,
>> --
>> 2.4.5
>>
>
> This flag will be handled by vbus interrupt, would you please explain
> more what problem you have met?
the actual issue I had is,
build kernel with USB_OTG_FSM enabled,
keep usb cable plugged,
load/unload USB gadget module (for example I tried g_zero or g_serial),
after unload gadget module once, then the status of vbus_active is not
correct,
this causes host machine failed to detect gadget device when later
gadget device module is loaded again.


Thanks,
Jiada
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1251309

FromJiada Wang <jiada_wang@mentor.com>
Date2015-10-20 08:40 +0200
Message-ID<qlyKt-410-11@gated-at.bofh.it>
In reply to#1251305
Hi

On 10/20/2015 03:28 PM, Peter Chen wrote:
> On Tue, Oct 20, 2015 at 03:09:02PM +0900, Jiada Wang wrote:
>> Hi
>>
>> On 10/20/2015 03:01 PM, Peter Chen wrote:
>>> On Tue, Oct 20, 2015 at 11:29:18AM +0900, Jiada Wang wrote:
>>>> Currently in udc_stop, if vbus_active flag is true, all USB activities
>>>> will be stopped, but vbus_active flag is still left to be true,
>>>> this causes issue, when afterwards driver tries to connect gadget
>>>> device to host, But due to the uncleared vbus_active, some necessary
>>>> setup steps are skipped.
>>>>
>>>> This patch clears vbus_active flag in udc_stop callback.
>>>>
>>>> Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
>>>> ---
>>>>   drivers/usb/chipidea/udc.c | 1 +
>>>>   1 file changed, 1 insertion(+)
>>>>
>>>> diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
>>>> index 8223fe7..b9ac228 100644
>>>> --- a/drivers/usb/chipidea/udc.c
>>>> +++ b/drivers/usb/chipidea/udc.c
>>>> @@ -1762,6 +1762,7 @@ static int ci_udc_stop(struct usb_gadget *gadget)
>>>>   	spin_lock_irqsave(&ci->lock, flags);
>>>>
>>>>   	if (ci->vbus_active) {
>>>> +		ci->vbus_active = 0;
>>>>   		hw_device_state(ci, 0);
>>>>   		if (ci->platdata->notify_event)
>>>>   			ci->platdata->notify_event(ci,
>>>> --
>>>> 2.4.5
>>>>
>>>
>>> This flag will be handled by vbus interrupt, would you please explain
>>> more what problem you have met?
>> the actual issue I had is,
>> build kernel with USB_OTG_FSM enabled,
>> keep usb cable plugged,
>> load/unload USB gadget module (for example I tried g_zero or g_serial),
>> after unload gadget module once, then the status of vbus_active is not
>> correct,
>> this causes host machine failed to detect gadget device when later
>> gadget device module is loaded again.
>>
>>
>
> ci->vbus_active is only used at non-fsm mode, would you please try below
> fix?
>
> usb: chipidea: otg: gadget module load and unload support
>
> This patch is to support load and unload gadget driver in full OTG mode.
>
> Acked-by: Peter Chen <peter.chen@freescale.com>
> Signed-off-by: Li Jun <jun.li@freescale.com>
> ---
>   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 will test with this patch and come back with the result,
has this patch been submitted to community?

Thanks,
Jiada
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web