From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: Konrad Dybcio <konradybcio@kernel.org>,
Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Mathias Nyman <mathias.nyman@intel.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
usb4-upstream@oss.qualcomm.com,
Raghavendra Thoorpu <rthoorpu@qti.qualcomm.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Subject: Re: [PATCH v2 2/4] usb: xhci: Honor PORTSC.TM if valid
Date: Fri, 31 Jul 2026 13:51:34 +0300 [thread overview]
Message-ID: <7f0618ed-d2da-42a1-a605-0660439255d7@linux.intel.com> (raw)
In-Reply-To: <20260715-topic-dwc3_tunneling_state-v2-2-026487a08119@oss.qualcomm.com>
On 7/15/26 15:29, Konrad Dybcio wrote:
> From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
>
> Currently, the only way for the USB core to determine whether the link
> is native or tunneled is via an Intel vendor-specific Extended
> Capability.
>
> The XHCI specification v1.2 and newer expose a common ext_cap,
> indicating whether BIT(2) of PORTSC can be interpreted as the tunneling
> status.
>
> Make use of that and fall back to the existing Intel-specific path if
> the ext_cap is absent.
>
> Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
> ---
> drivers/usb/host/xhci-ext-caps.h | 3 +++
> drivers/usb/host/xhci-hub.c | 19 ++++++++++++++++---
> drivers/usb/host/xhci-port.h | 3 ++-
> 3 files changed, 21 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/host/xhci-ext-caps.h b/drivers/usb/host/xhci-ext-caps.h
> index 22e53a750e2a..af7d624cd38e 100644
> --- a/drivers/usb/host/xhci-ext-caps.h
> +++ b/drivers/usb/host/xhci-ext-caps.h
> @@ -66,6 +66,9 @@
> #define XHCI_HLC (1 << 19)
> #define XHCI_BLC (1 << 20)
>
> +/* USB3 tunneling support capability - section 7.11 */
> +#define XHCI_USB3_TUNNELING_SUPPORTED BIT(16)
> +
> /* Intel SPR shadow capability */
> #define XHCI_INTEL_SPR_ESS_PORT_OFFSET 0x8ac4 /* SuperSpeed port control */
> #define XHCI_INTEL_SPR_TUNEN BIT(4) /* Tunnel mode enabled */
> diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
> index b0264bd8577a..402e98ab95ee 100644
> --- a/drivers/usb/host/xhci-hub.c
> +++ b/drivers/usb/host/xhci-hub.c
> @@ -766,17 +766,30 @@ static int xhci_exit_test_mode(struct xhci_hcd *xhci)
> enum usb_link_tunnel_mode xhci_port_is_tunneled(struct xhci_hcd *xhci,
> struct xhci_port *port)
> {
> + void __iomem *base = &xhci->cap_regs->hc_capbase;
> struct usb_hcd *hcd;
> - void __iomem *base;
> u32 offset;
> + u32 val;
>
> - /* Don't try and probe this capability for non-Intel hosts */
> + /* Prefer the XHCI v1.2 ext_cap if advertised */
> + offset = xhci_find_next_ext_cap(base, 0, XHCI_EXT_CAPS_USB3_TUNNELING);
> + if (offset) {
> + if (!(readl(base + offset) & XHCI_USB3_TUNNELING_SUPPORTED))
> + return USB_LINK_NATIVE;
> +
The extcap 18 value won't change.
We can read it once in xhci_gen_setup()/xhci_setup_port_arrays() and cache it.
here we would just check:
if (xhci->portsc_tunnel_reporting) {
..read portsc and return, as you do below
> + val = xhci_portsc_readl(port);
> + if (val & PORT_TM)
> + return USB_LINK_TUNNELED;
> +
> + return USB_LINK_NATIVE;
> + }
> +
Thanks
Mathias
next prev parent reply other threads:[~2026-07-31 10:51 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 12:29 [PATCH v2 0/4] DWC3 link tunneling state reporting Konrad Dybcio
2026-07-15 12:29 ` [PATCH v2 1/4] usb: xhci: debugfs: Expose the USB3 tunneling ext_cap register value Konrad Dybcio
2026-07-15 12:29 ` [PATCH v2 2/4] usb: xhci: Honor PORTSC.TM if valid Konrad Dybcio
2026-07-22 22:57 ` Thinh Nguyen
2026-07-28 8:44 ` Konrad Dybcio
2026-07-31 10:34 ` Mathias Nyman
2026-07-31 10:53 ` Konrad Dybcio
2026-07-31 10:51 ` Mathias Nyman [this message]
2026-07-31 11:01 ` Konrad Dybcio
2026-07-15 12:29 ` [PATCH v2 3/4] usb: xhci: Allow custom op for usb_link_tunnel_mode reporting Konrad Dybcio
2026-07-22 22:37 ` Thinh Nguyen
2026-07-28 8:41 ` Konrad Dybcio
2026-07-15 12:29 ` [PATCH v2 4/4] usb: dwc3: Notify XHCI core of tunneled status Konrad Dybcio
2026-07-22 23:01 ` Thinh Nguyen
2026-07-28 8:48 ` Konrad Dybcio
2026-07-15 12:58 ` [PATCH v2 0/4] DWC3 link tunneling state reporting Konrad Dybcio
2026-07-22 23:07 ` Thinh Nguyen
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=7f0618ed-d2da-42a1-a605-0660439255d7@linux.intel.com \
--to=mathias.nyman@linux.intel.com \
--cc=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=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 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.