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 B147A3C81AD; Wed, 30 Sep 2026 18:51:53 +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=1790794314; cv=none; b=p/nadxH0rsaWaeRQIBj96eioYCIn8TO7CtfTAlh3WB9GL+Uh1ysVMAIu7Vhbl/kBZUE21ZCpX2I8RmS3p5HzeTmd9LAzXsvKHLnc+68mRHNdRDnh6JYXkpUJGjFrfzYedLsZrMfWvvEvxAiHnj+aO+FORd1H7sioZ9O/0LC7UWk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790794314; c=relaxed/simple; bh=NK44zi6OSN+0+Pm1AphhWdZWN3BKZURf38NPKTSBzZU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E4gDUk3b4QCbJm/m5Ucbewt6DEoin7nPndyEFn+DxczYhh94P8rEhkcOe55G84aAl6jPd2iJbhtrfLXtn1c4axsMzucq9LrzfzatwxlYqDrPtWk8zVg9w9tkjr6CQ60HZhDEg/eUvHeU8lb/FIYUyshnzDiem/Lvmbo39WzjLHQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=qu0Cnzkz; 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="qu0Cnzkz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 162F01F000FF; Wed, 30 Sep 2026 18:51:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790794313; bh=5SQW5CCL1Okmczy87svMJIxco8xW1u041QyN1jm1Esw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qu0Cnzkzfrd/aIfOt980J6CPWdGUKkSa4BhJEgdvqIJHRzttXO/9P7i7PoW3Z/dmZ B31YmgBXZ0vjRXHn2KSt53qR8Px+S+m++ZkXPOx6D0wwVLgA+FSOY6a4QvrK0wfyMh rgyaV4hrO/eXsXu0V5GGgWqPE5+X5fjevu+hwZiA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mathias Nyman , Sasha Levin Subject: [PATCH 6.6 0168/1193] xhci: Prevent queuing new commands if xhci is inaccessible Date: Wed, 30 Sep 2026 17:14:12 +0200 Message-ID: <20260930152437.924228730@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152434.301151190@linuxfoundation.org> References: <20260930152434.301151190@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 6.6-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 d06f48ec30452..de9590f6301b6 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -4468,6 +4468,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) || @@ -4477,6 +4478,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 210b5727d1a63..f9fd5bbc3e713 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -919,6 +919,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