From: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
intel-xe@lists.freedesktop.org
Cc: mitulkumar.ajitkumar.golani@intel.com,
ankit.k.nautiyal@intel.com, suraj.kandpal@intel.com,
jani.nikula@linux.intel.com, sfr@canb.auug.org.au,
lucas.demarchi@intel.com
Subject: [PATCH v2 2/2] drm/i915/display: Update calculation to avoid overflow
Date: Fri, 14 Jun 2024 09:55:58 +0530 [thread overview]
Message-ID: <20240614042558.376983-3-mitulkumar.ajitkumar.golani@intel.com> (raw)
In-Reply-To: <20240614042558.376983-1-mitulkumar.ajitkumar.golani@intel.com>
Update calculation to avoid overflow.
-v2:
Remove extra line from commit message.(Lucas)
Fixes: 1676ecd303ac ("drm/i915: Compute CMRR and calculate vtotal")
Cc: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
Cc: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
Cc: Suraj Kandpal <suraj.kandpal@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
Reviewed-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
---
drivers/gpu/drm/i915/display/intel_vrr.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_vrr.c b/drivers/gpu/drm/i915/display/intel_vrr.c
index eb5b62b54d32..6430da25957d 100644
--- a/drivers/gpu/drm/i915/display/intel_vrr.c
+++ b/drivers/gpu/drm/i915/display/intel_vrr.c
@@ -147,10 +147,11 @@ cmrr_get_vtotal(struct intel_crtc_state *crtc_state, bool video_mode_required)
multiplier_n = 1000;
}
- crtc_state->cmrr.cmrr_n =
- desired_refresh_rate * adjusted_mode->crtc_htotal * multiplier_n;
- vtotal = (adjusted_mode->crtc_clock * 1000 * multiplier_n) / crtc_state->cmrr.cmrr_n;
- adjusted_pixel_rate = adjusted_mode->crtc_clock * 1000 * multiplier_m;
+ crtc_state->cmrr.cmrr_n = mul_u32_u32(desired_refresh_rate * adjusted_mode->crtc_htotal,
+ multiplier_n);
+ vtotal = DIV_ROUND_UP_ULL(mul_u32_u32(adjusted_mode->crtc_clock * 1000, multiplier_n),
+ crtc_state->cmrr.cmrr_n);
+ adjusted_pixel_rate = mul_u32_u32(adjusted_mode->crtc_clock * 1000, multiplier_m);
crtc_state->cmrr.cmrr_m = do_div(adjusted_pixel_rate, crtc_state->cmrr.cmrr_n);
return vtotal;
--
2.45.2
next prev parent reply other threads:[~2024-06-14 4:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-14 4:25 [PATCH v2 0/2] CMRR patch fixes Mitul Golani
2024-06-14 4:25 ` [PATCH v2 1/2] drm/dp: Describe target_rr_divider in struct drm_dp_as_sdp Mitul Golani
2024-06-14 19:53 ` Rodrigo Vivi
2024-06-18 20:10 ` Rodrigo Vivi
2024-06-14 4:25 ` Mitul Golani [this message]
2024-06-14 4:31 ` ✓ CI.Patch_applied: success for CMRR patch fixes Patchwork
2024-06-14 4:31 ` ✓ CI.checkpatch: " Patchwork
2024-06-14 4:32 ` ✓ CI.KUnit: " Patchwork
2024-06-14 4:44 ` ✓ CI.Build: " Patchwork
2024-06-14 4:46 ` ✗ CI.Hooks: failure " Patchwork
2024-06-14 4:47 ` ✗ CI.checksparse: warning " Patchwork
2024-06-14 5:09 ` ✓ CI.BAT: success " Patchwork
2024-06-14 8:58 ` ✗ CI.FULL: 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=20240614042558.376983-3-mitulkumar.ajitkumar.golani@intel.com \
--to=mitulkumar.ajitkumar.golani@intel.com \
--cc=ankit.k.nautiyal@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=lucas.demarchi@intel.com \
--cc=sfr@canb.auug.org.au \
--cc=suraj.kandpal@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