lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87eg4g43eg.fsf@linux.intel.com>
Date:   Mon, 19 Sep 2016 12:58:31 +0300
From:   Felipe Balbi <balbi@...nel.org>
To:     Baolin Wang <baolin.wang@...aro.org>
Cc:     Greg KH <gregkh@...uxfoundation.org>,
        Mark Brown <broonie@...nel.org>,
        USB <linux-usb@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 2/2] usb: dwc3: Wait for control tranfer completed when stopping gadget


Hi,

Baolin Wang <baolin.wang@...aro.org> writes:
>>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>>> index 1a33308..c9026ce 100644
>>> --- a/drivers/usb/dwc3/gadget.c
>>> +++ b/drivers/usb/dwc3/gadget.c
>>> @@ -1441,6 +1441,15 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend)
>>>       if (pm_runtime_suspended(dwc->dev))
>>>               return 0;
>>>
>>> +     /*
>>> +      * Per databook, when we want to stop the gadget, if a control transfer
>>> +      * is still in process, complete it and get the core into setup phase.
>>> +      */
>>> +     if (!is_on && dwc->ep0state != EP0_SETUP_PHASE) {
>>> +             reinit_completion(&dwc->ep0_completed);
>>
>> this seems unnecessary to me. Also, why return here so the caller has to
>
> We should re-init the completion due to it will complete control
> transfer many times before we try to stop gadget.

not sure I get this comment, care to furter explain what you mean?

>> wait? You could just have called wait_for_completion() here straight
>> away:
>>
>>         if (!is_on && dwc->ep0state != EP0_SETUP_PHASE) {
>>                 /* should this be interruptible? */
>>                 ret = wait_for_completion_timeout(&dwc->ep0_in_setup,
>>                                 msecs_to_jiffies(500));
>>                 if (ret == 0) {
>>                         dwc3_trace(trace_dwc3_gadget, "RUN/STOP timeout");
>>                         return -ETIMEDOUT;
>>                 }
>>         }
>>
>> There's also no need for that "try_again" trickery. We either can halt
>> the controller within 500ms or we cannot.
>
> But this is in atomic context and we can not issue
> wait_for_completion_timeout() in atomic context, then we should just
> return here.

heh, good point. Missed that :-)

-- 
balbi

Download attachment "signature.asc" of type "application/pgp-signature" (801 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ