[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <77194DC0-AA53-4CF9-8BDB-93E212B9FA72@toblux.com>
Date: Wed, 10 Jul 2024 13:55:32 +0200
From: Thorsten Blum <thorsten.blum@...lux.com>
To: Ville Syrjälä <ville.syrjala@...ux.intel.com>
Cc: jani.nikula@...ux.intel.com,
joonas.lahtinen@...ux.intel.com,
rodrigo.vivi@...el.com,
tursulin@...ulin.net,
airlied@...il.com,
daniel@...ll.ch,
intel-gfx@...ts.freedesktop.org,
dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drm/i915: Explicitly cast divisor to fix Coccinelle
warning
On 10. Jul 2024, at 13:38, Ville Syrjälä <ville.syrjala@...ux.intel.com> wrote:
> On Wed, Jul 10, 2024 at 09:46:51AM +0200, Thorsten Blum wrote:
>> As the comment explains, the if check ensures that the divisor oa_period
>> is a u32. Explicitly cast oa_period to u32 to remove the following
>> Coccinelle/coccicheck warning reported by do_div.cocci:
>>
>> WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead
>>
>> Signed-off-by: Thorsten Blum <thorsten.blum@...lux.com>
>> ---
>> drivers/gpu/drm/i915/i915_perf.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
>> index 0b1cd4c7a525..24722e758aaf 100644
>> --- a/drivers/gpu/drm/i915/i915_perf.c
>> +++ b/drivers/gpu/drm/i915/i915_perf.c
>> @@ -4103,7 +4103,7 @@ static int read_properties_unlocked(struct i915_perf *perf,
>> */
>> if (oa_period <= NSEC_PER_SEC) {
>> u64 tmp = NSEC_PER_SEC;
>> - do_div(tmp, oa_period);
>> + do_div(tmp, (u32)oa_period);
>
> Why is this code even using do_div() when it doesn't need the
> remainder?
do_div() is an optimized 64-by-32 division and the compiler should
automatically remove the remainder if it's not used.
Powered by blists - more mailing lists