[LEDE-DEV] [PATCH v2] ipq8064: fix dwc3-of-simple module unloading for Netgear R7500

Thomas Reifferscheid thomas at reifferscheid.org
Sun Apr 2 15:34:34 PDT 2017


Without patch unloading the dwc3-of-simple module went stuck after
successfully removing hcd.1 during the hcd.0 removal:

root at LEDE:/# rmmod dwc3-of-simple
[   21.391846] xhci-hcd xhci-hcd.1.auto: remove, state 1
[   21.391931] usb usb4: USB disconnect, device number 1
[   21.397038] xhci-hcd xhci-hcd.1.auto: USB bus 4 deregistered
[   21.401111] xhci-hcd xhci-hcd.1.auto: remove, state 1
[   21.406685] usb usb3: USB disconnect, device number 1
[   21.412848] xhci-hcd xhci-hcd.1.auto: USB bus 3 deregistered
[   21.417248] xhci-hcd xhci-hcd.0.auto: remove, state 1
[   21.422521] usb usb2: USB disconnect, device number 1
followed by nothing.

Sometimes a stall CPU was detected, or a kernel panic,
or a reboot occurred after a couple of minutes.

At the same time unloading the dwc3 module followed by dwc3-of-simple
module was working repeatedly.

root at LEDE:/# rmmod dwc3
[   53.827328] xhci-hcd xhci-hcd.1.auto: remove, state 1
[   53.827412] usb usb4: USB disconnect, device number 1
[   53.832630] xhci-hcd xhci-hcd.1.auto: USB bus 4 deregistered
[   53.836452] xhci-hcd xhci-hcd.1.auto: remove, state 1
[   53.842314] usb usb3: USB disconnect, device number 1
[   53.848412] xhci-hcd xhci-hcd.1.auto: USB bus 3 deregistered
[   53.852542] xhci-hcd xhci-hcd.0.auto: remove, state 1
[   53.857882] usb usb2: USB disconnect, device number 1
[   53.863956] xhci-hcd xhci-hcd.0.auto: USB bus 2 deregistered
[   53.867875] xhci-hcd xhci-hcd.0.auto: remove, state 1
[   53.873696] usb usb1: USB disconnect, device number 1
[   53.879742] xhci-hcd xhci-hcd.0.auto: USB bus 1 deregistered
root at LEDE:/# rmmod dwc3-of-simple
root at LEDE:/#

For the non-working case, the code was stuck in a readl() in
http://lxr.free-electrons.com/source/drivers/usb/host/xhci.c#L91
because
http://lxr.free-electrons.com/source/drivers/usb/dwc3/dwc3-of-simple.c#L126
was disabling the wrong clocks when removing hcd.1 (it was disabling
the clock of hcd.0). That's why the readl() went stuck when removing
hcd.0

The patch however addresses the clock assignment from the Netgear R7500
dts file and backs off the previous attempt.

Now unloading and repeated module loading is working just fine.

root at LEDE:/# rmmod dwc3-of-simple
[   24.089679] xhci-hcd xhci-hcd.1.auto: remove, state 1
[   24.089765] usb usb4: USB disconnect, device number 1
[   24.094856] xhci-hcd xhci-hcd.1.auto: USB bus 4 deregistered
[   24.098963] xhci-hcd xhci-hcd.1.auto: remove, state 1
[   24.104522] usb usb3: USB disconnect, device number 1
[   24.111194] xhci-hcd xhci-hcd.1.auto: USB bus 3 deregistered
[   24.115086] xhci-hcd xhci-hcd.0.auto: remove, state 1
[   24.120396] usb usb2: USB disconnect, device number 1
[   24.126503] xhci-hcd xhci-hcd.0.auto: USB bus 2 deregistered
[   24.130347] xhci-hcd xhci-hcd.0.auto: remove, state 1
[   24.135948] usb usb1: USB disconnect, device number 1
[   24.142085] xhci-hcd xhci-hcd.0.auto: USB bus 1 deregistered
root at LEDE:/#

Fixes: dwc3-of-simple module unloading for Netgear R7500

Signed-off-by: Thomas Reifferscheid <thomas at reifferscheid.org>
---

Changes since v1:

 * back off 17f60b1cd260a24ef990d6622f9c5ed6951c0722
 * adjust clock assignment in R7500.dts instead

 .../arch/arm/boot/dts/qcom-ipq8064-r7500.dts       |  6 +++++
 .../files-4.9/arch/arm/boot/dts/qcom-ipq8064.dtsi  | 28 +++++++++++-----------
 2 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/target/linux/ipq806x/files-4.9/arch/arm/boot/dts/qcom-ipq8064-r7500.dts b/target/linux/ipq806x/files-4.9/arch/arm/boot/dts/qcom-ipq8064-r7500.dts
index b31f34c..2ea856d 100644
--- a/target/linux/ipq806x/files-4.9/arch/arm/boot/dts/qcom-ipq8064-r7500.dts
+++ b/target/linux/ipq806x/files-4.9/arch/arm/boot/dts/qcom-ipq8064-r7500.dts
@@ -133,26 +133,32 @@
 		};
 
 		phy at 100f8800 {		/* USB3 port 1 HS phy */
+			clocks = <&gcc USB30_0_UTMI_CLK>;
 			status = "ok";
 		};
 
 		phy at 100f8830 {		/* USB3 port 1 SS phy */
+			clocks = <&gcc USB30_0_MASTER_CLK>;
 			status = "ok";
 		};
 
 		phy at 110f8800 {		/* USB3 port 0 HS phy */
+			clocks = <&gcc USB30_1_UTMI_CLK>;
 			status = "ok";
 		};
 
 		phy at 110f8830 {		/* USB3 port 0 SS phy */
+			clocks = <&gcc USB30_1_MASTER_CLK>;
 			status = "ok";
 		};
 
 		usb30 at 0 {
+			clocks = <&gcc USB30_1_MASTER_CLK>;
 			status = "ok";
 		};
 
 		usb30 at 1 {
+			clocks = <&gcc USB30_0_MASTER_CLK>;
 			status = "ok";
 		};
 
diff --git a/target/linux/ipq806x/files-4.9/arch/arm/boot/dts/qcom-ipq8064.dtsi b/target/linux/ipq806x/files-4.9/arch/arm/boot/dts/qcom-ipq8064.dtsi
index 296e7ba..9996bd7 100644
--- a/target/linux/ipq806x/files-4.9/arch/arm/boot/dts/qcom-ipq8064.dtsi
+++ b/target/linux/ipq806x/files-4.9/arch/arm/boot/dts/qcom-ipq8064.dtsi
@@ -918,9 +918,9 @@
 			reg = <0x01200600 0x100>;
 		};
 
-		hs_phy_1: phy at 110f8800 {
+		hs_phy_1: phy at 100f8800 {
 			compatible = "qcom,dwc3-hs-usb-phy";
-			reg = <0x110f8800 0x30>;
+			reg = <0x100f8800 0x30>;
 			clocks = <&gcc USB30_1_UTMI_CLK>;
 			clock-names = "ref";
 			#phy-cells = <0>;
@@ -928,9 +928,9 @@
 			status = "disabled";
 		};
 
-		ss_phy_1: phy at 110f8830 {
+		ss_phy_1: phy at 100f8830 {
 			compatible = "qcom,dwc3-ss-usb-phy";
-			reg = <0x110f8830 0x30>;
+			reg = <0x100f8830 0x30>;
 			clocks = <&gcc USB30_1_MASTER_CLK>;
 			clock-names = "ref";
 			#phy-cells = <0>;
@@ -938,9 +938,9 @@
 			status = "disabled";
 		};
 
-		hs_phy_0: phy at 100f8800 {
+		hs_phy_0: phy at 110f8800 {
 			compatible = "qcom,dwc3-hs-usb-phy";
-			reg = <0x100f8800 0x30>;
+			reg = <0x110f8800 0x30>;
 			clocks = <&gcc USB30_0_UTMI_CLK>;
 			clock-names = "ref";
 			#phy-cells = <0>;
@@ -948,9 +948,9 @@
 			status = "disabled";
 		};
 
-		ss_phy_0: phy at 100f8830 {
+		ss_phy_0: phy at 110f8830 {
 			compatible = "qcom,dwc3-ss-usb-phy";
-			reg = <0x100f8830 0x30>;
+			reg = <0x110f8830 0x30>;
 			clocks = <&gcc USB30_0_MASTER_CLK>;
 			clock-names = "ref";
 			#phy-cells = <0>;
@@ -969,10 +969,10 @@
 
 			status = "disabled";
 
-			dwc3 at 10000000 {
+			dwc3 at 11000000 {
 				compatible = "snps,dwc3";
-				reg = <0x10000000 0xcd00>;
-				interrupts = <0 205 0x4>;
+				reg = <0x11000000 0xcd00>;
+				interrupts = <0 110 0x4>;
 				phys = <&hs_phy_0>, <&ss_phy_0>;
 				phy-names = "usb2-phy", "usb3-phy";
 				dr_mode = "host";
@@ -991,10 +991,10 @@
 
 			status = "disabled";
 
-			dwc3 at 11000000 {
+			dwc3 at 10000000 {
 				compatible = "snps,dwc3";
-				reg = <0x11000000 0xcd00>;
-				interrupts = <0 110 0x4>;
+				reg = <0x10000000 0xcd00>;
+				interrupts = <0 205 0x4>;
 				phys = <&hs_phy_1>, <&ss_phy_1>;
 				phy-names = "usb2-phy", "usb3-phy";
 				dr_mode = "host";
-- 
2.1.4




More information about the Lede-dev mailing list