All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@amd.com>
To: <cpufreq@vger.kernel.org>, "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Matthew Garrett <mjg@redhat.com>,
	Andreas Herrmann <andreas.herrmann3@amd.com>,
	Thomas Renninger <trenn@suse.de>, <linux-pm@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Andre Przywara <andre.przywara@amd.com>
Subject: [PATCH 4/8] ACPI: Add fixups for AMD P-state figures
Date: Thu, 26 Jul 2012 14:28:40 +0200	[thread overview]
Message-ID: <1343305724-2809-5-git-send-email-andre.przywara@amd.com> (raw)
In-Reply-To: <1343305724-2809-1-git-send-email-andre.przywara@amd.com>

From: Matthew Garrett <mjg@redhat.com>

Some AMD systems may round the frequencies in ACPI tables to 100MHz
boundaries. We can obtain the real frequencies from MSRs, so add a quirk
to fix these frequencies up on AMD systems.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Andre Przywara <andre.przywara@amd.com>
---
 arch/x86/include/asm/msr-index.h |    1 +
 drivers/acpi/processor_perflib.c |   30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index 1e1f3eb..fbee971 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -248,6 +248,7 @@
 
 #define MSR_IA32_PERF_STATUS		0x00000198
 #define MSR_IA32_PERF_CTL		0x00000199
+#define MSR_AMD_PSTATE_DEF_BASE		0xc0010064
 #define MSR_AMD_PERF_STATUS		0xc0010063
 #define MSR_AMD_PERF_CTL		0xc0010062
 
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index a093dc1..836bfe0 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -324,6 +324,34 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr)
 	return result;
 }
 
+#ifdef CONFIG_X86
+/*
+ * Some AMDs have 50MHz frequency multiples, but only provide 100MHz rounding
+ * in their ACPI data. Calculate the real values and fix up the _PSS data.
+ */
+static void amd_fixup_frequency(struct acpi_processor_px *px, int i)
+{
+	u32 hi, lo, fid, did;
+	int index = px->control & 0x00000007;
+
+	if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
+		return;
+
+	if ((boot_cpu_data.x86 == 0x10 && boot_cpu_data.x86_model < 10)
+	    || boot_cpu_data.x86 == 0x11) {
+		rdmsr(MSR_AMD_PSTATE_DEF_BASE + index, lo, hi);
+		fid = lo & 0x3f;
+		did = (lo >> 6) & 7;
+		if (boot_cpu_data.x86 == 0x10)
+			px->core_frequency = (100 * (fid + 0x10)) >> did;
+		else
+			px->core_frequency = (100 * (fid + 8)) >> did;
+	}
+}
+#else
+static void amd_fixup_frequency(struct acpi_processor_px *px, int i) {};
+#endif
+
 static int acpi_processor_get_performance_states(struct acpi_processor *pr)
 {
 	int result = 0;
@@ -379,6 +407,8 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
 			goto end;
 		}
 
+		amd_fixup_frequency(px, i);
+
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
 				  "State [%d]: core_frequency[%d] power[%d] transition_latency[%d] bus_master_latency[%d] control[0x%x] status[0x%x]\n",
 				  i,
-- 
1.7.4.4



WARNING: multiple messages have this Message-ID (diff)
From: Andre Przywara <andre.przywara@amd.com>
To: cpufreq@vger.kernel.org, "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Matthew Garrett <mjg@redhat.com>,
	Andreas Herrmann <andreas.herrmann3@amd.com>,
	Thomas Renninger <trenn@suse.de>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Andre Przywara <andre.przywara@amd.com>
Subject: [PATCH 4/8] ACPI: Add fixups for AMD P-state figures
Date: Thu, 26 Jul 2012 14:28:40 +0200	[thread overview]
Message-ID: <1343305724-2809-5-git-send-email-andre.przywara@amd.com> (raw)
In-Reply-To: <1343305724-2809-1-git-send-email-andre.przywara@amd.com>

From: Matthew Garrett <mjg@redhat.com>

Some AMD systems may round the frequencies in ACPI tables to 100MHz
boundaries. We can obtain the real frequencies from MSRs, so add a quirk
to fix these frequencies up on AMD systems.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Andre Przywara <andre.przywara@amd.com>
---
 arch/x86/include/asm/msr-index.h |    1 +
 drivers/acpi/processor_perflib.c |   30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index 1e1f3eb..fbee971 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -248,6 +248,7 @@
 
 #define MSR_IA32_PERF_STATUS		0x00000198
 #define MSR_IA32_PERF_CTL		0x00000199
+#define MSR_AMD_PSTATE_DEF_BASE		0xc0010064
 #define MSR_AMD_PERF_STATUS		0xc0010063
 #define MSR_AMD_PERF_CTL		0xc0010062
 
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index a093dc1..836bfe0 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -324,6 +324,34 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr)
 	return result;
 }
 
+#ifdef CONFIG_X86
+/*
+ * Some AMDs have 50MHz frequency multiples, but only provide 100MHz rounding
+ * in their ACPI data. Calculate the real values and fix up the _PSS data.
+ */
+static void amd_fixup_frequency(struct acpi_processor_px *px, int i)
+{
+	u32 hi, lo, fid, did;
+	int index = px->control & 0x00000007;
+
+	if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
+		return;
+
+	if ((boot_cpu_data.x86 == 0x10 && boot_cpu_data.x86_model < 10)
+	    || boot_cpu_data.x86 == 0x11) {
+		rdmsr(MSR_AMD_PSTATE_DEF_BASE + index, lo, hi);
+		fid = lo & 0x3f;
+		did = (lo >> 6) & 7;
+		if (boot_cpu_data.x86 == 0x10)
+			px->core_frequency = (100 * (fid + 0x10)) >> did;
+		else
+			px->core_frequency = (100 * (fid + 8)) >> did;
+	}
+}
+#else
+static void amd_fixup_frequency(struct acpi_processor_px *px, int i) {};
+#endif
+
 static int acpi_processor_get_performance_states(struct acpi_processor *pr)
 {
 	int result = 0;
@@ -379,6 +407,8 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
 			goto end;
 		}
 
+		amd_fixup_frequency(px, i);
+
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
 				  "State [%d]: core_frequency[%d] power[%d] transition_latency[%d] bus_master_latency[%d] control[0x%x] status[0x%x]\n",
 				  i,
-- 
1.7.4.4


  parent reply	other threads:[~2012-07-26 12:29 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-26 12:28 [PATCH 0/8] acpi-cpufreq: Move modern AMD cpufreq support to acpi-cpufreq Andre Przywara
2012-07-26 12:28 ` Andre Przywara
2012-07-26 12:28 ` [PATCH 1/8] acpi-cpufreq: Add support for modern AMD CPUs Andre Przywara
2012-07-26 12:28   ` Andre Przywara
2012-07-26 12:28 ` [PATCH 2/8] acpi-cpufreq: Add quirk to disable _PSD usage on all " Andre Przywara
2012-07-26 12:28   ` Andre Przywara
2012-07-26 12:28 ` [PATCH 3/8] cpufreq: Add compatibility hack to powernow-k8 Andre Przywara
2012-07-26 12:28   ` Andre Przywara
2012-08-22  0:48   ` Thomas Renninger
2012-07-26 12:28 ` Andre Przywara [this message]
2012-07-26 12:28   ` [PATCH 4/8] ACPI: Add fixups for AMD P-state figures Andre Przywara
2012-07-26 12:28 ` [PATCH 5/8] acpi-cpufreq: Add support for disabling dynamic overclocking Andre Przywara
2012-07-26 12:28   ` Andre Przywara
2012-08-05 21:26   ` Rafael J. Wysocki
2012-07-26 12:28 ` [PATCH 6/8] acpi-cpufreq: Add compatibility for legacy AMD cpb sysfs knob Andre Przywara
2012-07-26 12:28   ` Andre Przywara
2012-08-05 21:29   ` Rafael J. Wysocki
2012-07-26 12:28 ` [PATCH 7/8] cpufreq: Remove support for hardware P-state chips from powernow-k8 Andre Przywara
2012-07-26 12:28   ` Andre Przywara
2012-08-05 21:33   ` Rafael J. Wysocki
2012-08-20 13:00     ` Andre Przywara
2012-08-20 13:00       ` Andre Przywara
2012-08-20 20:49       ` Rafael J. Wysocki
2012-08-22  1:00         ` Thomas Renninger
2012-08-22 13:39           ` Andre Przywara
2012-08-22 13:39             ` Andre Przywara
2012-08-22 14:34             ` Thomas Renninger
2012-07-26 12:28 ` [PATCH 8/8] Documentation: Add documentation for boost control switch Andre Przywara
2012-07-26 12:28   ` Andre Przywara
2012-08-05 21:34   ` Rafael J. Wysocki
2012-07-26 14:01 ` [PATCH 0/8] acpi-cpufreq: Move modern AMD cpufreq support to acpi-cpufreq Thomas Renninger
2012-07-26 19:58   ` Rafael J. Wysocki
2012-08-05 21:20 ` Rafael J. Wysocki
2012-08-05 23:39   ` H. Peter Anvin
2012-08-06  8:20     ` Borislav Petkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1343305724-2809-5-git-send-email-andre.przywara@amd.com \
    --to=andre.przywara@amd.com \
    --cc=andreas.herrmann3@amd.com \
    --cc=cpufreq@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mjg@redhat.com \
    --cc=rjw@sisk.pl \
    --cc=trenn@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.