public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: kernel-janitors@vger.kernel.org, dri-devel@lists.freedesktop.org,
	Matthias Brugger <matthias.bgg@gmail.com>,
	linux-mediatek@lists.infradead.org,
	shaoming chen <shaoming.chen@mediatek.com>
Subject: Re: [PATCH] drm/mediatek: fix a loop timeout
Date: Thu, 20 Apr 2017 11:05:05 +0000	[thread overview]
Message-ID: <1492686305.2158.51.camel@pengutronix.de> (raw)
In-Reply-To: <20170420102423.5yqe6uwohaeleyyl@mwanda>

Hi Dan,

On Thu, 2017-04-20 at 13:24 +0300, Dan Carpenter wrote:
> We expected to end with "timeout_ms" set to zero, but it's a post-op so
> the current code ends with -1.  Let's fix this by changing it to a
> pre-op.
> 
> Fixes: 21898816831f ("drm/mediatek: add dsi transfer function")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Indeed without this patch the timeout error path is only ever chosen if
the busy bit happened to flip exactly in the last iteration of the loop.

Acked-by: Philipp Zabel <p.zabel@pengutronix.de>

> diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
> index 808b995a990f..3a0b6d1057a2 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dsi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
> @@ -902,7 +902,7 @@ static void mtk_dsi_wait_for_idle(struct mtk_dsi *dsi)
>  {
>  	u32 timeout_ms = 500000; /* total 1s ~ 2s timeout */
>  
> -	while (timeout_ms--) {
> +	while (--timeout_ms) {
>  		if (!(readl(dsi->regs + DSI_INTSTA) & DSI_BUSY))
>  			break;
>  
> 

Instead of just calling usleep_range(2, 4) up to 500000 times in this
open coded loop, this should be replaced with a single call to
readl_poll_timeout() though.

regards
Philipp


  reply	other threads:[~2017-04-20 11:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-20 10:24 [PATCH] drm/mediatek: fix a loop timeout Dan Carpenter
2017-04-20 11:05 ` Philipp Zabel [this message]
2017-04-20 11:53   ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1492686305.2158.51.camel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=dan.carpenter@oracle.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=shaoming.chen@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox