public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>,
	dwmw2@infradead.org, matthias.bgg@gmail.com, robh@kernel.org,
	daniel.thompson@linaro.org, xiaolei.li@mediatek.com,
	linux-mtd@lists.infradead.org
Subject: Re: [PATCH 2/3] mtd: mediatek: driver for MTK Smart Device Gen1 NAND
Date: Tue, 8 Mar 2016 10:17:15 -0800	[thread overview]
Message-ID: <20160308181715.GJ55664@google.com> (raw)
In-Reply-To: <20160308172437.6eccce05@bbrezillon>

On Tue, Mar 08, 2016 at 05:24:37PM +0100, Boris Brezillon wrote:
> On Wed,  2 Mar 2016 12:00:12 -0500
> Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org> wrote:
> > +static void mtk_nfc_hw_reset(struct mtk_nfc_host *host)
> > +{
> > +	unsigned long timeout = MTK_RESET_TIMEOUT;
> > +	struct device *dev = host->dev;
> > +	u32 val;
> > +
> > +	/* reset the state machine, data fifo and fdm data */
> > +	mtk_nfi_writel(host, CON_FIFO_FLUSH | CON_NFI_RST, MTKSDG1_NFI_CON);
> > +	timeout += jiffies;
> > +	do {
> > +		val = mtk_nfi_readl(host, MTKSDG1_NFI_MASTER_STA);
> > +		val &= MASTER_STA_MASK;
> > +		if (!val)
> > +			return;
> > +		usleep_range(50, 100);
> > +
> > +	} while (time_before(jiffies, timeout));
> 
> You may want to use readl_relaxed_poll_timeout() (even though there's
> no way to specify a range).
> This comment applies to all the places where you're implementing this
> kind of loop.

What's more, this timeout loop (and probably many of the others) is
wrong. You need to do one last status check before declaring a timeout,
since the device may become ready while you're sleeping. It's the same
problem as we've resolved here:

http://git.infradead.org/l2-mtd.git/commitdiff/9ebfdf5b18493f338237ef9861a555c2f79b0c17
Subject: "mtd: nand: check status before reporting timeout"

readl_relaxed_poll_timeout() gets this right, of course.

> > +
> > +	dev_warn(dev, "nfi master active after in reset [0x%x] = 0x%x\n",
> > +		MTKSDG1_NFI_MASTER_STA, val);
> > +};

While we're at it: you have a stray semicolon after your function
definition.

Brian

  parent reply	other threads:[~2016-03-08 18:17 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-02 17:00 [RFC PATCH 0/3] MTK Smart Device Gen1 NAND support Jorge Ramirez-Ortiz
2016-03-02 17:00 ` [PATCH 1/3] mtd: mediatek: device tree docs for MTK Smart Device Gen1 NAND Jorge Ramirez-Ortiz
2016-03-08 15:00   ` Boris Brezillon
2016-03-08 18:19     ` Brian Norris
2016-03-08 15:15   ` Boris Brezillon
2016-03-02 17:00 ` [PATCH 2/3] mtd: mediatek: driver " Jorge Ramirez-Ortiz
2016-03-08 16:24   ` Boris Brezillon
2016-03-08 17:17     ` Jorge Ramirez-Ortiz
2016-03-08 18:17     ` Brian Norris [this message]
2016-03-08 20:08       ` Jorge Ramirez-Ortiz
2016-03-08 20:20         ` Brian Norris
2016-03-08 20:57           ` Jorge Ramirez-Ortiz
2016-03-08 21:22             ` Brian Norris
2016-03-08 22:02               ` Jorge Ramirez-Ortiz
2016-03-09 10:00             ` Boris Brezillon
2016-03-09 20:01     ` Jorge Ramirez-Ortiz
2016-03-09 20:43       ` Boris Brezillon
2016-03-18 14:00         ` Jorge Ramirez-Ortiz
2016-03-18 14:24           ` Boris Brezillon
2016-03-15 12:28     ` Jorge Ramirez-Ortiz
2016-03-15 12:59       ` Boris Brezillon
2016-03-15 13:21         ` Jorge Ramirez-Ortiz
2016-03-15 13:53           ` Boris Brezillon
2016-03-02 17:00 ` [PATCH 3/3] mtd: mediatek: device tree enable NAND in MTK's 2701 evb Jorge Ramirez-Ortiz

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=20160308181715.GJ55664@google.com \
    --to=computersforpeace@gmail.com \
    --cc=boris.brezillon@free-electrons.com \
    --cc=daniel.thompson@linaro.org \
    --cc=dwmw2@infradead.org \
    --cc=jorge.ramirez-ortiz@linaro.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=robh@kernel.org \
    --cc=xiaolei.li@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