<p>Re-enumerating the PCIe bus/tree via <code>echo 1 &gt; /sys/bus/pci/rescan</code> is the correct solution. We are using it the same way as you described it.</p>

<p>We are using <code>echo 1 &gt; $pcidevice/remove</code> to disconnect the driver from the device and to detach the device from the tree. The driver (xillybus) is not unloaded, just disconnected. </p>

<p>A better solution is to rescan only the node where your FPGA is attached to. This reduces the over all impact for the system.</p>

<p>This technique is used in the <a href="http://arxiv.org/pdf/1508.06843.pdf" rel="noreferrer">RC3E</a> FPGA cloud system.</p>
How to do a TRUE rescan of PCIe bus
<p>I have an FPGA (Like most of the people asking this question) that gets configured after my Linux kernel does the initial PCIe bus scan and enumeration. As you can guess, the FPGA implements a PCIe endpoint.</p>
<p>I would Like to have the PCIe core re-enumerate the ENTIRE PCIe bus so that my FPGA will then show up and I can load my driver module. I would also like the ability to SWAP the FPGA load out for a different configuration. By this I mean I would like to be able to:</p>
<ol>
<li>Boot Linux</li>
<li>Configure FPGA</li>
<li>Enumerate PCIe endpoint and load module</li>
<li>Remove PCIe endpoint</li>
<li>Re-configure FPGA</li>
<li>Re-enumerate PCIe endpoint</li>
</ol>
<p>All without rebooting Linux</p>
<p>Here are solutions that have been proposed elsewhere but do not solve the problem.</p>
<p><code>echo 1 &gt; /sys/bus/pci/rescan</code> This seems to work (only sometimes) and it does not work if I want to hotswap the FPGA load after it was first enumerated.</p>
<p>Can the Hotplug/power managment facilities of PCIe be used to make this work? If so is there any good resources for how to use the Hotplug system with PCIe? (LDD does not quite cover it thoroughly enough)</p>