From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Konrad Dybcio <konradybcio@kernel.org>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Mathias Nyman <mathias.nyman@intel.com>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"usb4-upstream@oss.qualcomm.com" <usb4-upstream@oss.qualcomm.com>,
Raghavendra Thoorpu <rthoorpu@qti.qualcomm.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Sven Peter <sven@kernel.org>,
Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Subject: Re: [PATCH v4 4/4] usb: dwc3: Notify XHCI core of tunneled status
Date: Sat, 3 Oct 2026 01:23:42 +0000 [thread overview]
Message-ID: <asBMw-j0fxVLVW5Q@vbox> (raw)
In-Reply-To: <20260929-topic-dwc3_tunneling_state-v4-4-63e296346d57@oss.qualcomm.com>
On Tue, Sep 29, 2026, Konrad Dybcio wrote:
> From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
>
> The Thunderbolt framework relies on the USB core to create device links
> for tunneled ports, so that the USB3 controller is only kept
> runtime-resumed for the duration of the tunneling. This depends on
> first knowing whether a connection is tunneled or native.
>
> Add the logic to handle that for DWC3 controllers.
>
> Assisted-by: LLM
> Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
> ---
> drivers/usb/dwc3/core.c | 18 ++++++++++++++++++
> drivers/usb/dwc3/core.h | 18 ++++++++++++++++++
> drivers/usb/dwc3/host.c | 14 ++++++++++++++
> 3 files changed, 50 insertions(+)
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index fd5c2cd36c59..4eb430f58983 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -162,6 +162,24 @@ void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode, bool ignore_susphy)
> }
> EXPORT_SYMBOL_GPL(dwc3_set_prtcap);
>
> +#if IS_ENABLED(CONFIG_USB_DWC3_HOST) || IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE)
Move this function to host.c instead of core.c, drop the guards, and
make it static.
> +enum usb_link_tunnel_mode dwc3_link_tunnel_mode(struct dwc3 *dwc, u8 port)
> +{
Maybe also add a check if (port >= dwc->num_usb3_ports) and return
USB_LINK_UNKNOWN?
> + /* Prior versions had no CIO support */
> + if (!DWC3_VER_IS_WITHIN(DWC31, 191A, ANY))
> + return USB_LINK_UNKNOWN;
Regarding your cover letter question about CIO for other IPs. We can
leave that for later when we need to make an update.
> +
> + /* Not all DWC3 instances have CIO HW, trust the platform firmware */
> + if (!device_property_present(dwc->dev, "usb4-host-interface"))
Can we pass this as a dwc3 property from your glue driver instead,
inferred from the compatible string? (ie. add dwc->has_cio)
So we can remove the DT dependency.
> + return USB_LINK_UNKNOWN;
> +
> + if (dwc3_readl(dwc, DWC3_CIOCTRL(port)) & DWC3_CIOCTRL_CIO_EN)
> + return USB_LINK_TUNNELED;
> +
> + return USB_LINK_NATIVE;
> +}
> +#endif
> +
> static void __dwc3_set_mode(struct work_struct *work)
> {
> struct dwc3 *dwc = work_to_dwc(work);
> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> index 608daeb7ef10..decc51cd6505 100644
> --- a/drivers/usb/dwc3/core.h
> +++ b/drivers/usb/dwc3/core.h
> @@ -179,6 +179,11 @@
> #define DWC3_OEVTEN 0xcc0C
> #define DWC3_OSTS 0xcc10
>
> +/* CIO regs */
> +#define DWC3_CIO_BASE(n) (0xcd20 + ((n) * 0x30))
> +#define DWC3_CIOCTRL(n) (DWC3_CIO_BASE(n) + 0x00)
> +#define DWC3_CIOCTRL_CIO_EN BIT(0)
> +
> #define DWC3_LLUCTL(n) (0xd024 + ((n) * 0x80))
>
> /* Bit fields */
> @@ -1314,6 +1319,7 @@ struct dwc3 {
> #define DWC31_REVISION_170A 0x3137302a
> #define DWC31_REVISION_180A 0x3138302a
> #define DWC31_REVISION_190A 0x3139302a
> +#define DWC31_REVISION_191A 0x3139312a
> #define DWC31_REVISION_200A 0x3230302a
>
> #define DWC32_REVISION_ANY 0x0
> @@ -1658,11 +1664,23 @@ static inline void dwc3_pre_run_stop(struct dwc3 *dwc, bool is_on)
> #if IS_ENABLED(CONFIG_USB_DWC3_HOST) || IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE)
> int dwc3_host_init(struct dwc3 *dwc);
> void dwc3_host_exit(struct dwc3 *dwc);
> +
> +/**
> + * dwc3_link_tunnel_mode - Check whether the link is tunneled over TBT/USB4
> + * @dwc: Pointer to DWC3 controller context
> + * @port: 0-based port index
> + *
> + * Returns: USB_LINK_TUNNELED if tunneled, USB_LINK_NATIVE if not, or
> + * when the controller does not have USB4 capabilities.
Do we need to describe the USB_LINK_UNKNOWN case?
Thanks,
Thinh
prev parent reply other threads:[~2026-10-03 1:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 15:54 [PATCH v4 0/4] DWC3 link tunneling state reporting Konrad Dybcio
2026-09-29 15:54 ` [PATCH v4 1/4] usb: xhci: debugfs: Expose the USB3 tunneling ext_cap register value Konrad Dybcio
2026-09-29 15:54 ` [PATCH v4 2/4] usb: xhci: Honor PORTSC.TM if valid Konrad Dybcio
2026-09-29 15:54 ` [PATCH v4 3/4] usb: xhci: Use update_device overrides for tunnel reporting Konrad Dybcio
2026-10-03 0:30 ` Thinh Nguyen
2026-09-29 15:54 ` [PATCH v4 4/4] usb: dwc3: Notify XHCI core of tunneled status Konrad Dybcio
2026-10-03 1:23 ` Thinh Nguyen [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=asBMw-j0fxVLVW5Q@vbox \
--to=thinh.nguyen@synopsys.com \
--cc=gregkh@linuxfoundation.org \
--cc=konrad.dybcio@oss.qualcomm.com \
--cc=konradybcio@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
--cc=mika.westerberg@linux.intel.com \
--cc=rthoorpu@qti.qualcomm.com \
--cc=sven@kernel.org \
--cc=usb4-upstream@oss.qualcomm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®