Skip to content

Commit b72c409

Browse files
committed
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/PCI: truncate _CRS windows with _LEN > _MAX - _MIN + 1 x86/PCI: for host bridge address space collisions, show conflicting resource frv/PCI: remove redundant warnings x86/PCI: remove redundant warnings PCI: don't say we claimed a resource if we failed PCI quirk: Disable MSI on VIA K8T890 systems PCI quirk: RS780/RS880: work around missing MSI initialization PCI quirk: only apply CX700 PCI bus parking quirk if external VT6212L is present PCI: complain about devices that seem to be broken PCI: print resources consistently with %pR PCI: make disabled window printk style match the enabled ones PCI: break out primary/secondary/subordinate for readability PCI: for address space collisions, show conflicting resource resources: add interfaces that return conflict information PCI: cleanup error return for pcix get and set mmrbc functions PCI: fix access of PCI_X_CMD by pcix get and set mmrbc functions PCI: kill off pci_register_set_vga_state() symbol export. PCI: fix return value from pcix_get_max_mmrbc()
2 parents e4d5042 + d558b48 commit b72c409

File tree

13 files changed

+184
-97
lines changed

13 files changed

+184
-97
lines changed

arch/frv/mb93090-mb00/pci-frv.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
9494
r = &dev->resource[idx];
9595
if (!r->start)
9696
continue;
97-
if (pci_claim_resource(dev, idx) < 0)
98-
printk(KERN_ERR "PCI: Cannot allocate resource region %d of bridge %s\n", idx, pci_name(dev));
97+
pci_claim_resource(dev, idx);
9998
}
10099
}
101100
pcibios_allocate_bus_resources(&bus->children);
@@ -125,7 +124,6 @@ static void __init pcibios_allocate_resources(int pass)
125124
DBG("PCI: Resource %08lx-%08lx (f=%lx, d=%d, p=%d)\n",
126125
r->start, r->end, r->flags, disabled, pass);
127126
if (pci_claim_resource(dev, idx) < 0) {
128-
printk(KERN_ERR "PCI: Cannot allocate resource region %d of device %s\n", idx, pci_name(dev));
129127
/* We'll assign a new address later */
130128
r->end -= r->start;
131129
r->start = 0;

arch/x86/pci/acpi.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
122122
struct acpi_resource_address64 addr;
123123
acpi_status status;
124124
unsigned long flags;
125-
struct resource *root;
126-
u64 start, end;
125+
struct resource *root, *conflict;
126+
u64 start, end, max_len;
127127

128128
status = resource_to_addr(acpi_res, &addr);
129129
if (!ACPI_SUCCESS(status))
@@ -140,6 +140,17 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
140140
} else
141141
return AE_OK;
142142

143+
max_len = addr.maximum - addr.minimum + 1;
144+
if (addr.address_length > max_len) {
145+
dev_printk(KERN_DEBUG, &info->bridge->dev,
146+
"host bridge window length %#llx doesn't fit in "
147+
"%#llx-%#llx, trimming\n",
148+
(unsigned long long) addr.address_length,
149+
(unsigned long long) addr.minimum,
150+
(unsigned long long) addr.maximum);
151+
addr.address_length = max_len;
152+
}
153+
143154
start = addr.minimum + addr.translation_offset;
144155
end = start + addr.address_length - 1;
145156

@@ -157,9 +168,12 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
157168
return AE_OK;
158169
}
159170

160-
if (insert_resource(root, res)) {
171+
conflict = insert_resource_conflict(root, res);
172+
if (conflict) {
161173
dev_err(&info->bridge->dev,
162-
"can't allocate host bridge window %pR\n", res);
174+
"address space collision: host bridge window %pR "
175+
"conflicts with %s %pR\n",
176+
res, conflict->name, conflict);
163177
} else {
164178
pci_bus_add_resource(info->bus, res, 0);
165179
info->res_num++;

arch/x86/pci/i386.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,6 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
127127
continue;
128128
if (!r->start ||
129129
pci_claim_resource(dev, idx) < 0) {
130-
dev_info(&dev->dev,
131-
"can't reserve window %pR\n",
132-
r);
133130
/*
134131
* Something is wrong with the region.
135132
* Invalidate the resource to prevent
@@ -181,8 +178,6 @@ static void __init pcibios_allocate_resources(int pass)
181178
"BAR %d: reserving %pr (d=%d, p=%d)\n",
182179
idx, r, disabled, pass);
183180
if (pci_claim_resource(dev, idx) < 0) {
184-
dev_info(&dev->dev,
185-
"can't reserve %pR\n", r);
186181
/* We'll assign a new address later */
187182
r->end -= r->start;
188183
r->start = 0;

drivers/gpu/drm/radeon/radeon_irq_kms.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,7 @@ int radeon_irq_kms_init(struct radeon_device *rdev)
116116
}
117117
/* enable msi */
118118
rdev->msi_enabled = 0;
119-
/* MSIs don't seem to work on my rs780;
120-
* not sure about rs880 or other rs780s.
121-
* Needs more investigation.
122-
*/
123-
if ((rdev->family >= CHIP_RV380) &&
124-
(rdev->family != CHIP_RS780) &&
125-
(rdev->family != CHIP_RS880)) {
119+
if (rdev->family >= CHIP_RV380) {
126120
int ret = pci_enable_msi(rdev->pdev);
127121
if (!ret) {
128122
rdev->msi_enabled = 1;

drivers/pci/hotplug/pciehp_hpc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -832,9 +832,8 @@ static inline void dbg_ctrl(struct controller *ctrl)
832832
for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
833833
if (!pci_resource_len(pdev, i))
834834
continue;
835-
ctrl_info(ctrl, " PCI resource [%d] : 0x%llx@0x%llx\n",
836-
i, (unsigned long long)pci_resource_len(pdev, i),
837-
(unsigned long long)pci_resource_start(pdev, i));
835+
ctrl_info(ctrl, " PCI resource [%d] : %pR\n",
836+
i, &pdev->resource[i]);
838837
}
839838
ctrl_info(ctrl, "Slot Capabilities : 0x%08x\n", ctrl->slot_cap);
840839
ctrl_info(ctrl, " Physical Slot Number : %d\n", PSN(ctrl));

drivers/pci/ioapic.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ static int ioapic_probe(struct pci_dev *dev, const struct pci_device_id *ent)
3131
acpi_status status;
3232
unsigned long long gsb;
3333
struct ioapic *ioapic;
34-
u64 addr;
3534
int ret;
3635
char *type;
36+
struct resource *res;
3737

3838
handle = DEVICE_ACPI_HANDLE(&dev->dev);
3939
if (!handle)
@@ -69,13 +69,12 @@ static int ioapic_probe(struct pci_dev *dev, const struct pci_device_id *ent)
6969
if (pci_request_region(dev, 0, type))
7070
goto exit_disable;
7171

72-
addr = pci_resource_start(dev, 0);
73-
if (acpi_register_ioapic(ioapic->handle, addr, ioapic->gsi_base))
72+
res = &dev->resource[0];
73+
if (acpi_register_ioapic(ioapic->handle, res->start, ioapic->gsi_base))
7474
goto exit_release;
7575

7676
pci_set_drvdata(dev, ioapic);
77-
dev_info(&dev->dev, "%s at %#llx, GSI %u\n", type, addr,
78-
ioapic->gsi_base);
77+
dev_info(&dev->dev, "%s at %pR, GSI %u\n", type, res, ioapic->gsi_base);
7978
return 0;
8079

8180
exit_release:

drivers/pci/pci.c

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2576,18 +2576,17 @@ EXPORT_SYMBOL_GPL(pci_reset_function);
25762576
*/
25772577
int pcix_get_max_mmrbc(struct pci_dev *dev)
25782578
{
2579-
int err, cap;
2579+
int cap;
25802580
u32 stat;
25812581

25822582
cap = pci_find_capability(dev, PCI_CAP_ID_PCIX);
25832583
if (!cap)
25842584
return -EINVAL;
25852585

2586-
err = pci_read_config_dword(dev, cap + PCI_X_STATUS, &stat);
2587-
if (err)
2586+
if (pci_read_config_dword(dev, cap + PCI_X_STATUS, &stat))
25882587
return -EINVAL;
25892588

2590-
return (stat & PCI_X_STATUS_MAX_READ) >> 12;
2589+
return 512 << ((stat & PCI_X_STATUS_MAX_READ) >> 21);
25912590
}
25922591
EXPORT_SYMBOL(pcix_get_max_mmrbc);
25932592

@@ -2600,18 +2599,17 @@ EXPORT_SYMBOL(pcix_get_max_mmrbc);
26002599
*/
26012600
int pcix_get_mmrbc(struct pci_dev *dev)
26022601
{
2603-
int ret, cap;
2604-
u32 cmd;
2602+
int cap;
2603+
u16 cmd;
26052604

26062605
cap = pci_find_capability(dev, PCI_CAP_ID_PCIX);
26072606
if (!cap)
26082607
return -EINVAL;
26092608

2610-
ret = pci_read_config_dword(dev, cap + PCI_X_CMD, &cmd);
2611-
if (!ret)
2612-
ret = 512 << ((cmd & PCI_X_CMD_MAX_READ) >> 2);
2609+
if (pci_read_config_word(dev, cap + PCI_X_CMD, &cmd))
2610+
return -EINVAL;
26132611

2614-
return ret;
2612+
return 512 << ((cmd & PCI_X_CMD_MAX_READ) >> 2);
26152613
}
26162614
EXPORT_SYMBOL(pcix_get_mmrbc);
26172615

@@ -2626,28 +2624,27 @@ EXPORT_SYMBOL(pcix_get_mmrbc);
26262624
*/
26272625
int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc)
26282626
{
2629-
int cap, err = -EINVAL;
2630-
u32 stat, cmd, v, o;
2627+
int cap;
2628+
u32 stat, v, o;
2629+
u16 cmd;
26312630

26322631
if (mmrbc < 512 || mmrbc > 4096 || !is_power_of_2(mmrbc))
2633-
goto out;
2632+
return -EINVAL;
26342633

26352634
v = ffs(mmrbc) - 10;
26362635

26372636
cap = pci_find_capability(dev, PCI_CAP_ID_PCIX);
26382637
if (!cap)
2639-
goto out;
2638+
return -EINVAL;
26402639

2641-
err = pci_read_config_dword(dev, cap + PCI_X_STATUS, &stat);
2642-
if (err)
2643-
goto out;
2640+
if (pci_read_config_dword(dev, cap + PCI_X_STATUS, &stat))
2641+
return -EINVAL;
26442642

26452643
if (v > (stat & PCI_X_STATUS_MAX_READ) >> 21)
26462644
return -E2BIG;
26472645

2648-
err = pci_read_config_dword(dev, cap + PCI_X_CMD, &cmd);
2649-
if (err)
2650-
goto out;
2646+
if (pci_read_config_word(dev, cap + PCI_X_CMD, &cmd))
2647+
return -EINVAL;
26512648

26522649
o = (cmd & PCI_X_CMD_MAX_READ) >> 2;
26532650
if (o != v) {
@@ -2657,10 +2654,10 @@ int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc)
26572654

26582655
cmd &= ~PCI_X_CMD_MAX_READ;
26592656
cmd |= v << 2;
2660-
err = pci_write_config_dword(dev, cap + PCI_X_CMD, cmd);
2657+
if (pci_write_config_word(dev, cap + PCI_X_CMD, cmd))
2658+
return -EIO;
26612659
}
2662-
out:
2663-
return err;
2660+
return 0;
26642661
}
26652662
EXPORT_SYMBOL(pcix_set_mmrbc);
26662663

@@ -3023,7 +3020,6 @@ EXPORT_SYMBOL(pcim_pin_device);
30233020
EXPORT_SYMBOL(pci_disable_device);
30243021
EXPORT_SYMBOL(pci_find_capability);
30253022
EXPORT_SYMBOL(pci_bus_find_capability);
3026-
EXPORT_SYMBOL(pci_register_set_vga_state);
30273023
EXPORT_SYMBOL(pci_release_regions);
30283024
EXPORT_SYMBOL(pci_request_regions);
30293025
EXPORT_SYMBOL(pci_request_regions_exclusive);

drivers/pci/probe.c

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,19 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
174174
pci_read_config_dword(dev, pos, &sz);
175175
pci_write_config_dword(dev, pos, l);
176176

177+
if (!sz)
178+
goto fail; /* BAR not implemented */
179+
177180
/*
178181
* All bits set in sz means the device isn't working properly.
179-
* If the BAR isn't implemented, all bits must be 0. If it's a
180-
* memory BAR or a ROM, bit 0 must be clear; if it's an io BAR, bit
181-
* 1 must be clear.
182+
* If it's a memory BAR or a ROM, bit 0 must be clear; if it's
183+
* an io BAR, bit 1 must be clear.
182184
*/
183-
if (!sz || sz == 0xffffffff)
185+
if (sz == 0xffffffff) {
186+
dev_err(&dev->dev, "reg %x: invalid size %#x; broken device?\n",
187+
pos, sz);
184188
goto fail;
189+
}
185190

186191
/*
187192
* I don't know how l can have all bits set. Copied from old code.
@@ -244,13 +249,17 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
244249
pos, res);
245250
}
246251
} else {
247-
sz = pci_size(l, sz, mask);
252+
u32 size = pci_size(l, sz, mask);
248253

249-
if (!sz)
254+
if (!size) {
255+
dev_err(&dev->dev, "reg %x: invalid size "
256+
"(l %#x sz %#x mask %#x); broken device?",
257+
pos, l, sz, mask);
250258
goto fail;
259+
}
251260

252261
res->start = l;
253-
res->end = l + sz;
262+
res->end = l + size;
254263

255264
dev_printk(KERN_DEBUG, &dev->dev, "reg %x: %pR\n", pos, res);
256265
}
@@ -312,7 +321,7 @@ static void __devinit pci_read_bridge_io(struct pci_bus *child)
312321
dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res);
313322
} else {
314323
dev_printk(KERN_DEBUG, &dev->dev,
315-
" bridge window [io %04lx - %04lx] reg reading\n",
324+
" bridge window [io %#06lx-%#06lx] (disabled)\n",
316325
base, limit);
317326
}
318327
}
@@ -336,7 +345,7 @@ static void __devinit pci_read_bridge_mmio(struct pci_bus *child)
336345
dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res);
337346
} else {
338347
dev_printk(KERN_DEBUG, &dev->dev,
339-
" bridge window [mem 0x%08lx - 0x%08lx] reg reading\n",
348+
" bridge window [mem %#010lx-%#010lx] (disabled)\n",
340349
base, limit + 0xfffff);
341350
}
342351
}
@@ -387,7 +396,7 @@ static void __devinit pci_read_bridge_mmio_pref(struct pci_bus *child)
387396
dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res);
388397
} else {
389398
dev_printk(KERN_DEBUG, &dev->dev,
390-
" bridge window [mem 0x%08lx - %08lx pref] reg reading\n",
399+
" bridge window [mem %#010lx-%#010lx pref] (disabled)\n",
391400
base, limit + 0xfffff);
392401
}
393402
}
@@ -673,16 +682,20 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
673682
int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS);
674683
u32 buses, i, j = 0;
675684
u16 bctl;
685+
u8 primary, secondary, subordinate;
676686
int broken = 0;
677687

678688
pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses);
689+
primary = buses & 0xFF;
690+
secondary = (buses >> 8) & 0xFF;
691+
subordinate = (buses >> 16) & 0xFF;
679692

680-
dev_dbg(&dev->dev, "scanning behind bridge, config %06x, pass %d\n",
681-
buses & 0xffffff, pass);
693+
dev_dbg(&dev->dev, "scanning [bus %02x-%02x] behind bridge, pass %d\n",
694+
secondary, subordinate, pass);
682695

683696
/* Check if setup is sensible at all */
684697
if (!pass &&
685-
((buses & 0xff) != bus->number || ((buses >> 8) & 0xff) <= bus->number)) {
698+
(primary != bus->number || secondary <= bus->number)) {
686699
dev_dbg(&dev->dev, "bus configuration invalid, reconfiguring\n");
687700
broken = 1;
688701
}
@@ -693,15 +706,15 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
693706
pci_write_config_word(dev, PCI_BRIDGE_CONTROL,
694707
bctl & ~PCI_BRIDGE_CTL_MASTER_ABORT);
695708

696-
if ((buses & 0xffff00) && !pcibios_assign_all_busses() && !is_cardbus && !broken) {
697-
unsigned int cmax, busnr;
709+
if ((secondary || subordinate) && !pcibios_assign_all_busses() &&
710+
!is_cardbus && !broken) {
711+
unsigned int cmax;
698712
/*
699713
* Bus already configured by firmware, process it in the first
700714
* pass and just note the configuration.
701715
*/
702716
if (pass)
703717
goto out;
704-
busnr = (buses >> 8) & 0xFF;
705718

706719
/*
707720
* If we already got to this bus through a different bridge,
@@ -710,13 +723,13 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
710723
* However, we continue to descend down the hierarchy and
711724
* scan remaining child buses.
712725
*/
713-
child = pci_find_bus(pci_domain_nr(bus), busnr);
726+
child = pci_find_bus(pci_domain_nr(bus), secondary);
714727
if (!child) {
715-
child = pci_add_new_bus(bus, dev, busnr);
728+
child = pci_add_new_bus(bus, dev, secondary);
716729
if (!child)
717730
goto out;
718-
child->primary = buses & 0xFF;
719-
child->subordinate = (buses >> 16) & 0xFF;
731+
child->primary = primary;
732+
child->subordinate = subordinate;
720733
child->bridge_ctl = bctl;
721734
}
722735

0 commit comments

Comments
 (0)