diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2017-01-14 11:32:01 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2017-01-14 11:32:01 +0000 |
commit | 10a8737833fb19370b60cb6b60d029d088c852ea (patch) | |
tree | ecceea4af9c8fde4c93df84a122350350dc3ad3b /sys | |
parent | 815c4d8f94ac71865eca9b3e2e61c7369ad2013d (diff) |
Revert aml_rdpciaddr changes; breaks several machines that were working
before.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/acpi/acpi.c | 22 | ||||
-rw-r--r-- | sys/dev/acpi/dsdt.c | 34 |
2 files changed, 30 insertions, 26 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index 83300dbe201..46d5558629b 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.319 2017/01/11 09:39:39 jsg Exp $ */ +/* $OpenBSD: acpi.c,v 1.320 2017/01/14 11:32:00 kettenis Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> @@ -614,7 +614,6 @@ acpi_getpci(struct aml_node *node, void *arg) pci->dev = ACPI_ADR_PCIDEV(val); pci->fun = ACPI_ADR_PCIFUN(val); pci->node = node; - node->pci = pci; pci->sub = -1; dnprintf(10, "%.2x:%.2x.%x -> %s\n", @@ -640,12 +639,17 @@ acpi_getpci(struct aml_node *node, void *arg) pci->_s4w = -1; /* Check if PCI device exists */ - if (pci->dev > 31 || pci->fun > 7) - return 1; + if (pci->dev > 0x1F || pci->fun > 7) { + free(pci, M_DEVBUF, sizeof(*pci)); + return (1); + } tag = pci_make_tag(pc, pci->bus, pci->dev, pci->fun); reg = pci_conf_read(pc, tag, PCI_ID_REG); - if (PCI_VENDOR(reg) == PCI_VENDOR_INVALID) - return 1; + if (PCI_VENDOR(reg) == PCI_VENDOR_INVALID) { + free(pci, M_DEVBUF, sizeof(*pci)); + return (1); + } + node->pci = pci; TAILQ_INSERT_TAIL(&acpi_pcidevs, pci, next); @@ -1062,12 +1066,12 @@ acpi_attach(struct device *parent, struct device *self, void *aux) config_found_sm(self, &aaa, acpi_print, acpi_submatch); } - /* get PCI mapping */ - aml_walknodes(&aml_root, AML_WALK_PRE, acpi_getpci, sc); - /* initialize runtime environment */ aml_find_node(&aml_root, "_INI", acpi_inidev, sc); + /* Get PCI mapping */ + aml_walknodes(&aml_root, AML_WALK_PRE, acpi_getpci, sc); + /* attach pci interrupt routing tables */ aml_find_node(&aml_root, "_PRT", acpi_foundprt, sc); diff --git a/sys/dev/acpi/dsdt.c b/sys/dev/acpi/dsdt.c index dd9e7d28feb..16102230779 100644 --- a/sys/dev/acpi/dsdt.c +++ b/sys/dev/acpi/dsdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsdt.c,v 1.229 2017/01/08 12:39:16 kettenis Exp $ */ +/* $OpenBSD: dsdt.c,v 1.230 2017/01/14 11:32:00 kettenis Exp $ */ /* * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> * @@ -2218,16 +2218,21 @@ aml_rdpciaddr(struct aml_node *pcidev, union amlpci_t *addr) { int64_t res; - if (pcidev->pci == NULL) - return -1; - - if (aml_evalinteger(acpi_softc, pcidev, "_ADR", 0, NULL, &res)) - return -1; - - addr->fun = res & 0xffff; - addr->dev = res >> 16; - addr->bus = pcidev->pci->bus; - return 0; + if (aml_evalinteger(acpi_softc, pcidev, "_ADR", 0, NULL, &res) == 0) { + addr->fun = res & 0xFFFF; + addr->dev = res >> 16; + } + while (pcidev != NULL) { + /* HID device (PCI or PCIE root): eval _BBN */ + if (__aml_search(pcidev, "_HID", 0)) { + if (aml_evalinteger(acpi_softc, pcidev, "_BBN", 0, NULL, &res) == 0) { + addr->bus = res; + break; + } + } + pcidev = pcidev->parent; + } + return (0); } /* Read/Write from opregion object */ @@ -2269,12 +2274,7 @@ aml_rwgas(struct aml_value *rgn, int bpos, int blen, struct aml_value *val, if (rgn->v_opregion.iospace == GAS_PCI_CFG_SPACE) { /* Get PCI Root Address for this opregion */ - if (aml_rdpciaddr(rgn->node->parent, &pi)) { - if (mode == ACPI_IOREAD) - pi.fun = 0xffff; - else - return; - } + aml_rdpciaddr(rgn->node->parent, &pi); } tbit = &tmp.v_integer; |