Skip to contentSkip to conversation

phy: rockchip-inno-usb2: Sync initial otg state

PATCH Applied Peter Geis 5 participants 13 messages Jun 22, 2022 – Aug 22, 2022

Subsystems (2)
lore
Share & tools
lore

Peter Geis

author
#0 lore raw

PATCH 1/1 phy: rockchip-inno-usb2: Sync initial otg state

The initial otg state for the phy defaults to device mode. The actual state isn't detected until an ID IRQ fires. Fix this by syncing the ID state during initialization.

Fixes 51a9b2c03dd3 ("phy: rockchip-inno-usb2: Handle ID IRQ")
---
 drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +6 -0
index 6711659f727c..6e44069617df 100644
@@ -1162,6 +1162,12 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
 					EXTCON_USB_HOST, &rport->event_nb);
 		if (ret)
 			dev_err(rphy->dev, "register USB HOST notifier failed\n");
+
+		if (!of_property_read_bool(rphy->dev->of_node, "extcon")) {
+			/* do initial sync of usb state */
+			ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
+			extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret);
+		}
 	}
 
 out:
Signature · 7 lines
2.25.1


-- 
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Peter Geis

The initial otg state for the phy defaults to device mode. The actual state isn't detected until an ID IRQ fires. Fix this by syncing the ID state during initialization.

Fixes 51a9b2c03dd3 ("phy: rockchip-inno-usb2: Handle ID IRQ")

One comment below. Either way it fixes a bug, so:

Quoted 9 lines
---
 drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +0 -0
index 6711659f727c..6e44069617df 100644

drivers/phy/rockchip/phy-rockchip-inno-usb2.c static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, · line 1166

Quoted 5 lines
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +2 -0
@@ -1162,6 +1162,12 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
 					EXTCON_USB_HOST, &rport->event_nb);
 		if (ret)
 			dev_err(rphy->dev, "register USB HOST notifier failed\n");
+
+		if (!of_property_read_bool(rphy->dev->of_node, "extcon")) {

Currently the IRQ handler does not care who created the extcon. We should at least be consistent between here and there.

Regards,
Samuel

Quoted 8 lines
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +4 -0
+			/* do initial sync of usb state */
+			ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
+			extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret);
+		}
 	}
 
 out:
author
#2 lore raw
Quoted 6 lines · Samuel Holland
Quoted 4 lines · Peter Geis

The initial otg state for the phy defaults to device mode. The actual state isn't detected until an ID IRQ fires. Fix this by syncing the ID state during initialization.

Quoted 6 lines
Quoted 2 lines
Fixes 51a9b2c03dd3 ("phy: rockchip-inno-usb2: Handle ID IRQ")

One comment below. Either way it fixes a bug, so:

Thanks!

Quoted 5 lines
Quoted 5 lines
---
 drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 6 ++++++
 1 file changed, 6 insertions(+)
Quoted 13 lines

drivers/phy/rockchip/phy-rockchip-inno-usb2.c static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, · line 1166

Quoted 10 lines
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +2 -0
index 6711659f727c..6e44069617df 100644
@@ -1162,6 +1162,12 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
                                      EXTCON_USB_HOST, &rport->event_nb);
              if (ret)
                      dev_err(rphy->dev, "register USB HOST notifier failed\n");
+
+             if (!of_property_read_bool(rphy->dev->of_node, "extcon")) {

Currently the IRQ handler does not care who created the extcon. We should at least be consistent between here and there.

We care in this instance because if there is an external extcon it is responsible for setting the initial state. Our ID pin may or may not be used in this case and if it isn't we would overwrite the initial state with an invalid one.

Quoted 13 lines

Regards,
Samuel

Quoted 8 lines
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +4 -0
+                     /* do initial sync of usb state */
+                     ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
+                     extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret);
+             }
      }
 
 out:
Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
maintainer Applied
#3 lore raw
In reply to Peter Geis
Quoted 3 lines · Peter Geis

The initial otg state for the phy defaults to device mode. The actual state isn't detected until an ID IRQ fires. Fix this by syncing the ID state during initialization.

Applied, thanks

Signature · 1 line
~Vinod
#4 lore raw
In reply to Peter Geis

Hi Peter,
Am 22.06.22 um 02:31 schrieb Peter Geis:

Quoted 17 lines

The initial otg state for the phy defaults to device mode. The actual state isn't detected until an ID IRQ fires. Fix this by syncing the ID state during initialization.

Fixes 51a9b2c03dd3 ("phy: rockchip-inno-usb2: Handle ID IRQ")
---
  drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +0 -0
index 6711659f727c..6e44069617df 100644
@@ -1162,6 +1162,12 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
  					EXTCON_USB_HOST, &rport->event_nb);
  		if (ret)

drivers/phy/rockchip/phy-rockchip-inno-usb2.c static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, · line 1173

Quoted 10 lines
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +6 -0
  			dev_err(rphy->dev, "register USB HOST notifier failed\n");
+
+		if (!of_property_read_bool(rphy->dev->of_node, "extcon")) {
+			/* do initial sync of usb state */
+			ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
+			extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret);
+		}
  	}
 
  out:

with recent linux-next kernels, here with next-20220725 my rk3399-roc-pc does not boot. Bisecting pointed to this commit. By reverting this commit the board boots again.

2.431005] Unable to handle kernel NULL pointer dereference at virtual address
0000000000000000

[    2.432152] Mem abort info:
[    2.432519]   ESR = 0x0000000086000004
[    2.433001]   EC = 0x21: IABT (current EL), IL = 32 bits
[    2.433674]   SET = 0, FnV = 0
[    2.434075]   EA = 0, S1PTW = 0
[    2.434484]   FSC = 0x04: level 0 translation fault
[    2.435102] user pgtable: 4k pages, 48-bit VAs, pgdp=0000000001765000
[    2.435911] [0000000000000000] pgd=0000000000000000, p4d=0000000000000000
[    2.436775] Internal error: Oops: 86000004 [#1] SMP
[    2.437397] Modules linked in: ip_tables x_tables ipv6 xhci_plat_hcd xhci_hcd rockchipdrm drm_cma_helper dwc3 analogix_dp dw_hdmi realtek dwc3_of_simple drm_display_helper dw_mipi_dsi drm_kms_helper syscopyarea ohci_platform ohci_hcd ehci_platform sysfillrect sysimgblt ehci_hcd dwmac_rk fb_sys_fops stmmac_platform stmmac pcs_xpcs phylink drm usbcore drm_panel_orientation_quirks
[    2.441651] CPU: 3 PID: 0 Comm: swapper/3 Not tainted 5.19.0-rc8-next-20220725 #417
[    2.442609] Hardware name: Firefly ROC-RK3399-PC Mezzanine Board (DT)
[    2.443415] pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[    2.444289] pc : 0x0
[    2.444594] lr : call_timer_fn.constprop.0+0x24/0x80
[    2.445247] sp : ffff800008f43a50
[    2.445678] x29: ffff800008f43a50 x28: 0000000000000005 x27: 0000000000000020
[    2.453334] x26: ffff000000646580 x25: ffff800008f43b00 x24: 0000000000000000
[    2.461028] x23: 0000000000000001 x22: 00000000000000e0 x21: 0000000000000100
[    2.466727] x20: ffff000000646580 x19: 0000000000000000 x18: ffff00000679e80c
[    2.471614] x17: ffff8000eec73000 x16: ffff800008d84000 x15: 0000000000004000
[    2.476524] x14: ffff000000646580 x13: ffff8000eec73000 x12: ffff0000f7786ef0
[    2.481408] x11: 0000000000000001 x10: 0000000000000000 x9 : 000000000000006d
[    2.486309] x8 : ffff0000f7786ea8 x7 : ffffffffffffffff x6 : 0000000000000000
[    2.491197] x5 : 0000000000000000 x4 : 0000000000000000 x3 : ffff800008f43b00
[    2.496077] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff0000018e0b10
[    2.500871] Call trace:
[    2.505098]  0x0
[    2.509249]  expire_timers+0xcc/0x100
[    2.513533]  run_timer_softirq+0x11c/0x300
[    2.517842]  _stext+0x124/0x2a4
[    2.522050]  __irq_exit_rcu+0xcc/0xfc
[    2.526289]  irq_exit_rcu+0x10/0x1c
[    2.530448]  el1_interrupt+0x38/0x54
[    2.534601]  el1h_64_irq_handler+0x18/0x24
[    2.538791]  el1h_64_irq+0x64/0x68
[    2.542892]  cpuidle_enter_state+0x130/0x2f0
[    2.547064]  cpuidle_enter+0x38/0x50
[    2.551167]  do_idle+0x228/0x2ac
[    2.555267]  cpu_startup_entry+0x24/0x30
[    2.559396]  secondary_start_kernel+0x124/0x140
[    2.563526]  __secondary_switched+0xb0/0xb4
[    2.567599] Code: bad PC value
[    2.571567] ---[ end trace 0000000000000000 ]---
[    2.575625] Kernel panic - not syncing: Oops: Fatal exception in interrupt
[    2.579901] SMP: stopping secondary CPUs
[    2.584020] Kernel Offset: disabled
[    2.587955] CPU features: 0x2000,0820b021,00001082
[    2.592000] Memory Limit: none
[    2.595844] ---[ end Kernel panic - not syncing: Oops: Fatal exception in interrupt ]---

Gruß,

Signature · 1 line
Markus Reichl
#5 lore raw
In reply to Peter Geis

Hi,

with linux-next-20220728 rk3399-roc-pc does not boot. Bisecting pointed to this commit.
By reverting this commit the board boots again.

[    2.398700] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008
[    2.399517] Mem abort info:
[    2.399772]   ESR = 0x0000000096000004
[    2.400114]   EC = 0x25: DABT (current EL), IL = 32 bits
[    2.400594]   SET = 0, FnV = 0
[    2.400873]   EA = 0, S1PTW = 0
[    2.401161]   FSC = 0x04: level 0 translation fault
[    2.401602] Data abort info:
[    2.401864]   ISV = 0, ISS = 0x00000004
[    2.402212]   CM = 0, WnR = 0
[    2.402484] user pgtable: 4k pages, 48-bit VAs, pgdp=0000000001376000
[    2.403071] [0000000000000008] pgd=0000000000000000, p4d=0000000000000000
[    2.403687] Internal error: Oops: 96000004 [#1] SMP
[    2.404130] Modules linked in: ip_tables x_tables ipv6 xhci_plat_hcd xhci_hcd dwc3 rockchipdrm drm_cma_helper analogix_dp dw_hdmi realtek drm_display_helper dwc3_of_simple dw_mipi_dsi ehci_platform ohci_platform ohci_hcd ehci_hcd drm_kms_helper dwmac_rk syscopyarea sysfillrect stmmac_platform sysimgblt fb_sys_fops usbcore stmmac pcs_xpcs drm phylink drm_panel_orientation_quirks
[    2.407155] CPU: 4 PID: 71 Comm: kworker/4:6 Not tainted 5.19.0-rc8-next-20220728 #437
[    2.407868] Hardware name: Firefly ROC-RK3399-PC Mezzanine Board (DT)
[    2.408448] Workqueue: events rockchip_usb2phy_otg_sm_work
[    2.408958] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[    2.411634] pc : rockchip_usb2phy_otg_sm_work+0x50/0x330
[    2.414332] lr : process_one_work+0x1d8/0x380
[    2.416948] sp : ffff800009373d60
[    2.419406] x29: ffff800009373d60 x28: 0000000000000000 x27: 0000000000000000
[    2.422199] x26: ffff0000f779fcb8 x25: ffff0000f77a3a05 x24: 000000000000000c
[    2.424978] x23: 0000000000000000 x22: ffff0000010c8258 x21: ffff80000888ec10
[    2.427768] x20: ffff0000010c82f0 x19: 000000000000000c x18: 0000000000000001
[    2.430604] x17: 000000040044ffff x16: 00400034b5503510 x15: 0000000000000000
[    2.433390] x14: ffff000000708000 x13: ffff8000eec96000 x12: 0000000034d4d91d
[    2.436185] x11: 0000000000000000 x10: 0000000000000a10 x9 : ffff000001aa7a74
[    2.438958] x8 : fefefefefefefeff x7 : 0000000000000018 x6 : ffff000001aa7a74
[    2.441668] x5 : 000073746e657665 x4 : 000000000000002f x3 : ffff00000356c808
[    2.444407] x2 : ffff800009373da4 x1 : 000000000000e2ac x0 : ffff80000888eb34
[    2.447190] Call trace:
[    2.449557]  rockchip_usb2phy_otg_sm_work+0x50/0x330
[    2.452169]  process_one_work+0x1d8/0x380
[    2.454684]  worker_thread+0x170/0x4e0
[    2.457056]  kthread+0xd8/0xdc
[    2.459354]  ret_from_fork+0x10/0x20
[    2.461728] Code: 91037015 295be001 f9403c77 b940e413 (f94006e0)
[    2.464338] ---[ end trace 0000000000000000 ]---

Am 22.06.22 um 02:31 schrieb Peter Geis:

Quoted 17 lines

The initial otg state for the phy defaults to device mode. The actual state isn't detected until an ID IRQ fires. Fix this by syncing the ID state during initialization.

Fixes 51a9b2c03dd3 ("phy: rockchip-inno-usb2: Handle ID IRQ")
---
  drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +0 -0
index 6711659f727c..6e44069617df 100644
@@ -1162,6 +1162,12 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
  					EXTCON_USB_HOST, &rport->event_nb);
  		if (ret)

drivers/phy/rockchip/phy-rockchip-inno-usb2.c static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, · line 1173

Quoted 10 lines
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +6 -0
  			dev_err(rphy->dev, "register USB HOST notifier failed\n");
+
+		if (!of_property_read_bool(rphy->dev->of_node, "extcon")) {
+			/* do initial sync of usb state */
+			ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
+			extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret);
+		}
  	}
 
  out:

Gruß,

Signature · 1 line
Markus Reichl
author
#6 lore raw
Quoted 6 lines · Markus Reichl

Hi,

with linux-next-20220728 rk3399-roc-pc does not boot. Bisecting pointed to this commit.
By reverting this commit the board boots again.

Thank you for reporting this, someone was kind enough to reproduce the problem on the rockpro64 and confirmed this is an issue. As I won't have access to my hardware until next month, we should probably revert this until the root cause can be identified.

Very Respectfully,
Peter Geis

Quoted 79 lines
[    2.398700] Unable to handle kernel NULL pointer dereference at virtual address
0000000000000008
[    2.399517] Mem abort info:
[    2.399772]   ESR = 0x0000000096000004
[    2.400114]   EC = 0x25: DABT (current EL), IL = 32 bits
[    2.400594]   SET = 0, FnV = 0
[    2.400873]   EA = 0, S1PTW = 0
[    2.401161]   FSC = 0x04: level 0 translation fault
[    2.401602] Data abort info:
[    2.401864]   ISV = 0, ISS = 0x00000004
[    2.402212]   CM = 0, WnR = 0
[    2.402484] user pgtable: 4k pages, 48-bit VAs, pgdp=0000000001376000
[    2.403071] [0000000000000008] pgd=0000000000000000, p4d=0000000000000000
[    2.403687] Internal error: Oops: 96000004 [#1] SMP
[    2.404130] Modules linked in: ip_tables x_tables ipv6 xhci_plat_hcd xhci_hcd

dwc3 rockchipdrm drm_cma_helper analogix_dp dw_hdmi realtek drm_display_helper dwc3_of_simple dw_mipi_dsi ehci_platform ohci_platform ohci_hcd ehci_hcd drm_kms_helper dwmac_rk syscopyarea sysfillrect stmmac_platform sysimgblt fb_sys_fops usbcore stmmac pcs_xpcs drm phylink drm_panel_orientation_quirks

[    2.407155] CPU: 4 PID: 71 Comm: kworker/4:6 Not tainted
5.19.0-rc8-next-20220728 #437
[    2.407868] Hardware name: Firefly ROC-RK3399-PC Mezzanine Board (DT)
[    2.408448] Workqueue: events rockchip_usb2phy_otg_sm_work
[    2.408958] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[    2.411634] pc : rockchip_usb2phy_otg_sm_work+0x50/0x330
[    2.414332] lr : process_one_work+0x1d8/0x380
[    2.416948] sp : ffff800009373d60
[    2.419406] x29: ffff800009373d60 x28: 0000000000000000 x27: 0000000000000000
[    2.422199] x26: ffff0000f779fcb8 x25: ffff0000f77a3a05 x24: 000000000000000c
[    2.424978] x23: 0000000000000000 x22: ffff0000010c8258 x21: ffff80000888ec10
[    2.427768] x20: ffff0000010c82f0 x19: 000000000000000c x18: 0000000000000001
[    2.430604] x17: 000000040044ffff x16: 00400034b5503510 x15: 0000000000000000
[    2.433390] x14: ffff000000708000 x13: ffff8000eec96000 x12: 0000000034d4d91d
[    2.436185] x11: 0000000000000000 x10: 0000000000000a10 x9 : ffff000001aa7a74
[    2.438958] x8 : fefefefefefefeff x7 : 0000000000000018 x6 : ffff000001aa7a74
[    2.441668] x5 : 000073746e657665 x4 : 000000000000002f x3 : ffff00000356c808
[    2.444407] x2 : ffff800009373da4 x1 : 000000000000e2ac x0 : ffff80000888eb34
[    2.447190] Call trace:
[    2.449557]  rockchip_usb2phy_otg_sm_work+0x50/0x330
[    2.452169]  process_one_work+0x1d8/0x380
[    2.454684]  worker_thread+0x170/0x4e0
[    2.457056]  kthread+0xd8/0xdc
[    2.459354]  ret_from_fork+0x10/0x20
[    2.461728] Code: 91037015 295be001 f9403c77 b940e413 (f94006e0)
[    2.464338] ---[ end trace 0000000000000000 ]---

Am 22.06.22 um 02:31 schrieb Peter Geis:

Quoted 17 lines

The initial otg state for the phy defaults to device mode. The actual state isn't detected until an ID IRQ fires. Fix this by syncing the ID state during initialization.

Fixes 51a9b2c03dd3 ("phy: rockchip-inno-usb2: Handle ID IRQ")
---
  drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +0 -0
index 6711659f727c..6e44069617df 100644
@@ -1162,6 +1162,12 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
                                      EXTCON_USB_HOST, &rport->event_nb);
              if (ret)

drivers/phy/rockchip/phy-rockchip-inno-usb2.c static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, · line 1173

Quoted 10 lines
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +6 -0
                      dev_err(rphy->dev, "register USB HOST notifier failed\n");
+
+             if (!of_property_read_bool(rphy->dev->of_node, "extcon")) {
+                     /* do initial sync of usb state */
+                     ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
+                     extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret);
+             }
      }
 
  out:

Gruß,
--
Markus Reichl

Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
#7 lore raw

Hi all,

Quoted 4 lines · Peter Geis
Quoted 3 lines · Markus Reichl

Hi,

Quoted 8 lines
Quoted 3 lines

with linux-next-20220728 rk3399-roc-pc does not boot. Bisecting pointed to this commit.
By reverting this commit the board boots again.

Thank you for reporting this, someone was kind enough to reproduce the problem on the rockpro64 and confirmed this is an issue. As I won't have access to my hardware until next month, we should probably revert this until the root cause can be identified.

Just experienced this issue on my ROCK3 Model A board (RK3568) and reverting this commit solved it.

Having the revert in v6.0-rc2 would be great -- if there is anything I can help to accelerate this please let me know.

Thanks and best regards,
Michael

Quoted 88 lines

Very Respectfully,
Peter Geis

Quoted 74 lines
[    2.398700] Unable to handle kernel NULL pointer dereference at virtual address
0000000000000008
[    2.399517] Mem abort info:
[    2.399772]   ESR = 0x0000000096000004
[    2.400114]   EC = 0x25: DABT (current EL), IL = 32 bits
[    2.400594]   SET = 0, FnV = 0
[    2.400873]   EA = 0, S1PTW = 0
[    2.401161]   FSC = 0x04: level 0 translation fault
[    2.401602] Data abort info:
[    2.401864]   ISV = 0, ISS = 0x00000004
[    2.402212]   CM = 0, WnR = 0
[    2.402484] user pgtable: 4k pages, 48-bit VAs, pgdp=0000000001376000
[    2.403071] [0000000000000008] pgd=0000000000000000, p4d=0000000000000000
[    2.403687] Internal error: Oops: 96000004 [#1] SMP
[    2.404130] Modules linked in: ip_tables x_tables ipv6 xhci_plat_hcd xhci_hcd

dwc3 rockchipdrm drm_cma_helper analogix_dp dw_hdmi realtek drm_display_helper dwc3_of_simple dw_mipi_dsi ehci_platform ohci_platform ohci_hcd ehci_hcd drm_kms_helper dwmac_rk syscopyarea sysfillrect stmmac_platform sysimgblt fb_sys_fops usbcore stmmac pcs_xpcs drm phylink drm_panel_orientation_quirks

[    2.407155] CPU: 4 PID: 71 Comm: kworker/4:6 Not tainted
5.19.0-rc8-next-20220728 #437
[    2.407868] Hardware name: Firefly ROC-RK3399-PC Mezzanine Board (DT)
[    2.408448] Workqueue: events rockchip_usb2phy_otg_sm_work
[    2.408958] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[    2.411634] pc : rockchip_usb2phy_otg_sm_work+0x50/0x330
[    2.414332] lr : process_one_work+0x1d8/0x380
[    2.416948] sp : ffff800009373d60
[    2.419406] x29: ffff800009373d60 x28: 0000000000000000 x27: 0000000000000000
[    2.422199] x26: ffff0000f779fcb8 x25: ffff0000f77a3a05 x24: 000000000000000c
[    2.424978] x23: 0000000000000000 x22: ffff0000010c8258 x21: ffff80000888ec10
[    2.427768] x20: ffff0000010c82f0 x19: 000000000000000c x18: 0000000000000001
[    2.430604] x17: 000000040044ffff x16: 00400034b5503510 x15: 0000000000000000
[    2.433390] x14: ffff000000708000 x13: ffff8000eec96000 x12: 0000000034d4d91d
[    2.436185] x11: 0000000000000000 x10: 0000000000000a10 x9 : ffff000001aa7a74
[    2.438958] x8 : fefefefefefefeff x7 : 0000000000000018 x6 : ffff000001aa7a74
[    2.441668] x5 : 000073746e657665 x4 : 000000000000002f x3 : ffff00000356c808
[    2.444407] x2 : ffff800009373da4 x1 : 000000000000e2ac x0 : ffff80000888eb34
[    2.447190] Call trace:
[    2.449557]  rockchip_usb2phy_otg_sm_work+0x50/0x330
[    2.452169]  process_one_work+0x1d8/0x380
[    2.454684]  worker_thread+0x170/0x4e0
[    2.457056]  kthread+0xd8/0xdc
[    2.459354]  ret_from_fork+0x10/0x20
[    2.461728] Code: 91037015 295be001 f9403c77 b940e413 (f94006e0)
[    2.464338] ---[ end trace 0000000000000000 ]---

Am 22.06.22 um 02:31 schrieb Peter Geis:

Quoted 26 lines

The initial otg state for the phy defaults to device mode. The actual state isn't detected until an ID IRQ fires. Fix this by syncing the ID state during initialization.

Fixes 51a9b2c03dd3 ("phy: rockchip-inno-usb2: Handle ID IRQ")
---
  drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +6 -0
index 6711659f727c..6e44069617df 100644
@@ -1162,6 +1162,12 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
                                      EXTCON_USB_HOST, &rport->event_nb);
              if (ret)
                      dev_err(rphy->dev, "register USB HOST notifier failed\n");
+
+             if (!of_property_read_bool(rphy->dev->of_node, "extcon")) {
+                     /* do initial sync of usb state */
+                     ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
+                     extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret);
+             }
      }
 
Quoted 5 lines

drivers/phy/rockchip/phy-rockchip-inno-usb2.c static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, · line 1173

Quoted 1 line
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +0 -0
  out:

Gruß,
--
Markus Reichl

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
author
#8 lore raw
Quoted 17 lines · Michael Riesch

Hi all,

Quoted 4 lines · Peter Geis
Quoted 3 lines · Markus Reichl

Hi,

Quoted 8 lines
Quoted 3 lines

with linux-next-20220728 rk3399-roc-pc does not boot. Bisecting pointed to this commit.
By reverting this commit the board boots again.

Thank you for reporting this, someone was kind enough to reproduce the problem on the rockpro64 and confirmed this is an issue. As I won't have access to my hardware until next month, we should probably revert this until the root cause can be identified.

Quoted 5 lines

Just experienced this issue on my ROCK3 Model A board (RK3568) and reverting this commit solved it.

Having the revert in v6.0-rc2 would be great -- if there is anything I can help to accelerate this please let me know.

If this is now happening on rk356x where I know it works, it now cements my theory that it's a symptom and not the actual problem. Possibly a race condition with the grf and regmap code where it isn't quite ready when called. This code path is called exactly the same way later on when the irq fires.

What config are you based on? I'm running a stripped down version of the arm64_defconfig, but if you deviate from that it will be helpful in reproducing the issue.

We should revert it until it's isolated, as well as the patch setting the rk356x to otg since it will again be broken. If someone could weigh in here as well (I currently don't have access to my hardware) it would be helpful.

Quoted 92 lines

Thanks and best regards,
Michael

Quoted 88 lines

Very Respectfully,
Peter Geis

Quoted 74 lines
[    2.398700] Unable to handle kernel NULL pointer dereference at virtual address
0000000000000008
[    2.399517] Mem abort info:
[    2.399772]   ESR = 0x0000000096000004
[    2.400114]   EC = 0x25: DABT (current EL), IL = 32 bits
[    2.400594]   SET = 0, FnV = 0
[    2.400873]   EA = 0, S1PTW = 0
[    2.401161]   FSC = 0x04: level 0 translation fault
[    2.401602] Data abort info:
[    2.401864]   ISV = 0, ISS = 0x00000004
[    2.402212]   CM = 0, WnR = 0
[    2.402484] user pgtable: 4k pages, 48-bit VAs, pgdp=0000000001376000
[    2.403071] [0000000000000008] pgd=0000000000000000, p4d=0000000000000000
[    2.403687] Internal error: Oops: 96000004 [#1] SMP
[    2.404130] Modules linked in: ip_tables x_tables ipv6 xhci_plat_hcd xhci_hcd

dwc3 rockchipdrm drm_cma_helper analogix_dp dw_hdmi realtek drm_display_helper dwc3_of_simple dw_mipi_dsi ehci_platform ohci_platform ohci_hcd ehci_hcd drm_kms_helper dwmac_rk syscopyarea sysfillrect stmmac_platform sysimgblt fb_sys_fops usbcore stmmac pcs_xpcs drm phylink drm_panel_orientation_quirks

[    2.407155] CPU: 4 PID: 71 Comm: kworker/4:6 Not tainted
5.19.0-rc8-next-20220728 #437
[    2.407868] Hardware name: Firefly ROC-RK3399-PC Mezzanine Board (DT)
[    2.408448] Workqueue: events rockchip_usb2phy_otg_sm_work
[    2.408958] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[    2.411634] pc : rockchip_usb2phy_otg_sm_work+0x50/0x330
[    2.414332] lr : process_one_work+0x1d8/0x380
[    2.416948] sp : ffff800009373d60
[    2.419406] x29: ffff800009373d60 x28: 0000000000000000 x27: 0000000000000000
[    2.422199] x26: ffff0000f779fcb8 x25: ffff0000f77a3a05 x24: 000000000000000c
[    2.424978] x23: 0000000000000000 x22: ffff0000010c8258 x21: ffff80000888ec10
[    2.427768] x20: ffff0000010c82f0 x19: 000000000000000c x18: 0000000000000001
[    2.430604] x17: 000000040044ffff x16: 00400034b5503510 x15: 0000000000000000
[    2.433390] x14: ffff000000708000 x13: ffff8000eec96000 x12: 0000000034d4d91d
[    2.436185] x11: 0000000000000000 x10: 0000000000000a10 x9 : ffff000001aa7a74
[    2.438958] x8 : fefefefefefefeff x7 : 0000000000000018 x6 : ffff000001aa7a74
[    2.441668] x5 : 000073746e657665 x4 : 000000000000002f x3 : ffff00000356c808
[    2.444407] x2 : ffff800009373da4 x1 : 000000000000e2ac x0 : ffff80000888eb34
[    2.447190] Call trace:
[    2.449557]  rockchip_usb2phy_otg_sm_work+0x50/0x330
[    2.452169]  process_one_work+0x1d8/0x380
[    2.454684]  worker_thread+0x170/0x4e0
[    2.457056]  kthread+0xd8/0xdc
[    2.459354]  ret_from_fork+0x10/0x20
[    2.461728] Code: 91037015 295be001 f9403c77 b940e413 (f94006e0)
[    2.464338] ---[ end trace 0000000000000000 ]---

Am 22.06.22 um 02:31 schrieb Peter Geis:

Quoted 26 lines

The initial otg state for the phy defaults to device mode. The actual state isn't detected until an ID IRQ fires. Fix this by syncing the ID state during initialization.

Fixes 51a9b2c03dd3 ("phy: rockchip-inno-usb2: Handle ID IRQ")
---
  drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +6 -0
index 6711659f727c..6e44069617df 100644
@@ -1162,6 +1162,12 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
                                      EXTCON_USB_HOST, &rport->event_nb);
              if (ret)
                      dev_err(rphy->dev, "register USB HOST notifier failed\n");
+
+             if (!of_property_read_bool(rphy->dev->of_node, "extcon")) {
+                     /* do initial sync of usb state */
+                     ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
+                     extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret);
+             }
      }
 
Quoted 5 lines

drivers/phy/rockchip/phy-rockchip-inno-usb2.c static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, · line 1173

Quoted 1 line
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +0 -0
  out:

Gruß,
--
Markus Reichl

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

#9 lore raw

Hi Peter,

Quoted 31 lines · Peter Geis
Quoted 17 lines · Michael Riesch

Hi all,

Quoted 4 lines · Peter Geis
Quoted 3 lines · Markus Reichl

Hi,

Quoted 8 lines
Quoted 3 lines

with linux-next-20220728 rk3399-roc-pc does not boot. Bisecting pointed to this commit.
By reverting this commit the board boots again.

Thank you for reporting this, someone was kind enough to reproduce the problem on the rockpro64 and confirmed this is an issue. As I won't have access to my hardware until next month, we should probably revert this until the root cause can be identified.

Quoted 5 lines

Just experienced this issue on my ROCK3 Model A board (RK3568) and reverting this commit solved it.

Having the revert in v6.0-rc2 would be great -- if there is anything I can help to accelerate this please let me know.

If this is now happening on rk356x where I know it works, it now cements my theory that it's a symptom and not the actual problem. Possibly a race condition with the grf and regmap code where it isn't quite ready when called. This code path is called exactly the same way later on when the irq fires.

Quoted 3 lines

What config are you based on? I'm running a stripped down version of the arm64_defconfig, but if you deviate from that it will be helpful in reproducing the issue.

I posted my Kconfig here: https://pastebin.com/P1As0W4k

FWIW the ROCK3 board has a switch to set the OTG port to device or host, respectively. The NPE does not occur when the switch is set to host.

Best regards,
Michael

Quoted 97 lines

We should revert it until it's isolated, as well as the patch setting the rk356x to otg since it will again be broken. If someone could weigh in here as well (I currently don't have access to my hardware) it would be helpful.

Quoted 92 lines

Thanks and best regards,
Michael

Quoted 88 lines

Very Respectfully,
Peter Geis

Quoted 74 lines
[    2.398700] Unable to handle kernel NULL pointer dereference at virtual address
0000000000000008
[    2.399517] Mem abort info:
[    2.399772]   ESR = 0x0000000096000004
[    2.400114]   EC = 0x25: DABT (current EL), IL = 32 bits
[    2.400594]   SET = 0, FnV = 0
[    2.400873]   EA = 0, S1PTW = 0
[    2.401161]   FSC = 0x04: level 0 translation fault
[    2.401602] Data abort info:
[    2.401864]   ISV = 0, ISS = 0x00000004
[    2.402212]   CM = 0, WnR = 0
[    2.402484] user pgtable: 4k pages, 48-bit VAs, pgdp=0000000001376000
[    2.403071] [0000000000000008] pgd=0000000000000000, p4d=0000000000000000
[    2.403687] Internal error: Oops: 96000004 [#1] SMP
[    2.404130] Modules linked in: ip_tables x_tables ipv6 xhci_plat_hcd xhci_hcd

dwc3 rockchipdrm drm_cma_helper analogix_dp dw_hdmi realtek drm_display_helper dwc3_of_simple dw_mipi_dsi ehci_platform ohci_platform ohci_hcd ehci_hcd drm_kms_helper dwmac_rk syscopyarea sysfillrect stmmac_platform sysimgblt fb_sys_fops usbcore stmmac pcs_xpcs drm phylink drm_panel_orientation_quirks

[    2.407155] CPU: 4 PID: 71 Comm: kworker/4:6 Not tainted
5.19.0-rc8-next-20220728 #437
[    2.407868] Hardware name: Firefly ROC-RK3399-PC Mezzanine Board (DT)
[    2.408448] Workqueue: events rockchip_usb2phy_otg_sm_work
[    2.408958] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[    2.411634] pc : rockchip_usb2phy_otg_sm_work+0x50/0x330
[    2.414332] lr : process_one_work+0x1d8/0x380
[    2.416948] sp : ffff800009373d60
[    2.419406] x29: ffff800009373d60 x28: 0000000000000000 x27: 0000000000000000
[    2.422199] x26: ffff0000f779fcb8 x25: ffff0000f77a3a05 x24: 000000000000000c
[    2.424978] x23: 0000000000000000 x22: ffff0000010c8258 x21: ffff80000888ec10
[    2.427768] x20: ffff0000010c82f0 x19: 000000000000000c x18: 0000000000000001
[    2.430604] x17: 000000040044ffff x16: 00400034b5503510 x15: 0000000000000000
[    2.433390] x14: ffff000000708000 x13: ffff8000eec96000 x12: 0000000034d4d91d
[    2.436185] x11: 0000000000000000 x10: 0000000000000a10 x9 : ffff000001aa7a74
[    2.438958] x8 : fefefefefefefeff x7 : 0000000000000018 x6 : ffff000001aa7a74
[    2.441668] x5 : 000073746e657665 x4 : 000000000000002f x3 : ffff00000356c808
[    2.444407] x2 : ffff800009373da4 x1 : 000000000000e2ac x0 : ffff80000888eb34
[    2.447190] Call trace:
[    2.449557]  rockchip_usb2phy_otg_sm_work+0x50/0x330
[    2.452169]  process_one_work+0x1d8/0x380
[    2.454684]  worker_thread+0x170/0x4e0
[    2.457056]  kthread+0xd8/0xdc
[    2.459354]  ret_from_fork+0x10/0x20
[    2.461728] Code: 91037015 295be001 f9403c77 b940e413 (f94006e0)
[    2.464338] ---[ end trace 0000000000000000 ]---

Am 22.06.22 um 02:31 schrieb Peter Geis:

Quoted 26 lines

The initial otg state for the phy defaults to device mode. The actual state isn't detected until an ID IRQ fires. Fix this by syncing the ID state during initialization.

Fixes 51a9b2c03dd3 ("phy: rockchip-inno-usb2: Handle ID IRQ")
---
  drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +6 -0
index 6711659f727c..6e44069617df 100644
@@ -1162,6 +1162,12 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
                                      EXTCON_USB_HOST, &rport->event_nb);
              if (ret)
                      dev_err(rphy->dev, "register USB HOST notifier failed\n");
+
+             if (!of_property_read_bool(rphy->dev->of_node, "extcon")) {
+                     /* do initial sync of usb state */
+                     ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
+                     extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret);
+             }
      }
 
Quoted 5 lines

drivers/phy/rockchip/phy-rockchip-inno-usb2.c static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, · line 1173

Quoted 1 line
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +0 -0
  out:

Gruß,
--
Markus Reichl

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
author
#10 lore raw
Quoted 38 lines · Michael Riesch

Hi Peter,

Quoted 31 lines · Peter Geis
Quoted 17 lines · Michael Riesch

Hi all,

Quoted 4 lines · Peter Geis
Quoted 3 lines · Markus Reichl

Hi,

Quoted 8 lines
Quoted 3 lines

with linux-next-20220728 rk3399-roc-pc does not boot. Bisecting pointed to this commit.
By reverting this commit the board boots again.

Thank you for reporting this, someone was kind enough to reproduce the problem on the rockpro64 and confirmed this is an issue. As I won't have access to my hardware until next month, we should probably revert this until the root cause can be identified.

Quoted 5 lines

Just experienced this issue on my ROCK3 Model A board (RK3568) and reverting this commit solved it.

Having the revert in v6.0-rc2 would be great -- if there is anything I can help to accelerate this please let me know.

If this is now happening on rk356x where I know it works, it now cements my theory that it's a symptom and not the actual problem. Possibly a race condition with the grf and regmap code where it isn't quite ready when called. This code path is called exactly the same way later on when the irq fires.

Quoted 3 lines

What config are you based on? I'm running a stripped down version of the arm64_defconfig, but if you deviate from that it will be helpful in reproducing the issue.

Quoted 7 lines

I posted my Kconfig here: https://pastebin.com/P1As0W4k

FWIW the ROCK3 board has a switch to set the OTG port to device or host, respectively. The NPE does not occur when the switch is set to host.

Best regards,
Michael

Good Afternoon Michael,

Please try the following fix.

Very Respectfully,
Peter Geis

drivers/phy/rockchip/phy-rockchip-inno-usb2.c +1 -0
index 0b1e9337ee8e..5fc7c374a6b4 100644
@@ -1169,6 +1169,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
 			/* do initial sync of usb state */
 			ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
 			extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret);
+			ret = 0;
 		}
 	}
 
Quoted 98 lines
Quoted 98 lines

We should revert it until it's isolated, as well as the patch setting the rk356x to otg since it will again be broken. If someone could weigh in here as well (I currently don't have access to my hardware) it would be helpful.

Quoted 92 lines

Thanks and best regards,
Michael

Quoted 88 lines

Very Respectfully,
Peter Geis

Quoted 74 lines
[    2.398700] Unable to handle kernel NULL pointer dereference at virtual address
0000000000000008
[    2.399517] Mem abort info:
[    2.399772]   ESR = 0x0000000096000004
[    2.400114]   EC = 0x25: DABT (current EL), IL = 32 bits
[    2.400594]   SET = 0, FnV = 0
[    2.400873]   EA = 0, S1PTW = 0
[    2.401161]   FSC = 0x04: level 0 translation fault
[    2.401602] Data abort info:
[    2.401864]   ISV = 0, ISS = 0x00000004
[    2.402212]   CM = 0, WnR = 0
[    2.402484] user pgtable: 4k pages, 48-bit VAs, pgdp=0000000001376000
[    2.403071] [0000000000000008] pgd=0000000000000000, p4d=0000000000000000
[    2.403687] Internal error: Oops: 96000004 [#1] SMP
[    2.404130] Modules linked in: ip_tables x_tables ipv6 xhci_plat_hcd xhci_hcd

dwc3 rockchipdrm drm_cma_helper analogix_dp dw_hdmi realtek drm_display_helper dwc3_of_simple dw_mipi_dsi ehci_platform ohci_platform ohci_hcd ehci_hcd drm_kms_helper dwmac_rk syscopyarea sysfillrect stmmac_platform sysimgblt fb_sys_fops usbcore stmmac pcs_xpcs drm phylink drm_panel_orientation_quirks

[    2.407155] CPU: 4 PID: 71 Comm: kworker/4:6 Not tainted
5.19.0-rc8-next-20220728 #437
[    2.407868] Hardware name: Firefly ROC-RK3399-PC Mezzanine Board (DT)
[    2.408448] Workqueue: events rockchip_usb2phy_otg_sm_work
[    2.408958] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[    2.411634] pc : rockchip_usb2phy_otg_sm_work+0x50/0x330
[    2.414332] lr : process_one_work+0x1d8/0x380
[    2.416948] sp : ffff800009373d60
[    2.419406] x29: ffff800009373d60 x28: 0000000000000000 x27: 0000000000000000
[    2.422199] x26: ffff0000f779fcb8 x25: ffff0000f77a3a05 x24: 000000000000000c
[    2.424978] x23: 0000000000000000 x22: ffff0000010c8258 x21: ffff80000888ec10
[    2.427768] x20: ffff0000010c82f0 x19: 000000000000000c x18: 0000000000000001
[    2.430604] x17: 000000040044ffff x16: 00400034b5503510 x15: 0000000000000000
[    2.433390] x14: ffff000000708000 x13: ffff8000eec96000 x12: 0000000034d4d91d
[    2.436185] x11: 0000000000000000 x10: 0000000000000a10 x9 : ffff000001aa7a74
[    2.438958] x8 : fefefefefefefeff x7 : 0000000000000018 x6 : ffff000001aa7a74
[    2.441668] x5 : 000073746e657665 x4 : 000000000000002f x3 : ffff00000356c808
[    2.444407] x2 : ffff800009373da4 x1 : 000000000000e2ac x0 : ffff80000888eb34
[    2.447190] Call trace:
[    2.449557]  rockchip_usb2phy_otg_sm_work+0x50/0x330
[    2.452169]  process_one_work+0x1d8/0x380
[    2.454684]  worker_thread+0x170/0x4e0
[    2.457056]  kthread+0xd8/0xdc
[    2.459354]  ret_from_fork+0x10/0x20
[    2.461728] Code: 91037015 295be001 f9403c77 b940e413 (f94006e0)
[    2.464338] ---[ end trace 0000000000000000 ]---

Am 22.06.22 um 02:31 schrieb Peter Geis:

Quoted 26 lines

The initial otg state for the phy defaults to device mode. The actual state isn't detected until an ID IRQ fires. Fix this by syncing the ID state during initialization.

Fixes 51a9b2c03dd3 ("phy: rockchip-inno-usb2: Handle ID IRQ")
---
   drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 6 ++++++
   1 file changed, 6 insertions(+)
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +6 -0
index 6711659f727c..6e44069617df 100644
@@ -1162,6 +1162,12 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
                                       EXTCON_USB_HOST, &rport->event_nb);
               if (ret)
                       dev_err(rphy->dev, "register USB HOST notifier failed\n");
+
+             if (!of_property_read_bool(rphy->dev->of_node, "extcon")) {
+                     /* do initial sync of usb state */
+                     ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
+                     extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret);
+             }
       }
 
Quoted 5 lines

drivers/phy/rockchip/phy-rockchip-inno-usb2.c static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, · line 1173

Quoted 1 line
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +0 -0
   out:

Gruß,
--
Markus Reichl

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

#11 lore raw

Hi Peter,

Quoted 63 lines · Peter Geis
Quoted 39 lines · Michael Riesch

Hi Peter,

Quoted 32 lines · Peter Geis
Quoted 18 lines · Michael Riesch

Hi all,

Quoted 5 lines · Peter Geis
Quoted 3 lines · Markus Reichl

Hi,

Quoted 8 lines
Quoted 3 lines

with linux-next-20220728 rk3399-roc-pc does not boot. Bisecting pointed to this commit.
By reverting this commit the board boots again.

Thank you for reporting this, someone was kind enough to reproduce the problem on the rockpro64 and confirmed this is an issue. As I won't have access to my hardware until next month, we should probably revert this until the root cause can be identified.

Quoted 5 lines

Just experienced this issue on my ROCK3 Model A board (RK3568) and reverting this commit solved it.

Having the revert in v6.0-rc2 would be great -- if there is anything I can help to accelerate this please let me know.

If this is now happening on rk356x where I know it works, it now cements my theory that it's a symptom and not the actual problem. Possibly a race condition with the grf and regmap code where it isn't quite ready when called. This code path is called exactly the same way later on when the irq fires.

Quoted 3 lines

What config are you based on? I'm running a stripped down version of the arm64_defconfig, but if you deviate from that it will be helpful in reproducing the issue.

Quoted 7 lines

I posted my Kconfig here: https://pastebin.com/P1As0W4k

FWIW the ROCK3 board has a switch to set the OTG port to device or host, respectively. The NPE does not occur when the switch is set to host.

Best regards,
Michael

Good Afternoon Michael,

Please try the following fix.

Very Respectfully,
Peter Geis

drivers/phy/rockchip/phy-rockchip-inno-usb2.c +0 -0
index 0b1e9337ee8e..5fc7c374a6b4 100644

drivers/phy/rockchip/phy-rockchip-inno-usb2.c static int rockchip_usb2phy_otg_port_init(struct · line 1175

Quoted 7 lines
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +1 -0
@@ -1169,6 +1169,7 @@ static int rockchip_usb2phy_otg_port_init(struct
 rockchip_usb2phy *rphy,
              /* do initial sync of usb state */
              ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
              extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret);
+            ret = 0;
          }
      }

Thanks, this patch indeed solves the issue in my setup. With both role switch settings the NPE does not occur anymore, the correct role is selected, and both roles work (tested with zerogadget (device) and a USB drive (host)). Can you spin a patch?

NB: On the ROCK3 the device tree needs a fix to get the host role going, I'll need to take a closer look on this one and spin a patch.

What I still find strange (but is unrelated to the commit "phy:
rockchip-inno-usb2: Sync initial otg state") is that two and four xhci controllers pop up in the device role and the host role, respectively. For example, in the device role there is a pair of controllers

# lsusb | grep xhci
Bus 006 Device 001: ID 1d6b:0003 Linux 6.0.0-rc1+ xhci-hcd xHCI Host
Controller
Bus 005 Device 001: ID 1d6b:0002 Linux 6.0.0-rc1+ xhci-hcd xHCI Host
Controller
# hexdump /sys/bus/usb/devices/usb5/of_node/reg
0000000 0000 0000 00fd 0000 0000 0000 4000 0000
0000010
# hexdump /sys/bus/usb/devices/usb6/of_node/reg
0000000 0000 0000 00fd 0000 0000 0000 4000 0000
0000010

that are related to the same device (in this case usb_host1_xhci). I would have expected a single controller. Anyone care to enlighten me a bit why there is a pair of them?

Thanks and best regards,
Michael

Quoted 126 lines
Quoted 126 lines
Quoted 126 lines

We should revert it until it's isolated, as well as the patch setting the rk356x to otg since it will again be broken. If someone could weigh in here as well (I currently don't have access to my hardware) it would be helpful.

Quoted 121 lines

Thanks and best regards,
Michael

Quoted 117 lines

Very Respectfully,
Peter Geis

Quoted 103 lines

[    2.398700] Unable to handle kernel NULL pointer dereference at virtual address
0000000000000008
[    2.399517] Mem abort info:
[    2.399772]   ESR = 0x0000000096000004
[    2.400114]   EC = 0x25: DABT (current EL), IL = 32 bits [    2.400594]   SET = 0, FnV = 0
[    2.400873]   EA = 0, S1PTW = 0
[    2.401161]   FSC = 0x04: level 0 translation fault
[    2.401602] Data abort info:
[    2.401864]   ISV = 0, ISS = 0x00000004
[    2.402212]   CM = 0, WnR = 0
[    2.402484] user pgtable: 4k pages, 48-bit VAs, pgdp=0000000001376000
[    2.403071] [0000000000000008] pgd=0000000000000000, p4d=0000000000000000
[    2.403687] Internal error: Oops: 96000004 [#1] SMP
[    2.404130] Modules linked in: ip_tables x_tables ipv6 xhci_plat_hcd xhci_hcd
dwc3 rockchipdrm drm_cma_helper analogix_dp dw_hdmi realtek drm_display_helper
dwc3_of_simple dw_mipi_dsi ehci_platform ohci_platform ohci_hcd ehci_hcd
drm_kms_helper dwmac_rk syscopyarea sysfillrect stmmac_platform sysimgblt
fb_sys_fops usbcore stmmac pcs_xpcs drm phylink drm_panel_orientation_quirks
[    2.407155] CPU: 4 PID: 71 Comm: kworker/4:6 Not tainted 5.19.0-rc8-next-20220728 #437
[    2.407868] Hardware name: Firefly ROC-RK3399-PC Mezzanine Board (DT)
[    2.408448] Workqueue: events rockchip_usb2phy_otg_sm_work [    2.408958] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[    2.411634] pc : rockchip_usb2phy_otg_sm_work+0x50/0x330 [    2.414332] lr : process_one_work+0x1d8/0x380
[    2.416948] sp : ffff800009373d60
[    2.419406] x29: ffff800009373d60 x28: 0000000000000000 x27:
0000000000000000
[    2.422199] x26: ffff0000f779fcb8 x25: ffff0000f77a3a05 x24:
000000000000000c
[    2.424978] x23: 0000000000000000 x22: ffff0000010c8258 x21:
ffff80000888ec10
[    2.427768] x20: ffff0000010c82f0 x19: 000000000000000c x18:
0000000000000001
[    2.430604] x17: 000000040044ffff x16: 00400034b5503510 x15:
0000000000000000
[    2.433390] x14: ffff000000708000 x13: ffff8000eec96000 x12:
0000000034d4d91d
[    2.436185] x11: 0000000000000000 x10: 0000000000000a10 x9 :
ffff000001aa7a74
[    2.438958] x8 : fefefefefefefeff x7 : 0000000000000018 x6 :
ffff000001aa7a74
[    2.441668] x5 : 000073746e657665 x4 : 000000000000002f x3 :
ffff00000356c808
[    2.444407] x2 : ffff800009373da4 x1 : 000000000000e2ac x0 :
ffff80000888eb34
[    2.447190] Call trace:
[    2.449557]  rockchip_usb2phy_otg_sm_work+0x50/0x330 [    2.452169]  process_one_work+0x1d8/0x380
[    2.454684]  worker_thread+0x170/0x4e0
[    2.457056]  kthread+0xd8/0xdc
[    2.459354]  ret_from_fork+0x10/0x20
[    2.461728] Code: 91037015 295be001 f9403c77 b940e413 (f94006e0) [    2.464338] ---[ end trace 0000000000000000 ]---

Am 22.06.22 um 02:31 schrieb Peter Geis:

Quoted 35 lines

The initial otg state for the phy defaults to device mode. The actual
state isn't detected until an ID IRQ fires. Fix this by syncing the ID
state during initialization.

Fixes 51a9b2c03dd3 ("phy: rockchip-inno-usb2: Handle ID IRQ")

---
   drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 6 ++++++

   1 file changed, 6 insertions(+)
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +0 -0
index 6711659f727c..6e44069617df 100644
@@ -1162,6 +1162,12 @@ static int
 rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
                                        EXTCON_USB_HOST,
 &rport->event_nb);
                if (ret)

                       dev_err(rphy->dev, "register USB HOST notifier failed\n");
+
+             if (!of_property_read_bool(rphy->dev->of_node, "extcon")) {
+                     /* do initial sync of usb state */ +                     ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
+                     extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret);
+             }
       }

Quoted 5 lines
Quoted 1 line

   out:

Gruß,

Signature · 1 line
Markus Reichl

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

Tested-by
#12 lore raw
In reply to Peter Geis

Hi Peter,
Am 20.08.22 um 12:23 schrieb Peter Geis:

Quoted 64 lines · Michael Riesch
Quoted 38 lines

Hi Peter,

Quoted 31 lines · Peter Geis
Quoted 17 lines · Michael Riesch

Hi all,

Quoted 4 lines · Peter Geis
Quoted 3 lines · Markus Reichl

Hi,

Quoted 8 lines
Quoted 3 lines

with linux-next-20220728 rk3399-roc-pc does not boot. Bisecting pointed to this commit.
By reverting this commit the board boots again.

Thank you for reporting this, someone was kind enough to reproduce the problem on the rockpro64 and confirmed this is an issue. As I won't have access to my hardware until next month, we should probably revert this until the root cause can be identified.

Quoted 5 lines

Just experienced this issue on my ROCK3 Model A board (RK3568) and reverting this commit solved it.

Having the revert in v6.0-rc2 would be great -- if there is anything I can help to accelerate this please let me know.

If this is now happening on rk356x where I know it works, it now cements my theory that it's a symptom and not the actual problem. Possibly a race condition with the grf and regmap code where it isn't quite ready when called. This code path is called exactly the same way later on when the irq fires.

Quoted 3 lines

What config are you based on? I'm running a stripped down version of the arm64_defconfig, but if you deviate from that it will be helpful in reproducing the issue.

Quoted 7 lines

I posted my Kconfig here: https://pastebin.com/P1As0W4k

FWIW the ROCK3 board has a switch to set the OTG port to device or host, respectively. The NPE does not occur when the switch is set to host.

Best regards,
Michael

Good Afternoon Michael,

Please try the following fix.

Very Respectfully,
Peter Geis

drivers/phy/rockchip/phy-rockchip-inno-usb2.c +0 -0
index 0b1e9337ee8e..5fc7c374a6b4 100644

drivers/phy/rockchip/phy-rockchip-inno-usb2.c static int rockchip_usb2phy_otg_port_init(struct · line 1175

Quoted 7 lines
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +1 -0
@@ -1169,6 +1169,7 @@ static int rockchip_usb2phy_otg_port_init(struct 
 rockchip_usb2phy *rphy,
              /* do initial sync of usb state */
              ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
              extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret);
+            ret = 0;
          }
      }

This fixes the bug i reported on rk3399-roc-pc.
Feel free to add:

Gruß,
--
Markus

Quoted 106 lines
Quoted 97 lines
Quoted 97 lines

We should revert it until it's isolated, as well as the patch setting the rk356x to otg since it will again be broken. If someone could weigh in here as well (I currently don't have access to my hardware) it would be helpful.

Quoted 91 lines

Thanks and best regards,
Michael

Quoted 87 lines

Very Respectfully,
Peter Geis

Quoted 82 lines

[    2.398700] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008
[    2.399517] Mem abort info:
[    2.399772]   ESR = 0x0000000096000004
[    2.400114]   EC = 0x25: DABT (current EL), IL = 32 bits
[    2.400594]   SET = 0, FnV = 0
[    2.400873]   EA = 0, S1PTW = 0
[    2.401161]   FSC = 0x04: level 0 translation fault
[    2.401602] Data abort info:
[    2.401864]   ISV = 0, ISS = 0x00000004
[    2.402212]   CM = 0, WnR = 0
[    2.402484] user pgtable: 4k pages, 48-bit VAs, pgdp=0000000001376000 [    2.403071] [0000000000000008] pgd=0000000000000000, p4d=0000000000000000 [    2.403687] Internal error: Oops: 96000004 [#1] SMP
[    2.404130] Modules linked in: ip_tables x_tables ipv6 xhci_plat_hcd xhci_hcd dwc3 rockchipdrm drm_cma_helper analogix_dp dw_hdmi realtek drm_display_helper dwc3_of_simple dw_mipi_dsi ehci_platform ohci_platform ohci_hcd ehci_hcd drm_kms_helper dwmac_rk syscopyarea sysfillrect stmmac_platform sysimgblt fb_sys_fops usbcore stmmac pcs_xpcs drm phylink drm_panel_orientation_quirks [    2.407155] CPU: 4 PID: 71 Comm: kworker/4:6 Not tainted 5.19.0-rc8-next-20220728 #437
[    2.407868] Hardware name: Firefly ROC-RK3399-PC Mezzanine Board (DT) [    2.408448] Workqueue: events rockchip_usb2phy_otg_sm_work
[    2.408958] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [    2.411634] pc : rockchip_usb2phy_otg_sm_work+0x50/0x330
[    2.414332] lr : process_one_work+0x1d8/0x380
[    2.416948] sp : ffff800009373d60
[    2.419406] x29: ffff800009373d60 x28: 0000000000000000 x27: 0000000000000000 [    2.422199] x26: ffff0000f779fcb8 x25: ffff0000f77a3a05 x24: 000000000000000c [    2.424978] x23: 0000000000000000 x22: ffff0000010c8258 x21: ffff80000888ec10 [    2.427768] x20: ffff0000010c82f0 x19: 000000000000000c x18: 0000000000000001 [    2.430604] x17: 000000040044ffff x16: 00400034b5503510 x15: 0000000000000000 [    2.433390] x14: ffff000000708000 x13: ffff8000eec96000 x12: 0000000034d4d91d [    2.436185] x11: 0000000000000000 x10: 0000000000000a10 x9 : ffff000001aa7a74 [    2.438958] x8 : fefefefefefefeff x7 : 0000000000000018 x6 : ffff000001aa7a74 [    2.441668] x5 : 000073746e657665 x4 : 000000000000002f x3 : ffff00000356c808 [    2.444407] x2 : ffff800009373da4 x1 : 000000000000e2ac x0 : ffff80000888eb34 [    2.447190] Call trace:
[    2.449557]  rockchip_usb2phy_otg_sm_work+0x50/0x330
[    2.452169]  process_one_work+0x1d8/0x380
[    2.454684]  worker_thread+0x170/0x4e0
[    2.457056]  kthread+0xd8/0xdc
[    2.459354]  ret_from_fork+0x10/0x20
[    2.461728] Code: 91037015 295be001 f9403c77 b940e413 (f94006e0)
[    2.464338] ---[ end trace 0000000000000000 ]---

Am 22.06.22 um 02:31 schrieb Peter Geis:

Quoted 29 lines

The initial otg state for the phy defaults to device mode. The actual state isn't detected until an ID IRQ fires. Fix this by syncing the ID state during initialization.

Fixes 51a9b2c03dd3 ("phy: rockchip-inno-usb2: Handle ID IRQ")

---
   drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 6 ++++++

   1 file changed, 6 insertions(+)
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +6 -0
index 6711659f727c..6e44069617df 100644
@@ -1162,6 +1162,12 @@ static int rockchip_usb2phy_otg_port_init(struct 
 rockchip_usb2phy *rphy,
                                        EXTCON_USB_HOST, &rport->event_nb);
                if (ret)
                        dev_err(rphy->dev, "register USB HOST notifier failed\n");
+
+             if (!of_property_read_bool(rphy->dev->of_node, "extcon")) {
+                     /* do initial sync of usb state */
+                     ret = property_enabled(rphy->grf, 
 &rport->port_cfg->utmi_id);
+                     extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, 
 !ret);
+             }

       }

Quoted 1 line

   out:

Gruß,

Signature · 1 line
Markus Reichl
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip