public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
Cc: Boris Brezillon <boris.brezillon@free-electrons.com>,
	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 13:22:40 -0800	[thread overview]
Message-ID: <20160308212240.GM55664@google.com> (raw)
In-Reply-To: <56DF3CC8.7070400@linaro.org>

Hi Jorge,

On Tue, Mar 08, 2016 at 03:57:44PM -0500, Jorge Ramirez-Ortiz wrote:
> On 03/08/2016 03:20 PM, Brian Norris wrote:
> >> > If you feel strongly about it I don't mind adding an additional check after any
> >> > form of sleep (not so sure about adding it after a cpu_relax) but I don't think
> >> > it is needed.
> > It is non-negotiable that your timeout loops must be logically correct.
> > That is, you must recheck the exit condition before you declare a
> > timeout.
> 
> Hi Brian,
> 
> My point was that the current timeout loops (except one which is just
> implementing its own version of readx_poll_timeout) are logically correct as
> they are since they are not involving the scheduler: so doing the additional
> check after cpu_relax() is unnecessary - cpu_relax is a dmb instruction.

No, they're not correct just because you're not invoking the scheduler
directly. What about CONFIG_PREEMPT?

> > If you just follow Boris's suggestion of using the helper macros, then
> > you'll be fine.
> 
> I am sorry (not trying to be difficult here) but relaxed_poll_timeout calls
> usleep_range and involving the scheduler brings in a level of undeterminism (so
> we could have slept for 100 useconds or 1000)
> am I wrong? is under that case that we need to check after exiting the loop.

Just bound sleep_us to the largest amount of nondeterminism you can
accept. And that number can be 0.

> a different discussion is if using cpu_relax (busy loop) at all is a good idea:
> the way I see it, that should depend on the case but I suppose a silver bullet
> solution via the helper macros is ok too - and certainly more readable and
> easier to maintain - so will do as you suggest (correct all loops).

I'm not specifically saying you must use those helpers, but you have to
get your timeout loops correct. And given the confusion so far, it looks
like it's reasonable to assume we'd get fewer bugs if you used the
helpers...

Brian

  reply	other threads:[~2016-03-08 21:23 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
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 [this message]
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=20160308212240.GM55664@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