From: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
To: Eric Miao <eric.y.miao@gmail.com>
Cc: linux-mtd@lists.infradead.org, mreimer@vpop.net,
dwmw2@infradead.org, dedekind1@gmail.com
Subject: Re: [PATCH] pxa3xx_nand: fix time calculation
Date: Mon, 12 Oct 2009 12:03:58 +0200 [thread overview]
Message-ID: <ly3a5p6i9d.fsf@ensc-virt.intern.sigma-chemnitz.de> (raw)
In-Reply-To: <f17812d70910112022g63c60438jca2a0e47944813a5@mail.gmail.com> (Eric Miao's message of "Mon, 12 Oct 2009 11:22:32 +0800")
Eric Miao <eric.y.miao@gmail.com> writes:
>>> Use DIV_ROUND_UP to calculate number of clocks. Else, calculated clocks
>>> are nearly always to low and for times < 10ns, they will be negative on
>>> PXA320 (which has a nand clock of 104 MHz).
>>>
>>> -#define ns2cycle(ns, clk) (int)(((ns) * (clk / 1000000) / 1000) - 1)
>>> +#define ns2cycle(ns, clk) (int)(DIV_ROUND_UP((ns) * (clk / 1000000), 1000) - 1)
>>
>> Why there is -1 at the end?
> ...
> I'd recommend we remove this '-1' to always make the final result
> a little bit larger and avoid the negative case. DIV_ROUND_UP() is
> kind of confusing here, since the original equation is:
>
> cycles = ns / (1/clk * 10^9) = ns * clk / 10^9
Hi Eric,
for me, the DIV_ROUND_UP() is more clean, because 'ns' are minimum
values given on the datasheet and you have to round up fractional cycle
counts hence. But I agree that
| #define ns2cycle(ns, clk) (int)(DIV_ROUND_UP((ns) * (clk / 1000000), 1000) - 1)
and
| #define ns2cycle(ns, clk) (int)(((ns) * (clk / 1000000) / 1000))
give same results for most values. I do not have a strong preference
for one of these two variants.
> Could you please verify that removing '-1' will solve all corner
> cases?
Except for overflows (which are uninteresting here), timings which are
a multiple of 1000ns are the only corner cases. And these will result
into cycle counts which are increased by 1 compared to their ideal
value.
Enrico
prev parent reply other threads:[~2009-10-12 10:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-07 9:31 [PATCH] pxa3xx_nand: fix time calculation Enrico Scholz
2009-10-11 12:51 ` Artem Bityutskiy
2009-10-12 3:22 ` Eric Miao
2009-10-12 10:03 ` Enrico Scholz [this message]
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=ly3a5p6i9d.fsf@ensc-virt.intern.sigma-chemnitz.de \
--to=enrico.scholz@sigma-chemnitz.de \
--cc=dedekind1@gmail.com \
--cc=dwmw2@infradead.org \
--cc=eric.y.miao@gmail.com \
--cc=linux-mtd@lists.infradead.org \
--cc=mreimer@vpop.net \
/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