mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexandre Bailon <abailon@baylibre.com>
To: hminas@synopsys.com
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Alexandre Bailon <abailon@baylibre.com>
Subject: [RFC PATCH 0/1] DWC2 DMA issue
Date: Wed, 26 Jul 2023 12:22:51 +0200	[thread overview]
Message-ID: <20230726102252.2236314-1-abailon@baylibre.com> (raw)

For context, I am trying to reduce latency of UAC2 gadget
and one way to achieve it is to reduce the number of USB requests.
The SoC on the board I use (vim3l) use a DWC2 IP.
If I enable the UAC2 gadget with 3 requests, every ms I get data from isocronous
in endpoint and everything works fine (I can listen what come from the interface)
But if use only two requests, then, what I listen is hugly!
What I noticed is that after two sucessful USB transfer, I get a ZLP.

I suspect that happens because in dwc2_gadget_fill_isoc_desc, we may update
the DMA descriptor whereas it is already owned by the DMA.
On completion of a request, the gadget queue the request that has been completed.
The DWC2 driver clear DEV_DMA_L bit of last descriptor and add a new descriptor to DMA.
In that way, we never stop DMA and keep the endpoint enabled while we are
feeding it with data.

If we use three or more request when we start the gadget, the DMA has three descriptors
and when queue a new one, DMA is processing descriptor L-1, the driver update descriptor L
and the descriptor L+1.

But when we only have two requests, the DMA has only two requests and when we queue
the request on completion, DMA is processing descriptor L, the driver update it and add
the descriptor L+1. Instead of using the new descriptor, the DMA raise a BNA interrupt,
the controller send a ZLP to host and the driver re-initialize the endpoint to prepare
the next transfers.

The patch try to fix it. I am not conviced so far this is the best fix so
I am open to any suggestion.

Alexandre Bailon (1):
  usb: dwc2: Don't set DEV_DMA_L by default for isoc transfer

 drivers/usb/dwc2/gadget.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

-- 
2.41.0


             reply	other threads:[~2023-07-26 10:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-26 10:22 Alexandre Bailon [this message]
2023-07-26 10:22 ` [RFC PATCH 1/1] usb: dwc2: Don't set DEV_DMA_L by default for isoc transfer Alexandre Bailon

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=20230726102252.2236314-1-abailon@baylibre.com \
    --to=abailon@baylibre.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hminas@synopsys.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.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

all inboxes | Powered by JetHome®