From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 20E2F3FAE09 for ; Fri, 5 Jun 2026 10:30:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780655410; cv=none; b=IoATPaRsq226FAVP9VYkA0/Cwif/WTT8EYdgOQAcbENZcNQ/sSc7sOW43VHr9zMQYciEETdvrQpUV1xBzMCXPK+brcBhLVi46nQGDo87VgrX7PkVGIsrWBKHSnUxucNABP/k/mFd6kJ5om9T1yuCS+dpNSxpEVZeu05+VgOYcNY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780655410; c=relaxed/simple; bh=IcilndRyAKqQCF1QSaXNfFd0st+oLZ4AaMEsfiCIfXQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=PkHuM7uKk+PmqkKPxfvsXrcjCU6h+XTtiH/A4A97SVmDdZKaUqR2AoYUkzDLn6LT/SOW+lgq8a2rWsy/mu09lKcJYKVKVcf+EjYHwyO5gVVKsRDwSV6hmt29cGCDmSAE/HYZIknWp3iPLYdE0wxM8LITrugvQuxRYr9bBh8UR8w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=QLjjj51j; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="QLjjj51j" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6FEF04CF1; Fri, 5 Jun 2026 03:30:01 -0700 (PDT) Received: from [10.1.31.21] (e122027.cambridge.arm.com [10.1.31.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 755413F632; Fri, 5 Jun 2026 03:30:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1780655406; bh=IcilndRyAKqQCF1QSaXNfFd0st+oLZ4AaMEsfiCIfXQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=QLjjj51jj69xdI11Crft2GjNOZml3pL9OIpqJvPng2pre5pfIp9V3yfJuPoCuayLs vv6L5AgIEcD1H9n+bEEgjZThJ0o62H2AY9IHuDF+EpaVvPPu2mrstbCVCM2Y+DCzcR KVr/mdjIZiwSLvzfXZT0treTCDDqu+XKu0Sm8Ghs= Message-ID: <19d76abb-baff-4249-9f17-d0460b418d56@arm.com> Date: Fri, 5 Jun 2026 11:29:59 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/7] drm/panfrost: Prevent division by 0 To: Boris Brezillon , =?UTF-8?Q?Adri=C3=A1n_Larumbe?= Cc: Rob Herring , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Faith Ekstrand , "Marty E. Plummer" , Tomeu Vizoso , Eric Anholt , Alyssa Rosenzweig , Robin Murphy , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Collabora Kernel Team , Neil Armstrong , Claude References: <20260604-claude-fixes-v2-0-57c6bd4c1655@collabora.com> <20260604-claude-fixes-v2-2-57c6bd4c1655@collabora.com> <20260604200215.303dbc43@fedora-2.home> From: Steven Price Content-Language: en-GB In-Reply-To: <20260604200215.303dbc43@fedora-2.home> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 04/06/2026 19:02, Boris Brezillon wrote: > On Thu, 04 Jun 2026 18:35:21 +0100 > Adrián Larumbe 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 >> Closes: https://gitlab.freedesktop.org/panfrost/linux/-/work_items/88 >> Signed-off-by: Adrián Larumbe >> 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), > I have to admit I prefer Boris' version ;) But either way: Reviewed-by: Steven Price >> status->current_frequency / 1000 / 1000); >> >> return 0; >> >