Re: [PATCH AUTOSEL 5.2 51/59] drm/exynos: fix missing decrement of retry counter

2019-08-17 Thread Sasha Levin

On Wed, Aug 07, 2019 at 08:49:52AM +, David Laight wrote:

From: Sasha Levin

Sent: 06 August 2019 22:33

From: Colin Ian King 

[ Upstream commit 1bbbab097a05276e312dd2462791d32b21ceb1ee ]

Currently the retry counter is not being decremented, leading to a
potential infinite spin if the scalar_reads don't change state.

Addresses-Coverity: ("Infinite loop")
Fixes: 280e54c9f614 ("drm/exynos: scaler: Reset hardware before starting the 
operation")
Signed-off-by: Colin Ian King 
Signed-off-by: Inki Dae 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/exynos/exynos_drm_scaler.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_scaler.c 
b/drivers/gpu/drm/exynos/exynos_drm_scaler.c
index ec9c1b7d31033..8989f8af716b7 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_scaler.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_scaler.c
@@ -94,12 +94,12 @@ static inline int scaler_reset(struct scaler_context 
*scaler)
scaler_write(SCALER_CFG_SOFT_RESET, SCALER_CFG);
do {
cpu_relax();
-   } while (retry > 1 &&
+   } while (--retry > 1 &&
 scaler_read(SCALER_CFG) & SCALER_CFG_SOFT_RESET);
do {
cpu_relax();
scaler_write(1, SCALER_INT_EN);
-   } while (retry > 0 && scaler_read(SCALER_INT_EN) != 1);
+   } while (--retry > 0 && scaler_read(SCALER_INT_EN) != 1);

return retry ? 0 : -EIO;


If the first loop hits the retry limit the second loop won't be right
and the final return value will be 0.


This looks like an upstream problem as well, no?

--
Thanks,
Sasha
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

RE: [PATCH AUTOSEL 5.2 51/59] drm/exynos: fix missing decrement of retry counter

2019-08-07 Thread David Laight
From: Sasha Levin
> Sent: 06 August 2019 22:33
> 
> From: Colin Ian King 
> 
> [ Upstream commit 1bbbab097a05276e312dd2462791d32b21ceb1ee ]
> 
> Currently the retry counter is not being decremented, leading to a
> potential infinite spin if the scalar_reads don't change state.
> 
> Addresses-Coverity: ("Infinite loop")
> Fixes: 280e54c9f614 ("drm/exynos: scaler: Reset hardware before starting the 
> operation")
> Signed-off-by: Colin Ian King 
> Signed-off-by: Inki Dae 
> Signed-off-by: Sasha Levin 
> ---
>  drivers/gpu/drm/exynos/exynos_drm_scaler.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_scaler.c 
> b/drivers/gpu/drm/exynos/exynos_drm_scaler.c
> index ec9c1b7d31033..8989f8af716b7 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_scaler.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_scaler.c
> @@ -94,12 +94,12 @@ static inline int scaler_reset(struct scaler_context 
> *scaler)
>   scaler_write(SCALER_CFG_SOFT_RESET, SCALER_CFG);
>   do {
>   cpu_relax();
> - } while (retry > 1 &&
> + } while (--retry > 1 &&
>scaler_read(SCALER_CFG) & SCALER_CFG_SOFT_RESET);
>   do {
>   cpu_relax();
>   scaler_write(1, SCALER_INT_EN);
> - } while (retry > 0 && scaler_read(SCALER_INT_EN) != 1);
> + } while (--retry > 0 && scaler_read(SCALER_INT_EN) != 1);
> 
>   return retry ? 0 : -EIO;

If the first loop hits the retry limit the second loop won't be right
and the final return value will be 0.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, 
UK
Registration No: 1397386 (Wales)