From: sashiko-bot@kernel.org
To: "Petar Stepanovic" <pstepanovic@axiado.com>
Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v5 3/6] usb: gadget: udc: crg: Add ring and transfer management
Date: Mon, 16 Nov 2026 19:46:37 +0000 [thread overview]
Message-ID: <sashiko-outbox-217601@kernel.org> (raw)
In-Reply-To: <20261116-axiado-ax3000-usb-device-controller-v5-3-49271ed5c793@axiado.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] usb: gadget: udc: crg: missing session check in
crg_udc_queue_pending_trbs()
--
commit 4959c938e3393a398d380564ec6cf72791b96459
Author: Petar Stepanovic <pstepanovic@axiado.com>
usb: gadget: udc: crg: Add ring and transfer management
This patch adds event ring initialization, event processing, and transfer
ring TRB management for the Axiado AX3000/AX3005 UDC driver.
> diff --git a/drivers/usb/gadget/udc/crg/crg-udc-ring.c b/drivers/usb/gadget/udc/crg/crg-udc-ring.c
> new file mode 100644
> index 0000000000000..348d2b611a332
> --- /dev/null
> +++ b/drivers/usb/gadget/udc/crg/crg-udc-ring.c
[ ... ]
> +int crg_udc_queue_pending_trbs(struct crg_udc_ep *udc_ep_ptr)
> +{
> + struct crg_udc_request *req;
> + struct crg_gadget_dev *crg_udc = udc_ep_ptr->crg_udc;
> + u32 generation = crg_udc->udc_event[0].generation;
> + u32 ep_generation = udc_ep_ptr->generation;
> + int ret;
> +
> +restart:
> + /* A giveback can reset/disable the endpoint while udc_lock is dropped. */
> + if (crg_udc->resetting || crg_udc->port_reset_pending ||
> + crg_udc->endpoint_recovery_pending ||
> + !udc_ep_ptr->desc || udc_ep_ptr->halt_failed || udc_ep_ptr->nuking ||
> + udc_ep_ptr->ep_state != EP_STATE_RUNNING)
> + return 0;
> +
> + list_for_each_entry(req, &udc_ep_ptr->queue, queue) {
> + if (req->all_trbs_queued)
> + continue;
> +
> + /* A large request must finish its current TD before the next
> + * TD (or the next USB request) can be submitted: the event
> + * handler uses all_trbs_queued to complete the USB request.
> + */
> + if (req->td_pending)
> + return 0;
> +
> + ret = crg_udc_build_td(udc_ep_ptr, req);
> + if (ret == -ENOSPC || ret == -EBUSY)
> + return ret;
> + if (ret) {
> + dev_err(crg_udc->dev,
> + "failed to build pending transfer: %d\n", ret);
> + /* Giveback removes req and drops udc_lock: callbacks can
> + * remove or free every saved request-list iterator.
> + */
> + crg_udc_req_done(udc_ep_ptr, req, ret);
> + if (generation != crg_udc->udc_event[0].generation ||
> + ep_generation != udc_ep_ptr->generation)
> + return 0;
> + goto restart;
> + }
[Severity: Medium]
Can crg_udc_queue_pending_trbs() publish TRBs and ring the doorbell after a
concurrent suspend or teardown has stopped the controller?
When crg_udc_req_done() drops udc_lock (either inside this loop or in a
caller right before invoking crg_udc_queue_pending_trbs()), another context
can stop the session before controller reset runs:
CPU0 CPU1
crg_udc_handle_xfer_event()
crg_udc_req_done()
spin_unlock(&crg_udc->udc_lock)
crg_udc_suspend()
crg_udc->suspended = true;
crg_udc_set_pullup(..., false)
/* clears CRG_U3DC_CTRL_RUN */
spin_unlock(&crg_udc->udc_lock)
synchronize_irq()
spin_lock(&crg_udc->udc_lock)
crg_udc_queue_pending_trbs()
crg_udc_build_td() <-- publishes TRBs and rings doorbell
During this window, crg_udc->resetting is still false, generations have not
changed, and data endpoints remain in EP_STATE_RUNNING, so the check at
restart passes even though crg_udc_session_ready(crg_udc) is false.
Checking !crg_udc_session_ready(crg_udc) at restart would prevent queueing
TRBs once the session is no longer ready.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116-axiado-ax3000-usb-device-controller-v5-0-49271ed5c793@axiado.com?part=3
next prev parent reply other threads:[~2026-11-16 19:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 19:06 [PATCH v5 0/6] Axiado AX3000 and AX3005 USB Device Controller (UDC) Petar Stepanovic
2026-11-16 19:06 ` [PATCH v5 1/6] dt-bindings: usb: gadget: udc: add Axiado AX3000 and AX3005 UDC Petar Stepanovic
2026-11-16 19:12 ` sashiko-bot
2026-11-16 19:06 ` [PATCH v5 2/6] usb: gadget: udc: crg: Add hardware definitions and structs Petar Stepanovic
2026-11-16 19:24 ` sashiko-bot
2026-11-16 19:06 ` [PATCH v5 3/6] usb: gadget: udc: crg: Add ring and transfer management Petar Stepanovic
2026-11-16 19:46 ` sashiko-bot [this message]
2026-11-16 19:06 ` [PATCH v5 4/6] usb: gadget: udc: crg: Add endpoint 0 handling Petar Stepanovic
2026-11-16 20:16 ` sashiko-bot
2026-11-16 19:06 ` [PATCH v5 5/6] usb: gadget: udc: crg: Add gadget and endpoint operations Petar Stepanovic
2026-11-16 20:47 ` sashiko-bot
2026-11-16 19:06 ` [PATCH v5 6/6] usb: gadget: udc: crg: Add core driver and build integration Petar Stepanovic
2026-11-16 21:15 ` sashiko-bot
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=sashiko-outbox-217601@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=pstepanovic@axiado.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.