hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/pci/setup-res.c
....@@ -73,7 +73,8 @@
7373 /*
7474 * Apparently some Matrox devices have ROM BARs that read
7575 * 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/
7778 */
7879 if (!(res->flags & IORESOURCE_ROM_ENABLE))
7980 return;
....@@ -209,6 +210,17 @@
209210
210211 root = pci_find_parent_resource(dev, res);
211212 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
+ */
212224 if (res->flags & IORESOURCE_IO)
213225 root = &ioport_resource;
214226 else
....@@ -409,10 +421,16 @@
409421 int pci_resize_resource(struct pci_dev *dev, int resno, int size)
410422 {
411423 struct resource *res = dev->resource + resno;
424
+ struct pci_host_bridge *host;
412425 int old, ret;
413426 u32 sizes;
414427 u16 cmd;
415428
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
+
416434 /* Make sure the resource isn't assigned before resizing it. */
417435 if (!(res->flags & IORESOURCE_UNSET))
418436 return -EBUSY;