linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: drm/exynos: scaler: Reset hardware before starting the operation (bug report)
@ 2019-07-05 16:09 ` Colin Ian King
  2019-07-22 17:05   ` Marek Szyprowski
  0 siblings, 1 reply; 2+ messages in thread
From: Colin Ian King @ 2019-07-05 16:09 UTC (permalink / raw)
  To: Andrzej Pietrasiewicz, Marek Szyprowski, Inki Dae, linux-samsung-soc
  Cc: linux-kernel

Hi,

Static analysis on today's linux-next has found a potential error in the
following commit:

commit 280e54c9f614c88292685383cf2d65057586e9fb
Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Date:   Thu Jun 7 13:06:08 2018 +0200

    drm/exynos: scaler: Reset hardware before starting the operation

In the following code the retry counter does not appear to be
decremented, so potentially the loop could get stuck forever if the H/W
does not change state:

static inline int scaler_reset(struct scaler_context *scaler)
{
        int retry = SCALER_RESET_WAIT_RETRIES;

        scaler_write(SCALER_CFG_SOFT_RESET, SCALER_CFG);
        do {
                cpu_relax();
        } 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);

        return retry ? 0 : -EIO;
}

Maybe I'm missing something here subtle.

Colin

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: drm/exynos: scaler: Reset hardware before starting the operation (bug report)
  2019-07-05 16:09 ` drm/exynos: scaler: Reset hardware before starting the operation (bug report) Colin Ian King
@ 2019-07-22 17:05   ` Marek Szyprowski
  0 siblings, 0 replies; 2+ messages in thread
From: Marek Szyprowski @ 2019-07-22 17:05 UTC (permalink / raw)
  To: Colin Ian King, Andrzej Pietrasiewicz, Inki Dae, linux-samsung-soc
  Cc: linux-kernel

Hi,

On 2019-07-05 18:09, Colin Ian King wrote:
> Static analysis on today's linux-next has found a potential error in the
> following commit:
>
> commit 280e54c9f614c88292685383cf2d65057586e9fb
> Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
> Date:   Thu Jun 7 13:06:08 2018 +0200
>
>      drm/exynos: scaler: Reset hardware before starting the operation
>
> In the following code the retry counter does not appear to be
> decremented, so potentially the loop could get stuck forever if the H/W
> does not change state:
>
> static inline int scaler_reset(struct scaler_context *scaler)
> {
>          int retry = SCALER_RESET_WAIT_RETRIES;
>
>          scaler_write(SCALER_CFG_SOFT_RESET, SCALER_CFG);
>          do {
>                  cpu_relax();
>          } 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);
>
>          return retry ? 0 : -EIO;
> }
>
> Maybe I'm missing something here subtle.

Right. Indeed there is missing decrementation of the 'retry' variable. I 
suggest to add it to both loops and reset retry value to 
SCALER_RESET_WAIT_RETRIES between them.

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-22 17:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20190705160911epcas2p2754c2c703cc6086f7f1715e1840deb1b@epcas2p2.samsung.com>
2019-07-05 16:09 ` drm/exynos: scaler: Reset hardware before starting the operation (bug report) Colin Ian King
2019-07-22 17:05   ` Marek Szyprowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).