From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94A35248F71; Mon, 12 May 2025 17:31:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747071095; cv=none; b=TzbQmt94xJJnPIBi+kovqvQ1y3zbvfTMe+sQrCRag4uFG9uzqT4FsyV1NlZF+NUxNvr/uF28QnvQA5JTRJ7jjNDOF5oiBOQXQ2XAtkIkYvpvgwjv1wwlTXuKvP28njnxBoK9OhCOomYVqy31pW5iCGlgpnvubJOwbxYnZ3HP5Kw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747071095; c=relaxed/simple; bh=+ONtzLWt3ib4BKu/3dx2/qwe1C/3OQkmPfEtNSvk4+I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PtdoAe7mIntBU8zSzn51Z6oUeYFyQM3jEF3Pj9AEVvcJWbUfdMhFkAJ1YL0Tl/ElEfTxsv9DKeC+LwLFR7CZ3rm6O2Y9GDny0STxWy3XOxIAWIh0ZY2GbccomBNq0DRFwXqO6ANMk/P+wauxgF6RM8vN1OdLf8duEC3b1gsXQVA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=w76gZEQe; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="w76gZEQe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23C32C4CEE7; Mon, 12 May 2025 17:31:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1747071095; bh=+ONtzLWt3ib4BKu/3dx2/qwe1C/3OQkmPfEtNSvk4+I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w76gZEQeaIa6vm7014LM7V6cYYUw5FYyCaYrFfW3y+ckQ2R50Z6an5exbIBz78fpm 9NJ8f4AzeeMlF8E5IuP3EZQw58XPuFqt5ySlGJ6dNLd9uCy0BAVPzhKZq0Cc1EhyUM NjG9CbZC/ej2lRspLCiCOvT5NHlCg5KBbTqk1OoI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Jim Lin , Wayne Chang Subject: [PATCH 5.15 38/54] usb: host: tegra: Prevent host controller crash when OTG port is used Date: Mon, 12 May 2025 19:29:50 +0200 Message-ID: <20250512172017.176182969@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250512172015.643809034@linuxfoundation.org> References: <20250512172015.643809034@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jim Lin commit 732f35cf8bdfece582f6e4a9c659119036577308 upstream. When a USB device is connected to the OTG port, the tegra_xhci_id_work() routine transitions the PHY to host mode and calls xhci_hub_control() with the SetPortFeature command to enable port power. In certain cases, the XHCI controller may be in a low-power state when this operation occurs. If xhci_hub_control() is invoked while the controller is suspended, the PORTSC register may return 0xFFFFFFFF, indicating a read failure. This causes xhci_hc_died() to be triggered, leading to host controller shutdown. Example backtrace: [ 105.445736] Workqueue: events tegra_xhci_id_work [ 105.445747] dump_backtrace+0x0/0x1e8 [ 105.445759] xhci_hc_died.part.48+0x40/0x270 [ 105.445769] tegra_xhci_set_port_power+0xc0/0x240 [ 105.445774] tegra_xhci_id_work+0x130/0x240 To prevent this, ensure the controller is fully resumed before interacting with hardware registers by calling pm_runtime_get_sync() prior to the host mode transition and xhci_hub_control(). Fixes: f836e7843036 ("usb: xhci-tegra: Add OTG support") Cc: stable Signed-off-by: Jim Lin Signed-off-by: Wayne Chang Link: https://lore.kernel.org/r/20250422114001.126367-1-waynec@nvidia.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-tegra.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/usb/host/xhci-tegra.c +++ b/drivers/usb/host/xhci-tegra.c @@ -1228,6 +1228,7 @@ static void tegra_xhci_id_work(struct wo tegra->otg_usb3_port = tegra_xusb_padctl_get_usb3_companion(tegra->padctl, tegra->otg_usb2_port); + pm_runtime_get_sync(tegra->dev); if (tegra->host_mode) { /* switch to host mode */ if (tegra->otg_usb3_port >= 0) { @@ -1257,6 +1258,7 @@ static void tegra_xhci_id_work(struct wo } tegra_xhci_set_port_power(tegra, true, true); + pm_runtime_mark_last_busy(tegra->dev); } else { if (tegra->otg_usb3_port >= 0) @@ -1264,6 +1266,7 @@ static void tegra_xhci_id_work(struct wo tegra_xhci_set_port_power(tegra, true, false); } + pm_runtime_put_autosuspend(tegra->dev); } #if IS_ENABLED(CONFIG_PM) || IS_ENABLED(CONFIG_PM_SLEEP)