From 9bf4bbcaf7939a9b4efb781e61f50cafc2939956 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Mon, 16 Oct 2000 07:24:00 +0000 Subject: [PATCH] When a pci device hasn't had an interrupt routed to it (signified by the intline of 255) go ahead and route the interrupt when we allocate an interrupt. Submitted by: msmith --- sys/dev/pci/pci.c | 19 +++++++++++++++++++ sys/pci/pci.c | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index c0a4bb83c40a..0d3df317273e 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -1286,6 +1286,25 @@ pci_alloc_resource(device_t dev, device_t child, int type, int *rid, { struct pci_devinfo *dinfo = device_get_ivars(child); struct resource_list *rl = &dinfo->resources; + pcicfgregs *cfg = &dinfo->cfg; + + /* + * Perform lazy resource allocation + * + * XXX add support here for SYS_RES_IOPORT and SYS_RES_MEMORY + */ + if (device_get_parent(child) == dev) { + if ((type == SYS_RES_IRQ) && (cfg->intline == 255)) { + cfg->intline = PCIB_ROUTE_INTERRUPT( + device_get_parent(dev), pci_get_slot(child), + cfg->intpin); + if (cfg->intline != 255) { + /* XXX write back to PCI space? */ + resource_list_add(rl, SYS_RES_IRQ, 0, + cfg->intline, cfg->intline, 1); + } + } + } return resource_list_alloc(rl, dev, child, type, rid, start, end, count, flags); diff --git a/sys/pci/pci.c b/sys/pci/pci.c index c0a4bb83c40a..0d3df317273e 100644 --- a/sys/pci/pci.c +++ b/sys/pci/pci.c @@ -1286,6 +1286,25 @@ pci_alloc_resource(device_t dev, device_t child, int type, int *rid, { struct pci_devinfo *dinfo = device_get_ivars(child); struct resource_list *rl = &dinfo->resources; + pcicfgregs *cfg = &dinfo->cfg; + + /* + * Perform lazy resource allocation + * + * XXX add support here for SYS_RES_IOPORT and SYS_RES_MEMORY + */ + if (device_get_parent(child) == dev) { + if ((type == SYS_RES_IRQ) && (cfg->intline == 255)) { + cfg->intline = PCIB_ROUTE_INTERRUPT( + device_get_parent(dev), pci_get_slot(child), + cfg->intpin); + if (cfg->intline != 255) { + /* XXX write back to PCI space? */ + resource_list_add(rl, SYS_RES_IRQ, 0, + cfg->intline, cfg->intline, 1); + } + } + } return resource_list_alloc(rl, dev, child, type, rid, start, end, count, flags);