From nobody Fri Apr 3 01:22:42 2026 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 502A73B9D92 for ; Wed, 25 Mar 2026 10:34:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774434889; cv=none; b=HW8gap3/w7oKMtmv0KKIuq1dbep2kbsBvH4D9ODehEg0LwulndVF1WTE/xn2SI6RXKIgXq/oX0xXbPu1vXsS19bYmyCoPQYjx8DLdW9p9ZK6bGJqQnEIWcYH8NW6ge1AiSqlqb1AcGCD0rI3V9nFWeg3ilZZZs+sYJ7S6mw0D+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774434889; c=relaxed/simple; bh=hdqvN8dbIVMYYR3KmJ72pADuTcifzKiscaN6z4J415I=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=usCsmF3bdNnSj56rXmHAl9CcH83jA+okwpjdtNUhyUDivd1nmbBBhzn/d161/I2KVeOyjRvYqCynk7tv4vhgN5+Ms1n8xsFaozhqv8EEI751LyBE+Q5n1KIcczKxNPYJ02Uhk2Q1mgPqyAjw9BRtg/W8q1ibb30kVA2ZKPVs3Vo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZLIh/JkK; arc=none smtp.client-ip=209.85.208.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZLIh/JkK" Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-667f8794e97so10863924a12.2 for ; Wed, 25 Mar 2026 03:34:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774434885; x=1775039685; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=spsunTQ1jn61nQrCZCSca5bTUZV0NZxZvfA/zQfYZcw=; b=ZLIh/JkKXwELVsi2G6pmi6Km8YEw5YbuH+DbkDUbDBJN+qBOguT05ODkKFGgVMNxQe AyvBW8k+aH2Pfu54C3/O1rym9TMLhYUg42sLK5FXJSrK9Ezm+xDGc7bWzXOK8l79CqJo /0upwXFSez/U7z9WTVexkis4xRg6zUd5QWQIQt8vhsS37UupbcOKs/B6C0KoyVBneUco 7UVtSNkpQoW3hY5WBfcb4LPQjQwgBmuhy2S+rdXsHBol0oyrlx9VQh+tmiJOLNep0Cvt koUE4FPkhbqaIVr/CYDXZeliexl05+UyAiOWeetvpDEZhUkog1VB2BXovKnJ1MNh86pd hAGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774434885; x=1775039685; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=spsunTQ1jn61nQrCZCSca5bTUZV0NZxZvfA/zQfYZcw=; b=Jj7dltld9rmNU3MNqsTC/Qtuwr7OBehutFh9LdybKQJiAW6tgBCJ6MxVJQCn2k7zmR FX7AhflOKIGUCCz3hrytU/JBo7OCZY7ISfDKRGqJ41HyDiS8NClIlwjj2bzWRUAmnHSa A7kwa9SwOZZrL3Xz6iIrjI84qG685tAjce8D0JB+5Mse1tRLn9s4miowX4LO3K0/KJcH Su5fXKDofGIJsfIw6TwbVqxJwBfnXSFf9gNh1HF8ItU2UN3CKhmUmxsgerdDRwylDaFk 8jMh0QcO76SuDYBqPNuzCBQ4ykWcVybdkuO8cGi06V7aUR7iK43xyCnHl8LJbBkgPGE+ y2pA== X-Forwarded-Encrypted: i=1; AJvYcCWlz2hunceSkSQ+Rpnmapbktrmb11ieDoQGA8PBK/nmMI0lNCZXOCBjMnjLcG5uEOCWS7KY8fw6d9DTprY=@vger.kernel.org X-Gm-Message-State: AOJu0YwR0rEqc+HgBPjQDxw9LMNaacpzKeLZhvjXy9iPymP3t+3rae5l d87STJ4YeJ97T10w9/RDmDUXycYZ134zdBDyp/ouxD4f/5I8wJAvOx06ymWaMw== X-Gm-Gg: ATEYQzyHT+sLmPcaO9ID8PzD6xqSssjdskofAk9gCJbnV5JZg4lE4P0SG73ipjLh+MU 7qN6SiFlaU5X1YTGPUbvyevsbZcLfHLMgOjM5aK7slKwDvAxvZDocrF1OY3bt3zYgg7AGNXdjgc 6IOW32hnkvvF8bDlulpglgnKdixdg7erk6a6xIw4oPnWMwIxgjXnEsKUUxCO5NjkGDvIQ0YPFny URqYx9iWt6hBC9MYiQKJp0U4B25qXF0wzxUeIsFPIbniZhx4/hNiE07L2ZiA4Kboqt+XtNCuPlG t6gHujNf7GW5HNCsd6nbWuIRKlEStfOnHEog8meAOdEa+lPe8K0VgcjO6P3LakfG4zTbtP62My/ VMNtlsWUbVtTn/72VFeolxqUWJ5eeXTaqCJJPNeMgjQuk/ogqUqdPArcwffWjC4kTUm0p5ZMI8p rFbb2dfYG8yGVN4p1ccepPF6It5jJNEuGgQpU= X-Received: by 2002:a17:906:416:b0:b97:306a:cb56 with SMTP id a640c23a62f3a-b9a3f1b21c7mr125602766b.22.1774434885365; Wed, 25 Mar 2026 03:34:45 -0700 (PDT) Received: from foxbook (bfk214.neoplus.adsl.tpnet.pl. [83.28.48.214]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b98335de182sm759613666b.38.2026.03.25.03.34.44 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 25 Mar 2026 03:34:45 -0700 (PDT) Date: Wed, 25 Mar 2026 11:34:42 +0100 From: Michal Pecio To: Mathias Nyman Cc: Mathias Nyman , Greg Kroah-Hartman , Xu Rao , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3] usb: xhci: Fix debugfs bandwidth reporting Message-ID: <20260325113442.07cc2976.michal.pecio@gmail.com> In-Reply-To: <20260325113246.07681667.michal.pecio@gmail.com> References: <20260304114928.110be4c4.michal.pecio@gmail.com> <20260325113246.07681667.michal.pecio@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace kernel USB speed numbers with xHCI protocol IDs expected by HW. They are numerically equal up to high speed, but instead of SuperSpeed we were querying SuperSpeed+. Gen1 hardware rejects such commands with TRB Error, which resulted in zero available bandwidth being shown. While at that, report failures properly. No attempt made at "tunneling" all possible comp codes through errno, debugfs users may inspect the result through event-ring/trbs. Rename port_bandwidth to port-bandwidth for consistency with others. Signed-off-by: Michal Pecio --- New in v3: - rename port_bandwidth to port-bandwidth New in v2: - print an error string instead of returning -EIO - document known and sometimes unobvious error cases drivers/usb/host/xhci-debugfs.c | 12 ++++++++---- drivers/usb/host/xhci.c | 9 ++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/usb/host/xhci-debugfs.c b/drivers/usb/host/xhci-debugf= s.c index 6cc0f60da771..55778c8cab78 100644 --- a/drivers/usb/host/xhci-debugfs.c +++ b/drivers/usb/host/xhci-debugfs.c @@ -703,6 +703,10 @@ static int xhci_port_bw_show(struct xhci_hcd *xhci, u8= dev_speed, seq_printf(s, "port[%d] available bw: %d%%.\n", i, ctx->bytes[i]); err_out: + if (ret =3D=3D -EIO) { + seq_puts(s, "Get Port Bandwidth failed\n"); + ret =3D 0; + } pm_runtime_put_sync(dev); xhci_free_port_bw_ctx(xhci, ctx); return ret; @@ -713,7 +717,7 @@ static int xhci_ss_bw_show(struct seq_file *s, void *un= used) int ret; struct xhci_hcd *xhci =3D (struct xhci_hcd *)s->private; =20 - ret =3D xhci_port_bw_show(xhci, USB_SPEED_SUPER, s); + ret =3D xhci_port_bw_show(xhci, DEV_PORT_SPEED(XDEV_SS), s); return ret; } =20 @@ -722,7 +726,7 @@ static int xhci_hs_bw_show(struct seq_file *s, void *un= used) int ret; struct xhci_hcd *xhci =3D (struct xhci_hcd *)s->private; =20 - ret =3D xhci_port_bw_show(xhci, USB_SPEED_HIGH, s); + ret =3D xhci_port_bw_show(xhci, DEV_PORT_SPEED(XDEV_HS), s); return ret; } =20 @@ -731,7 +735,7 @@ static int xhci_fs_bw_show(struct seq_file *s, void *un= used) int ret; struct xhci_hcd *xhci =3D (struct xhci_hcd *)s->private; =20 - ret =3D xhci_port_bw_show(xhci, USB_SPEED_FULL, s); + ret =3D xhci_port_bw_show(xhci, DEV_PORT_SPEED(XDEV_FS), s); return ret; } =20 @@ -767,7 +771,7 @@ static const struct file_operations bw_fops =3D { static void xhci_debugfs_create_bandwidth(struct xhci_hcd *xhci, struct dentry *parent) { - parent =3D debugfs_create_dir("port_bandwidth", parent); + parent =3D debugfs_create_dir("port-bandwidth", parent); =20 xhci_debugfs_create_files(xhci, bw_context_files, ARRAY_SIZE(bw_context_files), diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index e6edafdfcdb4..c86819afdede 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -3262,7 +3262,12 @@ void xhci_reset_bandwidth(struct usb_hcd *hcd, struc= t usb_device *udev) } EXPORT_SYMBOL_GPL(xhci_reset_bandwidth); =20 -/* Get the available bandwidth of the ports under the xhci roothub */ +/* + * Get the available bandwidth of the ports under the xhci roothub. + * EIO means the command failed: command not implemented or unsupported + * speed (TRB Error), some ASMedia complete with Parameter Error when + * querying the root hub (slot_id =3D 0), or other error or timeout. + */ int xhci_get_port_bandwidth(struct xhci_hcd *xhci, struct xhci_container_c= tx *ctx, u8 dev_speed) { @@ -3291,6 +3296,8 @@ int xhci_get_port_bandwidth(struct xhci_hcd *xhci, st= ruct xhci_container_ctx *ct spin_unlock_irqrestore(&xhci->lock, flags); =20 wait_for_completion(cmd->completion); + if (cmd->status !=3D COMP_SUCCESS) + ret =3D -EIO; err_out: kfree(cmd->completion); kfree(cmd); --=20 2.48.1