aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/setup-res.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/setup-res.c')
-rw-r--r--drivers/pci/setup-res.c70
1 files changed, 33 insertions, 37 deletions
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 7d35cdf4579f..1a5fc83c71b3 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -26,8 +26,7 @@
26#include "pci.h" 26#include "pci.h"
27 27
28 28
29void 29void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno)
30pci_update_resource(struct pci_dev *dev, struct resource *res, int resno)
31{ 30{
32 struct pci_bus_region region; 31 struct pci_bus_region region;
33 u32 new, check, mask; 32 u32 new, check, mask;
@@ -43,20 +42,20 @@ pci_update_resource(struct pci_dev *dev, struct resource *res, int resno)
43 /* 42 /*
44 * Ignore non-moveable resources. This might be legacy resources for 43 * Ignore non-moveable resources. This might be legacy resources for
45 * which no functional BAR register exists or another important 44 * which no functional BAR register exists or another important
46 * system resource we should better not move around in system address 45 * system resource we shouldn't move around.
47 * space.
48 */ 46 */
49 if (res->flags & IORESOURCE_PCI_FIXED) 47 if (res->flags & IORESOURCE_PCI_FIXED)
50 return; 48 return;
51 49
52 pcibios_resource_to_bus(dev, &region, res); 50 pcibios_resource_to_bus(dev, &region, res);
53 51
54 pr_debug(" got res [%llx:%llx] bus [%llx:%llx] flags %lx for " 52 dev_dbg(&dev->dev, "BAR %d: got res [%#llx-%#llx] bus [%#llx-%#llx] "
55 "BAR %d of %s\n", (unsigned long long)res->start, 53 "flags %#lx\n", resno,
54 (unsigned long long)res->start,
56 (unsigned long long)res->end, 55 (unsigned long long)res->end,
57 (unsigned long long)region.start, 56 (unsigned long long)region.start,
58 (unsigned long long)region.end, 57 (unsigned long long)region.end,
59 (unsigned long)res->flags, resno, pci_name(dev)); 58 (unsigned long)res->flags);
60 59
61 new = region.start | (res->flags & PCI_REGION_FLAG_MASK); 60 new = region.start | (res->flags & PCI_REGION_FLAG_MASK);
62 if (res->flags & IORESOURCE_IO) 61 if (res->flags & IORESOURCE_IO)
@@ -81,9 +80,8 @@ pci_update_resource(struct pci_dev *dev, struct resource *res, int resno)
81 pci_read_config_dword(dev, reg, &check); 80 pci_read_config_dword(dev, reg, &check);
82 81
83 if ((new ^ check) & mask) { 82 if ((new ^ check) & mask) {
84 printk(KERN_ERR "PCI: Error while updating region " 83 dev_err(&dev->dev, "BAR %d: error updating (%#08x != %#08x)\n",
85 "%s/%d (%08x != %08x)\n", pci_name(dev), resno, 84 resno, new, check);
86 new, check);
87 } 85 }
88 86
89 if ((new & (PCI_BASE_ADDRESS_SPACE|PCI_BASE_ADDRESS_MEM_TYPE_MASK)) == 87 if ((new & (PCI_BASE_ADDRESS_SPACE|PCI_BASE_ADDRESS_MEM_TYPE_MASK)) ==
@@ -92,15 +90,14 @@ pci_update_resource(struct pci_dev *dev, struct resource *res, int resno)
92 pci_write_config_dword(dev, reg + 4, new); 90 pci_write_config_dword(dev, reg + 4, new);
93 pci_read_config_dword(dev, reg + 4, &check); 91 pci_read_config_dword(dev, reg + 4, &check);
94 if (check != new) { 92 if (check != new) {
95 printk(KERN_ERR "PCI: Error updating region " 93 dev_err(&dev->dev, "BAR %d: error updating "
96 "%s/%d (high %08x != %08x)\n", 94 "(high %#08x != %#08x)\n", resno, new, check);
97 pci_name(dev), resno, new, check);
98 } 95 }
99 } 96 }
100 res->flags &= ~IORESOURCE_UNSET; 97 res->flags &= ~IORESOURCE_UNSET;
101 pr_debug("PCI: moved device %s resource %d (%lx) to %x\n", 98 dev_dbg(&dev->dev, "BAR %d: moved to bus [%#llx-%#llx] flags %#lx\n",
102 pci_name(dev), resno, res->flags, 99 resno, (unsigned long long)region.start,
103 new & ~PCI_REGION_FLAG_MASK); 100 (unsigned long long)region.end, res->flags);
104} 101}
105 102
106int pci_claim_resource(struct pci_dev *dev, int resource) 103int pci_claim_resource(struct pci_dev *dev, int resource)
@@ -117,10 +114,11 @@ int pci_claim_resource(struct pci_dev *dev, int resource)
117 err = insert_resource(root, res); 114 err = insert_resource(root, res);
118 115
119 if (err) { 116 if (err) {
120 printk(KERN_ERR "PCI: %s region %d of %s %s [%llx:%llx]\n", 117 dev_err(&dev->dev, "BAR %d: %s of %s [%#llx-%#llx]\n",
121 root ? "Address space collision on" : 118 resource,
122 "No parent found for", 119 root ? "address space collision on" :
123 resource, dtype, pci_name(dev), 120 "no parent found for",
121 dtype,
124 (unsigned long long)res->start, 122 (unsigned long long)res->start,
125 (unsigned long long)res->end); 123 (unsigned long long)res->end);
126 } 124 }
@@ -140,11 +138,10 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
140 138
141 align = resource_alignment(res); 139 align = resource_alignment(res);
142 if (!align) { 140 if (!align) {
143 printk(KERN_ERR "PCI: Cannot allocate resource (bogus " 141 dev_err(&dev->dev, "BAR %d: can't allocate resource (bogus "
144 "alignment) %d [%llx:%llx] (flags %lx) of %s\n", 142 "alignment) [%#llx-%#llx] flags %#lx\n",
145 resno, (unsigned long long)res->start, 143 resno, (unsigned long long)res->start,
146 (unsigned long long)res->end, res->flags, 144 (unsigned long long)res->end, res->flags);
147 pci_name(dev));
148 return -EINVAL; 145 return -EINVAL;
149 } 146 }
150 147
@@ -165,11 +162,11 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
165 } 162 }
166 163
167 if (ret) { 164 if (ret) {
168 printk(KERN_ERR "PCI: Failed to allocate %s resource " 165 dev_err(&dev->dev, "BAR %d: can't allocate %s resource "
169 "#%d:%llx@%llx for %s\n", 166 "[%#llx-%#llx]\n", resno,
170 res->flags & IORESOURCE_IO ? "I/O" : "mem", 167 res->flags & IORESOURCE_IO ? "I/O" : "mem",
171 resno, (unsigned long long)size, 168 (unsigned long long)res->start,
172 (unsigned long long)res->start, pci_name(dev)); 169 (unsigned long long)res->end);
173 } else { 170 } else {
174 res->flags &= ~IORESOURCE_STARTALIGN; 171 res->flags &= ~IORESOURCE_STARTALIGN;
175 if (resno < PCI_BRIDGE_RESOURCES) 172 if (resno < PCI_BRIDGE_RESOURCES)
@@ -205,11 +202,11 @@ int pci_assign_resource_fixed(struct pci_dev *dev, int resno)
205 } 202 }
206 203
207 if (ret) { 204 if (ret) {
208 printk(KERN_ERR "PCI: Failed to allocate %s resource " 205 dev_err(&dev->dev, "BAR %d: can't allocate %s resource "
209 "#%d:%llx@%llx for %s\n", 206 "[%#llx-%#llx\n]", resno,
210 res->flags & IORESOURCE_IO ? "I/O" : "mem", 207 res->flags & IORESOURCE_IO ? "I/O" : "mem",
211 resno, (unsigned long long)(res->end - res->start + 1), 208 (unsigned long long)res->start,
212 (unsigned long long)res->start, pci_name(dev)); 209 (unsigned long long)res->end);
213 } else if (resno < PCI_BRIDGE_RESOURCES) { 210 } else if (resno < PCI_BRIDGE_RESOURCES) {
214 pci_update_resource(dev, res, resno); 211 pci_update_resource(dev, res, resno);
215 } 212 }
@@ -239,11 +236,10 @@ void pdev_sort_resources(struct pci_dev *dev, struct resource_list *head)
239 236
240 r_align = resource_alignment(r); 237 r_align = resource_alignment(r);
241 if (!r_align) { 238 if (!r_align) {
242 printk(KERN_WARNING "PCI: bogus alignment of resource " 239 dev_warn(&dev->dev, "BAR %d: bogus alignment "
243 "%d [%llx:%llx] (flags %lx) of %s\n", 240 "[%#llx-%#llx] flags %#lx\n",
244 i, (unsigned long long)r->start, 241 i, (unsigned long long)r->start,
245 (unsigned long long)r->end, r->flags, 242 (unsigned long long)r->end, r->flags);
246 pci_name(dev));
247 continue; 243 continue;
248 } 244 }
249 for (list = head; ; list = list->next) { 245 for (list = head; ; list = list->next) {
@@ -291,7 +287,7 @@ int pci_enable_resources(struct pci_dev *dev, int mask)
291 287
292 if (!r->parent) { 288 if (!r->parent) {
293 dev_err(&dev->dev, "device not available because of " 289 dev_err(&dev->dev, "device not available because of "
294 "BAR %d [%llx:%llx] collisions\n", i, 290 "BAR %d [%#llx-%#llx] collisions\n", i,
295 (unsigned long long) r->start, 291 (unsigned long long) r->start,
296 (unsigned long long) r->end); 292 (unsigned long long) r->end);
297 return -EINVAL; 293 return -EINVAL;