diff mbox

drm/exynos: fimd: harden fimd_calc_clkdiv()

Message ID 1462465418-3769-1-git-send-email-tjakobi@math.uni-bielefeld.de (mailing list archive)
State Not Applicable
Headers show

Commit Message

Tobias Jakobi May 5, 2016, 4:23 p.m. UTC
Don't use the vrefresh field of the DRM mode since this
one is supposed to only be used for debug purpose.
Instead use the clock field which should also provide
much more precise information.

Also sanitize the case in which the clock value
should be zero. We then just default to the maximum
clock divisor.

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
---
 drivers/gpu/drm/exynos/exynos_drm_fimd.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Andrzej Hajda May 6, 2016, 5:44 a.m. UTC | #1
Hi Tobias,

On 05/05/2016 06:23 PM, Tobias Jakobi wrote:
> Don't use the vrefresh field of the DRM mode since this
> one is supposed to only be used for debug purpose.
> Instead use the clock field which should also provide
> much more precise information.
>
> Also sanitize the case in which the clock value
> should be zero. We then just default to the maximum
> clock divisor.
>
> Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>

Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
--
Regards
Andrzej
> ---
>  drivers/gpu/drm/exynos/exynos_drm_fimd.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> index 57020f9..9d4cae4 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> @@ -367,9 +367,16 @@ static void fimd_clear_channels(struct exynos_drm_crtc *crtc)
>  static u32 fimd_calc_clkdiv(struct fimd_context *ctx,
>  		const struct drm_display_mode *mode)
>  {
> -	unsigned long ideal_clk = mode->htotal * mode->vtotal * mode->vrefresh;
> +	unsigned long ideal_clk;
>  	u32 clkdiv;
>  
> +	if (mode->clock == 0) {
> +		DRM_ERROR("Mode has zero clock value.\n");
> +		return 0xff;
> +	}
> +
> +	ideal_clk = mode->clock * 1000;
> +
>  	if (ctx->i80_if) {
>  		/*
>  		 * The frame done interrupt should be occurred prior to the

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index 57020f9..9d4cae4 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -367,9 +367,16 @@  static void fimd_clear_channels(struct exynos_drm_crtc *crtc)
 static u32 fimd_calc_clkdiv(struct fimd_context *ctx,
 		const struct drm_display_mode *mode)
 {
-	unsigned long ideal_clk = mode->htotal * mode->vtotal * mode->vrefresh;
+	unsigned long ideal_clk;
 	u32 clkdiv;
 
+	if (mode->clock == 0) {
+		DRM_ERROR("Mode has zero clock value.\n");
+		return 0xff;
+	}
+
+	ideal_clk = mode->clock * 1000;
+
 	if (ctx->i80_if) {
 		/*
 		 * The frame done interrupt should be occurred prior to the