aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2012-09-17 22:25:34 -0700
committerYinghai Lu <yinghai@kernel.org>2012-09-17 22:25:34 -0700
commit6b4e1cd4d34fa448d8ef6f860a1634a4c7da7e4d (patch)
tree02b8cd695d22014be76d30e051336ddfb633a794
parentf43a3cd9df54e3e0daef270e90dd3d30f57c0808 (diff)
downloadlinux-yinghai-6b4e1cd4d34fa448d8ef6f860a1634a4c7da7e4d.tar.gz
PCI: Allocate resource with big size at first when alignment is the same
When sorting them, put the one with big size before small size. Signed-off-by: Yinghai Lu <yinghai@kernel.org>
-rw-r--r--drivers/pci/setup-bus.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index cec15c100a4b61..e779bdeef47328 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -128,7 +128,7 @@ static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head)
for_each_pci_resource(dev, r, i, PCI_ALL_RES) {
struct pci_dev_resource *dev_res, *tmp;
- resource_size_t r_align;
+ resource_size_t r_align, r_size;
struct list_head *n;
if (r->flags & IORESOURCE_PCI_FIXED)
@@ -143,6 +143,7 @@ static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head)
i, r);
continue;
}
+ r_size = resource_size(r);
tmp = kzalloc(sizeof(*tmp), GFP_KERNEL);
if (!tmp)
@@ -159,7 +160,9 @@ static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head)
align = pci_resource_alignment(dev_res->dev,
dev_res->res);
- if (r_align > align) {
+ if (r_align > align ||
+ (r_align == align &&
+ r_size > resource_size(dev_res->res))) {
n = &dev_res->list;
break;
}