Sun Aug 8 18:25:06 2010 UTC ()
Improve error and debug messages.


(jruoho)
diff -r1.15 -r1.16 src/sys/dev/acpi/acpi_cpu_cstate.c
diff -r1.3 -r1.4 src/sys/dev/acpi/acpi_cpu_pstate.c

cvs diff -r1.15 -r1.16 src/sys/dev/acpi/acpi_cpu_cstate.c (expand / switch to unified diff)

--- src/sys/dev/acpi/acpi_cpu_cstate.c 2010/08/08 16:58:42 1.15
+++ src/sys/dev/acpi/acpi_cpu_cstate.c 2010/08/08 18:25:06 1.16
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: acpi_cpu_cstate.c,v 1.15 2010/08/08 16:58:42 jruoho Exp $ */ 1/* $NetBSD: acpi_cpu_cstate.c,v 1.16 2010/08/08 18:25:06 jruoho Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2010 Jukka Ruohonen <jruohonen@iki.fi> 4 * Copyright (c) 2010 Jukka Ruohonen <jruohonen@iki.fi>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 10 *
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE. 27 * SUCH DAMAGE.
28 */ 28 */
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_cstate.c,v 1.15 2010/08/08 16:58:42 jruoho Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_cstate.c,v 1.16 2010/08/08 18:25:06 jruoho Exp $");
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/cpu.h> 33#include <sys/cpu.h>
34#include <sys/device.h> 34#include <sys/device.h>
35#include <sys/kernel.h> 35#include <sys/kernel.h>
36#include <sys/once.h> 36#include <sys/once.h>
37#include <sys/mutex.h> 37#include <sys/mutex.h>
38#include <sys/timetc.h> 38#include <sys/timetc.h>
39 39
40#include <dev/pci/pcivar.h> 40#include <dev/pci/pcivar.h>
41#include <dev/pci/pcidevs.h> 41#include <dev/pci/pcidevs.h>
42 42
43#include <dev/acpi/acpireg.h> 43#include <dev/acpi/acpireg.h>
@@ -124,27 +124,27 @@ acpicpu_cstate_attach_print(struct acpic @@ -124,27 +124,27 @@ acpicpu_cstate_attach_print(struct acpic
124 124
125 case ACPICPU_C_STATE_FFH: 125 case ACPICPU_C_STATE_FFH:
126 str = "FFH"; 126 str = "FFH";
127 break; 127 break;
128 128
129 case ACPICPU_C_STATE_SYSIO: 129 case ACPICPU_C_STATE_SYSIO:
130 str = "SYSIO"; 130 str = "SYSIO";
131 break; 131 break;
132 132
133 default: 133 default:
134 panic("NOTREACHED"); 134 panic("NOTREACHED");
135 } 135 }
136 136
137 aprint_verbose_dev(sc->sc_dev, "C%d: %5s, " 137 aprint_debug_dev(sc->sc_dev, "C%d: %5s, "
138 "lat %3u us, pow %5u mW, addr 0x%06x, flags 0x%02x\n", 138 "lat %3u us, pow %5u mW, addr 0x%06x, flags 0x%02x\n",
139 i, str, cs->cs_latency, cs->cs_power, 139 i, str, cs->cs_latency, cs->cs_power,
140 (uint32_t)cs->cs_addr, cs->cs_flags); 140 (uint32_t)cs->cs_addr, cs->cs_flags);
141 } 141 }
142} 142}
143 143
144int 144int
145acpicpu_cstate_detach(device_t self) 145acpicpu_cstate_detach(device_t self)
146{ 146{
147 struct acpicpu_softc *sc = device_private(self); 147 struct acpicpu_softc *sc = device_private(self);
148 static ONCE_DECL(once_detach); 148 static ONCE_DECL(once_detach);
149 int rv; 149 int rv;
150 150
@@ -276,30 +276,26 @@ acpicpu_cstate_cst(struct acpicpu_softc  @@ -276,30 +276,26 @@ acpicpu_cstate_cst(struct acpicpu_softc
276 elm = &obj->Package.Elements[i]; 276 elm = &obj->Package.Elements[i];
277 rv = acpicpu_cstate_cst_add(sc, elm); 277 rv = acpicpu_cstate_cst_add(sc, elm);
278 278
279 if (ACPI_SUCCESS(rv)) 279 if (ACPI_SUCCESS(rv))
280 count++; 280 count++;
281 } 281 }
282 282
283 rv = (count != 0) ? AE_OK : AE_NOT_EXIST; 283 rv = (count != 0) ? AE_OK : AE_NOT_EXIST;
284 284
285out: 285out:
286 if (buf.Pointer != NULL) 286 if (buf.Pointer != NULL)
287 ACPI_FREE(buf.Pointer); 287 ACPI_FREE(buf.Pointer);
288 288
289 if (ACPI_FAILURE(rv)) 
290 aprint_error_dev(sc->sc_dev, "failed to evaluate " 
291 "_CST: %s\n", AcpiFormatException(rv)); 
292 
293 return rv; 289 return rv;
294} 290}
295 291
296static ACPI_STATUS 292static ACPI_STATUS
297acpicpu_cstate_cst_add(struct acpicpu_softc *sc, ACPI_OBJECT *elm) 293acpicpu_cstate_cst_add(struct acpicpu_softc *sc, ACPI_OBJECT *elm)
298{ 294{
299 const struct acpicpu_object *ao = &sc->sc_object; 295 const struct acpicpu_object *ao = &sc->sc_object;
300 struct acpicpu_cstate *cs = sc->sc_cstate; 296 struct acpicpu_cstate *cs = sc->sc_cstate;
301 struct acpicpu_cstate state; 297 struct acpicpu_cstate state;
302 struct acpicpu_reg *reg; 298 struct acpicpu_reg *reg;
303 ACPI_STATUS rv = AE_OK; 299 ACPI_STATUS rv = AE_OK;
304 ACPI_OBJECT *obj; 300 ACPI_OBJECT *obj;
305 uint32_t type; 301 uint32_t type;
@@ -413,27 +409,27 @@ acpicpu_cstate_cst_add(struct acpicpu_so @@ -413,27 +409,27 @@ acpicpu_cstate_cst_add(struct acpicpu_so
413 409
414 switch (type) { 410 switch (type) {
415 411
416 case ACPI_STATE_C1: 412 case ACPI_STATE_C1:
417 413
418 if ((sc->sc_flags & ACPICPU_FLAG_C_FFH) == 0) 414 if ((sc->sc_flags & ACPICPU_FLAG_C_FFH) == 0)
419 state.cs_method = ACPICPU_C_STATE_HALT; 415 state.cs_method = ACPICPU_C_STATE_HALT;
420 416
421 break; 417 break;
422 418
423 default: 419 default:
424 420
425 if ((sc->sc_flags & ACPICPU_FLAG_C_FFH) == 0) { 421 if ((sc->sc_flags & ACPICPU_FLAG_C_FFH) == 0) {
426 rv = AE_AML_BAD_RESOURCE_VALUE; 422 rv = AE_SUPPORT;
427 goto out; 423 goto out;
428 } 424 }
429 } 425 }
430 426
431 if (sc->sc_cap != 0) { 427 if (sc->sc_cap != 0) {
432 428
433 /* 429 /*
434 * The _CST FFH GAS encoding may contain 430 * The _CST FFH GAS encoding may contain
435 * additional hints on Intel processors. 431 * additional hints on Intel processors.
436 * Use these to determine whether we can 432 * Use these to determine whether we can
437 * avoid the bus master activity check. 433 * avoid the bus master activity check.
438 */ 434 */
439 if ((reg->reg_accesssize & ACPICPU_PDC_GAS_BM) == 0) 435 if ((reg->reg_accesssize & ACPICPU_PDC_GAS_BM) == 0)
@@ -450,28 +446,28 @@ acpicpu_cstate_cst_add(struct acpicpu_so @@ -450,28 +446,28 @@ acpicpu_cstate_cst_add(struct acpicpu_so
450 if (cs[type].cs_method != 0) { 446 if (cs[type].cs_method != 0) {
451 rv = AE_ALREADY_EXISTS; 447 rv = AE_ALREADY_EXISTS;
452 goto out; 448 goto out;
453 } 449 }
454 450
455 cs[type].cs_addr = state.cs_addr; 451 cs[type].cs_addr = state.cs_addr;
456 cs[type].cs_power = state.cs_power; 452 cs[type].cs_power = state.cs_power;
457 cs[type].cs_flags = state.cs_flags; 453 cs[type].cs_flags = state.cs_flags;
458 cs[type].cs_method = state.cs_method; 454 cs[type].cs_method = state.cs_method;
459 cs[type].cs_latency = state.cs_latency; 455 cs[type].cs_latency = state.cs_latency;
460 456
461out: 457out:
462 if (ACPI_FAILURE(rv)) 458 if (ACPI_FAILURE(rv))
463 aprint_verbose_dev(sc->sc_dev, 459 aprint_debug_dev(sc->sc_dev, "invalid "
464 "invalid _CST: %s\n", AcpiFormatException(rv)); 460 "_CST: %s\n", AcpiFormatException(rv));
465 461
466 return rv; 462 return rv;
467} 463}
468 464
469static void 465static void
470acpicpu_cstate_cst_bios(void) 466acpicpu_cstate_cst_bios(void)
471{ 467{
472 const uint8_t val = AcpiGbl_FADT.CstControl; 468 const uint8_t val = AcpiGbl_FADT.CstControl;
473 const uint32_t addr = AcpiGbl_FADT.SmiCommand; 469 const uint32_t addr = AcpiGbl_FADT.SmiCommand;
474 470
475 if (addr == 0) 471 if (addr == 0)
476 return; 472 return;
477 473

cvs diff -r1.3 -r1.4 src/sys/dev/acpi/acpi_cpu_pstate.c (expand / switch to unified diff)

--- src/sys/dev/acpi/acpi_cpu_pstate.c 2010/08/08 18:10:34 1.3
+++ src/sys/dev/acpi/acpi_cpu_pstate.c 2010/08/08 18:25:06 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: acpi_cpu_pstate.c,v 1.3 2010/08/08 18:10:34 jruoho Exp $ */ 1/* $NetBSD: acpi_cpu_pstate.c,v 1.4 2010/08/08 18:25:06 jruoho Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2010 Jukka Ruohonen <jruohonen@iki.fi> 4 * Copyright (c) 2010 Jukka Ruohonen <jruohonen@iki.fi>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 10 *
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE. 27 * SUCH DAMAGE.
28 */ 28 */
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_pstate.c,v 1.3 2010/08/08 18:10:34 jruoho Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_pstate.c,v 1.4 2010/08/08 18:25:06 jruoho Exp $");
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/kmem.h> 33#include <sys/kmem.h>
34#include <sys/once.h> 34#include <sys/once.h>
35 35
36#include <dev/acpi/acpireg.h> 36#include <dev/acpi/acpireg.h>
37#include <dev/acpi/acpivar.h> 37#include <dev/acpi/acpivar.h>
38#include <dev/acpi/acpi_cpu.h> 38#include <dev/acpi/acpi_cpu.h>
39 39
40#define _COMPONENT ACPI_BUS_COMPONENT 40#define _COMPONENT ACPI_BUS_COMPONENT
41ACPI_MODULE_NAME ("acpi_cpu_pstate") 41ACPI_MODULE_NAME ("acpi_cpu_pstate")
42 42
43static void acpicpu_pstate_attach_print(struct acpicpu_softc *); 43static void acpicpu_pstate_attach_print(struct acpicpu_softc *);
@@ -375,36 +375,36 @@ acpicpu_pstate_pct(struct acpicpu_softc  @@ -375,36 +375,36 @@ acpicpu_pstate_pct(struct acpicpu_softc
375 375
376 switch (reg[i]->reg_spaceid) { 376 switch (reg[i]->reg_spaceid) {
377 377
378 case ACPI_ADR_SPACE_SYSTEM_IO: 378 case ACPI_ADR_SPACE_SYSTEM_IO:
379 379
380 if (reg[i]->reg_addr == 0) { 380 if (reg[i]->reg_addr == 0) {
381 rv = AE_AML_ILLEGAL_ADDRESS; 381 rv = AE_AML_ILLEGAL_ADDRESS;
382 goto out; 382 goto out;
383 } 383 }
384 384
385 width = reg[i]->reg_bitwidth; 385 width = reg[i]->reg_bitwidth;
386 386
387 if (width != 8 && width != 16 && width != 32) { 387 if (width != 8 && width != 16 && width != 32) {
388 rv = AE_SUPPORT; 388 rv = AE_AML_BAD_RESOURCE_VALUE;
389 goto out; 389 goto out;
390 } 390 }
391 391
392 break; 392 break;
393 393
394 case ACPI_ADR_SPACE_FIXED_HARDWARE: 394 case ACPI_ADR_SPACE_FIXED_HARDWARE:
395 395
396 if ((sc->sc_flags & ACPICPU_FLAG_P_FFH) == 0) { 396 if ((sc->sc_flags & ACPICPU_FLAG_P_FFH) == 0) {
397 rv = AE_AML_BAD_RESOURCE_VALUE; 397 rv = AE_SUPPORT;
398 goto out; 398 goto out;
399 } 399 }
400 400
401 break; 401 break;
402 402
403 default: 403 default:
404 rv = AE_AML_INVALID_SPACE_ID; 404 rv = AE_AML_INVALID_SPACE_ID;
405 goto out; 405 goto out;
406 } 406 }
407 } 407 }
408 408
409 if (reg[0]->reg_spaceid != reg[1]->reg_spaceid) { 409 if (reg[0]->reg_spaceid != reg[1]->reg_spaceid) {
410 rv = AE_AML_INVALID_SPACE_ID; 410 rv = AE_AML_INVALID_SPACE_ID;