mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zeng Heng <zengheng4@huawei.com>
To: <lenb@kernel.org>, <viresh.kumar@linaro.org>, <rafael@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <linux-pm@vger.kernel.org>,
	<wangxiongfeng2@huawei.com>, <xiexiuqi@huawei.com>,
	<liwei391@huawei.com>, <linux-acpi@vger.kernel.org>,
	<weiyongjun1@huawei.com>
Subject: [PATCH v2 2/2] acpi: CPPC: read delivered_reg and reference_reg in critical section
Date: Tue, 16 May 2023 21:32:47 +0800	[thread overview]
Message-ID: <20230516133248.712242-2-zengheng4@huawei.com> (raw)
In-Reply-To: <20230516133248.712242-1-zengheng4@huawei.com>

Reading the content of delivered_reg and reference_reg should be in
the same critical section, in case any interrupt comes, which could
lead to inaccurate frequency calculation.

Signed-off-by: Zeng Heng <zengheng4@huawei.com>
---
 drivers/acpi/cppc_acpi.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index 7ff269a78c20..92af57ff61ce 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -1315,6 +1315,7 @@ int cppc_get_perf_ctrs(int cpunum, struct cppc_perf_fb_ctrs *perf_fb_ctrs)
 	struct cppc_pcc_data *pcc_ss_data = NULL;
 	u64 delivered, reference, ref_perf, ctr_wrap_time;
 	int ret = 0, regs_in_pcc = 0;
+	unsigned long flags;
 
 	if (!cpc_desc) {
 		pr_debug("No CPC descriptor for CPU:%d\n", cpunum);
@@ -1350,8 +1351,11 @@ int cppc_get_perf_ctrs(int cpunum, struct cppc_perf_fb_ctrs *perf_fb_ctrs)
 		}
 	}
 
+	local_irq_save(flags);
 	cpc_read(cpunum, delivered_reg, &delivered);
 	cpc_read(cpunum, reference_reg, &reference);
+	local_irq_restore(flags);
+
 	cpc_read(cpunum, ref_perf_reg, &ref_perf);
 
 	/*
-- 
2.25.1


  reply	other threads:[~2023-05-16 13:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-16 13:32 [PATCH v2 1/2] cpufreq: CPPC: keep target core awake when reading its cpufreq rate Zeng Heng
2023-05-16 13:32 ` Zeng Heng [this message]
2023-05-16 13:32 ` [PATCH 0/2] drivers/cpufreq: gain accurate CPU frequency from cpufreq/scaling_cur_freq Zeng Heng
2023-05-17  8:17 ` [PATCH v2 1/2] cpufreq: CPPC: keep target core awake when reading its cpufreq rate Pierre Gondois
2023-05-17 15:03   ` Sumit Gupta
2023-05-17 18:46     ` Yang Shi
2023-05-18 14:40       ` Sumit Gupta
2023-05-19 16:39         ` Beata Michalska
2023-05-24 18:08         ` Yang Shi
2023-05-18  1:44     ` Zeng Heng
2023-05-26  8:58   ` Zeng Heng

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=20230516133248.712242-2-zengheng4@huawei.com \
    --to=zengheng4@huawei.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=liwei391@huawei.com \
    --cc=rafael@kernel.org \
    --cc=viresh.kumar@linaro.org \
    --cc=wangxiongfeng2@huawei.com \
    --cc=weiyongjun1@huawei.com \
    --cc=xiexiuqi@huawei.com \
    /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

all inboxes | Powered by JetHome®