[PATCH] drm: rcar-du: dsi: Fix hsfreq range matching

Kieran Bingham kieran.bingham+renesas at ideasonboard.com
Mon Dec 6 15:36:59 UTC 2021


Quoting Laurent Pinchart (2021-12-06 14:06:01)
> When iterating over hsfreqrange_table, rcar_mipi_dsi_parameters_calc()
> may dereference the sentinel table entry. Fix the loop condition to
> break as soon as a suitable entry is found, defined by the lower bound
> of the frequency range stored in the table being equal to or higher than
> the target frequency.
> 
> Reported-by: kernel test robot <lkp at intel.com>
> Reported-by: Dan Carpenter <dan.carpenter at oracle.com>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas at ideasonboard.com>
> ---
> I will squash this with "drm: rcar-du: Add R-Car DSI driver", but I'm
> posting it separately to ease review.
> ---
>  drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> index faf993eae564..891bb956fd61 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> @@ -219,9 +219,8 @@ static void rcar_mipi_dsi_parameters_calc(struct rcar_mipi_dsi *dsi,
>         /* Find hsfreqrange */
>         hsfreq = fout_target * 2;
>         for (i = 0; i < ARRAY_SIZE(hsfreqrange_table); i++) {
> -               if (hsfreq > hsfreqrange_table[i][0] &&
> -                       hsfreq <= hsfreqrange_table[i+1][0]) {
> -                       setup_info->hsfreqrange = hsfreqrange_table[i+1][1];
> +               if (hsfreqrange_table[i][0] >= hsfreq) {

It's hard to tell from this patch, or this point alone, but I see that
fout_target is already limited at 1250000000, so hsfreq can never be
bigger than 2500000000U.

So ... this is fine (as long as the table and validation check are kept
in sync if anyone updates this).

Reviewed-by: Kieran Bingham <kieran.bingham+renesas at ideasonboard.com>

Also validated that it still boots/probes and displays pictures with
kmstest and kmstest --flip.

--
Kieran


> +                       setup_info->hsfreqrange = hsfreqrange_table[i][1];
>                         break;
>                 }
>         }
> 
> base-commit: c18c8891111bb5e014e144716044991112f16833
> prerequisite-patch-id: dc9121a1b85ea05bf3eae2b0ac2168d47101ee87
> prerequisite-patch-id: 6754b2ec4caec03e235550004003fe63c1cc793b
> prerequisite-patch-id: d69c605df34d40934fa5d4e00f23d5785105099d
> prerequisite-patch-id: 7d9edfb4758cafe8aec92d32709c0ad25a50942c
> prerequisite-patch-id: 86c526fb41f9f9cbe95c50ba8a140e20484f187f
> prerequisite-patch-id: a9649b53b55858f023b8d3d29afb9be7ad39ea3b
> -- 
> Regards,
> 
> Laurent Pinchart
>


More information about the dri-devel mailing list