All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Michal Nazarewicz <mina86@mina86.com>, linux-usb@vger.kernel.org
Subject: usb: gadget: ffs: Let setup() return USB_GADGET_DELAYED_STATUS
Date: Fri, 12 Jan 2018 13:26:15 +0200	[thread overview]
Message-ID: <87po6fwc6g.fsf@linux.intel.com> (raw)

Hi,

Lars-Peter Clausen <lars@metafoo.de> writes:
> Some UDC drivers (like the DWC3) expect that the response to a setup()

not some, but *all*. You can only queue a response later IFF you return
USB_GADGET_DELAYED_STATUS.

> request is queued from within the setup function itself so that it is
> available as soon as setup() has completed.
>
> Upon receiving a setup request the function fs driver creates an event that
> is made available to userspace. And only once userspace has acknowledged
> that event the response to the setup request is queued.
>
> So it violates the requirement of those UDC drivers and random failures can
> be observed. This is basically a race condition and if userspace is able to
> read the event and queue the response fast enough all is good. But if it is
> not, for example because other processes are currently scheduled to run,
> the USB host that sent the setup request will observe an error.
>
> To avoid this the gadget framework provides the USB_GADGET_DELAYED_STATUS
> return code. If a setup() callback returns this value the UDC driver is
> aware that response is not yet available and can uses the appropriate
> methods to handle this case.
>
> Since in the case of function fs the response will never be available when
> the setup() function returns make sure that this status code is used.
>
> This fixed random occasional failures that were previously observed on a
> DWC3 based system under high system load.

I need to see tracepoint capture from the failure ;-) Care to send them
to me for analysis?

             reply	other threads:[~2018-01-12 11:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-12 11:26 Felipe Balbi [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-01-12 14:10 usb: gadget: ffs: Let setup() return USB_GADGET_DELAYED_STATUS Lars-Peter Clausen
2018-01-12 12:01 Felipe Balbi
2018-01-12 11:41 Lars-Peter Clausen
2018-01-12 10:26 Lars-Peter Clausen

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=87po6fwc6g.fsf@linux.intel.com \
    --to=balbi@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-usb@vger.kernel.org \
    --cc=mina86@mina86.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 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.