* [PATCH] drm/msm: Avoid rounding up to one jiffy
@ 2025-01-09 23:07 Rob Clark
2025-01-13 10:33 ` Akhil P Oommen
0 siblings, 1 reply; 2+ messages in thread
From: Rob Clark @ 2025-01-09 23:07 UTC (permalink / raw)
To: dri-devel
Cc: freedreno, linux-arm-msm, Rob Clark, Rob Clark, Abhinav Kumar,
Dmitry Baryshkov, Sean Paul, Marijn Suijten, David Airlie,
Simona Vetter, open list
From: Rob Clark <robdclark@chromium.org>
If userspace is trying to achieve a timeout of zero, let 'em have it.
Only round up if the timeout is greater than zero.
Fixes: 4969bccd5f4e ("drm/msm: Avoid rounding down to zero jiffies")
Signed-off-by: Rob Clark <robdclark@chromium.org>
---
drivers/gpu/drm/msm/msm_drv.h | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index fee31680a6d5..451d258b9827 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -537,16 +537,14 @@ static inline int align_pitch(int width, int bpp)
static inline unsigned long timeout_to_jiffies(const ktime_t *timeout)
{
ktime_t now = ktime_get();
- s64 remaining_jiffies;
- if (ktime_compare(*timeout, now) < 0) {
- remaining_jiffies = 0;
+ if (ktime_compare(*timeout, now) <= 0) {
+ return 0;
} else {
ktime_t rem = ktime_sub(*timeout, now);
- remaining_jiffies = ktime_divns(rem, NSEC_PER_SEC / HZ);
+ s64 remaining_jiffies = ktime_divns(rem, NSEC_PER_SEC / HZ);
+ return clamp(remaining_jiffies, 1LL, (s64)INT_MAX);
}
-
- return clamp(remaining_jiffies, 1LL, (s64)INT_MAX);
}
/* Driver helpers */
--
2.47.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/msm: Avoid rounding up to one jiffy
2025-01-09 23:07 [PATCH] drm/msm: Avoid rounding up to one jiffy Rob Clark
@ 2025-01-13 10:33 ` Akhil P Oommen
0 siblings, 0 replies; 2+ messages in thread
From: Akhil P Oommen @ 2025-01-13 10:33 UTC (permalink / raw)
To: Rob Clark, dri-devel
Cc: freedreno, linux-arm-msm, Rob Clark, Abhinav Kumar,
Dmitry Baryshkov, Sean Paul, Marijn Suijten, David Airlie,
Simona Vetter, open list
On 1/10/2025 4:37 AM, Rob Clark wrote:
> From: Rob Clark <robdclark@chromium.org>
>
> If userspace is trying to achieve a timeout of zero, let 'em have it.
> Only round up if the timeout is greater than zero.
>
> Fixes: 4969bccd5f4e ("drm/msm: Avoid rounding down to zero jiffies")
> Signed-off-by: Rob Clark <robdclark@chromium.org>
> ---
> drivers/gpu/drm/msm/msm_drv.h | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
> index fee31680a6d5..451d258b9827 100644
> --- a/drivers/gpu/drm/msm/msm_drv.h
> +++ b/drivers/gpu/drm/msm/msm_drv.h
> @@ -537,16 +537,14 @@ static inline int align_pitch(int width, int bpp)
> static inline unsigned long timeout_to_jiffies(const ktime_t *timeout)
> {
> ktime_t now = ktime_get();
> - s64 remaining_jiffies;
>
> - if (ktime_compare(*timeout, now) < 0) {
> - remaining_jiffies = 0;
> + if (ktime_compare(*timeout, now) <= 0) {
> + return 0;
> } else {
For readability, we can now remove 'else' block and de-nest rest of the
code.
-Akhil
> ktime_t rem = ktime_sub(*timeout, now);
> - remaining_jiffies = ktime_divns(rem, NSEC_PER_SEC / HZ);
> + s64 remaining_jiffies = ktime_divns(rem, NSEC_PER_SEC / HZ);
> + return clamp(remaining_jiffies, 1LL, (s64)INT_MAX);
> }
> -
> - return clamp(remaining_jiffies, 1LL, (s64)INT_MAX);
> }
>
> /* Driver helpers */
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-13 10:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-09 23:07 [PATCH] drm/msm: Avoid rounding up to one jiffy Rob Clark
2025-01-13 10:33 ` Akhil P Oommen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox