Hello Furquan Shaikh, Arthur Heymans, Kyösti Mälkki, Aaron Durbin,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/41553
to review the following change.
Change subject: device/pci: Don't enabled unassigned resources ......................................................................
device/pci: Don't enabled unassigned resources
We only have a single bit in the PCI_COMMAND register to enable or disable resources of one type. If any resource of a type is unassigned, we have to disable all of them.
Change-Id: I7a7e9c5c382358446b60a7bd5b29954f80cce07e Signed-off-by: Nico Huber nico.h@gmx.de --- M src/device/pci_device.c 1 file changed, 12 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/53/41553/1
diff --git a/src/device/pci_device.c b/src/device/pci_device.c index 5afbfa9..8df44df 100644 --- a/src/device/pci_device.c +++ b/src/device/pci_device.c @@ -506,7 +506,8 @@ } }
-static void pci_set_resource(struct device *dev, struct resource *resource) +static void pci_set_resource(struct device *const dev, struct resource *const resource, + uint16_t *const command_mask) { /* Make certain the resource has actually been assigned a value. */ if (!(resource->flags & IORESOURCE_ASSIGNED)) { @@ -518,6 +519,11 @@ printk(BIOS_ERR, "ERROR: %s %02lx %s size: 0x%010llx not " "assigned\n", dev_path(dev), resource->index, resource_type(resource), resource->size); + /* We'll have to disable all resources of this type. */ + if (resource->flags & IORESOURCE_MEM) + *command_mask &= ~PCI_COMMAND_MEMORY; + if (resource->flags & IORESOURCE_IO) + *command_mask &= ~PCI_COMMAND_IO; return; } } @@ -561,12 +567,16 @@
void pci_dev_set_resources(struct device *dev) { + uint16_t command_mask = 0xffff; struct resource *res; struct bus *bus; u8 line;
for (res = dev->resource_list; res; res = res->next) - pci_set_resource(dev, res); + pci_set_resource(dev, res, &command_mask); + /* If there are unassigned resources, we might + have to disable others of the same type. */ + dev->command &= command_mask;
for (bus = dev->link_list; bus; bus = bus->next) { if (bus->children)