Linux USB
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Niklas Neronin" <niklas.neronin@linux.intel.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH v3 03/12] usb: xhci: rework Port Link State macros
Date: Thu, 03 Dec 2026 14:59:34 +0000	[thread overview]
Message-ID: <sashiko-outbox-248041@kernel.org> (raw)
In-Reply-To: <20261203144244.1680587-4-niklas.neronin@linux.intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] usb: xhci: redundant FIELD_GET(PORT_PLS_MASK) calls in
  handle_port_status()
--

commit ee9d70e142f86a51d9ccfe785b68150e454c910c
Author: Niklas Neronin <niklas.neronin@linux.intel.com>

usb: xhci: rework Port Link State macros

This commit replaces the pre-shifted XDEV_* Port Link State macros with
unshifted PLS_* values defined against GENMASK(8, 5), and updates callers
to use FIELD_GET() and FIELD_MODIFY().

> diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
> index 676f71d8305b1..8117e7fe8da2f 100644
> --- a/drivers/usb/host/xhci-ring.c
> +++ b/drivers/usb/host/xhci-ring.c
> @@ -2112,7 +2112,7 @@ static void handle_port_status(struct xhci_hcd *xhci, union xhci_trb *event)
>  	bus_state = &port->rhub->bus_state;
>  	hcd_portnum = port->hcd_portnum;
>  	portsc = xhci_portsc_readl(port);
> -	pls = portsc & PORT_PLS_MASK;
> +	pls = FIELD_GET(PORT_PLS_MASK, portsc);
>  
>  	xhci_dbg(xhci, "Port change event, %d-%d, id %d, portsc: 0x%x\n",
>  		 hcd->self.busnum, hcd_portnum + 1, port_id, portsc);
> @@ -2129,11 +2129,12 @@ static void handle_port_status(struct xhci_hcd *xhci, union xhci_trb *event)
>  	 * Link status is not relible while port is in reset.
>  	 */
>  	if (!(portsc & PORT_RESET)) {
> -		port->link_inactive = (pls == XDEV_INACTIVE);
> +		port->link_inactive = (pls == PLS_INACTIVE);
>  		port->connected = !!(portsc & PORT_CONNECT);
>  	}
>  
> -	if ((portsc & PORT_PLC) && (portsc & PORT_PLS_MASK) == XDEV_RESUME) {
> +	pls = FIELD_GET(PORT_PLS_MASK, portsc);
> +	if ((portsc & PORT_PLC) && pls == PLS_RESUME) {
>  		xhci_dbg(xhci, "port resume event for port %d\n", port_id);
>  
>  		cmd_reg = readl(&xhci->op_regs->command);

[ ... ]

> @@ -2174,11 +2175,9 @@ static void handle_port_status(struct xhci_hcd *xhci, union xhci_trb *event)
>  		}
>  	}
>  
> -	if ((portsc & PORT_PLC) &&
> -	    FIELD_GET(PORT_SPEED_MASK, portsc) >= PORT_SPEED_SS &&
> -	    ((portsc & PORT_PLS_MASK) == XDEV_U0 ||
> -	     (portsc & PORT_PLS_MASK) == XDEV_U1 ||
> -	     (portsc & PORT_PLS_MASK) == XDEV_U2)) {
> +	pls = FIELD_GET(PORT_PLS_MASK, portsc);
> +	if ((portsc & PORT_PLC) && pls <= PLS_U2 &&
> +	    FIELD_GET(PORT_SPEED_MASK, portsc) >= PORT_SPEED_SS) {

[Severity: Low]
Are these two extra pls = FIELD_GET(PORT_PLS_MASK, portsc) assignments
needed?  handle_port_status() already extracts pls right after reading
portsc, and neither portsc nor pls is modified afterwards, so repeating
the extraction can mislead readers into thinking portsc was re-read from
hardware.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203144244.1680587-1-niklas.neronin@linux.intel.com?part=3

  reply	other threads:[~2026-12-03 14:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 14:42 [PATCH v3 00/12] usb: xhci: rework xHCI Port macros Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 01/12] usb: xhci: use BIT() for single bit port register flags Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 02/12] usb: xhci: rework Port Speed macros Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 03/12] usb: xhci: rework Port Link State macros Niklas Neronin
2026-12-03 14:59   ` sashiko-bot [this message]
2026-12-03 14:42 ` [PATCH v3 04/12] usb: xhci: rework Port Indicator Control macro Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 05/12] usb: xhci: rework USB3 PORTPMSC macros Niklas Neronin
2026-12-03 14:50   ` sashiko-bot
2026-12-03 14:42 ` [PATCH v3 06/12] usb: xhci: rework USB2 " Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 07/12] usb: xhci: rework USB3 PORTLI macros Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 08/12] usb: xhci: rework USB2 " Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 09/12] usb: xhci: document USB3 PORTHLPMC register layout Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 10/12] usb: xhci: rework USB2 PORTHLPMC macros Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 11/12] usb: xhci: update port register bitfield comments for consistency Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 12/12] usb: xhci: rename PORTSC field macros to xHCI spec abbreviations Niklas Neronin
2026-12-03 14:54   ` sashiko-bot
2026-12-03 14:59 ` [PATCH v3 00/12] usb: xhci: rework xHCI Port macros sashiko-bot

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=sashiko-outbox-248041@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=niklas.neronin@linux.intel.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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