From: Felipe Balbi <balbi@kernel.org>
To: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
linux-usb@vger.kernel.org
Cc: John Youn <John.Youn@synopsys.com>
Subject: Re: [PATCH 4/5] usb: dwc3: gadget: Handle transfer completion
Date: Wed, 29 Apr 2020 10:48:16 +0300 [thread overview]
Message-ID: <87blna20n3.fsf@kernel.org> (raw)
In-Reply-To: <70555c2202529c6e0bdd23124003d0d4bc637cdc.1588025916.git.thinhn@synopsys.com>
[-- Attachment #1: Type: text/plain, Size: 4687 bytes --]
Hi,
Thinh Nguyen <Thinh.Nguyen@synopsys.com> writes:
> With the new usb_request->is_last field, now the function drivers can
> inform which request is the end of a transfer, dwc3 can program its TRBs
> to let the controller know when to free its resources when a transfer
> completes. This is required for stream transfers. The controller needs
> to know where one stream starts and ends to properly allocate resources
> for different streams.
>
> Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
from a quick read, it looks like this can be broken down into smaller
patches.
> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> index 7204a838ec06..b11183a715a7 100644
> --- a/drivers/usb/dwc3/core.h
> +++ b/drivers/usb/dwc3/core.h
> @@ -701,6 +701,7 @@ struct dwc3_ep {
> #define DWC3_EP_END_TRANSFER_PENDING BIT(4)
> #define DWC3_EP_PENDING_REQUEST BIT(5)
> #define DWC3_EP_DELAY_START BIT(6)
> +#define DWC3_EP_WAIT_TRANSFER_COMPLETE BIT(7)
this could be its own patch with proper description (and usage)
>
> /* This last one is specific to EP0 */
> #define DWC3_EP0_DIR_IN BIT(31)
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 865e6fbb7360..628f9d142876 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -579,6 +579,7 @@ static int dwc3_gadget_set_ep_config(struct dwc3_ep *dep, unsigned int action)
>
> if (usb_ss_max_streams(comp_desc) && usb_endpoint_xfer_bulk(desc)) {
> params.param1 |= DWC3_DEPCFG_STREAM_CAPABLE
> + | DWC3_DEPCFG_XFER_COMPLETE_EN
adding this bit for stream endpoints could be a separate commit.
> | DWC3_DEPCFG_STREAM_EVENT_EN;
> dep->stream_capable = true;
> }
> @@ -917,8 +918,9 @@ static u32 dwc3_calc_trbs_left(struct dwc3_ep *dep)
> }
>
> static void __dwc3_prepare_one_trb(struct dwc3_ep *dep, struct dwc3_trb *trb,
> - dma_addr_t dma, unsigned length, unsigned chain, unsigned node,
> - unsigned stream_id, unsigned short_not_ok, unsigned no_interrupt)
> + dma_addr_t dma, unsigned length, unsigned chain,
> + unsigned is_last, unsigned node, unsigned stream_id,
> + unsigned short_not_ok, unsigned no_interrupt)
if you add "is_last" as the last argument, this hunk will look
smaller. Nitpicking, I know.
> @@ -1223,6 +1231,10 @@ static void dwc3_prepare_trbs(struct dwc3_ep *dep)
>
> if (!dwc3_calc_trbs_left(dep))
> return;
> +
> + /* Don't prepare ahead. This is not an option for DWC_usb32. */
> + if (req->request.is_last)
> + return;
this requires some better description. Why isn't it an option for dwc_usb32?
> @@ -2648,37 +2666,22 @@ static bool dwc3_gadget_ep_should_continue(struct dwc3_ep *dep)
> return !dwc3_gadget_ep_request_completed(req);
> }
>
> -static void dwc3_gadget_endpoint_frame_from_event(struct dwc3_ep *dep,
> - const struct dwc3_event_depevt *event)
> -{
> - dep->frame_number = event->parameters;
> -}
moving these functions around could be a separate patch. The way it's
done now takes away from review.
> @@ -2704,6 +2707,45 @@ static void dwc3_gadget_endpoint_transfer_in_progress(struct dwc3_ep *dep,
>
> dwc->u1u2 = 0;
> }
> +
> + return no_started_trb;
> +}
> +
> +static void dwc3_gadget_endpoint_frame_from_event(struct dwc3_ep *dep,
> + const struct dwc3_event_depevt *event)
> +{
> + dep->frame_number = event->parameters;
> +}
> +
> +static void dwc3_gadget_endpoint_transfer_in_progress(struct dwc3_ep *dep,
> + const struct dwc3_event_depevt *event)
> +{
> + int status = 0;
> +
> + if (usb_endpoint_xfer_isoc(dep->endpoint.desc))
> + dwc3_gadget_endpoint_frame_from_event(dep, event);
> +
> + if (event->status & DEPEVT_STATUS_BUSERR)
> + status = -ECONNRESET;
> +
> + if (event->status & DEPEVT_STATUS_MISSED_ISOC)
> + status = -EXDEV;
> +
> + dwc3_gadget_endpoint_trbs_complete(dep, event, status);
> +}
> +
> +static void dwc3_gadget_endpoint_transfer_complete(struct dwc3_ep *dep,
> + const struct dwc3_event_depevt *event)
> +{
> + int status = 0;
> +
> + dep->flags &= ~DWC3_EP_TRANSFER_STARTED;
> +
> + if (event->status & DEPEVT_STATUS_BUSERR)
> + status = -ECONNRESET;
> +
> + if (dwc3_gadget_endpoint_trbs_complete(dep, event, status))
> + dep->flags &= ~DWC3_EP_WAIT_TRANSFER_COMPLETE;
> }
>
> static void dwc3_gadget_endpoint_transfer_not_ready(struct dwc3_ep *dep,
> @@ -2770,7 +2812,10 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc,
> }
> break;
> case DWC3_DEPEVT_STREAMEVT:
> + break;
Swap these around. Keep all the "nothing to do here" cases
together.
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
next prev parent reply other threads:[~2020-04-29 7:48 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-27 22:27 [PATCH 0/5] usb: dwc3: gadget: Handle streams Thinh Nguyen
2020-04-27 22:27 ` [PATCH 1/5] usb: gadget: Introduce usb_request->is_last field Thinh Nguyen
2020-04-29 3:15 ` Peter Chen
2020-04-30 1:00 ` Thinh Nguyen
2020-04-30 3:57 ` Peter Chen
2020-04-30 4:54 ` Thinh Nguyen
2020-04-30 14:21 ` Alan Stern
2020-04-30 17:17 ` Thinh Nguyen
2020-04-30 18:22 ` Alan Stern
2020-04-30 18:36 ` Thinh Nguyen
2020-04-27 22:27 ` [PATCH 2/5] usb: gadget: f_tcm: Inform last transfer request Thinh Nguyen
2020-04-27 22:27 ` [PATCH 3/5] usb: dwc3: gadget: Continue to process pending requests Thinh Nguyen
2020-04-27 22:27 ` [PATCH 4/5] usb: dwc3: gadget: Handle transfer completion Thinh Nguyen
2020-04-29 7:48 ` Felipe Balbi [this message]
2020-04-30 1:16 ` Thinh Nguyen
2020-05-14 10:38 ` Felipe Balbi
2020-05-15 1:23 ` Thinh Nguyen
2020-04-27 22:28 ` [PATCH 5/5] usb: dwc3: gadget: Handle stream transfers Thinh Nguyen
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=87blna20n3.fsf@kernel.org \
--to=balbi@kernel.org \
--cc=John.Youn@synopsys.com \
--cc=Thinh.Nguyen@synopsys.com \
--cc=gregkh@linuxfoundation.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;
as well as URLs for NNTP newsgroup(s).