Message ID | 20240807202040.54796-2-thorsten.blum@toblux.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v3] drm/i915: Explicitly cast divisor and use div_u64() | expand |
Hi Thorsten, > diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c > index 025a79fe5920..6ff905d2b78f 100644 > --- a/drivers/gpu/drm/i915/i915_perf.c > +++ b/drivers/gpu/drm/i915/i915_perf.c > @@ -4063,17 +4063,13 @@ static int read_properties_unlocked(struct i915_perf *perf, > oa_period = oa_exponent_to_ns(perf, value); > > /* This check is primarily to ensure that oa_period <= > - * UINT32_MAX (before passing to do_div which only > + * UINT32_MAX (before passing it to div_u64 which only > * accepts a u32 denominator), but we can also skip > * checking anything < 1Hz which implicitly can't be > * limited via an integer oa_max_sample_rate. > */ > - if (oa_period <= NSEC_PER_SEC) { > - u64 tmp = NSEC_PER_SEC; > - do_div(tmp, oa_period); > - oa_freq_hz = tmp; > - } else > - oa_freq_hz = 0; > + oa_freq_hz = oa_period > NSEC_PER_SEC ? 0 : > + div_u64(NSEC_PER_SEC, (u32)oa_period); Thanks for the follow up! Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com> Andi
diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index 025a79fe5920..6ff905d2b78f 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -4063,17 +4063,13 @@ static int read_properties_unlocked(struct i915_perf *perf, oa_period = oa_exponent_to_ns(perf, value); /* This check is primarily to ensure that oa_period <= - * UINT32_MAX (before passing to do_div which only + * UINT32_MAX (before passing it to div_u64 which only * accepts a u32 denominator), but we can also skip * checking anything < 1Hz which implicitly can't be * limited via an integer oa_max_sample_rate. */ - if (oa_period <= NSEC_PER_SEC) { - u64 tmp = NSEC_PER_SEC; - do_div(tmp, oa_period); - oa_freq_hz = tmp; - } else - oa_freq_hz = 0; + oa_freq_hz = oa_period > NSEC_PER_SEC ? 0 : + div_u64(NSEC_PER_SEC, (u32)oa_period); if (oa_freq_hz > i915_oa_max_sample_rate && !perfmon_capable()) { drm_dbg(&perf->i915->drm,