Re: [PATCH v5 02/11] drm/panfrost: Prevent division by 0

Boris Brezillon <[email protected]>
Newsgroups org.freedesktop.lists.dri-devel,org.kernel.vger.linux-kernel
Organization Collabora
Message-ID <[email protected]>
On Tue, 11 Aug 2026 22:42:11 +0100
Adrián Larumbe <[email protected]> wrote:

> When updating and debug-printing devfreq stats, in the very unlikely
> off-chance that total device time is less than 100 ns, division by 0
> would happen. Fix the divisor when relevant and rearrange operands.
> 
> Reported-by: Claude <[email protected]>
> Closes: https://gitlab.freedesktop.org/panfrost/linux/-/work_items/88
> Fixes: f3ba91228e8e ("drm/panfrost: Add initial panfrost driver")
> Reviewed-by: Steven Price <[email protected]>
> Signed-off-by: Adrián Larumbe <[email protected]>

Reviewed-by: Boris Brezillon <[email protected]>

> ---
>  drivers/gpu/drm/panfrost/panfrost_devfreq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> index b51c30778811..0fe81d259274 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> @@ -78,7 +78,7 @@ 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->busy_time * 100 / MAX(status->total_time, 1),
>  		status->current_frequency / 1000 / 1000);
>  
>  	return 0;
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.