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 v8 2/6] usb: gadget: udc: crg: Add hardware definitions and structs
Date: Fri, 04 Dec 2026 01:53:01 +0000 [thread overview]
Message-ID: <sashiko-outbox-248917@kernel.org> (raw)
In-Reply-To: <20261203-axiado-ax3000-usb-device-controller-v8-2-d5ff04febd4d@axiado.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] usb: gadget: crg: TRB tracepoints leak stale tail bytes and
format eagerly
- [Medium] usb: gadget: crg: crg_udc_ep_clear_enabled() directly mutates
usb_ep.enabled
- [Low] usb: gadget: crg: commit message omits tracepoints, debug
helpers, MAINTAINERS
--
commit d339b40b5ba3f303546cd716f68ba74376410e20
Author: Petar Stepanovic <pstepanovic@axiado.com>
> usb: gadget: udc: crg: Add hardware definitions and structs
>
> This patch introduces the hardware definitions, register offsets, and
> fundamental data structures for the Axiado AX3000/AX3005 USB Device
> Controller driver.
>
> Co-developed-by: Krutik Shah <krutikshah@axiado.com>
> Signed-off-by: Krutik Shah <krutikshah@axiado.com>
> Co-developed-by: Naveen Kumar Rajgiri Bassappa <rbnaveenkumar@axiado.com>
> Signed-off-by: Naveen Kumar Rajgiri Bassappa <rbnaveenkumar@axiado.com>
> Co-developed-by: Tzu-Hao Wei <twei@axiado.com>
> Signed-off-by: Tzu-Hao Wei <twei@axiado.com>
> Signed-off-by: Petar Stepanovic <pstepanovic@axiado.com>
[Severity: Low]
This patch also adds the ftrace tracepoints in crg-udc-trace.h, the debug
decode helpers in crg-udc-debug.h, and the MAINTAINERS entry, none of which
are mentioned in the commit message. Could the changelog mention those
additions as well?
[ ... ]
> diff --git a/drivers/usb/gadget/udc/crg/crg-udc-trace.h b/drivers/usb/gadget/udc/crg/crg-udc-trace.h
> new file mode 100644
> index 0000000000000..672a719a041bb
> --- /dev/null
> +++ b/drivers/usb/gadget/udc/crg/crg-udc-trace.h
[ ... ]
> +DECLARE_EVENT_CLASS(
> + crg_udc_log_trb,
> + TP_PROTO(struct crg_udc_ep *udc_ep, struct crg_transfer_trb *trb),
> + TP_ARGS(udc_ep, trb),
> + TP_STRUCT__entry(__string(name, udc_ep->usb_ep.name)
> + __field(struct crg_transfer_trb *, trb)
> + __dynamic_array(char, decoded,
> + CRG_MSG_MAX)),
> + TP_fast_assign(__assign_str(name); __entry->trb = trb;
> + crg_udc_decode_trb(__get_dynamic_array(decoded),
> + CRG_MSG_MAX, trb);),
> + TP_printk("%s: trb %p, %s", __get_str(name), __entry->trb,
> + __get_str(decoded)));
> +
> +DEFINE_EVENT(crg_udc_log_trb, crg_udc_queue_trb,
> + TP_PROTO(struct crg_udc_ep *udc_ep, struct crg_transfer_trb *trb),
> + TP_ARGS(udc_ep, trb));
> +
> +TRACE_EVENT(
> + crg_udc_event_trb, TP_PROTO(struct crg_event_trb *trb), TP_ARGS(trb),
> + TP_STRUCT__entry(__field(struct crg_event_trb *, trb)
> + __dynamic_array(char, decoded, CRG_MSG_MAX)),
> + TP_fast_assign(__entry->trb = trb;
> + crg_udc_decode_event_trb(__get_dynamic_array(decoded),
> + CRG_MSG_MAX, trb);),
> + TP_printk("trb %p, %s", __entry->trb, __get_str(decoded)));
[Severity: Medium]
Do crg_udc_log_trb and crg_udc_event_trb leak stale tail bytes into raw
trace records?
Both events reserve a 200-byte dynamic array and fill only a short
NUL-terminated prefix via scnprintf() in TP_fast_assign(). Neither
perf_trace_buf_alloc() nor ftrace zeroes the event body, so the trailing
bytes expose stale prior tracepoint data to raw readers like trace_pipe_raw.
Calling scnprintf() in TP_fast_assign() also adds formatting overhead on
the hot enqueue and IRQ paths, bloats each record to 200 bytes instead of
8, and prevents numeric filtering.
Since crg_udc_decode_trb() and crg_udc_decode_event_trb() only read dw2
and dw3, recording those two u32 fields and decoding in TP_printk() with
__get_buf(CRG_MSG_MAX), as crg_udc_portsc does, would avoid both issues.
[ ... ]
> diff --git a/drivers/usb/gadget/udc/crg/crg-udc.h b/drivers/usb/gadget/udc/crg/crg-udc.h
> new file mode 100644
> index 0000000000000..d6cc8641be28d
> --- /dev/null
> +++ b/drivers/usb/gadget/udc/crg/crg-udc.h
[ ... ]
> +/* Keep usb_ep_disable() in the driver until the last giveback returns. */
> +static inline void crg_udc_ep_clear_enabled(struct crg_udc_ep *ep)
> +{
> + if (ep->nuking)
> + ep->clear_enabled_on_nuke = true;
> + else
> + ep->usb_ep.enabled = false;
> +}
[Severity: Medium]
Should crg_udc_ep_clear_enabled() be clearing ep->usb_ep.enabled directly?
struct usb_ep.enabled is owned by the gadget core in udc/core.c. Clearing
it inside the UDC driver makes later usb_ep_disable() calls return early
without invoking ep->ops->disable(), and causes functions like f_ecm to
skip teardown such as gether_disconnect() in ecm_disable() and leak requests.
Writing ep->usb_ep.enabled under udc_lock also races with usb_ep_enable()
and usb_ep_disable(), which access ep->enabled without udc_lock. Tracking
driver endpoint state in a private field of struct crg_udc_ep instead
would leave ep->usb_ep.enabled owned by the gadget core.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-axiado-ax3000-usb-device-controller-v8-0-d5ff04febd4d@axiado.com?part=2
next prev parent reply other threads:[~2026-12-04 1:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 1:31 [PATCH v8 0/6] Axiado AX3000 and AX3005 USB Device Controller (UDC) Petar Stepanovic
2026-12-04 1:31 ` [PATCH v8 1/6] dt-bindings: usb: gadget: udc: add Axiado AX3000 and AX3005 UDC Petar Stepanovic
2026-12-04 1:31 ` [PATCH v8 2/6] usb: gadget: udc: crg: Add hardware definitions and structs Petar Stepanovic
2026-12-04 1:53 ` sashiko-bot [this message]
2026-12-04 1:31 ` [PATCH v8 3/6] usb: gadget: udc: crg: Add ring and transfer management Petar Stepanovic
2026-12-04 1:53 ` sashiko-bot
2026-12-04 1:31 ` [PATCH v8 4/6] usb: gadget: udc: crg: Add endpoint 0 handling Petar Stepanovic
2026-12-04 2:03 ` sashiko-bot
2026-12-04 1:31 ` [PATCH v8 5/6] usb: gadget: udc: crg: Add gadget and endpoint operations Petar Stepanovic
2026-12-04 2:03 ` sashiko-bot
2026-12-04 1:31 ` [PATCH v8 6/6] usb: gadget: udc: crg: Add core driver and build integration Petar Stepanovic
2026-12-04 2:07 ` sashiko-bot
2026-12-04 2:07 ` [PATCH v8 0/6] Axiado AX3000 and AX3005 USB Device Controller (UDC) 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-248917@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.