Re: [PATCH] PCI: spacemit-k1: Request the Gen2 speed change once the link is up
From: Aurelien Jarno
Date: Tue Nov 17 2026 - 16:42:19 EST
Hi Frédéric,
On 2026-11-17 09:55, Frédéric Mahé wrote:
> On a Banana Pi BPI-F3, an NVMe SSD in the M.2 slot (pcie1) always comes
> up at 2.5 GT/s, although the root port and the drive both support
> 5 GT/s. The Directed Speed Change that dw_pcie_setup_rc() requests
> before the LTSSM is enabled has no effect on K1. Setting Retrain Link
> in the root port's Link Control from userspace brings the link to
> 5 GT/s, so the link itself is fine.
>
> Once the link is up, request the speed change again, wait for the
> controller to clear SPEED_CHANGE (as pci-imx6 does), then briefly for
> Link Status to report the new speed. A port with nothing behind it is
> skipped after 100 ms.
>
> With an SK hynix BC511, the link now trains at 5 GT/s x2 and fio
> sequential read goes from 397 to 575-640 MB/s. Data verified with fio
> crc32c. The empty pcie2 port behaves as before.
>
> This change was developed with the help of Claude (Anthropic); I
> reviewed and tested it on hardware.
>
> Signed-off-by: Frédéric Mahé <frederic.mahe@xxxxxxxx>
> ---
> The K1 PCIe cover letter says all ports run at 5 GT/s, so maybe this
> depends on the drive or the firmware; on this board the link always came
> up at 2.5 GT/s before this patch. Tested on top of v7.4-rc1 with "PCI:
> spacemit: Ignore PERST# input in RC mode on K1" (applies cleanly without
> it too).
>
> drivers/pci/controller/dwc/pcie-spacemit-k1.c | 48 +++++++++++++++++++
> 1 file changed, 48 insertions(+)
Thanks, I confirming this works well and greatly improves the NVMe
performance. I have just tested it for a few hours, and I'll mail back
if I encountered any stability issue on the long term. In the meantime:
Tested-by: Aurelien Jarno <aurelien@xxxxxxxxxxx>
--
Aurelien Jarno GPG: 4096R/1DDD8C9B
aurelien@xxxxxxxxxxx http://aurel32.net