From: Artem Bityutskiy <dedekind1@gmail.com>
To: Johan Gunnarsson <johan.gunnarsson@axis.com>,
Brian Norris <computersforpeace@gmail.com>
Cc: linux-mtd@lists.infradead.org, jespern@axis.com
Subject: Re: [PATCH 2/2] mtd: nand: use hrtimer to measure timeout in nand_wait{_ready, }
Date: Tue, 22 May 2012 10:53:10 +0300 [thread overview]
Message-ID: <1337673190.2483.115.camel@sauron.fi.intel.com> (raw)
In-Reply-To: <1337589758-8775-3-git-send-email-johan.gunnarsson@axis.com>
[-- Attachment #1: Type: text/plain, Size: 1787 bytes --]
On Mon, 2012-05-21 at 10:42 +0200, Johan Gunnarsson wrote:
> @@ -533,19 +541,29 @@ static void panic_nand_wait_ready(struct mtd_info *mtd, unsigned long timeo)
> void nand_wait_ready(struct mtd_info *mtd)
> {
> struct nand_chip *chip = mtd->priv;
> - unsigned long timeo = jiffies + 2;
> + struct hrtimer timer;
>
> /* 400ms timeout */
> if (in_interrupt() || oops_in_progress)
> return panic_nand_wait_ready(mtd, 400);
>
> led_trigger_event(nand_led_trigger, LED_FULL);
> +
> + /* Arm timeout timer for 20ms timeout */
> + hrtimer_init(&timer, CLOCK_REALTIME, HRTIMER_MODE_REL);
> + timer.function = nand_wait_timeout_callback;
> + hrtimer_start(&timer, ns_to_ktime(20 * 1000 * 1000),
> + HRTIMER_MODE_REL);
> +
> /* Wait until command is processed or timeout occurs */
> do {
> if (chip->dev_ready(mtd))
> break;
> touch_softlockup_watchdog();
> - } while (time_before(jiffies, timeo));
Si this function waits for the chip, but if we cannot access the "ready"
pin - it waits for 400msecs? Where this number 400 comes from? Why not
500? How many chips we have which do not provide "dev_ready()" function?
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
we do like this:
if (!dev_ready()) {
msleep(400);
return
}
do {
} while
Why should we iterate if "dev_ready" is NULL?
My point is that this stuff ancient horror which needs love and cleaning
up. Your does not make it less scary. I'd prefer to first clean the
whole thing up, and then fix it.
I'm CCing Brian who spent a lot of time digging nand_base.c recently, he
has probably got some ideas.
--
Best Regards,
Artem Bityutskiy
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2012-05-22 7:49 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 [this message]
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
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=1337673190.2483.115.camel@sauron.fi.intel.com \
--to=dedekind1@gmail.com \
--cc=computersforpeace@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.