All of lore.kernel.org
 help / color / mirror / Atom feed
From: Biju Das <biju.das@bp.renesas.com>
To: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Thomas Gleixner <tglx@linutronix.de>
Cc: Simon Horman <horms@verge.net.au>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Chris Paterson <Chris.Paterson2@renesas.com>,
	Fabrizio Castro <fabrizio.castro@bp.renesas.com>,
	"linux-renesas-soc@vger.kernel.org"
	<linux-renesas-soc@vger.kernel.org>
Subject: RE: [PATCH] clocksource/drivers/sh_cmt: wait for CMCNT on init
Date: Mon, 11 Jun 2018 10:42:09 +0000	[thread overview]
Message-ID: <OSBPR01MB210349939FB878315FD11D1EB8780@OSBPR01MB2103.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <OSBPR01MB21038E08CD17E7E071EC381AB8780@OSBPR01MB2103.jpnprd01.prod.outlook.com>

> > Subject: Re: [PATCH] clocksource/drivers/sh_cmt: wait for CMCNT on
> > > diff --git a/drivers/clocksource/sh_cmt.c
> > > b/drivers/clocksource/sh_cmt.c index 70b3cf8..48910df 100644
> > > --- a/drivers/clocksource/sh_cmt.c
> > > +++ b/drivers/clocksource/sh_cmt.c
> > > @@ -328,7 +328,7 @@ static void sh_cmt_start_stop_ch(struct
> > > sh_cmt_channel *ch, int start)
> > >
> > >   static int sh_cmt_enable(struct sh_cmt_channel *ch)
> > >   {
> > > -int k, ret;
> > > +int j, k, ret;
> > >
> > >   pm_runtime_get_sync(&ch->cmt->pdev->dev);
> > >   dev_pm_syscore_device(&ch->cmt->pdev->dev, true); @@ -368,11
> > > +368,17 @@ static int sh_cmt_enable(struct sh_cmt_channel *ch)
> > >    * While at it, we're supposed to clear out the CMCNT as of this
> > >    * moment, so make sure it's processed properly here.  This will
> > >    * take RCLKx2 at maximum.
> > > + *
> > > + * Similar register access usage for CMCNT is mentioned in R-Car
> > > + * Gen[2/3]/RZ/G1 user's manual, RCLKx2 for cmt0 and RCLKx2 or
> > > + * CPϕx2 (CPEXϕx2)) for cmt1.
> > >    */
> > > -for (k = 0; k < 100; k++) {
> > > -if (!sh_cmt_read_cmcnt(ch))
> > > -break;
> > > -udelay(1);
> > > +for (j = 0; j < 2; j++) {
> > > +for (k = 0; k < 100; k++) {
> >
> >     Why not simply count to 200 ISO 100?>

That also works. It needs delay more than 100.
The worst case wait is around 130-150 microseconds.

Previously, I have put a print statement just before break statement during debugging.

> This issue is related to settling of CMCNT register during init.
>
> During my testing, I found that the first loop exit immediately before actually
> settling this register value to "0". ie, the instantaneous value of register
> becomes "0" in the first check and it breaks the first loop and in the next
> check report the error.
>
> The new logic is to double check this register value and make sure that this
> register value is settled to "0", before starting the timer channel.
>
> Regards,
> Biju




Renesas Electronics Europe Ltd, Dukes Meadow, Millboard Road, Bourne End, Buckinghamshire, SL8 5FH, UK. Registered in England & Wales under Registered No. 04586709.

  reply	other threads:[~2018-06-11 10:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-08 16:19 [PATCH] clocksource/drivers/sh_cmt: wait for CMCNT on init Biju Das
2018-06-09  9:08 ` Sergei Shtylyov
2018-06-11  8:28   ` Biju Das
2018-06-11 10:42     ` Biju Das [this message]
2018-06-11  7:16 ` Geert Uytterhoeven
2018-06-11 11:21   ` Biju Das
2018-06-11 11:41     ` Geert Uytterhoeven
2018-06-11 14:36       ` Biju Das
2018-10-09 13:01         ` Biju Das
2018-10-10  8:55           ` Geert Uytterhoeven
2018-10-10  9:50             ` Biju Das
2018-10-10 11:06               ` Geert Uytterhoeven

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=OSBPR01MB210349939FB878315FD11D1EB8780@OSBPR01MB2103.jpnprd01.prod.outlook.com \
    --to=biju.das@bp.renesas.com \
    --cc=Chris.Paterson2@renesas.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=fabrizio.castro@bp.renesas.com \
    --cc=geert+renesas@glider.be \
    --cc=horms@verge.net.au \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=sergei.shtylyov@cogentembedded.com \
    --cc=tglx@linutronix.de \
    /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.