From: Heiko Stuebner <heiko@sntech.de>
To: Mathias Nyman <mathias.nyman@intel.com>,
Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
Sam Edwards <cfsworks@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Sam Edwards <CFSworks@gmail.com>
Subject: Re: [PATCH 1/2] xhci: Introduce "disable-usb3" DT property/quirk
Date: Tue, 12 Dec 2023 20:31:45 +0100 [thread overview]
Message-ID: <4854020.GXAFRqVoOG@phil> (raw)
In-Reply-To: <20231208210458.912776-2-CFSworks@gmail.com>
Am Freitag, 8. Dezember 2023, 22:04:57 CET schrieb Sam Edwards:
> Some systems may have xHCI controllers that enumerate USB 3.0 ports, but
> these ports nevertheless cannot be used. Perhaps enabling them triggers a
> hardware bug, or perhaps they simply aren't connected and it would be
> confusing to the user to see an unusable USB 3.0 rhub show up -- whatever
> the case may be, it's reasonable to want to disable these ports.
>
> Add a DT property (and associated quirk) to the xHCI driver that skips
> over (i.e. ignores and doesn't initialize) any USB 3.0 ports discovered
> during driver initialization.
>
> Signed-off-by: Sam Edwards <CFSworks@gmail.com>
I'm very much unsure, where the line goes between hw-quirk and
dt-is-not-a-configuration-space - in this specific instance.
DT is meant to describe the actual hardware present and not how
any operating system supports it.
So having that usb3phy present in the kernel - even if only in
a more limited form as you describe would be my preference.
But for a short-term thing, the usb3-phy in the binding is optional, so
so you could "just" deduce the no-usb3 state in your code from its
absence from the dt-node?
Heiko
> Documentation/devicetree/bindings/usb/usb-xhci.yaml | 4 ++++
> drivers/usb/host/xhci-mem.c | 4 ++++
> drivers/usb/host/xhci-plat.c | 3 +++
> drivers/usb/host/xhci.h | 1 +
> 4 files changed, 12 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.yaml b/Documentation/devicetree/bindings/usb/usb-xhci.yaml
> index 180a261c3e8f..8a64e747260a 100644
> --- a/Documentation/devicetree/bindings/usb/usb-xhci.yaml
> +++ b/Documentation/devicetree/bindings/usb/usb-xhci.yaml
> @@ -25,6 +25,10 @@ properties:
> description: Set if the controller has broken port disable mechanism
> type: boolean
>
> + disable-usb3:
> + description: Ignore (don't initialize, don't use) USB3 ports
> + type: boolean
> +
> imod-interval-ns:
> description: Interrupt moderation interval
> default: 5000
> diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
> index 0a37f0d511cf..bf8fcab626e4 100644
> --- a/drivers/usb/host/xhci-mem.c
> +++ b/drivers/usb/host/xhci-mem.c
> @@ -1968,6 +1968,10 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports,
> minor_revision = XHCI_EXT_PORT_MINOR(temp);
>
> if (major_revision == 0x03) {
> + /* Ignore USB3 ports entirely if USB3 support is disabled. */
> + if (xhci->quirks & XHCI_DISABLE_USB3)
> + return;
> +
> rhub = &xhci->usb3_rhub;
> /*
> * Some hosts incorrectly use sub-minor version for minor
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index b93161374293..75285fb5bbbc 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -249,6 +249,9 @@ int xhci_plat_probe(struct platform_device *pdev, struct device *sysdev, const s
> if (device_property_read_bool(tmpdev, "quirk-broken-port-ped"))
> xhci->quirks |= XHCI_BROKEN_PORT_PED;
>
> + if (device_property_read_bool(tmpdev, "disable-usb3"))
> + xhci->quirks |= XHCI_DISABLE_USB3;
> +
> device_property_read_u32(tmpdev, "imod-interval-ns",
> &xhci->imod_interval);
> }
> diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
> index 5df370482521..c53fbeea478f 100644
> --- a/drivers/usb/host/xhci.h
> +++ b/drivers/usb/host/xhci.h
> @@ -1906,6 +1906,7 @@ struct xhci_hcd {
> #define XHCI_RESET_TO_DEFAULT BIT_ULL(44)
> #define XHCI_ZHAOXIN_TRB_FETCH BIT_ULL(45)
> #define XHCI_ZHAOXIN_HOST BIT_ULL(46)
> +#define XHCI_DISABLE_USB3 BIT_ULL(47)
>
> unsigned int num_active_eps;
> unsigned int limit_active_eps;
>
next prev parent reply other threads:[~2023-12-12 19:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-08 21:04 [PATCH 0/2] Allow disabling USB3 ports in xHCI/DWC3 Sam Edwards
2023-12-08 21:04 ` [PATCH 1/2] xhci: Introduce "disable-usb3" DT property/quirk Sam Edwards
2023-12-09 13:53 ` Krzysztof Kozlowski
2023-12-09 19:26 ` Sam Edwards
2023-12-10 11:10 ` Krzysztof Kozlowski
2023-12-10 21:39 ` Sam Edwards
2023-12-12 19:31 ` Heiko Stuebner [this message]
2023-12-13 21:03 ` Sam Edwards
2023-12-08 21:04 ` [PATCH 2/2] usb: dwc3: host: Disable USB3 ports if maximum-speed doesn't permit USB3 Sam Edwards
2023-12-15 12:44 ` Greg Kroah-Hartman
2023-12-15 21:39 ` Sam Edwards
2023-12-14 11:05 ` [PATCH 0/2] Allow disabling USB3 ports in xHCI/DWC3 Mathias Nyman
2023-12-15 21:59 ` Sam Edwards
2023-12-18 15:40 ` Mathias Nyman
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=4854020.GXAFRqVoOG@phil \
--to=heiko@sntech.de \
--cc=Thinh.Nguyen@synopsys.com \
--cc=cfsworks@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.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