Linux USB
 help / color / mirror / Atom feed
From: Niklas Neronin <niklas.neronin@linux.intel.com>
To: mathias.nyman@linux.intel.com
Cc: linux-usb@vger.kernel.org, peter.chen@kernel.org,
	Niklas Neronin <niklas.neronin@linux.intel.com>
Subject: [PATCH v2 3/8] usb: xhci: improve xhci_decode_portsc()
Date: Wed, 17 Sep 2025 14:58:44 +0200	[thread overview]
Message-ID: <20250917125850.3380560-4-niklas.neronin@linux.intel.com> (raw)
In-Reply-To: <20250917125850.3380560-1-niklas.neronin@linux.intel.com>

This patch improves xhci_decode_portsc(), which is used in PORTSC tracing.
The upcoming patch will add tracing to all PORTSC writes.

Read-Write 1 to Clear (RW1C) bits are now grouped together and prefixed
with "RW1C: " if needed. This is because the meaning of a set RW1C bit
differs between reading and writing. For instance, when reading 'PORT_PE',
a value of '1' indicates the port is enabled, while '0' means it is
disabled. Conversely, writing a '1' to 'PORT_PE' signifies that the port
is being disabled.

Add Port Link State Write Strobe (LWS) to the decoder.

Simplify and reduce the length of the message.

==== Examples ====

Before:
0x00201203 Powered Connected Enabled Link:U0 PortSpeed:4 Change: PRC Wake:
0x0a0002a0 Powered Not-connected Disabled Link:RxDetect PortSpeed:0 \
 Change: Wake: WCE WOE

After:
0x00201203 Power:1 Connect:1 Link:U0 Speed:4 RW1C: PED PRC
0x0a0002a0 Power:1 Connect:0 Link:RxDetect Speed:0 WCE WOE

Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
---
 drivers/usb/host/xhci.h | 52 +++++++++++++++++++++++------------------
 1 file changed, 29 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 85d5b964bf1e..7a245745b289 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -2396,37 +2396,22 @@ static inline const char *xhci_decode_portsc(char *str, u32 portsc)
 	if (portsc == ~(u32)0)
 		return str;
 
-	ret += sprintf(str + ret, "%s %s %s Link:%s PortSpeed:%d ",
-		      portsc & PORT_POWER	? "Powered" : "Powered-off",
-		      portsc & PORT_CONNECT	? "Connected" : "Not-connected",
-		      portsc & PORT_PE		? "Enabled" : "Disabled",
+	ret += sprintf(str + ret, "Power:%d Connect:%d Link:%s Speed:%d ",
+		      !!(portsc & PORT_POWER),
+		      !!(portsc & PORT_CONNECT),
 		      xhci_portsc_link_state_string(portsc),
 		      DEV_PORT_SPEED(portsc));
 
-	if (portsc & PORT_OC)
-		ret += sprintf(str + ret, "OverCurrent ");
+	/* Read-Write 1 to Set */
 	if (portsc & PORT_RESET)
 		ret += sprintf(str + ret, "In-Reset ");
 
-	ret += sprintf(str + ret, "Change: ");
-	if (portsc & PORT_CSC)
-		ret += sprintf(str + ret, "CSC ");
-	if (portsc & PORT_PEC)
-		ret += sprintf(str + ret, "PEC ");
-	if (portsc & PORT_WRC)
-		ret += sprintf(str + ret, "WRC ");
-	if (portsc & PORT_OCC)
-		ret += sprintf(str + ret, "OCC ");
-	if (portsc & PORT_RC)
-		ret += sprintf(str + ret, "PRC ");
-	if (portsc & PORT_PLC)
-		ret += sprintf(str + ret, "PLC ");
-	if (portsc & PORT_CEC)
-		ret += sprintf(str + ret, "CEC ");
+	if (portsc & PORT_OC)
+		ret += sprintf(str + ret, "OCA ");
+	if (portsc & PORT_LINK_STROBE)
+		ret += sprintf(str + ret, "LWS ");
 	if (portsc & PORT_CAS)
 		ret += sprintf(str + ret, "CAS ");
-
-	ret += sprintf(str + ret, "Wake: ");
 	if (portsc & PORT_WKCONN_E)
 		ret += sprintf(str + ret, "WCE ");
 	if (portsc & PORT_WKDISC_E)
@@ -2434,6 +2419,27 @@ static inline const char *xhci_decode_portsc(char *str, u32 portsc)
 	if (portsc & PORT_WKOC_E)
 		ret += sprintf(str + ret, "WOE ");
 
+	/* Read-Write 1 to Clear */
+	if (portsc & (PORT_PE | PORT_CHANGE_MASK)) {
+		ret += sprintf(str + ret, "RW1C: ");
+		if (portsc & PORT_PE)
+			ret += sprintf(str + ret, "PED ");
+		if (portsc & PORT_CSC)
+			ret += sprintf(str + ret, "CSC ");
+		if (portsc & PORT_PEC)
+			ret += sprintf(str + ret, "PEC ");
+		if (portsc & PORT_WRC)
+			ret += sprintf(str + ret, "WRC ");
+		if (portsc & PORT_OCC)
+			ret += sprintf(str + ret, "OCC ");
+		if (portsc & PORT_RC)
+			ret += sprintf(str + ret, "PRC ");
+		if (portsc & PORT_PLC)
+			ret += sprintf(str + ret, "PLC ");
+		if (portsc & PORT_CEC)
+			ret += sprintf(str + ret, "CEC ");
+	}
+
 	return str;
 }
 
-- 
2.50.1


  parent reply	other threads:[~2025-09-17 12:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-17 12:58 [PATCH v2 0/8] usb: xhci: Port Register Set improvements Niklas Neronin
2025-09-17 12:58 ` [PATCH v2 1/8] usb: xhci: correct indentation for PORTSC tracing function Niklas Neronin
2025-09-17 12:58 ` [PATCH v2 2/8] usb: xhci: align PORTSC trace with one-based port numbering Niklas Neronin
2025-09-17 21:14   ` Mathias Nyman
2025-09-17 12:58 ` Niklas Neronin [this message]
2025-09-17 12:58 ` [PATCH v2 4/8] usb: xhci: add tracing for PORTSC register writes Niklas Neronin
2025-09-19 11:54   ` kernel test robot
2025-09-17 12:58 ` [PATCH v2 5/8] usb: xhci: add PORTSC read function Niklas Neronin
2025-09-20 16:19   ` kernel test robot
2025-09-17 12:58 ` [PATCH v2 6/8] usb: xhci: add USB Port Register Set struct Niklas Neronin
2025-09-17 12:58 ` [PATCH v2 7/8] usb: xhci: implement " Niklas Neronin
2025-09-17 12:58 ` [PATCH v2 8/8] usb: xhci: rename Port Register Set pointer in struct 'xhci_port' Niklas Neronin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250917125850.3380560-4-niklas.neronin@linux.intel.com \
    --to=niklas.neronin@linux.intel.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@linux.intel.com \
    --cc=peter.chen@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox