Page MenuHomeFreeBSD

eswin pcie attachment driver
Needs ReviewPublic

Authored by br on Dec 2 2024, 5:08 PM.
Tags
None
Referenced Files
F139528202: D47867.id148252.diff
Sat, Dec 13, 2:58 AM
Unknown Object (File)
Sat, Dec 6, 3:54 PM
Unknown Object (File)
Fri, Nov 28, 9:21 AM
Unknown Object (File)
Tue, Nov 18, 5:01 PM
Unknown Object (File)
Nov 13 2025, 12:26 PM
Unknown Object (File)
Nov 13 2025, 12:30 AM
Unknown Object (File)
Nov 12 2025, 10:19 PM
Unknown Object (File)
Nov 5 2025, 8:37 PM
Subscribers

Details

Reviewers
mhorne
jrtc27
Summary

Add Eswin PCIe attachement driver

Magic host initialization code obtained from u-boot/linux. I don't have documentation for these

Test Plan

Works on Premier P550 with an Intel NVME card inserted. No prior initialization of PCIe in the u-boot needed

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

br requested review of this revision.Dec 2 2024, 5:08 PM
br added reviewers: mhorne, jrtc27.

Same notes here: this looks fine as a glue driver, but I am not in the best position to evaluate PCIe. I hope you will monitor the upstreaming of linux/u-boot to eventually improve the magic initialization code.

sys/riscv/eswin/eswin_pcie.c
116–119

You can use powerof2() from sys/param.h.

433
This revision is now accepted and ready to land.Dec 3 2024, 6:26 PM
sys/riscv/eswin/eswin_pcie.c
210

This is very long.

Use delayed children attach.
It seems the PHY needs extra 500ms to initialize before we probe for devices. Otherwise PCIB could not find a device (Intel NVME in my case).
So instead of waiting for 500ms, postpone the bus enumeration.

Also

  • connect to the build
  • use powerof2 from sys/param.h
  • remove very long delay
  • style
This revision now requires review to proceed.Dec 19 2024, 5:48 PM
sys/riscv/eswin/eswin_pcie.c
410

You have no idea how long this is going to wait. If you need to wait a fixed amount of time then you need to do so somehow, whether synchronously or asynchronously...

sys/riscv/eswin/eswin_pcie.c
410

I noticed the delay needed for Intel DC P3600 only. Other devices enumerate fine without delay.
We can delay for 500ms synchronously but not sure if that is sufficient for all PCIe devices within the PCIe spec.
The delay needed was found empirically.

bus_delayed_attach_children() gives us around 1 second, but I agree that may differ on other systems and can vary depending on boot devices order

sys/riscv/eswin/eswin_pcie.c
209

If this really is PERSTn, there are important ordering and timing requirements on it that may explain your needed 500ms delay and aren’t being adhered to here. PERSTn must be deasserted at least 100ms after the power is stable, but you only wait 1ms here, and I think you also must be ready to train the links within some time period, but you don’t start the links until later. Maybe that’s fine though.

sys/riscv/eswin/eswin_pcie.c
209

It seems the 500ms delay needed just after setting PCIEMGMT_APP_LTSSM_ENABLE bit. Any amount of waiting before setting that bit does not help.