Page MenuHomeFreeBSD

eswin pcie attachment driver
Needs ReviewPublic

Authored by br on Dec 2 2024, 5:08 PM.
Tags
None
Referenced Files
F106842362: D47867.id147366.diff
Mon, Jan 6, 7:23 AM
F106831276: D47867.id.diff
Mon, Jan 6, 3:07 AM
F106829994: D47867.id148252.diff
Mon, Jan 6, 2:34 AM
F106824544: D47867.diff
Mon, Jan 6, 12:21 AM
Unknown Object (File)
Wed, Dec 11, 8:33 AM
Unknown Object (File)
Dec 6 2024, 8:47 AM
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
117–120

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

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

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.Thu, Dec 19, 5:48 PM
sys/riscv/eswin/eswin_pcie.c
409

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
409

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
208

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
208

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.