From: Ashwin Chaugule <ashwin.chaugule@linaro.org>
To: viresh.kumar@linaro.org
Cc: dirk.brandewie@gmail.com, rwells@codeaurora.org,
rjw@rjwysocki.net, linaro-acpi@lists.linaro.org,
linux-pm@vger.kernel.org, Catalin.Marinas@arm.com,
linda.knippers@hp.com,
Ashwin Chaugule <ashwin.chaugule@linaro.org>
Subject: [RFC PATCH v2 3/3] CPPC HACKS
Date: Wed, 8 Oct 2014 16:11:04 -0400 [thread overview]
Message-ID: <1412799064-2339-4-git-send-email-ashwin.chaugule@linaro.org> (raw)
In-Reply-To: <1412799064-2339-1-git-send-email-ashwin.chaugule@linaro.org>
Not for upstreaming.
The IO space specified in the PCCT of the thinkpad
doesn't seem to have anything behind it. So this patch
creates a fake buffer shared between CPPC and PCC.
Also, the write to DESIRED reg to indicate desired CPU
performance level is an MSR on the Thinkpad (PERF_CTL).
This is not specified by the CPC table on this laptop. So
skip the cpc_write64() and directly write to the MSR. This
avoids the deadlock situtaion where IRQs are disabled in the
following path:
mbox_send_message -> send_data -> pcc_send_data
Signed-off-by: Ashwin Chaugule <ashwin.chaugule@linaro.org>
---
drivers/cpufreq/acpi_pid.c | 40 ++++++++++++++++++++++++++++++++++------
1 file changed, 34 insertions(+), 6 deletions(-)
diff --git a/drivers/cpufreq/acpi_pid.c b/drivers/cpufreq/acpi_pid.c
index a6db149..f67dd8f 100644
--- a/drivers/cpufreq/acpi_pid.c
+++ b/drivers/cpufreq/acpi_pid.c
@@ -763,6 +763,8 @@ static int acpi_cppc_processor_probe(void)
unsigned int num_ent, ret = 0, i, cpu, len;
acpi_handle handle;
acpi_status status;
+ //HACK:
+ u64 *tmp_buff;
/* Parse the ACPI _CPC table for each cpu. */
for_each_possible_cpu(cpu) {
@@ -850,19 +852,32 @@ static int acpi_cppc_processor_probe(void)
pr_debug("From PCCT: CPPC subspace addr:%llx, len: %d\n", comm_base_addr, len);
- pcc_comm_addr = ioremap(comm_base_addr, len);
- if (!pcc_comm_addr) {
+ /* HACK:
+ * The IO space as specified by the PCCT on the Thinkpad
+ * doesn't seem to have anything behind it. So allocate
+ * a temp buff instead and use it between CPPC and PCC.
+ */
+ tmp_buff = kzalloc(PAGE_SIZE, GFP_KERNEL);
+ if (!tmp_buff) {
+ pr_err("Could not allocate temp PCC comm space\n");
ret = -ENOMEM;
- pr_err("Failed to ioremap PCC comm region mem\n");
goto out_free;
}
+// pcc_comm_addr = ioremap(comm_base_addr, len);
+// if (!pcc_comm_addr) {
+// ret = -ENOMEM;
+// pr_err("Failed to ioremap PCC comm region mem\n");
+// goto out_free;
+// }
/*
* Overwrite it here for ease of use later in cpc_read/write calls
* We dont really need the original address again anyway.
*/
- cppc_ss->base_address = (u64)pcc_comm_addr;
- pr_debug("New PCC comm space addr: %llx\n", (u64)pcc_comm_addr);
+// cppc_ss->base_address = (u64)pcc_comm_addr;
+ cppc_ss->base_address = (u64)tmp_buff;
+// pr_debug("New PCC comm space addr: %llx\n", (u64)pcc_comm_addr);
+ pr_debug("New PCC comm space addr: %llx\n", (u64)tmp_buff);
} else {
pr_err("No pcc subspace detected in any CPC structure!\n");
@@ -985,7 +1000,20 @@ static int cppc_set_pstate(struct cpudata *cpudata, int state)
}
desired_reg = &cpc_desc->cpc_regs[DESIRED_PERF];
- return cpc_write64(state, desired_reg);
+// return cpc_write64(state, desired_reg);
+/* HACK: Normally, the cpc_write64() would do the right thing,
+ * by writing to the DESIRED reg as specified by the CPC table.
+ * But, on this X240 laptop, the DESIRED reg is actually an MSR which
+ * is not defined in the CPC. So we could fake it inside the
+ * pcc_send_data() routine, but that wont work, since the
+ * mbox controller code disables IRQs before calling
+ * pcc_send_data(). This results in a deadlock, when that
+ * routine does a wrmsrl_on_cpu(). Directly call it here
+ * instead. Experimental anyway.
+ */
+ val = state << 8;
+ wrmsrl_on_cpu(cpu, MSR_IA32_PERF_CTL, val);
+ return 0;
}
static struct cpu_defaults acpi_pid_cppc = {
--
1.9.1
prev parent reply other threads:[~2014-10-08 20:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-08 20:11 [RFC PATCH v2 0/3] CPPC as PID backend Ashwin Chaugule
2014-10-08 20:11 ` [RFC PATCH v2 1/3] PCC HACKS: Update PCC comm region with MSR data Ashwin Chaugule
2014-10-08 20:11 ` [RFC PATCH v2 2/3] CPPC as a PID controller backend Ashwin Chaugule
2014-10-09 16:22 ` Dirk Brandewie
2014-10-09 17:16 ` Ashwin Chaugule
2014-10-09 17:40 ` Dirk Brandewie
2014-10-09 18:18 ` Ashwin Chaugule
2014-10-17 13:58 ` Ashwin Chaugule
2014-10-08 20:11 ` Ashwin Chaugule [this message]
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=1412799064-2339-4-git-send-email-ashwin.chaugule@linaro.org \
--to=ashwin.chaugule@linaro.org \
--cc=Catalin.Marinas@arm.com \
--cc=dirk.brandewie@gmail.com \
--cc=linaro-acpi@lists.linaro.org \
--cc=linda.knippers@hp.com \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=rwells@codeaurora.org \
--cc=viresh.kumar@linaro.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).