aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-12-18 13:13:24 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-12-18 13:13:24 -0500
commit46bdfe6a50b88942f5323f837a3afd93a1c86e60 (patch)
tree9fe5add84d9bcca4670b1af98940d7267c3a3571 /drivers
parentc15524a40a1603dc56a8691c4f50172fb86c23d8 (diff)
parenta2c606d53ab71dee6410f10ef0adf67321d60e06 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6: x86: avoid high BIOS area when allocating address space x86: avoid E820 regions when allocating address space x86: avoid low BIOS area when allocating address space resources: add arch hook for preventing allocation in reserved areas Revert "resources: support allocating space within a region from the top down" Revert "PCI: allocate bus resources from the top down" Revert "x86/PCI: allocate space from the end of a region, not the beginning" Revert "x86: allocate space within a region top-down" Revert "PCI: fix pci_bus_alloc_resource() hang, prefer positive decode" PCI: Update MCP55 quirk to not affect non HyperTransport variants
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pci/bus.c81
-rw-r--r--drivers/pci/quirks.c3
2 files changed, 8 insertions, 76 deletions
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 003170ea2e39..69546e9213dd 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -64,77 +64,6 @@ void pci_bus_remove_resources(struct pci_bus *bus)
64 } 64 }
65} 65}
66 66
67static bool pci_bus_resource_better(struct resource *res1, bool pos1,
68 struct resource *res2, bool pos2)
69{
70 /* If exactly one is positive decode, always prefer that one */
71 if (pos1 != pos2)
72 return pos1 ? true : false;
73
74 /* Prefer the one that contains the highest address */
75 if (res1->end != res2->end)
76 return (res1->end > res2->end) ? true : false;
77
78 /* Otherwise, prefer the one with highest "center of gravity" */
79 if (res1->start != res2->start)
80 return (res1->start > res2->start) ? true : false;
81
82 /* Otherwise, choose one arbitrarily (but consistently) */
83 return (res1 > res2) ? true : false;
84}
85
86static bool pci_bus_resource_positive(struct pci_bus *bus, struct resource *res)
87{
88 struct pci_bus_resource *bus_res;
89
90 /*
91 * This relies on the fact that pci_bus.resource[] refers to P2P or
92 * CardBus bridge base/limit registers, which are always positively
93 * decoded. The pci_bus.resources list contains host bridge or
94 * subtractively decoded resources.
95 */
96 list_for_each_entry(bus_res, &bus->resources, list) {
97 if (bus_res->res == res)
98 return (bus_res->flags & PCI_SUBTRACTIVE_DECODE) ?
99 false : true;
100 }
101 return true;
102}
103
104/*
105 * Find the next-best bus resource after the cursor "res". If the cursor is
106 * NULL, return the best resource. "Best" means that we prefer positive
107 * decode regions over subtractive decode, then those at higher addresses.
108 */
109static struct resource *pci_bus_find_resource_prev(struct pci_bus *bus,
110 unsigned int type,
111 struct resource *res)
112{
113 bool res_pos, r_pos, prev_pos = false;
114 struct resource *r, *prev = NULL;
115 int i;
116
117 res_pos = pci_bus_resource_positive(bus, res);
118 pci_bus_for_each_resource(bus, r, i) {
119 if (!r)
120 continue;
121
122 if ((r->flags & IORESOURCE_TYPE_BITS) != type)
123 continue;
124
125 r_pos = pci_bus_resource_positive(bus, r);
126 if (!res || pci_bus_resource_better(res, res_pos, r, r_pos)) {
127 if (!prev || pci_bus_resource_better(r, r_pos,
128 prev, prev_pos)) {
129 prev = r;
130 prev_pos = r_pos;
131 }
132 }
133 }
134
135 return prev;
136}
137
138/** 67/**
139 * pci_bus_alloc_resource - allocate a resource from a parent bus 68 * pci_bus_alloc_resource - allocate a resource from a parent bus
140 * @bus: PCI bus 69 * @bus: PCI bus
@@ -160,10 +89,9 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
160 resource_size_t), 89 resource_size_t),
161 void *alignf_data) 90 void *alignf_data)
162{ 91{
163 int ret = -ENOMEM; 92 int i, ret = -ENOMEM;
164 struct resource *r; 93 struct resource *r;
165 resource_size_t max = -1; 94 resource_size_t max = -1;
166 unsigned int type = res->flags & IORESOURCE_TYPE_BITS;
167 95
168 type_mask |= IORESOURCE_IO | IORESOURCE_MEM; 96 type_mask |= IORESOURCE_IO | IORESOURCE_MEM;
169 97
@@ -171,9 +99,10 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
171 if (!(res->flags & IORESOURCE_MEM_64)) 99 if (!(res->flags & IORESOURCE_MEM_64))
172 max = PCIBIOS_MAX_MEM_32; 100 max = PCIBIOS_MAX_MEM_32;
173 101
174 /* Look for space at highest addresses first */ 102 pci_bus_for_each_resource(bus, r, i) {
175 r = pci_bus_find_resource_prev(bus, type, NULL); 103 if (!r)
176 for ( ; r; r = pci_bus_find_resource_prev(bus, type, r)) { 104 continue;
105
177 /* type_mask must match */ 106 /* type_mask must match */
178 if ((res->flags ^ r->flags) & type_mask) 107 if ((res->flags ^ r->flags) & type_mask)
179 continue; 108 continue;
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 6f9350cabbd5..313c0bda0a8d 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -2329,6 +2329,9 @@ static void __devinit nvbridge_check_legacy_irq_routing(struct pci_dev *dev)
2329{ 2329{
2330 u32 cfg; 2330 u32 cfg;
2331 2331
2332 if (!pci_find_capability(dev, PCI_CAP_ID_HT))
2333 return;
2334
2332 pci_read_config_dword(dev, 0x74, &cfg); 2335 pci_read_config_dword(dev, 0x74, &cfg);
2333 2336
2334 if (cfg & ((1 << 2) | (1 << 15))) { 2337 if (cfg & ((1 << 2) | (1 << 15))) {