Skip to contentSkip to conversation

ARM: mvebu: fix usb on Linksys Caiman

PATCH New Patrick Uiterwijk 4 participants 9 messages Mar 29, 2016

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

PATCH 1/1 ARM: mvebu: fix usb on Linksys Caiman

Hi,

These patches fix the USB ports on Linksys Caiman (WRT1200AC) on 4.6rc1. After a lot of trial and error, I found out that if there's any unit with name "usb at 58000" defined, none of the USB ports work, but if I change it to anything else, the USB3 port comes up. And if I then also bring the linksys.dtsi unit name in sync (and different from USB at 58000), the USB2 port also comes up.

I can change it to literally anything else: nonsense at 58000 and usb at 58001 work, it's only usb at 58000 that doesn't work as far as I have found. Since the ehci-orion documentation gives the example of ehci at 50000, I just brought all of the Orion EHCI device tree definitions in sync with this.

#1 lore raw

PATCH 1/2 ARM: mvebu: correct the usb node name from usb@ to ehci@

According to Documentation/devicetree/bindings/usb/ehci-orion.txt, the Orion Marvell variant of EHCI controllers should have names ehci at 50000 for example.

---
 arch/arm/boot/dts/armada-370-db.dts                      | 4 ++--
 arch/arm/boot/dts/armada-370-dlink-dns327l.dts           | 2 +-
 arch/arm/boot/dts/armada-370-mirabox.dts                 | 4 ++--
 arch/arm/boot/dts/armada-370-netgear-rn102.dts           | 2 +-
 arch/arm/boot/dts/armada-370-netgear-rn104.dts           | 2 +-
 arch/arm/boot/dts/armada-370-rd.dts                      | 4 ++--
 arch/arm/boot/dts/armada-370-seagate-personal-cloud.dtsi | 2 +-
 arch/arm/boot/dts/armada-370-synology-ds213j.dts         | 4 ++--
 arch/arm/boot/dts/armada-370-xp.dtsi                     | 4 ++--
 arch/arm/boot/dts/armada-370.dtsi                        | 4 ++--
 arch/arm/boot/dts/armada-375-db.dts                      | 2 +-
 arch/arm/boot/dts/armada-375.dtsi                        | 4 ++--
 arch/arm/boot/dts/armada-385-linksys.dtsi                | 2 +-
 arch/arm/boot/dts/armada-388-clearfog.dts                | 2 +-
 arch/arm/boot/dts/armada-388-db.dts                      | 2 +-
 arch/arm/boot/dts/armada-388-gp.dts                      | 2 +-
 arch/arm/boot/dts/armada-38x.dtsi                        | 2 +-
 arch/arm/boot/dts/armada-xp-db.dts                       | 6 +++---
 arch/arm/boot/dts/armada-xp-gp.dts                       | 4 ++--
 arch/arm/boot/dts/armada-xp-lenovo-ix4-300d.dts          | 4 ++--
 arch/arm/boot/dts/armada-xp-linksys-mamba.dts            | 2 +-
 arch/arm/boot/dts/armada-xp-matrix.dts                   | 2 +-
 arch/arm/boot/dts/armada-xp-netgear-rn2120.dts           | 2 +-
 arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts         | 4 ++--
 arch/arm/boot/dts/armada-xp-synology-ds414.dts           | 2 +-
 arch/arm/boot/dts/armada-xp.dtsi                         | 2 +-
 26 files changed, 38 insertions(+), 38 deletions(-)
arch/arm/boot/dts/armada-370-db.dts +2 -2
index 2364fc5..4d50030 100644
@@ -147,11 +147,11 @@
 				broken-cd;
 			};
 
-			usb at 50000 {
+			ehci at 50000 {
 				status = "okay";
 			};
 
-			usb at 51000 {
+			ehci at 51000 {
 				status = "okay";
 			};
 
arch/arm/boot/dts/armada-370-dlink-dns327l.dts +1 -1
index e2a363b..6695653 100644
@@ -92,7 +92,7 @@
 				status = "okay";
 			};
 
-			usb at 50000 {
+			ehci at 50000 {
 				status = "okay";
 			};
 
arch/arm/boot/dts/armada-370-mirabox.dts +2 -2
index d5e19cd..3fbbc13 100644
@@ -154,11 +154,11 @@
 				 broken-cd;
 			};
 
-			usb at 50000 {
+			ehci at 50000 {
 				status = "okay";
 			};
 
-			usb at 51000 {
+			ehci at 51000 {
 				status = "okay";
 			};
 
arch/arm/boot/dts/armada-370-netgear-rn102.dts +1 -1
index 39181b3..a368e0e 100644
@@ -115,7 +115,7 @@
 				phy-mode = "rgmii-id";
 			};
 
-			usb at 50000 {
+			ehci at 50000 {
 				status = "okay";
 			};
 
arch/arm/boot/dts/armada-370-netgear-rn104.dts +1 -1
index 1156575..99c87ea 100644
@@ -121,7 +121,7 @@
 				phy-mode = "rgmii-id";
 			};
 
-			usb at 50000 {
+			ehci at 50000 {
 				status = "okay";
 			};
 
arch/arm/boot/dts/armada-370-rd.dts +2 -2
index fbef730..86f4fa8 100644
@@ -134,11 +134,11 @@
 				broken-cd;
 			};
 
-			usb at 50000 {
+			ehci at 50000 {
 				status = "okay";
 			};
 
-			usb at 51000 {
+			ehci at 51000 {
 				status = "okay";
 			};
 
arch/arm/boot/dts/armada-370-seagate-personal-cloud.dtsi +1 -1
index 1aba08e..344fe32 100644
@@ -88,7 +88,7 @@
 				};
 			};
 
-			usb at 50000 {
+			ehci at 50000 {
 				status = "okay";
 			};
 		};
arch/arm/boot/dts/armada-370-synology-ds213j.dts +2 -2
index 8ca7a43..f5e8950 100644
@@ -174,12 +174,12 @@
 			};
 
 			/* rear USB port, near reset button */
-			usb at 50000 {
+			ehci at 50000 {
 				status = "okay";
 			};
 
 			/* rear USB port, near RJ45 port */
-			usb at 51000 {
+			ehci at 51000 {
 				status = "okay";
 			};
 
arch/arm/boot/dts/armada-370-xp.dtsi +2 -2
index a718866..90a6eba 100644
@@ -253,14 +253,14 @@
 				reg = <0x22000 0x1000>;
 			};
 
-			usb at 50000 {
+			ehci at 50000 {
 				compatible = "marvell,orion-ehci";
 				reg = <0x50000 0x500>;
 				interrupts = <45>;
 				status = "disabled";
 			};
 
-			usb at 51000 {
+			ehci at 51000 {
 				compatible = "marvell,orion-ehci";
 				reg = <0x51000 0x500>;
 				interrupts = <46>;
arch/arm/boot/dts/armada-370.dtsi +2 -2
index 3b06aa8..47579c4 100644
@@ -271,11 +271,11 @@
 				status = "disabled";
 			};
 
-			usb at 50000 {
+			ehci at 50000 {
 				clocks = <&coreclk 0>;
 			};
 
-			usb at 51000 {
+			ehci at 51000 {
 				clocks = <&coreclk 0>;
 			};
 
arch/arm/boot/dts/armada-375-db.dts +1 -1
index cded5f0..d2a19a1 100644
@@ -144,7 +144,7 @@
 				};
 			};
 
-			usb at 54000 {
+			ehci at 54000 {
 				status = "okay";
 			};
 
arch/arm/boot/dts/armada-375.dtsi +2 -2
index cc952cf..1d61dff 100644
@@ -445,7 +445,7 @@
 				reg = <0x21010 0x1c>;
 			};
 
-			usb at 50000 {
+			ehci at 50000 {
 				compatible = "marvell,orion-ehci";
 				reg = <0x50000 0x500>;
 				interrupts = <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
@@ -455,7 +455,7 @@
 				status = "disabled";
 			};
 
-			usb at 54000 {
+			ehci at 54000 {
 				compatible = "marvell,orion-ehci";
 				reg = <0x54000 0x500>;
 				interrupts = <GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>;
arch/arm/boot/dts/armada-385-linksys.dtsi +1 -1
index 3710755..b328d94 100644
@@ -117,7 +117,7 @@
 			};
 
 			/* USB part of the eSATA/USB 2.0 port */
-			usb at 50000 {
+			ehci at 50000 {
 				status = "okay";
 			};
 
arch/arm/boot/dts/armada-388-clearfog.dts +1 -1
index c60206e..5ea8c67 100644
@@ -355,7 +355,7 @@
 				};
 			};
 
-			usb at 58000 {
+			ehci at 58000 {
 				/* CON3, nearest  power. */
 				status = "okay";
 			};
arch/arm/boot/dts/armada-388-db.dts +1 -1
index ea93ed7..e25bead 100644
@@ -105,7 +105,7 @@
 				bm,pool-short = <3>;
 			};
 
-			usb at 58000 {
+			ehci at 58000 {
 				status = "ok";
 			};
 
arch/arm/boot/dts/armada-388-gp.dts +1 -1
index fd75e5e..cafe2b2 100644
@@ -140,7 +140,7 @@
 			};
 
 			/* CON4 */
-			usb at 58000 {
+			ehci at 58000 {
 				vcc-supply = <&reg_usb2_0_vbus>;
 				status = "okay";
 			};
arch/arm/boot/dts/armada-38x.dtsi +1 -1
index 3312be6..7e881c0 100644
@@ -466,7 +466,7 @@
 				status = "disabled";
 			};
 
-			usb at 58000 {
+			ehci at 58000 {
 				compatible = "marvell,orion-ehci";
 				reg = <0x58000 0x500>;
 				interrupts = <GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>;
arch/arm/boot/dts/armada-xp-db.dts +3 -3
index 62422a9..0adc619 100644
@@ -219,15 +219,15 @@
 				broken-cd;
 			};
 
-			usb at 50000 {
+			ehci at 50000 {
 				status = "okay";
 			};
 
-			usb at 51000 {
+			ehci at 51000 {
 				status = "okay";
 			};
 
-			usb at 52000 {
+			ehci at 52000 {
 				status = "okay";
 			};
 
arch/arm/boot/dts/armada-xp-gp.dts +2 -2
index 061f423..776de1f 100644
@@ -223,12 +223,12 @@
 			};
 
 			/* Front-side USB slot */
-			usb at 50000 {
+			ehci at 50000 {
 				status = "okay";
 			};
 
 			/* Back-side USB slot */
-			usb at 51000 {
+			ehci at 51000 {
 				status = "okay";
 			};
 
arch/arm/boot/dts/armada-xp-lenovo-ix4-300d.dts +2 -2
index 8af463f..42b9000 100644
@@ -115,11 +115,11 @@
 				phy-mode = "rgmii-id";
 			};
 
-			usb at 50000 {
+			ehci at 50000 {
 				status = "okay";
 			};
 
-			usb at 51000 {
+			ehci at 51000 {
 				status = "okay";
 			};
 
arch/arm/boot/dts/armada-xp-linksys-mamba.dts +1 -1
index b89e6cf..f19f2fe 100644
@@ -135,7 +135,7 @@
 			};
 
 			/* USB part of the eSATA/USB 2.0 port */
-			usb at 50000 {
+			ehci at 50000 {
 				status = "okay";
 			};
 
arch/arm/boot/dts/armada-xp-matrix.dts +1 -1
index 6522b04..dedd100 100644
@@ -108,7 +108,7 @@
 				};
 			};
 
-			usb at 50000 {
+			ehci at 50000 {
 				status = "okay";
 			};
 		};
arch/arm/boot/dts/armada-xp-netgear-rn2120.dts +1 -1
index d19f44c..2d7160e 100644
@@ -150,7 +150,7 @@
 			};
 
 			/* Front USB 2.0 port */
-			usb at 50000 {
+			ehci at 50000 {
 				status = "okay";
 			};
 
arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts +2 -2
index ed3b889d..586c880 100644
@@ -220,12 +220,12 @@
 			};
 
 			/* Front side USB 0 */
-			usb at 50000 {
+			ehci at 50000 {
 				status = "okay";
 			};
 
 			/* Front side USB 1 */
-			usb at 51000 {
+			ehci at 51000 {
 				status = "okay";
 			};
 
arch/arm/boot/dts/armada-xp-synology-ds414.dts +1 -1
index d17dab0..2707a96 100644
@@ -202,7 +202,7 @@
 			};
 
 			/* Front USB 2.0 port */
-			usb at 50000 {
+			ehci at 50000 {
 				status = "okay";
 			};
 
arch/arm/boot/dts/armada-xp.dtsi +1 -1
index 553349c..593682b 100644
@@ -205,7 +205,7 @@
 				clocks = <&gateclk 19>;
 			};
 
-			usb at 52000 {
+			ehci at 52000 {
 				compatible = "marvell,orion-ehci";
 				reg = <0x52000 0x500>;
 				interrupts = <47>;
Signature · 1 line
2.7.4
#2 lore raw

PATCH 1/2 ARM: mvebu: correct the usb node name from usb@ to ehci@

Quoted 6 lines · On Tuesday 29 March 2016 13:56:52 Patrick Uiterwijk wrote:

According to Documentation/devicetree/bindings/usb/ehci-orion.txt, the Orion Marvell variant of EHCI controllers should have names ehci at 50000 for example.

I think it's better to follow the generic USB binding that suggests the name of 'usb', unless we understand what the specific bug is you run into. Do you think it is the boot loader that messes up the hardware, or something in the kernel that goes wrong? Did it work on earlier kernels?

We had a regression based on the USB device probing, but that should be fixed now with the patch below. Do you have that?

Arnd

commit 7222c832254a75dcd67d683df75753d4a4e125bb

Author: Nicolai Stange <[email protected]>
Date:   Thu Mar 17 23:53:02 2016 +0100
    usb/core: usb_alloc_dev(): fix setting of ->portnum
    
    With commit 69bec7259853 ("USB: core: let USB device know device node"),
    the port1 argument of usb_alloc_dev() gets overwritten as follows:
    
      ... usb_alloc_dev(..., unsigned port1)
      {
        ...
        if (!parent->parent) {
          port1 = usb_hcd_find_raw_port_number(..., port1);
        }
        ...
      }
    
    Later on, this now overwritten port1 gets assigned to ->portnum:
    
      dev->portnum = port1;
    
    However, since xhci_find_raw_port_number() isn't idempotent, the
    aforementioned commit causes a number of KASAN splats like the following:
    
      BUG: KASAN: slab-out-of-bounds in xhci_find_raw_port_number+0x98/0x170
                                           at addr ffff8801d9311670
      Read of size 8 by task kworker/2:1/87
      [...]
      Workqueue: usb_hub_wq hub_event
       0000000000000188 000000005814b877 ffff8800cba17588 ffffffff8191447e
       0000000041b58ab3 ffffffff82a03209 ffffffff819143a2 ffffffff82a252f4
       ffff8801d93115e0 0000000000000188 ffff8801d9311628 ffff8800cba17588
      Call Trace:
       [<ffffffff8191447e>] dump_stack+0xdc/0x15e
       [<ffffffff819143a2>] ? _atomic_dec_and_lock+0xa2/0xa2
       [<ffffffff814e2cd1>] ? print_section+0x61/0xb0
       [<ffffffff814e4939>] print_trailer+0x179/0x2c0
       [<ffffffff814f0d84>] object_err+0x34/0x40
       [<ffffffff814f4388>] kasan_report_error+0x2f8/0x8b0
       [<ffffffff814eb91e>] ? __slab_alloc+0x5e/0x90
       [<ffffffff812178c0>] ? __lock_is_held+0x90/0x130
       [<ffffffff814f5091>] kasan_report+0x71/0xa0
       [<ffffffff814ec082>] ? kmem_cache_alloc_trace+0x212/0x560
       [<ffffffff81d99468>] ? xhci_find_raw_port_number+0x98/0x170
       [<ffffffff814f33d4>] __asan_load8+0x64/0x70
       [<ffffffff81d99468>] xhci_find_raw_port_number+0x98/0x170
       [<ffffffff81db0105>] xhci_setup_addressable_virt_dev+0x235/0xa10
       [<ffffffff81d9ea51>] xhci_setup_device+0x3c1/0x1430
       [<ffffffff8121cddd>] ? trace_hardirqs_on+0xd/0x10
       [<ffffffff81d9fac0>] ? xhci_setup_device+0x1430/0x1430
       [<ffffffff81d9fad3>] xhci_address_device+0x13/0x20
       [<ffffffff81d2081a>] hub_port_init+0x55a/0x1550
       [<ffffffff81d28705>] hub_event+0xef5/0x24d0
       [<ffffffff81d27810>] ? hub_port_debounce+0x2f0/0x2f0
       [<ffffffff8195e1ee>] ? debug_object_deactivate+0x1be/0x270
       [<ffffffff81210203>] ? print_rt_rq+0x53/0x2d0
       [<ffffffff8121657d>] ? trace_hardirqs_off+0xd/0x10
       [<ffffffff8226acfb>] ? _raw_spin_unlock_irqrestore+0x5b/0x60
       [<ffffffff81250000>] ? irq_domain_set_hwirq_and_chip+0x30/0xb0
       [<ffffffff81256339>] ? debug_lockdep_rcu_enabled+0x39/0x40
       [<ffffffff812178c0>] ? __lock_is_held+0x90/0x130
       [<ffffffff81196877>] process_one_work+0x567/0xec0
      [...]
    
    Afterwards, xhci reports some functional errors:
    
      xhci_hcd 0000:00:14.0: ERROR: unexpected setup address command completion
                                    code 0x11.
      xhci_hcd 0000:00:14.0: ERROR: unexpected setup address command completion
                                    code 0x11.
      usb 4-3: device not accepting address 2, error -22
    
    Fix this by not overwriting the port1 argument in usb_alloc_dev(), but
    storing the raw port number as required by OF in an additional variable,
    raw_port.
    
    Fixes: 69bec7259853 ("USB: core: let USB device know device node")
    Signed-off-by: Nicolai Stange <[email protected]>
    Acked-by: Alan Stern <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>
drivers/usb/core/usb.c +3 -2
index ffa5cf13ffe1..dcb85e3cd5a7 100644
@@ -424,6 +424,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
 	struct usb_device *dev;
 	struct usb_hcd *usb_hcd = bus_to_hcd(bus);
 	unsigned root_hub = 0;
+	unsigned raw_port = port1;
 
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev)
@@ -498,11 +499,11 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
 
 		if (!parent->parent) {
 			/* device under root hub's port */
-			port1 = usb_hcd_find_raw_port_number(usb_hcd,
+			raw_port = usb_hcd_find_raw_port_number(usb_hcd,
 				port1);
 		}
 		dev->dev.of_node = usb_of_get_child_node(parent->dev.of_node,
-				port1);
+				raw_port);
 
 		/* hub driver sets up TT records */
 	}
#3 lore raw

PATCH 1/2 ARM: mvebu: correct the usb node name from usb@ to ehci@

Hi Arnd,

Quoted 5 lines · Arnd Bergmann
Quoted 4 lines · On Tuesday 29 March 2016 13:56:52 Patrick Uiterwijk wrote:

According to Documentation/devicetree/bindings/usb/ehci-orion.txt, the Orion Marvell variant of EHCI controllers should have names ehci at 50000 for example.

Quoted 9 lines
Quoted 2 lines

I think it's better to follow the generic USB binding that suggests the name of 'usb', unless we understand what the specific bug is you run into. Do you think it is the boot loader that messes up the hardware, or something in the kernel that goes wrong? Did it work on earlier kernels?

I am pretty sure that this issue is caused by the Marvell U-Boot which tries to modify the dts on the fly. But the device tree reference of this U-boot is not the one we use in mainline, so at end it mess up the dtb!

There is an option to ask Marvell bootloader to not modify the dts, I think it is something like ftd_skip.

Gregory

Quoted 115 lines

We had a regression based on the USB device probing, but that should be fixed now with the patch below. Do you have that?

Arnd

commit 7222c832254a75dcd67d683df75753d4a4e125bb

Author: Nicolai Stange <[email protected]>
Date:   Thu Mar 17 23:53:02 2016 +0100
    usb/core: usb_alloc_dev(): fix setting of ->portnum
    
    With commit 69bec7259853 ("USB: core: let USB device know device node"),
    the port1 argument of usb_alloc_dev() gets overwritten as follows:
    
      ... usb_alloc_dev(..., unsigned port1)
      {
        ...
        if (!parent->parent) {
          port1 = usb_hcd_find_raw_port_number(..., port1);
        }
        ...
      }
    
    Later on, this now overwritten port1 gets assigned to ->portnum:
    
      dev->portnum = port1;
    
    However, since xhci_find_raw_port_number() isn't idempotent, the
    aforementioned commit causes a number of KASAN splats like the following:
    
      BUG: KASAN: slab-out-of-bounds in xhci_find_raw_port_number+0x98/0x170
                                           at addr ffff8801d9311670
      Read of size 8 by task kworker/2:1/87
      [...]
      Workqueue: usb_hub_wq hub_event
       0000000000000188 000000005814b877 ffff8800cba17588 ffffffff8191447e
       0000000041b58ab3 ffffffff82a03209 ffffffff819143a2 ffffffff82a252f4
       ffff8801d93115e0 0000000000000188 ffff8801d9311628 ffff8800cba17588
      Call Trace:
       [<ffffffff8191447e>] dump_stack+0xdc/0x15e
       [<ffffffff819143a2>] ? _atomic_dec_and_lock+0xa2/0xa2
       [<ffffffff814e2cd1>] ? print_section+0x61/0xb0
       [<ffffffff814e4939>] print_trailer+0x179/0x2c0
       [<ffffffff814f0d84>] object_err+0x34/0x40
       [<ffffffff814f4388>] kasan_report_error+0x2f8/0x8b0
       [<ffffffff814eb91e>] ? __slab_alloc+0x5e/0x90
       [<ffffffff812178c0>] ? __lock_is_held+0x90/0x130
       [<ffffffff814f5091>] kasan_report+0x71/0xa0
       [<ffffffff814ec082>] ? kmem_cache_alloc_trace+0x212/0x560
       [<ffffffff81d99468>] ? xhci_find_raw_port_number+0x98/0x170
       [<ffffffff814f33d4>] __asan_load8+0x64/0x70
       [<ffffffff81d99468>] xhci_find_raw_port_number+0x98/0x170
       [<ffffffff81db0105>] xhci_setup_addressable_virt_dev+0x235/0xa10
       [<ffffffff81d9ea51>] xhci_setup_device+0x3c1/0x1430
       [<ffffffff8121cddd>] ? trace_hardirqs_on+0xd/0x10
       [<ffffffff81d9fac0>] ? xhci_setup_device+0x1430/0x1430
       [<ffffffff81d9fad3>] xhci_address_device+0x13/0x20
       [<ffffffff81d2081a>] hub_port_init+0x55a/0x1550
       [<ffffffff81d28705>] hub_event+0xef5/0x24d0
       [<ffffffff81d27810>] ? hub_port_debounce+0x2f0/0x2f0
       [<ffffffff8195e1ee>] ? debug_object_deactivate+0x1be/0x270
       [<ffffffff81210203>] ? print_rt_rq+0x53/0x2d0
       [<ffffffff8121657d>] ? trace_hardirqs_off+0xd/0x10
       [<ffffffff8226acfb>] ? _raw_spin_unlock_irqrestore+0x5b/0x60
       [<ffffffff81250000>] ? irq_domain_set_hwirq_and_chip+0x30/0xb0
       [<ffffffff81256339>] ? debug_lockdep_rcu_enabled+0x39/0x40
       [<ffffffff812178c0>] ? __lock_is_held+0x90/0x130
       [<ffffffff81196877>] process_one_work+0x567/0xec0
      [...]
    
    Afterwards, xhci reports some functional errors:
    
      xhci_hcd 0000:00:14.0: ERROR: unexpected setup address command completion
                                    code 0x11.
      xhci_hcd 0000:00:14.0: ERROR: unexpected setup address command completion
                                    code 0x11.
      usb 4-3: device not accepting address 2, error -22
    
    Fix this by not overwriting the port1 argument in usb_alloc_dev(), but
    storing the raw port number as required by OF in an additional variable,
    raw_port.
    
    Fixes: 69bec7259853 ("USB: core: let USB device know device node")
    Signed-off-by: Nicolai Stange <[email protected]>
    Acked-by: Alan Stern <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>
drivers/usb/core/usb.c +3 -2
index ffa5cf13ffe1..dcb85e3cd5a7 100644
@@ -424,6 +424,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
 	struct usb_device *dev;
 	struct usb_hcd *usb_hcd = bus_to_hcd(bus);
 	unsigned root_hub = 0;
+	unsigned raw_port = port1;
 
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev)
@@ -498,11 +499,11 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
 
 		if (!parent->parent) {
 			/* device under root hub's port */
-			port1 = usb_hcd_find_raw_port_number(usb_hcd,
+			raw_port = usb_hcd_find_raw_port_number(usb_hcd,
 				port1);
 		}
 		dev->dev.of_node = usb_of_get_child_node(parent->dev.of_node,
-				port1);
+				raw_port);
 
 		/* hub driver sets up TT records */
 	}
Signature · 4 lines
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#4 lore raw

PATCH 1/2 ARM: mvebu: correct the usb node name from usb@ to ehci@

Quoted 19 lines · Gregory CLEMENT

Hi Arnd,

Quoted 5 lines · Arnd Bergmann
Quoted 4 lines · On Tuesday 29 March 2016 13:56:52 Patrick Uiterwijk wrote:

According to Documentation/devicetree/bindings/usb/ehci-orion.txt, the Orion Marvell variant of EHCI controllers should have names ehci at 50000 for example.

Quoted 9 lines
Quoted 2 lines

I think it's better to follow the generic USB binding that suggests the name of 'usb', unless we understand what the specific bug is you run into. Do you think it is the boot loader that messes up the hardware, or something in the kernel that goes wrong? Did it work on earlier kernels?

Quoted 7 lines

I am pretty sure that this issue is caused by the Marvell U-Boot which tries to modify the dts on the fly. But the device tree reference of this U-boot is not the one we use in mainline, so at end it mess up the dtb!

There is an option to ask Marvell bootloader to not modify the dts, I think it is something like ftd_skip.

Thank you for this pointer, setting fdt_skip_update no did fix this issue indeed.
That only leaves my second patch as needed, so I'll submit just that separately.

Patrick

Quoted 124 lines

Gregory

Quoted 105 lines

We had a regression based on the USB device probing, but that should be fixed now with the patch below. Do you have that?

Arnd

commit 7222c832254a75dcd67d683df75753d4a4e125bb

Author: Nicolai Stange <[email protected]>
Date:   Thu Mar 17 23:53:02 2016 +0100
    usb/core: usb_alloc_dev(): fix setting of ->portnum

    With commit 69bec7259853 ("USB: core: let USB device know device node"),
    the port1 argument of usb_alloc_dev() gets overwritten as follows:

      ... usb_alloc_dev(..., unsigned port1)
      {
        ...
        if (!parent->parent) {
          port1 = usb_hcd_find_raw_port_number(..., port1);
        }
        ...
      }

    Later on, this now overwritten port1 gets assigned to ->portnum:

      dev->portnum = port1;

    However, since xhci_find_raw_port_number() isn't idempotent, the
    aforementioned commit causes a number of KASAN splats like the following:

      BUG: KASAN: slab-out-of-bounds in xhci_find_raw_port_number+0x98/0x170
                                           at addr ffff8801d9311670
      Read of size 8 by task kworker/2:1/87
      [...]
      Workqueue: usb_hub_wq hub_event
       0000000000000188 000000005814b877 ffff8800cba17588 ffffffff8191447e
       0000000041b58ab3 ffffffff82a03209 ffffffff819143a2 ffffffff82a252f4
       ffff8801d93115e0 0000000000000188 ffff8801d9311628 ffff8800cba17588
      Call Trace:
       [<ffffffff8191447e>] dump_stack+0xdc/0x15e
       [<ffffffff819143a2>] ? _atomic_dec_and_lock+0xa2/0xa2
       [<ffffffff814e2cd1>] ? print_section+0x61/0xb0
       [<ffffffff814e4939>] print_trailer+0x179/0x2c0
       [<ffffffff814f0d84>] object_err+0x34/0x40
       [<ffffffff814f4388>] kasan_report_error+0x2f8/0x8b0
       [<ffffffff814eb91e>] ? __slab_alloc+0x5e/0x90
       [<ffffffff812178c0>] ? __lock_is_held+0x90/0x130
       [<ffffffff814f5091>] kasan_report+0x71/0xa0
       [<ffffffff814ec082>] ? kmem_cache_alloc_trace+0x212/0x560
       [<ffffffff81d99468>] ? xhci_find_raw_port_number+0x98/0x170
       [<ffffffff814f33d4>] __asan_load8+0x64/0x70
       [<ffffffff81d99468>] xhci_find_raw_port_number+0x98/0x170
       [<ffffffff81db0105>] xhci_setup_addressable_virt_dev+0x235/0xa10
       [<ffffffff81d9ea51>] xhci_setup_device+0x3c1/0x1430
       [<ffffffff8121cddd>] ? trace_hardirqs_on+0xd/0x10
       [<ffffffff81d9fac0>] ? xhci_setup_device+0x1430/0x1430
       [<ffffffff81d9fad3>] xhci_address_device+0x13/0x20
       [<ffffffff81d2081a>] hub_port_init+0x55a/0x1550
       [<ffffffff81d28705>] hub_event+0xef5/0x24d0
       [<ffffffff81d27810>] ? hub_port_debounce+0x2f0/0x2f0
       [<ffffffff8195e1ee>] ? debug_object_deactivate+0x1be/0x270
       [<ffffffff81210203>] ? print_rt_rq+0x53/0x2d0
       [<ffffffff8121657d>] ? trace_hardirqs_off+0xd/0x10
       [<ffffffff8226acfb>] ? _raw_spin_unlock_irqrestore+0x5b/0x60
       [<ffffffff81250000>] ? irq_domain_set_hwirq_and_chip+0x30/0xb0
       [<ffffffff81256339>] ? debug_lockdep_rcu_enabled+0x39/0x40
       [<ffffffff812178c0>] ? __lock_is_held+0x90/0x130
       [<ffffffff81196877>] process_one_work+0x567/0xec0
      [...]

    Afterwards, xhci reports some functional errors:

      xhci_hcd 0000:00:14.0: ERROR: unexpected setup address command completion
                                    code 0x11.
      xhci_hcd 0000:00:14.0: ERROR: unexpected setup address command completion
                                    code 0x11.
      usb 4-3: device not accepting address 2, error -22

    Fix this by not overwriting the port1 argument in usb_alloc_dev(), but
    storing the raw port number as required by OF in an additional variable,
    raw_port.

    Fixes: 69bec7259853 ("USB: core: let USB device know device node")
    Signed-off-by: Nicolai Stange <[email protected]>
    Acked-by: Alan Stern <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>
drivers/usb/core/usb.c +1 -0
index ffa5cf13ffe1..dcb85e3cd5a7 100644
@@ -424,6 +424,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
      struct usb_device *dev;
      struct usb_hcd *usb_hcd = bus_to_hcd(bus);
      unsigned root_hub = 0;
+     unsigned raw_port = port1;
 
      dev = kzalloc(sizeof(*dev), GFP_KERNEL);
      if (!dev)
@@ -498,11 +499,11 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
 
              if (!parent->parent) {
                      /* device under root hub's port */

drivers/usb/core/usb.c struct usb_device *usb_alloc_dev(struct usb_device *parent, · line 509

Quoted 10 lines
drivers/usb/core/usb.c +2 -2
-                     port1 = usb_hcd_find_raw_port_number(usb_hcd,
+                     raw_port = usb_hcd_find_raw_port_number(usb_hcd,
                              port1);
              }
              dev->dev.of_node = usb_of_get_child_node(parent->dev.of_node,
-                             port1);
+                             raw_port);
 
              /* hub driver sets up TT records */
      }

--
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

#5 lore raw

PATCH 1/2 ARM: mvebu: correct the usb node name from usb@ to ehci@

Hello,

Quoted 2 lines · Patrick Uiterwijk

Thank you for this pointer, setting fdt_skip_update no did fix this issue indeed.

Hum, what should fix the problem is to set fdt_skip_update to "yes". If you set it to "no", then the Marvell U-Boot will do its funky DTB tweaks which are not necessarily compatible with the mainline kernel DT bindings.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#6 lore raw

PATCH 1/2 ARM: mvebu: correct the usb node name from usb@ to ehci@

Hi,

Quoted 11 lines · Thomas Petazzoni

Hello,

Quoted 2 lines · Patrick Uiterwijk

Thank you for this pointer, setting fdt_skip_update no did fix this issue indeed.

Hum, what should fix the problem is to set fdt_skip_update to "yes". If you set it to "no", then the Marvell U-Boot will do its funky DTB tweaks which are not necessarily compatible with the mainline kernel DT bindings.

Correct, I meant setting it to "yes" fixed the problem, sorry for the confusion.

Patrick

#7 lore raw

PATCH 1/2 ARM: mvebu: correct the usb node name from usb@ to ehci@

Hello,

Quoted 11 lines · Patrick Uiterwijk
Quoted 9 lines · Patrick Uiterwijk
Quoted 3 lines

Thank you for this pointer, setting fdt_skip_update no did fix this issue indeed.

Hum, what should fix the problem is to set fdt_skip_update to "yes". If you set it to "no", then the Marvell U-Boot will do its funky DTB tweaks which are not necessarily compatible with the mainline kernel DT bindings.

Correct, I meant setting it to "yes" fixed the problem, sorry for the confusion.

Ok, then it makes sense. It's amazing how much weird issues this Marvell U-Boot behavior has caused :-/

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#8 lore raw

PATCH 2/2 ARM: mvebu: Correct unit address for linksys

In reply to Patrick Uiterwijk

The USB2 port for Armada 38x is defined to be at 58000, not at 50000.

---
 arch/arm/boot/dts/armada-385-linksys.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/armada-385-linksys.dtsi +1 -1
index b328d94..94b8b0b 100644
@@ -117,7 +117,7 @@
 			};
 
 			/* USB part of the eSATA/USB 2.0 port */
-			ehci at 50000 {
+			ehci at 58000 {
 				status = "okay";
 			};
 
Signature · 1 line
2.7.4