From 59eb83b7aa8a1022b3237e2d4fe8ea1e072c80d2 Mon Sep 17 00:00:00 2001 From: William Wu Date: Fri, 15 Nov 2024 14:36:10 +0800 Subject: [PATCH] usb: typec: tcpci_husb311: Avoid unregister port on shutdown Test on RK3576 EVB1, if do tcpci_unregister_port on husb311_shutdown, it will cause two issues in reboot test. 1. Introducing unnecessary usb mode initialization in dwc3 driver, the call trace: husb311_shutdown -> tcpci_unregister_port -> tcpm_reset_port -> tcpm_mux_set -> usb_role_switch_set_role -> dwc3_usb_role_switch_set 2. More seriously, if the dwc3 driver is unbind before husb311_shutdown, it will cause kernel panic. (1) echo 23000000.usb > /sys/bus/platform/drivers/dwc3/unbind (2) do reboot (3) kernel panic with the following log: Unable to handle kernel access to user memory outside uaccess routines at virtual address 0000000000000010 Mem abort info: ESR = 0x0000000096000005 EC = 0x25: DABT (current EL), IL = 32 bits SET = 0, FnV = 0 EA = 0, S1PTW = 0 FSC = 0x05: level 1 translation fault Data abort info: ISV = 0, ISS = 0x00000005 CM = 0, WnR = 0 user pgtable: 4k pages, 39-bit VAs, pgdp=00000001021ef000 [0000000000000010] pgd=0000000000000000, p4d=0000000000000000, pud=0000000000000000 Internal error: Oops: 0000000096000005 [#1] PREEMPT SMP Modules linked in: CPU: 4 PID: 1 Comm: init Not tainted 6.1.99 #110 Hardware name: Rockchip RK3576 EVB1 V10 Board (DT) pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : usb_role_switch_put+0x24/0x40 lr : tcpm_unregister_port+0x7c/0xd0 ... Call trace: usb_role_switch_put+0x24/0x40 tcpm_unregister_port+0x7c/0xd0 tcpci_unregister_port+0x18/0x2c husb311_shutdown+0x80/0xb0 i2c_device_shutdown+0x3c/0x5c device_shutdown+0x16c/0x21c kernel_restart+0x3c/0x104 Signed-off-by: William Wu Change-Id: Iab02d60b7e25d0cb086fa486e5f31b30029142ec --- drivers/usb/typec/tcpm/tcpci_husb311.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/usb/typec/tcpm/tcpci_husb311.c b/drivers/usb/typec/tcpm/tcpci_husb311.c index 6eaba84a5b69..20d91839a1bc 100644 --- a/drivers/usb/typec/tcpm/tcpci_husb311.c +++ b/drivers/usb/typec/tcpm/tcpci_husb311.c @@ -324,7 +324,6 @@ static void husb311_shutdown(struct i2c_client *client) disable_irq(client->irq); cancel_delayed_work_sync(&chip->pm_work); - tcpci_unregister_port(chip->tcpci); } static int husb311_pm_suspend(struct device *dev)