mbox series

[v2,0/2] usb: xhci: page size improvements

Message ID 20250113143037.2131346-1-niklas.neronin@linux.intel.com
Headers show
Series usb: xhci: page size improvements | expand

Message

Niklas Neronin Jan. 13, 2025, 2:30 p.m. UTC
Correct off-by-one page size debug message.
Set page size to the xHCI-supported size, instead of 4KB.

Clarified the interpretation of the xHCI spec 1.9 regarding page size.
The correct interpretation is that only one bit is set, indicating the
only supported page size. This is supported by the following sources:

Section 6.6.1, PSZ:
  The PSZ calculation uses the page size bit and would not work with
  multiple bits set.

Section 7.7, Implementation Notes:
  "This version of the xHCI spec only allows an implementation to support
   a single page size, as reported by the PAGESIZE register."


Version 2 changes:
* Added handling for invalid page size register values.

Niklas Neronin (2):
  usb: xhci: correct debug message page size calculation
  usb: xhci: set page size to the xHCI-supported size

 drivers/usb/host/xhci-mem.c | 34 ++++++++++++++++++----------------
 drivers/usb/host/xhci.h     |  8 ++++----
 2 files changed, 22 insertions(+), 20 deletions(-)

Comments

Niklas Neronin Jan. 14, 2025, 8:31 a.m. UTC | #1
On 13/01/2025 18.00, MichaƂ Pecio wrote:
> On Mon, 13 Jan 2025 16:30:36 +0200, Niklas Neronin wrote:
>> Fix this by subtracting one from the result of ffs(). Note that since
>> variable 'i' is unsigned, subtracting one from zero will result in the
>> maximum unsigned integer value. Consequently, the condition 'if (i <
>> 16)' will still function correctly.
> 
> Is it unsigned? I see a simple 'int' here, so this wouldn't work.
> 

You are correct, it is not unsigned.
Thank you for catching it, don't know how I missed it.

Best Regards,
Niklas Neronin