All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Xu Yang" <xu.yang_2@oss.nxp.com>
Cc: linux-usb@vger.kernel.org, imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH 2/2] usb: dwc3: imx8mp: set needs_full_reinit as true
Date: Fri, 06 Nov 2026 11:44:11 +0000	[thread overview]
Message-ID: <sashiko-outbox-201351@kernel.org> (raw)
In-Reply-To: <20261106111943.2868733-3-xu.yang_2@oss.nxp.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] usb: dwc3: imx8mp: bitfield race on needs_full_reinit in
  dwc3_imx8mp_probe()
--

commit f35ce9daa116e0df2a34cb6ec0a405a630719820
Author: Xu Yang <xu.yang_2@nxp.com>

usb: dwc3: imx8mp: set needs_full_reinit as true

This commit sets dwc3->needs_full_reinit in dwc3_imx8mp_probe() so that the
USB3 controller is re-initialized after system suspend on i.MX8MP.

> diff --git a/drivers/usb/dwc3/dwc3-imx8mp.c b/drivers/usb/dwc3/dwc3-imx8mp.c
> index ee92a5efaa6e8..78cb79fefba2c 100644
> --- a/drivers/usb/dwc3/dwc3-imx8mp.c
> +++ b/drivers/usb/dwc3/dwc3-imx8mp.c
> @@ -267,6 +267,7 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
>  	}
>  
>  	dwc3->glue_ops = &dwc3_imx_glue_ops;
> +	dwc3->needs_full_reinit = true;

[Severity: Medium]
Can setting dwc3->needs_full_reinit without holding dwc3->lock clobber
adjacent bitfields in struct dwc3?

needs_full_reinit is a 1-bit bitfield sharing a storage word with runtime
gadget flags:

drivers/usb/dwc3/core.h:struct dwc3 {
    ...
	unsigned		connected:1;
	unsigned		softconnect:1;
    ...
	unsigned		pending_events:1;
	unsigned		do_fifo_resize:1;
	unsigned		pullups_connected:1;
	unsigned		setup_packet_pending:1;
	unsigned		three_stage_setup:1;
    ...
	unsigned		needs_full_reinit:1;
};

Earlier in dwc3_imx8mp_probe(), of_platform_populate() synchronously runs
dwc3_probe() -> dwc3_core_probe() -> dwc3_core_init_mode().  In peripheral
mode, usb_add_gadget() registers the UDC, allowing a gadget driver to bind
and start the controller before of_platform_populate() returns:

CPU0                              CPU1
dwc3_imx8mp_probe()
  of_platform_populate()
    ...
      usb_add_gadget()
                                  gadget_bind_driver()
                                    ...
                                      dwc3_gadget_pullup()
                                        spin_lock_irqsave(&dwc->lock)
  /* RMW loads bitfield word */
                                        dwc3_gadget_soft_connect()
                                          dwc->pullups_connected = true;
                                        spin_unlock_irqrestore(&dwc->lock)
  dwc3->needs_full_reinit = true;
  /* RMW store overwrites pullups_connected */

Overwriting pullups_connected or adjacent EP0 and event flags can corrupt
EP0 state or cause dwc3_gadget_soft_disconnect() to see pullups_connected
as zero and skip halting the controller before suspend.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261106111943.2868733-1-xu.yang_2@oss.nxp.com?part=2

      reply	other threads:[~2026-11-06 11:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 11:19 [PATCH 0/2] usb: dwc3: recover USB3 link after controller power loss Xu Yang
2026-11-06 11:19 ` [PATCH 1/2] usb: dwc3: wait for the port to leave RxDetect before xHCI reset Xu Yang
2026-11-06 11:36   ` sashiko-bot
2026-11-06 11:19 ` [PATCH 2/2] usb: dwc3: imx8mp: set needs_full_reinit as true Xu Yang
2026-11-06 11:44   ` sashiko-bot [this message]

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-201351@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=linux-usb@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=xu.yang_2@oss.nxp.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.