linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marek Behun <marek.behun@nic.cz>
To: Guenter Roeck <linux@roeck-us.net>
Cc: linux-watchdog@vger.kernel.org, wim@linux-watchdog.org
Subject: Re: [PATCH 1/2] watchdog: Add support for Armada 37xx CPU watchdog
Date: Thu, 30 Aug 2018 20:50:04 +0200	[thread overview]
Message-ID: <20180830205004.6fe9858f@nic.cz> (raw)
In-Reply-To: <20180830204223.391d6066@nic.cz>

> > > +static u64 get_counter_value(struct armada_37xx_watchdog *dev)
> > > +{
> > > +	u64 val;
> > > +
> > > +	val = readl(dev->reg + CNTR_COUNT_HIGH);
> > > +	val = (val << 32) | readl(dev->reg + CNTR_COUNT_LOW);    
> > 
> > Is this guaranteed to be consistent ? What happens if there is a
> > 32-bit wrap between those two operations ?  
> 
> hmmm. The address is not divisible by 8, so I can't use readq :( what
> do you propose?

What do you think of this solution?

u64 val;
u32 low1, low2;

low1 = readl(dev->reg + CNTR_COUNT_LOW);
val = readl(dev->reg + CNTR_COUNT_HIGH);
low2 = readl(dev->reg + CNTR_COUNT_LOW);

/*
 * If low jumped in this short time more than 2^31, a wrap probably
 * occured. Read high again.
 */
if (low2 - low1 > 0x80000000)
	val = readl(dev->reg + CNTR_COUNT_HIGH);
val = (val << 32) | low2;

  reply	other threads:[~2018-08-30 18:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-30 14:22 [PATCH 1/2] watchdog: Add support for Armada 37xx CPU watchdog Marek Behún
2018-08-30 14:22 ` [PATCH 2/2] arm64: dts: marvell: armada-37xx: add nodes to support watchdog Marek Behún
2018-08-30 14:28 ` [PATCH 1/2] watchdog: Add support for Armada 37xx CPU watchdog Marek Behun
2018-08-30 14:40   ` Guenter Roeck
2018-08-30 16:28 ` Guenter Roeck
2018-08-30 18:42   ` Marek Behun
2018-08-30 18:50     ` Marek Behun [this message]
2018-08-30 19:12       ` Guenter Roeck
2018-09-01  0:29         ` Marek Behun
2018-09-01  0:47           ` Guenter Roeck
2018-09-02 20:12             ` Marek Behun
2018-09-03  0:55               ` Guenter Roeck
2018-08-30 19:07     ` Guenter Roeck

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=20180830205004.6fe9858f@nic.cz \
    --to=marek.behun@nic.cz \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=wim@linux-watchdog.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).