mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-03 12:52:52 +00:00
PCI: Add pcibios_default_alignment() for arch-specific alignment control
When VFIO passes through a PCI device to a guest, it does not allow the guest to mmap BARs that are smaller than PAGE_SIZE unless it can reserve the rest of the page (see vfio_pci_probe_mmaps()). This is because a page might contain several small BARs for unrelated devices and a guest should not be able to access all of them. VFIO emulates guest accesses to non-mappable BARs, which is functional but slow. On systems with large page sizes, e.g., PowerNV with 64K pages, BARs are more likely to share a page and performance is more likely to be a problem. Add a weak function to set default alignment for all PCI devices. An arch can override it to force the PCI core to place memory BARs on their own pages. Signed-off-by: Yongji Xie <elohimes@gmail.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:
parent
c9c75143a5
commit
0a701aa637
1 changed files with 8 additions and 2 deletions
|
@ -4947,6 +4947,11 @@ void pci_ignore_hotplug(struct pci_dev *dev)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(pci_ignore_hotplug);
|
EXPORT_SYMBOL_GPL(pci_ignore_hotplug);
|
||||||
|
|
||||||
|
resource_size_t __weak pcibios_default_alignment(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#define RESOURCE_ALIGNMENT_PARAM_SIZE COMMAND_LINE_SIZE
|
#define RESOURCE_ALIGNMENT_PARAM_SIZE COMMAND_LINE_SIZE
|
||||||
static char resource_alignment_param[RESOURCE_ALIGNMENT_PARAM_SIZE] = {0};
|
static char resource_alignment_param[RESOURCE_ALIGNMENT_PARAM_SIZE] = {0};
|
||||||
static DEFINE_SPINLOCK(resource_alignment_lock);
|
static DEFINE_SPINLOCK(resource_alignment_lock);
|
||||||
|
@ -4962,14 +4967,15 @@ static resource_size_t pci_specified_resource_alignment(struct pci_dev *dev)
|
||||||
{
|
{
|
||||||
int seg, bus, slot, func, align_order, count;
|
int seg, bus, slot, func, align_order, count;
|
||||||
unsigned short vendor, device, subsystem_vendor, subsystem_device;
|
unsigned short vendor, device, subsystem_vendor, subsystem_device;
|
||||||
resource_size_t align = 0;
|
resource_size_t align = pcibios_default_alignment();
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
spin_lock(&resource_alignment_lock);
|
spin_lock(&resource_alignment_lock);
|
||||||
p = resource_alignment_param;
|
p = resource_alignment_param;
|
||||||
if (!*p)
|
if (!*p && !align)
|
||||||
goto out;
|
goto out;
|
||||||
if (pci_has_flag(PCI_PROBE_ONLY)) {
|
if (pci_has_flag(PCI_PROBE_ONLY)) {
|
||||||
|
align = 0;
|
||||||
pr_info_once("PCI: Ignoring requested alignments (PCI_PROBE_ONLY)\n");
|
pr_info_once("PCI: Ignoring requested alignments (PCI_PROBE_ONLY)\n");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue