public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@intel.com>
To: raoxu <raoxu@uniontech.com>, gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	wangyuli@uniontech.com, zhanjun@uniontech.com
Subject: Re: [PATCH V2] usb: xhci: Add debugfs support for xHCI port bandwidth
Date: Tue, 4 Mar 2025 14:32:43 +0200	[thread overview]
Message-ID: <7f231ac1-69de-43ce-a9f6-23beade42fc8@intel.com> (raw)
In-Reply-To: <20250303105635.21290-1-raoxu@uniontech.com>

On 3.3.2025 12.56, raoxu wrote:
> From: Xu Rao <raoxu@uniontech.com>
> 
> In many projects, you need to obtain the available bandwidth of the
> xhci roothub port. Refer to xhci rev1_2 and use the TRB_GET_BW
> command to obtain it.
> 
> hardware tested:
> 03:00.3 USB controller: Advanced Micro Devices, Inc. [AMD] Raven USB 3.1
> (prog-if 30 [XHCI])
> Subsystem: Huawei Technologies Co., Ltd. Raven USB 3.1
> Flags: bus master, fast devsel, latency 0, IRQ 30
> Memory at c0300000 (64-bit, non-prefetchable) [size=1M]
> Capabilities: [48] Vendor Specific Information: Len=08 <?>
> Capabilities: [50] Power Management version 3
> Capabilities: [64] Express Endpoint, MSI 00
> Capabilities: [a0] MSI: Enable- Count=1/8 Maskable- 64bit+
> Capabilities: [c0] MSI-X: Enable+ Count=8 Masked-
> Kernel driver in use: xhci_hcd
> 
> test progress:
> 1.cd /sys/kernel/debug/usb/xhci/0000:03:00.3
> cat port_bandwidth
> /sys/kernel/debug/usb/xhci/0000:03:00.3# cat port_bandwidth
> port[1] available bw: 79%.
> port[2] available bw: 79%.
> port[3] available bw: 79%.
> port[4] available bw: 79%.
> port[5] available bw: 90%.
> port[6] available bw: 90%.
> port[7] available bw: 90%.
> port[8] available bw: 90%.
> 2.plug in usb video cammer open it
> cat port_bandwidth
> port[1] available bw: 39%.
> port[2] available bw: 39%.
> port[3] available bw: 39%.
> port[4] available bw: 39%.
> port[5] available bw: 90%.
> port[6] available bw: 90%.
> port[7] available bw: 90%.
> port[8] available bw: 90%.
> 
> Signed-off-by: Xu Rao <raoxu@uniontech.com>

Thanks Xy Rao,
Nice to see support for 'Get Port Bandwidth' feature in xhci.

I do however have some larger rework suggestions to this.

Instead of queuing three commands on one file read, parsing and
copy the content from each context dma into an array on stack, we could
have separate files in debugfs for each speed, and queue one command
for each. we could also skip the array on stack and print values from context
directly.

Something is also very off with the locks in this patch.
Looks like every lock/unlock got replaced with an unlock

Thanks
Mathias


  parent reply	other threads:[~2025-03-04 12:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-03 10:56 [PATCH V2] usb: xhci: Add debugfs support for xHCI port bandwidth raoxu
2025-03-04  5:33 ` Greg KH
2025-03-04 12:32 ` Mathias Nyman [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-03-04  7:09 raoxu
2025-03-04 13:40 ` [PATCH " Greg KH

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=7f231ac1-69de-43ce-a9f6-23beade42fc8@intel.com \
    --to=mathias.nyman@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=raoxu@uniontech.com \
    --cc=wangyuli@uniontech.com \
    --cc=zhanjun@uniontech.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