From: "Michał Pecio" <michal.pecio@gmail.com>
To: Mathias Nyman <mathias.nyman@linux.intel.com>
Cc: Niklas Neronin <niklas.neronin@linux.intel.com>,
linux-usb@vger.kernel.org
Subject: Re: [PATCH 2/2] usb: xhci: set page size to the xHCI-supported size
Date: Mon, 13 Jan 2025 11:16:12 +0100 [thread overview]
Message-ID: <20250113111612.5726c3f6@foxbook> (raw)
In-Reply-To: <0825d8a0-d2f7-49a1-b6a9-a65fc865e923@linux.intel.com>
Hi,
On Fri, 10 Jan 2025 14:35:50 +0200, Mathias Nyman wrote:
> On 8.1.2025 16.28, Niklas Neronin wrote:
> > + page_shift = readl(&xhci->op_regs->page_size) &
> > XHCI_PAGE_SIZE_MASK;
>
> Should we check that page_shift value makes sense here?
Maybe it would make sense to validate it. Interpreting PAGESIZE wrong
is potentially dangerous, because the xHC will assume that scratchpad
buffers are of this size and it can write to them whatever it wants.
Before the buggy ffs() patch 81720ec5320c, the driver used to pick the
lowest set bit or warn if all are zero, but then it still ignored the
calculated size and used 4K.
I would probably be safer to use the highest bit, or just reject the
xHC if it sets multiple bits (5.4.3 says: "the supported page size",
not "a bitmask of supported sizes").
0xffffffff looks like a brain dead chip and not going to work anyway.
> We used to hardcode page_size to 4k, and don't really know if all xHC
> vendors have a sane op_regs->page_size value.
FWIW, all of mine report 4K as per debugfs:
/sys/kernel/debug/usb/xhci/0000:00:10.0/reg-op:PAGESIZE = 0x00000001
/sys/kernel/debug/usb/xhci/0000:02:00.0/reg-op:PAGESIZE = 0x00000001
...
00:10.0 USB controller: Advanced Micro Devices, Inc. [AMD] FCH USB XHCI Controller (rev 20)
02:00.0 USB controller: Advanced Micro Devices, Inc. [AMD] 300 Series Chipset USB 3.1 xHCI Controller (rev 02)
06:00.0 USB controller: ASMedia Technology Inc. ASM1142 USB 3.1 Host Controller
09:00.0 USB controller: Renesas Electronics Corp. uPD720202 USB 3.0 Host Controller (rev 02)
0a:00.0 USB controller: Etron Technology, Inc. EJ168 USB 3.0 Host Controller (rev 01)
0b:00.0 USB controller: NEC Corporation uPD720200 USB 3.0 Host Controller (rev 03)
0c:00.0 USB controller: VIA Technologies, Inc. VL805/806 xHCI USB 3.0 Controller (rev 01)
Also ASM1042 and ASM3142.
And I have an NVIDIA Tegra board which runs some antique kernel and
doesn't warn, so PAGESIZE must at least be non-zero there.
Regards,
Michal
next prev parent reply other threads:[~2025-01-13 10:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-08 14:28 [PATCH 0/2] usb: xhci: page size improvements Niklas Neronin
2025-01-08 14:28 ` [PATCH 1/2] usb: xhci: correct debug message page size calculation Niklas Neronin
2025-01-08 14:28 ` [PATCH 2/2] usb: xhci: set page size to the xHCI-supported size Niklas Neronin
2025-01-10 12:35 ` Mathias Nyman
2025-01-13 10:16 ` Michał Pecio [this message]
2025-01-13 14:18 ` Mathias Nyman
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=20250113111612.5726c3f6@foxbook \
--to=michal.pecio@gmail.com \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@linux.intel.com \
--cc=niklas.neronin@linux.intel.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