From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 8F59A51FCC3; Wed, 30 Sep 2026 17:55:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790790910; cv=none; b=VC7/BgfyH+ujBI/5d3urEhTWXTVBt+4PK4YawlrmdRxqNsc1vB0ndTfBYXjC69D7zcFENKmt4mYXosi7jJ3yCQ8HcPHjhAea6p76nYSdOYPuoAKu0PsIqF7GF9XiCMZ51pzJVp6RVh7frnmnT2kH+AsPMG48l3IZlmJloFUrK0k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790790910; c=relaxed/simple; bh=xPsLII23F8wAMqmoQIVeasE1jAVxTvQlACOvREYy6Vc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WklJohg8bUO9hFnnd6alz1Wv+cAqV8a1gx6//OJqvAO85a308FItR6H2mfNRH8rAkXZVq4vB1+h46Ui4Mb15g1t5KV2dvVVLYTvko7SGLWZ658kp8ZZCrOnD9rkbU9jGGmqTPp8Tx9LIHMU5PTJGUlN3YR7r0GQ1n4Xa2KKzbtw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=puOzoKZ6; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="puOzoKZ6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC5701F000FF; Wed, 30 Sep 2026 17:55:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790790909; bh=eEcJ28lTBKgumOt4RJC5rREyItAmitHb5cWqZLNLh+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=puOzoKZ6RE7TEb4I9DEzdKlZS/aqxTYpywB/pebvE7LJ1Y1l+c9jPty0zf60R5Vf9 5y3qC8metLyP95Hri/O+6lHOzosHJzGBxjJ0vPVCMz34uJ2BiqCaLMbOenv5UUCvwI CsKfYkIUPGpL/xYklcVnIVYTNDTivNgWOvNV/kso= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mathias Nyman , Sasha Levin Subject: [PATCH 5.15 115/752] xhci: Prevent queuing new commands if xhci is inaccessible Date: Wed, 30 Sep 2026 17:19:45 +0200 Message-ID: <20260930152400.664223277@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152358.131179731@linuxfoundation.org> References: <20260930152358.131179731@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev 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: Mathias Nyman [ Upstream commit 82b70c799281cc24506085be978b829149ba0ca4 ] Refuse to queue a new command on the command ring if xHC is marked inaccessible with the HCD_FLAG_HW_ACCESSIBLE. HCD_FLAG_HW_ACCESSIBLE is set and cleared in suspend and resume. Also print a warning if xhci is being suspended with commands still pending on the command ring. Signed-off-by: Mathias Nyman Link: https://patch.msgid.link/20260603091132.1110849-13-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/host/xhci-ring.c | 6 ++++++ drivers/usb/host/xhci.c | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 9666a34d16947..978ff4d112fb8 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -4499,6 +4499,7 @@ static int queue_command(struct xhci_hcd *xhci, struct xhci_command *cmd, u32 field3, u32 field4, bool command_must_succeed) { int reserved_trbs = xhci->cmd_ring_reserved_trbs; + struct usb_hcd *hcd = xhci_to_hcd(xhci); int ret; if ((xhci->xhc_state & XHCI_STATE_DYING) || @@ -4508,6 +4509,11 @@ static int queue_command(struct xhci_hcd *xhci, struct xhci_command *cmd, return -ESHUTDOWN; } + if (!HCD_HW_ACCESSIBLE(hcd)) { + xhci_warn(xhci, "Can't queue command, xHC not accessible\n"); + return -ESHUTDOWN; + } + if (!command_must_succeed) reserved_trbs++; diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 823fe397bfb10..fee939389a30b 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1053,6 +1053,10 @@ int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup) /* step 1: stop endpoint */ /* skipped assuming that port suspend has done */ + /* Check if command ring is empty */ + if (!list_empty(&xhci->cmd_list)) + xhci_warn(xhci, "Suspending and stopping xHC with pending command!\n"); + /* step 2: clear Run/Stop bit */ command = readl(&xhci->op_regs->command); command &= ~CMD_RUN; -- 2.53.0