Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Nov 2010 20:48:28 -0500
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        freebsd-acpi@FreeBSD.org
Cc:        Andriy Gapon <avg@freebsd.org>
Subject:   Re: fixup for missing C1 in _CST
Message-ID:  <201011112048.31127.jkim@FreeBSD.org>
In-Reply-To: <201011111737.32399.jkim@FreeBSD.org>
References:  <4CDC25F2.6080409@freebsd.org> <201011111737.32399.jkim@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--Boundary-00=_vzJ3MiMq5bzGAN1
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Thursday 11 November 2010 05:37 pm, Jung-uk Kim wrote:
> On Thursday 11 November 2010 12:20 pm, Andriy Gapon wrote:
> > Dear fellow FreeBSD ACPI hackers,
> > what is your opinion about the following patch?
> >
> > The idea is to add a C1 state to available states if a bugggy
> > BIOS supplies us with _CST that has states with C2, C3, etc
> > types, but no state with C1 type.
>
> Can you please try the attached patch instead?

It seems C1 state became mandatory years ago.  Please ignore the 
previous patches and try this instead.

Thanks!

Jung-uk Kim

--Boundary-00=_vzJ3MiMq5bzGAN1
Content-Type: text/plain;
  charset="iso-8859-1";
  name="acpi_cpu3.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="acpi_cpu3.diff"

Index: sys/dev/acpica/acpi_cpu.c
===================================================================
--- sys/dev/acpica/acpi_cpu.c	(revision 215135)
+++ sys/dev/acpica/acpi_cpu.c	(working copy)
@@ -668,9 +668,19 @@ acpi_cpu_cx_cst(struct acpi_cpu_softc *sc)
 	count = MAX_CX_STATES;
     }
 
-    /* Set up all valid states. */
+    sc->cpu_non_c3 = 0;
     sc->cpu_cx_count = 0;
     cx_ptr = sc->cpu_cx_states;
+
+    /*
+     * C1 has been required since just after ACPI 1.0.
+     * Reserve the first slot for it.
+     */
+    cx_ptr->type = ACPI_STATE_C0;
+    cx_ptr++;
+    sc->cpu_cx_count++;
+
+    /* Set up all valid states. */
     for (i = 0; i < count; i++) {
 	pkg = &top->Package.Elements[i + 1];
 	if (!ACPI_PKG_VALID(pkg, 4) ||
@@ -685,9 +695,14 @@ acpi_cpu_cx_cst(struct acpi_cpu_softc *sc)
 	/* Validate the state to see if we should use it. */
 	switch (cx_ptr->type) {
 	case ACPI_STATE_C1:
-	    sc->cpu_non_c3 = i;
-	    cx_ptr++;
-	    sc->cpu_cx_count++;
+	    if (sc->cpu_cx_states[0].type == ACPI_STATE_C0) {
+		/* This is the first C1 state.  Use the reserved slot. */
+		sc->cpu_cx_states[0] = *cx_ptr;
+	    } else {
+		sc->cpu_non_c3 = i;
+		cx_ptr++;
+		sc->cpu_cx_count++;
+	    }
 	    continue;
 	case ACPI_STATE_C2:
 	    sc->cpu_non_c3 = i;
@@ -726,6 +741,13 @@ acpi_cpu_cx_cst(struct acpi_cpu_softc *sc)
     }
     AcpiOsFree(buf.Pointer);
 
+    /* If C1 state was not found, we need one now. */
+    cx_ptr = sc->cpu_cx_states;
+    if (cx_ptr->type == ACPI_STATE_C0) {
+	cx_ptr->type = ACPI_STATE_C1;
+	cx_ptr->trans_lat = 0;
+    }
+
     return (0);
 }
 

--Boundary-00=_vzJ3MiMq5bzGAN1--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201011112048.31127.jkim>