From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [Intel-gfx] [PATCH 3/5] drm/i915: Fix potential overflows in ilk ips calculations
Date: Wed, 21 Oct 2020 16:14:41 +0300 [thread overview]
Message-ID: <20201021131443.25616-3-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20201021131443.25616-1-ville.syrjala@linux.intel.com>
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
A bunch of the ips calculations require 64bit math. In particular
'corr' and 'corr2' look like they can overflow on 32bit systems.
Switch to explicit u64 for those.
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
drivers/gpu/drm/i915/gt/intel_rps.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/intel_rps.c b/drivers/gpu/drm/i915/gt/intel_rps.c
index e0db7541dbfa..1cf48c51a93e 100644
--- a/drivers/gpu/drm/i915/gt/intel_rps.c
+++ b/drivers/gpu/drm/i915/gt/intel_rps.c
@@ -1281,8 +1281,9 @@ static unsigned long __ips_gfx_val(struct intel_ips *ips)
{
struct intel_rps *rps = container_of(ips, typeof(*rps), ips);
struct intel_uncore *uncore = rps_to_uncore(rps);
- unsigned long t, corr, state1, corr2, state2;
+ unsigned int t, state1, state2;
u32 pxvid, ext_v;
+ u64 corr, corr2;
lockdep_assert_held(&mchdev_lock);
@@ -1303,11 +1304,10 @@ static unsigned long __ips_gfx_val(struct intel_ips *ips)
else /* < 50 */
corr = t * 301 + 1004;
- corr = corr * 150142 * state1 / 10000 - 78642;
- corr /= 100000;
- corr2 = corr * ips->corr;
+ corr = div_u64(corr * 150142 * state1, 10000) - 78642;
+ corr2 = div_u64(corr, 100000) * ips->corr;
- state2 = corr2 * state1 / 10000;
+ state2 = div_u64(corr2 * state1, 10000);
state2 /= 100; /* convert to mW */
__gen5_ips_update(ips);
--
2.26.2
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2020-10-21 13:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-21 13:14 [Intel-gfx] [PATCH 1/5] drm/i915: Restore ILK-M RPS support Ville Syrjala
2020-10-21 13:14 ` [Intel-gfx] [PATCH 2/5] drm/i915: Read actual GPU frequency from MEMSTAT_ILK on ILK Ville Syrjala
2020-10-21 17:36 ` Chris Wilson
2020-10-21 20:44 ` Chris Wilson
2020-10-21 13:14 ` Ville Syrjala [this message]
2020-10-21 17:40 ` [Intel-gfx] [PATCH 3/5] drm/i915: Fix potential overflows in ilk ips calculations Chris Wilson
2020-10-21 13:14 ` [Intel-gfx] [PATCH 4/5] drm/i915: Do gen5_gt_irq_postinstall() before enabling the master interrupt Ville Syrjala
2020-10-21 17:43 ` Chris Wilson
2020-10-21 13:14 ` [Intel-gfx] [PATCH 5/5] drm/i915: Clean up the irq enable/disable for ilk rps Ville Syrjala
2020-10-21 17:46 ` Chris Wilson
2020-10-21 13:26 ` [Intel-gfx] [PATCH 1/5] drm/i915: Restore ILK-M RPS support Chris Wilson
2020-10-21 14:11 ` [Intel-gfx] ✓ Fi.CI.BAT: success for series starting with [1/5] " Patchwork
2020-10-21 15:47 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
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=20201021131443.25616-3-ville.syrjala@linux.intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.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