From: "Jan Beulich" Subject: [PATCH 1/4] mwait-idle: allow sparse sub-state numbering, for Bay Trail Date: Thu, 26 Jun 2014 11:19:44 +0100 Message-ID: <53AC0FE0020000780001D8A6@mail.emea.novell.com> References: <53AC0ED0020000780001D883@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartB38146D0.0__=" Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X06mQ-00078o-Sm for xen-devel@lists.xenproject.org; Thu, 26 Jun 2014 10:19:47 +0000 In-Reply-To: <53AC0ED0020000780001D883@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Keir Fraser List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartB38146D0.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline From: Len Brown Like acpi_idle, mwait-idle compared sub-state numbers to the number of supported sub-states -- discarding sub-states numbers that were numbered >=3D the number of states. But some Bay Trail SOCs use sparse sub-state numbers, so we can't make such a comparison if we are going to access those states. So now we simply check that _some_ sub-states are supported for the given state, and assume that the sub-state number in our driver is valid. In practice, the driver is correct, and even if it were not, the hardware clips invalid sub-state requests to valid ones. No entries in the driver require this change, but Bay Trail will need it. Signed-off-by: Len Brown Signed-off-by: Jan Beulich --- a/xen/arch/x86/cpu/mwait-idle.c +++ b/xen/arch/x86/cpu/mwait-idle.c @@ -557,23 +557,22 @@ static int mwait_idle_cpu_init(struct no dev->count =3D 1; =20 for (cstate =3D 0; cpuidle_state_table[cstate].target_residency; = ++cstate) { - unsigned int num_substates, hint, state, substate; + unsigned int num_substates, hint, state; struct acpi_processor_cx *cx; =20 hint =3D flg2MWAIT(cpuidle_state_table[cstate].flags); state =3D MWAIT_HINT2CSTATE(hint) + 1; - substate =3D MWAIT_HINT2SUBSTATE(hint); =20 if (state > max_cstate) { printk(PREFIX "max C-state %u reached\n", = max_cstate); break; } =20 - /* Does the state exist in CPUID.MWAIT? */ + /* Number of sub-states for this state in CPUID.MWAIT. */ num_substates =3D (mwait_substates >> (state * 4)) & MWAIT_SUBSTATE_MASK; - /* if sub-state in table is not enumerated by CPUID */ - if (substate >=3D num_substates) + /* If NO sub-states for this state in CPUID, skip it. */ + if (num_substates =3D=3D 0) continue; =20 if (dev->count >=3D ACPI_PROCESSOR_MAX_POWER) { --=__PartB38146D0.0__= Content-Type: text/plain; name="x86-mwait-sparse-substates.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-mwait-sparse-substates.patch" mwait-idle: allow sparse sub-state numbering, for Bay Trail=0A=0ALike = acpi_idle, mwait-idle compared sub-state numbers=0Ato the number of = supported sub-states -- discarding=0Asub-states numbers that were numbered = >=3D the number of states.=0A=0ABut some Bay Trail SOCs use sparse = sub-state numbers,=0Aso we can't make such a comparison if we are = going=0Ato access those states.=0A=0ASo now we simply check that _some_ = sub-states are=0Asupported for the given state, and assume that the=0Asub-s= tate number in our driver is valid.=0A=0AIn practice, the driver is = correct, and even if it were not,=0Athe hardware clips invalid sub-state = requests to valid ones.=0A=0ANo entries in the driver require this = change,=0Abut Bay Trail will need it.=0A=0ASigned-off-by: Len Brown = =0ASigned-off-by: Jan Beulich =0A= =0A--- a/xen/arch/x86/cpu/mwait-idle.c=0A+++ b/xen/arch/x86/cpu/mwait-idle.= c=0A@@ -557,23 +557,22 @@ static int mwait_idle_cpu_init(struct no=0A = dev->count =3D 1;=0A =0A for (cstate =3D 0; cpuidle_state_table[csta= te].target_residency; ++cstate) {=0A- unsigned int num_substates,= hint, state, substate;=0A+ unsigned int num_substates, hint, = state;=0A struct acpi_processor_cx *cx;=0A =0A = hint =3D flg2MWAIT(cpuidle_state_table[cstate].flags);=0A = state =3D MWAIT_HINT2CSTATE(hint) + 1;=0A- substate =3D = MWAIT_HINT2SUBSTATE(hint);=0A =0A if (state > max_cstate) = {=0A printk(PREFIX "max C-state %u reached\n", = max_cstate);=0A break;=0A }=0A =0A- = /* Does the state exist in CPUID.MWAIT? */=0A+ /* Number = of sub-states for this state in CPUID.MWAIT. */=0A num_substat= es =3D (mwait_substates >> (state * 4))=0A & = MWAIT_SUBSTATE_MASK;=0A- /* if sub-state in table is not = enumerated by CPUID */=0A- if (substate >=3D num_substates)=0A= + /* If NO sub-states for this state in CPUID, skip it. = */=0A+ if (num_substates =3D=3D 0)=0A = continue;=0A =0A if (dev->count >=3D ACPI_PROCESSOR_MAX_POWE= R) {=0A --=__PartB38146D0.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__PartB38146D0.0__=--