From: Nick Hu <nickhu@andestech.com>
To: "Greentime Ying-Han Hu(胡英漢)" <greentime@andestech.com>,
"palmer@sifive.com" <palmer@sifive.com>,
"albert@sifive.com" <albert@sifive.com>,
"linux-riscv@lists.infradead.org"
<linux-riscv@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"hch@infradead.org" <hch@infradead.org>
Cc: "green.hu@gmail.com" <green.hu@gmail.com>
Subject: Re: [PATCH v2] riscv: Fix udelay in RV32.
Date: Thu, 30 May 2019 14:54:36 +0800 [thread overview]
Message-ID: <20190530065436.GA15137@andestech.com> (raw)
In-Reply-To: <67a14915b99ee5d933ef9e7e056fc6e1935e775e.1559198255.git.nickhu@andestech.com>
On Thu, May 30, 2019 at 02:49:10PM +0800, Nick Chun-Ming Hu(胡峻銘) wrote:
> In RV32, udelay would delay the wrong cycle. When it shifts right
> "UDELAY_SHITFT" bits, it either delays 0 cycle or 1 cycle. It only works
> correctly in RV64. Because the 'ucycles' always needs to be 64 bits
> variable.
>
> Signed-off-by: Nick Hu <nickhu@andestech.com>
> ---
> arch/riscv/lib/delay.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/lib/delay.c b/arch/riscv/lib/delay.c
> index dce8ae24c6d3..ee6853c1e341 100644
> --- a/arch/riscv/lib/delay.c
> +++ b/arch/riscv/lib/delay.c
> @@ -88,7 +88,7 @@ EXPORT_SYMBOL(__delay);
>
> void udelay(unsigned long usecs)
> {
> - unsigned long ucycles = usecs * lpj_fine * UDELAY_MULT;
> + u64 ucycles = (u64)usecs * lpj_fine * UDELAY_MULT;
>
> if (unlikely(usecs > MAX_UDELAY_US)) {
> __delay((u64)usecs * riscv_timebase / 1000000ULL);
> --
> 2.17.0
>
Hi All, I forgot to add "Reviewed-by: Palmer Dabbelt <palmer@sifive.com>".
I will send another patch.
Sorry.
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
prev parent reply other threads:[~2019-05-30 6:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-30 6:49 [PATCH v2] riscv: Fix udelay in RV32 Nick Hu
2019-05-30 6:54 ` Nick Hu [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=20190530065436.GA15137@andestech.com \
--to=nickhu@andestech.com \
--cc=albert@sifive.com \
--cc=green.hu@gmail.com \
--cc=greentime@andestech.com \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@sifive.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;
as well as URLs for NNTP newsgroup(s).