From: "tip-bot2 for Lakshmi Sowjanya D" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
"Christopher S. Hall" <christopher.s.hall@intel.com>,
Lakshmi Sowjanya D <lakshmi.sowjanya.d@intel.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: timers/core] x86/tsc: Provide ART base clock information for TSC
Date: Mon, 03 Jun 2024 09:30:09 -0000 [thread overview]
Message-ID: <171740700928.10875.14755603550947818962.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20240513103813.5666-3-lakshmi.sowjanya.d@intel.com>
The following commit has been merged into the timers/core branch of tip:
Commit-ID: 3a52886c8f972c3a5b70bfec330c71817cd7fc63
Gitweb: https://git.kernel.org/tip/3a52886c8f972c3a5b70bfec330c71817cd7fc63
Author: Lakshmi Sowjanya D <lakshmi.sowjanya.d@intel.com>
AuthorDate: Mon, 13 May 2024 16:08:03 +05:30
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Mon, 03 Jun 2024 11:18:50 +02:00
x86/tsc: Provide ART base clock information for TSC
The core code provides a new mechanism to allow conversion between ART and
TSC. This allows to replace the x86 specific ART/TSC conversion functions.
Prepare for removal by filling in the base clock conversion information for
ART and associating the base clock to the TSC clocksource.
The existing conversion functions will be removed once the usage sites are
converted over to the new model.
[ tglx: Massaged change log ]
Co-developed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Co-developed-by: Christopher S. Hall <christopher.s.hall@intel.com>
Signed-off-by: Christopher S. Hall <christopher.s.hall@intel.com>
Signed-off-by: Lakshmi Sowjanya D <lakshmi.sowjanya.d@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20240513103813.5666-3-lakshmi.sowjanya.d@intel.com
---
arch/x86/kernel/tsc.c | 42 ++++++++++++++++++--------------
include/linux/clocksource_ids.h | 1 +-
2 files changed, 25 insertions(+), 18 deletions(-)
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 06b1707..d1888db 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -50,9 +50,9 @@ int tsc_clocksource_reliable;
static int __read_mostly tsc_force_recalibrate;
-static u32 art_to_tsc_numerator;
-static u32 art_to_tsc_denominator;
-static u64 art_to_tsc_offset;
+static struct clocksource_base art_base_clk = {
+ .id = CSID_X86_ART,
+};
static bool have_art;
struct cyc2ns {
@@ -1074,7 +1074,7 @@ core_initcall(cpufreq_register_tsc_scaling);
*/
static void __init detect_art(void)
{
- unsigned int unused[2];
+ unsigned int unused;
if (boot_cpu_data.cpuid_level < ART_CPUID_LEAF)
return;
@@ -1089,13 +1089,14 @@ static void __init detect_art(void)
tsc_async_resets)
return;
- cpuid(ART_CPUID_LEAF, &art_to_tsc_denominator,
- &art_to_tsc_numerator, unused, unused+1);
+ cpuid(ART_CPUID_LEAF, &art_base_clk.denominator,
+ &art_base_clk.numerator, &art_base_clk.freq_khz, &unused);
- if (art_to_tsc_denominator < ART_MIN_DENOMINATOR)
+ art_base_clk.freq_khz /= KHZ;
+ if (art_base_clk.denominator < ART_MIN_DENOMINATOR)
return;
- rdmsrl(MSR_IA32_TSC_ADJUST, art_to_tsc_offset);
+ rdmsrl(MSR_IA32_TSC_ADJUST, art_base_clk.offset);
/* Make this sticky over multiple CPU init calls */
setup_force_cpu_cap(X86_FEATURE_ART);
@@ -1303,13 +1304,13 @@ struct system_counterval_t convert_art_to_tsc(u64 art)
{
u64 tmp, res, rem;
- rem = do_div(art, art_to_tsc_denominator);
+ rem = do_div(art, art_base_clk.denominator);
- res = art * art_to_tsc_numerator;
- tmp = rem * art_to_tsc_numerator;
+ res = art * art_base_clk.numerator;
+ tmp = rem * art_base_clk.numerator;
- do_div(tmp, art_to_tsc_denominator);
- res += tmp + art_to_tsc_offset;
+ do_div(tmp, art_base_clk.denominator);
+ res += tmp + art_base_clk.offset;
return (struct system_counterval_t) {
.cs_id = have_art ? CSID_X86_TSC : CSID_GENERIC,
@@ -1356,7 +1357,6 @@ struct system_counterval_t convert_art_ns_to_tsc(u64 art_ns)
}
EXPORT_SYMBOL(convert_art_ns_to_tsc);
-
static void tsc_refine_calibration_work(struct work_struct *work);
static DECLARE_DELAYED_WORK(tsc_irqwork, tsc_refine_calibration_work);
/**
@@ -1458,8 +1458,10 @@ out:
if (tsc_unstable)
goto unreg;
- if (boot_cpu_has(X86_FEATURE_ART))
+ if (boot_cpu_has(X86_FEATURE_ART)) {
have_art = true;
+ clocksource_tsc.base = &art_base_clk;
+ }
clocksource_register_khz(&clocksource_tsc, tsc_khz);
unreg:
clocksource_unregister(&clocksource_tsc_early);
@@ -1484,8 +1486,10 @@ static int __init init_tsc_clocksource(void)
* the refined calibration and directly register it as a clocksource.
*/
if (boot_cpu_has(X86_FEATURE_TSC_KNOWN_FREQ)) {
- if (boot_cpu_has(X86_FEATURE_ART))
+ if (boot_cpu_has(X86_FEATURE_ART)) {
have_art = true;
+ clocksource_tsc.base = &art_base_clk;
+ }
clocksource_register_khz(&clocksource_tsc, tsc_khz);
clocksource_unregister(&clocksource_tsc_early);
@@ -1509,10 +1513,12 @@ static bool __init determine_cpu_tsc_frequencies(bool early)
if (early) {
cpu_khz = x86_platform.calibrate_cpu();
- if (tsc_early_khz)
+ if (tsc_early_khz) {
tsc_khz = tsc_early_khz;
- else
+ } else {
tsc_khz = x86_platform.calibrate_tsc();
+ clocksource_tsc.freq_khz = tsc_khz;
+ }
} else {
/* We should not be here with non-native cpu calibration */
WARN_ON(x86_platform.calibrate_cpu != native_calibrate_cpu);
diff --git a/include/linux/clocksource_ids.h b/include/linux/clocksource_ids.h
index a4fa343..2bb4d8c 100644
--- a/include/linux/clocksource_ids.h
+++ b/include/linux/clocksource_ids.h
@@ -9,6 +9,7 @@ enum clocksource_ids {
CSID_X86_TSC_EARLY,
CSID_X86_TSC,
CSID_X86_KVM_CLK,
+ CSID_X86_ART,
CSID_MAX,
};
next prev parent reply other threads:[~2024-06-03 9:30 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-13 10:38 [PATCH v8 00/12] Add support for Intel PPS Generator lakshmi.sowjanya.d
2024-05-13 10:38 ` [PATCH v8 01/12] timekeeping: Add base clock properties in clocksource structure lakshmi.sowjanya.d
2024-06-03 9:30 ` [tip: timers/core] timekeeping: Provide infrastructure for converting to/from a base clock tip-bot2 for Lakshmi Sowjanya D
2024-05-13 10:38 ` [PATCH v8 02/12] x86/tsc: Update tsc/art values in the base clock structure lakshmi.sowjanya.d
2024-06-03 9:30 ` tip-bot2 for Lakshmi Sowjanya D [this message]
2024-05-13 10:38 ` [PATCH v8 03/12] e1000e: remove convert_art_to_tsc() lakshmi.sowjanya.d
2024-06-03 9:30 ` [tip: timers/core] e1000e: Replace convert_art_to_tsc() tip-bot2 for Thomas Gleixner
2024-05-13 10:38 ` [PATCH v8 04/12] igc: remove convert_art_ns_to_tsc() lakshmi.sowjanya.d
2024-06-03 9:30 ` [tip: timers/core] igc: Remove convert_art_ns_to_tsc() tip-bot2 for Thomas Gleixner
2024-05-13 10:38 ` [PATCH v8 05/12] stmmac: intel: remove convert_art_to_tsc() lakshmi.sowjanya.d
2024-06-03 9:30 ` [tip: timers/core] stmmac: intel: Remove convert_art_to_tsc() tip-bot2 for Thomas Gleixner
2024-05-13 10:38 ` [PATCH v8 06/12] ALSA: hda: remove convert_art_to_tsc() lakshmi.sowjanya.d
2024-06-03 9:30 ` [tip: timers/core] ALSA: hda: Remove convert_art_to_tsc() tip-bot2 for Thomas Gleixner
2024-05-13 10:38 ` [PATCH v8 07/12] ice/ptp: remove convert_art_to_tsc() lakshmi.sowjanya.d
2024-06-03 9:30 ` [tip: timers/core] ice/ptp: Remove convert_art_to_tsc() tip-bot2 for Thomas Gleixner
2024-05-13 10:38 ` [PATCH v8 08/12] x86/tsc: Remove art to tsc conversion functions which are obsolete lakshmi.sowjanya.d
2024-06-03 9:30 ` [tip: timers/core] x86/tsc: Remove obsolete ART to TSC conversion functions tip-bot2 for Lakshmi Sowjanya D
2024-05-13 10:38 ` [PATCH v8 09/12] timekeeping: Add function to convert realtime to base clock lakshmi.sowjanya.d
2024-06-03 9:30 ` [tip: timers/core] " tip-bot2 for Lakshmi Sowjanya D
2024-05-13 10:38 ` [PATCH v8 10/12] pps: generators: Add PPS Generator TIO Driver lakshmi.sowjanya.d
2024-05-13 11:18 ` Andy Shevchenko
2024-05-13 11:20 ` Andy Shevchenko
2024-05-27 11:48 ` D, Lakshmi Sowjanya
2024-05-27 14:34 ` Andy Shevchenko
2024-05-30 5:52 ` D, Lakshmi Sowjanya
2024-05-30 8:38 ` Andy Shevchenko
2024-05-13 10:38 ` [PATCH v8 11/12] Documentation: driver-api: pps: Add Intel Timed I/O PPS generator lakshmi.sowjanya.d
2024-05-15 11:16 ` Bagas Sanjaya
2024-05-13 10:38 ` [PATCH v8 12/12] ABI: pps: Add ABI documentation for Intel TIO lakshmi.sowjanya.d
2024-05-13 11:22 ` Andy Shevchenko
2024-05-27 11:53 ` D, Lakshmi Sowjanya
2024-05-27 14:37 ` Andy Shevchenko
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=171740700928.10875.14755603550947818962.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=christopher.s.hall@intel.com \
--cc=lakshmi.sowjanya.d@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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
all inboxes | Powered by JetHome®