Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Tvrtko Ursulin <tursulin@ursulin.net>
Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>,
	<intel-gfx@lists.freedesktop.org>,
	Ashutosh Dixit <ashutosh.dixit@intel.com>,
	 <andi.shyti@kernel.org>
Subject: Re: [PATCH] drm/i915: Fix conversion between clock ticks and nanoseconds
Date: Wed, 5 Nov 2025 14:38:18 -0500	[thread overview]
Message-ID: <aQunqj1t9tG-pK4t@intel.com> (raw)
In-Reply-To: <e60834fa-2d03-4531-a56e-fa8d1799ed11@ursulin.net>

On Fri, Oct 31, 2025 at 08:40:53AM +0000, Tvrtko Ursulin wrote:
> 
> On 29/10/2025 22:01, Umesh Nerlige Ramappa wrote:
> > On Wed, Oct 29, 2025 at 11:33:20AM +0000, Tvrtko Ursulin wrote:
> > > 
> > > On 16/10/2025 01:03, Umesh Nerlige Ramappa wrote:
> > > > When tick values are large, the multiplication by NSEC_PER_SEC is larger
> > > > than 64 bits and results in bad conversions.
> > > > 
> > > > The issue is seen in PMU busyness counters that look like they have
> > > > wrapped around due to bad conversion. i915 PMU implementation returns
> > > > monotonically increasing counters. If a count is lesser than previous
> > > > one, it will only return the larger value until the smaller value
> > > > catches up. The user will see this as zero delta between two
> > > > measurements even though the engines are busy.
> > > > 
> > > > Fix it by using mul_u64_u32_div()
> > > > 
> > > > Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14955
> > > > Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
> > > 
> > > There was no need for Fixes: or cc: stable?
> > 
> > Oh, sorry, I missed that. Should have been both. Is it too late to do
> > that now?
> > 
> > Fixes: 77cdd054dd2c ("drm/i915/pmu: Connect engine busyness stats from
> > GuC to pmu")
> 
> Possibly not. Lets ask Rodrigo if he could manually cherry pick it for 6.18.

Done, and added the fixes tag while at it.

Thanks for the heads up.

> 
> Regards,
> 
> Tvrtko
> 
> > > > ---
> > > > v2:
> > > > - Fix divide by zero for Gen11 (Andi)
> > > > - Update commit message
> > > > 
> > > > v3:
> > > > - Drop GCD and use mul_u64_u32_div() instead (Ashutosh)
> > > > ---
> > > >  drivers/gpu/drm/i915/gt/intel_gt_clock_utils.c | 4 ++--
> > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/i915/gt/intel_gt_clock_utils.c b/
> > > > drivers/gpu/drm/i915/gt/intel_gt_clock_utils.c
> > > > index 88b147fa5cb1..c90b35881a26 100644
> > > > --- a/drivers/gpu/drm/i915/gt/intel_gt_clock_utils.c
> > > > +++ b/drivers/gpu/drm/i915/gt/intel_gt_clock_utils.c
> > > > @@ -205,7 +205,7 @@ static u64 div_u64_roundup(u64 nom, u32 den)
> > > >  u64 intel_gt_clock_interval_to_ns(const struct intel_gt *gt, u64 count)
> > > >  {
> > > > -    return div_u64_roundup(count * NSEC_PER_SEC, gt->clock_frequency);
> > > > +    return mul_u64_u32_div(count, NSEC_PER_SEC, gt->clock_frequency);
> > > >  }
> > > >  u64 intel_gt_pm_interval_to_ns(const struct intel_gt *gt, u64 count)
> > > > @@ -215,7 +215,7 @@ u64 intel_gt_pm_interval_to_ns(const struct
> > > > intel_gt *gt, u64 count)
> > > >  u64 intel_gt_ns_to_clock_interval(const struct intel_gt *gt, u64 ns)
> > > >  {
> > > > -    return div_u64_roundup(gt->clock_frequency * ns, NSEC_PER_SEC);
> > > > +    return mul_u64_u32_div(ns, gt->clock_frequency, NSEC_PER_SEC);
> > > >  }
> > > >  u64 intel_gt_ns_to_pm_interval(const struct intel_gt *gt, u64 ns)
> > > 
> 

  reply	other threads:[~2025-11-05 19:38 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-16  0:03 [PATCH] drm/i915: Fix conversion between clock ticks and nanoseconds Umesh Nerlige Ramappa
2025-10-16  1:17 ` ✓ i915.CI.BAT: success for drm/i915: Fix conversion between clock ticks and nanoseconds (rev3) Patchwork
2025-10-16 10:18 ` ✓ i915.CI.Full: " Patchwork
2025-10-16 20:07 ` [PATCH] drm/i915: Fix conversion between clock ticks and nanoseconds Dixit, Ashutosh
2025-10-16 23:36   ` Umesh Nerlige Ramappa
2025-10-17  2:01     ` Rodrigo Vivi
2025-10-29 11:33 ` Tvrtko Ursulin
2025-10-29 22:01   ` Umesh Nerlige Ramappa
2025-10-31  8:40     ` Tvrtko Ursulin
2025-11-05 19:38       ` Rodrigo Vivi [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-10-09 19:16 Umesh Nerlige Ramappa
2025-10-07 23:35 Umesh Nerlige Ramappa
2025-10-09 12:24 ` Andi Shyti
2025-10-10 17:45   ` Umesh Nerlige Ramappa
2025-10-14  8:58     ` Andi Shyti
2025-10-14  1:19 ` Dixit, Ashutosh
2025-10-14 20:31   ` Umesh Nerlige Ramappa
2025-10-14 21:43     ` Dixit, Ashutosh

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=aQunqj1t9tG-pK4t@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=andi.shyti@kernel.org \
    --cc=ashutosh.dixit@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=tursulin@ursulin.net \
    --cc=umesh.nerlige.ramappa@intel.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