* [PATCH v9 0/3] USB prerequisites for PHY consumer/provider split
@ 2026-08-10 12:56 Vladimir Oltean
2026-08-10 12:56 ` [PATCH v9 1/3] usb: add missing headers transitively included by <linux/phy/phy.h> Vladimir Oltean
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Vladimir Oltean @ 2026-08-10 12:56 UTC (permalink / raw)
To: linux-usb; +Cc: imx, linux-arm-kernel, linux-kernel, linux-tegra
"[PATCH v8 phy-next 00/31] Split Generic PHY consumer and provider API"
https://lore.kernel.org/linux-phy/20260505100523.1922388-1-vladimir.oltean@nxp.com/
became unmanageably large for a single patch series and needs to be
split per subsystem.
Here are the patches pertaining to USB extracted out of the larger
series.
Change log in individual patches.
Vladimir Oltean (3):
usb: add missing headers transitively included by <linux/phy/phy.h>
usb: host: tegra: avoid direct dereference of phy->dev.of_node
usb: gadget: tegra-xudc: avoid direct dereference of phy->dev.of_node
drivers/usb/chipidea/ci_hdrc_imx.c | 1 +
drivers/usb/core/hcd.c | 1 +
drivers/usb/dwc3/dwc3-generic-plat.c | 1 +
drivers/usb/dwc3/dwc3-imx.c | 1 +
drivers/usb/dwc3/gadget.c | 1 +
drivers/usb/gadget/udc/tegra-xudc.c | 43 +++++++++++++++++++++-------
drivers/usb/host/xhci-tegra.c | 43 +++++++++++++++++-----------
7 files changed, 64 insertions(+), 27 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v9 1/3] usb: add missing headers transitively included by <linux/phy/phy.h>
2026-08-10 12:56 [PATCH v9 0/3] USB prerequisites for PHY consumer/provider split Vladimir Oltean
@ 2026-08-10 12:56 ` Vladimir Oltean
2026-08-10 17:05 ` Frank Li
2026-08-10 12:56 ` [PATCH v9 2/3] usb: host: tegra: avoid direct dereference of phy->dev.of_node Vladimir Oltean
2026-08-10 12:56 ` [PATCH v9 3/3] usb: gadget: tegra-xudc: " Vladimir Oltean
2 siblings, 1 reply; 7+ messages in thread
From: Vladimir Oltean @ 2026-08-10 12:56 UTC (permalink / raw)
To: linux-usb
Cc: imx, linux-arm-kernel, linux-kernel, linux-tegra, Thinh Nguyen,
Greg Kroah-Hartman, Peter Chen, Frank Li, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Xu Yang
The chipidea ci_hdrc_imx driver uses regulator consumer API like
regulator_enable() but does not include <linux/regulator/consumer.h>.
The core USB HCD driver calls invalidate_kernel_vmap_range() and
flush_kernel_vmap_range(), but does not include <linux/highmem.h>.
The DWC3 gadget driver calls:
- device_property_present()
- device_property_count_u8()
- device_property_read_u8_array()
but does not include <linux/property.h>
Similarly, dwc3-imx uses device_property_read_bool() without including
<linux/property.h>.
The dwc3-generic-plat driver uses of_device_get_match_data() but does
not include <linux/of.h>.
In all these cases, the necessary includes were still provided somehow,
directly or indirectly, through <linux/phy/phy.h>. I found the following
command to be quite helpful in figuring out the include chain:
$ make KCFLAGS="-H" drivers/usb/dwc3/dwc3-imx.o
Since <linux/phy/phy.h> wants to drop the unnecessary includes, fill in
the required headers to avoid any breakage.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> # dwc3
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
Cc: Peter Chen <peter.chen@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Frank Li <Frank.Li@nxp.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Cc: Xu Yang <xu.yang_2@nxp.com>
v7->v9: none
v6->v7:
- add drivers/usb/dwc3/dwc3-imx.c to the list of patched files
- collect tag from Greg, keeping it despite the new addition because the
change is minor and in the same spirit as the rest
(https://lore.kernel.org/linux-phy/2026033028-squint-yield-4c23@gregkh/)
v2->v6: none
v1->v2: collect tag
---
drivers/usb/chipidea/ci_hdrc_imx.c | 1 +
drivers/usb/core/hcd.c | 1 +
drivers/usb/dwc3/dwc3-generic-plat.c | 1 +
drivers/usb/dwc3/dwc3-imx.c | 1 +
drivers/usb/dwc3/gadget.c | 1 +
5 files changed, 5 insertions(+)
diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
index 282314eea7fc..1509b8ec630c 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -17,6 +17,7 @@
#include <linux/clk.h>
#include <linux/pinctrl/consumer.h>
#include <linux/pm_qos.h>
+#include <linux/regulator/consumer.h>
#include "ci.h"
#include "ci_hdrc_imx.h"
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 8e8a5f59b319..f7def9b116e0 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -10,6 +10,7 @@
*/
#include <linux/bcd.h>
+#include <linux/highmem.h>
#include <linux/module.h>
#include <linux/version.h>
#include <linux/kernel.h>
diff --git a/drivers/usb/dwc3/dwc3-generic-plat.c b/drivers/usb/dwc3/dwc3-generic-plat.c
index ca69ac0eb07c..2f2ae6f4704f 100644
--- a/drivers/usb/dwc3/dwc3-generic-plat.c
+++ b/drivers/usb/dwc3/dwc3-generic-plat.c
@@ -8,6 +8,7 @@
*/
#include <linux/clk.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/reset.h>
#include <linux/regmap.h>
diff --git a/drivers/usb/dwc3/dwc3-imx.c b/drivers/usb/dwc3/dwc3-imx.c
index 973a486b544d..6e122674edaf 100644
--- a/drivers/usb/dwc3/dwc3-imx.c
+++ b/drivers/usb/dwc3/dwc3-imx.c
@@ -13,6 +13,7 @@
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
+#include <linux/property.h>
#include "core.h"
#include "glue.h"
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index fa0f16ffafef..e70c17d50db8 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -10,6 +10,7 @@
#include <linux/kernel.h>
#include <linux/delay.h>
+#include <linux/property.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/platform_device.h>
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v9 2/3] usb: host: tegra: avoid direct dereference of phy->dev.of_node
2026-08-10 12:56 [PATCH v9 0/3] USB prerequisites for PHY consumer/provider split Vladimir Oltean
2026-08-10 12:56 ` [PATCH v9 1/3] usb: add missing headers transitively included by <linux/phy/phy.h> Vladimir Oltean
@ 2026-08-10 12:56 ` Vladimir Oltean
2026-08-10 13:08 ` sashiko-bot
2026-08-10 12:56 ` [PATCH v9 3/3] usb: gadget: tegra-xudc: " Vladimir Oltean
2 siblings, 1 reply; 7+ messages in thread
From: Vladimir Oltean @ 2026-08-10 12:56 UTC (permalink / raw)
To: linux-usb
Cc: imx, linux-arm-kernel, linux-kernel, linux-tegra,
Greg Kroah-Hartman, JC Kuo, Johan Hovold, Jonathan Hunter,
Mathias Nyman, Thierry Reding
A piece of context which seems relevant here is that the USB subsystem
is transitioning from struct usb_phy to struct phy (belonging to the
Generic PHY subsystem). Commit 1a229d8690a0 ("Revert "usb: phy: add usb
phy notify port status API"") seems to confirm that this is the case.
In the transition process, some PHY provider drivers register themselves
as both Generic PHY and USB PHY in an attempt to bridge the API gap.
Such is the case with drivers/phy/tegra/xusb.c, accessed here by the
Tegra USB host driver. This USB host expects the PHY device behind the
Generic PHY to also be a USB PHY, and calls
devm_usb_get_phy_by_node(phy->dev.of_node).
The Generic PHY exposes no API to get the OF node from a PHY device, so
the Tegra USB host driver gets it directly. However, "struct phy" will
be made an opaque pointer, to avoid misuse, so this will no longer be
possible.
Considering the fact that the Generic PHY/USB PHY duality is a
transitional state, I am deliberately not planning to make the life of
this driver any easier by providing a helper to get to the OF node
somehow. Instead, implement a parallel lookup path through which the
Tegra USB host driver can continue to get to the OF node provided by the
padctl component, using the 'phys' phandle.
Secondly (minor issue) the driver uses the phy->dev.of_node again to
print using dev_dbg() that a "remote wake" was detected. Just print the
index at which the PHY appears inside the driver's tegra->phys[] array
instead.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: JC Kuo <jckuo@nvidia.com>
Cc: Johan Hovold <johan+linaro@kernel.org>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Mathias Nyman <mathias.nyman@intel.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
v8->v9: none
v7->v8:
- add missing of_node_put(args.np) in tegra_xusb_init_usb_phy()
- replace %d with %u in tegra_xhci_disable_phy_wake()
Both pointed out by Sashiko.
v5->v7: none
v4->v5: patch is new
---
drivers/usb/host/xhci-tegra.c | 43 ++++++++++++++++++++++-------------
1 file changed, 27 insertions(+), 16 deletions(-)
diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
index e7e6d569f1db..4d85702ad42f 100644
--- a/drivers/usb/host/xhci-tegra.c
+++ b/drivers/usb/host/xhci-tegra.c
@@ -1502,6 +1502,7 @@ static int tegra_xhci_id_notify(struct notifier_block *nb,
static int tegra_xusb_init_usb_phy(struct tegra_xusb *tegra)
{
+ struct device_node *np = dev_of_node(tegra->dev);
unsigned int i;
tegra->usbphy = devm_kcalloc(tegra->dev, tegra->num_usb_phys,
@@ -1515,23 +1516,34 @@ static int tegra_xusb_init_usb_phy(struct tegra_xusb *tegra)
tegra->otg_usb3_port = -EINVAL;
for (i = 0; i < tegra->num_usb_phys; i++) {
- struct phy *phy = tegra_xusb_get_phy(tegra, "usb2", i);
+ struct of_phandle_args args;
+ struct usb_phy *usbphy;
+ int index, err;
+ char prop[8];
- if (!phy)
+ snprintf(prop, sizeof(prop), "usb2-%d", i);
+
+ /*
+ * usb-phy is optional, continue if it's not available.
+ */
+ index = of_property_match_string(np, "phy-names", prop);
+ if (index < 0)
continue;
- tegra->usbphy[i] = devm_usb_get_phy_by_node(tegra->dev,
- phy->dev.of_node,
- &tegra->id_nb);
- if (!IS_ERR(tegra->usbphy[i])) {
- dev_dbg(tegra->dev, "usbphy-%d registered", i);
- otg_set_host(tegra->usbphy[i]->otg, &tegra->hcd->self);
- } else {
- /*
- * usb-phy is optional, continue if its not available.
- */
- tegra->usbphy[i] = NULL;
- }
+ err = of_parse_phandle_with_args(np, "phys", "#phy-cells",
+ index, &args);
+ if (err)
+ continue;
+
+ usbphy = devm_usb_get_phy_by_node(tegra->dev, args.np,
+ &tegra->id_nb);
+ of_node_put(args.np);
+ if (IS_ERR(usbphy))
+ continue;
+
+ tegra->usbphy[i] = usbphy;
+ dev_dbg(tegra->dev, "usbphy-%d registered", i);
+ otg_set_host(tegra->usbphy[i]->otg, &tegra->hcd->self);
}
return 0;
@@ -2186,8 +2198,7 @@ static void tegra_xhci_disable_phy_wake(struct tegra_xusb *tegra)
continue;
if (tegra_xusb_padctl_remote_wake_detected(padctl, tegra->phys[i]))
- dev_dbg(tegra->dev, "%pOF remote wake detected\n",
- tegra->phys[i]->dev.of_node);
+ dev_dbg(tegra->dev, "PHY %u remote wake detected\n", i);
tegra_xusb_padctl_disable_phy_wake(padctl, tegra->phys[i]);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v9 3/3] usb: gadget: tegra-xudc: avoid direct dereference of phy->dev.of_node
2026-08-10 12:56 [PATCH v9 0/3] USB prerequisites for PHY consumer/provider split Vladimir Oltean
2026-08-10 12:56 ` [PATCH v9 1/3] usb: add missing headers transitively included by <linux/phy/phy.h> Vladimir Oltean
2026-08-10 12:56 ` [PATCH v9 2/3] usb: host: tegra: avoid direct dereference of phy->dev.of_node Vladimir Oltean
@ 2026-08-10 12:56 ` Vladimir Oltean
2026-08-10 13:07 ` sashiko-bot
2 siblings, 1 reply; 7+ messages in thread
From: Vladimir Oltean @ 2026-08-10 12:56 UTC (permalink / raw)
To: linux-usb
Cc: imx, linux-arm-kernel, linux-kernel, linux-tegra,
Greg Kroah-Hartman, JC Kuo, Johan Hovold, Jonathan Hunter,
Mathias Nyman, Thierry Reding
In a somewhat similar situation as the Tegra USB host controller driver,
the Tegra XUDC driver for USB gadget mode needs to get to a struct
usb_phy that sits behind the same OF node as the Generic PHY. It does
that directly, which will no longer be possible. The PHY provider is
also the xusb padctl driver.
The rework here is also to implement a parallel OF node lookup path
based on the "phys" phandle and the #phy-cells of the padctl provider.
Some further notes:
- create a local "usbphy" variable to hold the devm_usb_get_phy_by_node()
output. This makes the error checks more obvious (avoids keeping an
error-encoded pointer in xudc->usbphy[i] even temporarily).
- the "if (IS_ERR(utmi_phy)) .. else if (utmi_phy) .. else if (!utmi_phy)"
pattern can be simplified, considering that neither the IS_ERR() nor
the NULL case continue execution in the current block. Therefore, we
can move the case where the "utmi_phy" is a valid pointer outside the
"if" checks, and this reduces the code indentation level.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: JC Kuo <jckuo@nvidia.com>
Cc: Johan Hovold <johan+linaro@kernel.org>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Mathias Nyman <mathias.nyman@intel.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
v8->v9: none
v7->v8:
- remove duplicated variable "err" which shadows existing one
- stop execution on of_property_match_string() and
of_parse_phandle_with_args() errors, instead of silently continuing
v5->v7: none
v4->v5: patch is new
---
drivers/usb/gadget/udc/tegra-xudc.c | 43 +++++++++++++++++++++--------
1 file changed, 32 insertions(+), 11 deletions(-)
diff --git a/drivers/usb/gadget/udc/tegra-xudc.c b/drivers/usb/gadget/udc/tegra-xudc.c
index e9d33be02866..f93e0a5651ab 100644
--- a/drivers/usb/gadget/udc/tegra-xudc.c
+++ b/drivers/usb/gadget/udc/tegra-xudc.c
@@ -3494,6 +3494,7 @@ static void tegra_xudc_device_params_init(struct tegra_xudc *xudc)
static int tegra_xudc_phy_get(struct tegra_xudc *xudc)
{
+ struct device_node *np = dev_of_node(xudc->dev);
int err = 0, usb3_companion_port;
unsigned int i, j;
@@ -3515,7 +3516,10 @@ static int tegra_xudc_phy_get(struct tegra_xudc *xudc)
xudc->vbus_nb.notifier_call = tegra_xudc_vbus_notify;
for (i = 0; i < xudc->soc->num_phys; i++) {
+ struct of_phandle_args args;
char phy_name[] = "usb.-.";
+ struct usb_phy *usbphy;
+ int index;
/* Get USB2 phy */
snprintf(phy_name, sizeof(phy_name), "usb2-%d", i);
@@ -3525,22 +3529,39 @@ static int tegra_xudc_phy_get(struct tegra_xudc *xudc)
dev_err_probe(xudc->dev, err,
"failed to get PHY for phy-name usb2-%d\n", i);
goto clean_up;
- } else if (xudc->utmi_phy[i]) {
- /* Get usb-phy, if utmi phy is available */
- xudc->usbphy[i] = devm_usb_get_phy_by_node(xudc->dev,
- xudc->utmi_phy[i]->dev.of_node,
- NULL);
- if (IS_ERR(xudc->usbphy[i])) {
- err = PTR_ERR(xudc->usbphy[i]);
- dev_err_probe(xudc->dev, err,
- "failed to get usbphy-%d\n", i);
- goto clean_up;
- }
} else if (!xudc->utmi_phy[i]) {
/* if utmi phy is not available, ignore USB3 phy get */
continue;
}
+ index = of_property_match_string(np, "phy-names", phy_name);
+ if (index < 0) {
+ dev_err(xudc->dev,
+ "no \"phy-names\" entry for \"%s\": %pe\n",
+ phy_name, ERR_PTR(index));
+ goto clean_up;
+ }
+
+ err = of_parse_phandle_with_args(np, "phys", "#phy-cells",
+ index, &args);
+ if (err) {
+ dev_err(xudc->dev,
+ "failed to follow \"%s\" reference\n: %pe\n",
+ phy_name, ERR_PTR(err));
+ goto clean_up;
+ }
+
+ /* Get usb-phy, if utmi phy is available */
+ usbphy = devm_usb_get_phy_by_node(xudc->dev, args.np, NULL);
+ of_node_put(args.np);
+ if (IS_ERR(usbphy)) {
+ err = PTR_ERR(usbphy);
+ dev_err_probe(xudc->dev, err,
+ "failed to get usbphy-%d\n", i);
+ goto clean_up;
+ }
+ xudc->usbphy[i] = usbphy;
+
/* Get USB3 phy */
usb3_companion_port = tegra_xusb_padctl_get_usb3_companion(xudc->padctl, i);
if (usb3_companion_port < 0)
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v9 3/3] usb: gadget: tegra-xudc: avoid direct dereference of phy->dev.of_node
2026-08-10 12:56 ` [PATCH v9 3/3] usb: gadget: tegra-xudc: " Vladimir Oltean
@ 2026-08-10 13:07 ` sashiko-bot
0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-08-10 13:07 UTC (permalink / raw)
To: Vladimir Oltean; +Cc: imx, Frank.Li
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Missing error code assignment when `of_property_match_string()` fails, causing a silent initialization failure.
- [Low] Malformed error message format string splits log across two lines.
--
--- Patch [3]: [PATCH v9 3/3] usb: gadget: tegra-xudc: avoid direct dereference of phy->dev.of_node ---
commit 5dbf80ca5d539781ed1dcc83abb9ad4e29628462
Author: Vladimir Oltean <vladimir.oltean@nxp.com>
usb: gadget: tegra-xudc: avoid direct dereference of phy->dev.of_node
This patch reworks the PHY lookup in the Tegra XUDC driver to avoid directly
dereferencing phy->dev.of_node. It introduces a parallel OF node lookup path
based on the "phys" phandle and the #phy-cells of the padctl provider.
> diff --git a/drivers/usb/gadget/udc/tegra-xudc.c b/drivers/usb/gadget/udc/tegra-xudc.c
> --- a/drivers/usb/gadget/udc/tegra-xudc.c
> +++ b/drivers/usb/gadget/udc/tegra-xudc.c
[ ... ]
> @@ -3525,22 +3529,39 @@ static int tegra_xudc_phy_get(struct tegra_xudc *xudc)
[ ... ]
> } else if (!xudc->utmi_phy[i]) {
> /* if utmi phy is not available, ignore USB3 phy get */
> continue;
> }
>
> + index = of_property_match_string(np, "phy-names", phy_name);
> + if (index < 0) {
> + dev_err(xudc->dev,
> + "no \"phy-names\" entry for \"%s\": %pe\n",
> + phy_name, ERR_PTR(index));
> + goto clean_up;
> + }
[Severity: High]
If this fails, we jump to clean_up without updating the err variable. Since err
was initialized to 0, would this cause the driver probe to falsely report
success without having acquired the PHYs?
Could we assign err = index before the goto?
> +
> + err = of_parse_phandle_with_args(np, "phys", "#phy-cells",
> + index, &args);
> + if (err) {
> + dev_err(xudc->dev,
> + "failed to follow \"%s\" reference\n: %pe\n",
> + phy_name, ERR_PTR(err));
[Severity: Low]
This isn't a bug, but there is an extraneous newline before the colon in the
format string which will split the log message across two lines.
> + goto clean_up;
> + }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260810125614.441667-1-vladimir.oltean@nxp.com?part=3
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v9 2/3] usb: host: tegra: avoid direct dereference of phy->dev.of_node
2026-08-10 12:56 ` [PATCH v9 2/3] usb: host: tegra: avoid direct dereference of phy->dev.of_node Vladimir Oltean
@ 2026-08-10 13:08 ` sashiko-bot
0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-08-10 13:08 UTC (permalink / raw)
To: Vladimir Oltean; +Cc: Frank.Li, imx
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Reusing a single `struct notifier_block` (`tegra->id_nb`) across multiple independent USB PHYs corrupts their atomic notifier chains.
- [High] Delayed work can be scheduled after driver removal due to devres-based notifier unregistration.
--
--- Patch [2]: [PATCH v9 2/3] usb: host: tegra: avoid direct dereference of phy->dev.of_node ---
commit 5072858d37310d2ff0794e119a072f8de6f28872
Author: Vladimir Oltean <vladimir.oltean@nxp.com>
usb: host: tegra: avoid direct dereference of phy->dev.of_node
This commit removes direct access to phy->dev.of_node from the Tegra USB
host driver. It implements a parallel lookup path using the 'phys' phandle
to retrieve the OF node. The remote wake debug print is also updated to use
the PHY index instead.
> diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
> --- a/drivers/usb/host/xhci-tegra.c
> +++ b/drivers/usb/host/xhci-tegra.c
> @@ -1515,23 +1516,34 @@ static int tegra_xusb_init_usb_phy(struct tegra_xusb *tegra)
> tegra->otg_usb3_port = -EINVAL;
>
> for (i = 0; i < tegra->num_usb_phys; i++) {
> - struct phy *phy = tegra_xusb_get_phy(tegra, "usb2", i);
[ ... ]
> + err = of_parse_phandle_with_args(np, "phys", "#phy-cells",
> + index, &args);
> + if (err)
> + continue;
> +
> + usbphy = devm_usb_get_phy_by_node(tegra->dev, args.np,
> + &tegra->id_nb);
[Severity: High]
This is a pre-existing issue, but does reusing a single struct notifier_block
(tegra->id_nb) across multiple independent USB PHYs corrupt their atomic
notifier chains?
Since tegra_xusb_init_usb_phy() loops over all available usb2 PHYs, it passes
the exact same &tegra->id_nb notifier block to devm_usb_get_phy_by_node().
usb_register_notifier() then links this same block into each PHY's independent
atomic_notifier_head, which overwrites its next pointer.
Could this lead to missed events or infinite loops when the lists are
traversed?
[Severity: High]
This isn't a bug introduced by this patch, but does the devres lifecycle
for this notifier create a use-after-free risk during driver removal?
In tegra_xusb_remove(), cancel_work_sync(&tegra->id_work) is called to
stop pending work, but the notifier remains registered until the devres
release phase via devm_usb_phy_release2().
If a USB PHY event fires in this window, tegra_xhci_id_notify() calls
schedule_work(). Devres then unregisters the notifier and frees the
tegra_xusb structure, causing the workqueue to dereference the freed
structure when it executes.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260810125614.441667-1-vladimir.oltean@nxp.com?part=2
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v9 1/3] usb: add missing headers transitively included by <linux/phy/phy.h>
2026-08-10 12:56 ` [PATCH v9 1/3] usb: add missing headers transitively included by <linux/phy/phy.h> Vladimir Oltean
@ 2026-08-10 17:05 ` Frank Li
0 siblings, 0 replies; 7+ messages in thread
From: Frank Li @ 2026-08-10 17:05 UTC (permalink / raw)
To: Vladimir Oltean
Cc: linux-usb, imx, linux-arm-kernel, linux-kernel, linux-tegra,
Thinh Nguyen, Greg Kroah-Hartman, Peter Chen, Frank Li,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Xu Yang
On Mon, Aug 10, 2026 at 03:56:12PM +0300, Vladimir Oltean wrote:
> The chipidea ci_hdrc_imx driver uses regulator consumer API like
> regulator_enable() but does not include <linux/regulator/consumer.h>.
>
> The core USB HCD driver calls invalidate_kernel_vmap_range() and
> flush_kernel_vmap_range(), but does not include <linux/highmem.h>.
>
> The DWC3 gadget driver calls:
> - device_property_present()
> - device_property_count_u8()
> - device_property_read_u8_array()
> but does not include <linux/property.h>
>
> Similarly, dwc3-imx uses device_property_read_bool() without including
> <linux/property.h>.
>
> The dwc3-generic-plat driver uses of_device_get_match_data() but does
> not include <linux/of.h>.
>
> In all these cases, the necessary includes were still provided somehow,
> directly or indirectly, through <linux/phy/phy.h>. I found the following
> command to be quite helpful in figuring out the include chain:
>
> $ make KCFLAGS="-H" drivers/usb/dwc3/dwc3-imx.o
>
> Since <linux/phy/phy.h> wants to drop the unnecessary includes, fill in
> the required headers to avoid any breakage.
>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> # dwc3
> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> ---
> Cc: Peter Chen <peter.chen@kernel.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Frank Li <Frank.Li@nxp.com>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
> Cc: Fabio Estevam <festevam@gmail.com>
> Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
> Cc: Xu Yang <xu.yang_2@nxp.com>
>
> v7->v9: none
> v6->v7:
> - add drivers/usb/dwc3/dwc3-imx.c to the list of patched files
> - collect tag from Greg, keeping it despite the new addition because the
> change is minor and in the same spirit as the rest
> (https://lore.kernel.org/linux-phy/2026033028-squint-yield-4c23@gregkh/)
> v2->v6: none
> v1->v2: collect tag
> ---
> drivers/usb/chipidea/ci_hdrc_imx.c | 1 +
> drivers/usb/core/hcd.c | 1 +
> drivers/usb/dwc3/dwc3-generic-plat.c | 1 +
> drivers/usb/dwc3/dwc3-imx.c | 1 +
> drivers/usb/dwc3/gadget.c | 1 +
> 5 files changed, 5 insertions(+)
>
> diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
> index 282314eea7fc..1509b8ec630c 100644
> --- a/drivers/usb/chipidea/ci_hdrc_imx.c
> +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
> @@ -17,6 +17,7 @@
> #include <linux/clk.h>
> #include <linux/pinctrl/consumer.h>
> #include <linux/pm_qos.h>
> +#include <linux/regulator/consumer.h>
>
> #include "ci.h"
> #include "ci_hdrc_imx.h"
> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> index 8e8a5f59b319..f7def9b116e0 100644
> --- a/drivers/usb/core/hcd.c
> +++ b/drivers/usb/core/hcd.c
> @@ -10,6 +10,7 @@
> */
>
> #include <linux/bcd.h>
> +#include <linux/highmem.h>
> #include <linux/module.h>
> #include <linux/version.h>
> #include <linux/kernel.h>
> diff --git a/drivers/usb/dwc3/dwc3-generic-plat.c b/drivers/usb/dwc3/dwc3-generic-plat.c
> index ca69ac0eb07c..2f2ae6f4704f 100644
> --- a/drivers/usb/dwc3/dwc3-generic-plat.c
> +++ b/drivers/usb/dwc3/dwc3-generic-plat.c
> @@ -8,6 +8,7 @@
> */
>
> #include <linux/clk.h>
> +#include <linux/of.h>
> #include <linux/platform_device.h>
> #include <linux/reset.h>
> #include <linux/regmap.h>
> diff --git a/drivers/usb/dwc3/dwc3-imx.c b/drivers/usb/dwc3/dwc3-imx.c
> index 973a486b544d..6e122674edaf 100644
> --- a/drivers/usb/dwc3/dwc3-imx.c
> +++ b/drivers/usb/dwc3/dwc3-imx.c
> @@ -13,6 +13,7 @@
> #include <linux/of_platform.h>
> #include <linux/platform_device.h>
> #include <linux/pm_runtime.h>
> +#include <linux/property.h>
>
> #include "core.h"
> #include "glue.h"
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index fa0f16ffafef..e70c17d50db8 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -10,6 +10,7 @@
>
> #include <linux/kernel.h>
> #include <linux/delay.h>
> +#include <linux/property.h>
> #include <linux/slab.h>
> #include <linux/spinlock.h>
> #include <linux/platform_device.h>
> --
> 2.34.1
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-08-10 17:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-10 12:56 [PATCH v9 0/3] USB prerequisites for PHY consumer/provider split Vladimir Oltean
2026-08-10 12:56 ` [PATCH v9 1/3] usb: add missing headers transitively included by <linux/phy/phy.h> Vladimir Oltean
2026-08-10 17:05 ` Frank Li
2026-08-10 12:56 ` [PATCH v9 2/3] usb: host: tegra: avoid direct dereference of phy->dev.of_node Vladimir Oltean
2026-08-10 13:08 ` sashiko-bot
2026-08-10 12:56 ` [PATCH v9 3/3] usb: gadget: tegra-xudc: " Vladimir Oltean
2026-08-10 13:07 ` sashiko-bot
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.