From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795970925; b=LGYV1k6YYcH1pHezJs7rbwsCzc/dO7/SSJkeG5w6QUBcquWa7EgJWQQQ7y113kh/NZvc OnSii8XfIHi+07gN4Or2ONjRqqDhw3N9Zcle/NHXzNg72QtJu7TMUgWWk8zQ33B8gGZ1o x8L3qk4Yfue3thAAUR3wFAPWrfxQq5PfCNMz2SgZA7/98B4CWqvggVcv9GEe0PwpN0sTp 32TLmtH/CSyPO1AVnix9/ac62w03FEdzzj1Gi0ofDaS7DQW5OM1AeC8J1vXnpNF/4kGBl lbLKX5RyTmKC9aQJjS1Un/JkZZwQJauNWjJ3SIzjHKGX0ChD2BFktvBBuUicYM6caQg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795970925; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=D1Fq2NFkdTs0XjirHaNQ9+wybpTa/OyR0eXBKlh5l4A=; b=0Fqc5QZMW+E3VqKX9UJwl6KrMLUxRRH4HsX1Pkv8BG5HyCsmJQvYHe/h4tZsuqANJisr OuvyboUbHWS3jlehjo1J7A2TXo8KwYulG9XQ50KMzvvNwxou91rtpDqpUrAbmrVbrS5qE 9UXB1+esuyRMjj8N1IPBDQ283+nA6m3b4J4XXYWsKXYkEbgOzwIQfhGpJAWQnL7e+udzR uL82/CTqsTjJw8X27cZUBsi575kI21kTYpcf+XgY1Y930011Omn955PlvRDfkqjVskO8C 0aPIA3LxiJRHkEJjPrOAJKuoRr22v+v2rBLCMPbTepl44TbRnkMyBAImpoWt6nDpF+w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=h0DaqRUo; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F68B606A31C for ; Sun, 29 Nov 2026 16:48:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=h0DaqRUo Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1E3C1F000C1; Sun, 29 Nov 2026 16:48:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795970925; bh=D1Fq2NFkdTs0XjirHaNQ9+wybpTa/OyR0eXBKlh5l4A=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=h0DaqRUoS9ogbCowXEVo+mQEz4K/MkVMbjobQ1gxxgUACvzF8WjRIJ+7D6chcwpV1 vAMWn+BMJXNSkSUde9MfgPmEMIrLT4xZ3itQdfsGogBWKTsN2bgjBexvPgERf9boJ2 6NHWUlkXLzPxn+IyPADGvAZNuTOghpuqVzsUCiuGFbM8tKa8cdCWfPatO9A0CY6Rad yUuMBA+Fn0Gc30k7ytpyXEm17swmzPo7Ta9ZOkqYP/B+BpW37417ox2ZRKPPWh/VF+ 4p8bYUwrMJCVzI91uDDnq5Oh7gkjjrkuDldV+98ORthk2xSz3dLQHp71eZ2RWZnXwn dbxezkcSzvQ1Q== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] usb: renesas_usbhs: Stop an active host on removal Reply-To: sashiko-reviews@lists.linux.dev To: "Guangshuo Li" Cc: linux-usb@vger.kernel.org In-Reply-To: <20261130-7242f82796-u58-0@mail.sdu.edu.cn> References: <20261130-7242f82796-u58-0@mail.sdu.edu.cn> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Nov 2026 16:48:44 +0000 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] usb: renesas_usbhs: wrong power-off order and leak in usbhs_remove() - [Medium] usb: renesas_usbhs: deadlock on setup_ack_done in usbhs_remove() It also noticed 1 related pre-existing issue this patch does not introduce: - [High] usb: renesas_usbhs: unchecked pm_runtime_get_sync() in usbhsc_power_ctrl() [1] -- commit 25a84d9054639b6536f6c92a19f9076160ea996e Author: Guangshuo Li usb: renesas_usbhs: Stop an active host on removal This commit disables hotplug work and stops an active host controller in usbhs_remove() while skipping host teardown in usbhsh_stop() if the root hub was never registered. > diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usb= hs/common.c > index 22a5175dcceb9..6e3c6891b6b4b 100644 > --- a/drivers/usb/renesas_usbhs/common.c > +++ b/drivers/usb/renesas_usbhs/common.c > @@ -811,7 +811,7 @@ static void usbhs_remove(struct platform_device *pdev) > =20 > dev_dbg(&pdev->dev, "usb remove\n"); > =20 > - flush_delayed_work(&priv->notify_hotplug_work); > + disable_delayed_work_sync(&priv->notify_hotplug_work); > =20 > /* > * Explicitly free the IRQ to ensure the interrupt handler is > @@ -821,6 +821,13 @@ static void usbhs_remove(struct platform_device *pde= v) > */ > devm_free_irq(&pdev->dev, priv->irq, priv); > =20 > + if (usbhs_mod_is_host(priv) > 0) { > + usbhs_mod_call(priv, stop, priv); [Severity: Medium] Can freeing priv->irq before stopping the host hang usb_remove_hcd() when a control transfer is in the setup stage? usbhsh_urb_enqueue() links the control URB onto ep->urb_list and waits uninterruptibly on hpriv->setup_ack_done in usbhsh_setup_stage_packet_push() before setting urb->hcpriv. Because setup_ack_done is only completed from usbhs_interrupt() via usbhsh_irq_setup_ack() or usbhsh_irq_setup_err(), freeing the IRQ (and clearing mod->irq_sack and mod->irq_sign in usbhsh_stop()) before usb_remove_hcd() prevents the setup stage from completing, while usbhsh_urb_dequeue() cannot cancel the URB because urb->hcpriv is still NULL. > + usbhs_mod_change(priv, -1); > + if (usbhs_get_dparam(priv, runtime_pwctrl)) > + usbhsc_power_ctrl(priv, 0); > + } > + > usbhs_mod_remove(priv); [Severity: High] When runtime_pwctrl is enabled, does calling usbhsc_power_ctrl(priv, 0) before usbhs_mod_remove(priv) access SYSCFG after clocks are disabled, and leak power and clocks when removing in gadget mode? If a gadget driver is bound to the UDC while in host mode, usbhs_mod_remove() -> usb_del_gadget_udc() calls usbhsg_pullup() -> usbhs_sys_function_pullup(), which reads and writes SYSCFG after usbhsc_power_ctrl(priv, 0) has already disabled the clocks and suspended the device. Conversely, if the controller is active in gadget mode when removed under runtime_pwctrl, usbhs_mod_is_host(priv) is false and the later !usbhs_get_dparam(priv, runtime_pwctrl) check is also false, so usbhsc_power_ctrl(priv, 0) is never called. Should this follow usbhsc_suspend() by stopping any active module and calling usbhsc_power_ctrl(priv, 0) after usbhs_mod_remove(priv) whenever a module was active or runtime_pwctrl is disabled? [Severity: High] This problem wasn't introduced by this patch, but usbhsc_power_ctrl() does not check the return value of pm_runtime_get_sync() [1]: drivers/usb/renesas_usbhs/common.c:usbhsc_power_ctrl() { if (enable) { /* enable PM */ pm_runtime_get_sync(dev); /* enable clks */ if (usbhsc_clk_prepare_enable(priv)) return; /* enable platform power */ usbhs_platform_call(priv, power_ctrl, pdev, priv->base, enable); /* USB on */ usbhs_sys_clock_ctrl(priv, enable); } If runtime resume fails, usbhsc_power_ctrl() still accesses hardware registers while the device is unpowered and leaves the runtime PM usage counter elevated. [1] https://sashiko.dev/#/bug/linux-7b7fec09-1915-42cd-b05f-29a47b39550d --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130-7242f82796= -u58-0@mail.sdu.edu.cn?part=3D1