Linux Samsung SOC development
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: Paul Zimmerman <Paul.Zimmerman@synopsys.com>,
	"balbi@ti.com" <balbi@ti.com>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-samsung-soc@vger.kernel.org"
	<linux-samsung-soc@vger.kernel.org>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Robert Baldyga <r.baldyga@samsung.com>,
	Krzysztof Kozlowski <k.kozlowski@samsung.com>
Subject: Re: [PATCH v4] usb: dwc2/gadget: rework disconnect event handling
Date: Mon, 17 Nov 2014 07:27:45 +0100	[thread overview]
Message-ID: <54699561.5040303@samsung.com> (raw)
In-Reply-To: <A2CA0424C0A6F04399FB9E1CD98E0304844EBDAB@US01WEMBX2.internal.synopsys.com>

Hello,

On 2014-11-14 23:09, Paul Zimmerman wrote:
>> From: Paul Zimmerman
>> Sent: Friday, November 14, 2014 1:21 PM
>>
>>> From: linux-usb-owner@vger.kernel.org [mailto:linux-usb-owner@vger.kernel.org] On Behalf Of Felipe Balbi
>>> Sent: Friday, November 14, 2014 11:05 AM
>>>
>>> On Fri, Nov 14, 2014 at 07:01:37PM +0000, Paul Zimmerman wrote:
>>>>> -----Original Message-----
>>>>> From: Marek Szyprowski [mailto:m.szyprowski@samsung.com]
>>>>> Sent: Friday, November 14, 2014 4:20 AM
>>>>>
>>>>> This patch adds a call to s3c_hsotg_disconnect() from 'end session'
>>>>> interrupt (GOTGINT_SES_END_DET) to correctly notify gadget subsystem
>>>>> about unplugged usb cable. DISCONNINT interrupt cannot be used for this
>>>>> purpose, because it is asserted only in host mode.
>>>>>
>>>>> To avoid reporting disconnect event more than once, a disconnect call has
>>>>> been moved from USB_REQ_SET_ADDRESS handling function to SESSREQINT
>>>>> interrupt. This way driver ensures that disconnect event is reported
>>>>> either when usb cable is unplugged or every time the host starts a new
>>>>> session.
>>>>>
>>>>> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
>>>>> ---
>>>>>   drivers/usb/dwc2/core.h   |  1 +
>>>>>   drivers/usb/dwc2/gadget.c | 13 +++++++++++--
>>>>>   2 files changed, 12 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
>>>>> index 55c90c53f2d6..78b9090ebf71 100644
>>>>> --- a/drivers/usb/dwc2/core.h
>>>>> +++ b/drivers/usb/dwc2/core.h
>>>>> @@ -210,6 +210,7 @@ struct s3c_hsotg {
>>>>>   	u8                      ctrl_buff[8];
>>>>>
>>>>>   	struct usb_gadget       gadget;
>>>>> +	unsigned int		session:1;
>>>>>   	unsigned int            setup;
>>>>>   	unsigned long           last_rst;
>>>>>   	struct s3c_hsotg_ep     *eps;
>>>>> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
>>>>> index fcd2bb55ccca..c7f68dc1cf6b 100644
>>>>> --- a/drivers/usb/dwc2/gadget.c
>>>>> +++ b/drivers/usb/dwc2/gadget.c
>>>>> @@ -1029,7 +1029,6 @@ static int s3c_hsotg_process_req_feature(struct s3c_hsotg *hsotg,
>>>>>   }
>>>>>
>>>>>   static void s3c_hsotg_enqueue_setup(struct s3c_hsotg *hsotg);
>>>>> -static void s3c_hsotg_disconnect(struct s3c_hsotg *hsotg);
>>>>>
>>>>>   /**
>>>>>    * s3c_hsotg_stall_ep0 - stall ep0
>>>>> @@ -1107,7 +1106,6 @@ static void s3c_hsotg_process_control(struct s3c_hsotg *hsotg,
>>>>>   	if ((ctrl->bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD) {
>>>>>   		switch (ctrl->bRequest) {
>>>>>   		case USB_REQ_SET_ADDRESS:
>>>>> -			s3c_hsotg_disconnect(hsotg);
>>>>>   			dcfg = readl(hsotg->regs + DCFG);
>>>>>   			dcfg &= ~DCFG_DEVADDR_MASK;
>>>>>   			dcfg |= (le16_to_cpu(ctrl->wValue) <<
>>>>> @@ -2031,6 +2029,10 @@ static void s3c_hsotg_disconnect(struct s3c_hsotg *hsotg)
>>>>>   {
>>>>>   	unsigned ep;
>>>>>
>>>>> +	if (!hsotg->session)
>>>>> +		return;
>>>>> +
>>>>> +	hsotg->session = 0;
>>>>>   	for (ep = 0; ep < hsotg->num_of_eps; ep++)
>>>>>   		kill_all_requests(hsotg, &hsotg->eps[ep], -ESHUTDOWN, true);
>>>>>
>>>>> @@ -2290,11 +2292,18 @@ irq_retry:
>>>>>   		dev_info(hsotg->dev, "OTGInt: %08x\n", otgint);
>>>>>
>>>>>   		writel(otgint, hsotg->regs + GOTGINT);
>>>>> +
>>>>> +		if (otgint & GOTGINT_SES_END_DET) {
>>>>> +			s3c_hsotg_disconnect(hsotg);
>>>> I think you should clear hsotg->session here, shouldn't you?
>>>> Otherwise I think s3c_hsotg_disconnect() will be called twice, once
>>>> here and once when the next GINTSTS_SESSREQINT comes.
>>> the best way to avoid that would be fiddle with hsotg->session inside
>>> s3c_hsotg_disconnect() only.
>> Whoops, I just noticed that hsotg->session *is* cleared inside of
>> s3c_hsotg_disconnect(). So I think the patch is good as-is.
>>
>> Acked-by: Paul Zimmerman <paulz@synopsys.com>
> I'm having second thoughts about this. Currently, the
> GINTSTS_SESSREQINT interrupt in the gadget does nothing except print
> a debug message. So I'm not sure that all versions of the controller
> actually assert this interrupt when a connection is made. If they
> don't, then this patch would break the disconnect handling, since
> hsotg->session would never get set.
>
> In particular, I'm thinking that a core which is synthesized without
> SRP support may not implement the GINTSTS_SESSREQINT interrupt. The
> databook seems to imply that:
>
> "SessReqInt: In Device mode, this interrupt is asserted when the
> utmisrp_bvalid signal goes high."
>
> And in the section which describes the utmisrp_bvalid signal, there is
> a note that says:
>
> "This interface is present only when parameter OTG_MODE specifies an
> SRP-capable configuration."
>
> So Marek, can you try moving the line which sets hsotg->session = 1
> into s3c_hsotg_irq_enumdone() instead? Then we will be sure it gets set
> to one after a connect. Probably it should be renamed from 'session'
> to 'connect' in that case.

Well... ok, but this will work exactly the same way as v3, which you were
not keen of. I think the best way will be to keep it set both in SESSREQINT
and enumdone, I will send a patch in a few minutes.

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland

  reply	other threads:[~2014-11-17  6:27 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-20 10:45 [PATCH v2 00/10] more dwc2/gadget fixes Marek Szyprowski
2014-10-20 10:45 ` [PATCH v2 01/10] usb: dwc2/gadget: report disconnect event from 'end session' irq Marek Szyprowski
     [not found]   ` <1413801940-31086-2-git-send-email-m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2014-10-25  1:23     ` Paul Zimmerman
     [not found]       ` <A2CA0424C0A6F04399FB9E1CD98E0304844E5C19-Yu2iAY70zvrYN67daEjeMPufCSb+aD3WLzEdoUbNIic@public.gmane.org>
2014-10-31  7:45         ` Marek Szyprowski
2014-10-31  8:04   ` [PATCH v3] " Marek Szyprowski
2014-10-31 18:15     ` Paul Zimmerman
2014-11-13 13:39       ` Marek Szyprowski
     [not found]         ` <5464B496.9010000-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2014-11-13 20:50           ` Paul Zimmerman
2014-11-14 10:31             ` Marek Szyprowski
2014-11-14 12:00             ` Marek Szyprowski
     [not found]               ` <5465EEF3.7060902-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2014-11-14 12:20                 ` [PATCH v4] usb: dwc2/gadget: rework disconnect event handling Marek Szyprowski
     [not found]                   ` <1415967607-6174-1-git-send-email-m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2014-11-14 19:01                     ` Paul Zimmerman
2014-11-14 19:04                       ` Felipe Balbi
2014-11-14 21:21                         ` Paul Zimmerman
2014-11-14 22:09                         ` Paul Zimmerman
2014-11-17  6:27                           ` Marek Szyprowski [this message]
2014-11-17  8:59                             ` [PATCH v5] " Marek Szyprowski
     [not found]                               ` <1416214782-13911-1-git-send-email-m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2014-11-18 20:56                                 ` Paul Zimmerman
2014-11-20 19:53                               ` Felipe Balbi
     [not found] ` <1413801940-31086-1-git-send-email-m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2014-10-20 10:45   ` [PATCH v2 02/10] usb: dwc2/gadget: fix enumeration issues Marek Szyprowski
     [not found]     ` <1413801940-31086-3-git-send-email-m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2014-10-25  0:21       ` Paul Zimmerman
2014-10-20 10:45   ` [PATCH v2 03/10] usb: dwc2/gadget: fix gadget unregistration in udc_stop() function Marek Szyprowski
     [not found]     ` <1413801940-31086-4-git-send-email-m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2014-10-23 15:01       ` Felipe Balbi
2014-10-23 18:18         ` Paul Zimmerman
     [not found]           ` <A2CA0424C0A6F04399FB9E1CD98E0304844E5483-Yu2iAY70zvrYN67daEjeMPufCSb+aD3WLzEdoUbNIic@public.gmane.org>
2014-10-23 18:56             ` Felipe Balbi
2014-10-20 10:45   ` [PATCH v2 04/10] usb: dwc2/gadget: disable phy before turning off power regulators Marek Szyprowski
     [not found]     ` <1413801940-31086-5-git-send-email-m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2014-10-23 15:01       ` Felipe Balbi
2014-10-23 18:15         ` Paul Zimmerman
2014-10-23 18:58           ` Felipe Balbi
2014-10-20 10:45   ` [PATCH v2 06/10] usb: dwc2/gadget: decouple setting soft-disconnect from s3c_hsotg_core_init Marek Szyprowski
2014-10-25  0:35     ` Paul Zimmerman
2014-10-27 13:52       ` Marek Szyprowski
2014-10-20 10:45   ` [PATCH v2 09/10] usb: dwc2/gadget: fix calls to phy control functions in suspend/resume code Marek Szyprowski
2014-10-25  0:45     ` Paul Zimmerman
2014-10-20 10:45   ` [PATCH v2 10/10] usb: dwc2/gadget: rework suspend/resume code to correctly restore gadget state Marek Szyprowski
2014-10-25  1:16     ` Paul Zimmerman
2014-10-27  7:18       ` Marek Szyprowski
2014-10-31 10:08         ` Marek Szyprowski
2014-10-31 10:12           ` [PATCH v3 1/2] usb: dwc2/gadget: add mutex to serialize init/deinit calls Marek Szyprowski
2014-10-31 10:12             ` [PATCH v3 2/2] usb: dwc2/gadget: rework suspend/resume code to correctly restore gadget state Marek Szyprowski
2014-10-31 18:46             ` [PATCH v3 1/2] usb: dwc2/gadget: add mutex to serialize init/deinit calls Paul Zimmerman
     [not found]               ` <A2CA0424C0A6F04399FB9E1CD98E0304844E7FDD-Yu2iAY70zvrYN67daEjeMPufCSb+aD3WLzEdoUbNIic@public.gmane.org>
2014-11-13 15:17                 ` Marek Szyprowski
2014-11-13 20:55                   ` Paul Zimmerman
2014-11-14  9:19                     ` Marek Szyprowski
2014-11-14 19:43                       ` Paul Zimmerman
2014-11-14 19:51                         ` Felipe Balbi
     [not found]             ` <1414750354-19571-1-git-send-email-m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2014-11-18 21:00               ` Paul Zimmerman
2014-11-20 19:53             ` Felipe Balbi
2014-10-20 10:45 ` [PATCH v2 05/10] usb: dwc2/gadget: move setting last reset time to s3c_hsotg_core_init Marek Szyprowski
     [not found]   ` <1413801940-31086-6-git-send-email-m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2014-10-25  0:23     ` Paul Zimmerman
2014-10-20 10:45 ` [PATCH v2 07/10] usb: dwc2/gadget: move phy control calls out of pullup() method Marek Szyprowski
2014-10-25  0:36   ` Paul Zimmerman
2014-10-20 10:45 ` [PATCH v2 08/10] usb: dwc2/gadget: use soft-disconnect udc feature in " Marek Szyprowski
2014-10-25  0:43   ` Paul Zimmerman

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=54699561.5040303@samsung.com \
    --to=m.szyprowski@samsung.com \
    --cc=Paul.Zimmerman@synopsys.com \
    --cc=balbi@ti.com \
    --cc=k.kozlowski@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=r.baldyga@samsung.com \
    /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