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 32BD13A8F7; Mon, 4 Aug 2025 00:31:23 +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=1754267483; cv=none; b=cSXuYtSuALqfm4+C4lFnx+od52QfCfx8Rt2+4s03f9vDCPtcZic3f/pczDtYh7InT4oejsHxb/+SFopSzgn/3ts7HY6PSTpZfz9evfO77v/sgm0UwlRXWlYX1joIflnUGKDOZF03Vh9AzVwaYeA7p6zmbJ0uN7gJc2k7JGSfwro= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754267483; c=relaxed/simple; bh=fiPFPsUUViQOYh0lYiVrj4SgH/o89LMzRckw6SQSNAA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=qy04sUdQkk7UXI6UiIxDbvfPa8uPMuDL1XlfGAQnXHkazDu8+2RU8gTbzHx05pvuZ/xuxJrTuLlWRbHY2tRO6zOUAPFh3lGevEIKnUloreE3ZLrOcMRMuyO5nXKHw7VTe+qMav8j10fG4JOC6ytG61+URQ+wS8JiE354IDfCyI0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ujN2/9UF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ujN2/9UF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB7E6C4CEEB; Mon, 4 Aug 2025 00:31:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1754267483; bh=fiPFPsUUViQOYh0lYiVrj4SgH/o89LMzRckw6SQSNAA=; h=From:To:Cc:Subject:Date:From; b=ujN2/9UFeKIOAdeKHSH15qivnkF82Aw1CQ9C4tMfjgzM5jJo6uUypqfiygX3gdblI yq1IiDSE1IJ/LnUjdmWjODRVaUE/0VKBC4sLv1KrcfVDBgRA5GJfSH/QGXUuVLJ1uF xEg5UKtsaOILHRCgB/aDCvfkFgdwLxyNdyEa4tV2m+BK08HkKqMEC970LYD3ui9VYw 0bl/1q4Zyo1K5rya+DbiY2prR6pvcyl3uEm6WznR/QBrNq0DRBHD8SKoxAO6qumu8Z yXGzAcCkT1BkjPAFmaIAfM6XqOvMf/UI9lOUrPafXnqYFgrva2K+1tSdKWwAH1fhae 80wyhyCwvDOlg== From: Sasha Levin To: patches@lists.linux.dev, stable@vger.kernel.org Cc: Su Hui , Greg Kroah-Hartman , Sasha Levin , mathias.nyman@intel.com, linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 6.12 01/69] usb: xhci: print xhci->xhc_state when queue_command failed Date: Sun, 3 Aug 2025 20:30:11 -0400 Message-Id: <20250804003119.3620476-1-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.12.41 Content-Transfer-Encoding: 8bit From: Su Hui [ Upstream commit 7919407eca2ef562fa6c98c41cfdf6f6cdd69d92 ] When encounters some errors like these: xhci_hcd 0000:4a:00.2: xHCI dying or halted, can't queue_command xhci_hcd 0000:4a:00.2: FIXME: allocate a command ring segment usb usb5-port6: couldn't allocate usb_device It's hard to know whether xhc_state is dying or halted. So it's better to print xhc_state's value which can help locate the resaon of the bug. Signed-off-by: Su Hui Link: https://lore.kernel.org/r/20250725060117.1773770-1-suhui@nfschina.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- LLM Generated explanations, may be completely bogus: **Backport Status: YES** This commit is suitable for backporting to stable kernel trees for the following reasons: 1. **Enhanced Debugging for Real-World Issues**: The commit improves debugging of USB xHCI host controller failures by printing the actual `xhc_state` value when `queue_command` fails. The commit message shows real error messages users encounter ("xHCI dying or halted, can't queue_command"), demonstrating this is a real-world debugging problem. 2. **Minimal and Safe Change**: The change is extremely small and safe - it only modifies a debug print statement from: ```c xhci_dbg(xhci, "xHCI dying or halted, can't queue_command\n"); ``` to: ```c xhci_dbg(xhci, "xHCI dying or halted, can't queue_command. state: 0x%x\n", xhci->xhc_state); ``` 3. **No Functional Changes**: This is a pure diagnostic improvement. It doesn't change any logic, control flow, or data structures. It only adds the state value (0x%x format) to an existing debug message. 4. **Important for Troubleshooting**: The xHCI driver is critical for USB functionality, and when it fails with "dying or halted" states, knowing the exact state helps diagnose whether: - `XHCI_STATE_DYING` (0x1) - controller is dying - `XHCI_STATE_HALTED` (0x2) - controller is halted - Both states (0x3) - controller has both flags set This distinction is valuable for debugging hardware issues, driver bugs, or system problems. 5. **Zero Risk of Regression**: Adding a parameter to a debug print statement has no risk of introducing regressions. The worst case is the debug message prints the state value. 6. **Follows Stable Rules**: This meets stable kernel criteria as it: - Fixes a real debugging limitation - Is obviously correct - Has been tested (signed-off and accepted by Greg KH) - Is small (single line change) - Doesn't add new features, just improves existing diagnostics The commit helps system administrators and developers diagnose USB issues more effectively by providing the actual state value rather than just saying "dying or halted", making it a valuable debugging enhancement for stable kernels. drivers/usb/host/xhci-ring.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 2ff8787f753c..19978f02bb9e 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -4378,7 +4378,8 @@ static int queue_command(struct xhci_hcd *xhci, struct xhci_command *cmd, if ((xhci->xhc_state & XHCI_STATE_DYING) || (xhci->xhc_state & XHCI_STATE_HALTED)) { - xhci_dbg(xhci, "xHCI dying or halted, can't queue_command\n"); + xhci_dbg(xhci, "xHCI dying or halted, can't queue_command. state: 0x%x\n", + xhci->xhc_state); return -ESHUTDOWN; } -- 2.39.5