Mon Aug 9 09:36:42 2010 UTC ()
acpi_pcidev_scan: attach PCI information only to working devices.

ok jruoho@


(gsutre)
diff -r1.214 -r1.215 src/sys/dev/acpi/acpi.c
diff -r1.13 -r1.14 src/sys/dev/acpi/acpi_pci.c

cvs diff -r1.214 -r1.215 src/sys/dev/acpi/acpi.c (expand / switch to unified diff)

--- src/sys/dev/acpi/acpi.c 2010/08/07 20:07:25 1.214
+++ src/sys/dev/acpi/acpi.c 2010/08/09 09:36:42 1.215
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: acpi.c,v 1.214 2010/08/07 20:07:25 jruoho Exp $ */ 1/* $NetBSD: acpi.c,v 1.215 2010/08/09 09:36:42 gsutre Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc. 4 * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Charles M. Hannum of By Noon Software, Inc. 8 * by Charles M. Hannum of By Noon Software, Inc.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -90,27 +90,27 @@ @@ -90,27 +90,27 @@
90 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 90 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
91 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 91 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
92 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 92 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
93 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 93 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
94 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 94 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
95 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 95 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
96 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 96 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
97 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 97 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
98 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 98 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
99 * POSSIBILITY OF SUCH DAMAGE. 99 * POSSIBILITY OF SUCH DAMAGE.
100 */ 100 */
101 101
102#include <sys/cdefs.h> 102#include <sys/cdefs.h>
103__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.214 2010/08/07 20:07:25 jruoho Exp $"); 103__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.215 2010/08/09 09:36:42 gsutre Exp $");
104 104
105#include "opt_acpi.h" 105#include "opt_acpi.h"
106#include "opt_pcifixup.h" 106#include "opt_pcifixup.h"
107 107
108#include <sys/param.h> 108#include <sys/param.h>
109#include <sys/device.h> 109#include <sys/device.h>
110#include <sys/kernel.h> 110#include <sys/kernel.h>
111#include <sys/malloc.h> 111#include <sys/malloc.h>
112#include <sys/module.h> 112#include <sys/module.h>
113#include <sys/mutex.h> 113#include <sys/mutex.h>
114#include <sys/sysctl.h> 114#include <sys/sysctl.h>
115#include <sys/systm.h> 115#include <sys/systm.h>
116#include <sys/timetc.h> 116#include <sys/timetc.h>
@@ -953,26 +953,28 @@ acpi_rescan_nodes(struct acpi_softc *sc) @@ -953,26 +953,28 @@ acpi_rescan_nodes(struct acpi_softc *sc)
953 * There is a bug in ACPICA: it defines the type 953 * There is a bug in ACPICA: it defines the type
954 * of the scopes incorrectly for its own reasons. 954 * of the scopes incorrectly for its own reasons.
955 */ 955 */
956 if (acpi_is_scope(ad) != false) 956 if (acpi_is_scope(ad) != false)
957 continue; 957 continue;
958 958
959 di = ad->ad_devinfo; 959 di = ad->ad_devinfo;
960 960
961 /* 961 /*
962 * We only attach devices which are present, enabled, and 962 * We only attach devices which are present, enabled, and
963 * functioning properly. However, if a device is enabled, 963 * functioning properly. However, if a device is enabled,
964 * it is decoding resources and we should claim these, 964 * it is decoding resources and we should claim these,
965 * if possible. This requires changes to bus_space(9). 965 * if possible. This requires changes to bus_space(9).
 966 * Note: there is a possible race condition, because _STA
 967 * may have changed since di->CurrentStatus was set.
966 */ 968 */
967 if (di->Type == ACPI_TYPE_DEVICE) { 969 if (di->Type == ACPI_TYPE_DEVICE) {
968 970
969 if ((di->Valid & ACPI_VALID_STA) != 0 && 971 if ((di->Valid & ACPI_VALID_STA) != 0 &&
970 (di->CurrentStatus & ACPI_STA_OK) != ACPI_STA_OK) 972 (di->CurrentStatus & ACPI_STA_OK) != ACPI_STA_OK)
971 continue; 973 continue;
972 } 974 }
973 975
974 /* 976 /*
975 * The same problem as above. As for example 977 * The same problem as above. As for example
976 * thermal zones and power resources do not 978 * thermal zones and power resources do not
977 * have a valid HID, only evaluate devices. 979 * have a valid HID, only evaluate devices.
978 */ 980 */

cvs diff -r1.13 -r1.14 src/sys/dev/acpi/acpi_pci.c (expand / switch to unified diff)

--- src/sys/dev/acpi/acpi_pci.c 2010/08/08 16:26:47 1.13
+++ src/sys/dev/acpi/acpi_pci.c 2010/08/09 09:36:42 1.14
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: acpi_pci.c,v 1.13 2010/08/08 16:26:47 gsutre Exp $ */ 1/* $NetBSD: acpi_pci.c,v 1.14 2010/08/09 09:36:42 gsutre Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc. 4 * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Christoph Egger and Gregoire Sutre. 8 * by Christoph Egger and Gregoire Sutre.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -19,27 +19,27 @@ @@ -19,27 +19,27 @@
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE. 28 * SUCH DAMAGE.
29 */ 29 */
30 30
31#include <sys/cdefs.h> 31#include <sys/cdefs.h>
32__KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.13 2010/08/08 16:26:47 gsutre Exp $"); 32__KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.14 2010/08/09 09:36:42 gsutre Exp $");
33 33
34#include <sys/param.h> 34#include <sys/param.h>
35#include <sys/device.h> 35#include <sys/device.h>
36#include <sys/kmem.h> 36#include <sys/kmem.h>
37#include <sys/systm.h> 37#include <sys/systm.h>
38 38
39#include <dev/pci/pcireg.h> 39#include <dev/pci/pcireg.h>
40#include <dev/pci/pcidevs.h> 40#include <dev/pci/pcidevs.h>
41#include <dev/pci/ppbreg.h> 41#include <dev/pci/ppbreg.h>
42 42
43#include <dev/acpi/acpireg.h> 43#include <dev/acpi/acpireg.h>
44#include <dev/acpi/acpivar.h> 44#include <dev/acpi/acpivar.h>
45#include <dev/acpi/acpi_pci.h> 45#include <dev/acpi/acpi_pci.h>
@@ -159,26 +159,36 @@ ACPI_STATUS @@ -159,26 +159,36 @@ ACPI_STATUS
159acpi_pcidev_scan(struct acpi_devnode *ad) 159acpi_pcidev_scan(struct acpi_devnode *ad)
160{ 160{
161 struct acpi_devnode *child; 161 struct acpi_devnode *child;
162 struct acpi_pci_info *ap; 162 struct acpi_pci_info *ap;
163 ACPI_INTEGER val; 163 ACPI_INTEGER val;
164 ACPI_STATUS rv; 164 ACPI_STATUS rv;
165 165
166 ad->ad_pciinfo = NULL; 166 ad->ad_pciinfo = NULL;
167 167
168 if (ad->ad_devinfo->Type != ACPI_TYPE_DEVICE || 168 if (ad->ad_devinfo->Type != ACPI_TYPE_DEVICE ||
169 !(ad->ad_devinfo->Valid & ACPI_VALID_ADR)) 169 !(ad->ad_devinfo->Valid & ACPI_VALID_ADR))
170 goto rec; 170 goto rec;
171 171
 172 /*
 173 * We attach PCI information only to devices that are present,
 174 * enabled, and functioning properly.
 175 * Note: there is a possible race condition, because _STA may
 176 * have changed since ad->ad_devinfo->CurrentStatus was set.
 177 */
 178 if ((ad->ad_devinfo->Valid & ACPI_VALID_STA) != 0 &&
 179 (ad->ad_devinfo->CurrentStatus & ACPI_STA_OK) != ACPI_STA_OK)
 180 goto rec;
 181
172 if (ad->ad_devinfo->Flags & ACPI_PCI_ROOT_BRIDGE) { 182 if (ad->ad_devinfo->Flags & ACPI_PCI_ROOT_BRIDGE) {
173 183
174 ap = kmem_zalloc(sizeof(*ap), KM_SLEEP); 184 ap = kmem_zalloc(sizeof(*ap), KM_SLEEP);
175 185
176 if (ap == NULL) 186 if (ap == NULL)
177 return AE_NO_MEMORY; 187 return AE_NO_MEMORY;
178 188
179 /* 189 /*
180 * If no _SEG exist, all PCI bus segments are assumed 190 * If no _SEG exist, all PCI bus segments are assumed
181 * to be in the PCI segment group 0 (ACPI 4.0, p. 277). 191 * to be in the PCI segment group 0 (ACPI 4.0, p. 277).
182 * The segment group number is conveyed in the lower 192 * The segment group number is conveyed in the lower
183 * 16 bits of _SEG (the other bits are all reserved). 193 * 16 bits of _SEG (the other bits are all reserved).
184 */ 194 */