diff mbox

[v6,3/4] PCI: Don't change resources' size when using resource_alignment

Message ID 1475131581-4373-4-git-send-email-xyjxie@linux.vnet.ibm.com (mailing list archive)
State Superseded
Headers show

Commit Message

Yongji Xie Sept. 29, 2016, 6:46 a.m. UTC
When using resource_alignment kernel parameter, the current
implement reassigns the alignment by changing resources' size
which can potentially break some drivers. For example, the driver
uses the size to locate some register whose length is related
to the size.

This patch tries to use IORESOURCE_STARTALIGN to specify the
alignment instead of IORESOURCE_SIZEALIGN. Thus, we can
reassign the alignment without changing resources's size.

Signed-off-by: Yongji Xie <xyjxie@linux.vnet.ibm.com>
---
 drivers/pci/pci.c |   13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
diff mbox

Patch

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index b8357d7..d867c90 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -5086,15 +5086,10 @@  void pci_reassigndev_resource_alignment(struct pci_dev *dev)
 		}
 
 		size = resource_size(r);
-		if (size < align) {
-			size = align;
-			dev_info(&dev->dev,
-				"Rounding up size of resource #%d to %#llx.\n",
-				i, (unsigned long long)size);
-		}
-		r->flags |= IORESOURCE_UNSET;
-		r->end = size - 1;
-		r->start = 0;
+		r->flags &= ~IORESOURCE_SIZEALIGN;
+		r->flags |= IORESOURCE_STARTALIGN | IORESOURCE_UNSET;
+		r->start = max(align, size);
+		r->end = r->start + size - 1;
 	}
 	/* Need to disable bridge's resource window,
 	 * to enable the kernel to reassign new resource