linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@kernel.org>
To: Sriharsha Allenki <sallenki@codeaurora.org>
Cc: "linux-usb\@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"gregkh\@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	Manu Gautam <mgautam@codeaurora.org>,
	Jack Pham <jackp@codeaurora.org>
Subject: Re: Fwd: [DWC3][Gadget] Question regarding the unmapping of request as part of queue failure
Date: Sat, 28 Mar 2020 10:34:13 +0200	[thread overview]
Message-ID: <87369skhdm.fsf@kernel.org> (raw)
In-Reply-To: <53a4614f-d1bc-5856-8e01-eb790a6ff7fe@codeaurora.org>

[-- Attachment #1: Type: text/plain, Size: 1564 bytes --]


Hi,

Sriharsha Allenki <sallenki@codeaurora.org> writes:
> I was looking at the code flow for ep_queue and came across the
> following piece of code.
>
> __dwc3_gadget_kick_transfer {
>  
>     dwc3_prepare_trbs(dep);
>     req = next_request(&dep->started_list);
>     if (!req) {
>             dep->flags |= DWC3_EP_PENDING_REQUEST;
>             return 0;
>     }
> }
>
> As part of dwc3_prepare_trbs(dep), we get a request from the pending_list
> and queue to the tail of the started_list. But here we get the head of
> the started_list, now if there is any failure in issuing UPDATE_TRANSFER
> to the core, we unmap this request using "dwc3_gadget_del_and_unmap_request".
>
> But if this kick_transfer was part of the ep_queue and we have failed
> to issue update transfer, instead of unmapping the request we are trying
> to queue, we will be unmapping a different request (first in the started_list)
> which the core could have already started processing. I believe we should unmap
> the request we are trying to queue but not any other.

no, we have to start requests in order and dequeue them in order as
well. There's no way to verify that the request is already processed by
the HW, other than checking HWO bit which is set during
dwc3_prepare_trbs(). This is a HW-SW race condition that we can't really
fix.

It is minimized, however, by the fact that, at least for non-isoc
endpoints, we use No Status Update Transfer commands, which means the
command can't fail.

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2020-03-28  8:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <0105a5cd-936e-fb08-77bf-c2f1dbf0aeed@codeaurora.org>
2020-03-26  6:10 ` Fwd: [DWC3][Gadget] Question regarding the unmapping of request as part of queue failure Sriharsha Allenki
2020-03-28  8:34   ` Felipe Balbi [this message]
2020-04-01 13:26     ` Sriharsha Allenki
2020-04-02  9:53       ` 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=87369skhdm.fsf@kernel.org \
    --to=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jackp@codeaurora.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mgautam@codeaurora.org \
    --cc=sallenki@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 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).