public inbox for linux-usb@vger.kernel.org
 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,
	Niklas Neronin <niklas.neronin@linux.intel.com>
Subject: [PATCH 3/7] usb: xhci: improve xhci_decode_portsc()
Date: Thu,  4 Sep 2025 17:42:16 +0200	[thread overview]
Message-ID: <20250904154221.2314596-4-niklas.neronin@linux.intel.com> (raw)
In-Reply-To: <20250904154221.2314596-1-niklas.neronin@linux.intel.com>

This patch improves xhci_decode_portsc(), which is used in PORTCS tracing.
The upcoming patch will add tracing to all PORTCS 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>
---
I am aware that the 'XHCI_PORT_RW1CS' macro could replace
'(PORT_PE | PORT_CHANGE_MASK)'. However, it is not located in xhci-port.h,
does not utilize established port macros, and is inaccessible in xhci.h.
To avoid complicating this patch set further, I've decided to defer this
change to part 2. Otherwise, this patch set will grow forever :D
Part 2 will tackle xhci-port.h and all associated macros.

 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 a20f4e7cd43a..f37965e64fd5 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -2395,37 +2395,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)
@@ -2433,6 +2418,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-04 15:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-04 15:42 [PATCH 0/7] usb: xhci: Port Register Set improvements Niklas Neronin
2025-09-04 15:42 ` [PATCH 1/7] usb: xhci: correct indentation for PORTCS tracing function Niklas Neronin
2025-09-04 15:42 ` [PATCH 2/7] usb: xhci: align PORTCS trace with one-based port numbering Niklas Neronin
2025-09-04 15:42 ` Niklas Neronin [this message]
2025-09-04 15:42 ` [PATCH 4/7] usb: xhci: add tracing for PORTCS register writes Niklas Neronin
2025-09-04 15:42 ` [PATCH 5/7] usb: xhci: add USB Port Register Set struct Niklas Neronin
2025-09-04 15:42 ` [PATCH 6/7] usb: xhci: implement " Niklas Neronin
2025-09-04 15:42 ` [PATCH 7/7] usb: xhci: rename Port Register Set pointer in struct 'xhci_port' Niklas Neronin
2025-09-05  2:40   ` Peter Chen (CIX)
2025-09-10  7:24     ` Neronin, Niklas
2025-09-12  0:48       ` Peter Chen (CIX)
2025-09-05  1:57 ` [PATCH 0/7] usb: xhci: Port Register Set improvements Peter Chen (CIX)
2025-09-10  7:12   ` Neronin, Niklas

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=20250904154221.2314596-4-niklas.neronin@linux.intel.com \
    --to=niklas.neronin@linux.intel.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@linux.intel.com \
    /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