title: linux-pcie preallocate BAR space?
body: <p>I have a device that I wish to enable hotplug on. It has BARs larger than NVMe standards. My BIOS (Dell R640) has no options for preallocating BAR space.</p>
  <p>When I try to start with an empty system and add the cards, I get the following errors:</p>
  <pre><code>[  120.951915] pci 0000:67:00.0: BAR 0: no space for [mem size 0x02000000]
  [  120.951919] pci 0000:67:00.0: BAR 0: failed to assign [mem size 0x02000000]
  [  120.951923] pci 0000:67:00.1: BAR 0: no space for [mem size 0x02000000]
  [  120.951927] pci 0000:67:00.1: BAR 0: failed to assign [mem size 0x02000000]
  [  120.951931] pci 0000:67:00.1: BAR 1: no space for [mem size 0x00020000]
  [  120.951935] pci 0000:67:00.1: BAR 1: failed to assign [mem size 0x00020000]
  [  120.951939] pci 0000:67:00.0: BAR 1: no space for [mem size 0x00010000]
  [  120.951942] pci 0000:67:00.0: BAR 1: failed to assign [mem size 0x00010000]
   
  </code></pre>
  <p>My /etc/default/grub is the following:</p>
  <pre><code>GRUB_CMDLINE_LINUX=&quot;crashkernel=auto spectre_v2=retpoline rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet pci=assign-busses,hpbussize=4,realloc=on,hpmemsize=8G&quot;
  </code></pre>
  <p>And my grub.cfg contains the following additions.</p>
  <pre><code>pciehp.pciehp_force=1 pci=pcie_bus_perf
  </code></pre>
  <p>I cannot get any of these to work for hotplug unless I remove the root complex:</p>
  <pre><code>echo 1 &gt; /sys/bus/pci/devices/&lt;root_port&gt;/remove
  *add the card*
  echo 1 &gt; /sys/bus/pci/rescan
  </code></pre>
  <p>This enables all the BARs as needed, however it brings down the entire root complex and all devices on it. Simply rescanning doesn't help.</p>
  <p>How can I tell the kernel to preallocate so I don't need to remove the entire Root Port? I know that the assigned BDF will be the exact same every time (and they will be in the same physical ports, same BAR sizes, etc.). I feel like this has to be an option.</p>