PCI: Expose PCIe Resizable BAR support via sysfs
authorAlex Williamson <alex.williamson@redhat.com>
Fri, 16 Sep 2022 20:44:48 +0000 (14:44 -0600)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 5 Oct 2022 17:21:02 +0000 (12:21 -0500)
commit91fa127794ac1c48069479b9d45eb4c7378c0e30
tree7d5e75ed69ae94d812d65671c4ca421c6eb51d7e
parent568035b01cfb107af8d2e4bd2fb9aea22cf5b868
PCI: Expose PCIe Resizable BAR support via sysfs

Add a simple sysfs interface to Resizable BAR support, largely for the
purposes of assigning such devices to a VM through VFIO.  Resizable BARs
present a difficult feature to expose to a VM through emulation, as
resizing a BAR is done on the host.  It can fail, and often does, but we
have no means via emulation of a PCIe REBAR capability to handle the error
cases.

A vfio-pci specific ioctl interface is also cumbersome as there are often
multiple devices within the same bridge aperture and handling them is a
challenge.  In the interface proposed here, expanding a BAR potentially
requires such devices to be soft-removed during the resize operation and
rescanned after, in order for all the necessary resources to be released.
A pci-sysfs interface is also more universal than a vfio specific
interface.

Please see the ABI documentation update for usage.

Link: https://lore.kernel.org/r/166336088796.3597940.14973499936692558556.stgit@omen
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Cc: Krzysztof Wilczyński <kw@linux.com>
Documentation/ABI/testing/sysfs-bus-pci
drivers/pci/pci-sysfs.c