From: Felipe Balbi <balbi@kernel.org>
To: Wesley Cheng <wcheng@codeaurora.org>,
Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"jackp@codeaurora.org" <jackp@codeaurora.org>
Subject: Re: [PATCH v2] usb: dwc3: gadget: Avoid canceling current request for queuing error
Date: Thu, 06 May 2021 12:00:15 +0300 [thread overview]
Message-ID: <87r1ikgrts.fsf@kernel.org> (raw)
In-Reply-To: <49c5e3eb-7c2b-a83b-2406-a620d91b827a@codeaurora.org>
[-- Attachment #1: Type: text/plain, Size: 2389 bytes --]
Hi,
Wesley Cheng <wcheng@codeaurora.org> writes:
>> If I understood the whole thing correctly, we want everything except the
>> current request (the one that failed START or UPDATE transfer) to go
>> through giveback(). This really tells me that we're not handling error
>> case in kick_transfer and/or prepare_trbs() correctly.
>>
>
> We don't want the request passed in usb_ep_queue() to be calling
> giveback() IF DONE IN the usb_ep_queue() context only.
right, that's how this should behave.
>> I also don't want to pass another argument to kick_transfer because it
>> should be unnecessary: the current request should *always* be the last
>> one in the list. Therefore we should rely on something like
>> list_last_entry() followed by list_for_each_entry_safe_reverse() to
>> handle this without a special case.
>>
>> ret = dwc3_send_gadget_ep_cmd();
>> if (ret < 0) {
>> current = list_last_entry();
>>
>> unmap(current);
>> for_each_trb_in(current) {
>> clear_HWO(trb);
>> }
>>
>> list_for_entry_safe_reverse() {
>> move_cancelled();
>> }
>> }
>>
> Nice, thanks for the suggestion and info! Problem we have is that kick
> transfer is being used elsewhere, for example, during the TRB complete path:
>
> static bool dwc3_gadget_endpoint_trbs_complete(struct dwc3_ep *dep,
> const struct dwc3_event_depevt *event, int status)
> {
> ...
> else if (dwc3_gadget_ep_should_continue(dep))
> if (__dwc3_gadget_kick_transfer(dep) == 0)
> no_started_trb = false;
>
> So in these types of calls, we would still want ALL requests to be
> cancelled w/ giveback() called, so that the completion() callbacks can
> cleanup/free those requests accordingly.
>
> If we went and only unmapped the last entry (and removed it from any
> list), then no one would clean it up as it is outside of the
> usb_ep_queue() context, and not within any of the DWC3 lists.
oh, I see what you mean. At the moment we want kick_transfer to behave
in two different manners and that's probably where the bug is
originating from.
It sounds like it's time to split kick_transfer into
kick_queued_transfer() and e.g. continue_pending_transfers()
The thing is that if we continue to sprinkle special cases all over the
place, soon enough it'll be super hard to maintain the driver.
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 511 bytes --]
next prev parent reply other threads:[~2021-05-06 9:00 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-04 1:21 [PATCH v2] usb: dwc3: gadget: Avoid canceling current request for queuing error Wesley Cheng
2021-05-04 2:20 ` Thinh Nguyen
2021-05-04 2:45 ` Wesley Cheng
2021-05-04 3:12 ` Thinh Nguyen
2021-05-04 3:27 ` Wesley Cheng
2021-05-04 5:22 ` Thinh Nguyen
2021-05-04 8:24 ` Wesley Cheng
2021-05-05 1:50 ` Thinh Nguyen
2021-05-05 3:37 ` Wesley Cheng
2021-05-05 12:59 ` Felipe Balbi
2021-05-05 12:57 ` Felipe Balbi
2021-05-05 15:19 ` Alan Stern
2021-05-05 18:01 ` Wesley Cheng
2021-05-05 18:31 ` Thinh Nguyen
2021-05-05 18:46 ` Alan Stern
2021-05-06 9:04 ` Felipe Balbi
2021-05-06 18:06 ` Thinh Nguyen
2021-05-05 17:59 ` Wesley Cheng
2021-05-06 9:00 ` Felipe Balbi [this message]
2021-05-05 19:06 ` Thinh Nguyen
2021-05-05 12:50 ` Felipe Balbi
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=87r1ikgrts.fsf@kernel.org \
--to=balbi@kernel.org \
--cc=Thinh.Nguyen@synopsys.com \
--cc=gregkh@linuxfoundation.org \
--cc=jackp@codeaurora.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=wcheng@codeaurora.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.