This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Keystone II PCIe re-initialisation

Hi,

We have a custom K2E based board running Linux, which we are using to connect to an FPGA over PCIe using our own device driver. This is currently all working fine in normal operation, but we have a requirement where we would like to be able to reload the FPGA with a different bitfile 'on the fly', i.e. without rebooting Linux.

This would require us to:

- Unload our device driver

- Potentially remove the PCIe device from Linux, e.g. using /sys/bus/pci/devices/<device>/remove

- Reboot the FPGA with the new image

- Re-initialise PCIe in Linux, e.g. link training, enumeration etc

- Re-load our device driver

We have tried using various combinations of '/sys/bus/pci/devices/<device>/remove' and '/sys/bus/pci/rescan', and have also toggled LTSSM_EN in the CMD_STATUS register to re-train the link, but cannot get PCIe to properly re-initialise and enumerate.

Is it possible to re-initialise PCIe in this way, i.e. without rebooting? I assume we would effectively need to cause keystone_pcie_setup() and keystone_pcie_rc_init(), at least, to be called again after re-loading the FPGA. Is there a way to do this?

Thanks

 

  • Hi,
    Have you tried to build your own driver as module and you can load on demand and you you can reload when you wish to do so.
    Also I would like to suggest you to refer to the PCIe initialization sequence from "PCIe user guide" of keystone platform.
  • Hi,

    Thanks for the reply.

    Yes, we are building our driver as a module and can successfully load and unload it. This is not the problem. It is the underlying PCIe system initialisation and enumeration that we need to re-run after updating our FGPA, i.e. the functionality provided in pcie-keystone.c, not just the device specific initialisation in our driver. This is configured in the kernel at "Bus support->PCI host controller drivers->TI Keystone PCIe support", but as far as I know it is not possible to build this as a module.

    We have been working through the PCIe user guide, experimenting with registers settings using devmem2, with limited success. However we are really looking for a solution that uses existing driver functionality, and that will keep Linux's device info up to date.

    Thanks