* [PATCH] drm/mgag200: Apply upper limit for clock variable
@ 2024-11-11 13:46 Murad Masimov
2024-11-11 14:02 ` Christophe JAILLET
0 siblings, 1 reply; 2+ messages in thread
From: Murad Masimov @ 2024-11-11 13:46 UTC (permalink / raw)
To: Dave Airlie
Cc: Murad Masimov, Thomas Zimmermann, Jocelyn Falempe,
Maarten Lankhorst, Maxime Ripard, David Airlie, Simona Vetter,
dri-devel, linux-kernel, lvc-project
If the value of the clock variable is higher than 800000, the value of the
variable m, which is used as a divisor, will remain zero, because
(clock * testp) will be higher than vcomax in every loop iteration, which
leads to skipping every iteration and leaving variable m unmodified.
Clamp value of the clock variable to the upper limit, the same way it's done
with the lower limit.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 877507bb954e ("drm/mgag200: Provide per-device callbacks for PIXPLLC")
Signed-off-by: Murad Masimov <m.masimov@maxima.ru>
---
drivers/gpu/drm/mgag200/mgag200_g200se.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/mgag200/mgag200_g200se.c b/drivers/gpu/drm/mgag200/mgag200_g200se.c
index 7a32d3b1d226..69402a591f59 100644
--- a/drivers/gpu/drm/mgag200/mgag200_g200se.c
+++ b/drivers/gpu/drm/mgag200/mgag200_g200se.c
@@ -218,6 +218,8 @@ static int mgag200_g200se_04_pixpllc_atomic_check(struct drm_crtc *crtc,
if (clock < 25000)
clock = 25000;
+ else if (clock > 800000)
+ clock = 800000;
clock = clock * 2;
/* Permited delta is 0.5% as VESA Specification */
--
2.39.2
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] drm/mgag200: Apply upper limit for clock variable
2024-11-11 13:46 [PATCH] drm/mgag200: Apply upper limit for clock variable Murad Masimov
@ 2024-11-11 14:02 ` Christophe JAILLET
0 siblings, 0 replies; 2+ messages in thread
From: Christophe JAILLET @ 2024-11-11 14:02 UTC (permalink / raw)
To: Murad Masimov, Dave Airlie
Cc: Thomas Zimmermann, Jocelyn Falempe, Maarten Lankhorst,
Maxime Ripard, David Airlie, Simona Vetter, dri-devel,
linux-kernel, lvc-project
Le 11/11/2024 à 14:46, Murad Masimov a écrit :
> If the value of the clock variable is higher than 800000, the value of the
> variable m, which is used as a divisor, will remain zero, because
> (clock * testp) will be higher than vcomax in every loop iteration, which
> leads to skipping every iteration and leaving variable m unmodified.
>
> Clamp value of the clock variable to the upper limit, the same way it's done
> with the lower limit.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: 877507bb954e ("drm/mgag200: Provide per-device callbacks for PIXPLLC")
> Signed-off-by: Murad Masimov <m.masimov@maxima.ru>
> ---
> drivers/gpu/drm/mgag200/mgag200_g200se.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/mgag200/mgag200_g200se.c b/drivers/gpu/drm/mgag200/mgag200_g200se.c
> index 7a32d3b1d226..69402a591f59 100644
> --- a/drivers/gpu/drm/mgag200/mgag200_g200se.c
> +++ b/drivers/gpu/drm/mgag200/mgag200_g200se.c
> @@ -218,6 +218,8 @@ static int mgag200_g200se_04_pixpllc_atomic_check(struct drm_crtc *crtc,
>
> if (clock < 25000)
> clock = 25000;
> + else if (clock > 800000)
> + clock = 800000;
Maybe:
clock = clamp(clock, 25000, 800000);
to be less verbose?
CJ
> clock = clock * 2;
>
> /* Permited delta is 0.5% as VESA Specification */
> --
> 2.39.2
>
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-11-11 14:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-11 13:46 [PATCH] drm/mgag200: Apply upper limit for clock variable Murad Masimov
2024-11-11 14:02 ` Christophe JAILLET
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®