Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

usb: xhci: Fix debugfs bandwidth reporting

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.

Signed-off-by: Michal Pecio <michal.pecio@gmail.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://patch.msgid.link/20260402131342.2628648-4-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Michal Pecio and committed by
Greg Kroah-Hartman
452af0f9 88a985cf

+15 -4
+7 -3
drivers/usb/host/xhci-debugfs.c
··· 700 700 seq_printf(s, "port[%d] available bw: %d%%.\n", i, 701 701 ctx->bytes[i]); 702 702 err_out: 703 + if (ret == -EIO) { 704 + seq_puts(s, "Get Port Bandwidth failed\n"); 705 + ret = 0; 706 + } 703 707 pm_runtime_put_sync(dev); 704 708 xhci_free_port_bw_ctx(xhci, ctx); 705 709 return ret; ··· 714 710 int ret; 715 711 struct xhci_hcd *xhci = (struct xhci_hcd *)s->private; 716 712 717 - ret = xhci_port_bw_show(xhci, USB_SPEED_SUPER, s); 713 + ret = xhci_port_bw_show(xhci, DEV_PORT_SPEED(XDEV_SS), s); 718 714 return ret; 719 715 } 720 716 ··· 723 719 int ret; 724 720 struct xhci_hcd *xhci = (struct xhci_hcd *)s->private; 725 721 726 - ret = xhci_port_bw_show(xhci, USB_SPEED_HIGH, s); 722 + ret = xhci_port_bw_show(xhci, DEV_PORT_SPEED(XDEV_HS), s); 727 723 return ret; 728 724 } 729 725 ··· 732 728 int ret; 733 729 struct xhci_hcd *xhci = (struct xhci_hcd *)s->private; 734 730 735 - ret = xhci_port_bw_show(xhci, USB_SPEED_FULL, s); 731 + ret = xhci_port_bw_show(xhci, DEV_PORT_SPEED(XDEV_FS), s); 736 732 return ret; 737 733 } 738 734
+8 -1
drivers/usb/host/xhci.c
··· 3201 3201 } 3202 3202 EXPORT_SYMBOL_GPL(xhci_reset_bandwidth); 3203 3203 3204 - /* Get the available bandwidth of the ports under the xhci roothub */ 3204 + /* 3205 + * Get the available bandwidth of the ports under the xhci roothub. 3206 + * EIO means the command failed: command not implemented or unsupported 3207 + * speed (TRB Error), some ASMedia complete with Parameter Error when 3208 + * querying the root hub (slot_id = 0), or other error or timeout. 3209 + */ 3205 3210 int xhci_get_port_bandwidth(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx, 3206 3211 u8 dev_speed) 3207 3212 { ··· 3235 3230 spin_unlock_irqrestore(&xhci->lock, flags); 3236 3231 3237 3232 wait_for_completion(cmd->completion); 3233 + if (cmd->status != COMP_SUCCESS) 3234 + ret = -EIO; 3238 3235 err_out: 3239 3236 kfree(cmd->completion); 3240 3237 kfree(cmd);