From: Peter Hilber <peter.hilber@opensynergy.com>
To: lakshmi.sowjanya.d@intel.com, tglx@linutronix.de,
jstultz@google.com, giometti@enneenne.com, corbet@lwn.net,
linux-kernel@vger.kernel.org
Cc: x86@kernel.org, netdev@vger.kernel.org,
linux-doc@vger.kernel.org, intel-wired-lan@lists.osuosl.org,
andriy.shevchenko@linux.intel.com, eddie.dong@intel.com,
christopher.s.hall@intel.com, jesse.brandeburg@intel.com,
davem@davemloft.net, alexandre.torgue@foss.st.com,
joabreu@synopsys.com, mcoquelin.stm32@gmail.com, perex@perex.cz,
linux-sound@vger.kernel.org, anthony.l.nguyen@intel.com,
pandith.n@intel.com, subramanian.mohan@intel.com,
thejesh.reddy.t.r@intel.com
Subject: Re: [PATCH v7 01/12] timekeeping: Add base clock properties in clocksource structure
Date: Tue, 30 Apr 2024 16:28:11 +0200 [thread overview]
Message-ID: <ace1be8b-d66d-4326-b5de-0f4164df88e6@opensynergy.com> (raw)
In-Reply-To: <20240430085225.18086-2-lakshmi.sowjanya.d@intel.com>
On 30.04.24 10:52, lakshmi.sowjanya.d@intel.com wrote:
> From: Lakshmi Sowjanya D <lakshmi.sowjanya.d@intel.com>
>
> Add base clock hardware abstraction in clocksource structure.
>
> Provide generic functionality in convert_base_to_cs() to convert base
> clock timestamps to system clocksource without requiring architecture
> specific parameters.
>
> This is intended to replace convert_art_to_tsc() and
> convert_art_ns_to_tsc() functions which are specific to convert ART
> (Always Running Timer) time to the corresponding TSC value.
>
> Add the infrastructure in get_device_system_crosststamp().
>
> 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>
> ---
> include/linux/clocksource.h | 27 +++++++++++++++++++++++++
> include/linux/timekeeping.h | 2 ++
> kernel/time/timekeeping.c | 39 +++++++++++++++++++++++++++++++++++--
> 3 files changed, 66 insertions(+), 2 deletions(-)
>
[...]
> diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
> index b58dffc58a8f..4e5e931e766a 100644
> --- a/kernel/time/timekeeping.c
> +++ b/kernel/time/timekeeping.c
> @@ -1193,6 +1193,42 @@ static bool timestamp_in_interval(u64 start, u64 end, u64 ts)
> return false;
> }
>
> +static bool convert_clock(u64 *val, u32 numerator, u32 denominator)
> +{
> + u64 rem, res;
> +
> + if (!numerator || !denominator)
> + return false;
> +
> + res = div64_u64_rem(*val, denominator, &rem) * numerator;
> + *val = res + div_u64(rem * numerator, denominator);
> + return true;
> +}
> +
> +static bool convert_base_to_cs(struct system_counterval_t *scv)
> +{
> + struct clocksource *cs = tk_core.timekeeper.tkr_mono.clock;
> + struct clocksource_base *base = cs->base;
> + u32 num, den;
> +
> + /* The timestamp was taken from the time keeper clock source */
> + if (cs->id == scv->cs_id)
> + return true;
> +
> + /* Check whether cs_id matches the base clock */
> + if (!base || base->id != scv->cs_id)
> + return false;
> +
> + num = scv->use_nsecs ? cs->freq_khz : base->numerator;
> + den = scv->use_nsecs ? USEC_PER_SEC : base->denominator;
> +
> + if (!convert_clock(&scv->cycles, num, den))
> + return false;
> +
> + scv->cycles += base->offset;
> + return true;
> +}
> +
> /**
> * get_device_system_crosststamp - Synchronously capture system/device timestamp
> * @get_time_fn: Callback to get simultaneous device time and
> @@ -1238,8 +1274,7 @@ int get_device_system_crosststamp(int (*get_time_fn)
> * system counter value is the same as for the currently
> * installed timekeeper clocksource
> */
> - if (system_counterval.cs_id == CSID_GENERIC ||
> - tk->tkr_mono.clock->id != system_counterval.cs_id)
> + if (!convert_base_to_cs(&system_counterval))
> return -ENODEV;
AFAIU the error condition
system_counterval.cs_id == CSID_GENERIC
is silently dropped by this patch, but shouldn't be.
get_device_system_crosststamp() can only check the identity of a
clocksource (base) for non-generic ids.
Regards,
Peter
next prev parent reply other threads:[~2024-04-30 14:47 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-30 8:52 [PATCH v7 00/12] Add support for Intel PPS Generator lakshmi.sowjanya.d
2024-04-30 8:52 ` [PATCH v7 01/12] timekeeping: Add base clock properties in clocksource structure lakshmi.sowjanya.d
2024-04-30 14:28 ` Peter Hilber [this message]
2024-05-09 4:38 ` D, Lakshmi Sowjanya
2024-04-30 8:52 ` [PATCH v7 02/12] x86/tsc: Update tsc/art values in the base clock structure lakshmi.sowjanya.d
2024-04-30 8:52 ` [PATCH v7 03/12] e1000e: remove convert_art_to_tsc() lakshmi.sowjanya.d
2024-04-30 8:52 ` [PATCH v7 04/12] igc: remove convert_art_ns_to_tsc() lakshmi.sowjanya.d
2024-04-30 8:52 ` [PATCH v7 05/12] stmmac: intel: remove convert_art_to_tsc() lakshmi.sowjanya.d
2024-04-30 8:52 ` [PATCH v7 06/12] ALSA: hda: " lakshmi.sowjanya.d
2024-04-30 8:52 ` [PATCH v7 07/12] ice/ptp: " lakshmi.sowjanya.d
2024-04-30 8:52 ` [PATCH v7 08/12] x86/tsc: Remove art to tsc conversion functions which are obsolete lakshmi.sowjanya.d
2024-04-30 8:52 ` [PATCH v7 09/12] timekeeping: Add function to convert realtime to base clock lakshmi.sowjanya.d
2024-04-30 16:27 ` [Intel-wired-lan] " kernel test robot
2024-04-30 8:52 ` [PATCH v7 10/12] pps: generators: Add PPS Generator TIO Driver lakshmi.sowjanya.d
2024-04-30 13:53 ` Andy Shevchenko
2024-05-09 4:38 ` D, Lakshmi Sowjanya
2024-05-10 14:27 ` Andy Shevchenko
2024-04-30 8:52 ` [PATCH v7 11/12] Documentation: driver-api: pps: Add Intel Timed I/O PPS generator lakshmi.sowjanya.d
2024-04-30 8:52 ` [PATCH v7 12/12] ABI: pps: Add ABI documentation for Intel TIO lakshmi.sowjanya.d
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=ace1be8b-d66d-4326-b5de-0f4164df88e6@opensynergy.com \
--to=peter.hilber@opensynergy.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=christopher.s.hall@intel.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=eddie.dong@intel.com \
--cc=giometti@enneenne.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jesse.brandeburg@intel.com \
--cc=joabreu@synopsys.com \
--cc=jstultz@google.com \
--cc=lakshmi.sowjanya.d@intel.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pandith.n@intel.com \
--cc=perex@perex.cz \
--cc=subramanian.mohan@intel.com \
--cc=tglx@linutronix.de \
--cc=thejesh.reddy.t.r@intel.com \
--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