Skip to content

Commit 0179c6d

Browse files
juhosggregkh
authored andcommitted
usb: core: phy: avoid double use of 'usb3-phy'
Commit 53a2d95 ("usb: core: add phy notify connect and disconnect") causes double use of the 'usb3-phy' in certain cases. Since that commit, if a generic PHY named 'usb3-phy' is specified in the device tree, that is getting added to the 'phy_roothub' list of the secondary HCD by the usb_phy_roothub_alloc_usb3_phy() function. However, that PHY is getting added also to the primary HCD's 'phy_roothub' list by usb_phy_roothub_alloc() if there is no generic PHY specified with 'usb2-phy' name. This causes that the usb_add_hcd() function executes each phy operations twice on the 'usb3-phy'. Once when the primary HCD is added, then once again when the secondary HCD is added. The issue affects the Marvell Armada 3700 platform at least, where a custom name is used for the USB2 PHY: $ git grep 'phy-names.*usb3' arch/arm64/boot/dts/marvell/armada-37xx.dtsi | tr '\t' ' ' arch/arm64/boot/dts/marvell/armada-37xx.dtsi: phy-names = "usb3-phy", "usb2-utmi-otg-phy"; Extend the usb_phy_roothub_alloc_usb3_phy() function to skip adding the 'usb3-phy' to the 'phy_roothub' list of the secondary HCD when 'usb2-phy' is not specified in the device tree to avoid the double use. Fixes: 53a2d95 ("usb: core: add phy notify connect and disconnect") Cc: stable <stable@kernel.org> Signed-off-by: Gabor Juhos <j4g8y7@gmail.com> Link: https://patch.msgid.link/20260330-usb-avoid-usb3-phy-double-use-v1-1-d2113aecb535@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e367599 commit 0179c6d

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

drivers/usb/core/phy.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ EXPORT_SYMBOL_GPL(usb_phy_roothub_alloc);
114114
struct usb_phy_roothub *usb_phy_roothub_alloc_usb3_phy(struct device *dev)
115115
{
116116
struct usb_phy_roothub *phy_roothub;
117-
int num_phys;
117+
int num_phys, usb2_phy_index;
118118

119119
if (!IS_ENABLED(CONFIG_GENERIC_PHY))
120120
return NULL;
@@ -124,6 +124,16 @@ struct usb_phy_roothub *usb_phy_roothub_alloc_usb3_phy(struct device *dev)
124124
if (num_phys <= 0)
125125
return NULL;
126126

127+
/*
128+
* If 'usb2-phy' is not present, usb_phy_roothub_alloc() added
129+
* all PHYs to the primary HCD's phy_roothub already, so skip
130+
* adding 'usb3-phy' here to avoid double use of that.
131+
*/
132+
usb2_phy_index = of_property_match_string(dev->of_node, "phy-names",
133+
"usb2-phy");
134+
if (usb2_phy_index < 0)
135+
return NULL;
136+
127137
phy_roothub = devm_kzalloc(dev, sizeof(*phy_roothub), GFP_KERNEL);
128138
if (!phy_roothub)
129139
return ERR_PTR(-ENOMEM);

0 commit comments

Comments
 (0)