On 2025/3/12 23:32, Mathias Nyman wrote: thanks Mathias Nyman, >xHC might be runtime suspended when this debugfs file is read. >We should make sure xHC is running here by calling pm_runtime_get() or similar, >to make sure command can be processed. This suggestion is very useful. Before reading the bandwidth. Need to make sure the device is active >I think its better to create a new command structure with context for each time >we read port bandwidth instead of allocating one shared. > >The port bandwidth won't be read at all in most cases, and sharing has >concurrency issues. > >I'd suggest adding support for a new XHCI_CTX_TYPE_PORT_BW context type to >xhci_alloc_container_ctx(), which allocates and maps 256 bytes, 16byte aligned, >like xhci->small_streams_pool dma pool. When obtaining port bandwidth, alloc a new command structure with context for each time.This is indeed better for concurrent reading. In the specific implementation, I created a new dma pool for port bandwidth context. I used the new function xhci_alloc_port_bw_ctx to get container_ctx instead of still using xhci_alloc_container_ctx. Because xhci_alloc_container_ctx allocates space from device_pool, and xhci_free_container_ctx also operates on device_pool. So it is more intuitive to use a new function instead of adding a new XHCI_CTX_TYPE_PORT_BW context type. I put the code changes on patch v5. thanks, raoxu