From: Ivan Djelic <ivan.djelic@parrot.com>
To: Brian Norris <computersforpeace@gmail.com>
Cc: "dedekind1@gmail.com" <dedekind1@gmail.com>,
"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
Jesper Nilsson <jespern@axis.com>,
Johan Gunnarsson <johan.gunnarsson@axis.com>
Subject: Re: [PATCH 2/2] mtd: nand: use hrtimer to measure timeout in nand_wait{_ready, }
Date: Wed, 23 May 2012 10:36:00 +0200 [thread overview]
Message-ID: <20120523083600.GA4201@parrot.com> (raw)
In-Reply-To: <CAN8TOE90vWS713_vKNwkBDMBPbEiz10R0oiawnRVgmTYFRPh0g@mail.gmail.com>
On Wed, May 23, 2012 at 07:39:51AM +0100, Brian Norris wrote:
(...)
> >> > Can we simplify this function and assume everyone has "dev_ready()" and
> >> > add BUG_ON(!chip->dev_ready) - could you make a small research ? Or can
> >>
> >> The drivers/mtd/nand/h1910.c driver sets dev_ready to NULL on init. The others seem to have dev_ready implementations.
>
> Not true: there are several drivers which do not have dev_ready, but
> this is also because they are controller-based, so they provide their
> own cmdfunc as well, mostly avoiding the nand_wait_ready stuff.
> (Drivers: denali.c, docg4.c, my out-of-tree driver, ...)
>
> Note: another use of nand_wait_ready is in nand_do_read_ops and
> nand_do_read_oob, under the following condition:
> if (!(chip->options & NAND_NO_READRDY)) {
> Isn't NAND_NO_READRDY no longer needed, since I killed autoincrement?
> (i.e., we *always* "do not support autoincrement", as its comment says
> in nand.h) So if we kill this option, we can kill the only use of
> nand_wait_ready outside of cmdfunc(); this brings us closer to being
> able to using BUG_ON(!chip->dev_ready). I'll send a patch for this,
> and you guys can comment.
Agreed.
> >> Actually, it's worse than that. If dev_ready is NULL (as in the h1910.c case) we'll crash the kernel, right?
>
> No, I don't think so. It looks like nand_wait_ready is never called
> when dev_ready is NULL.
True, but since nand_wait_ready() is a public function, it could be called from a driver that has (dev_ready == NULL), resulting in a crash.
So all drivers must make sure they define dev_ready if they are going to call nand_wait_ready() (like cafe_nand.c).
(...)
>
> > * the udelay() fallback should probably be phased out if only one driver (h1910) depends on it because it does not define chip->dev_ready() ?
>
> Clarification: only one driver does leaves both chip->dev_ready and
> chip->cmdfunc NULL, right?
Yes, exactly. I meant that we could get rid of the udelay in the default chip->cmdfunc implementations (nand_command and nand_command_lp).
In other words, if chip->cmdfunc == NULL, we require chip->dev_ready != NULL. And move the existing udelay in an implementation of chip->dev_ready for the h1910 driver.
> Feel free to send a patch; it's probably easier to talk more
> concretely about a patch that implements your (seemingly reasonable)
> suggestions, and then provide comments based on concrete ideas.
Will do,
Thanks,
--
Ivan
next prev parent reply other threads:[~2012-05-23 8:36 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-21 8:42 [PATCH 0/2] use hrtimer in nand_wait Johan Gunnarsson
2012-05-21 8:42 ` [PATCH 1/2] mtd: nand: panic_nand_wait expects timeout in ms Johan Gunnarsson
2012-05-21 8:42 ` [PATCH 2/2] mtd: nand: use hrtimer to measure timeout in nand_wait{_ready, } Johan Gunnarsson
2012-05-22 7:53 ` Artem Bityutskiy
2012-05-22 8:52 ` Johan Gunnarsson
2012-05-22 10:25 ` Artem Bityutskiy
2012-05-22 14:24 ` Johan Gunnarsson
2012-05-22 17:10 ` Ivan Djelic
2012-05-22 18:21 ` Artem Bityutskiy
2012-05-23 6:39 ` Brian Norris
2012-05-23 8:36 ` Ivan Djelic [this message]
2012-05-23 8:14 ` Johan Gunnarsson
2012-05-22 7:23 ` [PATCH 0/2] use hrtimer in nand_wait Artem Bityutskiy
2012-05-22 8:37 ` Johan Gunnarsson
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=20120523083600.GA4201@parrot.com \
--to=ivan.djelic@parrot.com \
--cc=computersforpeace@gmail.com \
--cc=dedekind1@gmail.com \
--cc=jespern@axis.com \
--cc=johan.gunnarsson@axis.com \
--cc=linux-mtd@lists.infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).