| .. | .. |
|---|
| 73 | 73 | /* |
|---|
| 74 | 74 | * Apparently some Matrox devices have ROM BARs that read |
|---|
| 75 | 75 | * as zero when disabled, so don't update ROM BARs unless |
|---|
| 76 | | - * they're enabled. See https://lkml.org/lkml/2005/8/30/138. |
|---|
| 76 | + * they're enabled. See |
|---|
| 77 | + * https://lore.kernel.org/r/43147B3D.1030309@vc.cvut.cz/ |
|---|
| 77 | 78 | */ |
|---|
| 78 | 79 | if (!(res->flags & IORESOURCE_ROM_ENABLE)) |
|---|
| 79 | 80 | return; |
|---|
| .. | .. |
|---|
| 209 | 210 | |
|---|
| 210 | 211 | root = pci_find_parent_resource(dev, res); |
|---|
| 211 | 212 | if (!root) { |
|---|
| 213 | + /* |
|---|
| 214 | + * If dev is behind a bridge, accesses will only reach it |
|---|
| 215 | + * if res is inside the relevant bridge window. |
|---|
| 216 | + */ |
|---|
| 217 | + if (pci_upstream_bridge(dev)) |
|---|
| 218 | + return -ENXIO; |
|---|
| 219 | + |
|---|
| 220 | + /* |
|---|
| 221 | + * On the root bus, assume the host bridge will forward |
|---|
| 222 | + * everything. |
|---|
| 223 | + */ |
|---|
| 212 | 224 | if (res->flags & IORESOURCE_IO) |
|---|
| 213 | 225 | root = &ioport_resource; |
|---|
| 214 | 226 | else |
|---|
| .. | .. |
|---|
| 409 | 421 | int pci_resize_resource(struct pci_dev *dev, int resno, int size) |
|---|
| 410 | 422 | { |
|---|
| 411 | 423 | struct resource *res = dev->resource + resno; |
|---|
| 424 | + struct pci_host_bridge *host; |
|---|
| 412 | 425 | int old, ret; |
|---|
| 413 | 426 | u32 sizes; |
|---|
| 414 | 427 | u16 cmd; |
|---|
| 415 | 428 | |
|---|
| 429 | + /* Check if we must preserve the firmware's resource assignment */ |
|---|
| 430 | + host = pci_find_host_bridge(dev->bus); |
|---|
| 431 | + if (host->preserve_config) |
|---|
| 432 | + return -ENOTSUPP; |
|---|
| 433 | + |
|---|
| 416 | 434 | /* Make sure the resource isn't assigned before resizing it. */ |
|---|
| 417 | 435 | if (!(res->flags & IORESOURCE_UNSET)) |
|---|
| 418 | 436 | return -EBUSY; |
|---|