Re: [PATCH v2 2/7] drm/panfrost: Prevent division by 0
From: Boris Brezillon
Date: Thu Jun 04 2026 - 14:02:32 EST
On Thu, 04 Jun 2026 18:35:21 +0100
Adrián Larumbe <adrian.larumbe@xxxxxxxxxxxxx> wrote:
> When updating and debug-printing devfreq stats, in the very unlikely
> offchance that total device time is less than 100 ns, clamp it to 0 to
> avoid division by 0.
>
> Reported-by: Claude <noreply@xxxxxxxxxxxxx>
> Closes: https://gitlab.freedesktop.org/panfrost/linux/-/work_items/88
> Signed-off-by: Adrián Larumbe <adrian.larumbe@xxxxxxxxxxxxx>
> Fixes: f3ba91228e8e ("drm/panfrost: Add initial panfrost driver")
> ---
> drivers/gpu/drm/panfrost/panfrost_devfreq.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> index b51c30778811..e34de47bf43b 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> @@ -78,7 +78,8 @@ static int panfrost_devfreq_get_dev_status(struct device *dev,
>
> dev_dbg(pfdev->base.dev, "busy %lu total %lu %lu %% freq %lu MHz\n",
> status->busy_time, status->total_time,
> - status->busy_time / (status->total_time / 100),
> + status->total_time >= 100 ?
> + status->busy_time / (status->total_time / 100) : 0,
or:
status->busy_time * 100 / MAX(status->total_time, 1),
> status->current_frequency / 1000 / 1000);
>
> return 0;
>