aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYongji Xie <xyjxie@linux.vnet.ibm.com>2016-09-13 05:00:31 -0400
committerBjorn Helgaas <bhelgaas@google.com>2016-09-28 17:44:52 -0400
commitf0b99f70e92dcdc4fecf5cf7ce2f6857ddd82c65 (patch)
treeb6e2535a0411500b62aaebe0164d4a7ae09417bb
parent29b4817d4018df78086157ea3a55c1d9424a7cfc (diff)
PCI: Ignore requested alignment for PROBE_ONLY and fixed resources
Users may request additional alignment of PCI resources, e.g., to align BARs on page boundaries so they can be shared with guests via VFIO. This of course may require reallocation if firmware has already assigned the BARs with smaller alignments. If the platform has requested PCI_PROBE_ONLY, we should never change any PCI BARs, so we can't provide any additional alignment. Also, if a BAR is marked as IORESOURCE_PCI_FIXED, e.g., for PCI Enhanced Allocation or if the firmware depends on the current BAR value, we can't change the alignment. In these cases, log a message and ignore the user's alignment requests. [bhelgaas: changelog, use goto to simplify PCI_PROBE_ONLY check] Signed-off-by: Yongji Xie <xyjxie@linux.vnet.ibm.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
-rw-r--r--drivers/pci/pci.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index aab9d5115a5f..ed9447aee863 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4959,6 +4959,13 @@ static resource_size_t pci_specified_resource_alignment(struct pci_dev *dev)
4959 4959
4960 spin_lock(&resource_alignment_lock); 4960 spin_lock(&resource_alignment_lock);
4961 p = resource_alignment_param; 4961 p = resource_alignment_param;
4962 if (!*p)
4963 goto out;
4964 if (pci_has_flag(PCI_PROBE_ONLY)) {
4965 pr_info_once("PCI: Ignoring requested alignments (PCI_PROBE_ONLY)\n");
4966 goto out;
4967 }
4968
4962 while (*p) { 4969 while (*p) {
4963 count = 0; 4970 count = 0;
4964 if (sscanf(p, "%d%n", &align_order, &count) == 1 && 4971 if (sscanf(p, "%d%n", &align_order, &count) == 1 &&
@@ -5023,6 +5030,7 @@ static resource_size_t pci_specified_resource_alignment(struct pci_dev *dev)
5023 } 5030 }
5024 p++; 5031 p++;
5025 } 5032 }
5033out:
5026 spin_unlock(&resource_alignment_lock); 5034 spin_unlock(&resource_alignment_lock);
5027 return align; 5035 return align;
5028} 5036}
@@ -5063,6 +5071,12 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev)
5063 r = &dev->resource[i]; 5071 r = &dev->resource[i];
5064 if (!(r->flags & IORESOURCE_MEM)) 5072 if (!(r->flags & IORESOURCE_MEM))
5065 continue; 5073 continue;
5074 if (r->flags & IORESOURCE_PCI_FIXED) {
5075 dev_info(&dev->dev, "Ignoring requested alignment for BAR%d: %pR\n",
5076 i, r);
5077 continue;
5078 }
5079
5066 size = resource_size(r); 5080 size = resource_size(r);
5067 if (size < align) { 5081 if (size < align) {
5068 size = align; 5082 size = align;