Module Name:    src
Committed By:   christos
Date:           Tue Jan 26 22:52:15 UTC 2016

Modified Files:
        src/sys/dev/acpi/acpica: OsdHardware.c

Log Message:
The new acpi code tries to read the pci configuration registers in the
acpi_probe() phase, before acpi_softc is allocated. Detect this and use
a NULL chipset handle instead of crashing.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/acpi/acpica/OsdHardware.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/acpi/acpica/OsdHardware.c
diff -u src/sys/dev/acpi/acpica/OsdHardware.c:1.9 src/sys/dev/acpi/acpica/OsdHardware.c:1.10
--- src/sys/dev/acpi/acpica/OsdHardware.c:1.9	Fri Dec 27 13:53:25 2013
+++ src/sys/dev/acpi/acpica/OsdHardware.c	Tue Jan 26 17:52:14 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: OsdHardware.c,v 1.9 2013/12/27 18:53:25 christos Exp $	*/
+/*	$NetBSD: OsdHardware.c,v 1.10 2016/01/26 22:52:14 christos Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -44,7 +44,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: OsdHardware.c,v 1.9 2013/12/27 18:53:25 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: OsdHardware.c,v 1.10 2016/01/26 22:52:14 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -212,15 +212,15 @@ AcpiOsReadPciConfiguration(ACPI_PCI_ID *
 {
 	pcitag_t tag;
 	pcireg_t tmp;
+	pci_chipset_tag_t pc = acpi_softc ? acpi_softc->sc_pc : NULL;
 
 	/* XXX Need to deal with "segment" ("hose" in Alpha terminology). */
 
 	if (PciId->Bus >= 256 || PciId->Device >= 32 || PciId->Function >= 8)
 		return AE_BAD_PARAMETER;
 
-	tag = pci_make_tag(acpi_softc->sc_pc, PciId->Bus, PciId->Device,
-	    PciId->Function);
-	tmp = pci_conf_read(acpi_softc->sc_pc, tag, Register & ~3);
+	tag = pci_make_tag(pc, PciId->Bus, PciId->Device, PciId->Function);
+	tmp = pci_conf_read(pc, tag, Register & ~3);
 
 	switch (Width) {
 	case 8:
@@ -253,21 +253,21 @@ AcpiOsWritePciConfiguration(ACPI_PCI_ID 
 {
 	pcitag_t tag;
 	pcireg_t tmp;
+	pci_chipset_tag_t pc = acpi_softc ? acpi_softc->sc_pc : NULL;
 
 	/* XXX Need to deal with "segment" ("hose" in Alpha terminology). */
 
-	tag = pci_make_tag(acpi_softc->sc_pc, PciId->Bus, PciId->Device,
-	    PciId->Function);
+	tag = pci_make_tag(pc, PciId->Bus, PciId->Device, PciId->Function);
 
 	switch (Width) {
 	case 8:
-		tmp = pci_conf_read(acpi_softc->sc_pc, tag, Register & ~3);
+		tmp = pci_conf_read(pc, tag, Register & ~3);
 		tmp &= ~(0xff << ((Register & 3) * 8));
 		tmp |= (Value << ((Register & 3) * 8));
 		break;
 
 	case 16:
-		tmp = pci_conf_read(acpi_softc->sc_pc, tag, Register & ~3);
+		tmp = pci_conf_read(pc, tag, Register & ~3);
 		tmp &= ~(0xffff << ((Register & 3) * 8));
 		tmp |= (Value << ((Register & 3) * 8));
 		break;
@@ -280,7 +280,7 @@ AcpiOsWritePciConfiguration(ACPI_PCI_ID 
 		return AE_BAD_PARAMETER;
 	}
 
-	pci_conf_write(acpi_softc->sc_pc, tag, Register & ~3, tmp);
+	pci_conf_write(pc, tag, Register & ~3, tmp);
 
 	return AE_OK;
 }

Reply via email to