Skip to contentSkip to conversation

usb: dwc3: qcom: Add missing DWC3 OF node refcount decrement

PATCH In review Serge Semin 2 participants 10 messages Feb 12, 2021 – Mar 26, 2021

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH v7 1/3 usb: dwc3: qcom: Add missing DWC3 OF node refcount decrement

of_get_child_by_name() increments the reference counter of the OF node it managed to find. So after the code is done using the device node, the refcount must be decremented. Add missing of_node_put() invocation then to the dwc3_qcom_of_register_core() method, since DWC3 OF node is being used only there.

Fixes a4333c3a6ba9 ("usb: dwc3: Add Qualcomm DWC3 glue driver")

---

Note the patch will get cleanly applied on the commit 2bc02355f8ba ("usb:
dwc3: qcom: Add support for booting with ACPI"), while the bug has been there since the Qualcomm DWC3 glue driver was submitted.

Changelog v7:
- This is a new patch. Please drop it If I missed something and the OF node refcount decrement wasn't supposed to be there.

---
 drivers/usb/dwc3/dwc3-qcom.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/usb/dwc3/dwc3-qcom.c +6 -3
index c703d552bbcf..3564d00cdce3 100644
@@ -639,16 +639,19 @@ static int dwc3_qcom_of_register_core(struct platform_device *pdev)
 	ret = of_platform_populate(np, NULL, NULL, dev);
 	if (ret) {
 		dev_err(dev, "failed to register dwc3 core - %d\n", ret);
-		return ret;
+		goto node_put;
 	}
 
 	qcom->dwc3 = of_find_device_by_node(dwc3_np);
 	if (!qcom->dwc3) {
+		ret = -ENODEV;
 		dev_err(dev, "failed to get dwc3 platform device\n");
-		return -ENODEV;
 	}
 
-	return 0;
+node_put:
+	of_node_put(dwc3_np);
+
+	return ret;
 }
 
 static int dwc3_qcom_probe(struct platform_device *pdev)
Signature · 1 line
2.30.0
#1 lore raw

PATCH v7 2/3 usb: dwc3: qcom: Detect DWC3 DT-nodes using compatible string

In accordance with the USB HCD/DRD schema all the USB controllers are supposed to have DT-nodes named with prefix "^usb(@.*)?". Since the existing DT-nodes will be renamed in a subsequent patch let's fix the DWC3 Qcom-specific code to detect the DWC3 sub-node just by checking its compatible string to match the "snps,dwc3". The semantic of the code won't change seeing all the DWC USB3 nodes are supposed to have the compatible property with any of those strings set.

---

Changelog v7:
- Replace "of_get_child_by_name(np, "usb") ?: of_get_child_by_name(np, "dwc3");" pattern with using of_get_compatible_child() method.
- Discard Bjorn Andersson Reviewed-by tag since the patch content has been changed.

---
 drivers/usb/dwc3/dwc3-qcom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-qcom.c +1 -1
index 3564d00cdce3..c8483becea5d 100644
@@ -630,7 +630,7 @@ static int dwc3_qcom_of_register_core(struct platform_device *pdev)
 	struct device		*dev = &pdev->dev;
 	int			ret;
 
-	dwc3_np = of_get_child_by_name(np, "dwc3");
+	dwc3_np = of_get_compatible_child(np, "snps,dwc3");
 	if (!dwc3_np) {
 		dev_err(dev, "failed to find dwc3 core child\n");
 		return -ENODEV;
Signature · 1 line
2.30.0
#2 lore raw

PATCH v7 3/3 arm64: dts: qcom: Harmonize DWC USB3 DT nodes name

In reply to Serge Semin

In accordance with the DWC USB3 bindings the corresponding node name is suppose to comply with the Generic USB HCD DT schema, which requires the USB nodes to have the name acceptable by the regexp:
"^usb(@.*)?" . Make sure the "snps,dwc3"-compatible nodes are correctly named.

---
 arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi | 4 ++--
 arch/arm64/boot/dts/qcom/ipq8074.dtsi        | 4 ++--
 arch/arm64/boot/dts/qcom/msm8996.dtsi        | 4 ++--
 arch/arm64/boot/dts/qcom/msm8998.dtsi        | 2 +-
 arch/arm64/boot/dts/qcom/qcs404-evb.dtsi     | 2 +-
 arch/arm64/boot/dts/qcom/qcs404.dtsi         | 4 ++--
 arch/arm64/boot/dts/qcom/sc7180.dtsi         | 2 +-
 arch/arm64/boot/dts/qcom/sdm845.dtsi         | 4 ++--
 arch/arm64/boot/dts/qcom/sm8150.dtsi         | 2 +-
 9 files changed, 14 insertions(+), 14 deletions(-)
arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi +2 -2
index defcbd15edf9..34e97da98270 100644
@@ -1064,7 +1064,7 @@ &usb2 {
 	status = "okay";
 	extcon = <&usb2_id>;
 
-	dwc3@7600000 {
+	usb@7600000 {
 		extcon = <&usb2_id>;
 		dr_mode = "otg";
 		maximum-speed = "high-speed";
@@ -1075,7 +1075,7 @@ &usb3 {
 	status = "okay";
 	extcon = <&usb3_id>;
 
-	dwc3@6a00000 {
+	usb@6a00000 {
 		extcon = <&usb3_id>;
 		dr_mode = "otg";
 	};
arch/arm64/boot/dts/qcom/ipq8074.dtsi +2 -2
index a32e5e79ab0b..7df4eb710aae 100644
@@ -427,7 +427,7 @@ usb_0: usb@8af8800 {
 			resets = <&gcc GCC_USB0_BCR>;
 			status = "disabled";
 
-			dwc_0: dwc3@8a00000 {
+			dwc_0: usb@8a00000 {
 				compatible = "snps,dwc3";
 				reg = <0x8a00000 0xcd00>;
 				interrupts = <GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>;
@@ -468,7 +468,7 @@ usb_1: usb@8cf8800 {
 			resets = <&gcc GCC_USB1_BCR>;
 			status = "disabled";
 
-			dwc_1: dwc3@8c00000 {
+			dwc_1: usb@8c00000 {
 				compatible = "snps,dwc3";
 				reg = <0x8c00000 0xcd00>;
 				interrupts = <GIC_SPI 99 IRQ_TYPE_LEVEL_HIGH>;
arch/arm64/boot/dts/qcom/msm8996.dtsi +2 -2
index 7eef07e73e25..374bb7b557e4 100644
@@ -1768,7 +1768,7 @@ usb3: usb@6af8800 {
 			power-domains = <&gcc USB30_GDSC>;
 			status = "disabled";
 
-			dwc3@6a00000 {
+			usb@6a00000 {
 				compatible = "snps,dwc3";
 				reg = <0x06a00000 0xcc00>;
 				interrupts = <0 131 IRQ_TYPE_LEVEL_HIGH>;
@@ -1979,7 +1979,7 @@ usb2: usb@76f8800 {
 			power-domains = <&gcc USB30_GDSC>;
 			status = "disabled";
 
-			dwc3@7600000 {
+			usb@7600000 {
 				compatible = "snps,dwc3";
 				reg = <0x07600000 0xcc00>;
 				interrupts = <0 138 IRQ_TYPE_LEVEL_HIGH>;
arch/arm64/boot/dts/qcom/msm8998.dtsi +1 -1
index ebdaaf1dfca4..1a7fb9d3ccab 100644
@@ -1678,7 +1678,7 @@ usb3: usb@a8f8800 {
 
 			resets = <&gcc GCC_USB_30_BCR>;
 
-			usb3_dwc3: dwc3@a800000 {
+			usb3_dwc3: usb@a800000 {
 				compatible = "snps,dwc3";
 				reg = <0x0a800000 0xcd00>;
 				interrupts = <GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>;
arch/arm64/boot/dts/qcom/qcs404-evb.dtsi +1 -1
index a80c578484ba..f8a55307b855 100644
@@ -337,7 +337,7 @@ &usb2_phy_sec {
 &usb3 {
 	status = "okay";
 
-	dwc3@7580000 {
+	usb@7580000 {
 		dr_mode = "host";
 	};
 };
arch/arm64/boot/dts/qcom/qcs404.dtsi +2 -2
index 339790ba585d..9c4be020d568 100644
@@ -544,7 +544,7 @@ usb3: usb@7678800 {
 			assigned-clock-rates = <19200000>, <200000000>;
 			status = "disabled";
 
-			dwc3@7580000 {
+			usb@7580000 {
 				compatible = "snps,dwc3";
 				reg = <0x07580000 0xcd00>;
 				interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>;
@@ -573,7 +573,7 @@ usb2: usb@79b8800 {
 			assigned-clock-rates = <19200000>, <133333333>;
 			status = "disabled";
 
-			dwc3@78c0000 {
+			usb@78c0000 {
 				compatible = "snps,dwc3";
 				reg = <0x078c0000 0xcc00>;
 				interrupts = <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>;
arch/arm64/boot/dts/qcom/sc7180.dtsi +1 -1
index 22b832fc62e3..347a98ba12e0 100644
@@ -2855,7 +2855,7 @@ usb_1: usb@a6f8800 {
 					<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_USB3 0>;
 			interconnect-names = "usb-ddr", "apps-usb";
 
-			usb_1_dwc3: dwc3@a600000 {
+			usb_1_dwc3: usb@a600000 {
 				compatible = "snps,dwc3";
 				reg = <0 0x0a600000 0 0xe000>;
 				interrupts = <GIC_SPI 133 IRQ_TYPE_LEVEL_HIGH>;
arch/arm64/boot/dts/qcom/sdm845.dtsi +2 -2
index bcf888381f14..2133e58776d1 100644
@@ -3771,7 +3771,7 @@ usb_1: usb@a6f8800 {
 					<&gladiator_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_USB3_0 0>;
 			interconnect-names = "usb-ddr", "apps-usb";
 
-			usb_1_dwc3: dwc3@a600000 {
+			usb_1_dwc3: usb@a600000 {
 				compatible = "snps,dwc3";
 				reg = <0 0x0a600000 0 0xcd00>;
 				interrupts = <GIC_SPI 133 IRQ_TYPE_LEVEL_HIGH>;
@@ -3819,7 +3819,7 @@ usb_2: usb@a8f8800 {
 					<&gladiator_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_USB3_1 0>;
 			interconnect-names = "usb-ddr", "apps-usb";
 
-			usb_2_dwc3: dwc3@a800000 {
+			usb_2_dwc3: usb@a800000 {
 				compatible = "snps,dwc3";
 				reg = <0 0x0a800000 0 0xcd00>;
 				interrupts = <GIC_SPI 138 IRQ_TYPE_LEVEL_HIGH>;
arch/arm64/boot/dts/qcom/sm8150.dtsi +1 -1
index 5270bda7418f..45007621e09c 100644
@@ -1562,7 +1562,7 @@ usb_1: usb@a6f8800 {
 
 			resets = <&gcc GCC_USB30_PRIM_BCR>;
 
-			usb_1_dwc3: dwc3@a600000 {
+			usb_1_dwc3: usb@a600000 {
 				compatible = "snps,dwc3";
 				reg = <0 0x0a600000 0 0xcd00>;
 				interrupts = <GIC_SPI 133 IRQ_TYPE_LEVEL_HIGH>;
Signature · 1 line
2.30.0
#3 lore raw
In reply to Serge Semin

Bjorn, Greg, Felippe, Andy,
Any comments on this series? Bjorn, Greg you asked me to resend the patches related with the DW USB3 node name change. I did as you said, but no news since then. I'd be glad to have this patch accepted in some -next repo and forget about it.

-Sergey

Quoted 52 lines · Serge Semin

of_get_child_by_name() increments the reference counter of the OF node it managed to find. So after the code is done using the device node, the refcount must be decremented. Add missing of_node_put() invocation then to the dwc3_qcom_of_register_core() method, since DWC3 OF node is being used only there.

Fixes a4333c3a6ba9 ("usb: dwc3: Add Qualcomm DWC3 glue driver")

---

Note the patch will get cleanly applied on the commit 2bc02355f8ba ("usb:
dwc3: qcom: Add support for booting with ACPI"), while the bug has been there since the Qualcomm DWC3 glue driver was submitted.

Changelog v7:
- This is a new patch. Please drop it If I missed something and the OF node refcount decrement wasn't supposed to be there.

---
 drivers/usb/dwc3/dwc3-qcom.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/usb/dwc3/dwc3-qcom.c +6 -3
index c703d552bbcf..3564d00cdce3 100644
@@ -639,16 +639,19 @@ static int dwc3_qcom_of_register_core(struct platform_device *pdev)
 	ret = of_platform_populate(np, NULL, NULL, dev);
 	if (ret) {
 		dev_err(dev, "failed to register dwc3 core - %d\n", ret);
-		return ret;
+		goto node_put;
 	}
 
 	qcom->dwc3 = of_find_device_by_node(dwc3_np);
 	if (!qcom->dwc3) {
+		ret = -ENODEV;
 		dev_err(dev, "failed to get dwc3 platform device\n");
-		return -ENODEV;
 	}
 
-	return 0;
+node_put:
+	of_node_put(dwc3_np);
+
+	return ret;
 }
 
 static int dwc3_qcom_probe(struct platform_device *pdev)
Signature · 1 line
2.30.0
#4 lore raw
Quoted 5 lines · Serge Semin

Bjorn, Greg, Felippe, Andy,
Any comments on this series? Bjorn, Greg you asked me to resend the patches related with the DW USB3 node name change. I did as you said, but no news since then. I'd be glad to have this patch accepted in some -next repo and forget about it.

Sorry, but it's the merge window right now and I can't add anything new until 5.12-rc1 is out. So can you wait until then?

thanks,

greg k-h

#5 lore raw
Quoted 10 lines · Greg Kroah-Hartman
Quoted 5 lines · Serge Semin

Bjorn, Greg, Felippe, Andy,
Any comments on this series? Bjorn, Greg you asked me to resend the patches related with the DW USB3 node name change. I did as you said, but no news since then. I'd be glad to have this patch accepted in some -next repo and forget about it.

Sorry, but it's the merge window right now and I can't add anything new until 5.12-rc1 is out. So can you wait until then?

Well, I don't think there is another choice but to wait now.) Hopefully the patchset won't be forgotten when the merge window closes as that happened with the original series...

-Sergey

Quoted 4 lines

thanks,

greg k-h

#6 lore raw
Quoted 9 lines · Serge Semin
Quoted 7 lines · Greg Kroah-Hartman
Quoted 5 lines · Serge Semin

Bjorn, Greg, Felippe, Andy,
Any comments on this series? Bjorn, Greg you asked me to resend the patches related with the DW USB3 node name change. I did as you said, but no news since then. I'd be glad to have this patch accepted in some -next repo and forget about it.

Quoted 6 lines
Quoted 2 lines

Sorry, but it's the merge window right now and I can't add anything new until 5.12-rc1 is out. So can you wait until then?

Well, I don't think there is another choice but to wait now.) Hopefully the patchset won't be forgotten when the merge window closes as that happened with the original series...

Can you resend this if still needed? I don't see them in my queue...

thanks,

greg k-h

#7 lore raw

Hi Greg,

Quoted 13 lines · Greg Kroah-Hartman
Quoted 12 lines · Serge Semin
Quoted 10 lines · Greg Kroah-Hartman
Quoted 5 lines · Serge Semin

Bjorn, Greg, Felippe, Andy,
Any comments on this series? Bjorn, Greg you asked me to resend the patches related with the DW USB3 node name change. I did as you said, but no news since then. I'd be glad to have this patch accepted in some -next repo and forget about it.

Sorry, but it's the merge window right now and I can't add anything new until 5.12-rc1 is out. So can you wait until then?

Quoted 6 lines
Quoted 3 lines

Well, I don't think there is another choice but to wait now.) Hopefully the patchset won't be forgotten when the merge window closes as that happened with the original series...

Can you resend this if still needed? I don't see them in my queue...

I see the very first patch of this series has already been merged in somewhere between v5.12-rc3 and v5.12-rc2. See commit 1cffb1c66499 ("usb:
dwc3: qcom: Add missing DWC3 OF node refcount decrement"). But the rest of the patches still hanging up unattended. I'll resend them in a few minutes. Could you merge them in too?

-Sergey

Quoted 4 lines

thanks,

greg k-h

#8 lore raw
Quoted 21 lines · Serge Semin

Hi Greg,

Quoted 17 lines · Greg Kroah-Hartman
Quoted 15 lines · Serge Semin
Quoted 10 lines · Greg Kroah-Hartman
Quoted 5 lines · Serge Semin

Bjorn, Greg, Felippe, Andy,
Any comments on this series? Bjorn, Greg you asked me to resend the patches related with the DW USB3 node name change. I did as you said, but no news since then. I'd be glad to have this patch accepted in some -next repo and forget about it.

Sorry, but it's the merge window right now and I can't add anything new until 5.12-rc1 is out. So can you wait until then?

Well, I don't think there is another choice but to wait now.) Hopefully the patchset won't be forgotten when the merge window closes as that happened with the original series...

Quoted 7 lines
Quoted 1 line

Can you resend this if still needed? I don't see them in my queue...

I see the very first patch of this series has already been merged in somewhere between v5.12-rc3 and v5.12-rc2. See commit 1cffb1c66499 ("usb:
dwc3: qcom: Add missing DWC3 OF node refcount decrement"). But the rest of the patches still hanging up unattended. I'll resend them in a few minutes. Could you merge them in too?

Do you have a lore.kernel.org link to your resend, I don't see it...

thanks,

greg k-h

#9 lore raw
Quoted 24 lines · Greg Kroah-Hartman
Quoted 23 lines · Serge Semin

Hi Greg,

Quoted 19 lines · Greg Kroah-Hartman
Quoted 9 lines · Serge Semin
Quoted 7 lines · Greg Kroah-Hartman
Quoted 5 lines · Serge Semin

Bjorn, Greg, Felippe, Andy,
Any comments on this series? Bjorn, Greg you asked me to resend the patches related with the DW USB3 node name change. I did as you said, but no news since then. I'd be glad to have this patch accepted in some -next repo and forget about it.

Quoted 6 lines
Quoted 2 lines

Sorry, but it's the merge window right now and I can't add anything new until 5.12-rc1 is out. So can you wait until then?

Well, I don't think there is another choice but to wait now.) Hopefully the patchset won't be forgotten when the merge window closes as that happened with the original series...

Can you resend this if still needed? I don't see them in my queue...

Quoted 8 lines
Quoted 5 lines

I see the very first patch of this series has already been merged in somewhere between v5.12-rc3 and v5.12-rc2. See commit 1cffb1c66499 ("usb:
dwc3: qcom: Add missing DWC3 OF node refcount decrement"). But the rest of the patches still hanging up unattended. I'll resend them in a few minutes. Could you merge them in too?

Do you have a lore.kernel.org link to your resend, I don't see it...

I've got the rest two patches back to the main series and resent it two days ago:
https://lore.kernel.org/lkml/[email protected]/
See the last two patches there.

They have been part of the main series from the very first time I submitted it. But two months ago Bjorn asked me to detach Qcom-related ones and resubmit to take into account his comment. Since then I didn't hear any new update neither on these three patches nor on the main series except you merging in the very first Qcom-related patch (usb: dwc3: qcom: Add missing DWC3 OF node refcount decrement). Since even being detached the patches left unattended I've decided to combine them back to ease the re-submission process.

Note the patchset has been re-submitting for about five months already with no comments for the last three versions.

-Sergey

Quoted 4 lines

thanks,

greg k-h