From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Roy Luo <royluo@google.com>
Cc: "mathias.nyman@intel.com" <mathias.nyman@intel.com>,
"quic_ugoswami@quicinc.com" <quic_ugoswami@quicinc.com>,
Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] xhci: Add a quirk for full reset on removal
Date: Thu, 15 May 2025 23:42:50 +0000 [thread overview]
Message-ID: <20250515234244.tpqp375x77jh53fl@synopsys.com> (raw)
In-Reply-To: <20250515185227.1507363-2-royluo@google.com>
On Thu, May 15, 2025, Roy Luo wrote:
> Commit 6ccb83d6c497 ("usb: xhci: Implement xhci_handshake_check_state()
> helper") introduced an optimization to xhci_reset() during xhci removal,
> allowing it to bail out early without waiting for the reset to complete.
>
> This behavior can cause issues on SNPS DWC3 USB controller with dual-role
> capability. When the DWC3 controller exits host mode and removes xhci
> while a reset is still in progress, and then tries to configure its
> hardware for device mode, the ongoing reset leads to register access
> issues; specifically, all register reads returns 0. These issues extend
> beyond the xhci register space (which is expected during a reset) and
> affect the entire DWC3 IP block, causing the DWC3 device mode to
> malfunction.
>
> To address this, introduce the `XHCI_FULL_RESET_ON_REMOVE` quirk. When this
> quirk is set, xhci_reset() always completes its reset handshake, ensuring
> the controller is in a fully reset state before proceeding.
>
> Cc: stable@vger.kernel.org
> Fixes: 6ccb83d6c497 ("usb: xhci: Implement xhci_handshake_check_state() helper")
> Signed-off-by: Roy Luo <royluo@google.com>
> ---
> drivers/usb/host/xhci-plat.c | 3 +++
> drivers/usb/host/xhci.c | 8 +++++++-
> drivers/usb/host/xhci.h | 1 +
> 3 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index 3155e3a842da..19c5c26a8e63 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -265,6 +265,9 @@ int xhci_plat_probe(struct platform_device *pdev, struct device *sysdev, const s
> if (device_property_read_bool(tmpdev, "xhci-skip-phy-init-quirk"))
> xhci->quirks |= XHCI_SKIP_PHY_INIT;
>
> + if (device_property_read_bool(tmpdev, "xhci-full-reset-on-remove-quirk"))
> + xhci->quirks |= XHCI_FULL_RESET_ON_REMOVE;
> +
> device_property_read_u32(tmpdev, "imod-interval-ns",
> &xhci->imod_interval);
> }
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index 90eb491267b5..4f091d618c01 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -198,6 +198,7 @@ int xhci_reset(struct xhci_hcd *xhci, u64 timeout_us)
> u32 command;
> u32 state;
> int ret;
> + unsigned int exit_state;
>
> state = readl(&xhci->op_regs->status);
>
> @@ -226,8 +227,13 @@ int xhci_reset(struct xhci_hcd *xhci, u64 timeout_us)
> if (xhci->quirks & XHCI_INTEL_HOST)
> udelay(1000);
>
> + if (xhci->quirks & XHCI_FULL_RESET_ON_REMOVE)
> + exit_state = 0;
There's no state 0. Checking against that is odd. Couldn't we just use
xhci_handshake() equivalent instead?
In any case, this is basically a revert of this change:
6ccb83d6c497 ("usb: xhci: Implement xhci_handshake_check_state() helper")
Can't we just revert or fix the above patch that causes a regression?
Thanks,
Thinh
> + else
> + exit_state = XHCI_STATE_REMOVING;
> +
> ret = xhci_handshake_check_state(xhci, &xhci->op_regs->command,
> - CMD_RESET, 0, timeout_us, XHCI_STATE_REMOVING);
> + CMD_RESET, 0, timeout_us, exit_state);
> if (ret)
> return ret;
>
> diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
> index 242ab9fbc8ae..ac65af788298 100644
> --- a/drivers/usb/host/xhci.h
> +++ b/drivers/usb/host/xhci.h
> @@ -1637,6 +1637,7 @@ struct xhci_hcd {
> #define XHCI_WRITE_64_HI_LO BIT_ULL(47)
> #define XHCI_CDNS_SCTX_QUIRK BIT_ULL(48)
> #define XHCI_ETRON_HOST BIT_ULL(49)
> +#define XHCI_FULL_RESET_ON_REMOVE BIT_ULL(50)
>
> unsigned int num_active_eps;
> unsigned int limit_active_eps;
> --
> 2.49.0.1112.g889b7c5bd8-goog
>
next prev parent reply other threads:[~2025-05-15 23:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-15 18:52 [PATCH v2 0/2] Introduce XHCI_FULL_RESET_ON_REMOVE quirk for DWC3 Roy Luo
2025-05-15 18:52 ` [PATCH v2 1/2] xhci: Add a quirk for full reset on removal Roy Luo
2025-05-15 23:42 ` Thinh Nguyen [this message]
2025-05-16 6:33 ` Michał Pecio
2025-05-16 23:11 ` Roy Luo
2025-05-16 23:38 ` Thinh Nguyen
2025-05-17 0:50 ` Roy Luo
2025-05-17 4:39 ` Michał Pecio
2025-05-15 18:52 ` [PATCH v2 2/2] usb: dwc3: Force full reset on xhci removal Roy Luo
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=20250515234244.tpqp375x77jh53fl@synopsys.com \
--to=thinh.nguyen@synopsys.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
--cc=quic_ugoswami@quicinc.com \
--cc=royluo@google.com \
--cc=stable@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 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.